Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ld
go-codec-dagpb
Commits
07d051e5
Unverified
Commit
07d051e5
authored
Dec 09, 2020
by
Rod Vagg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
betterer codegen invocation
parent
035ab815
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
200 additions
and
288 deletions
+200
-288
gen.go
gen.go
+11
-5
ipldsch_minima.go
ipldsch_minima.go
+12
-13
ipldsch_satisfaction.go
ipldsch_satisfaction.go
+161
-254
ipldsch_types.go
ipldsch_types.go
+16
-16
No files found.
gen
/main
.go
→
gen.go
View file @
07d051e5
// +build ignore
package
main
// based on https://github.com/ipld/go-ipld-prime-proto/blob/master/gen/main.go
import
(
"os/exec"
"fmt"
"os"
"github.com/ipld/go-ipld-prime/schema"
gengo
"github.com/ipld/go-ipld-prime/schema/gen/go"
)
func
main
()
{
ts
:=
schema
.
TypeSystem
{}
ts
.
Init
()
adjCfg
:=
&
gengo
.
AdjunctCfg
{}
...
...
@@ -55,8 +57,12 @@ func main() {
schema
.
SpawnStructRepresentationMap
(
nil
),
))
// note in scope: ts.Accumulate(schema.SpawnBytes("RawNode"))
if
errs
:=
ts
.
ValidateGraph
();
errs
!=
nil
{
for
_
,
err
:=
range
errs
{
fmt
.
Printf
(
"- %s
\n
"
,
err
)
}
os
.
Exit
(
1
)
}
gengo
.
Generate
(
"./"
,
pkgName
,
ts
,
adjCfg
)
exec
.
Command
(
"go"
,
"fmt"
)
.
Run
()
gengo
.
Generate
(
"."
,
pkgName
,
ts
,
adjCfg
)
}
ipldsch_minima.go
View file @
07d051e5
...
...
@@ -31,7 +31,6 @@ const (
laState_midValue
laState_finished
)
type
_ErrorThunkAssembler
struct
{
e
error
}
...
...
ipldsch_satisfaction.go
View file @
07d051e5
...
...
@@ -15,7 +15,6 @@ func (_Bytes__Prototype) FromBytes(v []byte) (Bytes, error) {
n := _Bytes{v}
return &n, nil
}
type _Bytes__Maybe struct {
m schema.Maybe
v Bytes
...
...
@@ -49,10 +48,8 @@ func (m MaybeBytes) Must() Bytes {
}
return m.v
}
var _ ipld.Node = (Bytes)(&_Bytes{})
var _ schema.TypedNode = (Bytes)(&_Bytes{})
func (Bytes) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Bytes
}
...
...
@@ -104,7 +101,6 @@ func (Bytes) AsLink() (ipld.Link, error) {
func (Bytes) Prototype() ipld.NodePrototype {
return _Bytes__Prototype{}
}
type _Bytes__Prototype struct{}
func (_Bytes__Prototype) NewBuilder() ipld.NodeBuilder {
...
...
@@ -112,11 +108,9 @@ func (_Bytes__Prototype) NewBuilder() ipld.NodeBuilder {
nb.Reset()
return &nb
}
type _Bytes__Builder struct {
_Bytes__Assembler
}
func (nb *_Bytes__Builder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
...
...
@@ -128,7 +122,6 @@ func (nb *_Bytes__Builder) Reset() {
var m schema.Maybe
*nb = _Bytes__Builder{_Bytes__Assembler{w: &w, m: &m}}
}
type _Bytes__Assembler struct {
w *_Bytes
m *schema.Maybe
...
...
@@ -213,11 +206,8 @@ func (Bytes) Type() schema.Type {
func (n Bytes) Representation() ipld.Node {
return (*_Bytes__Repr)(n)
}
type _Bytes__Repr = _Bytes
var _ ipld.Node = &_Bytes__Repr{}
type _Bytes__ReprPrototype = _Bytes__Prototype
type _Bytes__ReprAssembler = _Bytes__Assembler
...
...
@@ -228,7 +218,6 @@ func (_Int__Prototype) FromInt(v int) (Int, error) {
n := _Int{v}
return &n, nil
}
type _Int__Maybe struct {
m schema.Maybe
v Int
...
...
@@ -262,10 +251,8 @@ func (m MaybeInt) Must() Int {
}
return m.v
}
var _ ipld.Node = (Int)(&_Int{})
var _ schema.TypedNode = (Int)(&_Int{})
func (Int) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Int
}
...
...
@@ -317,7 +304,6 @@ func (Int) AsLink() (ipld.Link, error) {
func (Int) Prototype() ipld.NodePrototype {
return _Int__Prototype{}
}
type _Int__Prototype struct{}
func (_Int__Prototype) NewBuilder() ipld.NodeBuilder {
...
...
@@ -325,11 +311,9 @@ func (_Int__Prototype) NewBuilder() ipld.NodeBuilder {
nb.Reset()
return &nb
}
type _Int__Builder struct {
_Int__Assembler
}
func (nb *_Int__Builder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
...
...
@@ -341,7 +325,6 @@ func (nb *_Int__Builder) Reset() {
var m schema.Maybe
*nb = _Int__Builder{_Int__Assembler{w: &w, m: &m}}
}
type _Int__Assembler struct {
w *_Int
m *schema.Maybe
...
...
@@ -426,11 +409,8 @@ func (Int) Type() schema.Type {
func (n Int) Representation() ipld.Node {
return (*_Int__Repr)(n)
}
type _Int__Repr = _Int
var _ ipld.Node = &_Int__Repr{}
type _Int__ReprPrototype = _Int__Prototype
type _Int__ReprAssembler = _Int__Assembler
...
...
@@ -441,7 +421,6 @@ func (_Link__Prototype) FromLink(v ipld.Link) (Link, error) {
n := _Link{v}
return &n, nil
}
type _Link__Maybe struct {
m schema.Maybe
v Link
...
...
@@ -475,10 +454,8 @@ func (m MaybeLink) Must() Link {
}
return m.v
}
var _ ipld.Node = (Link)(&_Link{})
var _ schema.TypedNode = (Link)(&_Link{})
func (Link) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Link
}
...
...
@@ -530,7 +507,6 @@ func (n Link) AsLink() (ipld.Link, error) {
func (Link) Prototype() ipld.NodePrototype {
return _Link__Prototype{}
}
type _Link__Prototype struct{}
func (_Link__Prototype) NewBuilder() ipld.NodeBuilder {
...
...
@@ -538,11 +514,9 @@ func (_Link__Prototype) NewBuilder() ipld.NodeBuilder {
nb.Reset()
return &nb
}
type _Link__Builder struct {
_Link__Assembler
}
func (nb *_Link__Builder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
...
...
@@ -554,7 +528,6 @@ func (nb *_Link__Builder) Reset() {
var m schema.Maybe
*nb = _Link__Builder{_Link__Assembler{w: &w, m: &m}}
}
type _Link__Assembler struct {
w *_Link
m *schema.Maybe
...
...
@@ -639,14 +612,12 @@ func (Link) Type() schema.Type {
func (n Link) Representation() ipld.Node {
return (*_Link__Repr)(n)
}
type _Link__Repr = _Link
var _ ipld.Node = &_Link__Repr{}
type _Link__ReprPrototype = _Link__Prototype
type _Link__ReprAssembler = _Link__Assembler
func (n _PBLink) FieldHash() Link {
return &n.Hash
}
...
...
@@ -656,7 +627,6 @@ func (n _PBLink) FieldName() MaybeString {
func (n _PBLink) FieldTsize() MaybeInt {
return &n.Tsize
}
type _PBLink__Maybe struct {
m schema.Maybe
v PBLink
...
...
@@ -690,7 +660,6 @@ func (m MaybePBLink) Must() PBLink {
}
return m.v
}
var (
fieldName__PBLink_Hash = _String{"Hash"}
fieldName__PBLink_Name = _String{"Name"}
...
...
@@ -698,7 +667,6 @@ var (
)
var _ ipld.Node = (PBLink)(&_PBLink{})
var _ schema.TypedNode = (PBLink)(&_PBLink{})
func (PBLink) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Map
}
...
...
@@ -807,7 +775,6 @@ func (PBLink) AsLink() (ipld.Link, error) {
func (PBLink) Prototype() ipld.NodePrototype {
return _PBLink__Prototype{}
}
type _PBLink__Prototype struct{}
func (_PBLink__Prototype) NewBuilder() ipld.NodeBuilder {
...
...
@@ -815,11 +782,9 @@ func (_PBLink__Prototype) NewBuilder() ipld.NodeBuilder {
nb.Reset()
return &nb
}
type _PBLink__Builder struct {
_PBLink__Assembler
}
func (nb *_PBLink__Builder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
...
...
@@ -831,7 +796,6 @@ func (nb *_PBLink__Builder) Reset() {
var m schema.Maybe
*nb = _PBLink__Builder{_PBLink__Assembler{w: &w, m: &m}}
}
type _PBLink__Assembler struct {
w *_PBLink
m *schema.Maybe
...
...
@@ -843,7 +807,7 @@ type _PBLink__Assembler struct {
ca_Hash _Link__Assembler
ca_Name _String__Assembler
ca_Tsize _Int__Assembler
}
}
func (na *_PBLink__Assembler) reset() {
na.state = maState_initial
...
...
@@ -857,9 +821,8 @@ var (
fieldBit__PBLink_Hash = 1 << 0
fieldBit__PBLink_Name = 1 << 1
fieldBit__PBLink_Tsize = 1 << 2
fieldBits__PBLink_sufficient = 0 + 1<<0
fieldBits__PBLink_sufficient = 0 + 1
<<
0
)
func (na *_PBLink__Assembler) BeginMap(int) (ipld.MapAssembler, error) {
switch *na.m {
case schema.Maybe_Value, schema.Maybe_Null:
...
...
@@ -1000,7 +963,7 @@ func (ma *_PBLink__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error
}
switch k {
case "Hash":
if ma.s
&
fieldBit__PBLink_Hash != 0 {
if ma.s
&
fieldBit__PBLink_Hash != 0 {
return nil, ipld.ErrRepeatedMapKey{&fieldName__PBLink_Hash}
}
ma.s += fieldBit__PBLink_Hash
...
...
@@ -1010,7 +973,7 @@ func (ma *_PBLink__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error
ma.ca_Hash.m = &ma.cm
return &ma.ca_Hash, nil
case "Name":
if ma.s
&
fieldBit__PBLink_Name != 0 {
if ma.s
&
fieldBit__PBLink_Name != 0 {
return nil, ipld.ErrRepeatedMapKey{&fieldName__PBLink_Name}
}
ma.s += fieldBit__PBLink_Name
...
...
@@ -1020,7 +983,7 @@ func (ma *_PBLink__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error
ma.ca_Name.m = &ma.w.Name.m
return &ma.ca_Name, nil
case "Tsize":
if ma.s
&
fieldBit__PBLink_Tsize != 0 {
if ma.s
&
fieldBit__PBLink_Tsize != 0 {
return nil, ipld.ErrRepeatedMapKey{&fieldName__PBLink_Tsize}
}
ma.s += fieldBit__PBLink_Tsize
...
...
@@ -1030,7 +993,7 @@ func (ma *_PBLink__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error
ma.ca_Tsize.m = &ma.w.Tsize.m
return &ma.ca_Tsize, nil
default:
return nil, ipld.ErrInvalidKey{TypeName:
"dagpb.PBLink", Key:
&_String{k}}
return nil, ipld.ErrInvalidKey{TypeName:"dagpb.PBLink", Key:&_String{k}}
}
}
func (ma *_PBLink__Assembler) AssembleKey() ipld.NodeAssembler {
...
...
@@ -1097,9 +1060,9 @@ func (ma *_PBLink__Assembler) Finish() error {
case maState_finished:
panic("invalid state: Finish cannot be called on an assembler that's already finished")
}
if ma.s
&
fieldBits__PBLink_sufficient != fieldBits__PBLink_sufficient {
if ma.s
&
fieldBits__PBLink_sufficient != fieldBits__PBLink_sufficient {
err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)}
if ma.s
&
fieldBit__PBLink_Hash == 0 {
if ma.s
&
fieldBit__PBLink_Hash == 0 {
err.Missing = append(err.Missing, "Hash")
}
return err
...
...
@@ -1114,9 +1077,7 @@ func (ma *_PBLink__Assembler) KeyPrototype() ipld.NodePrototype {
func (ma *_PBLink__Assembler) ValuePrototype(k string) ipld.NodePrototype {
panic("todo structbuilder mapassembler valueprototype")
}
type _PBLink__KeyAssembler _PBLink__Assembler
func (_PBLink__KeyAssembler) BeginMap(sizeHint int) (ipld.MapAssembler, error) {
return mixins.StringAssembler{"dagpb.PBLink.KeyAssembler"}.BeginMap(0)
}
...
...
@@ -1141,28 +1102,28 @@ func (ka *_PBLink__KeyAssembler) AssignString(k string) error {
}
switch k {
case "Hash":
if ka.s
&
fieldBit__PBLink_Hash != 0 {
if ka.s
&
fieldBit__PBLink_Hash != 0 {
return ipld.ErrRepeatedMapKey{&fieldName__PBLink_Hash}
}
ka.s += fieldBit__PBLink_Hash
ka.state = maState_expectValue
ka.f = 0
case "Name":
if ka.s
&
fieldBit__PBLink_Name != 0 {
if ka.s
&
fieldBit__PBLink_Name != 0 {
return ipld.ErrRepeatedMapKey{&fieldName__PBLink_Name}
}
ka.s += fieldBit__PBLink_Name
ka.state = maState_expectValue
ka.f = 1
case "Tsize":
if ka.s
&
fieldBit__PBLink_Tsize != 0 {
if ka.s
&
fieldBit__PBLink_Tsize != 0 {
return ipld.ErrRepeatedMapKey{&fieldName__PBLink_Tsize}
}
ka.s += fieldBit__PBLink_Tsize
ka.state = maState_expectValue
ka.f = 2
default:
return ipld.ErrInvalidKey{TypeName:
"dagpb.PBLink", Key:
&_String{k}}
return ipld.ErrInvalidKey{TypeName:"dagpb.PBLink", Key:&_String{k}}
}
return nil
}
...
...
@@ -1188,16 +1149,13 @@ func (PBLink) Type() schema.Type {
func (n PBLink) Representation() ipld.Node {
return (*_PBLink__Repr)(n)
}
type _PBLink__Repr _PBLink
var (
fieldName__PBLink_Hash_serial = _String{"Hash"}
fieldName__PBLink_Name_serial = _String{"Name"}
fieldName__PBLink_Tsize_serial = _String{"Tsize"}
)
var _ ipld.Node = &_PBLink__Repr{}
func (_PBLink__Repr) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Map
}
...
...
@@ -1255,8 +1213,7 @@ type _PBLink__ReprMapItr struct {
}
func (itr *_PBLink__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) {
advance:
if itr.idx >= 3 {
advance:if itr.idx >= 3 {
return nil, nil, ipld.ErrIteratorOverread{}
}
switch itr.idx {
...
...
@@ -1326,7 +1283,6 @@ func (_PBLink__Repr) AsLink() (ipld.Link, error) {
func (_PBLink__Repr) Prototype() ipld.NodePrototype {
return _PBLink__ReprPrototype{}
}
type _PBLink__ReprPrototype struct{}
func (_PBLink__ReprPrototype) NewBuilder() ipld.NodeBuilder {
...
...
@@ -1334,11 +1290,9 @@ func (_PBLink__ReprPrototype) NewBuilder() ipld.NodeBuilder {
nb.Reset()
return &nb
}
type _PBLink__ReprBuilder struct {
_PBLink__ReprAssembler
}
func (nb *_PBLink__ReprBuilder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
...
...
@@ -1350,7 +1304,6 @@ func (nb *_PBLink__ReprBuilder) Reset() {
var m schema.Maybe
*nb = _PBLink__ReprBuilder{_PBLink__ReprAssembler{w: &w, m: &m}}
}
type _PBLink__ReprAssembler struct {
w *_PBLink
m *schema.Maybe
...
...
@@ -1362,7 +1315,7 @@ type _PBLink__ReprAssembler struct {
ca_Hash _Link__ReprAssembler
ca_Name _String__ReprAssembler
ca_Tsize _Int__ReprAssembler
}
}
func (na *_PBLink__ReprAssembler) reset() {
na.state = maState_initial
...
...
@@ -1464,8 +1417,7 @@ func (ma *_PBLink__ReprAssembler) valueFinishTidy() bool {
switch ma.f {
case 0:
switch ma.cm {
case schema.Maybe_Value:
ma.cm = schema.Maybe_Absent
case schema.Maybe_Value:ma.cm = schema.Maybe_Absent
ma.state = maState_initial
return true
default:
...
...
@@ -1510,7 +1462,7 @@ func (ma *_PBLink__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, e
}
switch k {
case "Hash":
if ma.s
&
fieldBit__PBLink_Hash != 0 {
if ma.s
&
fieldBit__PBLink_Hash != 0 {
return nil, ipld.ErrRepeatedMapKey{&fieldName__PBLink_Hash_serial}
}
ma.s += fieldBit__PBLink_Hash
...
...
@@ -1520,7 +1472,7 @@ func (ma *_PBLink__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, e
ma.ca_Hash.m = &ma.cm
return &ma.ca_Hash, nil
case "Name":
if ma.s
&
fieldBit__PBLink_Name != 0 {
if ma.s
&
fieldBit__PBLink_Name != 0 {
return nil, ipld.ErrRepeatedMapKey{&fieldName__PBLink_Name_serial}
}
ma.s += fieldBit__PBLink_Name
...
...
@@ -1531,7 +1483,7 @@ func (ma *_PBLink__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, e
return &ma.ca_Name, nil
case "Tsize":
if ma.s
&
fieldBit__PBLink_Tsize != 0 {
if ma.s
&
fieldBit__PBLink_Tsize != 0 {
return nil, ipld.ErrRepeatedMapKey{&fieldName__PBLink_Tsize_serial}
}
ma.s += fieldBit__PBLink_Tsize
...
...
@@ -1542,7 +1494,7 @@ func (ma *_PBLink__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, e
return &ma.ca_Tsize, nil
default:
return nil, ipld.ErrInvalidKey{TypeName:
"dagpb.PBLink.Repr", Key:
&_String{k}}
return nil, ipld.ErrInvalidKey{TypeName:"dagpb.PBLink.Repr", Key:&_String{k}}
}
}
func (ma *_PBLink__ReprAssembler) AssembleKey() ipld.NodeAssembler {
...
...
@@ -1611,9 +1563,9 @@ func (ma *_PBLink__ReprAssembler) Finish() error {
case maState_finished:
panic("invalid state: Finish cannot be called on an assembler that's already finished")
}
if ma.s
&
fieldBits__PBLink_sufficient != fieldBits__PBLink_sufficient {
if ma.s
&
fieldBits__PBLink_sufficient != fieldBits__PBLink_sufficient {
err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)}
if ma.s
&
fieldBit__PBLink_Hash == 0 {
if ma.s
&
fieldBit__PBLink_Hash == 0 {
err.Missing = append(err.Missing, "Hash")
}
return err
...
...
@@ -1628,9 +1580,7 @@ func (ma *_PBLink__ReprAssembler) KeyPrototype() ipld.NodePrototype {
func (ma *_PBLink__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype {
panic("todo structbuilder mapassembler repr valueprototype")
}
type _PBLink__ReprKeyAssembler _PBLink__ReprAssembler
func (_PBLink__ReprKeyAssembler) BeginMap(sizeHint int) (ipld.MapAssembler, error) {
return mixins.StringAssembler{"dagpb.PBLink.Repr.KeyAssembler"}.BeginMap(0)
}
...
...
@@ -1655,28 +1605,28 @@ func (ka *_PBLink__ReprKeyAssembler) AssignString(k string) error {
}
switch k {
case "Hash":
if ka.s
&
fieldBit__PBLink_Hash != 0 {
if ka.s
&
fieldBit__PBLink_Hash != 0 {
return ipld.ErrRepeatedMapKey{&fieldName__PBLink_Hash_serial}
}
ka.s += fieldBit__PBLink_Hash
ka.state = maState_expectValue
ka.f = 0
case "Name":
if ka.s
&
fieldBit__PBLink_Name != 0 {
if ka.s
&
fieldBit__PBLink_Name != 0 {
return ipld.ErrRepeatedMapKey{&fieldName__PBLink_Name_serial}
}
ka.s += fieldBit__PBLink_Name
ka.state = maState_expectValue
ka.f = 1
case "Tsize":
if ka.s
&
fieldBit__PBLink_Tsize != 0 {
if ka.s
&
fieldBit__PBLink_Tsize != 0 {
return ipld.ErrRepeatedMapKey{&fieldName__PBLink_Tsize_serial}
}
ka.s += fieldBit__PBLink_Tsize
ka.state = maState_expectValue
ka.f = 2
default:
return ipld.ErrInvalidKey{TypeName:
"dagpb.PBLink.Repr", Key:
&_String{k}}
return ipld.ErrInvalidKey{TypeName:"dagpb.PBLink.Repr", Key:&_String{k}}
}
return nil
}
...
...
@@ -1715,8 +1665,7 @@ func (n *_PBLinks) LookupMaybe(idx int) MaybePBLink {
}
}
var _PBLinks__valueAbsent = _PBLink__Maybe{m: schema.Maybe_Absent}
var _PBLinks__valueAbsent = _PBLink__Maybe{m:schema.Maybe_Absent}
func (n PBLinks) Iterator() *PBLinks__Itr {
return &PBLinks__Itr{n, 0}
}
...
...
@@ -1772,10 +1721,8 @@ func (m MaybePBLinks) Must() PBLinks {
}
return m.v
}
var _ ipld.Node = (PBLinks)(&_PBLinks{})
var _ schema.TypedNode = (PBLinks)(&_PBLinks{})
func (PBLinks) ReprKind() ipld.ReprKind {
return ipld.ReprKind_List
}
...
...
@@ -1859,7 +1806,6 @@ func (PBLinks) AsLink() (ipld.Link, error) {
func (PBLinks) Prototype() ipld.NodePrototype {
return _PBLinks__Prototype{}
}
type _PBLinks__Prototype struct{}
func (_PBLinks__Prototype) NewBuilder() ipld.NodeBuilder {
...
...
@@ -1867,11 +1813,9 @@ func (_PBLinks__Prototype) NewBuilder() ipld.NodeBuilder {
nb.Reset()
return &nb
}
type _PBLinks__Builder struct {
_PBLinks__Assembler
}
func (nb *_PBLinks__Builder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
...
...
@@ -1883,7 +1827,6 @@ func (nb *_PBLinks__Builder) Reset() {
var m schema.Maybe
*nb = _PBLinks__Builder{_PBLinks__Assembler{w: &w, m: &m}}
}
type _PBLinks__Assembler struct {
w *_PBLinks
m *schema.Maybe
...
...
@@ -2043,11 +1986,8 @@ func (PBLinks) Type() schema.Type {
func (n PBLinks) Representation() ipld.Node {
return (*_PBLinks__Repr)(n)
}
type _PBLinks__Repr _PBLinks
var _ ipld.Node = &_PBLinks__Repr{}
func (_PBLinks__Repr) ReprKind() ipld.ReprKind {
return ipld.ReprKind_List
}
...
...
@@ -2125,7 +2065,6 @@ func (_PBLinks__Repr) AsLink() (ipld.Link, error) {
func (_PBLinks__Repr) Prototype() ipld.NodePrototype {
return _PBLinks__ReprPrototype{}
}
type _PBLinks__ReprPrototype struct{}
func (_PBLinks__ReprPrototype) NewBuilder() ipld.NodeBuilder {
...
...
@@ -2133,11 +2072,9 @@ func (_PBLinks__ReprPrototype) NewBuilder() ipld.NodeBuilder {
nb.Reset()
return &nb
}
type _PBLinks__ReprBuilder struct {
_PBLinks__ReprAssembler
}
func (nb *_PBLinks__ReprBuilder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
...
...
@@ -2149,7 +2086,6 @@ func (nb *_PBLinks__ReprBuilder) Reset() {
var m schema.Maybe
*nb = _PBLinks__ReprBuilder{_PBLinks__ReprAssembler{w: &w, m: &m}}
}
type _PBLinks__ReprAssembler struct {
w *_PBLinks
m *schema.Maybe
...
...
@@ -2304,13 +2240,13 @@ func (la *_PBLinks__ReprAssembler) ValuePrototype(_ int) ipld.NodePrototype {
return _PBLink__ReprPrototype{}
}
func (n _PBNode) FieldLinks() PBLinks {
return &n.Links
}
func (n _PBNode) FieldData() MaybeBytes {
return &n.Data
}
type _PBNode__Maybe struct {
m schema.Maybe
v PBNode
...
...
@@ -2344,14 +2280,12 @@ func (m MaybePBNode) Must() PBNode {
}
return m.v
}
var (
fieldName__PBNode_Links = _String{"Links"}
fieldName__PBNode_Data = _String{"Data"}
)
var _ ipld.Node = (PBNode)(&_PBNode{})
var _ schema.TypedNode = (PBNode)(&_PBNode{})
func (PBNode) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Map
}
...
...
@@ -2448,7 +2382,6 @@ func (PBNode) AsLink() (ipld.Link, error) {
func (PBNode) Prototype() ipld.NodePrototype {
return _PBNode__Prototype{}
}
type _PBNode__Prototype struct{}
func (_PBNode__Prototype) NewBuilder() ipld.NodeBuilder {
...
...
@@ -2456,11 +2389,9 @@ func (_PBNode__Prototype) NewBuilder() ipld.NodeBuilder {
nb.Reset()
return &nb
}
type _PBNode__Builder struct {
_PBNode__Assembler
}
func (nb *_PBNode__Builder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
...
...
@@ -2472,7 +2403,6 @@ func (nb *_PBNode__Builder) Reset() {
var m schema.Maybe
*nb = _PBNode__Builder{_PBNode__Assembler{w: &w, m: &m}}
}
type _PBNode__Assembler struct {
w *_PBNode
m *schema.Maybe
...
...
@@ -2483,7 +2413,7 @@ type _PBNode__Assembler struct {
cm schema.Maybe
ca_Links _PBLinks__Assembler
ca_Data _Bytes__Assembler
}
}
func (na *_PBNode__Assembler) reset() {
na.state = maState_initial
...
...
@@ -2495,9 +2425,8 @@ func (na *_PBNode__Assembler) reset() {
var (
fieldBit__PBNode_Links = 1 << 0
fieldBit__PBNode_Data = 1 << 1
fieldBits__PBNode_sufficient = 0 + 1<<0
fieldBits__PBNode_sufficient = 0 + 1
<<
0
)
func (na *_PBNode__Assembler) BeginMap(int) (ipld.MapAssembler, error) {
switch *na.m {
case schema.Maybe_Value, schema.Maybe_Null:
...
...
@@ -2629,7 +2558,7 @@ func (ma *_PBNode__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error
}
switch k {
case "Links":
if ma.s
&
fieldBit__PBNode_Links != 0 {
if ma.s
&
fieldBit__PBNode_Links != 0 {
return nil, ipld.ErrRepeatedMapKey{&fieldName__PBNode_Links}
}
ma.s += fieldBit__PBNode_Links
...
...
@@ -2639,7 +2568,7 @@ func (ma *_PBNode__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error
ma.ca_Links.m = &ma.cm
return &ma.ca_Links, nil
case "Data":
if ma.s
&
fieldBit__PBNode_Data != 0 {
if ma.s
&
fieldBit__PBNode_Data != 0 {
return nil, ipld.ErrRepeatedMapKey{&fieldName__PBNode_Data}
}
ma.s += fieldBit__PBNode_Data
...
...
@@ -2649,7 +2578,7 @@ func (ma *_PBNode__Assembler) AssembleEntry(k string) (ipld.NodeAssembler, error
ma.ca_Data.m = &ma.w.Data.m
return &ma.ca_Data, nil
default:
return nil, ipld.ErrInvalidKey{TypeName:
"dagpb.PBNode", Key:
&_String{k}}
return nil, ipld.ErrInvalidKey{TypeName:"dagpb.PBNode", Key:&_String{k}}
}
}
func (ma *_PBNode__Assembler) AssembleKey() ipld.NodeAssembler {
...
...
@@ -2712,9 +2641,9 @@ func (ma *_PBNode__Assembler) Finish() error {
case maState_finished:
panic("invalid state: Finish cannot be called on an assembler that's already finished")
}
if ma.s
&
fieldBits__PBNode_sufficient != fieldBits__PBNode_sufficient {
if ma.s
&
fieldBits__PBNode_sufficient != fieldBits__PBNode_sufficient {
err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)}
if ma.s
&
fieldBit__PBNode_Links == 0 {
if ma.s
&
fieldBit__PBNode_Links == 0 {
err.Missing = append(err.Missing, "Links")
}
return err
...
...
@@ -2729,9 +2658,7 @@ func (ma *_PBNode__Assembler) KeyPrototype() ipld.NodePrototype {
func (ma *_PBNode__Assembler) ValuePrototype(k string) ipld.NodePrototype {
panic("todo structbuilder mapassembler valueprototype")
}
type _PBNode__KeyAssembler _PBNode__Assembler
func (_PBNode__KeyAssembler) BeginMap(sizeHint int) (ipld.MapAssembler, error) {
return mixins.StringAssembler{"dagpb.PBNode.KeyAssembler"}.BeginMap(0)
}
...
...
@@ -2756,21 +2683,21 @@ func (ka *_PBNode__KeyAssembler) AssignString(k string) error {
}
switch k {
case "Links":
if ka.s
&
fieldBit__PBNode_Links != 0 {
if ka.s
&
fieldBit__PBNode_Links != 0 {
return ipld.ErrRepeatedMapKey{&fieldName__PBNode_Links}
}
ka.s += fieldBit__PBNode_Links
ka.state = maState_expectValue
ka.f = 0
case "Data":
if ka.s
&
fieldBit__PBNode_Data != 0 {
if ka.s
&
fieldBit__PBNode_Data != 0 {
return ipld.ErrRepeatedMapKey{&fieldName__PBNode_Data}
}
ka.s += fieldBit__PBNode_Data
ka.state = maState_expectValue
ka.f = 1
default:
return ipld.ErrInvalidKey{TypeName:
"dagpb.PBNode", Key:
&_String{k}}
return ipld.ErrInvalidKey{TypeName:"dagpb.PBNode", Key:&_String{k}}
}
return nil
}
...
...
@@ -2796,15 +2723,12 @@ func (PBNode) Type() schema.Type {
func (n PBNode) Representation() ipld.Node {
return (*_PBNode__Repr)(n)
}
type _PBNode__Repr _PBNode
var (
fieldName__PBNode_Links_serial = _String{"Links"}
fieldName__PBNode_Data_serial = _String{"Data"}
)
var _ ipld.Node = &_PBNode__Repr{}
func (_PBNode__Repr) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Map
}
...
...
@@ -2852,8 +2776,7 @@ type _PBNode__ReprMapItr struct {
}
func (itr *_PBNode__ReprMapItr) Next() (k ipld.Node, v ipld.Node, _ error) {
advance:
if itr.idx >= 2 {
advance:if itr.idx >= 2 {
return nil, nil, ipld.ErrIteratorOverread{}
}
switch itr.idx {
...
...
@@ -2913,7 +2836,6 @@ func (_PBNode__Repr) AsLink() (ipld.Link, error) {
func (_PBNode__Repr) Prototype() ipld.NodePrototype {
return _PBNode__ReprPrototype{}
}
type _PBNode__ReprPrototype struct{}
func (_PBNode__ReprPrototype) NewBuilder() ipld.NodeBuilder {
...
...
@@ -2921,11 +2843,9 @@ func (_PBNode__ReprPrototype) NewBuilder() ipld.NodeBuilder {
nb.Reset()
return &nb
}
type _PBNode__ReprBuilder struct {
_PBNode__ReprAssembler
}
func (nb *_PBNode__ReprBuilder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
...
...
@@ -2937,7 +2857,6 @@ func (nb *_PBNode__ReprBuilder) Reset() {
var m schema.Maybe
*nb = _PBNode__ReprBuilder{_PBNode__ReprAssembler{w: &w, m: &m}}
}
type _PBNode__ReprAssembler struct {
w *_PBNode
m *schema.Maybe
...
...
@@ -2948,7 +2867,7 @@ type _PBNode__ReprAssembler struct {
cm schema.Maybe
ca_Links _PBLinks__ReprAssembler
ca_Data _Bytes__ReprAssembler
}
}
func (na *_PBNode__ReprAssembler) reset() {
na.state = maState_initial
...
...
@@ -3049,8 +2968,7 @@ func (ma *_PBNode__ReprAssembler) valueFinishTidy() bool {
switch ma.f {
case 0:
switch ma.cm {
case schema.Maybe_Value:
ma.cm = schema.Maybe_Absent
case schema.Maybe_Value:ma.cm = schema.Maybe_Absent
ma.state = maState_initial
return true
default:
...
...
@@ -3086,7 +3004,7 @@ func (ma *_PBNode__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, e
}
switch k {
case "Links":
if ma.s
&
fieldBit__PBNode_Links != 0 {
if ma.s
&
fieldBit__PBNode_Links != 0 {
return nil, ipld.ErrRepeatedMapKey{&fieldName__PBNode_Links_serial}
}
ma.s += fieldBit__PBNode_Links
...
...
@@ -3096,7 +3014,7 @@ func (ma *_PBNode__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, e
ma.ca_Links.m = &ma.cm
return &ma.ca_Links, nil
case "Data":
if ma.s
&
fieldBit__PBNode_Data != 0 {
if ma.s
&
fieldBit__PBNode_Data != 0 {
return nil, ipld.ErrRepeatedMapKey{&fieldName__PBNode_Data_serial}
}
ma.s += fieldBit__PBNode_Data
...
...
@@ -3107,7 +3025,7 @@ func (ma *_PBNode__ReprAssembler) AssembleEntry(k string) (ipld.NodeAssembler, e
return &ma.ca_Data, nil
default:
return nil, ipld.ErrInvalidKey{TypeName:
"dagpb.PBNode.Repr", Key:
&_String{k}}
return nil, ipld.ErrInvalidKey{TypeName:"dagpb.PBNode.Repr", Key:&_String{k}}
}
}
func (ma *_PBNode__ReprAssembler) AssembleKey() ipld.NodeAssembler {
...
...
@@ -3171,9 +3089,9 @@ func (ma *_PBNode__ReprAssembler) Finish() error {
case maState_finished:
panic("invalid state: Finish cannot be called on an assembler that's already finished")
}
if ma.s
&
fieldBits__PBNode_sufficient != fieldBits__PBNode_sufficient {
if ma.s
&
fieldBits__PBNode_sufficient != fieldBits__PBNode_sufficient {
err := ipld.ErrMissingRequiredField{Missing: make([]string, 0)}
if ma.s
&
fieldBit__PBNode_Links == 0 {
if ma.s
&
fieldBit__PBNode_Links == 0 {
err.Missing = append(err.Missing, "Links")
}
return err
...
...
@@ -3188,9 +3106,7 @@ func (ma *_PBNode__ReprAssembler) KeyPrototype() ipld.NodePrototype {
func (ma *_PBNode__ReprAssembler) ValuePrototype(k string) ipld.NodePrototype {
panic("todo structbuilder mapassembler repr valueprototype")
}
type _PBNode__ReprKeyAssembler _PBNode__ReprAssembler
func (_PBNode__ReprKeyAssembler) BeginMap(sizeHint int) (ipld.MapAssembler, error) {
return mixins.StringAssembler{"dagpb.PBNode.Repr.KeyAssembler"}.BeginMap(0)
}
...
...
@@ -3215,21 +3131,21 @@ func (ka *_PBNode__ReprKeyAssembler) AssignString(k string) error {
}
switch k {
case "Links":
if ka.s
&
fieldBit__PBNode_Links != 0 {
if ka.s
&
fieldBit__PBNode_Links != 0 {
return ipld.ErrRepeatedMapKey{&fieldName__PBNode_Links_serial}
}
ka.s += fieldBit__PBNode_Links
ka.state = maState_expectValue
ka.f = 0
case "Data":
if ka.s
&
fieldBit__PBNode_Data != 0 {
if ka.s
&
fieldBit__PBNode_Data != 0 {
return ipld.ErrRepeatedMapKey{&fieldName__PBNode_Data_serial}
}
ka.s += fieldBit__PBNode_Data
ka.state = maState_expectValue
ka.f = 1
default:
return ipld.ErrInvalidKey{TypeName:
"dagpb.PBNode.Repr", Key:
&_String{k}}
return ipld.ErrInvalidKey{TypeName:"dagpb.PBNode.Repr", Key:&_String{k}}
}
return nil
}
...
...
@@ -3261,7 +3177,6 @@ func (_String__Prototype) FromString(v string) (String, error) {
n := _String{v}
return &n, nil
}
type _String__Maybe struct {
m schema.Maybe
v String
...
...
@@ -3295,10 +3210,8 @@ func (m MaybeString) Must() String {
}
return m.v
}
var _ ipld.Node = (String)(&_String{})
var _ schema.TypedNode = (String)(&_String{})
func (String) ReprKind() ipld.ReprKind {
return ipld.ReprKind_String
}
...
...
@@ -3350,7 +3263,6 @@ func (String) AsLink() (ipld.Link, error) {
func (String) Prototype() ipld.NodePrototype {
return _String__Prototype{}
}
type _String__Prototype struct{}
func (_String__Prototype) NewBuilder() ipld.NodeBuilder {
...
...
@@ -3358,11 +3270,9 @@ func (_String__Prototype) NewBuilder() ipld.NodeBuilder {
nb.Reset()
return &nb
}
type _String__Builder struct {
_String__Assembler
}
func (nb *_String__Builder) Build() ipld.Node {
if *nb.m != schema.Maybe_Value {
panic("invalid state: cannot call Build on an assembler that's not finished")
...
...
@@ -3374,7 +3284,6 @@ func (nb *_String__Builder) Reset() {
var m schema.Maybe
*nb = _String__Builder{_String__Assembler{w: &w, m: &m}}
}
type _String__Assembler struct {
w *_String
m *schema.Maybe
...
...
@@ -3459,10 +3368,8 @@ func (String) Type() schema.Type {
func (n String) Representation() ipld.Node {
return (*_String__Repr)(n)
}
type _String__Repr = _String
var _ ipld.Node = &_String__Repr{}
type _String__ReprPrototype = _String__Prototype
type _String__ReprAssembler = _String__Assembler
ipldsch_types.go
View file @
07d051e5
...
...
@@ -5,7 +5,6 @@ package dagpb
import
(
ipld
"github.com/ipld/go-ipld-prime"
)
var
_
ipld
.
Node
=
nil
// suppress errors when this dependency is not referenced
// Type is a struct embeding a NodePrototype/Type for every Node implementation in this package.
// One of its major uses is to start the construction of a value.
...
...
@@ -74,3 +73,4 @@ type _PBNode struct {
// String matches the IPLD Schema type "String". It has string kind.
type
String
=
*
_String
type
_String
struct
{
x
string
}
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