mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 10:24:27 +00:00
[Rust] Ensure unions are referenced with the correct path (#6422)
* Add codegen test for namespaced unions * [Rust] Handle cross-namespace union use * [Rust] Test namespace handling * [Rust] Drop trailing whitespace in codegen * [Rust] Set flags in generate_code.bat to match .sh * [C#] Add additional namespace test file
This commit is contained in:
@@ -37,8 +37,23 @@ function TableInFirstNS_mt:FooEnum()
|
||||
end
|
||||
return 0
|
||||
end
|
||||
function TableInFirstNS_mt:FooStruct()
|
||||
function TableInFirstNS_mt:FooUnionType()
|
||||
local o = self.view:Offset(8)
|
||||
if o ~= 0 then
|
||||
return self.view:Get(flatbuffers.N.Uint8, o + self.view.pos)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
function TableInFirstNS_mt:FooUnion()
|
||||
local o = self.view:Offset(10)
|
||||
if o ~= 0 then
|
||||
local obj = flatbuffers.view.New(require('flatbuffers.binaryarray').New(0), 0)
|
||||
self.view:Union(obj, o)
|
||||
return obj
|
||||
end
|
||||
end
|
||||
function TableInFirstNS_mt:FooStruct()
|
||||
local o = self.view:Offset(12)
|
||||
if o ~= 0 then
|
||||
local x = o + self.view.pos
|
||||
local obj = require('NamespaceA.NamespaceB.StructInNestedNS').New()
|
||||
@@ -46,10 +61,12 @@ function TableInFirstNS_mt:FooStruct()
|
||||
return obj
|
||||
end
|
||||
end
|
||||
function TableInFirstNS.Start(builder) builder:StartObject(3) end
|
||||
function TableInFirstNS.Start(builder) builder:StartObject(5) end
|
||||
function TableInFirstNS.AddFooTable(builder, fooTable) builder:PrependUOffsetTRelativeSlot(0, fooTable, 0) end
|
||||
function TableInFirstNS.AddFooEnum(builder, fooEnum) builder:PrependInt8Slot(1, fooEnum, 0) end
|
||||
function TableInFirstNS.AddFooStruct(builder, fooStruct) builder:PrependStructSlot(2, fooStruct, 0) end
|
||||
function TableInFirstNS.AddFooUnionType(builder, fooUnionType) builder:PrependUint8Slot(2, fooUnionType, 0) end
|
||||
function TableInFirstNS.AddFooUnion(builder, fooUnion) builder:PrependUOffsetTRelativeSlot(3, fooUnion, 0) end
|
||||
function TableInFirstNS.AddFooStruct(builder, fooStruct) builder:PrependStructSlot(4, fooStruct, 0) end
|
||||
function TableInFirstNS.End(builder) return builder:EndObject() end
|
||||
|
||||
return TableInFirstNS -- return the module
|
||||
Reference in New Issue
Block a user