You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm surfacing your email question to a ticket so it is public; other people may have the same question.
I haven't implemented enum support. If you would like to assist with this, the first step would be to write down several examples of the starting and ending text that involve transformation of enums, and then to put those into a test file. The bambam project is entirely test driven (BDD to the extent possible), and this is an especially valuable approach for compilers (like bambam). Once you have a failing test in place, we can look at how to implement it. I would suggest starting a new branch so that the master doesn't have the failing test on it.
Best regards,
Jason
You asked:
Imagine these structs:
type MyStruct struct {
Hello []string `capid:"0"`
World []int `capid:"1"`
}
type People struct {
Name string `capid:"0"`
LastName string `capid:"1"`
}
type MType int
const (
PeopleType MType = iota
MyStructType
)
type MsgType struct {
Msg MType `capid:"0"`
MsgSize int `capid:"1"`
}
For these go structures I want to create a schema with bambam including the code generation.
Ok, now I call bambam and what I end up with ist the following schema:
@0x827b101c9c0b86fb;
using Go = import "go.capnp";
$Go.package("main");
$Go.import("testpkg");
struct MsgTypeCapn {
msg @0: Int64;
msgSize @1: Int64;
}
struct MyStructCapn {
hello @0: List(Text);
world @1: List(Int64);
}
struct PeopleCapn {
name @0: Text;
lastName @1: Text;
}
In the generated code:
func MsgTypeCapnToGo(src MsgTypeCapn, dest *MsgType) *MsgType {
if dest == nil {
dest = &MsgType{}
}
dest.Msg = *MTypeCapnToGo(src.Msg(), nil)
dest.MsgSize = int(src.MsgSize())
return dest
}
You should used fenced code blocks for code, that way it's easier to read (indentation preserved, mono font, optional highlighting, and content won't get misinterpreted as other markup).
Hi Dmitri (@shurcooL), thanks for your comment. I've appreciated your contributions to the Go community, particularly go-goon which I find invaluable. Are you using bambam?
Hi Björn (@HyperDrummer),
I'm surfacing your email question to a ticket so it is public; other people may have the same question.
I haven't implemented enum support. If you would like to assist with this, the first step would be to write down several examples of the starting and ending text that involve transformation of enums, and then to put those into a test file. The bambam project is entirely test driven (BDD to the extent possible), and this is an especially valuable approach for compilers (like bambam). Once you have a failing test in place, we can look at how to implement it. I would suggest starting a new branch so that the master doesn't have the failing test on it.
Best regards,
Jason
You asked:
Imagine these structs:
For these go structures I want to create a schema with bambam including the code generation.
Ok, now I call bambam and what I end up with ist the following schema:
In the generated code:
which leads to build errors:
./translateCapn.go:37: undefined: MTypeCapnToGo
./translateCapn.go:47: undefined: MTypeGoToCapn
The undefined data types never got generated.
Do you have an idea how to use enums with code generation?
Thanks in advance
Björn
The text was updated successfully, but these errors were encountered: