mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-19 18:25:42 +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:
@@ -48,10 +48,28 @@ class TableInFirstNS extends Table
|
||||
return $o != 0 ? $this->bb->getSbyte($o + $this->bb_pos) : \NamespaceA\NamespaceB\EnumInNestedNS::A;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return byte
|
||||
*/
|
||||
public function getFooUnionType()
|
||||
{
|
||||
$o = $this->__offset(8);
|
||||
return $o != 0 ? $this->bb->getByte($o + $this->bb_pos) : \NamespaceA\NamespaceB\UnionInNestedNS::NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returnint
|
||||
*/
|
||||
public function getFooUnion($obj)
|
||||
{
|
||||
$o = $this->__offset(10);
|
||||
return $o != 0 ? $this->__union($obj, $o) : null;
|
||||
}
|
||||
|
||||
public function getFooStruct()
|
||||
{
|
||||
$obj = new StructInNestedNS();
|
||||
$o = $this->__offset(8);
|
||||
$o = $this->__offset(12);
|
||||
return $o != 0 ? $obj->init($o + $this->bb_pos, $this->bb) : 0;
|
||||
}
|
||||
|
||||
@@ -61,18 +79,20 @@ class TableInFirstNS extends Table
|
||||
*/
|
||||
public static function startTableInFirstNS(FlatBufferBuilder $builder)
|
||||
{
|
||||
$builder->StartObject(3);
|
||||
$builder->StartObject(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return TableInFirstNS
|
||||
*/
|
||||
public static function createTableInFirstNS(FlatBufferBuilder $builder, $foo_table, $foo_enum, $foo_struct)
|
||||
public static function createTableInFirstNS(FlatBufferBuilder $builder, $foo_table, $foo_enum, $foo_union_type, $foo_union, $foo_struct)
|
||||
{
|
||||
$builder->startObject(3);
|
||||
$builder->startObject(5);
|
||||
self::addFooTable($builder, $foo_table);
|
||||
self::addFooEnum($builder, $foo_enum);
|
||||
self::addFooUnionType($builder, $foo_union_type);
|
||||
self::addFooUnion($builder, $foo_union);
|
||||
self::addFooStruct($builder, $foo_struct);
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
@@ -98,6 +118,21 @@ class TableInFirstNS extends Table
|
||||
$builder->addSbyteX(1, $fooEnum, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param byte
|
||||
* @return void
|
||||
*/
|
||||
public static function addFooUnionType(FlatBufferBuilder $builder, $fooUnionType)
|
||||
{
|
||||
$builder->addByteX(2, $fooUnionType, 0);
|
||||
}
|
||||
|
||||
public static function addFooUnion(FlatBufferBuilder $builder, $offset)
|
||||
{
|
||||
$builder->addOffsetX(3, $offset, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param int
|
||||
@@ -105,7 +140,7 @@ class TableInFirstNS extends Table
|
||||
*/
|
||||
public static function addFooStruct(FlatBufferBuilder $builder, $fooStruct)
|
||||
{
|
||||
$builder->addStructX(2, $fooStruct, 0);
|
||||
$builder->addStructX(4, $fooStruct, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user