mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-16 09:12:22 +00:00
Vector of unions for TS/JS and PHP (#4404)
* Eclipse ignore * TypeScript support * Prefixing enums * Test results * Merged JS and TS generators * Fixed AppVeyor build problems * Fixed more AppVeyor build problems * Fixed more AppVeyor build problems * Changed TS flag to options struct * Storing options by value * Removed unneeded const * Re-export support for unions * Uint support * Casting bools to numbers for mutation * TS shell tests * Reverted generates js test file to original version * Backing up js tests and properly generating test data * Not importing flatbuffers for TS test generation * Not overwriting generated js for tests * AppVeyor test fixes * Generating the most strict TS code possible * Not returning null when creating vectors * Not returning null from struct contructors * Vector of unions for ts/js * Sanity check for languages * Indentation fix + output test files * Vectors of unions for php * Fixes to union vector handling + tests
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
7cc72e4b11
commit
46bb05d952
94
tests/union_vector/Attacker.php
Normal file
94
tests/union_vector/Attacker.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace ;
|
||||
|
||||
use \Google\FlatBuffers\Struct;
|
||||
use \Google\FlatBuffers\Table;
|
||||
use \Google\FlatBuffers\ByteBuffer;
|
||||
use \Google\FlatBuffers\FlatBufferBuilder;
|
||||
|
||||
class Attacker extends Table
|
||||
{
|
||||
/**
|
||||
* @param ByteBuffer $bb
|
||||
* @return Attacker
|
||||
*/
|
||||
public static function getRootAsAttacker(ByteBuffer $bb)
|
||||
{
|
||||
$obj = new Attacker();
|
||||
return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb));
|
||||
}
|
||||
|
||||
public static function AttackerIdentifier()
|
||||
{
|
||||
return "MOVI";
|
||||
}
|
||||
|
||||
public static function AttackerBufferHasIdentifier(ByteBuffer $buf)
|
||||
{
|
||||
return self::__has_identifier($buf, self::AttackerIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $_i offset
|
||||
* @param ByteBuffer $_bb
|
||||
* @return Attacker
|
||||
**/
|
||||
public function init($_i, ByteBuffer $_bb)
|
||||
{
|
||||
$this->bb_pos = $_i;
|
||||
$this->bb = $_bb;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSwordAttackDamage()
|
||||
{
|
||||
$o = $this->__offset(4);
|
||||
return $o != 0 ? $this->bb->getInt($o + $this->bb_pos) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return void
|
||||
*/
|
||||
public static function startAttacker(FlatBufferBuilder $builder)
|
||||
{
|
||||
$builder->StartObject(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return Attacker
|
||||
*/
|
||||
public static function createAttacker(FlatBufferBuilder $builder, $sword_attack_damage)
|
||||
{
|
||||
$builder->startObject(1);
|
||||
self::addSwordAttackDamage($builder, $sword_attack_damage);
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param int
|
||||
* @return void
|
||||
*/
|
||||
public static function addSwordAttackDamage(FlatBufferBuilder $builder, $swordAttackDamage)
|
||||
{
|
||||
$builder->addIntX(0, $swordAttackDamage, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return int table offset
|
||||
*/
|
||||
public static function endAttacker(FlatBufferBuilder $builder)
|
||||
{
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user