Unverified Commit 07d051e5 authored by Rod Vagg's avatar Rod Vagg

betterer codegen invocation

parent 035ab815
// +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)
}
......@@ -10,14 +10,14 @@ import (
)
const (
midvalue = schema.Maybe(4)
midvalue = schema.Maybe(4)
allowNull = schema.Maybe(5)
)
type maState uint8
const (
maState_initial maState = iota
maState_initial maState = iota
maState_midKey
maState_expectValue
maState_midValue
......@@ -27,25 +27,24 @@ const (
type laState uint8
const (
laState_initial laState = iota
laState_initial laState = iota
laState_midValue
laState_finished
)
type _ErrorThunkAssembler struct {
e error
}
func (ea _ErrorThunkAssembler) BeginMap(_ int) (ipld.MapAssembler, error) { return nil, ea.e }
func (ea _ErrorThunkAssembler) BeginMap(_ int) (ipld.MapAssembler, error) { return nil, ea.e }
func (ea _ErrorThunkAssembler) BeginList(_ int) (ipld.ListAssembler, error) { return nil, ea.e }
func (ea _ErrorThunkAssembler) AssignNull() error { return ea.e }
func (ea _ErrorThunkAssembler) AssignBool(bool) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignInt(int) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignFloat(float64) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignString(string) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignBytes([]byte) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignLink(ipld.Link) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignNode(ipld.Node) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignNull() error { return ea.e }
func (ea _ErrorThunkAssembler) AssignBool(bool) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignInt(int) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignFloat(float64) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignString(string) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignBytes([]byte) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignLink(ipld.Link) error { return ea.e }
func (ea _ErrorThunkAssembler) AssignNode(ipld.Node) error { return ea.e }
func (ea _ErrorThunkAssembler) Prototype() ipld.NodePrototype {
panic(fmt.Errorf("cannot get prototype from error-carrying assembler: already derailed with error: %w", ea.e))
}
This diff is collapsed.
......@@ -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.
......@@ -20,20 +19,20 @@ var _ ipld.Node = nil // suppress errors when this dependency is not referenced
var Type typeSlab
type typeSlab struct {
Bytes _Bytes__Prototype
Bytes__Repr _Bytes__ReprPrototype
Int _Int__Prototype
Int__Repr _Int__ReprPrototype
Link _Link__Prototype
Link__Repr _Link__ReprPrototype
PBLink _PBLink__Prototype
PBLink__Repr _PBLink__ReprPrototype
Bytes _Bytes__Prototype
Bytes__Repr _Bytes__ReprPrototype
Int _Int__Prototype
Int__Repr _Int__ReprPrototype
Link _Link__Prototype
Link__Repr _Link__ReprPrototype
PBLink _PBLink__Prototype
PBLink__Repr _PBLink__ReprPrototype
PBLinks _PBLinks__Prototype
PBLinks__Repr _PBLinks__ReprPrototype
PBNode _PBNode__Prototype
PBNode__Repr _PBNode__ReprPrototype
String _String__Prototype
String__Repr _String__ReprPrototype
PBNode _PBNode__Prototype
PBNode__Repr _PBNode__ReprPrototype
String _String__Prototype
String__Repr _String__ReprPrototype
}
// --- type definitions follow ---
......@@ -53,8 +52,8 @@ type _Link struct{ x ipld.Link }
// PBLink matches the IPLD Schema type "PBLink". It has Struct type-kind, and may be interrogated like map kind.
type PBLink = *_PBLink
type _PBLink struct {
Hash _Link
Name _String__Maybe
Hash _Link
Name _String__Maybe
Tsize _Int__Maybe
}
......@@ -68,9 +67,10 @@ type _PBLinks struct {
type PBNode = *_PBNode
type _PBNode struct {
Links _PBLinks
Data _Bytes__Maybe
Data _Bytes__Maybe
}
// String matches the IPLD Schema type "String". It has string kind.
type String = *_String
type _String struct{ x string }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment