Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
6238964d
Commit
6238964d
authored
Nov 05, 2009
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt-ify nacl
R=rsc
http://go/go-review/1018062
parent
77334b98
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
62 deletions
+61
-62
av.go
src/pkg/exp/nacl/av/av.go
+11
-12
event.go
src/pkg/exp/nacl/av/event.go
+17
-15
image.go
src/pkg/exp/nacl/av/image.go
+6
-6
client.go
src/pkg/exp/nacl/srpc/client.go
+6
-6
msg.go
src/pkg/exp/nacl/srpc/msg.go
+18
-19
server.go
src/pkg/exp/nacl/srpc/server.go
+3
-4
No files found.
src/pkg/exp/nacl/av/av.go
View file @
6238964d
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"unsafe"
;
"unsafe"
;
)
)
var
srpcEnabled
=
srpc
.
Enabled
()
;
var
srpcEnabled
=
srpc
.
Enabled
()
// native_client/src/trusted/service_runtime/include/sys/audio_video.h
// native_client/src/trusted/service_runtime/include/sys/audio_video.h
...
@@ -89,7 +89,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
...
@@ -89,7 +89,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
xsubsys
:=
subsys
;
xsubsys
:=
subsys
;
if
srpcEnabled
{
if
srpcEnabled
{
waitBridge
();
waitBridge
();
xsubsys
&^=
SubsystemVideo
|
SubsystemEmbed
;
xsubsys
&^=
SubsystemVideo
|
SubsystemEmbed
;
}
}
if
xsubsys
&
SubsystemEmbed
!=
0
{
if
xsubsys
&
SubsystemEmbed
!=
0
{
...
@@ -102,7 +102,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
...
@@ -102,7 +102,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
return
nil
,
err
;
return
nil
,
err
;
}
}
if
subsys
&
SubsystemVideo
!=
0
{
if
subsys
&
SubsystemVideo
!=
0
{
if
dx
,
dy
,
err
=
videoInit
(
dx
,
dy
);
err
!=
nil
{
if
dx
,
dy
,
err
=
videoInit
(
dx
,
dy
);
err
!=
nil
{
return
nil
,
err
;
return
nil
,
err
;
}
}
...
@@ -113,7 +113,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
...
@@ -113,7 +113,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
w
.
quitc
=
make
(
chan
bool
);
w
.
quitc
=
make
(
chan
bool
);
}
}
if
subsys
&
SubsystemAudio
!=
0
{
if
subsys
&
SubsystemAudio
!=
0
{
var
n
int
;
var
n
int
;
if
n
,
err
=
audioInit
(
AudioFormatStereo44K
,
2048
);
err
!=
nil
{
if
n
,
err
=
audioInit
(
AudioFormatStereo44K
,
2048
);
err
!=
nil
{
return
nil
,
err
;
return
nil
,
err
;
...
@@ -121,7 +121,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
...
@@ -121,7 +121,7 @@ func Init(subsys int, dx, dy int) (*Window, os.Error) {
println
(
"audio"
,
n
);
println
(
"audio"
,
n
);
}
}
if
subsys
&
SubsystemVideo
!=
0
{
if
subsys
&
SubsystemVideo
!=
0
{
go
w
.
readEvents
();
go
w
.
readEvents
();
}
}
...
@@ -158,7 +158,7 @@ func videoUpdate(data []Color) (err os.Error) {
...
@@ -158,7 +158,7 @@ func videoUpdate(data []Color) (err os.Error) {
return
os
.
NewSyscallError
(
"video_update"
,
syscall
.
VideoUpdate
((
*
uint32
)(
&
data
[
0
])));
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
)
{
func
videoPollEvent
(
ev
[]
byte
)
(
err
os
.
Error
)
{
if
srpcEnabled
{
if
srpcEnabled
{
...
@@ -167,7 +167,7 @@ func videoPollEvent(ev []byte) (err os.Error) {
...
@@ -167,7 +167,7 @@ func videoPollEvent(ev []byte) (err os.Error) {
return
noEvents
;
return
noEvents
;
}
}
bytes
.
Copy
(
ev
,
&
bridge
.
share
.
eq
.
event
[
r
]);
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
nil
;
}
}
return
os
.
NewSyscallError
(
"video_poll_event"
,
syscall
.
VideoPollEvent
(
&
ev
[
0
]));
return
os
.
NewSyscallError
(
"video_poll_event"
,
syscall
.
VideoPollEvent
(
&
ev
[
0
]));
...
@@ -227,7 +227,7 @@ func waitBridge() {
...
@@ -227,7 +227,7 @@ func waitBridge() {
bridge
.
c
<-
<-
bridge
.
c
;
bridge
.
c
<-
<-
bridge
.
c
;
}
}
const
eqsize
=
64
;
const
eqsize
=
64
// Data structure shared with host via mmap.
// Data structure shared with host via mmap.
type
videoShare
struct
{
type
videoShare
struct
{
...
@@ -271,7 +271,7 @@ func (multimediaBridge) Run(arg, ret []interface{}, size []int) srpc.Errno {
...
@@ -271,7 +271,7 @@ func (multimediaBridge) Run(arg, ret []interface{}, size []int) srpc.Errno {
addr
,
_
,
errno
:=
syscall
.
Syscall6
(
syscall
.
SYS_MMAP
,
addr
,
_
,
errno
:=
syscall
.
Syscall6
(
syscall
.
SYS_MMAP
,
0
,
0
,
uintptr
(
st
.
Size
),
uintptr
(
st
.
Size
),
syscall
.
PROT_READ
|
syscall
.
PROT_WRITE
,
syscall
.
PROT_READ
|
syscall
.
PROT_WRITE
,
syscall
.
MAP_SHARED
,
syscall
.
MAP_SHARED
,
uintptr
(
bridge
.
displayFd
),
uintptr
(
bridge
.
displayFd
),
0
);
0
);
...
@@ -284,8 +284,8 @@ func (multimediaBridge) Run(arg, ret []interface{}, size []int) srpc.Errno {
...
@@ -284,8 +284,8 @@ func (multimediaBridge) Run(arg, ret []interface{}, size []int) srpc.Errno {
// Overestimate frame buffer size
// Overestimate frame buffer size
// (must use a compile-time constant)
// (must use a compile-time constant)
// and then reslice. 256 megapixels (1 GB) should be enough.
// and then reslice. 256 megapixels (1 GB) should be enough.
fb
:=
(
*
[
256
*
1024
*
1024
]
Color
)(
unsafe
.
Pointer
(
addr
+
videoShareSize
));
fb
:=
(
*
[
256
*
1024
*
1024
]
Color
)(
unsafe
.
Pointer
(
addr
+
videoShareSize
));
bridge
.
pixel
=
fb
[
0
:
(
st
.
Size
-
videoShareSize
)
/
4
];
bridge
.
pixel
=
fb
[
0
:
(
st
.
Size
-
videoShareSize
)
/
4
];
// Configure RPC connection back to client.
// Configure RPC connection back to client.
var
err
os
.
Error
;
var
err
os
.
Error
;
...
@@ -308,4 +308,3 @@ func init() {
...
@@ -308,4 +308,3 @@ func init() {
srpc
.
Add
(
"nacl_multimedia_bridge"
,
"hh:"
,
multimediaBridge
{});
srpc
.
Add
(
"nacl_multimedia_bridge"
,
"hh:"
,
multimediaBridge
{});
}
}
}
}
src/pkg/exp/nacl/av/event.go
View file @
6238964d
...
@@ -19,7 +19,8 @@ import (
...
@@ -19,7 +19,8 @@ import (
)
)
// An eventType identifies the type of a Native Client Event.
// An eventType identifies the type of a Native Client Event.
type
eventType
uint8
;
type
eventType
uint8
const
(
const
(
eventActive
=
1
+
iota
;
eventActive
=
1
+
iota
;
eventExpose
;
eventExpose
;
...
@@ -34,6 +35,7 @@ const (
...
@@ -34,6 +35,7 @@ const (
// A key represents a key on a keyboard.
// A key represents a key on a keyboard.
type
key
uint16
type
key
uint16
const
(
const
(
keyUnknown
=
0
;
keyUnknown
=
0
;
keyFirst
=
0
;
keyFirst
=
0
;
...
@@ -280,15 +282,16 @@ const (
...
@@ -280,15 +282,16 @@ const (
keyUndo
=
322
;
keyUndo
=
322
;
// Add any other keys here
// Add any other keys here
keyLast
keyLast
;
)
)
// A keymod is a set of bit flags
// A keymod is a set of bit flags
type
keymod
uint16
type
keymod
uint16
const
(
const
(
keymodNone
=
0x0000
;
keymodNone
=
0x0000
;
keymodLshift
=
0x0001
;
keymodLshift
=
0x0001
;
keymodRshift
=
0x0002
;
keymodRshift
=
0x0002
;
keymodLctrl
=
0x0040
;
keymodLctrl
=
0x0040
;
keymodRctrl
=
0x0080
;
keymodRctrl
=
0x0080
;
keymodLalt
=
0x0100
;
keymodLalt
=
0x0100
;
...
@@ -298,7 +301,7 @@ const (
...
@@ -298,7 +301,7 @@ const (
keymodNum
=
0x1000
;
keymodNum
=
0x1000
;
keymodCaps
=
0x2000
;
keymodCaps
=
0x2000
;
keymodMode
=
0x4000
;
keymodMode
=
0x4000
;
keymodReserved
=
0x8000
keymodReserved
=
0x8000
;
)
)
const
(
const
(
...
@@ -306,19 +309,19 @@ const (
...
@@ -306,19 +309,19 @@ const (
mouseButtonMiddle
=
2
;
mouseButtonMiddle
=
2
;
mouseButtonRight
=
3
;
mouseButtonRight
=
3
;
mouseScrollUp
=
4
;
mouseScrollUp
=
4
;
mouseScrollDown
=
5
mouseScrollDown
=
5
;
)
)
const
(
const
(
mouseStateLeftButtonPressed
=
1
;
mouseStateLeftButtonPressed
=
1
;
mouseStateMiddleButtonPressed
=
2
;
mouseStateMiddleButtonPressed
=
2
;
mouseStateRightButtonPressed
=
4
mouseStateRightButtonPressed
=
4
;
)
)
const
(
const
(
activeMouse
=
1
;
// mouse leaving/entering
activeMouse
=
1
;
// mouse leaving/entering
activeInputFocus
=
2
;
// input focus lost/restored
activeInputFocus
=
2
;
// input focus lost/restored
activeApplication
=
4
// application minimized/restored
activeApplication
=
4
;
// application minimized/restored
)
)
const
maxEventBytes
=
64
const
maxEventBytes
=
64
...
@@ -369,13 +372,12 @@ type quitEvent struct {
...
@@ -369,13 +372,12 @@ type quitEvent struct {
EventType
eventType
;
EventType
eventType
;
}
}
type
syncEvent
struct
{
type
syncEvent
struct
{}
}
type
event
interface
{
type
event
interface
{}
}
type
reader
[]
byte
type
reader
[]
byte
func
(
r
*
reader
)
Read
(
p
[]
byte
)
(
n
int
,
err
os
.
Error
)
{
func
(
r
*
reader
)
Read
(
p
[]
byte
)
(
n
int
,
err
os
.
Error
)
{
b
:=
*
r
;
b
:=
*
r
;
if
len
(
b
)
==
0
&&
len
(
p
)
>
0
{
if
len
(
b
)
==
0
&&
len
(
p
)
>
0
{
...
@@ -439,7 +441,7 @@ func (w *Window) readEvents() {
...
@@ -439,7 +441,7 @@ func (w *Window) readEvents() {
// log.Stdoutf("%#v\n", e);
// log.Stdoutf("%#v\n", e);
switch
buf
[
0
]
{
switch
buf
[
0
]
{
case
eventExpose
:
case
eventExpose
:
w
.
resizec
<-
true
w
.
resizec
<-
true
;
case
eventKeyDown
:
case
eventKeyDown
:
w
.
kbdc
<-
int
(
ke
.
Key
);
w
.
kbdc
<-
int
(
ke
.
Key
);
case
eventKeyUp
:
case
eventKeyUp
:
...
@@ -454,14 +456,14 @@ func (w *Window) readEvents() {
...
@@ -454,14 +456,14 @@ func (w *Window) readEvents() {
m
.
X
=
int
(
mbe
.
X
);
m
.
X
=
int
(
mbe
.
X
);
m
.
Y
=
int
(
mbe
.
Y
);
m
.
Y
=
int
(
mbe
.
Y
);
// TODO(rsc): Remove uint cast once 8g bug is fixed.
// 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
();
m
.
Nsec
=
time
.
Nanoseconds
();
_
=
w
.
mousec
<-
m
;
_
=
w
.
mousec
<-
m
;
case
eventMouseButtonUp
:
case
eventMouseButtonUp
:
m
.
X
=
int
(
mbe
.
X
);
m
.
X
=
int
(
mbe
.
X
);
m
.
Y
=
int
(
mbe
.
Y
);
m
.
Y
=
int
(
mbe
.
Y
);
// TODO(rsc): Remove uint cast once 8g bug is fixed.
// 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
();
m
.
Nsec
=
time
.
Nanoseconds
();
_
=
w
.
mousec
<-
m
;
_
=
w
.
mousec
<-
m
;
case
eventQuit
:
case
eventQuit
:
...
...
src/pkg/exp/nacl/av/image.go
View file @
6238964d
...
@@ -20,7 +20,7 @@ type Image struct {
...
@@ -20,7 +20,7 @@ type Image struct {
Pixel
[][]
Color
;
Pixel
[][]
Color
;
}
}
var
_
image
.
Image
=
(
*
Image
)(
nil
)
;
var
_
image
.
Image
=
(
*
Image
)(
nil
)
func
(
m
*
Image
)
ColorModel
()
image
.
ColorModel
{
func
(
m
*
Image
)
ColorModel
()
image
.
ColorModel
{
return
ColorModel
;
return
ColorModel
;
...
@@ -62,18 +62,19 @@ func newImage(dx, dy int, linear []Color) *Image {
...
@@ -62,18 +62,19 @@ func newImage(dx, dy int, linear []Color) *Image {
// A Color represents a Native Client color value,
// A Color represents a Native Client color value,
// a 32-bit R, G, B, A value packed as 0xAARRGGBB.
// a 32-bit R, G, B, A value packed as 0xAARRGGBB.
type
Color
uint32
type
Color
uint32
func
(
p
Color
)
RGBA
()
(
r
,
g
,
b
,
a
uint32
)
{
func
(
p
Color
)
RGBA
()
(
r
,
g
,
b
,
a
uint32
)
{
x
:=
uint32
(
p
);
x
:=
uint32
(
p
);
a
=
x
>>
24
;
a
=
x
>>
24
;
a
|=
a
<<
8
;
a
|=
a
<<
8
;
a
|=
a
<<
16
;
a
|=
a
<<
16
;
r
=
(
x
>>
16
)
&
0xFF
;
r
=
(
x
>>
16
)
&
0xFF
;
r
|=
r
<<
8
;
r
|=
r
<<
8
;
r
|=
r
<<
16
;
r
|=
r
<<
16
;
g
=
(
x
>>
8
)
&
0xFF
;
g
=
(
x
>>
8
)
&
0xFF
;
g
|=
g
<<
8
;
g
|=
g
<<
8
;
g
|=
g
<<
16
;
g
|=
g
<<
16
;
b
=
x
&
0xFF
;
b
=
x
&
0xFF
;
b
|=
b
<<
8
;
b
|=
b
<<
8
;
b
|=
b
<<
16
;
b
|=
b
<<
16
;
return
;
return
;
...
@@ -91,5 +92,4 @@ func toColor(color image.Color) image.Color {
...
@@ -91,5 +92,4 @@ func toColor(color image.Color) image.Color {
}
}
// ColorModel is the color model corresponding to the Native Client Color.
// ColorModel is the color model corresponding to the Native Client Color.
var
ColorModel
=
image
.
ColorModelFunc
(
toColor
);
var
ColorModel
=
image
.
ColorModelFunc
(
toColor
)
src/pkg/exp/nacl/srpc/client.go
View file @
6238964d
...
@@ -53,8 +53,8 @@ func NewClient(fd int) (c *Client, err os.Error) {
...
@@ -53,8 +53,8 @@ func NewClient(fd int) (c *Client, err os.Error) {
m
:=
&
msg
{
m
:=
&
msg
{
protocol
:
protocol
,
protocol
:
protocol
,
isReq
:
true
,
isReq
:
true
,
Ret
:
[]
interface
{}{
[]
byte
(
nil
)
},
Ret
:
[]
interface
{}{
[]
byte
(
nil
)
},
Size
:
[]
int
{
4000
},
Size
:
[]
int
{
4000
},
};
};
m
.
packRequest
();
m
.
packRequest
();
c
.
s
.
send
(
m
);
c
.
s
.
send
(
m
);
...
@@ -72,7 +72,7 @@ func NewClient(fd int) (c *Client, err os.Error) {
...
@@ -72,7 +72,7 @@ func NewClient(fd int) (c *Client, err os.Error) {
if
i
<
0
{
if
i
<
0
{
continue
;
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
);
c
.
out
=
make
(
chan
*
msg
);
...
@@ -159,11 +159,11 @@ func (r *RPC) Start(name string, arg []interface{}) {
...
@@ -159,11 +159,11 @@ func (r *RPC) Start(name string, arg []interface{}) {
for
srv
.
fmt
[
i
]
!=
':'
{
for
srv
.
fmt
[
i
]
!=
':'
{
i
++
;
i
++
;
}
}
fmt
:=
srv
.
fmt
[
i
+
1
:
len
(
srv
.
fmt
)];
fmt
:=
srv
.
fmt
[
i
+
1
:
len
(
srv
.
fmt
)];
// Now the return prototypes.
// Now the return prototypes.
m
.
Ret
=
make
([]
interface
{},
len
(
fmt
)
-
i
);
m
.
Ret
=
make
([]
interface
{},
len
(
fmt
)
-
i
);
m
.
Size
=
make
([]
int
,
len
(
fmt
)
-
i
);
m
.
Size
=
make
([]
int
,
len
(
fmt
)
-
i
);
for
i
:=
0
;
i
<
len
(
fmt
);
i
++
{
for
i
:=
0
;
i
<
len
(
fmt
);
i
++
{
switch
fmt
[
i
]
{
switch
fmt
[
i
]
{
default
:
default
:
...
...
src/pkg/exp/nacl/srpc/msg.go
View file @
6238964d
...
@@ -17,8 +17,9 @@ import (
...
@@ -17,8 +17,9 @@ import (
// An Errno is an SRPC status code.
// An Errno is an SRPC status code.
type
Errno
uint32
type
Errno
uint32
const
(
const
(
OK
Errno
=
256
+
iota
;
OK
Errno
=
256
+
iota
;
ErrBreak
;
ErrBreak
;
ErrMessageTruncated
;
ErrMessageTruncated
;
ErrNoMemory
;
ErrNoMemory
;
...
@@ -33,27 +34,27 @@ const (
...
@@ -33,27 +34,27 @@ const (
ErrAppError
;
ErrAppError
;
)
)
var
errstr
=
[
...
]
string
{
var
errstr
=
[
...
]
string
{
OK
-
OK
:
"ok"
,
OK
-
OK
:
"ok"
,
ErrBreak
-
OK
:
"break"
,
ErrBreak
-
OK
:
"break"
,
ErrMessageTruncated
-
OK
:
"message truncated"
,
ErrMessageTruncated
-
OK
:
"message truncated"
,
ErrNoMemory
-
OK
:
"out of memory"
,
ErrNoMemory
-
OK
:
"out of memory"
,
ErrProtocolMismatch
-
OK
:
"protocol mismatch"
,
ErrProtocolMismatch
-
OK
:
"protocol mismatch"
,
ErrBadRPCNumber
-
OK
:
"invalid RPC method number"
,
ErrBadRPCNumber
-
OK
:
"invalid RPC method number"
,
ErrBadArgType
-
OK
:
"unexpected argument type"
,
ErrBadArgType
-
OK
:
"unexpected argument type"
,
ErrTooFewArgs
-
OK
:
"too few arguments"
,
ErrTooFewArgs
-
OK
:
"too few arguments"
,
ErrTooManyArgs
-
OK
:
"too many arguments"
,
ErrTooManyArgs
-
OK
:
"too many arguments"
,
ErrInArgTypeMismatch
-
OK
:
"input argument type mismatch"
,
ErrInArgTypeMismatch
-
OK
:
"input argument type mismatch"
,
ErrOutArgTypeMismatch
-
OK
:
"output argument type mismatch"
,
ErrOutArgTypeMismatch
-
OK
:
"output argument type mismatch"
,
ErrInternalError
-
OK
:
"internal error"
,
ErrInternalError
-
OK
:
"internal error"
,
ErrAppError
-
OK
:
"application error"
,
ErrAppError
-
OK
:
"application error"
,
}
}
func
(
e
Errno
)
String
()
string
{
func
(
e
Errno
)
String
()
string
{
if
e
<
OK
||
int
(
e
-
OK
)
>=
len
(
errstr
)
{
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
// A *msgHdr is the data argument to the imc_recvmsg
...
@@ -139,7 +140,6 @@ type msgSender struct {
...
@@ -139,7 +140,6 @@ type msgSender struct {
fd
int
;
fd
int
;
hdr
msgHdr
;
hdr
msgHdr
;
iov
iov
;
iov
iov
;
}
}
func
(
s
*
msgSender
)
send
(
m
*
msg
)
os
.
Error
{
func
(
s
*
msgSender
)
send
(
m
*
msg
)
os
.
Error
{
...
@@ -222,8 +222,8 @@ func (m *msg) grow(n int) []byte {
...
@@ -222,8 +222,8 @@ func (m *msg) grow(n int) []byte {
bytes
.
Copy
(
a
,
m
.
wdata
);
bytes
.
Copy
(
a
,
m
.
wdata
);
m
.
wdata
=
a
;
m
.
wdata
=
a
;
}
}
m
.
wdata
=
m
.
wdata
[
0
:
i
+
n
];
m
.
wdata
=
m
.
wdata
[
0
:
i
+
n
];
return
m
.
wdata
[
i
:
i
+
n
];
return
m
.
wdata
[
i
:
i
+
n
];
}
}
func
(
m
*
msg
)
wuint8
(
x
uint8
)
{
func
(
m
*
msg
)
wuint8
(
x
uint8
)
{
...
@@ -529,4 +529,3 @@ func (m *msg) packResponse() {
...
@@ -529,4 +529,3 @@ func (m *msg) packResponse() {
m
.
wuint32
(
uint32
(
len
(
m
.
Ret
)));
m
.
wuint32
(
uint32
(
len
(
m
.
Ret
)));
m
.
packValues
(
m
.
Ret
);
m
.
packValues
(
m
.
Ret
);
}
}
src/pkg/exp/nacl/srpc/server.go
View file @
6238964d
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
// It reads arguments from arg, checks size for array limits,
// It reads arguments from arg, checks size for array limits,
// writes return values to ret, and returns an Errno status code.
// writes return values to ret, and returns an Errno status code.
type
Handler
interface
{
type
Handler
interface
{
Run
(
arg
,
ret
[]
interface
{},
size
[]
int
)
Errno
Run
(
arg
,
ret
[]
interface
{},
size
[]
int
)
Errno
;
}
}
type
method
struct
{
type
method
struct
{
...
@@ -61,7 +61,7 @@ func Add(name, fmt string, handler Handler) {
...
@@ -61,7 +61,7 @@ func Add(name, fmt string, handler Handler) {
}
}
rpcMethod
=
a
;
rpcMethod
=
a
;
}
}
rpcMethod
=
rpcMethod
[
0
:
n
+
1
];
rpcMethod
=
rpcMethod
[
0
:
n
+
1
];
rpcMethod
[
n
]
=
method
{
name
,
fmt
,
handler
};
rpcMethod
[
n
]
=
method
{
name
,
fmt
,
handler
};
}
}
...
@@ -175,7 +175,7 @@ func getFd() (fd int, err os.Error) {
...
@@ -175,7 +175,7 @@ func getFd() (fd int, err os.Error) {
// Enabled returns true if SRPC is enabled in the Native Client runtime.
// Enabled returns true if SRPC is enabled in the Native Client runtime.
func
Enabled
()
bool
{
func
Enabled
()
bool
{
_
,
err
:=
getFd
();
_
,
err
:=
getFd
();
return
err
==
nil
;
return
err
==
nil
;
}
}
...
@@ -201,4 +201,3 @@ func (serviceDiscovery) Run(arg, ret []interface{}, size []int) Errno {
...
@@ -201,4 +201,3 @@ func (serviceDiscovery) Run(arg, ret []interface{}, size []int) Errno {
func
init
()
{
func
init
()
{
Add
(
"service_discovery"
,
":C"
,
serviceDiscovery
{});
Add
(
"service_discovery"
,
":C"
,
serviceDiscovery
{});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment