forked from capnproto/go-capnp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request capnproto#335 from capnproto/enhancement/any-list
Add code generation for AnyList
- Loading branch information
Showing
19 changed files
with
445 additions
and
565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
// {{.Node.Name}}_Future is a wrapper for a {{.Node.Name}} promised by a client call. | ||
type {{.Node.Name}}_Future struct { *capnp.Future } | ||
|
||
func (p {{.Node.Name}}_Future) Struct() ({{.Node.Name}}, error) { | ||
s, err := p.Future.Struct() | ||
return {{.Node.Name}}(s), err | ||
func (f {{.Node.Name}}_Future) Struct() ({{.Node.Name}}, error) { | ||
p, err := f.Future.Ptr() | ||
return {{.Node.Name}}(p.Struct()), err | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
func (p {{ .Node.Name }}_Future) {{ .Field.Name|title }}() *capnp.Future { | ||
return p.Future.Field({{ .Field.Slot.Offset }}, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
func (s {{.Node.Name}}) {{.Field.Name|title}}() (capnp.List, error) { | ||
{{template "_checktag" . -}} | ||
p, err := capnp.Struct(s).Ptr({{.Field.Slot.Offset}}) | ||
{{if .Default.IsValid -}} | ||
if err != nil { | ||
return capnp.List{}, err | ||
} | ||
return p.ListDefault({{.Default}}) | ||
{{- else -}} | ||
return p.List(), err | ||
{{- end}} | ||
} | ||
|
||
{{template "_hasfield" .}} | ||
|
||
func (s {{.Node.Name}}) Set{{.Field.Name|title}}(v capnp.List) error { | ||
{{template "_settag" . -}} | ||
return capnp.Struct(s).SetPtr({{.Field.Slot.Offset}}, v.ToPtr()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.