forked from BigfootDev/flatbuffers
Track and emit required FlatBuffers namespace imports in generated Go code. Update Go code generator by moving most functionality into the generator class, to facilitate namespace tracking. (Note that the git diff in this combined commit may appear large due to this refactoring, but very little code was actually changed.) Update Go code generator by tracking namespace imports when generating FlatBuffers code. Update Go code generator by emitting package imports to correctly reference code in other FlatBuffers namespaces. Create Go test that checks the usage of InParentNamespace objects (as defined in the example schema). Create Docker test that checks the Go language port. Fixes #4883 Fixes #3927 Individual commits: * remove "static" from soon-to-be method functions * move almost all functions into class as methods * set current namespace and emit package names if needed * track imported namespaces * parent namespaces work * docker test for go ^1.11 * update base image name for go docker test * remove cerr debugging * formatting fixes * re-run generate_code.sh * explicitly test namespace imports and usage
84 lines
2.2 KiB
Go
84 lines
2.2 KiB
Go
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
|
|
|
|
package NamespaceA
|
|
|
|
import (
|
|
flatbuffers "github.com/google/flatbuffers/go"
|
|
|
|
NamespaceA__NamespaceB "NamespaceA/NamespaceB"
|
|
)
|
|
|
|
type TableInFirstNS struct {
|
|
_tab flatbuffers.Table
|
|
}
|
|
|
|
func GetRootAsTableInFirstNS(buf []byte, offset flatbuffers.UOffsetT) *TableInFirstNS {
|
|
n := flatbuffers.GetUOffsetT(buf[offset:])
|
|
x := &TableInFirstNS{}
|
|
x.Init(buf, n+offset)
|
|
return x
|
|
}
|
|
|
|
func (rcv *TableInFirstNS) Init(buf []byte, i flatbuffers.UOffsetT) {
|
|
rcv._tab.Bytes = buf
|
|
rcv._tab.Pos = i
|
|
}
|
|
|
|
func (rcv *TableInFirstNS) Table() flatbuffers.Table {
|
|
return rcv._tab
|
|
}
|
|
|
|
func (rcv *TableInFirstNS) FooTable(obj *NamespaceA__NamespaceB.TableInNestedNS) *NamespaceA__NamespaceB.TableInNestedNS {
|
|
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
|
if o != 0 {
|
|
x := rcv._tab.Indirect(o + rcv._tab.Pos)
|
|
if obj == nil {
|
|
obj = new(NamespaceA__NamespaceB.TableInNestedNS)
|
|
}
|
|
obj.Init(rcv._tab.Bytes, x)
|
|
return obj
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (rcv *TableInFirstNS) FooEnum() EnumInNestedNS {
|
|
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
|
|
if o != 0 {
|
|
return rcv._tab.GetInt8(o + rcv._tab.Pos)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
func (rcv *TableInFirstNS) MutateFooEnum(n EnumInNestedNS) bool {
|
|
return rcv._tab.MutateInt8Slot(6, n)
|
|
}
|
|
|
|
func (rcv *TableInFirstNS) FooStruct(obj *NamespaceA__NamespaceB.StructInNestedNS) *NamespaceA__NamespaceB.StructInNestedNS {
|
|
o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
|
|
if o != 0 {
|
|
x := o + rcv._tab.Pos
|
|
if obj == nil {
|
|
obj = new(NamespaceA__NamespaceB.StructInNestedNS)
|
|
}
|
|
obj.Init(rcv._tab.Bytes, x)
|
|
return obj
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func TableInFirstNSStart(builder *flatbuffers.Builder) {
|
|
builder.StartObject(3)
|
|
}
|
|
func TableInFirstNSAddFooTable(builder *flatbuffers.Builder, fooTable flatbuffers.UOffsetT) {
|
|
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(fooTable), 0)
|
|
}
|
|
func TableInFirstNSAddFooEnum(builder *flatbuffers.Builder, fooEnum int8) {
|
|
builder.PrependInt8Slot(1, fooEnum, 0)
|
|
}
|
|
func TableInFirstNSAddFooStruct(builder *flatbuffers.Builder, fooStruct flatbuffers.UOffsetT) {
|
|
builder.PrependStructSlot(2, flatbuffers.UOffsetT(fooStruct), 0)
|
|
}
|
|
func TableInFirstNSEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
|
return builder.EndObject()
|
|
}
|