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
Expand all
Hide 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
package
main
// based on https://github.com/ipld/go-ipld-prime-proto/blob/master/gen/main.go
// based on https://github.com/ipld/go-ipld-prime-proto/blob/master/gen/main.go
import
(
import
(
"os/exec"
"fmt"
"os"
"github.com/ipld/go-ipld-prime/schema"
"github.com/ipld/go-ipld-prime/schema"
gengo
"github.com/ipld/go-ipld-prime/schema/gen/go"
gengo
"github.com/ipld/go-ipld-prime/schema/gen/go"
)
)
func
main
()
{
func
main
()
{
ts
:=
schema
.
TypeSystem
{}
ts
:=
schema
.
TypeSystem
{}
ts
.
Init
()
ts
.
Init
()
adjCfg
:=
&
gengo
.
AdjunctCfg
{}
adjCfg
:=
&
gengo
.
AdjunctCfg
{}
...
@@ -55,8 +57,12 @@ func main() {
...
@@ -55,8 +57,12 @@ func main() {
schema
.
SpawnStructRepresentationMap
(
nil
),
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
)
gengo
.
Generate
(
"."
,
pkgName
,
ts
,
adjCfg
)
exec
.
Command
(
"go"
,
"fmt"
)
.
Run
()
}
}
ipldsch_minima.go
View file @
07d051e5
...
@@ -10,14 +10,14 @@ import (
...
@@ -10,14 +10,14 @@ import (
)
)
const
(
const
(
midvalue
=
schema
.
Maybe
(
4
)
midvalue
=
schema
.
Maybe
(
4
)
allowNull
=
schema
.
Maybe
(
5
)
allowNull
=
schema
.
Maybe
(
5
)
)
)
type
maState
uint8
type
maState
uint8
const
(
const
(
maState_initial
maState
=
iota
maState_initial
maState
=
iota
maState_midKey
maState_midKey
maState_expectValue
maState_expectValue
maState_midValue
maState_midValue
...
@@ -27,25 +27,24 @@ const (
...
@@ -27,25 +27,24 @@ const (
type
laState
uint8
type
laState
uint8
const
(
const
(
laState_initial
laState
=
iota
laState_initial
laState
=
iota
laState_midValue
laState_midValue
laState_finished
laState_finished
)
)
type
_ErrorThunkAssembler
struct
{
type
_ErrorThunkAssembler
struct
{
e
error
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
)
BeginList
(
_
int
)
(
ipld
.
ListAssembler
,
error
)
{
return
nil
,
ea
.
e
}
func
(
ea
_ErrorThunkAssembler
)
AssignNull
()
error
{
return
ea
.
e
}
func
(
ea
_ErrorThunkAssembler
)
AssignNull
()
error
{
return
ea
.
e
}
func
(
ea
_ErrorThunkAssembler
)
AssignBool
(
bool
)
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
)
AssignInt
(
int
)
error
{
return
ea
.
e
}
func
(
ea
_ErrorThunkAssembler
)
AssignFloat
(
float64
)
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
)
AssignString
(
string
)
error
{
return
ea
.
e
}
func
(
ea
_ErrorThunkAssembler
)
AssignBytes
([]
byte
)
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
)
AssignLink
(
ipld
.
Link
)
error
{
return
ea
.
e
}
func
(
ea
_ErrorThunkAssembler
)
AssignNode
(
ipld
.
Node
)
error
{
return
ea
.
e
}
func
(
ea
_ErrorThunkAssembler
)
AssignNode
(
ipld
.
Node
)
error
{
return
ea
.
e
}
func
(
ea
_ErrorThunkAssembler
)
Prototype
()
ipld
.
NodePrototype
{
func
(
ea
_ErrorThunkAssembler
)
Prototype
()
ipld
.
NodePrototype
{
panic
(
fmt
.
Errorf
(
"cannot get prototype from error-carrying assembler: already derailed with error: %w"
,
ea
.
e
))
panic
(
fmt
.
Errorf
(
"cannot get prototype from error-carrying assembler: already derailed with error: %w"
,
ea
.
e
))
}
}
ipldsch_satisfaction.go
View file @
07d051e5
This diff is collapsed.
Click to expand it.
ipldsch_types.go
View file @
07d051e5
...
@@ -5,7 +5,6 @@ package dagpb
...
@@ -5,7 +5,6 @@ package dagpb
import
(
import
(
ipld
"github.com/ipld/go-ipld-prime"
ipld
"github.com/ipld/go-ipld-prime"
)
)
var
_
ipld
.
Node
=
nil
// suppress errors when this dependency is not referenced
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.
// 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.
// 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
...
@@ -20,20 +19,20 @@ var _ ipld.Node = nil // suppress errors when this dependency is not referenced
var
Type
typeSlab
var
Type
typeSlab
type
typeSlab
struct
{
type
typeSlab
struct
{
Bytes
_Bytes__Prototype
Bytes
_Bytes__Prototype
Bytes__Repr
_Bytes__ReprPrototype
Bytes__Repr
_Bytes__ReprPrototype
Int
_Int__Prototype
Int
_Int__Prototype
Int__Repr
_Int__ReprPrototype
Int__Repr
_Int__ReprPrototype
Link
_Link__Prototype
Link
_Link__Prototype
Link__Repr
_Link__ReprPrototype
Link__Repr
_Link__ReprPrototype
PBLink
_PBLink__Prototype
PBLink
_PBLink__Prototype
PBLink__Repr
_PBLink__ReprPrototype
PBLink__Repr
_PBLink__ReprPrototype
PBLinks
_PBLinks__Prototype
PBLinks
_PBLinks__Prototype
PBLinks__Repr
_PBLinks__ReprPrototype
PBLinks__Repr
_PBLinks__ReprPrototype
PBNode
_PBNode__Prototype
PBNode
_PBNode__Prototype
PBNode__Repr
_PBNode__ReprPrototype
PBNode__Repr
_PBNode__ReprPrototype
String
_String__Prototype
String
_String__Prototype
String__Repr
_String__ReprPrototype
String__Repr
_String__ReprPrototype
}
}
// --- type definitions follow ---
// --- type definitions follow ---
...
@@ -53,8 +52,8 @@ type _Link struct{ x ipld.Link }
...
@@ -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.
// PBLink matches the IPLD Schema type "PBLink". It has Struct type-kind, and may be interrogated like map kind.
type
PBLink
=
*
_PBLink
type
PBLink
=
*
_PBLink
type
_PBLink
struct
{
type
_PBLink
struct
{
Hash
_Link
Hash
_Link
Name
_String__Maybe
Name
_String__Maybe
Tsize
_Int__Maybe
Tsize
_Int__Maybe
}
}
...
@@ -68,9 +67,10 @@ type _PBLinks struct {
...
@@ -68,9 +67,10 @@ type _PBLinks struct {
type
PBNode
=
*
_PBNode
type
PBNode
=
*
_PBNode
type
_PBNode
struct
{
type
_PBNode
struct
{
Links
_PBLinks
Links
_PBLinks
Data
_Bytes__Maybe
Data
_Bytes__Maybe
}
}
// String matches the IPLD Schema type "String". It has string kind.
// String matches the IPLD Schema type "String". It has string kind.
type
String
=
*
_String
type
String
=
*
_String
type
_String
struct
{
x
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