forked from smallnest/rpcx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark_gencode_schema_test.go
More file actions
120 lines (85 loc) · 1.67 KB
/
Copy pathbenchmark_gencode_schema_test.go
File metadata and controls
120 lines (85 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package rpcx
import (
"io"
"time"
"unsafe"
)
var (
_ = unsafe.Sizeof(0)
_ = io.ReadFull
_ = time.Now()
)
type GencodeArgs struct {
A int32
B int32
}
func (d *GencodeArgs) Size() (s uint64) {
s += 8
return
}
func (d *GencodeArgs) Marshal(buf []byte) ([]byte, error) {
size := d.Size()
{
if uint64(cap(buf)) >= size {
buf = buf[:size]
} else {
buf = make([]byte, size)
}
}
i := uint64(0)
{
buf[0+0] = byte(d.A >> 0)
buf[1+0] = byte(d.A >> 8)
buf[2+0] = byte(d.A >> 16)
buf[3+0] = byte(d.A >> 24)
}
{
buf[0+4] = byte(d.B >> 0)
buf[1+4] = byte(d.B >> 8)
buf[2+4] = byte(d.B >> 16)
buf[3+4] = byte(d.B >> 24)
}
return buf[:i+8], nil
}
func (d *GencodeArgs) Unmarshal(buf []byte) (uint64, error) {
i := uint64(0)
{
d.A = 0 | (int32(buf[0+0]) << 0) | (int32(buf[1+0]) << 8) | (int32(buf[2+0]) << 16) | (int32(buf[3+0]) << 24)
}
{
d.B = 0 | (int32(buf[0+4]) << 0) | (int32(buf[1+4]) << 8) | (int32(buf[2+4]) << 16) | (int32(buf[3+4]) << 24)
}
return i + 8, nil
}
type GencodeReply struct {
C int32
}
func (d *GencodeReply) Size() (s uint64) {
s += 4
return
}
func (d *GencodeReply) Marshal(buf []byte) ([]byte, error) {
size := d.Size()
{
if uint64(cap(buf)) >= size {
buf = buf[:size]
} else {
buf = make([]byte, size)
}
}
i := uint64(0)
{
buf[0+0] = byte(d.C >> 0)
buf[1+0] = byte(d.C >> 8)
buf[2+0] = byte(d.C >> 16)
buf[3+0] = byte(d.C >> 24)
}
return buf[:i+4], nil
}
func (d *GencodeReply) Unmarshal(buf []byte) (uint64, error) {
i := uint64(0)
{
d.C = 0 | (int32(buf[0+0]) << 0) | (int32(buf[1+0]) << 8) | (int32(buf[2+0]) << 16) | (int32(buf[3+0]) << 24)
}
return i + 4, nil
}