Fixed namespace code generation for C++

The code generator was assuming all declarations for the current
file sit in the same namepace. Now uses the "on demand" namespace
switching we had for the forward declarations.

Also fixed a bug related to namespace lookup.

Change-Id: Ib54a3efbc752cbb9590302fa0707c0c73448db3d
Tested: on Linux.
This commit is contained in:
Wouter van Oortmerssen
2016-02-12 16:20:33 -08:00
parent 472fb12273
commit 20c0082ee5
18 changed files with 1000 additions and 223 deletions

View File

@@ -0,0 +1,32 @@
// automatically generated, do not modify
package NamespaceA
import (
flatbuffers "github.com/google/flatbuffers/go"
)
type SecondTableInA struct {
_tab flatbuffers.Table
}
func (rcv *SecondTableInA) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i
}
func (rcv *SecondTableInA) ReferToC(obj *TableInC) *TableInC {
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
if o != 0 {
x := rcv._tab.Indirect(o + rcv._tab.Pos)
if obj == nil {
obj = new(TableInC)
}
obj.Init(rcv._tab.Bytes, x)
return obj
}
return nil
}
func SecondTableInAStart(builder *flatbuffers.Builder) { builder.StartObject(1) }
func SecondTableInAAddReferToC(builder *flatbuffers.Builder, referToC flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(referToC), 0) }
func SecondTableInAEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }