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
3d4bc65f
Commit
3d4bc65f
authored
7 years ago
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X draft of varable length tracking
parent
f596b330
x/fsnotify_stub
t
t+ypy3
t2
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
259 additions
and
88 deletions
+259
-88
t/neo/marshal.go
t/neo/marshal.go
+252
-87
t/neo/protogen.go
t/neo/protogen.go
+7
-1
No files found.
t/neo/marshal.go
View file @
3d4bc65f
This diff is collapsed.
Click to expand it.
t/neo/protogen.go
View file @
3d4bc65f
...
...
@@ -213,6 +213,7 @@ func (d *decoder) emitstrbytes(assignto string) {
d
.
emit
(
"if uint32(len(data)) < l { return 0, ErrDecodeOverflow }"
)
d
.
emit
(
"%v = string(data[:l])"
,
assignto
)
d
.
emit
(
"data = data[l:]"
)
d
.
emit
(
"nread += %v + l"
,
d
.
n
)
d
.
emit
(
"}"
)
d
.
n
=
0
}
...
...
@@ -223,6 +224,7 @@ func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice)
// [len]item
d
.
emit
(
"{ l := %v"
,
d
.
decodedBasic
(
nil
,
types
.
Typ
[
types
.
Uint32
]))
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"nread += %v"
,
d
.
n
)
d
.
n
=
0
d
.
emit
(
"%v = make(%v, l)"
,
assignto
,
typeName
(
typ
))
// TODO size check
...
...
@@ -233,6 +235,7 @@ func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice)
// XXX try to avoid (*) in a
d
.
emitobjtype
(
"(*a)"
,
obj
,
typ
.
Elem
())
// XXX also obj.Elem() ?
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt slice of slice ?
d
.
emit
(
"nread += %v"
,
d
.
n
)
d
.
emit
(
"}"
)
//d.emit("%v = string(data[:l])", assignto)
d
.
emit
(
"}"
)
...
...
@@ -244,6 +247,7 @@ func (d *decoder) emitmap(assignto string, obj types.Object, typ *types.Map) {
// [len](key, value)
d
.
emit
(
"{ l := %v"
,
d
.
decodedBasic
(
nil
,
types
.
Typ
[
types
.
Uint32
]))
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"nread += %v"
,
d
.
n
)
d
.
n
=
0
d
.
emit
(
"%v = make(%v, l)"
,
assignto
,
typeName
(
typ
))
// TODO size check
...
...
@@ -267,6 +271,7 @@ func (d *decoder) emitmap(assignto string, obj types.Object, typ *types.Map) {
}
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt map of map ?
d
.
emit
(
"nread += %v"
,
d
.
n
)
d
.
emit
(
"}"
)
//d.emit("%v = string(data[:l])", assignto)
d
.
emit
(
"}"
)
...
...
@@ -326,6 +331,7 @@ func gendecode(typespec *ast.TypeSpec) string {
d
:=
decoder
{}
// prologue
d
.
emit
(
"func (p *%s) NEODecode(data []byte) (int, error) {"
,
typespec
.
Name
.
Name
)
d
.
emit
(
"var nread uint32"
)
//n := 0
//t := typespec.Type.(*ast.StructType) // must be
...
...
@@ -336,7 +342,7 @@ func gendecode(typespec *ast.TypeSpec) string {
d
.
emitobjtype
(
"p"
,
obj
,
typ
)
d
.
emit
(
"return
%v /* + TODO variable part */, nil"
,
d
.
n
)
// FIXME n is wrong after reset
d
.
emit
(
"return
int(nread) + %v, nil"
,
d
.
n
)
d
.
emit
(
"}"
)
return
d
.
buf
.
String
()
...
...
This diff is collapsed.
Click to expand it.
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