]> Cypherpunks repositories - gostls13.git/commitdiff
gofmt-ify nacl
authorRobert Griesemer <gri@golang.org>
Thu, 5 Nov 2009 22:29:38 +0000 (14:29 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 5 Nov 2009 22:29:38 +0000 (14:29 -0800)
R=rsc
http://go/go-review/1018062

src/pkg/exp/nacl/av/av.go
src/pkg/exp/nacl/av/event.go
src/pkg/exp/nacl/av/image.go
src/pkg/exp/nacl/srpc/client.go
src/pkg/exp/nacl/srpc/msg.go
src/pkg/exp/nacl/srpc/server.go

index 9adc582fd48612bbc25b8f81a70fa2479687bfbf..4c63125527bec4ff2f8c169af1b7355d5a09ef50 100644 (file)
@@ -21,13 +21,13 @@ import (
        "unsafe";
 )
 
-var srpcEnabled = srpc.Enabled();
+var srpcEnabled = srpc.Enabled()
 
 // native_client/src/trusted/service_runtime/include/sys/audio_video.h
 
 // Subsystem values for Init.
 const (
-       SubsystemVideo = 1<<iota;
+       SubsystemVideo  = 1<<iota;
        SubsystemAudio;
        SubsystemEmbed;
 )
@@ -35,20 +35,20 @@ const (
 
 // Audio formats.
 const (
-       AudioFormatStereo44K = iota;
+       AudioFormatStereo44K    = iota;
        AudioFormatStereo48K;
 )
 
 // A Window represents a connection to the Native Client window.
 // It implements draw.Context.
 type Window struct {
-       Embedded bool;  // running as part of a web page?
-       *Image;         // screen image
+       Embedded        bool;   // running as part of a web page?
+       *Image;                 // screen image
 
-       mousec chan draw.Mouse;
-       kbdc chan int;
-       quitc chan bool;
-       resizec chan bool;
+       mousec  chan draw.Mouse;
+       kbdc    chan int;
+       quitc   chan bool;
+       resizec chan bool;
 }
 
 // *Window implements draw.Context
@@ -89,7 +89,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
        xsubsys := subsys;
        if srpcEnabled {
                waitBridge();
-               xsubsys &^= SubsystemVideo|SubsystemEmbed;
+               xsubsys &^= SubsystemVideo | SubsystemEmbed;
        }
 
        if xsubsys & SubsystemEmbed != 0 {
@@ -102,7 +102,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
                return nil, err;
        }
 
-       if subsys&SubsystemVideo != 0 {
+       if subsys & SubsystemVideo != 0 {
                if dx, dy, err = videoInit(dx, dy); err != nil {
                        return nil, err;
                }
@@ -113,7 +113,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
                w.quitc = make(chan bool);
        }
 
-       if subsys&SubsystemAudio != 0 {
+       if subsys & SubsystemAudio != 0 {
                var n int;
                if n, err = audioInit(AudioFormatStereo44K, 2048); err != nil {
                        return nil, err;
@@ -121,7 +121,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
                println("audio", n);
        }
 
-       if subsys&SubsystemVideo != 0 {
+       if subsys & SubsystemVideo != 0 {
                go w.readEvents();
        }
 
@@ -158,7 +158,7 @@ func videoUpdate(data []Color) (err os.Error) {
        return os.NewSyscallError("video_update", syscall.VideoUpdate((*uint32)(&data[0])));
 }
 
-var noEvents = os.NewError("no events");
+var noEvents = os.NewError("no events")
 
 func videoPollEvent(ev []byte) (err os.Error) {
        if srpcEnabled {
@@ -167,7 +167,7 @@ func videoPollEvent(ev []byte) (err os.Error) {
                        return noEvents;
                }
                bytes.Copy(ev, &bridge.share.eq.event[r]);
-               bridge.share.eq.ri = (r+1) % eqsize;
+               bridge.share.eq.ri = (r+1)%eqsize;
                return nil;
        }
        return os.NewSyscallError("video_poll_event", syscall.VideoPollEvent(&ev[0]));
@@ -209,13 +209,13 @@ func AudioStream(data []uint16) (nextSize int, err os.Error) {
 
 // Synchronization structure to wait for bridge to become ready.
 var bridge struct {
-       c chan bool;
-       displayFd int;
-       rpcFd int;
-       share *videoShare;
-       pixel []Color;
-       client *srpc.Client;
-       flushRPC *srpc.RPC;
+       c               chan bool;
+       displayFd       int;
+       rpcFd           int;
+       share           *videoShare;
+       pixel           []Color;
+       client          *srpc.Client;
+       flushRPC        *srpc.RPC;
 }
 
 // Wait for bridge to become ready.
@@ -227,27 +227,27 @@ func waitBridge() {
        bridge.c <- <-bridge.c;
 }
 
-const eqsize = 64;
+const eqsize = 64
 
 // Data structure shared with host via mmap.
 type videoShare struct {
-       revision int32; // definition below is rev 100 unless noted
-       mapSize int32;
+       revision        int32;  // definition below is rev 100 unless noted
+       mapSize         int32;
 
        // event queue
-       eq struct {
-               ri uint32;      // read index [0,eqsize)
-               wi uint32;      // write index [0,eqsize)
-               eof int32;
-               event [eqsize][64]byte;
+       eq      struct {
+               ri      uint32; // read index [0,eqsize)
+               wi      uint32; // write index [0,eqsize)
+               eof     int32;
+               event   [eqsize][64]byte;
        };
 
        // now unused
-       _, _, _, _ int32;
+       _, _, _, _      int32;
 
        // video backing store information
-       width, height, _, size int32;
-       ready int32;    // rev 0x101
+       width, height, _, size  int32;
+       ready                   int32;  // rev 0x101
 }
 
 // The frame buffer data is videoShareSize bytes after
@@ -271,7 +271,7 @@ func (multimediaBridge) Run(arg, ret []interface{}, size []int) srpc.Errno {
        addr, _, errno := syscall.Syscall6(syscall.SYS_MMAP,
                0,
                uintptr(st.Size),
-               syscall.PROT_READ|syscall.PROT_WRITE,
+               syscall.PROT_READ | syscall.PROT_WRITE,
                syscall.MAP_SHARED,
                uintptr(bridge.displayFd),
                0);
@@ -284,8 +284,8 @@ func (multimediaBridge) Run(arg, ret []interface{}, size []int) srpc.Errno {
        // Overestimate frame buffer size
        // (must use a compile-time constant)
        // and then reslice.  256 megapixels (1 GB) should be enough.
-       fb := (*[256*1024*1024]Color)(unsafe.Pointer(addr+videoShareSize));
-       bridge.pixel = fb[0:(st.Size - videoShareSize)/4];
+       fb := (*[256*1024*1024]Color)(unsafe.Pointer(addr + videoShareSize));
+       bridge.pixel = fb[0 : (st.Size - videoShareSize)/4];
 
        // Configure RPC connection back to client.
        var err os.Error;
@@ -308,4 +308,3 @@ func init() {
                srpc.Add("nacl_multimedia_bridge", "hh:", multimediaBridge{});
        }
 }
-
index 32b73badc07f9f52f3008616acacbf432031da1c..0b70b7e9c2ef4b11d31f2a7501e148f7b323ecaf 100644 (file)
@@ -19,9 +19,10 @@ import (
 )
 
 // An eventType identifies the type of a Native Client Event.
-type eventType uint8;
+type eventType uint8
+
 const (
-       eventActive = 1+iota;
+       eventActive     = 1+iota;
        eventExpose;
        eventKeyDown;
        eventKeyUp;
@@ -34,299 +35,301 @@ const (
 
 // A key represents a key on a keyboard.
 type key uint16
+
 const (
-       keyUnknown      = 0;
-       keyFirst        = 0;
-       keyBackspace    = 8;
-       keyTab          = 9;
-       keyClear        = 12;
-       keyReturn       = 13;
-       keyPause        = 19;
-       keyEscape       = 27;
-       keySpace        = 32;
-       keyExclaim      = 33;
-       keyQuotedbl     = 34;
-       keyHash         = 35;
-       keyDollar       = 36;
-       keyAmpersand    = 38;
-       keyQuote        = 39;
-       keyLeftparen    = 40;
-       keyRightparen   = 41;
-       keyAsterisk     = 42;
-       keyPlus         = 43;
-       keyComma        = 44;
-       keyMinus        = 45;
-       keyPeriod       = 46;
-       keySlash        = 47;
-       key0            = 48;
-       key1            = 49;
-       key2            = 50;
-       key3            = 51;
-       key4            = 52;
-       key5            = 53;
-       key6            = 54;
-       key7            = 55;
-       key8            = 56;
-       key9            = 57;
-       keyColon        = 58;
-       keySemicolon    = 59;
-       keyLess         = 60;
-       keyEquals       = 61;
-       keyGreater      = 62;
-       keyQuestion     = 63;
-       keyAt           = 64;
-       keyLeftbracket  = 91;
-       keyBackslash    = 92;
-       keyRightbracket = 93;
-       keyCaret        = 94;
-       keyUnderscore   = 95;
-       keyBackquote    = 96;
-       keyA            = 97;
-       keyB            = 98;
-       keyC            = 99;
-       keyD            = 100;
-       keyE            = 101;
-       keyF            = 102;
-       keyG            = 103;
-       keyH            = 104;
-       keyI            = 105;
-       keyJ            = 106;
-       keyK            = 107;
-       keyL            = 108;
-       keyM            = 109;
-       keyN            = 110;
-       keyO            = 111;
-       keyP            = 112;
-       keyQ            = 113;
-       keyR            = 114;
-       keyS            = 115;
-       keyT            = 116;
-       keyU            = 117;
-       keyV            = 118;
-       keyW            = 119;
-       keyX            = 120;
-       keyY            = 121;
-       keyZ            = 122;
-       keyDelete       = 127;
-       keyWorld0      = 160;
-       keyWorld1      = 161;
-       keyWorld2      = 162;
-       keyWorld3      = 163;
-       keyWorld4      = 164;
-       keyWorld5      = 165;
-       keyWorld6      = 166;
-       keyWorld7      = 167;
-       keyWorld8      = 168;
-       keyWorld9      = 169;
-       keyWorld10     = 170;
-       keyWorld11     = 171;
-       keyWorld12     = 172;
-       keyWorld13     = 173;
-       keyWorld14     = 174;
-       keyWorld15     = 175;
-       keyWorld16     = 176;
-       keyWorld17     = 177;
-       keyWorld18     = 178;
-       keyWorld19     = 179;
-       keyWorld20     = 180;
-       keyWorld21     = 181;
-       keyWorld22     = 182;
-       keyWorld23     = 183;
-       keyWorld24     = 184;
-       keyWorld25     = 185;
-       keyWorld26     = 186;
-       keyWorld27     = 187;
-       keyWorld28     = 188;
-       keyWorld29     = 189;
-       keyWorld30     = 190;
-       keyWorld31     = 191;
-       keyWorld32     = 192;
-       keyWorld33     = 193;
-       keyWorld34     = 194;
-       keyWorld35     = 195;
-       keyWorld36     = 196;
-       keyWorld37     = 197;
-       keyWorld38     = 198;
-       keyWorld39     = 199;
-       keyWorld40     = 200;
-       keyWorld41     = 201;
-       keyWorld42     = 202;
-       keyWorld43     = 203;
-       keyWorld44     = 204;
-       keyWorld45     = 205;
-       keyWorld46     = 206;
-       keyWorld47     = 207;
-       keyWorld48     = 208;
-       keyWorld49     = 209;
-       keyWorld50     = 210;
-       keyWorld51     = 211;
-       keyWorld52     = 212;
-       keyWorld53     = 213;
-       keyWorld54     = 214;
-       keyWorld55     = 215;
-       keyWorld56     = 216;
-       keyWorld57     = 217;
-       keyWorld58     = 218;
-       keyWorld59     = 219;
-       keyWorld60     = 220;
-       keyWorld61     = 221;
-       keyWorld62     = 222;
-       keyWorld63     = 223;
-       keyWorld64     = 224;
-       keyWorld65     = 225;
-       keyWorld66     = 226;
-       keyWorld67     = 227;
-       keyWorld68     = 228;
-       keyWorld69     = 229;
-       keyWorld70     = 230;
-       keyWorld71     = 231;
-       keyWorld72     = 232;
-       keyWorld73     = 233;
-       keyWorld74     = 234;
-       keyWorld75     = 235;
-       keyWorld76     = 236;
-       keyWorld77     = 237;
-       keyWorld78     = 238;
-       keyWorld79     = 239;
-       keyWorld80     = 240;
-       keyWorld81     = 241;
-       keyWorld82     = 242;
-       keyWorld83     = 243;
-       keyWorld84     = 244;
-       keyWorld85     = 245;
-       keyWorld86     = 246;
-       keyWorld87     = 247;
-       keyWorld88     = 248;
-       keyWorld89     = 249;
-       keyWorld90     = 250;
-       keyWorld91     = 251;
-       keyWorld92     = 252;
-       keyWorld93     = 253;
-       keyWorld94     = 254;
-       keyWorld95     = 255;
+       keyUnknown      = 0;
+       keyFirst        = 0;
+       keyBackspace    = 8;
+       keyTab          = 9;
+       keyClear        = 12;
+       keyReturn       = 13;
+       keyPause        = 19;
+       keyEscape       = 27;
+       keySpace        = 32;
+       keyExclaim      = 33;
+       keyQuotedbl     = 34;
+       keyHash         = 35;
+       keyDollar       = 36;
+       keyAmpersand    = 38;
+       keyQuote        = 39;
+       keyLeftparen    = 40;
+       keyRightparen   = 41;
+       keyAsterisk     = 42;
+       keyPlus         = 43;
+       keyComma        = 44;
+       keyMinus        = 45;
+       keyPeriod       = 46;
+       keySlash        = 47;
+       key0            = 48;
+       key1            = 49;
+       key2            = 50;
+       key3            = 51;
+       key4            = 52;
+       key5            = 53;
+       key6            = 54;
+       key7            = 55;
+       key8            = 56;
+       key9            = 57;
+       keyColon        = 58;
+       keySemicolon    = 59;
+       keyLess         = 60;
+       keyEquals       = 61;
+       keyGreater      = 62;
+       keyQuestion     = 63;
+       keyAt           = 64;
+       keyLeftbracket  = 91;
+       keyBackslash    = 92;
+       keyRightbracket = 93;
+       keyCaret        = 94;
+       keyUnderscore   = 95;
+       keyBackquote    = 96;
+       keyA            = 97;
+       keyB            = 98;
+       keyC            = 99;
+       keyD            = 100;
+       keyE            = 101;
+       keyF            = 102;
+       keyG            = 103;
+       keyH            = 104;
+       keyI            = 105;
+       keyJ            = 106;
+       keyK            = 107;
+       keyL            = 108;
+       keyM            = 109;
+       keyN            = 110;
+       keyO            = 111;
+       keyP            = 112;
+       keyQ            = 113;
+       keyR            = 114;
+       keyS            = 115;
+       keyT            = 116;
+       keyU            = 117;
+       keyV            = 118;
+       keyW            = 119;
+       keyX            = 120;
+       keyY            = 121;
+       keyZ            = 122;
+       keyDelete       = 127;
+       keyWorld0       = 160;
+       keyWorld1       = 161;
+       keyWorld2       = 162;
+       keyWorld3       = 163;
+       keyWorld4       = 164;
+       keyWorld5       = 165;
+       keyWorld6       = 166;
+       keyWorld7       = 167;
+       keyWorld8       = 168;
+       keyWorld9       = 169;
+       keyWorld10      = 170;
+       keyWorld11      = 171;
+       keyWorld12      = 172;
+       keyWorld13      = 173;
+       keyWorld14      = 174;
+       keyWorld15      = 175;
+       keyWorld16      = 176;
+       keyWorld17      = 177;
+       keyWorld18      = 178;
+       keyWorld19      = 179;
+       keyWorld20      = 180;
+       keyWorld21      = 181;
+       keyWorld22      = 182;
+       keyWorld23      = 183;
+       keyWorld24      = 184;
+       keyWorld25      = 185;
+       keyWorld26      = 186;
+       keyWorld27      = 187;
+       keyWorld28      = 188;
+       keyWorld29      = 189;
+       keyWorld30      = 190;
+       keyWorld31      = 191;
+       keyWorld32      = 192;
+       keyWorld33      = 193;
+       keyWorld34      = 194;
+       keyWorld35      = 195;
+       keyWorld36      = 196;
+       keyWorld37      = 197;
+       keyWorld38      = 198;
+       keyWorld39      = 199;
+       keyWorld40      = 200;
+       keyWorld41      = 201;
+       keyWorld42      = 202;
+       keyWorld43      = 203;
+       keyWorld44      = 204;
+       keyWorld45      = 205;
+       keyWorld46      = 206;
+       keyWorld47      = 207;
+       keyWorld48      = 208;
+       keyWorld49      = 209;
+       keyWorld50      = 210;
+       keyWorld51      = 211;
+       keyWorld52      = 212;
+       keyWorld53      = 213;
+       keyWorld54      = 214;
+       keyWorld55      = 215;
+       keyWorld56      = 216;
+       keyWorld57      = 217;
+       keyWorld58      = 218;
+       keyWorld59      = 219;
+       keyWorld60      = 220;
+       keyWorld61      = 221;
+       keyWorld62      = 222;
+       keyWorld63      = 223;
+       keyWorld64      = 224;
+       keyWorld65      = 225;
+       keyWorld66      = 226;
+       keyWorld67      = 227;
+       keyWorld68      = 228;
+       keyWorld69      = 229;
+       keyWorld70      = 230;
+       keyWorld71      = 231;
+       keyWorld72      = 232;
+       keyWorld73      = 233;
+       keyWorld74      = 234;
+       keyWorld75      = 235;
+       keyWorld76      = 236;
+       keyWorld77      = 237;
+       keyWorld78      = 238;
+       keyWorld79      = 239;
+       keyWorld80      = 240;
+       keyWorld81      = 241;
+       keyWorld82      = 242;
+       keyWorld83      = 243;
+       keyWorld84      = 244;
+       keyWorld85      = 245;
+       keyWorld86      = 246;
+       keyWorld87      = 247;
+       keyWorld88      = 248;
+       keyWorld89      = 249;
+       keyWorld90      = 250;
+       keyWorld91      = 251;
+       keyWorld92      = 252;
+       keyWorld93      = 253;
+       keyWorld94      = 254;
+       keyWorld95      = 255;
 
        // Numeric keypad
-       keyKp0          = 256;
-       keyKp1          = 257;
-       keyKp2          = 258;
-       keyKp3          = 259;
-       keyKp4          = 260;
-       keyKp5          = 261;
-       keyKp6          = 262;
-       keyKp7          = 263;
-       keyKp8          = 264;
-       keyKp9          = 265;
-       keyKpPeriod    = 266;
-       keyKpDivide    = 267;
-       keyKpMultiply  = 268;
-       keyKpMinus     = 269;
-       keyKpPlus      = 270;
-       keyKpEnter     = 271;
-       keyKpEquals    = 272;
+       keyKp0          = 256;
+       keyKp1          = 257;
+       keyKp2          = 258;
+       keyKp3          = 259;
+       keyKp4          = 260;
+       keyKp5          = 261;
+       keyKp6          = 262;
+       keyKp7          = 263;
+       keyKp8          = 264;
+       keyKp9          = 265;
+       keyKpPeriod     = 266;
+       keyKpDivide     = 267;
+       keyKpMultiply   = 268;
+       keyKpMinus      = 269;
+       keyKpPlus       = 270;
+       keyKpEnter      = 271;
+       keyKpEquals     = 272;
 
        // Arrow & insert/delete pad
-       keyUp           = 273;
-       keyDown         = 274;
-       keyRight        = 275;
-       keyLeft         = 276;
-       keyInsert       = 277;
-       keyHome         = 278;
-       keyEnd          = 279;
-       keyPageup       = 280;
-       keyPagedown     = 281;
+       keyUp           = 273;
+       keyDown         = 274;
+       keyRight        = 275;
+       keyLeft         = 276;
+       keyInsert       = 277;
+       keyHome         = 278;
+       keyEnd          = 279;
+       keyPageup       = 280;
+       keyPagedown     = 281;
 
        // Function keys
-       keyF1           = 282;
-       keyF2           = 283;
-       keyF3           = 284;
-       keyF4           = 285;
-       keyF5           = 286;
-       keyF6           = 287;
-       keyF7           = 288;
-       keyF8           = 289;
-       keyF9           = 290;
-       keyF10          = 291;
-       keyF11          = 292;
-       keyF12          = 293;
-       keyF13          = 294;
-       keyF14          = 295;
-       keyF15          = 296;
+       keyF1   = 282;
+       keyF2   = 283;
+       keyF3   = 284;
+       keyF4   = 285;
+       keyF5   = 286;
+       keyF6   = 287;
+       keyF7   = 288;
+       keyF8   = 289;
+       keyF9   = 290;
+       keyF10  = 291;
+       keyF11  = 292;
+       keyF12  = 293;
+       keyF13  = 294;
+       keyF14  = 295;
+       keyF15  = 296;
 
        // Modifier keys
-       keyNumlock      = 300;
-       keyCapslock     = 301;
-       keyScrollock    = 302;
-       keyRshift       = 303;
-       keyLshift       = 304;
-       keyRctrl        = 305;
-       keyLctrl        = 306;
-       keyRalt         = 307;
-       keyLalt         = 308;
-       keyRmeta        = 309;
-       keyLmeta        = 310;
-       keyLsuper       = 311;
-       keyRsuper       = 312;
-       keyMode         = 313;
-       keyCompose      = 314;
+       keyNumlock      = 300;
+       keyCapslock     = 301;
+       keyScrollock    = 302;
+       keyRshift       = 303;
+       keyLshift       = 304;
+       keyRctrl        = 305;
+       keyLctrl        = 306;
+       keyRalt         = 307;
+       keyLalt         = 308;
+       keyRmeta        = 309;
+       keyLmeta        = 310;
+       keyLsuper       = 311;
+       keyRsuper       = 312;
+       keyMode         = 313;
+       keyCompose      = 314;
 
        // Misc keys
-       keyHelp         = 315;
-       keyPrint        = 316;
-       keySysreq       = 317;
-       keyBreak        = 318;
-       keyMenu         = 319;
-       keyPower        = 320;
-       keyEuro         = 321;
-       keyUndo         = 322;
+       keyHelp         = 315;
+       keyPrint        = 316;
+       keySysreq       = 317;
+       keyBreak        = 318;
+       keyMenu         = 319;
+       keyPower        = 320;
+       keyEuro         = 321;
+       keyUndo         = 322;
 
        // Add any other keys here
-       keyLast
+       keyLast;
 )
 
 // A keymod is a set of bit flags
 type keymod uint16
+
 const (
-       keymodNone  = 0x0000;
-       keymodLshift= 0x0001;
-       keymodRshift= 0x0002;
-       keymodLctrl = 0x0040;
-       keymodRctrl = 0x0080;
-       keymodLalt  = 0x0100;
-       keymodRalt  = 0x0200;
-       keymodLmeta = 0x0400;
-       keymodRmeta = 0x0800;
-       keymodNum   = 0x1000;
-       keymodCaps  = 0x2000;
-       keymodMode  = 0x4000;
-       keymodReserved = 0x8000
+       keymodNone      = 0x0000;
+       keymodLshift    = 0x0001;
+       keymodRshift    = 0x0002;
+       keymodLctrl     = 0x0040;
+       keymodRctrl     = 0x0080;
+       keymodLalt      = 0x0100;
+       keymodRalt      = 0x0200;
+       keymodLmeta     = 0x0400;
+       keymodRmeta     = 0x0800;
+       keymodNum       = 0x1000;
+       keymodCaps      = 0x2000;
+       keymodMode      = 0x4000;
+       keymodReserved  = 0x8000;
 )
 
 const (
-       mouseButtonLeft = 1;
-       mouseButtonMiddle = 2;
-       mouseButtonRight = 3;
-       mouseScrollUp = 4;
-       mouseScrollDown = 5
+       mouseButtonLeft         = 1;
+       mouseButtonMiddle       = 2;
+       mouseButtonRight        = 3;
+       mouseScrollUp           = 4;
+       mouseScrollDown         = 5;
 )
 
 const (
-       mouseStateLeftButtonPressed = 1;
-       mouseStateMiddleButtonPressed = 2;
-       mouseStateRightButtonPressed = 4
+       mouseStateLeftButtonPressed     = 1;
+       mouseStateMiddleButtonPressed   = 2;
+       mouseStateRightButtonPressed    = 4;
 )
 
 const (
-       activeMouse = 1;        //  mouse leaving/entering
-       activeInputFocus = 2;  // input focus lost/restored
-       activeApplication = 4   // application minimized/restored
+       activeMouse             = 1;    //  mouse leaving/entering
+       activeInputFocus        = 2;    // input focus lost/restored
+       activeApplication       = 4;    // application minimized/restored
 )
 
 const maxEventBytes = 64
 
 type activeEvent struct {
-       EventType eventType;
-       Gain uint8;
-       State uint8;
+       EventType       eventType;
+       Gain            uint8;
+       State           uint8;
 }
 
 type exposeEvent struct {
@@ -334,48 +337,47 @@ type exposeEvent struct {
 }
 
 type keyboardEvent struct {
-       EventType eventType;
-       Device uint8;
-       State uint8;
-       Pad uint8;
-       ScanCode uint8;
-       Pad1 uint8;
-       Key key;
-       Mod keymod;
-       Unicode uint16;
+       EventType       eventType;
+       Device          uint8;
+       State           uint8;
+       Pad             uint8;
+       ScanCode        uint8;
+       Pad1            uint8;
+       Key             key;
+       Mod             keymod;
+       Unicode         uint16;
 }
 
 type mouseMotionEvent struct {
-       EventType eventType;
-       Device uint8;
-       Buttons uint8;
-       Pad uint8;
-       X uint16;
-       Y uint16;
-       Xrel int16;
-       Yrel int16;
+       EventType       eventType;
+       Device          uint8;
+       Buttons         uint8;
+       Pad             uint8;
+       X               uint16;
+       Y               uint16;
+       Xrel            int16;
+       Yrel            int16;
 }
 
 type mouseButtonEvent struct {
-       EventType eventType;
-       Device uint8;
-       Button uint8;
-       State uint8;
-       X uint16;
-       Y uint16;
+       EventType       eventType;
+       Device          uint8;
+       Button          uint8;
+       State           uint8;
+       X               uint16;
+       Y               uint16;
 }
 
 type quitEvent struct {
        EventType eventType;
 }
 
-type syncEvent struct {
-}
+type syncEvent struct{}
 
-type event interface {
-}
+type event interface{}
 
 type reader []byte
+
 func (r *reader) Read(p []byte) (n int, err os.Error) {
        b := *r;
        if len(b) == 0 && len(p) > 0 {
@@ -390,12 +392,12 @@ func (w *Window) readEvents() {
        buf := make([]byte, maxEventBytes);
        clean := false;
        var (
-               ea *activeEvent;
-               ee *exposeEvent;
-               ke *keyboardEvent;
-               mme *mouseMotionEvent;
-               mbe *mouseButtonEvent;
-               qe *quitEvent;
+               ea      *activeEvent;
+               ee      *exposeEvent;
+               ke      *keyboardEvent;
+               mme     *mouseMotionEvent;
+               mbe     *mouseButtonEvent;
+               qe      *quitEvent;
        )
        var m draw.Mouse;
        for {
@@ -439,7 +441,7 @@ func (w *Window) readEvents() {
                // log.Stdoutf("%#v\n", e);
                switch buf[0] {
                case eventExpose:
-                       w.resizec <- true
+                       w.resizec <- true;
                case eventKeyDown:
                        w.kbdc <- int(ke.Key);
                case eventKeyUp:
@@ -454,14 +456,14 @@ func (w *Window) readEvents() {
                        m.X = int(mbe.X);
                        m.Y = int(mbe.Y);
                        // TODO(rsc): Remove uint cast once 8g bug is fixed.
-                       m.Buttons |= 1<<uint(mbe.Button-1);
+                       m.Buttons |= 1<<uint(mbe.Button - 1);
                        m.Nsec = time.Nanoseconds();
                        _ = w.mousec <- m;
                case eventMouseButtonUp:
                        m.X = int(mbe.X);
                        m.Y = int(mbe.Y);
                        // TODO(rsc): Remove uint cast once 8g bug is fixed.
-                       m.Buttons &^= 1<<uint(mbe.Button-1);
+                       m.Buttons &^= 1<<uint(mbe.Button - 1);
                        m.Nsec = time.Nanoseconds();
                        _ = w.mousec <- m;
                case eventQuit:
index 3aee3cad04cce673ba8e4f2eff1bb40b6d4e85ff..8bc8fd07b3902623f364088cf98e67de7f16be0f 100644 (file)
@@ -16,11 +16,11 @@ import (
 // linear slice or as a two-dimensional slice of slices.
 // Image implements image.Image.
 type Image struct {
-       Linear []Color;
-       Pixel [][]Color;
+       Linear  []Color;
+       Pixel   [][]Color;
 }
 
-var _ image.Image = (*Image)(nil);
+var _ image.Image = (*Image)(nil)
 
 func (m *Image) ColorModel() image.ColorModel {
        return ColorModel;
@@ -62,18 +62,19 @@ func newImage(dx, dy int, linear []Color) *Image {
 // A Color represents a Native Client color value,
 // a 32-bit R, G, B, A value packed as 0xAARRGGBB.
 type Color uint32
+
 func (p Color) RGBA() (r, g, b, a uint32) {
        x := uint32(p);
        a = x>>24;
        a |= a<<8;
        a |= a<<16;
-       r = (x>>16) & 0xFF;
+       r = (x>>16)&0xFF;
        r |= r<<8;
        r |= r<<16;
-       g = (x>>8) & 0xFF;
+       g = (x>>8)&0xFF;
        g |= g<<8;
        g |= g<<16;
-       b = x & 0xFF;
+       b = x&0xFF;
        b |= b<<8;
        b |= b<<16;
        return;
@@ -91,5 +92,4 @@ func toColor(color image.Color) image.Color {
 }
 
 // ColorModel is the color model corresponding to the Native Client Color.
-var ColorModel = image.ColorModelFunc(toColor);
-
+var ColorModel = image.ColorModelFunc(toColor)
index 4c375fe2ae69fde653ce25b92bb021bedd520241..1a2d5fdc9c8c990274c17d7719fcd15f10cc1a40 100644 (file)
@@ -14,30 +14,30 @@ import (
 
 // A Client represents the client side of an SRPC connection.
 type Client struct {
-       fd int; // fd to server
-       r msgReceiver;
-       s msgSender;
-       service map[string]srv; // services by name
-       out chan *msg;  // send to out to write to connection
-
-       mu sync.Mutex;  // protects pending, idGen
-       pending map[uint64]*RPC;
-       idGen uint64;   // generator for request IDs
+       fd      int;    // fd to server
+       r       msgReceiver;
+       s       msgSender;
+       service map[string]srv; // services by name
+       out     chan *msg;      // send to out to write to connection
+
+       mu      sync.Mutex;     // protects pending, idGen
+       pending map[uint64]*RPC;
+       idGen   uint64; // generator for request IDs
 }
 
 // A srv is a single method that the server offers.
 type srv struct {
-       num uint32;     // method number
-       fmt string;     // argument format
+       num     uint32; // method number
+       fmt     string; // argument format
 }
 
 // An RPC represents a single RPC issued by a client.
 type RPC struct {
-       Ret []interface{};      // Return values
-       Done chan *RPC; // Channel where notification of done arrives
-       Errno Errno;    // Status code
-       c *Client;
-       id uint64;      // request id
+       Ret     []interface{};  // Return values
+       Done    chan *RPC;      // Channel where notification of done arrives
+       Errno   Errno;          // Status code
+       c       *Client;
+       id      uint64; // request id
 }
 
 // NewClient allocates a new client using the file descriptor fd.
@@ -53,8 +53,8 @@ func NewClient(fd int) (c *Client, err os.Error) {
        m := &msg{
                protocol: protocol,
                isReq: true,
-               Ret: []interface{}{ []byte(nil) },
-               Size: []int{ 4000 },
+               Ret: []interface{}{[]byte(nil)},
+               Size: []int{4000},
        };
        m.packRequest();
        c.s.send(m);
@@ -72,7 +72,7 @@ func NewClient(fd int) (c *Client, err os.Error) {
                if i < 0 {
                        continue;
                }
-               c.service[string(line[0:i])] = srv{uint32(n), string(line[i+1:len(line)])};
+               c.service[string(line[0:i])] = srv{uint32(n), string(line[i+1 : len(line)])};
        }
 
        c.out = make(chan *msg);
@@ -159,11 +159,11 @@ func (r *RPC) Start(name string, arg []interface{}) {
        for srv.fmt[i] != ':' {
                i++;
        }
-       fmt := srv.fmt[i+1:len(srv.fmt)];
+       fmt := srv.fmt[i+1 : len(srv.fmt)];
 
        // Now the return prototypes.
-       m.Ret = make([]interface{}, len(fmt) - i);
-       m.Size = make([]int, len(fmt) - i);
+       m.Ret = make([]interface{}, len(fmt)-i);
+       m.Size = make([]int, len(fmt)-i);
        for i := 0; i < len(fmt); i++ {
                switch fmt[i] {
                default:
index 27fe7212f800b5b03bcd6b66345f1a084be18f97..b0c8041a53bd72d3f488881127245acf1a9e7019 100644 (file)
@@ -17,8 +17,9 @@ import (
 
 // An Errno is an SRPC status code.
 type Errno uint32
+
 const (
-       OK Errno = 256 + iota;
+       OK      Errno   = 256+iota;
        ErrBreak;
        ErrMessageTruncated;
        ErrNoMemory;
@@ -33,27 +34,27 @@ const (
        ErrAppError;
 )
 
-var errstr = [...]string {
+var errstr = [...]string{
        OK-OK: "ok",
        ErrBreak-OK: "break",
-       ErrMessageTruncated-OK: "message truncated",
-       ErrNoMemory-OK: "out of memory",
-       ErrProtocolMismatch-OK: "protocol mismatch",
-       ErrBadRPCNumber-OK: "invalid RPC method number",
-       ErrBadArgType-OK: "unexpected argument type",
-       ErrTooFewArgs-OK: "too few arguments",
-       ErrTooManyArgs-OK: "too many arguments",
-       ErrInArgTypeMismatch-OK: "input argument type mismatch",
-       ErrOutArgTypeMismatch-OK: "output argument type mismatch",
-       ErrInternalError-OK: "internal error",
-       ErrAppError-OK: "application error",
+       ErrMessageTruncated - OK: "message truncated",
+       ErrNoMemory - OK: "out of memory",
+       ErrProtocolMismatch - OK: "protocol mismatch",
+       ErrBadRPCNumber - OK: "invalid RPC method number",
+       ErrBadArgType - OK: "unexpected argument type",
+       ErrTooFewArgs - OK: "too few arguments",
+       ErrTooManyArgs - OK: "too many arguments",
+       ErrInArgTypeMismatch - OK: "input argument type mismatch",
+       ErrOutArgTypeMismatch - OK: "output argument type mismatch",
+       ErrInternalError - OK: "internal error",
+       ErrAppError - OK: "application error",
 }
 
 func (e Errno) String() string {
        if e < OK || int(e-OK) >= len(errstr) {
-               return "Errno(" + strconv.Itoa64(int64(e)) + ")"
+               return "Errno(" + strconv.Itoa64(int64(e)) + ")";
        }
-       return errstr[e - OK];
+       return errstr[e-OK];
 }
 
 // A *msgHdr is the data argument to the imc_recvmsg
@@ -61,45 +62,45 @@ func (e Errno) String() string {
 // counts trusted by the system calls, the data structure is unsafe
 // to expose to package clients.
 type msgHdr struct {
-       iov *iov;
-       niov int32;
-       desc *int32;
-       ndesc int32;
-       flags uint32;
+       iov     *iov;
+       niov    int32;
+       desc    *int32;
+       ndesc   int32;
+       flags   uint32;
 }
 
 // A single region for I/O.  Just as unsafe as msgHdr.
 type iov struct {
-       base *byte;
-       len int32;
+       base    *byte;
+       len     int32;
 }
 
 // A msg is the Go representation of a message.
 type msg struct {
-       rdata []byte;   // data being consumed during message parsing
-       rdesc []int32;  // file descriptors being consumed during message parsing
-       wdata []byte;   // data being generated when replying
+       rdata   []byte;         // data being consumed during message parsing
+       rdesc   []int32;        // file descriptors being consumed during message parsing
+       wdata   []byte;         // data being generated when replying
 
        // parsed version of message
-       protocol uint32;
-       requestId uint64;
-       isReq bool;
-       rpcNumber uint32;
-       gotHeader bool;
-       status Errno;   // error code sent in response
-       Arg []interface{};      // method arguments
-       Ret []interface{};      // method results
-       Size []int;     // max sizes for arrays in method results
-       fmt string;     // accumulated format string of arg+":"+ret
+       protocol        uint32;
+       requestId       uint64;
+       isReq           bool;
+       rpcNumber       uint32;
+       gotHeader       bool;
+       status          Errno;          // error code sent in response
+       Arg             []interface{};  // method arguments
+       Ret             []interface{};  // method results
+       Size            []int;          // max sizes for arrays in method results
+       fmt             string;         // accumulated format string of arg+":"+ret
 }
 
 // A msgReceiver receives messages from a file descriptor.
 type msgReceiver struct {
-       fd int;
-       data [128*1024]byte;
-       desc [8]int32;
-       hdr msgHdr;
-       iov iov;
+       fd      int;
+       data    [128*1024]byte;
+       desc    [8]int32;
+       hdr     msgHdr;
+       iov     iov;
 }
 
 func (r *msgReceiver) recv() (*msg, os.Error) {
@@ -136,10 +137,9 @@ func (r *msgReceiver) recv() (*msg, os.Error) {
 
 // A msgSender sends messages on a file descriptor.
 type msgSender struct {
-       fd int;
-       hdr msgHdr;
-       iov iov;
-
+       fd      int;
+       hdr     msgHdr;
+       iov     iov;
 }
 
 func (s *msgSender) send(m *msg) os.Error {
@@ -222,8 +222,8 @@ func (m *msg) grow(n int) []byte {
                bytes.Copy(a, m.wdata);
                m.wdata = a;
        }
-       m.wdata = m.wdata[0:i+n];
-       return m.wdata[i:i+n];
+       m.wdata = m.wdata[0 : i+n];
+       return m.wdata[i : i+n];
 }
 
 func (m *msg) wuint8(x uint8) {
@@ -529,4 +529,3 @@ func (m *msg) packResponse() {
        m.wuint32(uint32(len(m.Ret)));
        m.packValues(m.Ret);
 }
-
index c4dc0a6c7dfcb2d21cc06200d4adcbaff5ae3a65..984aebeea9df48ffd554dc36970b5e0238d9d45b 100644 (file)
@@ -22,13 +22,13 @@ import (
 // It reads arguments from arg, checks size for array limits,
 // writes return values to ret, and returns an Errno status code.
 type Handler interface {
-       Run(arg, ret []interface{}, size []int) Errno
+       Run(arg, ret []interface{}, size []int) Errno;
 }
 
 type method struct {
-       name string;
-       fmt string;
-       handler Handler;
+       name    string;
+       fmt     string;
+       handler Handler;
 }
 
 var rpcMethod []method
@@ -61,7 +61,7 @@ func Add(name, fmt string, handler Handler) {
                }
                rpcMethod = a;
        }
-       rpcMethod = rpcMethod[0:n+1];
+       rpcMethod = rpcMethod[0 : n+1];
        rpcMethod[n] = method{name, fmt, handler};
 }
 
@@ -175,7 +175,7 @@ func getFd() (fd int, err os.Error) {
 
 // Enabled returns true if SRPC is enabled in the Native Client runtime.
 func Enabled() bool {
-       _, err:= getFd();
+       _, err := getFd();
        return err == nil;
 }
 
@@ -201,4 +201,3 @@ func (serviceDiscovery) Run(arg, ret []interface{}, size []int) Errno {
 func init() {
        Add("service_discovery", ":C", serviceDiscovery{});
 }
-