mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
Fix for strictPropertyInitialization for TS (#4540)
* Eclipse ignore * TypeScript support * Prefixing enums * Test results * Merged JS and TS generators * Fixed AppVeyor build problems * Fixed more AppVeyor build problems * Fixed more AppVeyor build problems * Changed TS flag to options struct * Storing options by value * Removed unneeded const * Re-export support for unions * Uint support * Casting bools to numbers for mutation * TS shell tests * Reverted generates js test file to original version * Backing up js tests and properly generating test data * Not importing flatbuffers for TS test generation * Not overwriting generated js for tests * AppVeyor test fixes * Generating the most strict TS code possible * Not returning null when creating vectors * Not returning null from struct contructors * Vector of unions for ts/js * Sanity check for languages * Indentation fix + output test files * Vectors of unions for php * Fixes to union vector handling + tests * Fix for strictPropertyInitialization
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
67b29d4e43
commit
142401f50a
@@ -361,12 +361,12 @@ static std::string GenType(const Type &type) {
|
||||
|
||||
std::string GenGetter(const Type &type, const std::string &arguments) {
|
||||
switch (type.base_type) {
|
||||
case BASE_TYPE_STRING: return "this.bb.__string" + arguments;
|
||||
case BASE_TYPE_STRUCT: return "this.bb.__struct" + arguments;
|
||||
case BASE_TYPE_UNION: return "this.bb.__union" + arguments;
|
||||
case BASE_TYPE_STRING: return GenBBAccess() + ".__string" + arguments;
|
||||
case BASE_TYPE_STRUCT: return GenBBAccess() + ".__struct" + arguments;
|
||||
case BASE_TYPE_UNION: return GenBBAccess() + ".__union" + arguments;
|
||||
case BASE_TYPE_VECTOR: return GenGetter(type.VectorType(), arguments);
|
||||
default: {
|
||||
auto getter = "this.bb.read" + MakeCamel(GenType(type)) + arguments;
|
||||
auto getter = GenBBAccess() + ".read" + MakeCamel(GenType(type)) + arguments;
|
||||
if (type.base_type == BASE_TYPE_BOOL) {
|
||||
getter = "!!" + getter;
|
||||
}
|
||||
@@ -379,6 +379,10 @@ std::string GenGetter(const Type &type, const std::string &arguments) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string GenBBAccess() {
|
||||
return lang_.language == IDLOptions::kTs ? "this.bb!" : "this.bb";
|
||||
}
|
||||
|
||||
std::string GenDefaultValue(const Value &value, const std::string &context) {
|
||||
if (value.type.enum_def) {
|
||||
if (auto val = value.type.enum_def->ReverseLookup(
|
||||
@@ -570,7 +574,7 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
code += " /**\n";
|
||||
code += " * @type {flatbuffers.ByteBuffer}\n";
|
||||
code += " */\n";
|
||||
code += " bb: flatbuffers.ByteBuffer;\n";
|
||||
code += " bb: flatbuffers.ByteBuffer|null = null;\n";
|
||||
code += "\n";
|
||||
code += " /**\n";
|
||||
code += " * @type {number}\n";
|
||||
@@ -666,8 +670,9 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
it != struct_def.fields.vec.end(); ++it) {
|
||||
auto &field = **it;
|
||||
if (field.deprecated) continue;
|
||||
auto offset_prefix = " var offset = this.bb.__offset(this.bb_pos, " +
|
||||
NumToString(field.value.offset) + ");\n return offset ? ";
|
||||
auto offset_prefix = " var offset = " + GenBBAccess() +
|
||||
".__offset(this.bb_pos, " + NumToString(field.value.offset) +
|
||||
");\n return offset ? ";
|
||||
|
||||
// Emit a scalar field
|
||||
if (IsScalar(field.value.type.base_type) ||
|
||||
@@ -711,7 +716,7 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
index += ", optionalEncoding";
|
||||
}
|
||||
code += offset_prefix + GenGetter(field.value.type,
|
||||
"(" + index + ")") + " : " + GenDefaultValue(field.value, "this.bb");
|
||||
"(" + index + ")") + " : " + GenDefaultValue(field.value, GenBBAccess());
|
||||
code += ";\n";
|
||||
}
|
||||
}
|
||||
@@ -735,13 +740,13 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
if (struct_def.fixed) {
|
||||
code += " return (obj || new " + type;
|
||||
code += ").__init(this.bb_pos";
|
||||
code += MaybeAdd(field.value.offset) + ", this.bb);\n";
|
||||
code += MaybeAdd(field.value.offset) + ", " + GenBBAccess() + ");\n";
|
||||
} else {
|
||||
code += offset_prefix + "(obj || new " + type + ").__init(";
|
||||
code += field.value.type.struct_def->fixed
|
||||
? "this.bb_pos + offset"
|
||||
: "this.bb.__indirect(this.bb_pos + offset)";
|
||||
code += ", this.bb) : null;\n";
|
||||
: GenBBAccess() + ".__indirect(this.bb_pos + offset)";
|
||||
code += ", " + GenBBAccess() + ") : null;\n";
|
||||
}
|
||||
|
||||
if (lang_.language == IDLOptions::kTs) {
|
||||
@@ -755,7 +760,7 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
auto vectortype = field.value.type.VectorType();
|
||||
auto vectortypename = GenTypeName(vectortype, false);
|
||||
auto inline_size = InlineSize(vectortype);
|
||||
auto index = "this.bb.__vector(this.bb_pos + offset) + index" +
|
||||
auto index = GenBBAccess() + ".__vector(this.bb_pos + offset) + index" +
|
||||
MaybeScale(inline_size);
|
||||
std::string args = "@param {number} index\n";
|
||||
std::string ret_type;
|
||||
@@ -818,8 +823,8 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
code += ").__init(";
|
||||
code += vectortype.struct_def->fixed
|
||||
? index
|
||||
: "this.bb.__indirect(" + index + ")";
|
||||
code += ", this.bb)";
|
||||
: GenBBAccess() + ".__indirect(" + index + ")";
|
||||
code += ", " + GenBBAccess() + ")";
|
||||
} else {
|
||||
if (is_union) {
|
||||
index = "obj, " + index;
|
||||
@@ -833,7 +838,7 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
code += "false";
|
||||
} else if (field.value.type.element == BASE_TYPE_LONG ||
|
||||
field.value.type.element == BASE_TYPE_ULONG) {
|
||||
code += "this.bb.createLong(0, 0)";
|
||||
code += GenBBAccess() + ".createLong(0, 0)";
|
||||
} else if (IsScalar(field.value.type.element)) {
|
||||
if (field.value.type.enum_def) {
|
||||
code += "/** @type {" +
|
||||
@@ -899,15 +904,15 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
" = function(value) {\n";
|
||||
}
|
||||
|
||||
code += " var offset = this.bb.__offset(this.bb_pos, " +
|
||||
code += " var offset = " + GenBBAccess() + ".__offset(this.bb_pos, " +
|
||||
NumToString(field.value.offset) + ");\n\n";
|
||||
code += " if (offset === 0) {\n";
|
||||
code += " return false;\n";
|
||||
code += " }\n\n";
|
||||
|
||||
// special case for bools, which are treated as uint8
|
||||
code += " this.bb.write" + MakeCamel(GenType(field.value.type)) +
|
||||
"(this.bb_pos + offset, ";
|
||||
code += " " + GenBBAccess() + ".write" +
|
||||
MakeCamel(GenType(field.value.type)) + "(this.bb_pos + offset, ";
|
||||
if (field.value.type.base_type == BASE_TYPE_BOOL &&
|
||||
lang_.language == IDLOptions::kTs) {
|
||||
code += "+";
|
||||
@@ -936,7 +941,7 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
code += "Length = function() {\n" + offset_prefix;
|
||||
}
|
||||
|
||||
code += "this.bb.__vector_len(this.bb_pos + offset) : 0;\n};\n\n";
|
||||
code += GenBBAccess() + ".__vector_len(this.bb_pos + offset) : 0;\n};\n\n";
|
||||
|
||||
if(parser_.opts.use_goog_js_export_format) {
|
||||
exports += "goog.exportProperty(" + object_name + ".prototype, '" +
|
||||
@@ -958,9 +963,10 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
code += "Array = function() {\n" + offset_prefix;
|
||||
}
|
||||
|
||||
code += "new " + GenType(vectorType) + "Array(this.bb.bytes().buffer, "
|
||||
"this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), "
|
||||
"this.bb.__vector_len(this.bb_pos + offset)) : null;\n};\n\n";
|
||||
code += "new " + GenType(vectorType) + "Array(" + GenBBAccess() +
|
||||
".bytes().buffer, " + GenBBAccess() + ".bytes().byteOffset + " +
|
||||
GenBBAccess() + ".__vector(this.bb_pos + offset), " +
|
||||
GenBBAccess() + ".__vector_len(this.bb_pos + offset)) : null;\n};\n\n";
|
||||
|
||||
if(parser_.opts.use_goog_js_export_format) {
|
||||
exports += "goog.exportProperty(" + object_name + ".prototype, '" +
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@ export class TableInNestedNS {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
bb: flatbuffers.ByteBuffer;
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -48,8 +48,8 @@ static getRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS)
|
||||
* @returns {number}
|
||||
*/
|
||||
foo():number {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -57,13 +57,13 @@ foo():number {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
mutate_foo(value:number):boolean {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeInt32(this.bb_pos + offset, value);
|
||||
this.bb!.writeInt32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -101,7 +101,7 @@ export class StructInNestedNS {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
bb: flatbuffers.ByteBuffer;
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -122,7 +122,7 @@ __init(i:number, bb:flatbuffers.ByteBuffer):StructInNestedNS {
|
||||
* @returns {number}
|
||||
*/
|
||||
a():number {
|
||||
return this.bb.readInt32(this.bb_pos);
|
||||
return this.bb!.readInt32(this.bb_pos);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -130,13 +130,13 @@ a():number {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
mutate_a(value:number):boolean {
|
||||
var offset = this.bb.__offset(this.bb_pos, 0);
|
||||
var offset = this.bb!.__offset(this.bb_pos, 0);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeInt32(this.bb_pos + offset, value);
|
||||
this.bb!.writeInt32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -144,7 +144,7 @@ mutate_a(value:number):boolean {
|
||||
* @returns {number}
|
||||
*/
|
||||
b():number {
|
||||
return this.bb.readInt32(this.bb_pos + 4);
|
||||
return this.bb!.readInt32(this.bb_pos + 4);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -152,13 +152,13 @@ b():number {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
mutate_b(value:number):boolean {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeInt32(this.bb_pos + offset, value);
|
||||
this.bb!.writeInt32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import * as NS11563891686210618450 from "./namespace_test1_generated";
|
||||
import * as NS9459827973991502386 from "./namespace_test1_generated";
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
@@ -9,7 +9,7 @@ export class TableInFirstNS {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
bb: flatbuffers.ByteBuffer;
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -39,31 +39,31 @@ static getRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):T
|
||||
* @param {NamespaceA.NamespaceB.TableInNestedNS=} obj
|
||||
* @returns {NamespaceA.NamespaceB.TableInNestedNS|null}
|
||||
*/
|
||||
fooTable(obj?:NS11563891686210618450.NamespaceA.NamespaceB.TableInNestedNS):NS11563891686210618450.NamespaceA.NamespaceB.TableInNestedNS|null {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? (obj || new NS11563891686210618450.NamespaceA.NamespaceB.TableInNestedNS).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
|
||||
fooTable(obj?:NS9459827973991502386.NamespaceA.NamespaceB.TableInNestedNS):NS9459827973991502386.NamespaceA.NamespaceB.TableInNestedNS|null {
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? (obj || new NS9459827973991502386.NamespaceA.NamespaceB.TableInNestedNS).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {NamespaceA.NamespaceB.EnumInNestedNS}
|
||||
*/
|
||||
fooEnum():NS11563891686210618450.NamespaceA.NamespaceB.EnumInNestedNS {
|
||||
var offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? /** @type {NamespaceA.NamespaceB.EnumInNestedNS} */ (this.bb.readInt8(this.bb_pos + offset)) : NS11563891686210618450.NamespaceA.NamespaceB.EnumInNestedNS.A;
|
||||
fooEnum():NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS {
|
||||
var offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? /** @type {NamespaceA.NamespaceB.EnumInNestedNS} */ (this.bb!.readInt8(this.bb_pos + offset)) : NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS.A;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {NamespaceA.NamespaceB.EnumInNestedNS} value
|
||||
* @returns {boolean}
|
||||
*/
|
||||
mutate_foo_enum(value:NS11563891686210618450.NamespaceA.NamespaceB.EnumInNestedNS):boolean {
|
||||
var offset = this.bb.__offset(this.bb_pos, 6);
|
||||
mutate_foo_enum(value:NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS):boolean {
|
||||
var offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeInt8(this.bb_pos + offset, value);
|
||||
this.bb!.writeInt8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -71,9 +71,9 @@ mutate_foo_enum(value:NS11563891686210618450.NamespaceA.NamespaceB.EnumInNestedN
|
||||
* @param {NamespaceA.NamespaceB.StructInNestedNS=} obj
|
||||
* @returns {NamespaceA.NamespaceB.StructInNestedNS|null}
|
||||
*/
|
||||
fooStruct(obj?:NS11563891686210618450.NamespaceA.NamespaceB.StructInNestedNS):NS11563891686210618450.NamespaceA.NamespaceB.StructInNestedNS|null {
|
||||
var offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? (obj || new NS11563891686210618450.NamespaceA.NamespaceB.StructInNestedNS).__init(this.bb_pos + offset, this.bb) : null;
|
||||
fooStruct(obj?:NS9459827973991502386.NamespaceA.NamespaceB.StructInNestedNS):NS9459827973991502386.NamespaceA.NamespaceB.StructInNestedNS|null {
|
||||
var offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? (obj || new NS9459827973991502386.NamespaceA.NamespaceB.StructInNestedNS).__init(this.bb_pos + offset, this.bb!) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -95,8 +95,8 @@ static addFooTable(builder:flatbuffers.Builder, fooTableOffset:flatbuffers.Offse
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {NamespaceA.NamespaceB.EnumInNestedNS} fooEnum
|
||||
*/
|
||||
static addFooEnum(builder:flatbuffers.Builder, fooEnum:NS11563891686210618450.NamespaceA.NamespaceB.EnumInNestedNS) {
|
||||
builder.addFieldInt8(1, fooEnum, NS11563891686210618450.NamespaceA.NamespaceB.EnumInNestedNS.A);
|
||||
static addFooEnum(builder:flatbuffers.Builder, fooEnum:NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS) {
|
||||
builder.addFieldInt8(1, fooEnum, NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS.A);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -126,7 +126,7 @@ export class TableInC {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
bb: flatbuffers.ByteBuffer;
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -157,8 +157,8 @@ static getRootAsTableInC(bb:flatbuffers.ByteBuffer, obj?:TableInC):TableInC {
|
||||
* @returns {NamespaceA.TableInFirstNS|null}
|
||||
*/
|
||||
referToA1(obj?:NamespaceA.TableInFirstNS):NamespaceA.TableInFirstNS|null {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? (obj || new NamespaceA.TableInFirstNS).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? (obj || new NamespaceA.TableInFirstNS).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -166,8 +166,8 @@ referToA1(obj?:NamespaceA.TableInFirstNS):NamespaceA.TableInFirstNS|null {
|
||||
* @returns {NamespaceA.SecondTableInA|null}
|
||||
*/
|
||||
referToA2(obj?:NamespaceA.SecondTableInA):NamespaceA.SecondTableInA|null {
|
||||
var offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? (obj || new NamespaceA.SecondTableInA).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? (obj || new NamespaceA.SecondTableInA).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -212,7 +212,7 @@ export class SecondTableInA {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
bb: flatbuffers.ByteBuffer;
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -243,8 +243,8 @@ static getRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):S
|
||||
* @returns {NamespaceC.TableInC|null}
|
||||
*/
|
||||
referToC(obj?:NamespaceC.TableInC):NamespaceC.TableInC|null {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? (obj || new NamespaceC.TableInC).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? (obj || new NamespaceC.TableInC).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ export class Attacker {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
bb: flatbuffers.ByteBuffer;
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -50,8 +50,8 @@ static getRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker {
|
||||
* @returns {number}
|
||||
*/
|
||||
swordAttackDamage():number {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -59,13 +59,13 @@ swordAttackDamage():number {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
mutate_sword_attack_damage(value:number):boolean {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeInt32(this.bb_pos + offset, value);
|
||||
this.bb!.writeInt32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -101,7 +101,7 @@ export class Rapunzel {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
bb: flatbuffers.ByteBuffer;
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -122,7 +122,7 @@ __init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel {
|
||||
* @returns {number}
|
||||
*/
|
||||
hairLength():number {
|
||||
return this.bb.readInt32(this.bb_pos);
|
||||
return this.bb!.readInt32(this.bb_pos);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -130,13 +130,13 @@ hairLength():number {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
mutate_hair_length(value:number):boolean {
|
||||
var offset = this.bb.__offset(this.bb_pos, 0);
|
||||
var offset = this.bb!.__offset(this.bb_pos, 0);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeInt32(this.bb_pos + offset, value);
|
||||
this.bb!.writeInt32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -159,7 +159,7 @@ export class BookReader {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
bb: flatbuffers.ByteBuffer;
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -180,7 +180,7 @@ __init(i:number, bb:flatbuffers.ByteBuffer):BookReader {
|
||||
* @returns {number}
|
||||
*/
|
||||
booksRead():number {
|
||||
return this.bb.readInt32(this.bb_pos);
|
||||
return this.bb!.readInt32(this.bb_pos);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -188,13 +188,13 @@ booksRead():number {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
mutate_books_read(value:number):boolean {
|
||||
var offset = this.bb.__offset(this.bb_pos, 0);
|
||||
var offset = this.bb!.__offset(this.bb_pos, 0);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeInt32(this.bb_pos + offset, value);
|
||||
this.bb!.writeInt32(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -217,7 +217,7 @@ export class Movie {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
bb: flatbuffers.ByteBuffer;
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -255,8 +255,8 @@ static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
|
||||
* @returns {Character}
|
||||
*/
|
||||
mainCharacterType():Character {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? /** @type {Character} */ (this.bb.readUint8(this.bb_pos + offset)) : Character.NONE;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? /** @type {Character} */ (this.bb!.readUint8(this.bb_pos + offset)) : Character.NONE;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -264,13 +264,13 @@ mainCharacterType():Character {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
mutate_main_character_type(value:Character):boolean {
|
||||
var offset = this.bb.__offset(this.bb_pos, 4);
|
||||
var offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
|
||||
if (offset === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.bb.writeUint8(this.bb_pos + offset, value);
|
||||
this.bb!.writeUint8(this.bb_pos + offset, value);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -279,8 +279,8 @@ mutate_main_character_type(value:Character):boolean {
|
||||
* @returns {?flatbuffers.Table}
|
||||
*/
|
||||
mainCharacter<T extends flatbuffers.Table>(obj:T):T|null {
|
||||
var offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -288,24 +288,24 @@ mainCharacter<T extends flatbuffers.Table>(obj:T):T|null {
|
||||
* @returns {Character}
|
||||
*/
|
||||
charactersType(index: number):Character|null {
|
||||
var offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? /** @type {Character} */ (this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index)) : /** @type {Character} */ (0);
|
||||
var offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? /** @type {Character} */ (this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index)) : /** @type {Character} */ (0);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
charactersTypeLength():number {
|
||||
var offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
charactersTypeArray():Uint8Array|null {
|
||||
var offset = this.bb.__offset(this.bb_pos, 8);
|
||||
return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 8);
|
||||
return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -314,16 +314,16 @@ charactersTypeArray():Uint8Array|null {
|
||||
* @returns {?flatbuffers.Table}
|
||||
*/
|
||||
characters<T extends flatbuffers.Table>(index: number, obj:T):T|null {
|
||||
var offset = this.bb.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb.__union(obj, this.bb.__vector(this.bb_pos + offset) + index * 4) : null;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.__union(obj, this.bb!.__vector(this.bb_pos + offset) + index * 4) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
charactersLength():number {
|
||||
var offset = this.bb.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
var offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user