Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
c93753be
Commit
c93753be
authored
Dec 27, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
56e14190
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
6 deletions
+55
-6
t/neo/marshal.go
t/neo/marshal.go
+40
-0
t/neo/proto.go
t/neo/proto.go
+1
-1
t/neo/protogen.go
t/neo/protogen.go
+14
-5
No files found.
t/neo/marshal.go
View file @
c93753be
...
...
@@ -432,3 +432,43 @@ func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) {
}
return
0
/* + TODO variable part */
,
nil
}
func
(
p
*
StoreObject
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
p
.
Oid
=
BigEndian
.
Uint64
(
data
[
0
:
])
p
.
Serial
=
BigEndian
.
Uint64
(
data
[
8
:
])
p
.
Compression
=
bool
((
data
[
16
:
])[
0
])
p
.
Checksum
[
0
]
=
(
data
[
17
:
])[
0
]
p
.
Checksum
[
1
]
=
(
data
[
18
:
])[
0
]
p
.
Checksum
[
2
]
=
(
data
[
19
:
])[
0
]
p
.
Checksum
[
3
]
=
(
data
[
20
:
])[
0
]
p
.
Checksum
[
4
]
=
(
data
[
21
:
])[
0
]
p
.
Checksum
[
5
]
=
(
data
[
22
:
])[
0
]
p
.
Checksum
[
6
]
=
(
data
[
23
:
])[
0
]
p
.
Checksum
[
7
]
=
(
data
[
24
:
])[
0
]
p
.
Checksum
[
8
]
=
(
data
[
25
:
])[
0
]
p
.
Checksum
[
9
]
=
(
data
[
26
:
])[
0
]
p
.
Checksum
[
10
]
=
(
data
[
27
:
])[
0
]
p
.
Checksum
[
11
]
=
(
data
[
28
:
])[
0
]
p
.
Checksum
[
12
]
=
(
data
[
29
:
])[
0
]
p
.
Checksum
[
13
]
=
(
data
[
30
:
])[
0
]
p
.
Checksum
[
14
]
=
(
data
[
31
:
])[
0
]
p
.
Checksum
[
15
]
=
(
data
[
32
:
])[
0
]
p
.
Checksum
[
16
]
=
(
data
[
33
:
])[
0
]
p
.
Checksum
[
17
]
=
(
data
[
34
:
])[
0
]
p
.
Checksum
[
18
]
=
(
data
[
35
:
])[
0
]
p
.
Checksum
[
19
]
=
(
data
[
36
:
])[
0
]
{
l
:=
BigEndian
.
Uint32
(
data
[
37
:
])
data
=
data
[
41
:
]
p
.
Data
=
make
([]
byte
,
l
)
for
i
:=
0
;
i
<
l
;
i
++
{
a
:=
&
p
.
Data
[
i
]
a
=
(
data
[
0
:
])[
0
]
data
=
data
[
1
:
]
}
}
p
.
DataSerial
=
BigEndian
.
Uint64
(
data
[
0
:
])
p
.
Tid
=
BigEndian
.
Uint64
(
data
[
8
:
])
p
.
Unlock
=
bool
((
data
[
16
:
])[
0
])
return
17
/* + TODO variable part */
,
nil
}
t/neo/proto.go
View file @
c93753be
...
...
@@ -414,7 +414,6 @@ type AnswerGenerateOIDs struct {
}
/*
// Ask to store an object. Send an OID, an original serial, a current
// transaction ID, and data. C -> S.
// Answer if an object has been stored. If an object is in conflict,
...
...
@@ -432,6 +431,7 @@ type StoreObject struct {
Unlock
bool
}
/*
type AnswerStoreObject struct {
Conflicting bool
Oid Oid
...
...
t/neo/protogen.go
View file @
c93753be
...
...
@@ -204,6 +204,7 @@ func (d *decoder) emitstrbytes(assignto string) {
d
.
n
=
0
}
// TODO optimize for []byte
func
(
d
*
decoder
)
emitslice
(
assignto
string
,
obj
types
.
Object
,
typ
*
types
.
Slice
)
{
// len u32
// [len]item
...
...
@@ -256,6 +257,19 @@ func (d *decoder) emitobjtype(assignto string, obj types.Object, typ types.Type)
d
.
emit
(
"%s = %s"
,
assignto
,
d
.
decodedBasic
(
obj
,
u
))
case
*
types
.
Array
:
// TODO optimize for [...]byte
var
i
int64
// XXX because `u.Len() int64`
for
i
=
0
;
i
<
u
.
Len
();
i
++
{
d
.
emitobjtype
(
fmt
.
Sprintf
(
"%v[%v]"
,
assignto
,
i
),
obj
,
u
.
Elem
())
}
case
*
types
.
Struct
:
for
i
:=
0
;
i
<
u
.
NumFields
();
i
++
{
v
:=
u
.
Field
(
i
)
d
.
emitobjtype
(
assignto
+
"."
+
v
.
Name
(),
v
,
v
.
Type
())
}
case
*
types
.
Slice
:
d
.
emitslice
(
assignto
,
obj
,
u
)
...
...
@@ -263,11 +277,6 @@ func (d *decoder) emitobjtype(assignto string, obj types.Object, typ types.Type)
d
.
emitmap
(
assignto
,
obj
,
u
)
case
*
types
.
Struct
:
for
i
:=
0
;
i
<
u
.
NumFields
();
i
++
{
v
:=
u
.
Field
(
i
)
d
.
emitobjtype
(
assignto
+
"."
+
v
.
Name
(),
v
,
v
.
Type
())
}
default
:
log
.
Fatalf
(
"%v: %v has unsupported type %v (%v)"
,
pos
(
obj
),
...
...
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