-
Notifications
You must be signed in to change notification settings - Fork 50
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 #123 from ipld/gendemo-regularization
clean up node/gendemo regeneration
- Loading branch information
Showing
5 changed files
with
124 additions
and
107 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 @@ | ||
// The gendemo package contains some what codegen output code, | ||
// so that it can demonstrate what schema-based codegen looks and acts like. | ||
// | ||
// The main purpose is to benchmark things, | ||
// and to provide an easy-to-look-at _thing_ for prospective users | ||
// who want to lay eyes on generated code without needing to get up-and-running with the generator themselves. | ||
// | ||
// This package is absolutely _not_ full of general purpose node implementations | ||
// that you should use in _any_ application. | ||
// | ||
// The input info for the code generation is in `gen.go` file. | ||
// (This is currently wired directly in code; in the future, the same instructions | ||
// will be extracted to an IPLD Schema file and standard tools will be used to process it.) | ||
// The code generation is triggered by `go:generate` comments in the `doc.go` file. | ||
|
||
//go:generate go run gen.go | ||
//go:generate gofmt -w . | ||
|
||
package gendemo |
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,28 @@ | ||
// +build ignore | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/ipld/go-ipld-prime/schema" | ||
gengo "github.com/ipld/go-ipld-prime/schema/gen/go" | ||
) | ||
|
||
func main() { | ||
pkgName := "gendemo" | ||
ts := schema.TypeSystem{} | ||
ts.Init() | ||
adjCfg := &gengo.AdjunctCfg{} | ||
ts.Accumulate(schema.SpawnInt("Int")) | ||
ts.Accumulate(schema.SpawnString("String")) | ||
ts.Accumulate(schema.SpawnStruct("Msg3", | ||
[]schema.StructField{ | ||
schema.SpawnStructField("whee", "Int", false, false), | ||
schema.SpawnStructField("woot", "Int", false, false), | ||
schema.SpawnStructField("waga", "Int", false, false), | ||
}, | ||
schema.SpawnStructRepresentationMap(nil), | ||
)) | ||
ts.Accumulate(schema.SpawnMap("Map__String__Msg3", | ||
"String", "Msg3", false)) | ||
gengo.Generate(".", pkgName, ts, adjCfg) | ||
} |
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.