Home | History | Annotate | Download | only in Example
      1 <?php
      2 // automatically generated by the FlatBuffers compiler, do not modify
      3 
      4 namespace MyGame\Example;
      5 
      6 use \Google\FlatBuffers\Struct;
      7 use \Google\FlatBuffers\Table;
      8 use \Google\FlatBuffers\ByteBuffer;
      9 use \Google\FlatBuffers\FlatBufferBuilder;
     10 
     11 /// an example documentation comment: monster object
     12 class Monster extends Table
     13 {
     14     /**
     15      * @param ByteBuffer $bb
     16      * @return Monster
     17      */
     18     public static function getRootAsMonster(ByteBuffer $bb)
     19     {
     20         $obj = new Monster();
     21         return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb));
     22     }
     23 
     24     public static function MonsterIdentifier()
     25     {
     26         return "MONS";
     27     }
     28 
     29     public static function MonsterBufferHasIdentifier(ByteBuffer $buf)
     30     {
     31         return self::__has_identifier($buf, self::MonsterIdentifier());
     32     }
     33 
     34     public static function MonsterExtension()
     35     {
     36         return "mon";
     37     }
     38 
     39     /**
     40      * @param int $_i offset
     41      * @param ByteBuffer $_bb
     42      * @return Monster
     43      **/
     44     public function init($_i, ByteBuffer $_bb)
     45     {
     46         $this->bb_pos = $_i;
     47         $this->bb = $_bb;
     48         return $this;
     49     }
     50 
     51     public function getPos()
     52     {
     53         $obj = new Vec3();
     54         $o = $this->__offset(4);
     55         return $o != 0 ? $obj->init($o + $this->bb_pos, $this->bb) : 0;
     56     }
     57 
     58     /**
     59      * @return short
     60      */
     61     public function getMana()
     62     {
     63         $o = $this->__offset(6);
     64         return $o != 0 ? $this->bb->getShort($o + $this->bb_pos) : 150;
     65     }
     66 
     67     /**
     68      * @return short
     69      */
     70     public function getHp()
     71     {
     72         $o = $this->__offset(8);
     73         return $o != 0 ? $this->bb->getShort($o + $this->bb_pos) : 100;
     74     }
     75 
     76     public function getName()
     77     {
     78         $o = $this->__offset(10);
     79         return $o != 0 ? $this->__string($o + $this->bb_pos) : null;
     80     }
     81 
     82     /**
     83      * @param int offset
     84      * @return byte
     85      */
     86     public function getInventory($j)
     87     {
     88         $o = $this->__offset(14);
     89         return $o != 0 ? $this->bb->getByte($this->__vector($o) + $j * 1) : 0;
     90     }
     91 
     92     /**
     93      * @return int
     94      */
     95     public function getInventoryLength()
     96     {
     97         $o = $this->__offset(14);
     98         return $o != 0 ? $this->__vector_len($o) : 0;
     99     }
    100 
    101     /**
    102      * @return string
    103      */
    104     public function getInventoryBytes()
    105     {
    106         return $this->__vector_as_bytes(14);
    107     }
    108 
    109     /**
    110      * @return sbyte
    111      */
    112     public function getColor()
    113     {
    114         $o = $this->__offset(16);
    115         return $o != 0 ? $this->bb->getSbyte($o + $this->bb_pos) : \MyGame\Example\Color::Blue;
    116     }
    117 
    118     /**
    119      * @return byte
    120      */
    121     public function getTestType()
    122     {
    123         $o = $this->__offset(18);
    124         return $o != 0 ? $this->bb->getByte($o + $this->bb_pos) : \MyGame\Example\Any::NONE;
    125     }
    126 
    127     /**
    128      * @returnint
    129      */
    130     public function getTest($obj)
    131     {
    132         $o = $this->__offset(20);
    133         return $o != 0 ? $this->__union($obj, $o) : null;
    134     }
    135 
    136     /**
    137      * @returnVectorOffset
    138      */
    139     public function getTest4($j)
    140     {
    141         $o = $this->__offset(22);
    142         $obj = new Test();
    143         return $o != 0 ? $obj->init($this->__vector($o) + $j *4, $this->bb) : null;
    144     }
    145 
    146     /**
    147      * @return int
    148      */
    149     public function getTest4Length()
    150     {
    151         $o = $this->__offset(22);
    152         return $o != 0 ? $this->__vector_len($o) : 0;
    153     }
    154 
    155     /**
    156      * @param int offset
    157      * @return string
    158      */
    159     public function getTestarrayofstring($j)
    160     {
    161         $o = $this->__offset(24);
    162         return $o != 0 ? $this->__string($this->__vector($o) + $j * 4) : 0;
    163     }
    164 
    165     /**
    166      * @return int
    167      */
    168     public function getTestarrayofstringLength()
    169     {
    170         $o = $this->__offset(24);
    171         return $o != 0 ? $this->__vector_len($o) : 0;
    172     }
    173 
    174 /// an example documentation comment: this will end up in the generated code
    175 /// multiline too
    176     /**
    177      * @returnVectorOffset
    178      */
    179     public function getTestarrayoftables($j)
    180     {
    181         $o = $this->__offset(26);
    182         $obj = new Monster();
    183         return $o != 0 ? $obj->init($this->__indirect($this->__vector($o) + $j * 4), $this->bb) : null;
    184     }
    185 
    186     /**
    187      * @return int
    188      */
    189     public function getTestarrayoftablesLength()
    190     {
    191         $o = $this->__offset(26);
    192         return $o != 0 ? $this->__vector_len($o) : 0;
    193     }
    194 
    195     public function getEnemy()
    196     {
    197         $obj = new Monster();
    198         $o = $this->__offset(28);
    199         return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0;
    200     }
    201 
    202     /**
    203      * @param int offset
    204      * @return byte
    205      */
    206     public function getTestnestedflatbuffer($j)
    207     {
    208         $o = $this->__offset(30);
    209         return $o != 0 ? $this->bb->getByte($this->__vector($o) + $j * 1) : 0;
    210     }
    211 
    212     /**
    213      * @return int
    214      */
    215     public function getTestnestedflatbufferLength()
    216     {
    217         $o = $this->__offset(30);
    218         return $o != 0 ? $this->__vector_len($o) : 0;
    219     }
    220 
    221     /**
    222      * @return string
    223      */
    224     public function getTestnestedflatbufferBytes()
    225     {
    226         return $this->__vector_as_bytes(30);
    227     }
    228 
    229     public function getTestempty()
    230     {
    231         $obj = new Stat();
    232         $o = $this->__offset(32);
    233         return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0;
    234     }
    235 
    236     /**
    237      * @return bool
    238      */
    239     public function getTestbool()
    240     {
    241         $o = $this->__offset(34);
    242         return $o != 0 ? $this->bb->getBool($o + $this->bb_pos) : false;
    243     }
    244 
    245     /**
    246      * @return int
    247      */
    248     public function getTesthashs32Fnv1()
    249     {
    250         $o = $this->__offset(36);
    251         return $o != 0 ? $this->bb->getInt($o + $this->bb_pos) : 0;
    252     }
    253 
    254     /**
    255      * @return uint
    256      */
    257     public function getTesthashu32Fnv1()
    258     {
    259         $o = $this->__offset(38);
    260         return $o != 0 ? $this->bb->getUint($o + $this->bb_pos) : 0;
    261     }
    262 
    263     /**
    264      * @return long
    265      */
    266     public function getTesthashs64Fnv1()
    267     {
    268         $o = $this->__offset(40);
    269         return $o != 0 ? $this->bb->getLong($o + $this->bb_pos) : 0;
    270     }
    271 
    272     /**
    273      * @return ulong
    274      */
    275     public function getTesthashu64Fnv1()
    276     {
    277         $o = $this->__offset(42);
    278         return $o != 0 ? $this->bb->getUlong($o + $this->bb_pos) : 0;
    279     }
    280 
    281     /**
    282      * @return int
    283      */
    284     public function getTesthashs32Fnv1a()
    285     {
    286         $o = $this->__offset(44);
    287         return $o != 0 ? $this->bb->getInt($o + $this->bb_pos) : 0;
    288     }
    289 
    290     /**
    291      * @return uint
    292      */
    293     public function getTesthashu32Fnv1a()
    294     {
    295         $o = $this->__offset(46);
    296         return $o != 0 ? $this->bb->getUint($o + $this->bb_pos) : 0;
    297     }
    298 
    299     /**
    300      * @return long
    301      */
    302     public function getTesthashs64Fnv1a()
    303     {
    304         $o = $this->__offset(48);
    305         return $o != 0 ? $this->bb->getLong($o + $this->bb_pos) : 0;
    306     }
    307 
    308     /**
    309      * @return ulong
    310      */
    311     public function getTesthashu64Fnv1a()
    312     {
    313         $o = $this->__offset(50);
    314         return $o != 0 ? $this->bb->getUlong($o + $this->bb_pos) : 0;
    315     }
    316 
    317     /**
    318      * @param int offset
    319      * @return bool
    320      */
    321     public function getTestarrayofbools($j)
    322     {
    323         $o = $this->__offset(52);
    324         return $o != 0 ? $this->bb->getBool($this->__vector($o) + $j * 1) : 0;
    325     }
    326 
    327     /**
    328      * @return int
    329      */
    330     public function getTestarrayofboolsLength()
    331     {
    332         $o = $this->__offset(52);
    333         return $o != 0 ? $this->__vector_len($o) : 0;
    334     }
    335 
    336     /**
    337      * @return float
    338      */
    339     public function getTestf()
    340     {
    341         $o = $this->__offset(54);
    342         return $o != 0 ? $this->bb->getFloat($o + $this->bb_pos) : 3.14159;
    343     }
    344 
    345     /**
    346      * @return float
    347      */
    348     public function getTestf2()
    349     {
    350         $o = $this->__offset(56);
    351         return $o != 0 ? $this->bb->getFloat($o + $this->bb_pos) : 3.0;
    352     }
    353 
    354     /**
    355      * @return float
    356      */
    357     public function getTestf3()
    358     {
    359         $o = $this->__offset(58);
    360         return $o != 0 ? $this->bb->getFloat($o + $this->bb_pos) : 0.0;
    361     }
    362 
    363     /**
    364      * @param int offset
    365      * @return string
    366      */
    367     public function getTestarrayofstring2($j)
    368     {
    369         $o = $this->__offset(60);
    370         return $o != 0 ? $this->__string($this->__vector($o) + $j * 4) : 0;
    371     }
    372 
    373     /**
    374      * @return int
    375      */
    376     public function getTestarrayofstring2Length()
    377     {
    378         $o = $this->__offset(60);
    379         return $o != 0 ? $this->__vector_len($o) : 0;
    380     }
    381 
    382     /**
    383      * @returnVectorOffset
    384      */
    385     public function getTestarrayofsortedstruct($j)
    386     {
    387         $o = $this->__offset(62);
    388         $obj = new Ability();
    389         return $o != 0 ? $obj->init($this->__vector($o) + $j *8, $this->bb) : null;
    390     }
    391 
    392     /**
    393      * @return int
    394      */
    395     public function getTestarrayofsortedstructLength()
    396     {
    397         $o = $this->__offset(62);
    398         return $o != 0 ? $this->__vector_len($o) : 0;
    399     }
    400 
    401     /**
    402      * @param int offset
    403      * @return byte
    404      */
    405     public function getFlex($j)
    406     {
    407         $o = $this->__offset(64);
    408         return $o != 0 ? $this->bb->getByte($this->__vector($o) + $j * 1) : 0;
    409     }
    410 
    411     /**
    412      * @return int
    413      */
    414     public function getFlexLength()
    415     {
    416         $o = $this->__offset(64);
    417         return $o != 0 ? $this->__vector_len($o) : 0;
    418     }
    419 
    420     /**
    421      * @return string
    422      */
    423     public function getFlexBytes()
    424     {
    425         return $this->__vector_as_bytes(64);
    426     }
    427 
    428     /**
    429      * @returnVectorOffset
    430      */
    431     public function getTest5($j)
    432     {
    433         $o = $this->__offset(66);
    434         $obj = new Test();
    435         return $o != 0 ? $obj->init($this->__vector($o) + $j *4, $this->bb) : null;
    436     }
    437 
    438     /**
    439      * @return int
    440      */
    441     public function getTest5Length()
    442     {
    443         $o = $this->__offset(66);
    444         return $o != 0 ? $this->__vector_len($o) : 0;
    445     }
    446 
    447     /**
    448      * @param int offset
    449      * @return long
    450      */
    451     public function getVectorOfLongs($j)
    452     {
    453         $o = $this->__offset(68);
    454         return $o != 0 ? $this->bb->getLong($this->__vector($o) + $j * 8) : 0;
    455     }
    456 
    457     /**
    458      * @return int
    459      */
    460     public function getVectorOfLongsLength()
    461     {
    462         $o = $this->__offset(68);
    463         return $o != 0 ? $this->__vector_len($o) : 0;
    464     }
    465 
    466     /**
    467      * @param int offset
    468      * @return double
    469      */
    470     public function getVectorOfDoubles($j)
    471     {
    472         $o = $this->__offset(70);
    473         return $o != 0 ? $this->bb->getDouble($this->__vector($o) + $j * 8) : 0;
    474     }
    475 
    476     /**
    477      * @return int
    478      */
    479     public function getVectorOfDoublesLength()
    480     {
    481         $o = $this->__offset(70);
    482         return $o != 0 ? $this->__vector_len($o) : 0;
    483     }
    484 
    485     public function getParentNamespaceTest()
    486     {
    487         $obj = new InParentNamespace();
    488         $o = $this->__offset(72);
    489         return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0;
    490     }
    491 
    492     /**
    493      * @param FlatBufferBuilder $builder
    494      * @return void
    495      */
    496     public static function startMonster(FlatBufferBuilder $builder)
    497     {
    498         $builder->StartObject(35);
    499     }
    500 
    501     /**
    502      * @param FlatBufferBuilder $builder
    503      * @return Monster
    504      */
    505     public static function createMonster(FlatBufferBuilder $builder, $pos, $mana, $hp, $name, $inventory, $color, $test_type, $test, $test4, $testarrayofstring, $testarrayoftables, $enemy, $testnestedflatbuffer, $testempty, $testbool, $testhashs32_fnv1, $testhashu32_fnv1, $testhashs64_fnv1, $testhashu64_fnv1, $testhashs32_fnv1a, $testhashu32_fnv1a, $testhashs64_fnv1a, $testhashu64_fnv1a, $testarrayofbools, $testf, $testf2, $testf3, $testarrayofstring2, $testarrayofsortedstruct, $flex, $test5, $vector_of_longs, $vector_of_doubles, $parent_namespace_test)
    506     {
    507         $builder->startObject(35);
    508         self::addPos($builder, $pos);
    509         self::addMana($builder, $mana);
    510         self::addHp($builder, $hp);
    511         self::addName($builder, $name);
    512         self::addInventory($builder, $inventory);
    513         self::addColor($builder, $color);
    514         self::addTestType($builder, $test_type);
    515         self::addTest($builder, $test);
    516         self::addTest4($builder, $test4);
    517         self::addTestarrayofstring($builder, $testarrayofstring);
    518         self::addTestarrayoftables($builder, $testarrayoftables);
    519         self::addEnemy($builder, $enemy);
    520         self::addTestnestedflatbuffer($builder, $testnestedflatbuffer);
    521         self::addTestempty($builder, $testempty);
    522         self::addTestbool($builder, $testbool);
    523         self::addTesthashs32Fnv1($builder, $testhashs32_fnv1);
    524         self::addTesthashu32Fnv1($builder, $testhashu32_fnv1);
    525         self::addTesthashs64Fnv1($builder, $testhashs64_fnv1);
    526         self::addTesthashu64Fnv1($builder, $testhashu64_fnv1);
    527         self::addTesthashs32Fnv1a($builder, $testhashs32_fnv1a);
    528         self::addTesthashu32Fnv1a($builder, $testhashu32_fnv1a);
    529         self::addTesthashs64Fnv1a($builder, $testhashs64_fnv1a);
    530         self::addTesthashu64Fnv1a($builder, $testhashu64_fnv1a);
    531         self::addTestarrayofbools($builder, $testarrayofbools);
    532         self::addTestf($builder, $testf);
    533         self::addTestf2($builder, $testf2);
    534         self::addTestf3($builder, $testf3);
    535         self::addTestarrayofstring2($builder, $testarrayofstring2);
    536         self::addTestarrayofsortedstruct($builder, $testarrayofsortedstruct);
    537         self::addFlex($builder, $flex);
    538         self::addTest5($builder, $test5);
    539         self::addVectorOfLongs($builder, $vector_of_longs);
    540         self::addVectorOfDoubles($builder, $vector_of_doubles);
    541         self::addParentNamespaceTest($builder, $parent_namespace_test);
    542         $o = $builder->endObject();
    543         $builder->required($o, 10);  // name
    544         return $o;
    545     }
    546 
    547     /**
    548      * @param FlatBufferBuilder $builder
    549      * @param int
    550      * @return void
    551      */
    552     public static function addPos(FlatBufferBuilder $builder, $pos)
    553     {
    554         $builder->addStructX(0, $pos, 0);
    555     }
    556 
    557     /**
    558      * @param FlatBufferBuilder $builder
    559      * @param short
    560      * @return void
    561      */
    562     public static function addMana(FlatBufferBuilder $builder, $mana)
    563     {
    564         $builder->addShortX(1, $mana, 150);
    565     }
    566 
    567     /**
    568      * @param FlatBufferBuilder $builder
    569      * @param short
    570      * @return void
    571      */
    572     public static function addHp(FlatBufferBuilder $builder, $hp)
    573     {
    574         $builder->addShortX(2, $hp, 100);
    575     }
    576 
    577     /**
    578      * @param FlatBufferBuilder $builder
    579      * @param StringOffset
    580      * @return void
    581      */
    582     public static function addName(FlatBufferBuilder $builder, $name)
    583     {
    584         $builder->addOffsetX(3, $name, 0);
    585     }
    586 
    587     /**
    588      * @param FlatBufferBuilder $builder
    589      * @param VectorOffset
    590      * @return void
    591      */
    592     public static function addInventory(FlatBufferBuilder $builder, $inventory)
    593     {
    594         $builder->addOffsetX(5, $inventory, 0);
    595     }
    596 
    597     /**
    598      * @param FlatBufferBuilder $builder
    599      * @param array offset array
    600      * @return int vector offset
    601      */
    602     public static function createInventoryVector(FlatBufferBuilder $builder, array $data)
    603     {
    604         $builder->startVector(1, count($data), 1);
    605         for ($i = count($data) - 1; $i >= 0; $i--) {
    606             $builder->addByte($data[$i]);
    607         }
    608         return $builder->endVector();
    609     }
    610 
    611     /**
    612      * @param FlatBufferBuilder $builder
    613      * @param int $numElems
    614      * @return void
    615      */
    616     public static function startInventoryVector(FlatBufferBuilder $builder, $numElems)
    617     {
    618         $builder->startVector(1, $numElems, 1);
    619     }
    620 
    621     /**
    622      * @param FlatBufferBuilder $builder
    623      * @param sbyte
    624      * @return void
    625      */
    626     public static function addColor(FlatBufferBuilder $builder, $color)
    627     {
    628         $builder->addSbyteX(6, $color, 8);
    629     }
    630 
    631     /**
    632      * @param FlatBufferBuilder $builder
    633      * @param byte
    634      * @return void
    635      */
    636     public static function addTestType(FlatBufferBuilder $builder, $testType)
    637     {
    638         $builder->addByteX(7, $testType, 0);
    639     }
    640 
    641     public static function addTest(FlatBufferBuilder $builder, $offset)
    642     {
    643         $builder->addOffsetX(8, $offset, 0);
    644     }
    645 
    646     /**
    647      * @param FlatBufferBuilder $builder
    648      * @param VectorOffset
    649      * @return void
    650      */
    651     public static function addTest4(FlatBufferBuilder $builder, $test4)
    652     {
    653         $builder->addOffsetX(9, $test4, 0);
    654     }
    655 
    656     /**
    657      * @param FlatBufferBuilder $builder
    658      * @param array offset array
    659      * @return int vector offset
    660      */
    661     public static function createTest4Vector(FlatBufferBuilder $builder, array $data)
    662     {
    663         $builder->startVector(4, count($data), 2);
    664         for ($i = count($data) - 1; $i >= 0; $i--) {
    665             $builder->addOffset($data[$i]);
    666         }
    667         return $builder->endVector();
    668     }
    669 
    670     /**
    671      * @param FlatBufferBuilder $builder
    672      * @param int $numElems
    673      * @return void
    674      */
    675     public static function startTest4Vector(FlatBufferBuilder $builder, $numElems)
    676     {
    677         $builder->startVector(4, $numElems, 2);
    678     }
    679 
    680     /**
    681      * @param FlatBufferBuilder $builder
    682      * @param VectorOffset
    683      * @return void
    684      */
    685     public static function addTestarrayofstring(FlatBufferBuilder $builder, $testarrayofstring)
    686     {
    687         $builder->addOffsetX(10, $testarrayofstring, 0);
    688     }
    689 
    690     /**
    691      * @param FlatBufferBuilder $builder
    692      * @param array offset array
    693      * @return int vector offset
    694      */
    695     public static function createTestarrayofstringVector(FlatBufferBuilder $builder, array $data)
    696     {
    697         $builder->startVector(4, count($data), 4);
    698         for ($i = count($data) - 1; $i >= 0; $i--) {
    699             $builder->addOffset($data[$i]);
    700         }
    701         return $builder->endVector();
    702     }
    703 
    704     /**
    705      * @param FlatBufferBuilder $builder
    706      * @param int $numElems
    707      * @return void
    708      */
    709     public static function startTestarrayofstringVector(FlatBufferBuilder $builder, $numElems)
    710     {
    711         $builder->startVector(4, $numElems, 4);
    712     }
    713 
    714     /**
    715      * @param FlatBufferBuilder $builder
    716      * @param VectorOffset
    717      * @return void
    718      */
    719     public static function addTestarrayoftables(FlatBufferBuilder $builder, $testarrayoftables)
    720     {
    721         $builder->addOffsetX(11, $testarrayoftables, 0);
    722     }
    723 
    724     /**
    725      * @param FlatBufferBuilder $builder
    726      * @param array offset array
    727      * @return int vector offset
    728      */
    729     public static function createTestarrayoftablesVector(FlatBufferBuilder $builder, array $data)
    730     {
    731         $builder->startVector(4, count($data), 4);
    732         for ($i = count($data) - 1; $i >= 0; $i--) {
    733             $builder->addOffset($data[$i]);
    734         }
    735         return $builder->endVector();
    736     }
    737 
    738     /**
    739      * @param FlatBufferBuilder $builder
    740      * @param int $numElems
    741      * @return void
    742      */
    743     public static function startTestarrayoftablesVector(FlatBufferBuilder $builder, $numElems)
    744     {
    745         $builder->startVector(4, $numElems, 4);
    746     }
    747 
    748     /**
    749      * @param FlatBufferBuilder $builder
    750      * @param int
    751      * @return void
    752      */
    753     public static function addEnemy(FlatBufferBuilder $builder, $enemy)
    754     {
    755         $builder->addOffsetX(12, $enemy, 0);
    756     }
    757 
    758     /**
    759      * @param FlatBufferBuilder $builder
    760      * @param VectorOffset
    761      * @return void
    762      */
    763     public static function addTestnestedflatbuffer(FlatBufferBuilder $builder, $testnestedflatbuffer)
    764     {
    765         $builder->addOffsetX(13, $testnestedflatbuffer, 0);
    766     }
    767 
    768     /**
    769      * @param FlatBufferBuilder $builder
    770      * @param array offset array
    771      * @return int vector offset
    772      */
    773     public static function createTestnestedflatbufferVector(FlatBufferBuilder $builder, array $data)
    774     {
    775         $builder->startVector(1, count($data), 1);
    776         for ($i = count($data) - 1; $i >= 0; $i--) {
    777             $builder->addByte($data[$i]);
    778         }
    779         return $builder->endVector();
    780     }
    781 
    782     /**
    783      * @param FlatBufferBuilder $builder
    784      * @param int $numElems
    785      * @return void
    786      */
    787     public static function startTestnestedflatbufferVector(FlatBufferBuilder $builder, $numElems)
    788     {
    789         $builder->startVector(1, $numElems, 1);
    790     }
    791 
    792     /**
    793      * @param FlatBufferBuilder $builder
    794      * @param int
    795      * @return void
    796      */
    797     public static function addTestempty(FlatBufferBuilder $builder, $testempty)
    798     {
    799         $builder->addOffsetX(14, $testempty, 0);
    800     }
    801 
    802     /**
    803      * @param FlatBufferBuilder $builder
    804      * @param bool
    805      * @return void
    806      */
    807     public static function addTestbool(FlatBufferBuilder $builder, $testbool)
    808     {
    809         $builder->addBoolX(15, $testbool, false);
    810     }
    811 
    812     /**
    813      * @param FlatBufferBuilder $builder
    814      * @param int
    815      * @return void
    816      */
    817     public static function addTesthashs32Fnv1(FlatBufferBuilder $builder, $testhashs32Fnv1)
    818     {
    819         $builder->addIntX(16, $testhashs32Fnv1, 0);
    820     }
    821 
    822     /**
    823      * @param FlatBufferBuilder $builder
    824      * @param uint
    825      * @return void
    826      */
    827     public static function addTesthashu32Fnv1(FlatBufferBuilder $builder, $testhashu32Fnv1)
    828     {
    829         $builder->addUintX(17, $testhashu32Fnv1, 0);
    830     }
    831 
    832     /**
    833      * @param FlatBufferBuilder $builder
    834      * @param long
    835      * @return void
    836      */
    837     public static function addTesthashs64Fnv1(FlatBufferBuilder $builder, $testhashs64Fnv1)
    838     {
    839         $builder->addLongX(18, $testhashs64Fnv1, 0);
    840     }
    841 
    842     /**
    843      * @param FlatBufferBuilder $builder
    844      * @param ulong
    845      * @return void
    846      */
    847     public static function addTesthashu64Fnv1(FlatBufferBuilder $builder, $testhashu64Fnv1)
    848     {
    849         $builder->addUlongX(19, $testhashu64Fnv1, 0);
    850     }
    851 
    852     /**
    853      * @param FlatBufferBuilder $builder
    854      * @param int
    855      * @return void
    856      */
    857     public static function addTesthashs32Fnv1a(FlatBufferBuilder $builder, $testhashs32Fnv1a)
    858     {
    859         $builder->addIntX(20, $testhashs32Fnv1a, 0);
    860     }
    861 
    862     /**
    863      * @param FlatBufferBuilder $builder
    864      * @param uint
    865      * @return void
    866      */
    867     public static function addTesthashu32Fnv1a(FlatBufferBuilder $builder, $testhashu32Fnv1a)
    868     {
    869         $builder->addUintX(21, $testhashu32Fnv1a, 0);
    870     }
    871 
    872     /**
    873      * @param FlatBufferBuilder $builder
    874      * @param long
    875      * @return void
    876      */
    877     public static function addTesthashs64Fnv1a(FlatBufferBuilder $builder, $testhashs64Fnv1a)
    878     {
    879         $builder->addLongX(22, $testhashs64Fnv1a, 0);
    880     }
    881 
    882     /**
    883      * @param FlatBufferBuilder $builder
    884      * @param ulong
    885      * @return void
    886      */
    887     public static function addTesthashu64Fnv1a(FlatBufferBuilder $builder, $testhashu64Fnv1a)
    888     {
    889         $builder->addUlongX(23, $testhashu64Fnv1a, 0);
    890     }
    891 
    892     /**
    893      * @param FlatBufferBuilder $builder
    894      * @param VectorOffset
    895      * @return void
    896      */
    897     public static function addTestarrayofbools(FlatBufferBuilder $builder, $testarrayofbools)
    898     {
    899         $builder->addOffsetX(24, $testarrayofbools, 0);
    900     }
    901 
    902     /**
    903      * @param FlatBufferBuilder $builder
    904      * @param array offset array
    905      * @return int vector offset
    906      */
    907     public static function createTestarrayofboolsVector(FlatBufferBuilder $builder, array $data)
    908     {
    909         $builder->startVector(1, count($data), 1);
    910         for ($i = count($data) - 1; $i >= 0; $i--) {
    911             $builder->addBool($data[$i]);
    912         }
    913         return $builder->endVector();
    914     }
    915 
    916     /**
    917      * @param FlatBufferBuilder $builder
    918      * @param int $numElems
    919      * @return void
    920      */
    921     public static function startTestarrayofboolsVector(FlatBufferBuilder $builder, $numElems)
    922     {
    923         $builder->startVector(1, $numElems, 1);
    924     }
    925 
    926     /**
    927      * @param FlatBufferBuilder $builder
    928      * @param float
    929      * @return void
    930      */
    931     public static function addTestf(FlatBufferBuilder $builder, $testf)
    932     {
    933         $builder->addFloatX(25, $testf, 3.14159);
    934     }
    935 
    936     /**
    937      * @param FlatBufferBuilder $builder
    938      * @param float
    939      * @return void
    940      */
    941     public static function addTestf2(FlatBufferBuilder $builder, $testf2)
    942     {
    943         $builder->addFloatX(26, $testf2, 3.0);
    944     }
    945 
    946     /**
    947      * @param FlatBufferBuilder $builder
    948      * @param float
    949      * @return void
    950      */
    951     public static function addTestf3(FlatBufferBuilder $builder, $testf3)
    952     {
    953         $builder->addFloatX(27, $testf3, 0.0);
    954     }
    955 
    956     /**
    957      * @param FlatBufferBuilder $builder
    958      * @param VectorOffset
    959      * @return void
    960      */
    961     public static function addTestarrayofstring2(FlatBufferBuilder $builder, $testarrayofstring2)
    962     {
    963         $builder->addOffsetX(28, $testarrayofstring2, 0);
    964     }
    965 
    966     /**
    967      * @param FlatBufferBuilder $builder
    968      * @param array offset array
    969      * @return int vector offset
    970      */
    971     public static function createTestarrayofstring2Vector(FlatBufferBuilder $builder, array $data)
    972     {
    973         $builder->startVector(4, count($data), 4);
    974         for ($i = count($data) - 1; $i >= 0; $i--) {
    975             $builder->addOffset($data[$i]);
    976         }
    977         return $builder->endVector();
    978     }
    979 
    980     /**
    981      * @param FlatBufferBuilder $builder
    982      * @param int $numElems
    983      * @return void
    984      */
    985     public static function startTestarrayofstring2Vector(FlatBufferBuilder $builder, $numElems)
    986     {
    987         $builder->startVector(4, $numElems, 4);
    988     }
    989 
    990     /**
    991      * @param FlatBufferBuilder $builder
    992      * @param VectorOffset
    993      * @return void
    994      */
    995     public static function addTestarrayofsortedstruct(FlatBufferBuilder $builder, $testarrayofsortedstruct)
    996     {
    997         $builder->addOffsetX(29, $testarrayofsortedstruct, 0);
    998     }
    999 
   1000     /**
   1001      * @param FlatBufferBuilder $builder
   1002      * @param array offset array
   1003      * @return int vector offset
   1004      */
   1005     public static function createTestarrayofsortedstructVector(FlatBufferBuilder $builder, array $data)
   1006     {
   1007         $builder->startVector(8, count($data), 4);
   1008         for ($i = count($data) - 1; $i >= 0; $i--) {
   1009             $builder->addOffset($data[$i]);
   1010         }
   1011         return $builder->endVector();
   1012     }
   1013 
   1014     /**
   1015      * @param FlatBufferBuilder $builder
   1016      * @param int $numElems
   1017      * @return void
   1018      */
   1019     public static function startTestarrayofsortedstructVector(FlatBufferBuilder $builder, $numElems)
   1020     {
   1021         $builder->startVector(8, $numElems, 4);
   1022     }
   1023 
   1024     /**
   1025      * @param FlatBufferBuilder $builder
   1026      * @param VectorOffset
   1027      * @return void
   1028      */
   1029     public static function addFlex(FlatBufferBuilder $builder, $flex)
   1030     {
   1031         $builder->addOffsetX(30, $flex, 0);
   1032     }
   1033 
   1034     /**
   1035      * @param FlatBufferBuilder $builder
   1036      * @param array offset array
   1037      * @return int vector offset
   1038      */
   1039     public static function createFlexVector(FlatBufferBuilder $builder, array $data)
   1040     {
   1041         $builder->startVector(1, count($data), 1);
   1042         for ($i = count($data) - 1; $i >= 0; $i--) {
   1043             $builder->addByte($data[$i]);
   1044         }
   1045         return $builder->endVector();
   1046     }
   1047 
   1048     /**
   1049      * @param FlatBufferBuilder $builder
   1050      * @param int $numElems
   1051      * @return void
   1052      */
   1053     public static function startFlexVector(FlatBufferBuilder $builder, $numElems)
   1054     {
   1055         $builder->startVector(1, $numElems, 1);
   1056     }
   1057 
   1058     /**
   1059      * @param FlatBufferBuilder $builder
   1060      * @param VectorOffset
   1061      * @return void
   1062      */
   1063     public static function addTest5(FlatBufferBuilder $builder, $test5)
   1064     {
   1065         $builder->addOffsetX(31, $test5, 0);
   1066     }
   1067 
   1068     /**
   1069      * @param FlatBufferBuilder $builder
   1070      * @param array offset array
   1071      * @return int vector offset
   1072      */
   1073     public static function createTest5Vector(FlatBufferBuilder $builder, array $data)
   1074     {
   1075         $builder->startVector(4, count($data), 2);
   1076         for ($i = count($data) - 1; $i >= 0; $i--) {
   1077             $builder->addOffset($data[$i]);
   1078         }
   1079         return $builder->endVector();
   1080     }
   1081 
   1082     /**
   1083      * @param FlatBufferBuilder $builder
   1084      * @param int $numElems
   1085      * @return void
   1086      */
   1087     public static function startTest5Vector(FlatBufferBuilder $builder, $numElems)
   1088     {
   1089         $builder->startVector(4, $numElems, 2);
   1090     }
   1091 
   1092     /**
   1093      * @param FlatBufferBuilder $builder
   1094      * @param VectorOffset
   1095      * @return void
   1096      */
   1097     public static function addVectorOfLongs(FlatBufferBuilder $builder, $vectorOfLongs)
   1098     {
   1099         $builder->addOffsetX(32, $vectorOfLongs, 0);
   1100     }
   1101 
   1102     /**
   1103      * @param FlatBufferBuilder $builder
   1104      * @param array offset array
   1105      * @return int vector offset
   1106      */
   1107     public static function createVectorOfLongsVector(FlatBufferBuilder $builder, array $data)
   1108     {
   1109         $builder->startVector(8, count($data), 8);
   1110         for ($i = count($data) - 1; $i >= 0; $i--) {
   1111             $builder->addLong($data[$i]);
   1112         }
   1113         return $builder->endVector();
   1114     }
   1115 
   1116     /**
   1117      * @param FlatBufferBuilder $builder
   1118      * @param int $numElems
   1119      * @return void
   1120      */
   1121     public static function startVectorOfLongsVector(FlatBufferBuilder $builder, $numElems)
   1122     {
   1123         $builder->startVector(8, $numElems, 8);
   1124     }
   1125 
   1126     /**
   1127      * @param FlatBufferBuilder $builder
   1128      * @param VectorOffset
   1129      * @return void
   1130      */
   1131     public static function addVectorOfDoubles(FlatBufferBuilder $builder, $vectorOfDoubles)
   1132     {
   1133         $builder->addOffsetX(33, $vectorOfDoubles, 0);
   1134     }
   1135 
   1136     /**
   1137      * @param FlatBufferBuilder $builder
   1138      * @param array offset array
   1139      * @return int vector offset
   1140      */
   1141     public static function createVectorOfDoublesVector(FlatBufferBuilder $builder, array $data)
   1142     {
   1143         $builder->startVector(8, count($data), 8);
   1144         for ($i = count($data) - 1; $i >= 0; $i--) {
   1145             $builder->addDouble($data[$i]);
   1146         }
   1147         return $builder->endVector();
   1148     }
   1149 
   1150     /**
   1151      * @param FlatBufferBuilder $builder
   1152      * @param int $numElems
   1153      * @return void
   1154      */
   1155     public static function startVectorOfDoublesVector(FlatBufferBuilder $builder, $numElems)
   1156     {
   1157         $builder->startVector(8, $numElems, 8);
   1158     }
   1159 
   1160     /**
   1161      * @param FlatBufferBuilder $builder
   1162      * @param int
   1163      * @return void
   1164      */
   1165     public static function addParentNamespaceTest(FlatBufferBuilder $builder, $parentNamespaceTest)
   1166     {
   1167         $builder->addOffsetX(34, $parentNamespaceTest, 0);
   1168     }
   1169 
   1170     /**
   1171      * @param FlatBufferBuilder $builder
   1172      * @return int table offset
   1173      */
   1174     public static function endMonster(FlatBufferBuilder $builder)
   1175     {
   1176         $o = $builder->endObject();
   1177         $builder->required($o, 10);  // name
   1178         return $o;
   1179     }
   1180 
   1181     public static function finishMonsterBuffer(FlatBufferBuilder $builder, $offset)
   1182     {
   1183         $builder->finish($offset, "MONS");
   1184     }
   1185 }
   1186