mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-14 16:36:55 +00:00
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:
100
tests/namespace_test/NamespaceA/TableInC.php
Normal file
100
tests/namespace_test/NamespaceA/TableInC.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
// automatically generated, do not modify
|
||||
|
||||
namespace NamespaceA;
|
||||
|
||||
use \Google\FlatBuffers\Struct;
|
||||
use \Google\FlatBuffers\Table;
|
||||
use \Google\FlatBuffers\ByteBuffer;
|
||||
use \Google\FlatBuffers\FlatBufferBuilder;
|
||||
|
||||
class TableInC extends Table
|
||||
{
|
||||
/**
|
||||
* @param ByteBuffer $bb
|
||||
* @return TableInC
|
||||
*/
|
||||
public static function getRootAsTableInC(ByteBuffer $bb)
|
||||
{
|
||||
$obj = new TableInC();
|
||||
return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $_i offset
|
||||
* @param ByteBuffer $_bb
|
||||
* @return TableInC
|
||||
**/
|
||||
public function init($_i, ByteBuffer $_bb)
|
||||
{
|
||||
$this->bb_pos = $_i;
|
||||
$this->bb = $_bb;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReferToA1()
|
||||
{
|
||||
$obj = new TableInFirstNS();
|
||||
$o = $this->__offset(4);
|
||||
return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0;
|
||||
}
|
||||
|
||||
public function getReferToA2()
|
||||
{
|
||||
$obj = new SecondTableInA();
|
||||
$o = $this->__offset(6);
|
||||
return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return void
|
||||
*/
|
||||
public static function startTableInC(FlatBufferBuilder $builder)
|
||||
{
|
||||
$builder->StartObject(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return TableInC
|
||||
*/
|
||||
public static function createTableInC(FlatBufferBuilder $builder, $refer_to_a1, $refer_to_a2)
|
||||
{
|
||||
$builder->startObject(2);
|
||||
self::addReferToA1($builder, $refer_to_a1);
|
||||
self::addReferToA2($builder, $refer_to_a2);
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param int
|
||||
* @return void
|
||||
*/
|
||||
public static function addReferToA1(FlatBufferBuilder $builder, $referToA1)
|
||||
{
|
||||
$builder->addOffsetX(0, $referToA1, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param int
|
||||
* @return void
|
||||
*/
|
||||
public static function addReferToA2(FlatBufferBuilder $builder, $referToA2)
|
||||
{
|
||||
$builder->addOffsetX(1, $referToA2, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return int table offset
|
||||
*/
|
||||
public static function endTableInC(FlatBufferBuilder $builder)
|
||||
{
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user