Lines Matching full:code
17 // independent from idl_parser, since this code is not needed for most clients
67 auto &code = *code_ptr; in BeginFile() local
68 code += "<?php\n"; in BeginFile()
69 code = code + "// " + FlatBuffersGeneratedWarning() + "\n\n"; in BeginFile()
72 code += "namespace " + name_space_name + ";\n\n"; in BeginFile()
76 code += "use \\Google\\FlatBuffers\\Struct;\n"; in BeginFile()
77 code += "use \\Google\\FlatBuffers\\Table;\n"; in BeginFile()
78 code += "use \\Google\\FlatBuffers\\ByteBuffer;\n"; in BeginFile()
79 code += "use \\Google\\FlatBuffers\\FlatBufferBuilder;\n"; in BeginFile()
80 code += "\n"; in BeginFile()
84 // Save out the generated code for a Php Table type.
89 std::string code = ""; in SaveType() local
91 &code); in SaveType()
92 code += classcode; in SaveType()
96 return SaveFile(filename.c_str(), code, false); in SaveType()
101 std::string &code = *code_ptr; in BeginClass() local
103 code += "class " + struct_def.name + " extends Struct\n"; in BeginClass()
105 code += "class " + struct_def.name + " extends Table\n"; in BeginClass()
107 code += "{\n"; in BeginClass()
111 std::string &code = *code_ptr; in EndClass() local
112 code += "}\n"; in EndClass()
115 // Begin enum code with a class declaration.
117 std::string &code = *code_ptr; in BeginEnum() local
118 code += "class " + class_name + "\n{\n"; in BeginEnum()
124 std::string &code = *code_ptr; in EnumMember() local
125 code += Indent + "const "; in EnumMember()
126 code += ev.name; in EnumMember()
127 code += " = "; in EnumMember()
128 code += enum_def.ToString(ev) + ";\n"; in EnumMember()
131 // End enum code.
133 std::string &code = *code_ptr; in EndEnum() local
134 code += "}\n"; in EndEnum()
140 std::string &code = *code_ptr; in NewRootTypeFromBuffer() local
142 code += Indent + "/**\n"; in NewRootTypeFromBuffer()
143 code += Indent + " * @param ByteBuffer $bb\n"; in NewRootTypeFromBuffer()
144 code += Indent + " * @return " + struct_def.name + "\n"; in NewRootTypeFromBuffer()
145 code += Indent + " */\n"; in NewRootTypeFromBuffer()
146 code += Indent + "public static function getRootAs"; in NewRootTypeFromBuffer()
147 code += struct_def.name; in NewRootTypeFromBuffer()
148 code += "(ByteBuffer $bb)\n"; in NewRootTypeFromBuffer()
149 code += Indent + "{\n"; in NewRootTypeFromBuffer()
151 code += Indent + Indent + "$obj = new " + struct_def.name + "();\n"; in NewRootTypeFromBuffer()
152 code += Indent + Indent; in NewRootTypeFromBuffer()
153 code += "return ($obj->init($bb->getInt($bb->getPosition())"; in NewRootTypeFromBuffer()
154 code += " + $bb->getPosition(), $bb));\n"; in NewRootTypeFromBuffer()
155 code += Indent + "}\n\n"; in NewRootTypeFromBuffer()
161 std::string &code = *code_ptr; in InitializeExisting() local
163 code += Indent + "/**\n"; in InitializeExisting()
164 code += Indent + " * @param int $_i offset\n"; in InitializeExisting()
165 code += Indent + " * @param ByteBuffer $_bb\n"; in InitializeExisting()
166 code += Indent + " * @return " + struct_def.name + "\n"; in InitializeExisting()
167 code += Indent + " **/\n"; in InitializeExisting()
168 code += Indent + "public function init($_i, ByteBuffer $_bb)\n"; in InitializeExisting()
169 code += Indent + "{\n"; in InitializeExisting()
170 code += Indent + Indent + "$this->bb_pos = $_i;\n"; in InitializeExisting()
171 code += Indent + Indent + "$this->bb = $_bb;\n"; in InitializeExisting()
172 code += Indent + Indent + "return $this;\n"; in InitializeExisting()
173 code += Indent + "}\n\n"; in InitializeExisting()
178 std::string &code = *code_ptr; in GetVectorLen() local
180 code += Indent + "/**\n"; in GetVectorLen()
181 code += Indent + " * @return int\n"; in GetVectorLen()
182 code += Indent + " */\n"; in GetVectorLen()
183 code += Indent + "public function get"; in GetVectorLen()
184 code += MakeCamel(field.name) + "Length()\n"; in GetVectorLen()
185 code += Indent + "{\n"; in GetVectorLen()
186 code += Indent + Indent + "$o = $this->__offset("; in GetVectorLen()
187 code += NumToString(field.value.offset) + ");\n"; in GetVectorLen()
188 code += Indent + Indent; in GetVectorLen()
189 code += "return $o != 0 ? $this->__vector_len($o) : 0;\n"; in GetVectorLen()
190 code += Indent + "}\n\n"; in GetVectorLen()
195 std::string &code = *code_ptr; in GetUByte() local
197 code += Indent + "/**\n"; in GetUByte()
198 code += Indent + " * @return string\n"; in GetUByte()
199 code += Indent + " */\n"; in GetUByte()
200 code += Indent + "public function get"; in GetUByte()
201 code += MakeCamel(field.name) + "Bytes()\n"; in GetUByte()
202 code += Indent + "{\n"; in GetUByte()
203 code += Indent + Indent + "return $this->__vector_as_bytes("; in GetUByte()
204 code += NumToString(field.value.offset) + ");\n"; in GetUByte()
205 code += Indent + "}\n\n"; in GetUByte()
211 std::string &code = *code_ptr; in GetScalarFieldOfStruct() local
214 code += Indent + "/**\n"; in GetScalarFieldOfStruct()
215 code += Indent + " * @return "; in GetScalarFieldOfStruct()
216 code += GenTypeGet(field.value.type) + "\n"; in GetScalarFieldOfStruct()
217 code += Indent + " */\n"; in GetScalarFieldOfStruct()
218 code += Indent + "public function " + getter; in GetScalarFieldOfStruct()
219 code += MakeCamel(field.name) + "()\n"; in GetScalarFieldOfStruct()
220 code += Indent + "{\n"; in GetScalarFieldOfStruct()
221 code += Indent + Indent + "return "; in GetScalarFieldOfStruct()
223 code += "$this->bb->get"; in GetScalarFieldOfStruct()
224 code += MakeCamel(GenTypeGet(field.value.type)); in GetScalarFieldOfStruct()
225 code += "($this->bb_pos + "; in GetScalarFieldOfStruct()
226 code += NumToString(field.value.offset) + ")"; in GetScalarFieldOfStruct()
227 code += ";\n"; in GetScalarFieldOfStruct()
229 code += Indent + "}\n\n"; in GetScalarFieldOfStruct()
234 std::string &code = *code_ptr; in GetScalarFieldOfTable() local
236 code += Indent + "/**\n"; in GetScalarFieldOfTable()
237 code += Indent + " * @return " + GenTypeGet(field.value.type) + "\n"; in GetScalarFieldOfTable()
238 code += Indent + " */\n"; in GetScalarFieldOfTable()
239 code += Indent + "public function get"; in GetScalarFieldOfTable()
240 code += MakeCamel(field.name); in GetScalarFieldOfTable()
241 code += "()\n"; in GetScalarFieldOfTable()
242 code += Indent + "{\n"; in GetScalarFieldOfTable()
243 code += Indent + Indent + "$o = $this->__offset(" + in GetScalarFieldOfTable()
246 code += "$this->bb->get"; in GetScalarFieldOfTable()
247 code += MakeCamel(GenTypeGet(field.value.type)) + "($o + $this->bb_pos)"; in GetScalarFieldOfTable()
248 code += " : " + GenDefaultValue(field.value) + ";\n"; in GetScalarFieldOfTable()
249 code += Indent + "}\n\n"; in GetScalarFieldOfTable()
255 std::string &code = *code_ptr; in GetStructFieldOfStruct() local
257 code += Indent + "/**\n"; in GetStructFieldOfStruct()
258 code += Indent + " * @return " + GenTypeGet(field.value.type) + "\n"; in GetStructFieldOfStruct()
259 code += Indent + " */\n"; in GetStructFieldOfStruct()
260 code += Indent + "public function get"; in GetStructFieldOfStruct()
261 code += MakeCamel(field.name) + "()\n"; in GetStructFieldOfStruct()
262 code += Indent + "{\n"; in GetStructFieldOfStruct()
263 code += Indent + Indent + "$obj = new "; in GetStructFieldOfStruct()
264 code += GenTypeGet(field.value.type) + "();\n"; in GetStructFieldOfStruct()
265 code += Indent + Indent + "$obj->init($this->bb_pos + "; in GetStructFieldOfStruct()
266 code += NumToString(field.value.offset) + ", $this->bb);"; in GetStructFieldOfStruct()
267 code += "\n" + Indent + Indent + "return $obj;\n"; in GetStructFieldOfStruct()
268 code += Indent + "}\n\n"; in GetStructFieldOfStruct()
274 std::string &code = *code_ptr; in GetStructFieldOfTable() local
276 code += Indent + "public function get"; in GetStructFieldOfTable()
277 code += MakeCamel(field.name); in GetStructFieldOfTable()
278 code += "()\n"; in GetStructFieldOfTable()
279 code += Indent + "{\n"; in GetStructFieldOfTable()
280 code += Indent + Indent + "$obj = new "; in GetStructFieldOfTable()
281 code += MakeCamel(GenTypeGet(field.value.type)) + "();\n"; in GetStructFieldOfTable()
282 code += Indent + Indent + "$o = $this->__offset(" + in GetStructFieldOfTable()
284 code += Indent + Indent; in GetStructFieldOfTable()
285 code += "return $o != 0 ? $obj->init("; in GetStructFieldOfTable()
287 code += "$o + $this->bb_pos, $this->bb) : "; in GetStructFieldOfTable()
289 code += "$this->__indirect($o + $this->bb_pos), $this->bb) : "; in GetStructFieldOfTable()
291 code += GenDefaultValue(field.value) + ";\n"; in GetStructFieldOfTable()
292 code += Indent + "}\n\n"; in GetStructFieldOfTable()
297 std::string &code = *code_ptr; in GetStringField() local
298 code += Indent + "public function get"; in GetStringField()
299 code += MakeCamel(field.name); in GetStringField()
300 code += "()\n"; in GetStringField()
301 code += Indent + "{\n"; in GetStringField()
302 code += Indent + Indent + "$o = $this->__offset(" + in GetStringField()
304 code += Indent + Indent; in GetStringField()
305 code += "return $o != 0 ? $this->__string($o + $this->bb_pos) : "; in GetStringField()
306 code += GenDefaultValue(field.value) + ";\n"; in GetStringField()
307 code += Indent + "}\n\n"; in GetStringField()
312 std::string &code = *code_ptr; in GetUnionField() local
314 code += Indent + "/**\n"; in GetUnionField()
315 code += Indent + " * @return" + GenTypeBasic(field.value.type) + "\n"; in GetUnionField()
316 code += Indent + " */\n"; in GetUnionField()
317 code += Indent + "public function get"; in GetUnionField()
318 code += MakeCamel(field.name) + "($obj)\n"; in GetUnionField()
319 code += Indent + "{\n"; in GetUnionField()
320 code += Indent + Indent + "$o = $this->__offset(" + in GetUnionField()
322 code += Indent + Indent; in GetUnionField()
323 code += "return $o != 0 ? $this->__union($obj, $o) : null;\n"; in GetUnionField()
324 code += Indent + "}\n\n"; in GetUnionField()
330 std::string &code = *code_ptr; in GetMemberOfVectorOfStruct() local
333 code += Indent + "/**\n"; in GetMemberOfVectorOfStruct()
334 code += Indent + " * @return" + GenTypeBasic(field.value.type) + "\n"; in GetMemberOfVectorOfStruct()
335 code += Indent + " */\n"; in GetMemberOfVectorOfStruct()
336 code += Indent + "public function get"; in GetMemberOfVectorOfStruct()
337 code += MakeCamel(field.name); in GetMemberOfVectorOfStruct()
338 code += "($j)\n"; in GetMemberOfVectorOfStruct()
339 code += Indent + "{\n"; in GetMemberOfVectorOfStruct()
340 code += Indent + Indent + "$o = $this->__offset(" + in GetMemberOfVectorOfStruct()
342 code += Indent + Indent + "$obj = new "; in GetMemberOfVectorOfStruct()
343 code += MakeCamel(GenTypeGet(field.value.type)) + "();\n"; in GetMemberOfVectorOfStruct()
348 code += Indent + Indent; in GetMemberOfVectorOfStruct()
349 code += "return $o != 0 ? $obj->init($this->bb_pos +" + in GetMemberOfVectorOfStruct()
352 code += Indent + Indent + "return $o != 0 ? $obj->init("; in GetMemberOfVectorOfStruct()
353 code += field.value.type.struct_def->fixed in GetMemberOfVectorOfStruct()
356 code += ", $this->bb) : null;\n"; in GetMemberOfVectorOfStruct()
360 code += "// base_type_string\n"; in GetMemberOfVectorOfStruct()
365 code += Indent + Indent + "return $o != 0 ? $obj->init("; in GetMemberOfVectorOfStruct()
367 code += "$this->__vector($o) + $j *"; in GetMemberOfVectorOfStruct()
368 code += NumToString(InlineSize(vectortype)); in GetMemberOfVectorOfStruct()
370 code += "$this->__indirect($this->__vector($o) + $j * "; in GetMemberOfVectorOfStruct()
371 code += NumToString(InlineSize(vectortype)) + ")"; in GetMemberOfVectorOfStruct()
373 code += ", $this->bb) : null;\n"; in GetMemberOfVectorOfStruct()
377 code += Indent + Indent + "return $o != 0 ? $this->"; in GetMemberOfVectorOfStruct()
378 code += GenGetter(field.value.type) + "($obj, $o); null;\n"; in GetMemberOfVectorOfStruct()
383 code += Indent + "}\n\n"; in GetMemberOfVectorOfStruct()
390 std::string &code = *code_ptr; in GetMemberOfVectorOfNonStruct() local
393 code += Indent + "/**\n"; in GetMemberOfVectorOfNonStruct()
394 code += Indent + " * @param int offset\n"; in GetMemberOfVectorOfNonStruct()
395 code += Indent + " * @return " + GenTypeGet(field.value.type) + "\n"; in GetMemberOfVectorOfNonStruct()
396 code += Indent + " */\n"; in GetMemberOfVectorOfNonStruct()
397 code += Indent + "public function get"; in GetMemberOfVectorOfNonStruct()
398 code += MakeCamel(field.name); in GetMemberOfVectorOfNonStruct()
399 code += "($j)\n"; in GetMemberOfVectorOfNonStruct()
400 code += Indent + "{\n"; in GetMemberOfVectorOfNonStruct()
401 code += Indent + Indent + "$o = $this->__offset(" + in GetMemberOfVectorOfNonStruct()
405 code += Indent + Indent; in GetMemberOfVectorOfNonStruct()
406 code += "return $o != 0 ? $this->__string($this->__vector($o) + $j * "; in GetMemberOfVectorOfNonStruct()
407 code += NumToString(InlineSize(vectortype)) + ") : "; in GetMemberOfVectorOfNonStruct()
408 code += GenDefaultValue(field.value) + ";\n"; in GetMemberOfVectorOfNonStruct()
410 code += Indent + Indent + "return $o != 0 ? $this->bb->get"; in GetMemberOfVectorOfNonStruct()
411 code += MakeCamel(GenTypeGet(field.value.type)); in GetMemberOfVectorOfNonStruct()
412 code += "($this->__vector($o) + $j * "; in GetMemberOfVectorOfNonStruct()
413 code += NumToString(InlineSize(vectortype)) + ") : "; in GetMemberOfVectorOfNonStruct()
414 code += GenDefaultValue(field.value) + ";\n"; in GetMemberOfVectorOfNonStruct()
416 code += Indent + "}\n\n"; in GetMemberOfVectorOfNonStruct()
422 std::string &code = *code_ptr; in GetMemberOfVectorOfUnion() local
425 code += Indent + "/**\n"; in GetMemberOfVectorOfUnion()
426 code += Indent + " * @param int offset\n"; in GetMemberOfVectorOfUnion()
427 code += Indent + " * @return " + GenTypeGet(field.value.type) + "\n"; in GetMemberOfVectorOfUnion()
428 code += Indent + " */\n"; in GetMemberOfVectorOfUnion()
429 code += Indent + "public function get"; in GetMemberOfVectorOfUnion()
430 code += MakeCamel(field.name); in GetMemberOfVectorOfUnion()
431 code += "($j, $obj)\n"; in GetMemberOfVectorOfUnion()
432 code += Indent + "{\n"; in GetMemberOfVectorOfUnion()
433 code += Indent + Indent + "$o = $this->__offset(" + in GetMemberOfVectorOfUnion()
435 code += Indent + Indent + "return $o != 0 ? "; in GetMemberOfVectorOfUnion()
436 code += "$this->__union($obj, $this->__vector($o) + $j * "; in GetMemberOfVectorOfUnion()
437 code += NumToString(InlineSize(vectortype)) + " - $this->bb_pos) : null;\n"; in GetMemberOfVectorOfUnion()
438 code += Indent + "}\n\n"; in GetMemberOfVectorOfUnion()
456 std::string &code = *code_ptr; in StructBuilderArgs() local
457 code += std::string(", $") + nameprefix; in StructBuilderArgs()
458 code += MakeCamel(field.name, false); in StructBuilderArgs()
467 std::string &code = *code_ptr; in StructBuilderBody() local
468 code += Indent + Indent + "$builder->prep("; in StructBuilderBody()
469 code += NumToString(struct_def.minalign) + ", "; in StructBuilderBody()
470 code += NumToString(struct_def.bytesize) + ");\n"; in StructBuilderBody()
475 code += Indent + Indent + "$builder->pad("; in StructBuilderBody()
476 code += NumToString(field.padding) + ");\n"; in StructBuilderBody()
482 code += Indent + Indent + "$builder->put" + GenMethod(field) + "($"; in StructBuilderBody()
483 code += nameprefix + MakeCamel(field.name, false) + ");\n"; in StructBuilderBody()
491 std::string &code = *code_ptr; in GetStartOfTable() local
493 code += Indent + "/**\n"; in GetStartOfTable()
494 code += Indent + " * @param FlatBufferBuilder $builder\n"; in GetStartOfTable()
495 code += Indent + " * @return void\n"; in GetStartOfTable()
496 code += Indent + " */\n"; in GetStartOfTable()
497 code += Indent + "public static function start" + struct_def.name; in GetStartOfTable()
498 code += "(FlatBufferBuilder $builder)\n"; in GetStartOfTable()
499 code += Indent + "{\n"; in GetStartOfTable()
500 code += Indent + Indent + "$builder->StartObject("; in GetStartOfTable()
501 code += NumToString(struct_def.fields.vec.size()); in GetStartOfTable()
502 code += ");\n"; in GetStartOfTable()
503 code += Indent + "}\n\n"; in GetStartOfTable()
505 code += Indent + "/**\n"; in GetStartOfTable()
506 code += Indent + " * @param FlatBufferBuilder $builder\n"; in GetStartOfTable()
507 code += Indent + " * @return " + struct_def.name + "\n"; in GetStartOfTable()
508 code += Indent + " */\n"; in GetStartOfTable()
509 code += Indent + "public static function create" + struct_def.name; in GetStartOfTable()
510 code += "(FlatBufferBuilder $builder, "; in GetStartOfTable()
517 code += "$" + field.name; in GetStartOfTable()
518 if (!(it == (--struct_def.fields.vec.end()))) { code += ", "; } in GetStartOfTable()
520 code += ")\n"; in GetStartOfTable()
521 code += Indent + "{\n"; in GetStartOfTable()
522 code += Indent + Indent + "$builder->startObject("; in GetStartOfTable()
523 code += NumToString(struct_def.fields.vec.size()); in GetStartOfTable()
524 code += ");\n"; in GetStartOfTable()
530 code += Indent + Indent + "self::add"; in GetStartOfTable()
531 code += MakeCamel(field.name) + "($builder, $" + field.name + ");\n"; in GetStartOfTable()
534 code += Indent + Indent + "$o = $builder->endObject();\n"; in GetStartOfTable()
540 code += Indent + Indent + "$builder->required($o, "; in GetStartOfTable()
541 code += NumToString(field.value.offset); in GetStartOfTable()
542 code += "); // " + field.name + "\n"; in GetStartOfTable()
545 code += Indent + Indent + "return $o;\n"; in GetStartOfTable()
546 code += Indent + "}\n\n"; in GetStartOfTable()
552 std::string &code = *code_ptr; in BuildFieldOfTable() local
554 code += Indent + "/**\n"; in BuildFieldOfTable()
555 code += Indent + " * @param FlatBufferBuilder $builder\n"; in BuildFieldOfTable()
556 code += Indent + " * @param " + GenTypeBasic(field.value.type) + "\n"; in BuildFieldOfTable()
557 code += Indent + " * @return void\n"; in BuildFieldOfTable()
558 code += Indent + " */\n"; in BuildFieldOfTable()
559 code += Indent + "public static function "; in BuildFieldOfTable()
560 code += "add" + MakeCamel(field.name); in BuildFieldOfTable()
561 code += "(FlatBufferBuilder $builder, "; in BuildFieldOfTable()
562 code += "$" + MakeCamel(field.name, false); in BuildFieldOfTable()
563 code += ")\n"; in BuildFieldOfTable()
564 code += Indent + "{\n"; in BuildFieldOfTable()
565 code += Indent + Indent + "$builder->add"; in BuildFieldOfTable()
566 code += GenMethod(field) + "X("; in BuildFieldOfTable()
567 code += NumToString(offset) + ", "; in BuildFieldOfTable()
569 code += "$" + MakeCamel(field.name, false); in BuildFieldOfTable()
570 code += ", "; in BuildFieldOfTable()
573 code += "false"; in BuildFieldOfTable()
575 code += field.value.constant; in BuildFieldOfTable()
577 code += ");\n"; in BuildFieldOfTable()
578 code += Indent + "}\n\n"; in BuildFieldOfTable()
583 std::string &code = *code_ptr; in BuildVectorOfTable() local
588 code += Indent + "/**\n"; in BuildVectorOfTable()
589 code += Indent + " * @param FlatBufferBuilder $builder\n"; in BuildVectorOfTable()
590 code += Indent + " * @param array offset array\n"; in BuildVectorOfTable()
591 code += Indent + " * @return int vector offset\n"; in BuildVectorOfTable()
592 code += Indent + " */\n"; in BuildVectorOfTable()
593 code += Indent + "public static function create"; in BuildVectorOfTable()
594 code += MakeCamel(field.name); in BuildVectorOfTable()
595 code += "Vector(FlatBufferBuilder $builder, array $data)\n"; in BuildVectorOfTable()
596 code += Indent + "{\n"; in BuildVectorOfTable()
597 code += Indent + Indent + "$builder->startVector("; in BuildVectorOfTable()
598 code += NumToString(elem_size); in BuildVectorOfTable()
599 code += ", count($data), " + NumToString(alignment); in BuildVectorOfTable()
600 code += ");\n"; in BuildVectorOfTable()
601 code += Indent + Indent; in BuildVectorOfTable()
602 code += "for ($i = count($data) - 1; $i >= 0; $i--) {\n"; in BuildVectorOfTable()
604 code += Indent + Indent + Indent; in BuildVectorOfTable()
605 code += "$builder->put"; in BuildVectorOfTable()
606 code += MakeCamel(GenTypeBasic(field.value.type.VectorType())); in BuildVectorOfTable()
607 code += "($data[$i]);\n"; in BuildVectorOfTable()
609 code += Indent + Indent + Indent; in BuildVectorOfTable()
610 code += "$builder->putOffset($data[$i]);\n"; in BuildVectorOfTable()
612 code += Indent + Indent + "}\n"; in BuildVectorOfTable()
613 code += Indent + Indent + "return $builder->endVector();\n"; in BuildVectorOfTable()
614 code += Indent + "}\n\n"; in BuildVectorOfTable()
616 code += Indent + "/**\n"; in BuildVectorOfTable()
617 code += Indent + " * @param FlatBufferBuilder $builder\n"; in BuildVectorOfTable()
618 code += Indent + " * @param int $numElems\n"; in BuildVectorOfTable()
619 code += Indent + " * @return void\n"; in BuildVectorOfTable()
620 code += Indent + " */\n"; in BuildVectorOfTable()
621 code += Indent + "public static function start"; in BuildVectorOfTable()
622 code += MakeCamel(field.name); in BuildVectorOfTable()
623 code += "Vector(FlatBufferBuilder $builder, $numElems)\n"; in BuildVectorOfTable()
624 code += Indent + "{\n"; in BuildVectorOfTable()
625 code += Indent + Indent + "$builder->startVector("; in BuildVectorOfTable()
626 code += NumToString(elem_size); in BuildVectorOfTable()
627 code += ", $numElems, " + NumToString(alignment); in BuildVectorOfTable()
628 code += ");\n"; in BuildVectorOfTable()
629 code += Indent + "}\n\n"; in BuildVectorOfTable()
634 std::string &code = *code_ptr; in GetEndOffsetOnTable() local
636 code += Indent + "/**\n"; in GetEndOffsetOnTable()
637 code += Indent + " * @param FlatBufferBuilder $builder\n"; in GetEndOffsetOnTable()
638 code += Indent + " * @return int table offset\n"; in GetEndOffsetOnTable()
639 code += Indent + " */\n"; in GetEndOffsetOnTable()
640 code += Indent + "public static function end" + struct_def.name; in GetEndOffsetOnTable()
641 code += "(FlatBufferBuilder $builder)\n"; in GetEndOffsetOnTable()
642 code += Indent + "{\n"; in GetEndOffsetOnTable()
643 code += Indent + Indent + "$o = $builder->endObject();\n"; in GetEndOffsetOnTable()
649 code += Indent + Indent + "$builder->required($o, "; in GetEndOffsetOnTable()
650 code += NumToString(field.value.offset); in GetEndOffsetOnTable()
651 code += "); // " + field.name + "\n"; in GetEndOffsetOnTable()
654 code += Indent + Indent + "return $o;\n"; in GetEndOffsetOnTable()
655 code += Indent + "}\n"; in GetEndOffsetOnTable()
658 code += "\n"; in GetEndOffsetOnTable()
659 code += Indent + "public static function finish"; in GetEndOffsetOnTable()
660 code += struct_def.name; in GetEndOffsetOnTable()
661 code += "Buffer(FlatBufferBuilder $builder, $offset)\n"; in GetEndOffsetOnTable()
662 code += Indent + "{\n"; in GetEndOffsetOnTable()
663 code += Indent + Indent + "$builder->finish($offset"; in GetEndOffsetOnTable()
666 code += ", \"" + parser_.file_identifier_ + "\""; in GetEndOffsetOnTable()
667 code += ");\n"; in GetEndOffsetOnTable()
668 code += Indent + "}\n"; in GetEndOffsetOnTable()
727 std::string &code = *code_ptr; in GenTableBuilders() local
728 code += Indent + "public static function add"; in GenTableBuilders()
729 code += MakeCamel(field.name); in GenTableBuilders()
730 code += "(FlatBufferBuilder $builder, $offset)\n"; in GenTableBuilders()
731 code += Indent + "{\n"; in GenTableBuilders()
732 code += Indent + Indent + "$builder->addOffsetX("; in GenTableBuilders()
733 code += NumToString(offset) + ", $offset, 0);\n"; in GenTableBuilders()
734 code += Indent + "}\n\n"; in GenTableBuilders()
759 std::string &code = *code_ptr; in GenStruct() local
763 code += Indent + "public static function " + struct_def.name; in GenStruct()
764 code += "Identifier()\n"; in GenStruct()
765 code += Indent + "{\n"; in GenStruct()
766 code += Indent + Indent + "return \""; in GenStruct()
767 code += parser_.file_identifier_ + "\";\n"; in GenStruct()
768 code += Indent + "}\n\n"; in GenStruct()
771 code += Indent + "public static function " + struct_def.name; in GenStruct()
772 code += "BufferHasIdentifier(ByteBuffer $buf)\n"; in GenStruct()
773 code += Indent + "{\n"; in GenStruct()
774 code += Indent + Indent + "return self::"; in GenStruct()
775 code += "__has_identifier($buf, self::"; in GenStruct()
776 code += struct_def.name + "Identifier());\n"; in GenStruct()
777 code += Indent + "}\n\n"; in GenStruct()
782 code += Indent + "public static function " + struct_def.name; in GenStruct()
783 code += "Extension()\n"; in GenStruct()
784 code += Indent + "{\n"; in GenStruct()
785 code += Indent + Indent + "return \"" + parser_.file_extension_; in GenStruct()
786 code += "\";\n"; in GenStruct()
787 code += Indent + "}\n\n"; in GenStruct()
824 std::string &code = *code_ptr; in GenEnum() local
825 code += "\n"; in GenEnum()
826 code += Indent + "private static $names = array(\n"; in GenEnum()
829 code += Indent + Indent + enum_def.name + "::" + ev.name + "=>" + "\"" + in GenEnum()
833 code += Indent + ");\n\n"; in GenEnum()
834 code += Indent + "public static function Name($e)\n"; in GenEnum()
835 code += Indent + "{\n"; in GenEnum()
836 code += Indent + Indent + "if (!isset(self::$names[$e])) {\n"; in GenEnum()
837 code += Indent + Indent + Indent + "throw new \\Exception();\n"; in GenEnum()
838 code += Indent + Indent + "}\n"; in GenEnum()
839 code += Indent + Indent + "return self::$names[$e];\n"; in GenEnum()
840 code += Indent + "}\n"; in GenEnum()
917 std::string &code = *code_ptr; in GenStructBuilder() local
918 code += "\n"; in GenStructBuilder()
919 code += Indent + "/**\n"; in GenStructBuilder()
920 code += Indent + " * @return int offset\n"; in GenStructBuilder()
921 code += Indent + " */\n"; in GenStructBuilder()
922 code += Indent + "public static function create" + struct_def.name; in GenStructBuilder()
923 code += "(FlatBufferBuilder $builder"; in GenStructBuilder()
925 code += ")\n"; in GenStructBuilder()
926 code += Indent + "{\n"; in GenStructBuilder()
930 code += Indent + Indent + "return $builder->offset();\n"; in GenStructBuilder()
931 code += Indent + "}\n"; in GenStructBuilder()