Commit 0bb3ce69 authored by Björn Harrtell's avatar Björn Harrtell Committed by Wouter van Oortmerssen

[JS/TS] Size prefix support (#5326)

* WIP size prefix support

* Consider size prefix in overloaded variant

* Work on code gen

* Disabled helper functions in code gen

* Enabled helper functions in code gen

* Fix size prefixed test

* Fix bad function call

* Add SIZE_PREFIX_LENGTH

* Fix review comments
parent b56d60f0
......@@ -48,6 +48,12 @@ flatbuffers.SIZEOF_INT = 4;
*/
flatbuffers.FILE_IDENTIFIER_LENGTH = 4;
/**
* @type {number}
* @const
*/
flatbuffers.SIZE_PREFIX_LENGTH = 4;
/**
* @enum {number}
*/
......@@ -676,12 +682,14 @@ outer_loop:
*
* @param {flatbuffers.Offset} root_table
* @param {string=} opt_file_identifier
* @param {boolean=} opt_size_prefix
*/
flatbuffers.Builder.prototype.finish = function(root_table, opt_file_identifier) {
flatbuffers.Builder.prototype.finish = function(root_table, opt_file_identifier, opt_size_prefix) {
var size_prefix = opt_size_prefix ? flatbuffers.SIZE_PREFIX_LENGTH : 0;
if (opt_file_identifier) {
var file_identifier = opt_file_identifier;
this.prep(this.minalign, flatbuffers.SIZEOF_INT +
flatbuffers.FILE_IDENTIFIER_LENGTH);
flatbuffers.FILE_IDENTIFIER_LENGTH + size_prefix);
if (file_identifier.length != flatbuffers.FILE_IDENTIFIER_LENGTH) {
throw new Error('FlatBuffers: file identifier must be length ' +
flatbuffers.FILE_IDENTIFIER_LENGTH);
......@@ -690,11 +698,24 @@ flatbuffers.Builder.prototype.finish = function(root_table, opt_file_identifier)
this.writeInt8(file_identifier.charCodeAt(i));
}
}
this.prep(this.minalign, flatbuffers.SIZEOF_INT);
this.prep(this.minalign, flatbuffers.SIZEOF_INT + size_prefix);
this.addOffset(root_table);
if (size_prefix) {
this.addInt32(this.bb.capacity() - this.space);
}
this.bb.setPosition(this.space);
};
/**
* Finalize a size prefixed buffer, pointing to the given `root_table`.
*
* @param {flatbuffers.Offset} root_table
* @param {string=} opt_file_identifier
*/
flatbuffers.Builder.prototype.finishSizePrefixed = function (root_table, opt_file_identifier) {
this.finish(root_table, opt_file_identifier, true);
};
/// @cond FLATBUFFERS_INTERNAL
/**
* This checks a required field has been set in a given table that has
......
......@@ -604,6 +604,62 @@ class JsTsGenerator : public BaseGenerator {
}
}
void GenerateRootAccessor(StructDef &struct_def, std::string *code_ptr,
std::string &code, std::string &object_name, bool size_prefixed) {
if (!struct_def.fixed) {
GenDocComment(code_ptr,
GenTypeAnnotation(kParam, "flatbuffers.ByteBuffer", "bb") +
GenTypeAnnotation(kParam, object_name + "=", "obj") +
GenTypeAnnotation(kReturns, object_name, "", false));
std::string sizePrefixed("SizePrefixed");
if (lang_.language == IDLOptions::kTs) {
code += "static get" + (size_prefixed ? sizePrefixed : "") + "Root" + Verbose(struct_def, "As");
code += "(bb:flatbuffers.ByteBuffer, obj?:" + object_name +
"):" + object_name + " {\n";
} else {
code += object_name + ".get" + (size_prefixed ? sizePrefixed : "") + "Root" + Verbose(struct_def, "As");
code += " = function(bb, obj) {\n";
}
code += " return (obj || new " + object_name;
code += ").__init(bb.readInt32(bb.position()) + bb.position(), bb);\n";
code += "};\n\n";
}
}
void GenerateFinisher(StructDef &struct_def, std::string *code_ptr,
std::string &code, std::string &object_name, bool size_prefixed) {
if (parser_.root_struct_def_ == &struct_def) {
std::string sizePrefixed("SizePrefixed");
GenDocComment(
code_ptr,
GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder") +
GenTypeAnnotation(kParam, "flatbuffers.Offset", "offset",
false));
if (lang_.language == IDLOptions::kTs) {
code += "static finish" + (size_prefixed ? sizePrefixed : "") + Verbose(struct_def) + "Buffer";
code +=
"(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {\n";
} else {
code += object_name + ".finish" + (size_prefixed ? sizePrefixed : "") + Verbose(struct_def) + "Buffer";
code += " = function(builder, offset) {\n";
}
code += " builder.finish(offset";
if (!parser_.file_identifier_.empty()) {
code += ", '" + parser_.file_identifier_ + "'";
}
if (size_prefixed) {
if (parser_.file_identifier_.empty()) {
code += ", undefined";
}
code += ", true";
}
code += ");\n";
code += "};\n\n";
}
}
// Generate an accessor struct with constructor for a flatbuffers struct.
void GenStruct(const Parser &parser, StructDef &struct_def,
std::string *code_ptr, std::string *exports_ptr,
......@@ -688,43 +744,28 @@ class JsTsGenerator : public BaseGenerator {
code += " return this;\n";
code += "};\n\n";
// Generate a special accessor for the table that when used as the root of a
// Generate special accessors for the table that when used as the root of a
// FlatBuffer
if (!struct_def.fixed) {
GenDocComment(code_ptr,
GenTypeAnnotation(kParam, "flatbuffers.ByteBuffer", "bb") +
GenTypeAnnotation(kParam, object_name + "=", "obj") +
GenTypeAnnotation(kReturns, object_name, "", false));
GenerateRootAccessor(struct_def, code_ptr, code, object_name, false);
GenerateRootAccessor(struct_def, code_ptr, code, object_name, true);
// Generate the identifier check method
if (!struct_def.fixed && parser_.root_struct_def_ == &struct_def &&
!parser_.file_identifier_.empty()) {
GenDocComment(
code_ptr,
GenTypeAnnotation(kParam, "flatbuffers.ByteBuffer", "bb") +
GenTypeAnnotation(kReturns, "boolean", "", false));
if (lang_.language == IDLOptions::kTs) {
code += "static getRoot" + Verbose(struct_def, "As");
code += "(bb:flatbuffers.ByteBuffer, obj?:" + object_name +
"):" + object_name + " {\n";
code +=
"static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean "
"{\n";
} else {
code += object_name + ".getRoot" + Verbose(struct_def, "As");
code += " = function(bb, obj) {\n";
code += object_name + ".bufferHasIdentifier = function(bb) {\n";
}
code += " return (obj || new " + object_name;
code += ").__init(bb.readInt32(bb.position()) + bb.position(), bb);\n";
code += "};\n\n";
// Generate the identifier check method
if (parser_.root_struct_def_ == &struct_def &&
!parser_.file_identifier_.empty()) {
GenDocComment(
code_ptr,
GenTypeAnnotation(kParam, "flatbuffers.ByteBuffer", "bb") +
GenTypeAnnotation(kReturns, "boolean", "", false));
if (lang_.language == IDLOptions::kTs) {
code +=
"static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean "
"{\n";
} else {
code += object_name + ".bufferHasIdentifier = function(bb) {\n";
}
code += " return bb.__has_identifier('" + parser_.file_identifier_;
code += "');\n};\n\n";
}
code += " return bb.__has_identifier('" + parser_.file_identifier_;
code += "');\n};\n\n";
}
// Emit field accessors
......@@ -1238,30 +1279,9 @@ class JsTsGenerator : public BaseGenerator {
code += " return offset;\n";
code += "};\n\n";
// Generate the method to complete buffer construction
if (parser_.root_struct_def_ == &struct_def) {
GenDocComment(
code_ptr,
GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder") +
GenTypeAnnotation(kParam, "flatbuffers.Offset", "offset",
false));
if (lang_.language == IDLOptions::kTs) {
code += "static finish" + Verbose(struct_def) + "Buffer";
code +=
"(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {\n";
} else {
code += object_name + ".finish" + Verbose(struct_def) + "Buffer";
code += " = function(builder, offset) {\n";
}
code += " builder.finish(offset";
if (!parser_.file_identifier_.empty()) {
code += ", '" + parser_.file_identifier_ + "'";
}
code += ");\n";
code += "};\n\n";
}
// Generate the methods to complete buffer construction
GenerateFinisher(struct_def, code_ptr, code, object_name, false);
GenerateFinisher(struct_def, code_ptr, code, object_name, true);
// Generate a convenient CreateX function
if (lang_.language == IDLOptions::kJs) {
......
......@@ -246,8 +246,10 @@ function testUnicode() {
MyGame.Example.Monster.addTestarrayofstring(fbb, testarrayofstringOffset);
MyGame.Example.Monster.addTestarrayoftables(fbb, testarrayoftablesOffset);
MyGame.Example.Monster.addName(fbb, name);
MyGame.Example.Monster.finishMonsterBuffer(fbb, MyGame.Example.Monster.endMonster(fbb));
testReadingUnicode(new flatbuffers.ByteBuffer(fbb.asUint8Array()));
MyGame.Example.Monster.finishSizePrefixedMonsterBuffer(fbb, MyGame.Example.Monster.endMonster(fbb));
var bb = new flatbuffers.ByteBuffer(fbb.asUint8Array())
bb.setPosition(4);
testReadingUnicode(bb);
}
var __imul = Math.imul ? Math.imul : function(a, b) {
......
......@@ -137,6 +137,15 @@ MyGame.InParentNamespace.getRootAsInParentNamespace = function(bb, obj) {
return (obj || new MyGame.InParentNamespace).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.InParentNamespace=} obj
* @returns {MyGame.InParentNamespace}
*/
MyGame.InParentNamespace.getSizePrefixedRootAsInParentNamespace = function(bb, obj) {
return (obj || new MyGame.InParentNamespace).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.Builder} builder
*/
......@@ -197,6 +206,15 @@ MyGame.Example2.Monster.getRootAsMonster = function(bb, obj) {
return (obj || new MyGame.Example2.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example2.Monster=} obj
* @returns {MyGame.Example2.Monster}
*/
MyGame.Example2.Monster.getSizePrefixedRootAsMonster = function(bb, obj) {
return (obj || new MyGame.Example2.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.Builder} builder
*/
......@@ -341,6 +359,15 @@ MyGame.Example.TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum = functi
return (obj || new MyGame.Example.TestSimpleTableWithEnum).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example.TestSimpleTableWithEnum=} obj
* @returns {MyGame.Example.TestSimpleTableWithEnum}
*/
MyGame.Example.TestSimpleTableWithEnum.getSizePrefixedRootAsTestSimpleTableWithEnum = function(bb, obj) {
return (obj || new MyGame.Example.TestSimpleTableWithEnum).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns {MyGame.Example.Color}
*/
......@@ -689,6 +716,15 @@ MyGame.Example.Stat.getRootAsStat = function(bb, obj) {
return (obj || new MyGame.Example.Stat).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example.Stat=} obj
* @returns {MyGame.Example.Stat}
*/
MyGame.Example.Stat.getSizePrefixedRootAsStat = function(bb, obj) {
return (obj || new MyGame.Example.Stat).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.Encoding=} optionalEncoding
* @returns {string|Uint8Array|null}
......@@ -834,6 +870,15 @@ MyGame.Example.Referrable.getRootAsReferrable = function(bb, obj) {
return (obj || new MyGame.Example.Referrable).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example.Referrable=} obj
* @returns {MyGame.Example.Referrable}
*/
MyGame.Example.Referrable.getSizePrefixedRootAsReferrable = function(bb, obj) {
return (obj || new MyGame.Example.Referrable).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns {flatbuffers.Long}
*/
......@@ -929,6 +974,15 @@ MyGame.Example.Monster.getRootAsMonster = function(bb, obj) {
return (obj || new MyGame.Example.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example.Monster=} obj
* @returns {MyGame.Example.Monster}
*/
MyGame.Example.Monster.getSizePrefixedRootAsMonster = function(bb, obj) {
return (obj || new MyGame.Example.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @returns {boolean}
......@@ -2597,6 +2651,14 @@ MyGame.Example.Monster.finishMonsterBuffer = function(builder, offset) {
builder.finish(offset, 'MONS');
};
/**
* @param {flatbuffers.Builder} builder
* @param {flatbuffers.Offset} offset
*/
MyGame.Example.Monster.finishSizePrefixedMonsterBuffer = function(builder, offset) {
builder.finish(offset, 'MONS', true);
};
/**
* @param {flatbuffers.Builder} builder
* @param {flatbuffers.Offset} posOffset
......@@ -2735,6 +2797,15 @@ MyGame.Example.TypeAliases.getRootAsTypeAliases = function(bb, obj) {
return (obj || new MyGame.Example.TypeAliases).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example.TypeAliases=} obj
* @returns {MyGame.Example.TypeAliases}
*/
MyGame.Example.TypeAliases.getSizePrefixedRootAsTypeAliases = function(bb, obj) {
return (obj || new MyGame.Example.TypeAliases).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns {number}
*/
......
......@@ -71,6 +71,15 @@ static getRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamesp
return (obj || new InParentNamespace).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param InParentNamespace= obj
* @returns InParentNamespace
*/
static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace {
return (obj || new InParentNamespace).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.Builder builder
*/
......@@ -121,6 +130,15 @@ static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
return (obj || new Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param Monster= obj
* @returns Monster
*/
static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
return (obj || new Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.Builder builder
*/
......@@ -250,6 +268,15 @@ static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimp
return (obj || new TestSimpleTableWithEnum).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param TestSimpleTableWithEnum= obj
* @returns TestSimpleTableWithEnum
*/
static getSizePrefixedRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum {
return (obj || new TestSimpleTableWithEnum).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns MyGame.Example.Color
*/
......@@ -577,6 +604,15 @@ static getRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat {
return (obj || new Stat).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param Stat= obj
* @returns Stat
*/
static getSizePrefixedRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat {
return (obj || new Stat).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.Encoding= optionalEncoding
* @returns string|Uint8Array|null
......@@ -711,6 +747,15 @@ static getRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrabl
return (obj || new Referrable).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param Referrable= obj
* @returns Referrable
*/
static getSizePrefixedRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable {
return (obj || new Referrable).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns flatbuffers.Long
*/
......@@ -795,6 +840,15 @@ static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
return (obj || new Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param Monster= obj
* @returns Monster
*/
static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster {
return (obj || new Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @returns boolean
......@@ -2469,6 +2523,14 @@ static finishMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offse
builder.finish(offset, 'MONS');
};
/**
* @param flatbuffers.Builder builder
* @param flatbuffers.Offset offset
*/
static finishSizePrefixedMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'MONS', true);
};
static createMonster(builder:flatbuffers.Builder, posOffset:flatbuffers.Offset, mana:number, hp:number, nameOffset:flatbuffers.Offset, inventoryOffset:flatbuffers.Offset, color:MyGame.Example.Color, testType:MyGame.Example.Any, testOffset:flatbuffers.Offset, test4Offset:flatbuffers.Offset, testarrayofstringOffset:flatbuffers.Offset, testarrayoftablesOffset:flatbuffers.Offset, enemyOffset:flatbuffers.Offset, testnestedflatbufferOffset:flatbuffers.Offset, testemptyOffset:flatbuffers.Offset, testbool:boolean, testhashs32Fnv1:number, testhashu32Fnv1:number, testhashs64Fnv1:flatbuffers.Long, testhashu64Fnv1:flatbuffers.Long, testhashs32Fnv1a:number, testhashu32Fnv1a:number, testhashs64Fnv1a:flatbuffers.Long, testhashu64Fnv1a:flatbuffers.Long, testarrayofboolsOffset:flatbuffers.Offset, testf:number, testf2:number, testf3:number, testarrayofstring2Offset:flatbuffers.Offset, testarrayofsortedstructOffset:flatbuffers.Offset, flexOffset:flatbuffers.Offset, test5Offset:flatbuffers.Offset, vectorOfLongsOffset:flatbuffers.Offset, vectorOfDoublesOffset:flatbuffers.Offset, parentNamespaceTestOffset:flatbuffers.Offset, vectorOfReferrablesOffset:flatbuffers.Offset, singleWeakReference:flatbuffers.Long, vectorOfWeakReferencesOffset:flatbuffers.Offset, vectorOfStrongReferrablesOffset:flatbuffers.Offset, coOwningReference:flatbuffers.Long, vectorOfCoOwningReferencesOffset:flatbuffers.Offset, nonOwningReference:flatbuffers.Long, vectorOfNonOwningReferencesOffset:flatbuffers.Offset, anyUniqueType:MyGame.Example.AnyUniqueAliases, anyUniqueOffset:flatbuffers.Offset, anyAmbiguousType:MyGame.Example.AnyAmbiguousAliases, anyAmbiguousOffset:flatbuffers.Offset, vectorOfEnumsOffset:flatbuffers.Offset):flatbuffers.Offset {
Monster.startMonster(builder);
Monster.addPos(builder, posOffset);
......@@ -2550,6 +2612,15 @@ static getRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAli
return (obj || new TypeAliases).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param TypeAliases= obj
* @returns TypeAliases
*/
static getSizePrefixedRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases {
return (obj || new TypeAliases).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns number
*/
......
......@@ -65,6 +65,15 @@ NamespaceA.NamespaceB.TableInNestedNS.getRootAsTableInNestedNS = function(bb, ob
return (obj || new NamespaceA.NamespaceB.TableInNestedNS).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {NamespaceA.NamespaceB.TableInNestedNS=} obj
* @returns {NamespaceA.NamespaceB.TableInNestedNS}
*/
NamespaceA.NamespaceB.TableInNestedNS.getSizePrefixedRootAsTableInNestedNS = function(bb, obj) {
return (obj || new NamespaceA.NamespaceB.TableInNestedNS).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns {number}
*/
......
......@@ -38,6 +38,15 @@ static getRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS)
return (obj || new TableInNestedNS).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param TableInNestedNS= obj
* @returns TableInNestedNS
*/
static getSizePrefixedRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):TableInNestedNS {
return (obj || new TableInNestedNS).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns number
*/
......
......@@ -53,6 +53,15 @@ NamespaceA.TableInFirstNS.getRootAsTableInFirstNS = function(bb, obj) {
return (obj || new NamespaceA.TableInFirstNS).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {NamespaceA.TableInFirstNS=} obj
* @returns {NamespaceA.TableInFirstNS}
*/
NamespaceA.TableInFirstNS.getSizePrefixedRootAsTableInFirstNS = function(bb, obj) {
return (obj || new NamespaceA.TableInFirstNS).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {NamespaceA.NamespaceB.TableInNestedNS=} obj
* @returns {NamespaceA.NamespaceB.TableInNestedNS|null}
......@@ -184,6 +193,15 @@ NamespaceC.TableInC.getRootAsTableInC = function(bb, obj) {
return (obj || new NamespaceC.TableInC).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {NamespaceC.TableInC=} obj
* @returns {NamespaceC.TableInC}
*/
NamespaceC.TableInC.getSizePrefixedRootAsTableInC = function(bb, obj) {
return (obj || new NamespaceC.TableInC).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {NamespaceA.TableInFirstNS=} obj
* @returns {NamespaceA.TableInFirstNS|null}
......@@ -282,6 +300,15 @@ NamespaceA.SecondTableInA.getRootAsSecondTableInA = function(bb, obj) {
return (obj || new NamespaceA.SecondTableInA).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {NamespaceA.SecondTableInA=} obj
* @returns {NamespaceA.SecondTableInA}
*/
NamespaceA.SecondTableInA.getSizePrefixedRootAsSecondTableInA = function(bb, obj) {
return (obj || new NamespaceA.SecondTableInA).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {NamespaceC.TableInC=} obj
* @returns {NamespaceC.TableInC|null}
......
......@@ -29,6 +29,15 @@ static getRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):T
return (obj || new TableInFirstNS).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param TableInFirstNS= obj
* @returns TableInFirstNS
*/
static getSizePrefixedRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):TableInFirstNS {
return (obj || new TableInFirstNS).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param NamespaceA.NamespaceB.TableInNestedNS= obj
* @returns NamespaceA.NamespaceB.TableInNestedNS|null
......@@ -147,6 +156,15 @@ static getRootAsTableInC(bb:flatbuffers.ByteBuffer, obj?:TableInC):TableInC {
return (obj || new TableInC).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param TableInC= obj
* @returns TableInC
*/
static getSizePrefixedRootAsTableInC(bb:flatbuffers.ByteBuffer, obj?:TableInC):TableInC {
return (obj || new TableInC).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param NamespaceA.TableInFirstNS= obj
* @returns NamespaceA.TableInFirstNS|null
......@@ -233,6 +251,15 @@ static getRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):S
return (obj || new SecondTableInA).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param SecondTableInA= obj
* @returns SecondTableInA
*/
static getSizePrefixedRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):SecondTableInA {
return (obj || new SecondTableInA).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param NamespaceC.TableInC= obj
* @returns NamespaceC.TableInC|null
......
......@@ -61,6 +61,15 @@ Attacker.getRootAsAttacker = function(bb, obj) {
return (obj || new Attacker).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {Attacker=} obj
* @returns {Attacker}
*/
Attacker.getSizePrefixedRootAsAttacker = function(bb, obj) {
return (obj || new Attacker).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns {number}
*/
......@@ -272,6 +281,15 @@ Movie.getRootAsMovie = function(bb, obj) {
return (obj || new Movie).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {Movie=} obj
* @returns {Movie}
*/
Movie.getSizePrefixedRootAsMovie = function(bb, obj) {
return (obj || new Movie).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @returns {boolean}
......@@ -453,6 +471,14 @@ Movie.finishMovieBuffer = function(builder, offset) {
builder.finish(offset, 'MOVI');
};
/**
* @param {flatbuffers.Builder} builder
* @param {flatbuffers.Offset} offset
*/
Movie.finishSizePrefixedMovieBuffer = function(builder, offset) {
builder.finish(offset, 'MOVI', true);
};
/**
* @param {flatbuffers.Builder} builder
* @param {Character} mainCharacterType
......
......@@ -40,6 +40,15 @@ static getRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker {
return (obj || new Attacker).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param Attacker= obj
* @returns Attacker
*/
static getSizePrefixedRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker {
return (obj || new Attacker).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns number
*/
......@@ -224,6 +233,15 @@ static getRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie {
return (obj || new Movie).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @param Movie= obj
* @returns Movie
*/
static getSizePrefixedRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie {
return (obj || new Movie).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param flatbuffers.ByteBuffer bb
* @returns boolean
......@@ -405,6 +423,14 @@ static finishMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset)
builder.finish(offset, 'MOVI');
};
/**
* @param flatbuffers.Builder builder
* @param flatbuffers.Offset offset
*/
static finishSizePrefixedMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, 'MOVI', true);
};
static createMovie(builder:flatbuffers.Builder, mainCharacterType:Character, mainCharacterOffset:flatbuffers.Offset, charactersTypeOffset:flatbuffers.Offset, charactersOffset:flatbuffers.Offset):flatbuffers.Offset {
Movie.startMovie(builder);
Movie.addMainCharacterType(builder, mainCharacterType);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment