diff options
author | Björn Harrtell <bjornharrtell@users.noreply.github.com> | 2021-04-12 19:41:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-12 10:41:59 -0700 |
commit | 408e4db4af7c728d6cd67cc5c855b71fe283aaa2 (patch) | |
tree | 0e4d4c7c011ca812659849e5942216abd335f035 | |
parent | 4d2364f34263be96895524e5a89a50627429cf4a (diff) | |
download | flatbuffers-408e4db4af7c728d6cd67cc5c855b71fe283aaa2.tar.gz flatbuffers-408e4db4af7c728d6cd67cc5c855b71fe283aaa2.tar.bz2 flatbuffers-408e4db4af7c728d6cd67cc5c855b71fe283aaa2.zip |
[TS] Add Build TS to CI jobs (#6524)
* Add Build TS to CI jobs
* Add npm compile step
* Fix syntax
* Add required code gen for TS
* Exit on failure
* Make TS code gen identical to test run
* Remove duplicate TS code gen artifacts
* Remove bad gitignore
* Forgot parts of generate_code and make sure same settings for test run
* Don't forget about the bat
* Try and fix flatc args
* Another attempt to fix args
* Fix typo
* Commit up to date code gen
* Another attempt to fix sh/bat
* Move -o param to after -I
* Commit missing code gen file
* Fix grpc code gen and test
* Another grpc code gen fix
* Rework to not use ts folder
* Fix env vars in bat and make less churn
* Move TS code gen to dedicated folder
* Fix transpilation output folder and module paths
* Fixes to code gen
* Include generated js
* Moved ts code gen
* Remove test ts code gen folder
77 files changed, 2908 insertions, 9040 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12f046e5..2fc6cff1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -228,3 +228,14 @@ jobs: - name: test working-directory: tests/FlatBuffers.Test.Swift run: sh SwiftTest.sh + + build-ts: + name: Build TS + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: compile + run: npm run compile + - name: test + working-directory: tests + run: sh TypeScriptTest.sh @@ -70,10 +70,7 @@ tests/monsterdata_go_wire.mon tests/monsterdata_javascript_wire.mon tests/monsterdata_lobster_wire.mon tests/monsterdata_rust_wire.mon -tests/unicode_test.mon -tests/ts/ tests/php/ -tests/js/ CMakeLists.txt.user CMakeScripts/** CTestTestfile.cmake @@ -143,5 +140,4 @@ yarn-error.log **/dist **/vendor **/go.sum -/tests/**/*.js flatbuffers.pc diff --git a/grpc/examples/generate.sh b/grpc/examples/generate.sh index b0740d8a..b0740d8a 100644..100755 --- a/grpc/examples/generate.sh +++ b/grpc/examples/generate.sh diff --git a/grpc/examples/ts/greeter/src/greeter_grpc.d.ts b/grpc/examples/ts/greeter/src/greeter_grpc.d.ts index 402d1ab1..07386bf3 100644 --- a/grpc/examples/ts/greeter/src/greeter_grpc.d.ts +++ b/grpc/examples/ts/greeter/src/greeter_grpc.d.ts @@ -1,5 +1,5 @@ // Generated GRPC code for FlatBuffers TS *** DO NOT EDIT *** -import { flatbuffers } from 'flatbuffers'; +import * as flatbuffers from 'flatbuffers'; import { HelloReply as models_HelloReply } from './models/hello-reply'; import { HelloRequest as models_HelloRequest } from './models/hello-request'; diff --git a/grpc/examples/ts/greeter/src/greeter_grpc.js b/grpc/examples/ts/greeter/src/greeter_grpc.js index aa3af9ae..6148a9bc 100644 --- a/grpc/examples/ts/greeter/src/greeter_grpc.js +++ b/grpc/examples/ts/greeter/src/greeter_grpc.js @@ -1,5 +1,5 @@ // Generated GRPC code for FlatBuffers TS *** DO NOT EDIT *** -import { flatbuffers } from 'flatbuffers'; +import * as flatbuffers from 'flatbuffers'; import { HelloReply as models_HelloReply } from './models/hello-reply'; import { HelloRequest as models_HelloRequest } from './models/hello-request'; diff --git a/grpc/src/compiler/ts_generator.cc b/grpc/src/compiler/ts_generator.cc index 98c3d543..e49fd8d9 100644 --- a/grpc/src/compiler/ts_generator.cc +++ b/grpc/src/compiler/ts_generator.cc @@ -71,7 +71,7 @@ void GenerateImports(const grpc_generator::Service *service, auto vars = *dictonary; printer->Print( "// Generated GRPC code for FlatBuffers TS *** DO NOT EDIT ***\n"); - printer->Print("import { flatbuffers } from 'flatbuffers';\n"); + printer->Print("import * as flatbuffers from 'flatbuffers';\n"); std::set<grpc::string> generated_imports; diff --git a/tests/JavaScriptTest.js b/tests/JavaScriptTest.js index 3e37f599..7a83af24 100644 --- a/tests/JavaScriptTest.js +++ b/tests/JavaScriptTest.js @@ -3,12 +3,12 @@ import assert from 'assert' import fs from 'fs' import * as flatbuffers from 'flatbuffers' -import { Monster, MonsterT } from './ts/my-game/example/monster' -import { Test } from './ts/my-game/example/test' -import { Stat } from './ts/my-game/example/stat' -import { Vec3 } from './ts/my-game/example/vec3' -import { Color } from './ts/my-game/example/color'; -import { Any } from './ts/my-game/example/any'; +import { Monster, MonsterT } from './my-game/example/monster' +import { Test } from './my-game/example/test' +import { Stat } from './my-game/example/stat' +import { Vec3 } from './my-game/example/vec3' +import { Color } from './my-game/example/color'; +import { Any } from './my-game/example/any'; function main() { diff --git a/tests/JavaScriptUnionVectorTest.js b/tests/JavaScriptUnionVectorTest.js index aea6d900..b80e37f1 100644 --- a/tests/JavaScriptUnionVectorTest.js +++ b/tests/JavaScriptUnionVectorTest.js @@ -1,10 +1,10 @@ import assert from 'assert' import * as flatbuffers from 'flatbuffers' -import { Character } from './ts/character' -import { BookReader, BookReaderT } from './ts/book-reader' -import { Attacker, AttackerT } from './ts/attacker' -import { Movie, MovieT } from './ts/movie' +import { Character } from './union_vector/character' +import { BookReader, BookReaderT } from './union_vector/book-reader' +import { Attacker, AttackerT } from './union_vector/attacker' +import { Movie, MovieT } from './union_vector/movie' var charTypes = [ Character.Belle, diff --git a/tests/TypeScriptTest.bat b/tests/TypeScriptTest.bat index 87c4b58f..d11804ba 100755 --- a/tests/TypeScriptTest.bat +++ b/tests/TypeScriptTest.bat @@ -1,7 +1,7 @@ npm install -../flatc.exe --ts --gen-name-strings --gen-mutable --gen-object-api -o ts -I include_test monster_test.fbs +../flatc.exe --ts --gen-name-strings --gen-mutable --gen-object-api -I include_test monster_test.fbs ../flatc.exe --gen-object-api -b -I include_test monster_test.fbs unicode_test.json -../flatc.exe --ts --gen-name-strings --gen-object-api -o ts union_vector/union_vector.fbs +../flatc.exe --ts --gen-name-strings --gen-mutable --gen-object-api -o union_vector union_vector/union_vector.fbs tsc node -r esm JavaScriptTest node -r esm JavaScriptUnionVectorTest diff --git a/tests/TypeScriptTest.sh b/tests/TypeScriptTest.sh index f9ce3edc..613b259b 100755 --- a/tests/TypeScriptTest.sh +++ b/tests/TypeScriptTest.sh @@ -14,15 +14,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -pushd "$(dirname $0)" >/dev/null +set -e # clean node_modules to make sure we depend on latest local flatbuffers at ../ rm -rf node_modules npm install -../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -o ts -I include_test monster_test.fbs -../flatc --gen-object-api -b -I include_test monster_test.fbs unicode_test.json -../flatc --ts --gen-name-strings --gen-object-api -o ts union_vector/union_vector.fbs +if [ -x ../flatc ]; then + ../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -I include_test monster_test.fbs + ../flatc --gen-object-api -b -I include_test monster_test.fbs unicode_test.json + ../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -o union_vector union_vector/union_vector.fbs +fi tsc node -r esm JavaScriptTest node -r esm JavaScriptUnionVectorTest diff --git a/tests/generate_code.bat b/tests/generate_code.bat index 71d1dba0..390efa9c 100644 --- a/tests/generate_code.bat +++ b/tests/generate_code.bat @@ -29,7 +29,7 @@ if NOT "%commandline%"=="%commandline:--cpp-std c++0x=%" ( set TEST_CPP_FLAGS=--gen-compare --cpp-ptr-type flatbuffers::unique_ptr %TEST_CPP_FLAGS% set TEST_CS_FLAGS=--cs-gen-json-serializer -set TEST_JS_TS_FLAGS=--gen-name-strings +set TEST_TS_FLAGS=--gen-name-strings set TEST_BASE_FLAGS=--reflect-names --gen-mutable --gen-object-api set TEST_RUST_FLAGS=%TEST_BASE_FLAGS% --gen-name-strings set TEST_NOINCL_FLAGS=%TEST_BASE_FLAGS% --no-includes @@ -41,13 +41,16 @@ set TEST_NOINCL_FLAGS=%TEST_BASE_FLAGS% --no-includes ..\%buildtype%\flatc.exe --python %TEST_BASE_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL ..\%buildtype%\flatc.exe --binary --cpp --java --csharp --dart --go --lobster --lua --ts --php --python ^ -%TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_JS_TS_FLAGS% -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL +%TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_TS_FLAGS% -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL @rem For Rust we currently generate two independent schemas, with namespace_test2 @rem duplicating the types in namespace_test1 ..\%buildtype%\flatc.exe --rust --gen-all %TEST_RUST_FLAGS% -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL -..\%buildtype%\flatc.exe --cpp --java --csharp --ts --php %TEST_BASE_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_JS_TS_FLAGS% -o union_vector ./union_vector/union_vector.fbs || goto FAIL +..\%buildtype%\flatc.exe --cpp --java --csharp --ts --php %TEST_BASE_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_TS_FLAGS% -o union_vector ./union_vector/union_vector.fbs || goto FAIL +..\%buildtype%\flatc.exe --ts --gen-name-strings --gen-mutable %TEST_BASE_FLAGS% %TEST_TS_FLAGS% -I include_test monster_test.fbs +..\%buildtype%\flatc.exe %TEST_BASE_FLAGS% %TEST_TS_FLAGS% -b -I include_test monster_test.fbs unicode_test.json +..\%buildtype%\flatc.exe --ts --gen-name-strings %TEST_BASE_FLAGS% %TEST_TS_FLAGS% -o union_vector union_vector/union_vector.fbs ..\%buildtype%\flatc.exe --rust -I include_test -o include_test include_test/include_test1.fbs || goto FAIL ..\%buildtype%\flatc.exe --rust -I include_test -o include_test/sub include_test/sub/include_test2.fbs || goto FAIL ..\%buildtype%\flatc.exe -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs || goto FAIL diff --git a/tests/generate_code.sh b/tests/generate_code.sh index 4f6b4374..d3a2dabc 100755 --- a/tests/generate_code.sh +++ b/tests/generate_code.sh @@ -26,7 +26,7 @@ fi TEST_CPP_FLAGS="--gen-compare --cpp-ptr-type flatbuffers::unique_ptr $TEST_CPP_FLAGS" TEST_CS_FLAGS="--cs-gen-json-serializer" -TEST_JS_TS_FLAGS="--gen-name-strings" +TEST_TS_FLAGS="--gen-name-strings" TEST_BASE_FLAGS="--reflect-names --gen-mutable --gen-object-api" TEST_RUST_FLAGS="$TEST_BASE_FLAGS --gen-name-strings" TEST_NOINCL_FLAGS="$TEST_BASE_FLAGS --no-includes" @@ -38,13 +38,16 @@ $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS -I include_test monster_test.f ../flatc --python $TEST_BASE_FLAGS -I include_test monster_test.fbs monsterdata_test.json ../flatc --cpp --java --kotlin --csharp --dart --go --binary --lobster --lua --ts --php --python \ -$TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_JS_TS_FLAGS -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs +$TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_TS_FLAGS -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs # For Rust we currently generate two independent schemas, with namespace_test2 # duplicating the types in namespace_test1 ../flatc --rust --gen-all $TEST_RUST_FLAGS -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs -../flatc --cpp --java --kotlin --csharp --ts --php $TEST_BASE_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_JS_TS_FLAGS -o union_vector ./union_vector/union_vector.fbs +../flatc --cpp --java --kotlin --csharp --ts --php $TEST_BASE_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_TS_FLAGS -o union_vector ./union_vector/union_vector.fbs +../flatc --ts --gen-name-strings --gen-mutable $TEST_BASE_FLAGS $TEST_TS_FLAGS -I include_test monster_test.fbs +../flatc $TEST_BASE_FLAGS $TEST_TS_FLAGS -b -I include_test monster_test.fbs unicode_test.json +../flatc --ts --gen-name-strings $TEST_BASE_FLAGS $TEST_TS_FLAGS -o union_vector union_vector/union_vector.fbs ../flatc --rust -I include_test -o include_test include_test/include_test1.fbs ../flatc --rust -I include_test -o include_test/sub include_test/sub/include_test2.fbs ../flatc -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs diff --git a/tests/monster_test_generated.js b/tests/monster_test_generated.js deleted file mode 100644 index fc200b44..00000000 --- a/tests/monster_test_generated.js +++ /dev/null @@ -1,3277 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @const - * @namespace - */ -var MyGame = MyGame || {}; - -/** - * @const - * @namespace - */ -MyGame.Example = MyGame.Example || {}; - -/** - * @const - * @namespace - */ -MyGame.Example2 = MyGame.Example2 || {}; - -/** - * @const - * @namespace - */ -MyGame.OtherNameSpace = MyGame.OtherNameSpace || {}; - -/** - * Composite components of Monster color. - * - * @enum {number} - */ -MyGame.Example.Color = { - Red: 1, - - /** - * \brief color Green - * Green is bit_flag with value (1u << 1) - */ - Green: 2, - - /** - * \brief color Blue (1u << 3) - */ - Blue: 8 -}; - -/** - * Composite components of Monster color. - * - * @enum {string} - */ -MyGame.Example.ColorName = { - '1': 'Red', - - /** - * \brief color Green - * Green is bit_flag with value (1u << 1) - */ - '2': 'Green', - - /** - * \brief color Blue (1u << 3) - */ - '8': 'Blue' -}; - -/** - * @enum {number} - */ -MyGame.Example.Race = { - None: -1, - Human: 0, - Dwarf: 1, - Elf: 2 -}; - -/** - * @enum {string} - */ -MyGame.Example.RaceName = { - '-1': 'None', - '0': 'Human', - '1': 'Dwarf', - '2': 'Elf' -}; - -/** - * @enum {number} - */ -MyGame.Example.Any = { - NONE: 0, - Monster: 1, - TestSimpleTableWithEnum: 2, - MyGame_Example2_Monster: 3 -}; - -/** - * @enum {string} - */ -MyGame.Example.AnyName = { - '0': 'NONE', - '1': 'Monster', - '2': 'TestSimpleTableWithEnum', - '3': 'MyGame_Example2_Monster' -}; - -/** - * @enum {number} - */ -MyGame.Example.AnyUniqueAliases = { - NONE: 0, - M: 1, - TS: 2, - M2: 3 -}; - -/** - * @enum {string} - */ -MyGame.Example.AnyUniqueAliasesName = { - '0': 'NONE', - '1': 'M', - '2': 'TS', - '3': 'M2' -}; - -/** - * @enum {number} - */ -MyGame.Example.AnyAmbiguousAliases = { - NONE: 0, - M1: 1, - M2: 2, - M3: 3 -}; - -/** - * @enum {string} - */ -MyGame.Example.AnyAmbiguousAliasesName = { - '0': 'NONE', - '1': 'M1', - '2': 'M2', - '3': 'M3' -}; - -/** - * @constructor - */ -MyGame.InParentNamespace = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.InParentNamespace} - */ -MyGame.InParentNamespace.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.InParentNamespace=} obj - * @returns {MyGame.InParentNamespace} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame.InParentNamespace).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.InParentNamespace.startInParentNamespace = function(builder) { - builder.startObject(0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.InParentNamespace.endInParentNamespace = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.InParentNamespace.createInParentNamespace = function(builder) { - MyGame.InParentNamespace.startInParentNamespace(builder); - return MyGame.InParentNamespace.endInParentNamespace(builder); -} - -/** - * @constructor - */ -MyGame.Example2.Monster = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example2.Monster} - */ -MyGame.Example2.Monster.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.Example2.Monster=} obj - * @returns {MyGame.Example2.Monster} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame.Example2.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.Example2.Monster.startMonster = function(builder) { - builder.startObject(0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example2.Monster.endMonster = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example2.Monster.createMonster = function(builder) { - MyGame.Example2.Monster.startMonster(builder); - return MyGame.Example2.Monster.endMonster(builder); -} - -/** - * @constructor - */ -MyGame.Example.Test = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Test} - */ -MyGame.Example.Test.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -MyGame.Example.Test.prototype.a = function() { - return this.bb.readInt16(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Test.prototype.mutate_a = function(value) { - this.bb.writeInt16(this.bb_pos + 0, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Test.prototype.b = function() { - return this.bb.readInt8(this.bb_pos + 2); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Test.prototype.mutate_b = function(value) { - this.bb.writeInt8(this.bb_pos + 2, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Test.sizeOf = function() { - return 4; -} - -/** - * @param {flatbuffers.Builder} builder - * @param {number} a - * @param {number} b - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Test.createTest = function(builder, a, b) { - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(b); - builder.writeInt16(a); - return builder.offset(); -}; - -/** - * @constructor - */ -MyGame.Example.TestSimpleTableWithEnum = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.TestSimpleTableWithEnum} - */ -MyGame.Example.TestSimpleTableWithEnum.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.Example.TestSimpleTableWithEnum=} obj - * @returns {MyGame.Example.TestSimpleTableWithEnum} - */ -MyGame.Example.TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum = function(bb, obj) { - 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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame.Example.TestSimpleTableWithEnum).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns {MyGame.Example.Color} - */ -MyGame.Example.TestSimpleTableWithEnum.prototype.color = function() { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Example.Color.Green; -}; - -/** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ -MyGame.Example.TestSimpleTableWithEnum.prototype.mutate_color = function(value) { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeUint8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.Example.TestSimpleTableWithEnum.startTestSimpleTableWithEnum = function(builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Color} color - */ -MyGame.Example.TestSimpleTableWithEnum.addColor = function(builder, color) { - builder.addFieldInt8(0, color, MyGame.Example.Color.Green); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example.TestSimpleTableWithEnum.endTestSimpleTableWithEnum = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Color} color - * @returns {flatbuffers.Offset} - */ -MyGame.Example.TestSimpleTableWithEnum.createTestSimpleTableWithEnum = function(builder, color) { - MyGame.Example.TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder); - MyGame.Example.TestSimpleTableWithEnum.addColor(builder, color); - return MyGame.Example.TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder); -} - -/** - * @constructor - */ -MyGame.Example.Vec3 = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Vec3} - */ -MyGame.Example.Vec3.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -MyGame.Example.Vec3.prototype.x = function() { - return this.bb.readFloat32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Vec3.prototype.mutate_x = function(value) { - this.bb.writeFloat32(this.bb_pos + 0, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Vec3.prototype.y = function() { - return this.bb.readFloat32(this.bb_pos + 4); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Vec3.prototype.mutate_y = function(value) { - this.bb.writeFloat32(this.bb_pos + 4, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Vec3.prototype.z = function() { - return this.bb.readFloat32(this.bb_pos + 8); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Vec3.prototype.mutate_z = function(value) { - this.bb.writeFloat32(this.bb_pos + 8, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Vec3.prototype.test1 = function() { - return this.bb.readFloat64(this.bb_pos + 16); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Vec3.prototype.mutate_test1 = function(value) { - this.bb.writeFloat64(this.bb_pos + 16, value); - return true; -}; - -/** - * @returns {MyGame.Example.Color} - */ -MyGame.Example.Vec3.prototype.test2 = function() { - return /** @type {MyGame.Example.Color} */ (this.bb.readUint8(this.bb_pos + 24)); -}; - -/** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ -MyGame.Example.Vec3.prototype.mutate_test2 = function(value) { - this.bb.writeUint8(this.bb_pos + 24, value); - return true; -}; - -/** - * @param {MyGame.Example.Test=} obj - * @returns {MyGame.Example.Test|null} - */ -MyGame.Example.Vec3.prototype.test3 = function(obj) { - return (obj || new MyGame.Example.Test).__init(this.bb_pos + 26, this.bb); -}; - -/** - * @returns {number} - */ -MyGame.Example.Vec3.sizeOf = function() { - return 32; -} - -/** - * @param {flatbuffers.Builder} builder - * @param {number} x - * @param {number} y - * @param {number} z - * @param {number} test1 - * @param {MyGame.Example.Color} test2 - * @param {number} test3_a - * @param {number} test3_b - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Vec3.createVec3 = function(builder, x, y, z, test1, test2, test3_a, test3_b) { - builder.prep(8, 32); - builder.pad(2); - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(test3_b); - builder.writeInt16(test3_a); - builder.pad(1); - builder.writeInt8(test2); - builder.writeFloat64(test1); - builder.pad(4); - builder.writeFloat32(z); - builder.writeFloat32(y); - builder.writeFloat32(x); - return builder.offset(); -}; - -/** - * @constructor - */ -MyGame.Example.Ability = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Ability} - */ -MyGame.Example.Ability.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -MyGame.Example.Ability.prototype.id = function() { - return this.bb.readUint32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Ability.prototype.mutate_id = function(value) { - this.bb.writeUint32(this.bb_pos + 0, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Ability.prototype.distance = function() { - return this.bb.readUint32(this.bb_pos + 4); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Ability.prototype.mutate_distance = function(value) { - this.bb.writeUint32(this.bb_pos + 4, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Ability.sizeOf = function() { - return 8; -} - -/** - * @param {flatbuffers.Builder} builder - * @param {number} id - * @param {number} distance - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Ability.createAbility = function(builder, id, distance) { - builder.prep(4, 8); - builder.writeInt32(distance); - builder.writeInt32(id); - return builder.offset(); -}; - -/** - * @constructor - */ -MyGame.Example.Stat = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Stat} - */ -MyGame.Example.Stat.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.Example.Stat=} obj - * @returns {MyGame.Example.Stat} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame.Example.Stat).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array|null} - */ -MyGame.Example.Stat.prototype.id = function(optionalEncoding) { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Stat.prototype.val = function() { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Stat.prototype.mutate_val = function(value) { - var offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Stat.prototype.count = function() { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Stat.prototype.mutate_count = function(value) { - var offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeUint16(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.Example.Stat.startStat = function(builder) { - builder.startObject(3); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} idOffset - */ -MyGame.Example.Stat.addId = function(builder, idOffset) { - builder.addFieldOffset(0, idOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} val - */ -MyGame.Example.Stat.addVal = function(builder, val) { - builder.addFieldInt64(1, val, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} count - */ -MyGame.Example.Stat.addCount = function(builder, count) { - builder.addFieldInt16(2, count, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Stat.endStat = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} idOffset - * @param {flatbuffers.Long} val - * @param {number} count - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Stat.createStat = function(builder, idOffset, val, count) { - MyGame.Example.Stat.startStat(builder); - MyGame.Example.Stat.addId(builder, idOffset); - MyGame.Example.Stat.addVal(builder, val); - MyGame.Example.Stat.addCount(builder, count); - return MyGame.Example.Stat.endStat(builder); -} - -/** - * @constructor - */ -MyGame.Example.Referrable = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Referrable} - */ -MyGame.Example.Referrable.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.Example.Referrable=} obj - * @returns {MyGame.Example.Referrable} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame.Example.Referrable).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Referrable.prototype.id = function() { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Referrable.prototype.mutate_id = function(value) { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.Example.Referrable.startReferrable = function(builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} id - */ -MyGame.Example.Referrable.addId = function(builder, id) { - builder.addFieldInt64(0, id, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Referrable.endReferrable = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} id - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Referrable.createReferrable = function(builder, id) { - MyGame.Example.Referrable.startReferrable(builder); - MyGame.Example.Referrable.addId(builder, id); - return MyGame.Example.Referrable.endReferrable(builder); -} - -/** - * an example documentation comment: "monster object" - * - * @constructor - */ -MyGame.Example.Monster = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.Monster} - */ -MyGame.Example.Monster.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.Example.Monster=} obj - * @returns {MyGame.Example.Monster} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame.Example.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @returns {boolean} - */ -MyGame.Example.Monster.bufferHasIdentifier = function(bb) { - return bb.__has_identifier('MONS'); -}; - -/** - * @param {MyGame.Example.Vec3=} obj - * @returns {MyGame.Example.Vec3|null} - */ -MyGame.Example.Monster.prototype.pos = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new MyGame.Example.Vec3).__init(this.bb_pos + offset, this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.mana = function() { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 150; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_mana = function(value) { - var offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.hp = function() { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 100; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_hp = function(value) { - var offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array|null} - */ -MyGame.Example.Monster.prototype.name = function(optionalEncoding) { - var offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; -}; - -/** - * @param {number} index - * @returns {number} - */ -MyGame.Example.Monster.prototype.inventory = function(index) { - var offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.inventoryLength = function() { - var offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Uint8Array} - */ -MyGame.Example.Monster.prototype.inventoryArray = function() { - var offset = this.bb.__offset(this.bb_pos, 14); - 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; -}; - -/** - * @returns {MyGame.Example.Color} - */ -MyGame.Example.Monster.prototype.color = function() { - var offset = this.bb.__offset(this.bb_pos, 16); - return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Example.Color.Blue; -}; - -/** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_color = function(value) { - var offset = this.bb.__offset(this.bb_pos, 16); - - if (offset === 0) { - return false; - } - - this.bb.writeUint8(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {MyGame.Example.Any} - */ -MyGame.Example.Monster.prototype.testType = function() { - var offset = this.bb.__offset(this.bb_pos, 18); - return offset ? /** @type {MyGame.Example.Any} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Example.Any.NONE; -}; - -/** - * @param {flatbuffers.Table} obj - * @returns {?flatbuffers.Table} - */ -MyGame.Example.Monster.prototype.test = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 20); - return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; -}; - -/** - * @param {number} index - * @param {MyGame.Example.Test=} obj - * @returns {MyGame.Example.Test} - */ -MyGame.Example.Monster.prototype.test4 = function(index, obj) { - var offset = this.bb.__offset(this.bb_pos, 22); - return offset ? (obj || new MyGame.Example.Test).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.test4Length = function() { - var offset = this.bb.__offset(this.bb_pos, 22); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} index - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ -MyGame.Example.Monster.prototype.testarrayofstring = function(index, optionalEncoding) { - var offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testarrayofstringLength = function() { - var offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * an example documentation comment: this will end up in the generated code - * multiline too - * - * @param {number} index - * @param {MyGame.Example.Monster=} obj - * @returns {MyGame.Example.Monster} - */ -MyGame.Example.Monster.prototype.testarrayoftables = function(index, obj) { - var offset = this.bb.__offset(this.bb_pos, 26); - return offset ? (obj || new MyGame.Example.Monster).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testarrayoftablesLength = function() { - var offset = this.bb.__offset(this.bb_pos, 26); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {MyGame.Example.Monster=} obj - * @returns {MyGame.Example.Monster|null} - */ -MyGame.Example.Monster.prototype.enemy = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 28); - return offset ? (obj || new MyGame.Example.Monster).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @param {number} index - * @returns {number} - */ -MyGame.Example.Monster.prototype.testnestedflatbuffer = function(index) { - var offset = this.bb.__offset(this.bb_pos, 30); - return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testnestedflatbufferLength = function() { - var offset = this.bb.__offset(this.bb_pos, 30); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Uint8Array} - */ -MyGame.Example.Monster.prototype.testnestedflatbufferArray = function() { - var offset = this.bb.__offset(this.bb_pos, 30); - 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; -}; - -/** - * @param {MyGame.Example.Stat=} obj - * @returns {MyGame.Example.Stat|null} - */ -MyGame.Example.Monster.prototype.testempty = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 32); - return offset ? (obj || new MyGame.Example.Stat).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.testbool = function() { - var offset = this.bb.__offset(this.bb_pos, 34); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; -}; - -/** - * @param {boolean} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testbool = function(value) { - var offset = this.bb.__offset(this.bb_pos, 34); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testhashs32Fnv1 = function() { - var offset = this.bb.__offset(this.bb_pos, 36); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashs32_fnv1 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 36); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testhashu32Fnv1 = function() { - var offset = this.bb.__offset(this.bb_pos, 38); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashu32_fnv1 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 38); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.testhashs64Fnv1 = function() { - var offset = this.bb.__offset(this.bb_pos, 40); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashs64_fnv1 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 40); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.testhashu64Fnv1 = function() { - var offset = this.bb.__offset(this.bb_pos, 42); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashu64_fnv1 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 42); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testhashs32Fnv1a = function() { - var offset = this.bb.__offset(this.bb_pos, 44); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashs32_fnv1a = function(value) { - var offset = this.bb.__offset(this.bb_pos, 44); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testhashu32Fnv1a = function() { - var offset = this.bb.__offset(this.bb_pos, 46); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashu32_fnv1a = function(value) { - var offset = this.bb.__offset(this.bb_pos, 46); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.testhashs64Fnv1a = function() { - var offset = this.bb.__offset(this.bb_pos, 48); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashs64_fnv1a = function(value) { - var offset = this.bb.__offset(this.bb_pos, 48); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.testhashu64Fnv1a = function() { - var offset = this.bb.__offset(this.bb_pos, 50); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testhashu64_fnv1a = function(value) { - var offset = this.bb.__offset(this.bb_pos, 50); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.testarrayofbools = function(index) { - var offset = this.bb.__offset(this.bb_pos, 52); - return offset ? !!this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : false; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testarrayofboolsLength = function() { - var offset = this.bb.__offset(this.bb_pos, 52); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Int8Array} - */ -MyGame.Example.Monster.prototype.testarrayofboolsArray = function() { - var offset = this.bb.__offset(this.bb_pos, 52); - return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testf = function() { - var offset = this.bb.__offset(this.bb_pos, 54); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.14159; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testf = function(value) { - var offset = this.bb.__offset(this.bb_pos, 54); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testf2 = function() { - var offset = this.bb.__offset(this.bb_pos, 56); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testf2 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 56); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testf3 = function() { - var offset = this.bb.__offset(this.bb_pos, 58); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_testf3 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 58); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ -MyGame.Example.Monster.prototype.testarrayofstring2 = function(index, optionalEncoding) { - var offset = this.bb.__offset(this.bb_pos, 60); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testarrayofstring2Length = function() { - var offset = this.bb.__offset(this.bb_pos, 60); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} index - * @param {MyGame.Example.Ability=} obj - * @returns {MyGame.Example.Ability} - */ -MyGame.Example.Monster.prototype.testarrayofsortedstruct = function(index, obj) { - var offset = this.bb.__offset(this.bb_pos, 62); - return offset ? (obj || new MyGame.Example.Ability).__init(this.bb.__vector(this.bb_pos + offset) + index * 8, this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testarrayofsortedstructLength = function() { - var offset = this.bb.__offset(this.bb_pos, 62); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} index - * @returns {number} - */ -MyGame.Example.Monster.prototype.flex = function(index) { - var offset = this.bb.__offset(this.bb_pos, 64); - return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.flexLength = function() { - var offset = this.bb.__offset(this.bb_pos, 64); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Uint8Array} - */ -MyGame.Example.Monster.prototype.flexArray = function() { - var offset = this.bb.__offset(this.bb_pos, 64); - 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; -}; - -/** - * @param {number} index - * @param {MyGame.Example.Test=} obj - * @returns {MyGame.Example.Test} - */ -MyGame.Example.Monster.prototype.test5 = function(index, obj) { - var offset = this.bb.__offset(this.bb_pos, 66); - return offset ? (obj || new MyGame.Example.Test).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.test5Length = function() { - var offset = this.bb.__offset(this.bb_pos, 66); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} index - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.vectorOfLongs = function(index) { - var offset = this.bb.__offset(this.bb_pos, 68); - return offset ? this.bb.readInt64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.vectorOfLongsLength = function() { - var offset = this.bb.__offset(this.bb_pos, 68); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} index - * @returns {number} - */ -MyGame.Example.Monster.prototype.vectorOfDoubles = function(index) { - var offset = this.bb.__offset(this.bb_pos, 70); - return offset ? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8) : 0; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.vectorOfDoublesLength = function() { - var offset = this.bb.__offset(this.bb_pos, 70); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Float64Array} - */ -MyGame.Example.Monster.prototype.vectorOfDoublesArray = function() { - var offset = this.bb.__offset(this.bb_pos, 70); - return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @param {MyGame.InParentNamespace=} obj - * @returns {MyGame.InParentNamespace|null} - */ -MyGame.Example.Monster.prototype.parentNamespaceTest = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 72); - return offset ? (obj || new MyGame.InParentNamespace).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @param {number} index - * @param {MyGame.Example.Referrable=} obj - * @returns {MyGame.Example.Referrable} - */ -MyGame.Example.Monster.prototype.vectorOfReferrables = function(index, obj) { - var offset = this.bb.__offset(this.bb_pos, 74); - return offset ? (obj || new MyGame.Example.Referrable).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.vectorOfReferrablesLength = function() { - var offset = this.bb.__offset(this.bb_pos, 74); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.singleWeakReference = function() { - var offset = this.bb.__offset(this.bb_pos, 76); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_single_weak_reference = function(value) { - var offset = this.bb.__offset(this.bb_pos, 76); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.vectorOfWeakReferences = function(index) { - var offset = this.bb.__offset(this.bb_pos, 78); - return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.vectorOfWeakReferencesLength = function() { - var offset = this.bb.__offset(this.bb_pos, 78); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} index - * @param {MyGame.Example.Referrable=} obj - * @returns {MyGame.Example.Referrable} - */ -MyGame.Example.Monster.prototype.vectorOfStrongReferrables = function(index, obj) { - var offset = this.bb.__offset(this.bb_pos, 80); - return offset ? (obj || new MyGame.Example.Referrable).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.vectorOfStrongReferrablesLength = function() { - var offset = this.bb.__offset(this.bb_pos, 80); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.coOwningReference = function() { - var offset = this.bb.__offset(this.bb_pos, 82); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_co_owning_reference = function(value) { - var offset = this.bb.__offset(this.bb_pos, 82); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.vectorOfCoOwningReferences = function(index) { - var offset = this.bb.__offset(this.bb_pos, 84); - return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.vectorOfCoOwningReferencesLength = function() { - var offset = this.bb.__offset(this.bb_pos, 84); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.nonOwningReference = function() { - var offset = this.bb.__offset(this.bb_pos, 86); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_non_owning_reference = function(value) { - var offset = this.bb.__offset(this.bb_pos, 86); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @returns {flatbuffers.Long} - */ -MyGame.Example.Monster.prototype.vectorOfNonOwningReferences = function(index) { - var offset = this.bb.__offset(this.bb_pos, 88); - return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.vectorOfNonOwningReferencesLength = function() { - var offset = this.bb.__offset(this.bb_pos, 88); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {MyGame.Example.AnyUniqueAliases} - */ -MyGame.Example.Monster.prototype.anyUniqueType = function() { - var offset = this.bb.__offset(this.bb_pos, 90); - return offset ? /** @type {MyGame.Example.AnyUniqueAliases} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Example.AnyUniqueAliases.NONE; -}; - -/** - * @param {flatbuffers.Table} obj - * @returns {?flatbuffers.Table} - */ -MyGame.Example.Monster.prototype.anyUnique = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 92); - return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; -}; - -/** - * @returns {MyGame.Example.AnyAmbiguousAliases} - */ -MyGame.Example.Monster.prototype.anyAmbiguousType = function() { - var offset = this.bb.__offset(this.bb_pos, 94); - return offset ? /** @type {MyGame.Example.AnyAmbiguousAliases} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Example.AnyAmbiguousAliases.NONE; -}; - -/** - * @param {flatbuffers.Table} obj - * @returns {?flatbuffers.Table} - */ -MyGame.Example.Monster.prototype.anyAmbiguous = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 96); - return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; -}; - -/** - * @param {number} index - * @returns {MyGame.Example.Color} - */ -MyGame.Example.Monster.prototype.vectorOfEnums = function(index) { - var offset = this.bb.__offset(this.bb_pos, 98); - return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index)) : /** @type {MyGame.Example.Color} */ (0); -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.vectorOfEnumsLength = function() { - var offset = this.bb.__offset(this.bb_pos, 98); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Uint8Array} - */ -MyGame.Example.Monster.prototype.vectorOfEnumsArray = function() { - var offset = this.bb.__offset(this.bb_pos, 98); - 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; -}; - -/** - * @returns {MyGame.Example.Race} - */ -MyGame.Example.Monster.prototype.signedEnum = function() { - var offset = this.bb.__offset(this.bb_pos, 100); - return offset ? /** @type {MyGame.Example.Race} */ (this.bb.readInt8(this.bb_pos + offset)) : MyGame.Example.Race.None; -}; - -/** - * @param {MyGame.Example.Race} value - * @returns {boolean} - */ -MyGame.Example.Monster.prototype.mutate_signed_enum = function(value) { - var offset = this.bb.__offset(this.bb_pos, 100); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @returns {number} - */ -MyGame.Example.Monster.prototype.testrequirednestedflatbuffer = function(index) { - var offset = this.bb.__offset(this.bb_pos, 102); - return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.testrequirednestedflatbufferLength = function() { - var offset = this.bb.__offset(this.bb_pos, 102); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Uint8Array} - */ -MyGame.Example.Monster.prototype.testrequirednestedflatbufferArray = function() { - var offset = this.bb.__offset(this.bb_pos, 102); - 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; -}; - -/** - * @param {number} index - * @param {MyGame.Example.Stat=} obj - * @returns {MyGame.Example.Stat} - */ -MyGame.Example.Monster.prototype.scalarKeySortedTables = function(index, obj) { - var offset = this.bb.__offset(this.bb_pos, 104); - return offset ? (obj || new MyGame.Example.Stat).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; -}; - -/** - * @returns {number} - */ -MyGame.Example.Monster.prototype.scalarKeySortedTablesLength = function() { - var offset = this.bb.__offset(this.bb_pos, 104); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.Example.Monster.startMonster = function(builder) { - builder.startObject(51); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} posOffset - */ -MyGame.Example.Monster.addPos = function(builder, posOffset) { - builder.addFieldStruct(0, posOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} mana - */ -MyGame.Example.Monster.addMana = function(builder, mana) { - builder.addFieldInt16(1, mana, 150); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} hp - */ -MyGame.Example.Monster.addHp = function(builder, hp) { - builder.addFieldInt16(2, hp, 100); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} nameOffset - */ -MyGame.Example.Monster.addName = function(builder, nameOffset) { - builder.addFieldOffset(3, nameOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} inventoryOffset - */ -MyGame.Example.Monster.addInventory = function(builder, inventoryOffset) { - builder.addFieldOffset(5, inventoryOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createInventoryVector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startInventoryVector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Color} color - */ -MyGame.Example.Monster.addColor = function(builder, color) { - builder.addFieldInt8(6, color, MyGame.Example.Color.Blue); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Any} testType - */ -MyGame.Example.Monster.addTestType = function(builder, testType) { - builder.addFieldInt8(7, testType, MyGame.Example.Any.NONE); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testOffset - */ -MyGame.Example.Monster.addTest = function(builder, testOffset) { - builder.addFieldOffset(8, testOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} test4Offset - */ -MyGame.Example.Monster.addTest4 = function(builder, test4Offset) { - builder.addFieldOffset(9, test4Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTest4Vector = function(builder, numElems) { - builder.startVector(4, numElems, 2); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofstringOffset - */ -MyGame.Example.Monster.addTestarrayofstring = function(builder, testarrayofstringOffset) { - builder.addFieldOffset(10, testarrayofstringOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestarrayofstringVector = function(builder, data) { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestarrayofstringVector = function(builder, numElems) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayoftablesOffset - */ -MyGame.Example.Monster.addTestarrayoftables = function(builder, testarrayoftablesOffset) { - builder.addFieldOffset(11, testarrayoftablesOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestarrayoftablesVector = function(builder, data) { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestarrayoftablesVector = function(builder, numElems) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} enemyOffset - */ -MyGame.Example.Monster.addEnemy = function(builder, enemyOffset) { - builder.addFieldOffset(12, enemyOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testnestedflatbufferOffset - */ -MyGame.Example.Monster.addTestnestedflatbuffer = function(builder, testnestedflatbufferOffset) { - builder.addFieldOffset(13, testnestedflatbufferOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestnestedflatbufferVector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestnestedflatbufferVector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testemptyOffset - */ -MyGame.Example.Monster.addTestempty = function(builder, testemptyOffset) { - builder.addFieldOffset(14, testemptyOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {boolean} testbool - */ -MyGame.Example.Monster.addTestbool = function(builder, testbool) { - builder.addFieldInt8(15, +testbool, +false); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashs32Fnv1 - */ -MyGame.Example.Monster.addTesthashs32Fnv1 = function(builder, testhashs32Fnv1) { - builder.addFieldInt32(16, testhashs32Fnv1, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashu32Fnv1 - */ -MyGame.Example.Monster.addTesthashu32Fnv1 = function(builder, testhashu32Fnv1) { - builder.addFieldInt32(17, testhashu32Fnv1, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashs64Fnv1 - */ -MyGame.Example.Monster.addTesthashs64Fnv1 = function(builder, testhashs64Fnv1) { - builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashu64Fnv1 - */ -MyGame.Example.Monster.addTesthashu64Fnv1 = function(builder, testhashu64Fnv1) { - builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashs32Fnv1a - */ -MyGame.Example.Monster.addTesthashs32Fnv1a = function(builder, testhashs32Fnv1a) { - builder.addFieldInt32(20, testhashs32Fnv1a, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testhashu32Fnv1a - */ -MyGame.Example.Monster.addTesthashu32Fnv1a = function(builder, testhashu32Fnv1a) { - builder.addFieldInt32(21, testhashu32Fnv1a, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashs64Fnv1a - */ -MyGame.Example.Monster.addTesthashs64Fnv1a = function(builder, testhashs64Fnv1a) { - builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashu64Fnv1a - */ -MyGame.Example.Monster.addTesthashu64Fnv1a = function(builder, testhashu64Fnv1a) { - builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofboolsOffset - */ -MyGame.Example.Monster.addTestarrayofbools = function(builder, testarrayofboolsOffset) { - builder.addFieldOffset(24, testarrayofboolsOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<boolean>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestarrayofboolsVector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(+data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestarrayofboolsVector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testf - */ -MyGame.Example.Monster.addTestf = function(builder, testf) { - builder.addFieldFloat32(25, testf, 3.14159); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testf2 - */ -MyGame.Example.Monster.addTestf2 = function(builder, testf2) { - builder.addFieldFloat32(26, testf2, 3.0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} testf3 - */ -MyGame.Example.Monster.addTestf3 = function(builder, testf3) { - builder.addFieldFloat32(27, testf3, 0.0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofstring2Offset - */ -MyGame.Example.Monster.addTestarrayofstring2 = function(builder, testarrayofstring2Offset) { - builder.addFieldOffset(28, testarrayofstring2Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestarrayofstring2Vector = function(builder, data) { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestarrayofstring2Vector = function(builder, numElems) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofsortedstructOffset - */ -MyGame.Example.Monster.addTestarrayofsortedstruct = function(builder, testarrayofsortedstructOffset) { - builder.addFieldOffset(29, testarrayofsortedstructOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestarrayofsortedstructVector = function(builder, numElems) { - builder.startVector(8, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} flexOffset - */ -MyGame.Example.Monster.addFlex = function(builder, flexOffset) { - builder.addFieldOffset(30, flexOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createFlexVector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startFlexVector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} test5Offset - */ -MyGame.Example.Monster.addTest5 = function(builder, test5Offset) { - builder.addFieldOffset(31, test5Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTest5Vector = function(builder, numElems) { - builder.startVector(4, numElems, 2); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} vectorOfLongsOffset - */ -MyGame.Example.Monster.addVectorOfLongs = function(builder, vectorOfLongsOffset) { - builder.addFieldOffset(32, vectorOfLongsOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Long>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createVectorOfLongsVector = function(builder, data) { - builder.startVector(8, data.length, 8); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt64(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startVectorOfLongsVector = function(builder, numElems) { - builder.startVector(8, numElems, 8); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} vectorOfDoublesOffset - */ -MyGame.Example.Monster.addVectorOfDoubles = function(builder, vectorOfDoublesOffset) { - builder.addFieldOffset(33, vectorOfDoublesOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createVectorOfDoublesVector = function(builder, data) { - builder.startVector(8, data.length, 8); - for (var i = data.length - 1; i >= 0; i--) { - builder.addFloat64(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startVectorOfDoublesVector = function(builder, numElems) { - builder.startVector(8, numElems, 8); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} parentNamespaceTestOffset - */ -MyGame.Example.Monster.addParentNamespaceTest = function(builder, parentNamespaceTestOffset) { - builder.addFieldOffset(34, parentNamespaceTestOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} vectorOfReferrablesOffset - */ -MyGame.Example.Monster.addVectorOfReferrables = function(builder, vectorOfReferrablesOffset) { - builder.addFieldOffset(35, vectorOfReferrablesOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createVectorOfReferrablesVector = function(builder, data) { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startVectorOfReferrablesVector = function(builder, numElems) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} singleWeakReference - */ -MyGame.Example.Monster.addSingleWeakReference = function(builder, singleWeakReference) { - builder.addFieldInt64(36, singleWeakReference, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} vectorOfWeakReferencesOffset - */ -MyGame.Example.Monster.addVectorOfWeakReferences = function(builder, vectorOfWeakReferencesOffset) { - builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Long>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createVectorOfWeakReferencesVector = function(builder, data) { - builder.startVector(8, data.length, 8); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt64(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startVectorOfWeakReferencesVector = function(builder, numElems) { - builder.startVector(8, numElems, 8); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} vectorOfStrongReferrablesOffset - */ -MyGame.Example.Monster.addVectorOfStrongReferrables = function(builder, vectorOfStrongReferrablesOffset) { - builder.addFieldOffset(38, vectorOfStrongReferrablesOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createVectorOfStrongReferrablesVector = function(builder, data) { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startVectorOfStrongReferrablesVector = function(builder, numElems) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} coOwningReference - */ -MyGame.Example.Monster.addCoOwningReference = function(builder, coOwningReference) { - builder.addFieldInt64(39, coOwningReference, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} vectorOfCoOwningReferencesOffset - */ -MyGame.Example.Monster.addVectorOfCoOwningReferences = function(builder, vectorOfCoOwningReferencesOffset) { - builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Long>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createVectorOfCoOwningReferencesVector = function(builder, data) { - builder.startVector(8, data.length, 8); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt64(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startVectorOfCoOwningReferencesVector = function(builder, numElems) { - builder.startVector(8, numElems, 8); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} nonOwningReference - */ -MyGame.Example.Monster.addNonOwningReference = function(builder, nonOwningReference) { - builder.addFieldInt64(41, nonOwningReference, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} vectorOfNonOwningReferencesOffset - */ -MyGame.Example.Monster.addVectorOfNonOwningReferences = function(builder, vectorOfNonOwningReferencesOffset) { - builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Long>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createVectorOfNonOwningReferencesVector = function(builder, data) { - builder.startVector(8, data.length, 8); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt64(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startVectorOfNonOwningReferencesVector = function(builder, numElems) { - builder.startVector(8, numElems, 8); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.AnyUniqueAliases} anyUniqueType - */ -MyGame.Example.Monster.addAnyUniqueType = function(builder, anyUniqueType) { - builder.addFieldInt8(43, anyUniqueType, MyGame.Example.AnyUniqueAliases.NONE); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} anyUniqueOffset - */ -MyGame.Example.Monster.addAnyUnique = function(builder, anyUniqueOffset) { - builder.addFieldOffset(44, anyUniqueOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.AnyAmbiguousAliases} anyAmbiguousType - */ -MyGame.Example.Monster.addAnyAmbiguousType = function(builder, anyAmbiguousType) { - builder.addFieldInt8(45, anyAmbiguousType, MyGame.Example.AnyAmbiguousAliases.NONE); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} anyAmbiguousOffset - */ -MyGame.Example.Monster.addAnyAmbiguous = function(builder, anyAmbiguousOffset) { - builder.addFieldOffset(46, anyAmbiguousOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} vectorOfEnumsOffset - */ -MyGame.Example.Monster.addVectorOfEnums = function(builder, vectorOfEnumsOffset) { - builder.addFieldOffset(47, vectorOfEnumsOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<MyGame.Example.Color>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createVectorOfEnumsVector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startVectorOfEnumsVector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Race} signedEnum - */ -MyGame.Example.Monster.addSignedEnum = function(builder, signedEnum) { - builder.addFieldInt8(48, signedEnum, MyGame.Example.Race.None); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testrequirednestedflatbufferOffset - */ -MyGame.Example.Monster.addTestrequirednestedflatbuffer = function(builder, testrequirednestedflatbufferOffset) { - builder.addFieldOffset(49, testrequirednestedflatbufferOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createTestrequirednestedflatbufferVector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startTestrequirednestedflatbufferVector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} scalarKeySortedTablesOffset - */ -MyGame.Example.Monster.addScalarKeySortedTables = function(builder, scalarKeySortedTablesOffset) { - builder.addFieldOffset(50, scalarKeySortedTablesOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.createScalarKeySortedTablesVector = function(builder, data) { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.Monster.startScalarKeySortedTablesVector = function(builder, numElems) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example.Monster.endMonster = function(builder) { - var offset = builder.endObject(); - builder.requiredField(offset, 10); // name - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} offset - */ -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); -}; - -/** - * @constructor - */ -MyGame.Example.TypeAliases = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {MyGame.Example.TypeAliases} - */ -MyGame.Example.TypeAliases.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {MyGame.Example.TypeAliases=} obj - * @returns {MyGame.Example.TypeAliases} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new MyGame.Example.TypeAliases).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.i8 = function() { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt8(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.TypeAliases.prototype.mutate_i8 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.u8 = function() { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.TypeAliases.prototype.mutate_u8 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeUint8(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.i16 = function() { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.TypeAliases.prototype.mutate_i16 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.u16 = function() { - var offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.TypeAliases.prototype.mutate_u16 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 10); - - if (offset === 0) { - return false; - } - - this.bb.writeUint16(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.i32 = function() { - var offset = this.bb.__offset(this.bb_pos, 12); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.TypeAliases.prototype.mutate_i32 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 12); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.u32 = function() { - var offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.TypeAliases.prototype.mutate_u32 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 14); - - if (offset === 0) { - return false; - } - - this.bb.writeUint32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.TypeAliases.prototype.i64 = function() { - var offset = this.bb.__offset(this.bb_pos, 16); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.TypeAliases.prototype.mutate_i64 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 16); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {flatbuffers.Long} - */ -MyGame.Example.TypeAliases.prototype.u64 = function() { - var offset = this.bb.__offset(this.bb_pos, 18); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); -}; - -/** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ -MyGame.Example.TypeAliases.prototype.mutate_u64 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 18); - - if (offset === 0) { - return false; - } - - this.bb.writeUint64(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.f32 = function() { - var offset = this.bb.__offset(this.bb_pos, 20); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.TypeAliases.prototype.mutate_f32 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 20); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.f64 = function() { - var offset = this.bb.__offset(this.bb_pos, 22); - return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -MyGame.Example.TypeAliases.prototype.mutate_f64 = function(value) { - var offset = this.bb.__offset(this.bb_pos, 22); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat64(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {number} index - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.v8 = function(index) { - var offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : 0; -}; - -/** - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.v8Length = function() { - var offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Int8Array} - */ -MyGame.Example.TypeAliases.prototype.v8Array = function() { - var offset = this.bb.__offset(this.bb_pos, 24); - return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @param {number} index - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.vf64 = function(index) { - var offset = this.bb.__offset(this.bb_pos, 26); - return offset ? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8) : 0; -}; - -/** - * @returns {number} - */ -MyGame.Example.TypeAliases.prototype.vf64Length = function() { - var offset = this.bb.__offset(this.bb_pos, 26); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Float64Array} - */ -MyGame.Example.TypeAliases.prototype.vf64Array = function() { - var offset = this.bb.__offset(this.bb_pos, 26); - return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @param {flatbuffers.Builder} builder - */ -MyGame.Example.TypeAliases.startTypeAliases = function(builder) { - builder.startObject(12); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} i8 - */ -MyGame.Example.TypeAliases.addI8 = function(builder, i8) { - builder.addFieldInt8(0, i8, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} u8 - */ -MyGame.Example.TypeAliases.addU8 = function(builder, u8) { - builder.addFieldInt8(1, u8, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} i16 - */ -MyGame.Example.TypeAliases.addI16 = function(builder, i16) { - builder.addFieldInt16(2, i16, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} u16 - */ -MyGame.Example.TypeAliases.addU16 = function(builder, u16) { - builder.addFieldInt16(3, u16, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} i32 - */ -MyGame.Example.TypeAliases.addI32 = function(builder, i32) { - builder.addFieldInt32(4, i32, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} u32 - */ -MyGame.Example.TypeAliases.addU32 = function(builder, u32) { - builder.addFieldInt32(5, u32, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} i64 - */ -MyGame.Example.TypeAliases.addI64 = function(builder, i64) { - builder.addFieldInt64(6, i64, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} u64 - */ -MyGame.Example.TypeAliases.addU64 = function(builder, u64) { - builder.addFieldInt64(7, u64, builder.createLong(0, 0)); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} f32 - */ -MyGame.Example.TypeAliases.addF32 = function(builder, f32) { - builder.addFieldFloat32(8, f32, 0.0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} f64 - */ -MyGame.Example.TypeAliases.addF64 = function(builder, f64) { - builder.addFieldFloat64(9, f64, 0.0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} v8Offset - */ -MyGame.Example.TypeAliases.addV8 = function(builder, v8Offset) { - builder.addFieldOffset(10, v8Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.TypeAliases.createV8Vector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.TypeAliases.startV8Vector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} vf64Offset - */ -MyGame.Example.TypeAliases.addVf64 = function(builder, vf64Offset) { - builder.addFieldOffset(11, vf64Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<number>} data - * @returns {flatbuffers.Offset} - */ -MyGame.Example.TypeAliases.createVf64Vector = function(builder, data) { - builder.startVector(8, data.length, 8); - for (var i = data.length - 1; i >= 0; i--) { - builder.addFloat64(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -MyGame.Example.TypeAliases.startVf64Vector = function(builder, numElems) { - builder.startVector(8, numElems, 8); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -MyGame.Example.TypeAliases.endTypeAliases = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} i8 - * @param {number} u8 - * @param {number} i16 - * @param {number} u16 - * @param {number} i32 - * @param {number} u32 - * @param {flatbuffers.Long} i64 - * @param {flatbuffers.Long} u64 - * @param {number} f32 - * @param {number} f64 - * @param {flatbuffers.Offset} v8Offset - * @param {flatbuffers.Offset} vf64Offset - * @returns {flatbuffers.Offset} - */ -MyGame.Example.TypeAliases.createTypeAliases = function(builder, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, v8Offset, vf64Offset) { - MyGame.Example.TypeAliases.startTypeAliases(builder); - MyGame.Example.TypeAliases.addI8(builder, i8); - MyGame.Example.TypeAliases.addU8(builder, u8); - MyGame.Example.TypeAliases.addI16(builder, i16); - MyGame.Example.TypeAliases.addU16(builder, u16); - MyGame.Example.TypeAliases.addI32(builder, i32); - MyGame.Example.TypeAliases.addU32(builder, u32); - MyGame.Example.TypeAliases.addI64(builder, i64); - MyGame.Example.TypeAliases.addU64(builder, u64); - MyGame.Example.TypeAliases.addF32(builder, f32); - MyGame.Example.TypeAliases.addF64(builder, f64); - MyGame.Example.TypeAliases.addV8(builder, v8Offset); - MyGame.Example.TypeAliases.addVf64(builder, vf64Offset); - return MyGame.Example.TypeAliases.endTypeAliases(builder); -} - -// Exports for Node.js and RequireJS -this.MyGame = MyGame; diff --git a/tests/monster_test_grpc.d.ts b/tests/monster_test_grpc.d.ts deleted file mode 100644 index a1535fed..00000000 --- a/tests/monster_test_grpc.d.ts +++ /dev/null @@ -1,93 +0,0 @@ -// Generated GRPC code for FlatBuffers TS *** DO NOT EDIT *** -import { flatbuffers } from 'flatbuffers'; -import { Stat as MyGame_Example_Stat } from './my-game/example/stat'; -import { Monster as MyGame_Example_Monster } from './my-game/example/monster'; - -import * as grpc from 'grpc'; - -interface IMonsterStorageService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> { - Store: IMonsterStorageService_IStore; - Retrieve: IMonsterStorageService_IRetrieve; - GetMaxHitPoint: IMonsterStorageService_IGetMaxHitPoint; - GetMinMaxHitPoints: IMonsterStorageService_IGetMinMaxHitPoints; -} -interface IMonsterStorageService_IStore extends grpc.MethodDefinition<MyGame_Example_Monster, MyGame_Example_Stat> { - path: string; // /MyGame.Example.MonsterStorage/Store - requestStream: boolean; // false - responseStream: boolean; // false - requestSerialize: grpc.serialize<MyGame_Example_Monster>; - requestDeserialize: grpc.deserialize<MyGame_Example_Monster>; - responseSerialize: grpc.serialize<MyGame_Example_Stat>; - responseDeserialize: grpc.deserialize<MyGame_Example_Stat>; -} - -interface IMonsterStorageService_IRetrieve extends grpc.MethodDefinition<MyGame_Example_Stat, MyGame_Example_Monster> { - path: string; // /MyGame.Example.MonsterStorage/Retrieve - requestStream: boolean; // false - responseStream: boolean; // true - requestSerialize: grpc.serialize<MyGame_Example_Stat>; - requestDeserialize: grpc.deserialize<MyGame_Example_Stat>; - responseSerialize: grpc.serialize<MyGame_Example_Monster>; - responseDeserialize: grpc.deserialize<MyGame_Example_Monster>; -} - -interface IMonsterStorageService_IGetMaxHitPoint extends grpc.MethodDefinition<MyGame_Example_Monster, MyGame_Example_Stat> { - path: string; // /MyGame.Example.MonsterStorage/GetMaxHitPoint - requestStream: boolean; // true - responseStream: boolean; // false - requestSerialize: grpc.serialize<MyGame_Example_Monster>; - requestDeserialize: grpc.deserialize<MyGame_Example_Monster>; - responseSerialize: grpc.serialize<MyGame_Example_Stat>; - responseDeserialize: grpc.deserialize<MyGame_Example_Stat>; -} - -interface IMonsterStorageService_IGetMinMaxHitPoints extends grpc.MethodDefinition<MyGame_Example_Monster, MyGame_Example_Stat> { - path: string; // /MyGame.Example.MonsterStorage/GetMinMaxHitPoints - requestStream: boolean; // true - responseStream: boolean; // true - requestSerialize: grpc.serialize<MyGame_Example_Monster>; - requestDeserialize: grpc.deserialize<MyGame_Example_Monster>; - responseSerialize: grpc.serialize<MyGame_Example_Stat>; - responseDeserialize: grpc.deserialize<MyGame_Example_Stat>; -} - - -export const MonsterStorageService: IMonsterStorageService; - -export interface IMonsterStorageServer { - Store: grpc.handleUnaryCall<MyGame_Example_Monster, MyGame_Example_Stat>; - Retrieve: grpc.handleServerStreamingCall<MyGame_Example_Stat, MyGame_Example_Monster>; - GetMaxHitPoint: grpc.handleClientStreamingCall<MyGame_Example_Monster, MyGame_Example_Stat>; - GetMinMaxHitPoints: grpc.handleBidiStreamingCall<MyGame_Example_Monster, MyGame_Example_Stat>; -} - -export interface IMonsterStorageClient { - Store(request: MyGame_Example_Monster, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - Retrieve(request: MyGame_Example_Stat, metadata: grpc.Metadata): grpc.ClientReadableStream<MyGame_Example_Monster>; - Retrieve(request: MyGame_Example_Stat, options: Partial<grpc.CallOptions>): grpc.ClientReadableStream<MyGame_Example_Monster>; - GetMaxHitPoint(callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>; - GetMaxHitPoint(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>; - GetMaxHitPoint(options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>; - GetMaxHitPoint(metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>; - GetMinMaxHitPoints(): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>; - GetMinMaxHitPoints(options: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>; - GetMinMaxHitPoints(metadata: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>; -} - -export class MonsterStorageClient extends grpc.Client implements IMonsterStorageClient { - constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); public Store(request: MyGame_Example_Monster, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - public Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - public Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; - public Retrieve(request: MyGame_Example_Stat, metadata: grpc.Metadata): grpc.ClientReadableStream<MyGame_Example_Monster>; - public Retrieve(request: MyGame_Example_Stat, options: Partial<grpc.CallOptions>): grpc.ClientReadableStream<MyGame_Example_Monster>; - public GetMaxHitPoint(callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>; - public GetMaxHitPoint(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>; - public GetMaxHitPoint(options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>; - public GetMaxHitPoint(metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream<MyGame_Example_Stat>; - public GetMinMaxHitPoints(): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>; - public GetMinMaxHitPoints(options: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>; - public GetMinMaxHitPoints(metadata: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<MyGame_Example_Monster, MyGame_Example_Stat>; -} - diff --git a/tests/my-game/example/ability.js b/tests/my-game/example/ability.js new file mode 100644 index 00000000..9fea3d6b --- /dev/null +++ b/tests/my-game/example/ability.js @@ -0,0 +1,54 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export class Ability { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + id() { + return this.bb.readUint32(this.bb_pos); + } + mutate_id(value) { + this.bb.writeUint32(this.bb_pos + 0, value); + return true; + } + distance() { + return this.bb.readUint32(this.bb_pos + 4); + } + mutate_distance(value) { + this.bb.writeUint32(this.bb_pos + 4, value); + return true; + } + static getFullyQualifiedName() { + return 'MyGame.Example.Ability'; + } + static sizeOf() { + return 8; + } + static createAbility(builder, id, distance) { + builder.prep(4, 8); + builder.writeInt32(distance); + builder.writeInt32(id); + return builder.offset(); + } + unpack() { + return new AbilityT(this.id(), this.distance()); + } + unpackTo(_o) { + _o.id = this.id(); + _o.distance = this.distance(); + } +} +export class AbilityT { + constructor(id = 0, distance = 0) { + this.id = id; + this.distance = distance; + } + pack(builder) { + return Ability.createAbility(builder, this.id, this.distance); + } +} diff --git a/tests/my-game/example/ability.ts b/tests/my-game/example/ability.ts index 6ab5b4d7..26395fba 100644 --- a/tests/my-game/example/ability.ts +++ b/tests/my-game/example/ability.ts @@ -31,6 +31,10 @@ mutate_distance(value:number):boolean { return true; } +static getFullyQualifiedName():string { + return 'MyGame.Example.Ability'; +} + static sizeOf():number { return 8; } diff --git a/tests/my-game/example/any-ambiguous-aliases.js b/tests/my-game/example/any-ambiguous-aliases.js new file mode 100644 index 00000000..7cd2a85b --- /dev/null +++ b/tests/my-game/example/any-ambiguous-aliases.js @@ -0,0 +1,27 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Monster } from '../../my-game/example/monster'; +export var AnyAmbiguousAliases; +(function (AnyAmbiguousAliases) { + AnyAmbiguousAliases[AnyAmbiguousAliases["NONE"] = 0] = "NONE"; + AnyAmbiguousAliases[AnyAmbiguousAliases["M1"] = 1] = "M1"; + AnyAmbiguousAliases[AnyAmbiguousAliases["M2"] = 2] = "M2"; + AnyAmbiguousAliases[AnyAmbiguousAliases["M3"] = 3] = "M3"; +})(AnyAmbiguousAliases || (AnyAmbiguousAliases = {})); +export function unionToAnyAmbiguousAliases(type, accessor) { + switch (AnyAmbiguousAliases[type]) { + case 'NONE': return null; + case 'M1': return accessor(new Monster()); + case 'M2': return accessor(new Monster()); + case 'M3': return accessor(new Monster()); + default: return null; + } +} +export function unionListToAnyAmbiguousAliases(type, accessor, index) { + switch (AnyAmbiguousAliases[type]) { + case 'NONE': return null; + case 'M1': return accessor(index, new Monster()); + case 'M2': return accessor(index, new Monster()); + case 'M3': return accessor(index, new Monster()); + default: return null; + } +} diff --git a/tests/my-game/example/any-unique-aliases.js b/tests/my-game/example/any-unique-aliases.js new file mode 100644 index 00000000..b5cc8820 --- /dev/null +++ b/tests/my-game/example/any-unique-aliases.js @@ -0,0 +1,29 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Monster as MyGameExample2Monster } from '../../my-game/example2/monster'; +import { Monster } from '../../my-game/example/monster'; +import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum'; +export var AnyUniqueAliases; +(function (AnyUniqueAliases) { + AnyUniqueAliases[AnyUniqueAliases["NONE"] = 0] = "NONE"; + AnyUniqueAliases[AnyUniqueAliases["M"] = 1] = "M"; + AnyUniqueAliases[AnyUniqueAliases["TS"] = 2] = "TS"; + AnyUniqueAliases[AnyUniqueAliases["M2"] = 3] = "M2"; +})(AnyUniqueAliases || (AnyUniqueAliases = {})); +export function unionToAnyUniqueAliases(type, accessor) { + switch (AnyUniqueAliases[type]) { + case 'NONE': return null; + case 'M': return accessor(new Monster()); + case 'TS': return accessor(new TestSimpleTableWithEnum()); + case 'M2': return accessor(new MyGameExample2Monster()); + default: return null; + } +} +export function unionListToAnyUniqueAliases(type, accessor, index) { + switch (AnyUniqueAliases[type]) { + case 'NONE': return null; + case 'M': return accessor(index, new Monster()); + case 'TS': return accessor(index, new TestSimpleTableWithEnum()); + case 'M2': return accessor(index, new MyGameExample2Monster()); + default: return null; + } +} diff --git a/tests/my-game/example/any.js b/tests/my-game/example/any.js new file mode 100644 index 00000000..7349c076 --- /dev/null +++ b/tests/my-game/example/any.js @@ -0,0 +1,29 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Monster as MyGameExample2Monster } from '../../my-game/example2/monster'; +import { Monster } from '../../my-game/example/monster'; +import { TestSimpleTableWithEnum } from '../../my-game/example/test-simple-table-with-enum'; +export var Any; +(function (Any) { + Any[Any["NONE"] = 0] = "NONE"; + Any[Any["Monster"] = 1] = "Monster"; + Any[Any["TestSimpleTableWithEnum"] = 2] = "TestSimpleTableWithEnum"; + Any[Any["MyGame_Example2_Monster"] = 3] = "MyGame_Example2_Monster"; +})(Any || (Any = {})); +export function unionToAny(type, accessor) { + switch (Any[type]) { + case 'NONE': return null; + case 'Monster': return accessor(new Monster()); + case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum()); + case 'MyGame_Example2_Monster': return accessor(new MyGameExample2Monster()); + default: return null; + } +} +export function unionListToAny(type, accessor, index) { + switch (Any[type]) { + case 'NONE': return null; + case 'Monster': return accessor(index, new Monster()); + case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum()); + case 'MyGame_Example2_Monster': return accessor(index, new MyGameExample2Monster()); + default: return null; + } +} diff --git a/tests/my-game/example/color.js b/tests/my-game/example/color.js new file mode 100644 index 00000000..f95f75e9 --- /dev/null +++ b/tests/my-game/example/color.js @@ -0,0 +1,17 @@ +// automatically generated by the FlatBuffers compiler, do not modify +/** + * Composite components of Monster color. + */ +export var Color; +(function (Color) { + Color[Color["Red"] = 1] = "Red"; + /** + * \brief color Green + * Green is bit_flag with value (1u << 1) + */ + Color[Color["Green"] = 2] = "Green"; + /** + * \brief color Blue (1u << 3) + */ + Color[Color["Blue"] = 8] = "Blue"; +})(Color || (Color = {})); diff --git a/tests/my-game/example/monster.js b/tests/my-game/example/monster.js new file mode 100644 index 00000000..201a84ee --- /dev/null +++ b/tests/my-game/example/monster.js @@ -0,0 +1,1079 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { Ability } from '../../my-game/example/ability'; +import { Any, unionToAny } from '../../my-game/example/any'; +import { AnyAmbiguousAliases, unionToAnyAmbiguousAliases } from '../../my-game/example/any-ambiguous-aliases'; +import { AnyUniqueAliases, unionToAnyUniqueAliases } from '../../my-game/example/any-unique-aliases'; +import { Color } from '../../my-game/example/color'; +import { Race } from '../../my-game/example/race'; +import { Referrable } from '../../my-game/example/referrable'; +import { Stat } from '../../my-game/example/stat'; +import { Test } from '../../my-game/example/test'; +import { Vec3 } from '../../my-game/example/vec3'; +import { InParentNamespace } from '../../my-game/in-parent-namespace'; +/** + * an example documentation comment: "monster object" + */ +export class Monster { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsMonster(bb, obj) { + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsMonster(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static bufferHasIdentifier(bb) { + return bb.__has_identifier('MONS'); + } + pos(obj) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new Vec3()).__init(this.bb_pos + offset, this.bb) : null; + } + mana() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt16(this.bb_pos + offset) : 150; + } + mutate_mana(value) { + const offset = this.bb.__offset(this.bb_pos, 6); + if (offset === 0) { + return false; + } + this.bb.writeInt16(this.bb_pos + offset, value); + return true; + } + hp() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readInt16(this.bb_pos + offset) : 100; + } + mutate_hp(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeInt16(this.bb_pos + offset, value); + return true; + } + name(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + inventory(index) { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + inventoryLength() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + inventoryArray() { + const offset = this.bb.__offset(this.bb_pos, 14); + 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; + } + color() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readUint8(this.bb_pos + offset) : Color.Blue; + } + mutate_color(value) { + const offset = this.bb.__offset(this.bb_pos, 16); + if (offset === 0) { + return false; + } + this.bb.writeUint8(this.bb_pos + offset, value); + return true; + } + testType() { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint8(this.bb_pos + offset) : Any.NONE; + } + test(obj) { + const offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; + } + test4(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? (obj || new Test()).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null; + } + test4Length() { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + testarrayofstring(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + testarrayofstringLength() { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + /** + * an example documentation comment: this will end up in the generated code + * multiline too + */ + testarrayoftables(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? (obj || new Monster()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + testarrayoftablesLength() { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + enemy(obj) { + const offset = this.bb.__offset(this.bb_pos, 28); + return offset ? (obj || new Monster()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + testnestedflatbuffer(index) { + const offset = this.bb.__offset(this.bb_pos, 30); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + testnestedflatbufferLength() { + const offset = this.bb.__offset(this.bb_pos, 30); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + testnestedflatbufferArray() { + const offset = this.bb.__offset(this.bb_pos, 30); + 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; + } + testempty(obj) { + const offset = this.bb.__offset(this.bb_pos, 32); + return offset ? (obj || new Stat()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + testbool() { + const offset = this.bb.__offset(this.bb_pos, 34); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + mutate_testbool(value) { + const offset = this.bb.__offset(this.bb_pos, 34); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, +value); + return true; + } + testhashs32Fnv1() { + const offset = this.bb.__offset(this.bb_pos, 36); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_testhashs32_fnv1(value) { + const offset = this.bb.__offset(this.bb_pos, 36); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + testhashu32Fnv1() { + const offset = this.bb.__offset(this.bb_pos, 38); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; + } + mutate_testhashu32_fnv1(value) { + const offset = this.bb.__offset(this.bb_pos, 38); + if (offset === 0) { + return false; + } + this.bb.writeUint32(this.bb_pos + offset, value); + return true; + } + testhashs64Fnv1() { + const offset = this.bb.__offset(this.bb_pos, 40); + return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_testhashs64_fnv1(value) { + const offset = this.bb.__offset(this.bb_pos, 40); + if (offset === 0) { + return false; + } + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + testhashu64Fnv1() { + const offset = this.bb.__offset(this.bb_pos, 42); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_testhashu64_fnv1(value) { + const offset = this.bb.__offset(this.bb_pos, 42); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + testhashs32Fnv1a() { + const offset = this.bb.__offset(this.bb_pos, 44); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_testhashs32_fnv1a(value) { + const offset = this.bb.__offset(this.bb_pos, 44); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + testhashu32Fnv1a() { + const offset = this.bb.__offset(this.bb_pos, 46); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; + } + mutate_testhashu32_fnv1a(value) { + const offset = this.bb.__offset(this.bb_pos, 46); + if (offset === 0) { + return false; + } + this.bb.writeUint32(this.bb_pos + offset, value); + return true; + } + testhashs64Fnv1a() { + const offset = this.bb.__offset(this.bb_pos, 48); + return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_testhashs64_fnv1a(value) { + const offset = this.bb.__offset(this.bb_pos, 48); + if (offset === 0) { + return false; + } + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + testhashu64Fnv1a() { + const offset = this.bb.__offset(this.bb_pos, 50); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_testhashu64_fnv1a(value) { + const offset = this.bb.__offset(this.bb_pos, 50); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + testarrayofbools(index) { + const offset = this.bb.__offset(this.bb_pos, 52); + return offset ? !!this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : false; + } + testarrayofboolsLength() { + const offset = this.bb.__offset(this.bb_pos, 52); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + testarrayofboolsArray() { + const offset = this.bb.__offset(this.bb_pos, 52); + return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + testf() { + const offset = this.bb.__offset(this.bb_pos, 54); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.14159; + } + mutate_testf(value) { + const offset = this.bb.__offset(this.bb_pos, 54); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + testf2() { + const offset = this.bb.__offset(this.bb_pos, 56); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.0; + } + mutate_testf2(value) { + const offset = this.bb.__offset(this.bb_pos, 56); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + testf3() { + const offset = this.bb.__offset(this.bb_pos, 58); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; + } + mutate_testf3(value) { + const offset = this.bb.__offset(this.bb_pos, 58); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + testarrayofstring2(index, optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 60); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + testarrayofstring2Length() { + const offset = this.bb.__offset(this.bb_pos, 60); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + testarrayofsortedstruct(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 62); + return offset ? (obj || new Ability()).__init(this.bb.__vector(this.bb_pos + offset) + index * 8, this.bb) : null; + } + testarrayofsortedstructLength() { + const offset = this.bb.__offset(this.bb_pos, 62); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + flex(index) { + const offset = this.bb.__offset(this.bb_pos, 64); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + flexLength() { + const offset = this.bb.__offset(this.bb_pos, 64); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + flexArray() { + const offset = this.bb.__offset(this.bb_pos, 64); + 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; + } + test5(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 66); + return offset ? (obj || new Test()).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null; + } + test5Length() { + const offset = this.bb.__offset(this.bb_pos, 66); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vectorOfLongs(index) { + const offset = this.bb.__offset(this.bb_pos, 68); + return offset ? this.bb.readInt64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); + } + vectorOfLongsLength() { + const offset = this.bb.__offset(this.bb_pos, 68); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vectorOfDoubles(index) { + const offset = this.bb.__offset(this.bb_pos, 70); + return offset ? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8) : 0; + } + vectorOfDoublesLength() { + const offset = this.bb.__offset(this.bb_pos, 70); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vectorOfDoublesArray() { + const offset = this.bb.__offset(this.bb_pos, 70); + return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + parentNamespaceTest(obj) { + const offset = this.bb.__offset(this.bb_pos, 72); + return offset ? (obj || new InParentNamespace()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + vectorOfReferrables(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 74); + return offset ? (obj || new Referrable()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + vectorOfReferrablesLength() { + const offset = this.bb.__offset(this.bb_pos, 74); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + singleWeakReference() { + const offset = this.bb.__offset(this.bb_pos, 76); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_single_weak_reference(value) { + const offset = this.bb.__offset(this.bb_pos, 76); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + vectorOfWeakReferences(index) { + const offset = this.bb.__offset(this.bb_pos, 78); + return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); + } + vectorOfWeakReferencesLength() { + const offset = this.bb.__offset(this.bb_pos, 78); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vectorOfStrongReferrables(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 80); + return offset ? (obj || new Referrable()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + vectorOfStrongReferrablesLength() { + const offset = this.bb.__offset(this.bb_pos, 80); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + coOwningReference() { + const offset = this.bb.__offset(this.bb_pos, 82); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_co_owning_reference(value) { + const offset = this.bb.__offset(this.bb_pos, 82); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + vectorOfCoOwningReferences(index) { + const offset = this.bb.__offset(this.bb_pos, 84); + return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); + } + vectorOfCoOwningReferencesLength() { + const offset = this.bb.__offset(this.bb_pos, 84); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + nonOwningReference() { + const offset = this.bb.__offset(this.bb_pos, 86); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_non_owning_reference(value) { + const offset = this.bb.__offset(this.bb_pos, 86); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + vectorOfNonOwningReferences(index) { + const offset = this.bb.__offset(this.bb_pos, 88); + return offset ? this.bb.readUint64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); + } + vectorOfNonOwningReferencesLength() { + const offset = this.bb.__offset(this.bb_pos, 88); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + anyUniqueType() { + const offset = this.bb.__offset(this.bb_pos, 90); + return offset ? this.bb.readUint8(this.bb_pos + offset) : AnyUniqueAliases.NONE; + } + anyUnique(obj) { + const offset = this.bb.__offset(this.bb_pos, 92); + return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; + } + anyAmbiguousType() { + const offset = this.bb.__offset(this.bb_pos, 94); + return offset ? this.bb.readUint8(this.bb_pos + offset) : AnyAmbiguousAliases.NONE; + } + anyAmbiguous(obj) { + const offset = this.bb.__offset(this.bb_pos, 96); + return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; + } + vectorOfEnums(index) { + const offset = this.bb.__offset(this.bb_pos, 98); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + vectorOfEnumsLength() { + const offset = this.bb.__offset(this.bb_pos, 98); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vectorOfEnumsArray() { + const offset = this.bb.__offset(this.bb_pos, 98); + 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; + } + signedEnum() { + const offset = this.bb.__offset(this.bb_pos, 100); + return offset ? this.bb.readInt8(this.bb_pos + offset) : Race.None; + } + mutate_signed_enum(value) { + const offset = this.bb.__offset(this.bb_pos, 100); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, value); + return true; + } + testrequirednestedflatbuffer(index) { + const offset = this.bb.__offset(this.bb_pos, 102); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + testrequirednestedflatbufferLength() { + const offset = this.bb.__offset(this.bb_pos, 102); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + testrequirednestedflatbufferArray() { + const offset = this.bb.__offset(this.bb_pos, 102); + 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; + } + scalarKeySortedTables(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 104); + return offset ? (obj || new Stat()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + scalarKeySortedTablesLength() { + const offset = this.bb.__offset(this.bb_pos, 104); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'MyGame.Example.Monster'; + } + static startMonster(builder) { + builder.startObject(51); + } + static addPos(builder, posOffset) { + builder.addFieldStruct(0, posOffset, 0); + } + static addMana(builder, mana) { + builder.addFieldInt16(1, mana, 150); + } + static addHp(builder, hp) { + builder.addFieldInt16(2, hp, 100); + } + static addName(builder, nameOffset) { + builder.addFieldOffset(3, nameOffset, 0); + } + static addInventory(builder, inventoryOffset) { + builder.addFieldOffset(5, inventoryOffset, 0); + } + static createInventoryVector(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); + } + static startInventoryVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addColor(builder, color) { + builder.addFieldInt8(6, color, Color.Blue); + } + static addTestType(builder, testType) { + builder.addFieldInt8(7, testType, Any.NONE); + } + static addTest(builder, testOffset) { + builder.addFieldOffset(8, testOffset, 0); + } + static addTest4(builder, test4Offset) { + builder.addFieldOffset(9, test4Offset, 0); + } + static startTest4Vector(builder, numElems) { + builder.startVector(4, numElems, 2); + } + static addTestarrayofstring(builder, testarrayofstringOffset) { + builder.addFieldOffset(10, testarrayofstringOffset, 0); + } + static createTestarrayofstringVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startTestarrayofstringVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addTestarrayoftables(builder, testarrayoftablesOffset) { + builder.addFieldOffset(11, testarrayoftablesOffset, 0); + } + static createTestarrayoftablesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startTestarrayoftablesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addEnemy(builder, enemyOffset) { + builder.addFieldOffset(12, enemyOffset, 0); + } + static addTestnestedflatbuffer(builder, testnestedflatbufferOffset) { + builder.addFieldOffset(13, testnestedflatbufferOffset, 0); + } + static createTestnestedflatbufferVector(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); + } + static startTestnestedflatbufferVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addTestempty(builder, testemptyOffset) { + builder.addFieldOffset(14, testemptyOffset, 0); + } + static addTestbool(builder, testbool) { + builder.addFieldInt8(15, +testbool, +false); + } + static addTesthashs32Fnv1(builder, testhashs32Fnv1) { + builder.addFieldInt32(16, testhashs32Fnv1, 0); + } + static addTesthashu32Fnv1(builder, testhashu32Fnv1) { + builder.addFieldInt32(17, testhashu32Fnv1, 0); + } + static addTesthashs64Fnv1(builder, testhashs64Fnv1) { + builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0)); + } + static addTesthashu64Fnv1(builder, testhashu64Fnv1) { + builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 0)); + } + static addTesthashs32Fnv1a(builder, testhashs32Fnv1a) { + builder.addFieldInt32(20, testhashs32Fnv1a, 0); + } + static addTesthashu32Fnv1a(builder, testhashu32Fnv1a) { + builder.addFieldInt32(21, testhashu32Fnv1a, 0); + } + static addTesthashs64Fnv1a(builder, testhashs64Fnv1a) { + builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0)); + } + static addTesthashu64Fnv1a(builder, testhashu64Fnv1a) { + builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 0)); + } + static addTestarrayofbools(builder, testarrayofboolsOffset) { + builder.addFieldOffset(24, testarrayofboolsOffset, 0); + } + static createTestarrayofboolsVector(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(+data[i]); + } + return builder.endVector(); + } + static startTestarrayofboolsVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addTestf(builder, testf) { + builder.addFieldFloat32(25, testf, 3.14159); + } + static addTestf2(builder, testf2) { + builder.addFieldFloat32(26, testf2, 3.0); + } + static addTestf3(builder, testf3) { + builder.addFieldFloat32(27, testf3, 0.0); + } + static addTestarrayofstring2(builder, testarrayofstring2Offset) { + builder.addFieldOffset(28, testarrayofstring2Offset, 0); + } + static createTestarrayofstring2Vector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startTestarrayofstring2Vector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addTestarrayofsortedstruct(builder, testarrayofsortedstructOffset) { + builder.addFieldOffset(29, testarrayofsortedstructOffset, 0); + } + static startTestarrayofsortedstructVector(builder, numElems) { + builder.startVector(8, numElems, 4); + } + static addFlex(builder, flexOffset) { + builder.addFieldOffset(30, flexOffset, 0); + } + static createFlexVector(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); + } + static startFlexVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addTest5(builder, test5Offset) { + builder.addFieldOffset(31, test5Offset, 0); + } + static startTest5Vector(builder, numElems) { + builder.startVector(4, numElems, 2); + } + static addVectorOfLongs(builder, vectorOfLongsOffset) { + builder.addFieldOffset(32, vectorOfLongsOffset, 0); + } + static createVectorOfLongsVector(builder, data) { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]); + } + return builder.endVector(); + } + static startVectorOfLongsVector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static addVectorOfDoubles(builder, vectorOfDoublesOffset) { + builder.addFieldOffset(33, vectorOfDoublesOffset, 0); + } + static createVectorOfDoublesVector(builder, data) { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addFloat64(data[i]); + } + return builder.endVector(); + } + static startVectorOfDoublesVector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static addParentNamespaceTest(builder, parentNamespaceTestOffset) { + builder.addFieldOffset(34, parentNamespaceTestOffset, 0); + } + static addVectorOfReferrables(builder, vectorOfReferrablesOffset) { + builder.addFieldOffset(35, vectorOfReferrablesOffset, 0); + } + static createVectorOfReferrablesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startVectorOfReferrablesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addSingleWeakReference(builder, singleWeakReference) { + builder.addFieldInt64(36, singleWeakReference, builder.createLong(0, 0)); + } + static addVectorOfWeakReferences(builder, vectorOfWeakReferencesOffset) { + builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0); + } + static createVectorOfWeakReferencesVector(builder, data) { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]); + } + return builder.endVector(); + } + static startVectorOfWeakReferencesVector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static addVectorOfStrongReferrables(builder, vectorOfStrongReferrablesOffset) { + builder.addFieldOffset(38, vectorOfStrongReferrablesOffset, 0); + } + static createVectorOfStrongReferrablesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startVectorOfStrongReferrablesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addCoOwningReference(builder, coOwningReference) { + builder.addFieldInt64(39, coOwningReference, builder.createLong(0, 0)); + } + static addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferencesOffset) { + builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0); + } + static createVectorOfCoOwningReferencesVector(builder, data) { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]); + } + return builder.endVector(); + } + static startVectorOfCoOwningReferencesVector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static addNonOwningReference(builder, nonOwningReference) { + builder.addFieldInt64(41, nonOwningReference, builder.createLong(0, 0)); + } + static addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferencesOffset) { + builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0); + } + static createVectorOfNonOwningReferencesVector(builder, data) { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt64(data[i]); + } + return builder.endVector(); + } + static startVectorOfNonOwningReferencesVector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static addAnyUniqueType(builder, anyUniqueType) { + builder.addFieldInt8(43, anyUniqueType, AnyUniqueAliases.NONE); + } + static addAnyUnique(builder, anyUniqueOffset) { + builder.addFieldOffset(44, anyUniqueOffset, 0); + } + static addAnyAmbiguousType(builder, anyAmbiguousType) { + builder.addFieldInt8(45, anyAmbiguousType, AnyAmbiguousAliases.NONE); + } + static addAnyAmbiguous(builder, anyAmbiguousOffset) { + builder.addFieldOffset(46, anyAmbiguousOffset, 0); + } + static addVectorOfEnums(builder, vectorOfEnumsOffset) { + builder.addFieldOffset(47, vectorOfEnumsOffset, 0); + } + static createVectorOfEnumsVector(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); + } + static startVectorOfEnumsVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addSignedEnum(builder, signedEnum) { + builder.addFieldInt8(48, signedEnum, Race.None); + } + static addTestrequirednestedflatbuffer(builder, testrequirednestedflatbufferOffset) { + builder.addFieldOffset(49, testrequirednestedflatbufferOffset, 0); + } + static createTestrequirednestedflatbufferVector(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); + } + static startTestrequirednestedflatbufferVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addScalarKeySortedTables(builder, scalarKeySortedTablesOffset) { + builder.addFieldOffset(50, scalarKeySortedTablesOffset, 0); + } + static createScalarKeySortedTablesVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startScalarKeySortedTablesVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endMonster(builder) { + const offset = builder.endObject(); + builder.requiredField(offset, 10); // name + return offset; + } + static finishMonsterBuffer(builder, offset) { + builder.finish(offset, 'MONS'); + } + static finishSizePrefixedMonsterBuffer(builder, offset) { + builder.finish(offset, 'MONS', true); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new MonsterT((this.pos() !== null ? this.pos().unpack() : null), this.mana(), this.hp(), this.name(), this.bb.createScalarList(this.inventory.bind(this), this.inventoryLength()), this.color(), this.testType(), (() => { + let temp = unionToAny(this.testType(), this.test.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(), this.bb.createObjList(this.test4.bind(this), this.test4Length()), this.bb.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()), this.bb.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), (this.enemy() !== null ? this.enemy().unpack() : null), this.bb.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), (this.testempty() !== null ? this.testempty().unpack() : null), this.testbool(), this.testhashs32Fnv1(), this.testhashu32Fnv1(), this.testhashs64Fnv1(), this.testhashu64Fnv1(), this.testhashs32Fnv1a(), this.testhashu32Fnv1a(), this.testhashs64Fnv1a(), this.testhashu64Fnv1a(), this.bb.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), this.testf(), this.testf2(), this.testf3(), this.bb.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), this.bb.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), this.bb.createScalarList(this.flex.bind(this), this.flexLength()), this.bb.createObjList(this.test5.bind(this), this.test5Length()), this.bb.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), this.bb.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), (this.parentNamespaceTest() !== null ? this.parentNamespaceTest().unpack() : null), this.bb.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), this.singleWeakReference(), this.bb.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), this.bb.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), this.coOwningReference(), this.bb.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), this.nonOwningReference(), this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), this.anyUniqueType(), (() => { + let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(), this.anyAmbiguousType(), (() => { + let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(), this.bb.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()), this.signedEnum(), this.bb.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()), this.bb.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength())); + } + unpackTo(_o) { + _o.pos = (this.pos() !== null ? this.pos().unpack() : null); + _o.mana = this.mana(); + _o.hp = this.hp(); + _o.name = this.name(); + _o.inventory = this.bb.createScalarList(this.inventory.bind(this), this.inventoryLength()); + _o.color = this.color(); + _o.testType = this.testType(); + _o.test = (() => { + let temp = unionToAny(this.testType(), this.test.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(); + _o.test4 = this.bb.createObjList(this.test4.bind(this), this.test4Length()); + _o.testarrayofstring = this.bb.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()); + _o.testarrayoftables = this.bb.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()); + _o.enemy = (this.enemy() !== null ? this.enemy().unpack() : null); + _o.testnestedflatbuffer = this.bb.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()); + _o.testempty = (this.testempty() !== null ? this.testempty().unpack() : null); + _o.testbool = this.testbool(); + _o.testhashs32Fnv1 = this.testhashs32Fnv1(); + _o.testhashu32Fnv1 = this.testhashu32Fnv1(); + _o.testhashs64Fnv1 = this.testhashs64Fnv1(); + _o.testhashu64Fnv1 = this.testhashu64Fnv1(); + _o.testhashs32Fnv1a = this.testhashs32Fnv1a(); + _o.testhashu32Fnv1a = this.testhashu32Fnv1a(); + _o.testhashs64Fnv1a = this.testhashs64Fnv1a(); + _o.testhashu64Fnv1a = this.testhashu64Fnv1a(); + _o.testarrayofbools = this.bb.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()); + _o.testf = this.testf(); + _o.testf2 = this.testf2(); + _o.testf3 = this.testf3(); + _o.testarrayofstring2 = this.bb.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()); + _o.testarrayofsortedstruct = this.bb.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()); + _o.flex = this.bb.createScalarList(this.flex.bind(this), this.flexLength()); + _o.test5 = this.bb.createObjList(this.test5.bind(this), this.test5Length()); + _o.vectorOfLongs = this.bb.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()); + _o.vectorOfDoubles = this.bb.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()); + _o.parentNamespaceTest = (this.parentNamespaceTest() !== null ? this.parentNamespaceTest().unpack() : null); + _o.vectorOfReferrables = this.bb.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()); + _o.singleWeakReference = this.singleWeakReference(); + _o.vectorOfWeakReferences = this.bb.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()); + _o.vectorOfStrongReferrables = this.bb.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()); + _o.coOwningReference = this.coOwningReference(); + _o.vectorOfCoOwningReferences = this.bb.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()); + _o.nonOwningReference = this.nonOwningReference(); + _o.vectorOfNonOwningReferences = this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()); + _o.anyUniqueType = this.anyUniqueType(); + _o.anyUnique = (() => { + let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(); + _o.anyAmbiguousType = this.anyAmbiguousType(); + _o.anyAmbiguous = (() => { + let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); + if (temp === null) { + return null; + } + return temp.unpack(); + })(); + _o.vectorOfEnums = this.bb.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()); + _o.signedEnum = this.signedEnum(); + _o.testrequirednestedflatbuffer = this.bb.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()); + _o.scalarKeySortedTables = this.bb.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()); + } +} +export class MonsterT { + constructor(pos = null, mana = 150, hp = 100, name = null, inventory = [], color = Color.Blue, testType = Any.NONE, test = null, test4 = [], testarrayofstring = [], testarrayoftables = [], enemy = null, testnestedflatbuffer = [], testempty = null, testbool = false, testhashs32Fnv1 = 0, testhashu32Fnv1 = 0, testhashs64Fnv1 = flatbuffers.createLong(0, 0), testhashu64Fnv1 = flatbuffers.createLong(0, 0), testhashs32Fnv1a = 0, testhashu32Fnv1a = 0, testhashs64Fnv1a = flatbuffers.createLong(0, 0), testhashu64Fnv1a = flatbuffers.createLong(0, 0), testarrayofbools = [], testf = 3.14159, testf2 = 3.0, testf3 = 0.0, testarrayofstring2 = [], testarrayofsortedstruct = [], flex = [], test5 = [], vectorOfLongs = [], vectorOfDoubles = [], parentNamespaceTest = null, vectorOfReferrables = [], singleWeakReference = flatbuffers.createLong(0, 0), vectorOfWeakReferences = [], vectorOfStrongReferrables = [], coOwningReference = flatbuffers.createLong(0, 0), vectorOfCoOwningReferences = [], nonOwningReference = flatbuffers.createLong(0, 0), vectorOfNonOwningReferences = [], anyUniqueType = AnyUniqueAliases.NONE, anyUnique = null, anyAmbiguousType = AnyAmbiguousAliases.NONE, anyAmbiguous = null, vectorOfEnums = [], signedEnum = Race.None, testrequirednestedflatbuffer = [], scalarKeySortedTables = []) { + this.pos = pos; + this.mana = mana; + this.hp = hp; + this.name = name; + this.inventory = inventory; + this.color = color; + this.testType = testType; + this.test = test; + this.test4 = test4; + this.testarrayofstring = testarrayofstring; + this.testarrayoftables = testarrayoftables; + this.enemy = enemy; + this.testnestedflatbuffer = testnestedflatbuffer; + this.testempty = testempty; + this.testbool = testbool; + this.testhashs32Fnv1 = testhashs32Fnv1; + this.testhashu32Fnv1 = testhashu32Fnv1; + this.testhashs64Fnv1 = testhashs64Fnv1; + this.testhashu64Fnv1 = testhashu64Fnv1; + this.testhashs32Fnv1a = testhashs32Fnv1a; + this.testhashu32Fnv1a = testhashu32Fnv1a; + this.testhashs64Fnv1a = testhashs64Fnv1a; + this.testhashu64Fnv1a = testhashu64Fnv1a; + this.testarrayofbools = testarrayofbools; + this.testf = testf; + this.testf2 = testf2; + this.testf3 = testf3; + this.testarrayofstring2 = testarrayofstring2; + this.testarrayofsortedstruct = testarrayofsortedstruct; + this.flex = flex; + this.test5 = test5; + this.vectorOfLongs = vectorOfLongs; + this.vectorOfDoubles = vectorOfDoubles; + this.parentNamespaceTest = parentNamespaceTest; + this.vectorOfReferrables = vectorOfReferrables; + this.singleWeakReference = singleWeakReference; + this.vectorOfWeakReferences = vectorOfWeakReferences; + this.vectorOfStrongReferrables = vectorOfStrongReferrables; + this.coOwningReference = coOwningReference; + this.vectorOfCoOwningReferences = vectorOfCoOwningReferences; + this.nonOwningReference = nonOwningReference; + this.vectorOfNonOwningReferences = vectorOfNonOwningReferences; + this.anyUniqueType = anyUniqueType; + this.anyUnique = anyUnique; + this.anyAmbiguousType = anyAmbiguousType; + this.anyAmbiguous = anyAmbiguous; + this.vectorOfEnums = vectorOfEnums; + this.signedEnum = signedEnum; + this.testrequirednestedflatbuffer = testrequirednestedflatbuffer; + this.scalarKeySortedTables = scalarKeySortedTables; + } + pack(builder) { + const name = (this.name !== null ? builder.createString(this.name) : 0); + const inventory = Monster.createInventoryVector(builder, this.inventory); + const test = builder.createObjectOffset(this.test); + const test4 = builder.createStructOffsetList(this.test4, Monster.startTest4Vector); + const testarrayofstring = Monster.createTestarrayofstringVector(builder, builder.createObjectOffsetList(this.testarrayofstring)); + const testarrayoftables = Monster.createTestarrayoftablesVector(builder, builder.createObjectOffsetList(this.testarrayoftables)); + const enemy = (this.enemy !== null ? this.enemy.pack(builder) : 0); + const testnestedflatbuffer = Monster.createTestnestedflatbufferVector(builder, this.testnestedflatbuffer); + const testempty = (this.testempty !== null ? this.testempty.pack(builder) : 0); + const testarrayofbools = Monster.createTestarrayofboolsVector(builder, this.testarrayofbools); + const testarrayofstring2 = Monster.createTestarrayofstring2Vector(builder, builder.createObjectOffsetList(this.testarrayofstring2)); + const testarrayofsortedstruct = builder.createStructOffsetList(this.testarrayofsortedstruct, Monster.startTestarrayofsortedstructVector); + const flex = Monster.createFlexVector(builder, this.flex); + const test5 = builder.createStructOffsetList(this.test5, Monster.startTest5Vector); + const vectorOfLongs = Monster.createVectorOfLongsVector(builder, this.vectorOfLongs); + const vectorOfDoubles = Monster.createVectorOfDoublesVector(builder, this.vectorOfDoubles); + const parentNamespaceTest = (this.parentNamespaceTest !== null ? this.parentNamespaceTest.pack(builder) : 0); + const vectorOfReferrables = Monster.createVectorOfReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfReferrables)); + const vectorOfWeakReferences = Monster.createVectorOfWeakReferencesVector(builder, this.vectorOfWeakReferences); + const vectorOfStrongReferrables = Monster.createVectorOfStrongReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfStrongReferrables)); + const vectorOfCoOwningReferences = Monster.createVectorOfCoOwningReferencesVector(builder, this.vectorOfCoOwningReferences); + const vectorOfNonOwningReferences = Monster.createVectorOfNonOwningReferencesVector(builder, this.vectorOfNonOwningReferences); + const anyUnique = builder.createObjectOffset(this.anyUnique); + const anyAmbiguous = builder.createObjectOffset(this.anyAmbiguous); + const vectorOfEnums = Monster.createVectorOfEnumsVector(builder, this.vectorOfEnums); + const testrequirednestedflatbuffer = Monster.createTestrequirednestedflatbufferVector(builder, this.testrequirednestedflatbuffer); + const scalarKeySortedTables = Monster.createScalarKeySortedTablesVector(builder, builder.createObjectOffsetList(this.scalarKeySortedTables)); + Monster.startMonster(builder); + Monster.addPos(builder, (this.pos !== null ? this.pos.pack(builder) : 0)); + Monster.addMana(builder, this.mana); + Monster.addHp(builder, this.hp); + Monster.addName(builder, name); + Monster.addInventory(builder, inventory); + Monster.addColor(builder, this.color); + Monster.addTestType(builder, this.testType); + Monster.addTest(builder, test); + Monster.addTest4(builder, test4); + Monster.addTestarrayofstring(builder, testarrayofstring); + Monster.addTestarrayoftables(builder, testarrayoftables); + Monster.addEnemy(builder, enemy); + Monster.addTestnestedflatbuffer(builder, testnestedflatbuffer); + Monster.addTestempty(builder, testempty); + Monster.addTestbool(builder, this.testbool); + Monster.addTesthashs32Fnv1(builder, this.testhashs32Fnv1); + Monster.addTesthashu32Fnv1(builder, this.testhashu32Fnv1); + Monster.addTesthashs64Fnv1(builder, this.testhashs64Fnv1); + Monster.addTesthashu64Fnv1(builder, this.testhashu64Fnv1); + Monster.addTesthashs32Fnv1a(builder, this.testhashs32Fnv1a); + Monster.addTesthashu32Fnv1a(builder, this.testhashu32Fnv1a); + Monster.addTesthashs64Fnv1a(builder, this.testhashs64Fnv1a); + Monster.addTesthashu64Fnv1a(builder, this.testhashu64Fnv1a); + Monster.addTestarrayofbools(builder, testarrayofbools); + Monster.addTestf(builder, this.testf); + Monster.addTestf2(builder, this.testf2); + Monster.addTestf3(builder, this.testf3); + Monster.addTestarrayofstring2(builder, testarrayofstring2); + Monster.addTestarrayofsortedstruct(builder, testarrayofsortedstruct); + Monster.addFlex(builder, flex); + Monster.addTest5(builder, test5); + Monster.addVectorOfLongs(builder, vectorOfLongs); + Monster.addVectorOfDoubles(builder, vectorOfDoubles); + Monster.addParentNamespaceTest(builder, parentNamespaceTest); + Monster.addVectorOfReferrables(builder, vectorOfReferrables); + Monster.addSingleWeakReference(builder, this.singleWeakReference); + Monster.addVectorOfWeakReferences(builder, vectorOfWeakReferences); + Monster.addVectorOfStrongReferrables(builder, vectorOfStrongReferrables); + Monster.addCoOwningReference(builder, this.coOwningReference); + Monster.addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferences); + Monster.addNonOwningReference(builder, this.nonOwningReference); + Monster.addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferences); + Monster.addAnyUniqueType(builder, this.anyUniqueType); + Monster.addAnyUnique(builder, anyUnique); + Monster.addAnyAmbiguousType(builder, this.anyAmbiguousType); + Monster.addAnyAmbiguous(builder, anyAmbiguous); + Monster.addVectorOfEnums(builder, vectorOfEnums); + Monster.addSignedEnum(builder, this.signedEnum); + Monster.addTestrequirednestedflatbuffer(builder, testrequirednestedflatbuffer); + Monster.addScalarKeySortedTables(builder, scalarKeySortedTables); + return Monster.endMonster(builder); + } +} diff --git a/tests/my-game/example/monster.ts b/tests/my-game/example/monster.ts index 26481d23..b4ee6e3f 100644 --- a/tests/my-game/example/monster.ts +++ b/tests/my-game/example/monster.ts @@ -646,6 +646,10 @@ scalarKeySortedTablesLength():number { return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; } +static getFullyQualifiedName():string { + return 'MyGame.Example.Monster'; +} + static startMonster(builder:flatbuffers.Builder) { builder.startObject(51); } diff --git a/tests/my-game/example/race.js b/tests/my-game/example/race.js new file mode 100644 index 00000000..74f51057 --- /dev/null +++ b/tests/my-game/example/race.js @@ -0,0 +1,8 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var Race; +(function (Race) { + Race[Race["None"] = -1] = "None"; + Race[Race["Human"] = 0] = "Human"; + Race[Race["Dwarf"] = 1] = "Dwarf"; + Race[Race["Elf"] = 2] = "Elf"; +})(Race || (Race = {})); diff --git a/tests/my-game/example/referrable.js b/tests/my-game/example/referrable.js new file mode 100644 index 00000000..98cc76a9 --- /dev/null +++ b/tests/my-game/example/referrable.js @@ -0,0 +1,70 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class Referrable { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsReferrable(bb, obj) { + return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsReferrable(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + id() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_id(value) { + const offset = this.bb.__offset(this.bb_pos, 4); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + static getFullyQualifiedName() { + return 'MyGame.Example.Referrable'; + } + static startReferrable(builder) { + builder.startObject(1); + } + static addId(builder, id) { + builder.addFieldInt64(0, id, builder.createLong(0, 0)); + } + static endReferrable(builder) { + const offset = builder.endObject(); + return offset; + } + static createReferrable(builder, id) { + Referrable.startReferrable(builder); + Referrable.addId(builder, id); + return Referrable.endReferrable(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new ReferrableT(this.id()); + } + unpackTo(_o) { + _o.id = this.id(); + } +} +export class ReferrableT { + constructor(id = flatbuffers.createLong(0, 0)) { + this.id = id; + } + pack(builder) { + return Referrable.createReferrable(builder, this.id); + } +} diff --git a/tests/my-game/example/referrable.ts b/tests/my-game/example/referrable.ts index 05e2a890..ce24debb 100644 --- a/tests/my-game/example/referrable.ts +++ b/tests/my-game/example/referrable.ts @@ -38,6 +38,10 @@ mutate_id(value:flatbuffers.Long):boolean { return true; } +static getFullyQualifiedName():string { + return 'MyGame.Example.Referrable'; +} + static startReferrable(builder:flatbuffers.Builder) { builder.startObject(1); } diff --git a/tests/my-game/example/stat.js b/tests/my-game/example/stat.js new file mode 100644 index 00000000..12746ed5 --- /dev/null +++ b/tests/my-game/example/stat.js @@ -0,0 +1,99 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class Stat { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsStat(bb, obj) { + return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsStat(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + id(optionalEncoding) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + val() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_val(value) { + const offset = this.bb.__offset(this.bb_pos, 6); + if (offset === 0) { + return false; + } + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + count() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + mutate_count(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeUint16(this.bb_pos + offset, value); + return true; + } + static getFullyQualifiedName() { + return 'MyGame.Example.Stat'; + } + static startStat(builder) { + builder.startObject(3); + } + static addId(builder, idOffset) { + builder.addFieldOffset(0, idOffset, 0); + } + static addVal(builder, val) { + builder.addFieldInt64(1, val, builder.createLong(0, 0)); + } + static addCount(builder, count) { + builder.addFieldInt16(2, count, 0); + } + static endStat(builder) { + const offset = builder.endObject(); + return offset; + } + static createStat(builder, idOffset, val, count) { + Stat.startStat(builder); + Stat.addId(builder, idOffset); + Stat.addVal(builder, val); + Stat.addCount(builder, count); + return Stat.endStat(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new StatT(this.id(), this.val(), this.count()); + } + unpackTo(_o) { + _o.id = this.id(); + _o.val = this.val(); + _o.count = this.count(); + } +} +export class StatT { + constructor(id = null, val = flatbuffers.createLong(0, 0), count = 0) { + this.id = id; + this.val = val; + this.count = count; + } + pack(builder) { + const id = (this.id !== null ? builder.createString(this.id) : 0); + return Stat.createStat(builder, id, this.val, this.count); + } +} diff --git a/tests/my-game/example/stat.ts b/tests/my-game/example/stat.ts index 87361e0b..c0ef62c7 100644 --- a/tests/my-game/example/stat.ts +++ b/tests/my-game/example/stat.ts @@ -61,6 +61,10 @@ mutate_count(value:number):boolean { return true; } +static getFullyQualifiedName():string { + return 'MyGame.Example.Stat'; +} + static startStat(builder:flatbuffers.Builder) { builder.startObject(3); } diff --git a/tests/my-game/example/struct-of-structs.js b/tests/my-game/example/struct-of-structs.js new file mode 100644 index 00000000..2debc294 --- /dev/null +++ b/tests/my-game/example/struct-of-structs.js @@ -0,0 +1,61 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Ability } from '../../my-game/example/ability'; +import { Test } from '../../my-game/example/test'; +export class StructOfStructs { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + a(obj) { + return (obj || new Ability()).__init(this.bb_pos, this.bb); + } + b(obj) { + return (obj || new Test()).__init(this.bb_pos + 8, this.bb); + } + c(obj) { + return (obj || new Ability()).__init(this.bb_pos + 12, this.bb); + } + static getFullyQualifiedName() { + return 'MyGame.Example.StructOfStructs'; + } + static sizeOf() { + return 20; + } + static createStructOfStructs(builder, a_id, a_distance, b_a, b_b, c_id, c_distance) { + builder.prep(4, 20); + builder.prep(4, 8); + builder.writeInt32(c_distance); + builder.writeInt32(c_id); + builder.prep(2, 4); + builder.pad(1); + builder.writeInt8(b_b); + builder.writeInt16(b_a); + builder.prep(4, 8); + builder.writeInt32(a_distance); + builder.writeInt32(a_id); + return builder.offset(); + } + unpack() { + return new StructOfStructsT((this.a() !== null ? this.a().unpack() : null), (this.b() !== null ? this.b().unpack() : null), (this.c() !== null ? this.c().unpack() : null)); + } + unpackTo(_o) { + _o.a = (this.a() !== null ? this.a().unpack() : null); + _o.b = (this.b() !== null ? this.b().unpack() : null); + _o.c = (this.c() !== null ? this.c().unpack() : null); + } +} +export class StructOfStructsT { + constructor(a = null, b = null, c = null) { + this.a = a; + this.b = b; + this.c = c; + } + pack(builder) { + return StructOfStructs.createStructOfStructs(builder, (this.a === null ? 0 : this.a.id), (this.a === null ? 0 : this.a.distance), (this.b === null ? 0 : this.b.a), (this.b === null ? 0 : this.b.b), (this.c === null ? 0 : this.c.id), (this.c === null ? 0 : this.c.distance)); + } +} diff --git a/tests/my-game/example/struct-of-structs.ts b/tests/my-game/example/struct-of-structs.ts index 3b7d3d49..11eca7ee 100644 --- a/tests/my-game/example/struct-of-structs.ts +++ b/tests/my-game/example/struct-of-structs.ts @@ -27,6 +27,10 @@ c(obj?:Ability):Ability|null { return (obj || new Ability()).__init(this.bb_pos + 12, this.bb!); } +static getFullyQualifiedName():string { + return 'MyGame.Example.StructOfStructs'; +} + static sizeOf():number { return 20; } diff --git a/tests/my-game/example/test-simple-table-with-enum.js b/tests/my-game/example/test-simple-table-with-enum.js new file mode 100644 index 00000000..b56bda44 --- /dev/null +++ b/tests/my-game/example/test-simple-table-with-enum.js @@ -0,0 +1,71 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { Color } from '../../my-game/example/color'; +export class TestSimpleTableWithEnum { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsTestSimpleTableWithEnum(bb, obj) { + return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsTestSimpleTableWithEnum(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + color() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint8(this.bb_pos + offset) : Color.Green; + } + mutate_color(value) { + const offset = this.bb.__offset(this.bb_pos, 4); + if (offset === 0) { + return false; + } + this.bb.writeUint8(this.bb_pos + offset, value); + return true; + } + static getFullyQualifiedName() { + return 'MyGame.Example.TestSimpleTableWithEnum'; + } + static startTestSimpleTableWithEnum(builder) { + builder.startObject(1); + } + static addColor(builder, color) { + builder.addFieldInt8(0, color, Color.Green); + } + static endTestSimpleTableWithEnum(builder) { + const offset = builder.endObject(); + return offset; + } + static createTestSimpleTableWithEnum(builder, color) { + TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder); + TestSimpleTableWithEnum.addColor(builder, color); + return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new TestSimpleTableWithEnumT(this.color()); + } + unpackTo(_o) { + _o.color = this.color(); + } +} +export class TestSimpleTableWithEnumT { + constructor(color = Color.Green) { + this.color = color; + } + pack(builder) { + return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder, this.color); + } +} diff --git a/tests/my-game/example/test-simple-table-with-enum.ts b/tests/my-game/example/test-simple-table-with-enum.ts index e8121b41..99a541f9 100644 --- a/tests/my-game/example/test-simple-table-with-enum.ts +++ b/tests/my-game/example/test-simple-table-with-enum.ts @@ -39,6 +39,10 @@ mutate_color(value:Color):boolean { return true; } +static getFullyQualifiedName():string { + return 'MyGame.Example.TestSimpleTableWithEnum'; +} + static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) { builder.startObject(1); } diff --git a/tests/my-game/example/test.js b/tests/my-game/example/test.js new file mode 100644 index 00000000..ba6ebfb7 --- /dev/null +++ b/tests/my-game/example/test.js @@ -0,0 +1,55 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export class Test { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + a() { + return this.bb.readInt16(this.bb_pos); + } + mutate_a(value) { + this.bb.writeInt16(this.bb_pos + 0, value); + return true; + } + b() { + return this.bb.readInt8(this.bb_pos + 2); + } + mutate_b(value) { + this.bb.writeInt8(this.bb_pos + 2, value); + return true; + } + static getFullyQualifiedName() { + return 'MyGame.Example.Test'; + } + static sizeOf() { + return 4; + } + static createTest(builder, a, b) { + builder.prep(2, 4); + builder.pad(1); + builder.writeInt8(b); + builder.writeInt16(a); + return builder.offset(); + } + unpack() { + return new TestT(this.a(), this.b()); + } + unpackTo(_o) { + _o.a = this.a(); + _o.b = this.b(); + } +} +export class TestT { + constructor(a = 0, b = 0) { + this.a = a; + this.b = b; + } + pack(builder) { + return Test.createTest(builder, this.a, this.b); + } +} diff --git a/tests/my-game/example/test.ts b/tests/my-game/example/test.ts index e49374db..afed125e 100644 --- a/tests/my-game/example/test.ts +++ b/tests/my-game/example/test.ts @@ -31,6 +31,10 @@ mutate_b(value:number):boolean { return true; } +static getFullyQualifiedName():string { + return 'MyGame.Example.Test'; +} + static sizeOf():number { return 4; } diff --git a/tests/my-game/example/type-aliases.js b/tests/my-game/example/type-aliases.js new file mode 100644 index 00000000..9522abc6 --- /dev/null +++ b/tests/my-game/example/type-aliases.js @@ -0,0 +1,290 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class TypeAliases { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsTypeAliases(bb, obj) { + return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsTypeAliases(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + i8() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readInt8(this.bb_pos + offset) : 0; + } + mutate_i8(value) { + const offset = this.bb.__offset(this.bb_pos, 4); + if (offset === 0) { + return false; + } + this.bb.writeInt8(this.bb_pos + offset, value); + return true; + } + u8() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; + } + mutate_u8(value) { + const offset = this.bb.__offset(this.bb_pos, 6); + if (offset === 0) { + return false; + } + this.bb.writeUint8(this.bb_pos + offset, value); + return true; + } + i16() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readInt16(this.bb_pos + offset) : 0; + } + mutate_i16(value) { + const offset = this.bb.__offset(this.bb_pos, 8); + if (offset === 0) { + return false; + } + this.bb.writeInt16(this.bb_pos + offset, value); + return true; + } + u16() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + mutate_u16(value) { + const offset = this.bb.__offset(this.bb_pos, 10); + if (offset === 0) { + return false; + } + this.bb.writeUint16(this.bb_pos + offset, value); + return true; + } + i32() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_i32(value) { + const offset = this.bb.__offset(this.bb_pos, 12); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + u32() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; + } + mutate_u32(value) { + const offset = this.bb.__offset(this.bb_pos, 14); + if (offset === 0) { + return false; + } + this.bb.writeUint32(this.bb_pos + offset, value); + return true; + } + i64() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_i64(value) { + const offset = this.bb.__offset(this.bb_pos, 16); + if (offset === 0) { + return false; + } + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + u64() { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + mutate_u64(value) { + const offset = this.bb.__offset(this.bb_pos, 18); + if (offset === 0) { + return false; + } + this.bb.writeUint64(this.bb_pos + offset, value); + return true; + } + f32() { + const offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; + } + mutate_f32(value) { + const offset = this.bb.__offset(this.bb_pos, 20); + if (offset === 0) { + return false; + } + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + f64() { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; + } + mutate_f64(value) { + const offset = this.bb.__offset(this.bb_pos, 22); + if (offset === 0) { + return false; + } + this.bb.writeFloat64(this.bb_pos + offset, value); + return true; + } + v8(index) { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + v8Length() { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + v8Array() { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + vf64(index) { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.readFloat64(this.bb.__vector(this.bb_pos + offset) + index * 8) : 0; + } + vf64Length() { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + vf64Array() { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? new Float64Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + static getFullyQualifiedName() { + return 'MyGame.Example.TypeAliases'; + } + static startTypeAliases(builder) { + builder.startObject(12); + } + static addI8(builder, i8) { + builder.addFieldInt8(0, i8, 0); + } + static addU8(builder, u8) { + builder.addFieldInt8(1, u8, 0); + } + static addI16(builder, i16) { + builder.addFieldInt16(2, i16, 0); + } + static addU16(builder, u16) { + builder.addFieldInt16(3, u16, 0); + } + static addI32(builder, i32) { + builder.addFieldInt32(4, i32, 0); + } + static addU32(builder, u32) { + builder.addFieldInt32(5, u32, 0); + } + static addI64(builder, i64) { + builder.addFieldInt64(6, i64, builder.createLong(0, 0)); + } + static addU64(builder, u64) { + builder.addFieldInt64(7, u64, builder.createLong(0, 0)); + } + static addF32(builder, f32) { + builder.addFieldFloat32(8, f32, 0.0); + } + static addF64(builder, f64) { + builder.addFieldFloat64(9, f64, 0.0); + } + static addV8(builder, v8Offset) { + builder.addFieldOffset(10, v8Offset, 0); + } + static createV8Vector(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); + } + static startV8Vector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addVf64(builder, vf64Offset) { + builder.addFieldOffset(11, vf64Offset, 0); + } + static createVf64Vector(builder, data) { + builder.startVector(8, data.length, 8); + for (let i = data.length - 1; i >= 0; i--) { + builder.addFloat64(data[i]); + } + return builder.endVector(); + } + static startVf64Vector(builder, numElems) { + builder.startVector(8, numElems, 8); + } + static endTypeAliases(builder) { + const offset = builder.endObject(); + return offset; + } + static createTypeAliases(builder, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, v8Offset, vf64Offset) { + TypeAliases.startTypeAliases(builder); + TypeAliases.addI8(builder, i8); + TypeAliases.addU8(builder, u8); + TypeAliases.addI16(builder, i16); + TypeAliases.addU16(builder, u16); + TypeAliases.addI32(builder, i32); + TypeAliases.addU32(builder, u32); + TypeAliases.addI64(builder, i64); + TypeAliases.addU64(builder, u64); + TypeAliases.addF32(builder, f32); + TypeAliases.addF64(builder, f64); + TypeAliases.addV8(builder, v8Offset); + TypeAliases.addVf64(builder, vf64Offset); + return TypeAliases.endTypeAliases(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new TypeAliasesT(this.i8(), this.u8(), this.i16(), this.u16(), this.i32(), this.u32(), this.i64(), this.u64(), this.f32(), this.f64(), this.bb.createScalarList(this.v8.bind(this), this.v8Length()), this.bb.createScalarList(this.vf64.bind(this), this.vf64Length())); + } + unpackTo(_o) { + _o.i8 = this.i8(); + _o.u8 = this.u8(); + _o.i16 = this.i16(); + _o.u16 = this.u16(); + _o.i32 = this.i32(); + _o.u32 = this.u32(); + _o.i64 = this.i64(); + _o.u64 = this.u64(); + _o.f32 = this.f32(); + _o.f64 = this.f64(); + _o.v8 = this.bb.createScalarList(this.v8.bind(this), this.v8Length()); + _o.vf64 = this.bb.createScalarList(this.vf64.bind(this), this.vf64Length()); + } +} +export class TypeAliasesT { + constructor(i8 = 0, u8 = 0, i16 = 0, u16 = 0, i32 = 0, u32 = 0, i64 = flatbuffers.createLong(0, 0), u64 = flatbuffers.createLong(0, 0), f32 = 0.0, f64 = 0.0, v8 = [], vf64 = []) { + this.i8 = i8; + this.u8 = u8; + this.i16 = i16; + this.u16 = u16; + this.i32 = i32; + this.u32 = u32; + this.i64 = i64; + this.u64 = u64; + this.f32 = f32; + this.f64 = f64; + this.v8 = v8; + this.vf64 = vf64; + } + pack(builder) { + const v8 = TypeAliases.createV8Vector(builder, this.v8); + const vf64 = TypeAliases.createVf64Vector(builder, this.vf64); + return TypeAliases.createTypeAliases(builder, this.i8, this.u8, this.i16, this.u16, this.i32, this.u32, this.i64, this.u64, this.f32, this.f64, v8, vf64); + } +} diff --git a/tests/my-game/example/type-aliases.ts b/tests/my-game/example/type-aliases.ts index 8e89bbcb..58940d01 100644 --- a/tests/my-game/example/type-aliases.ts +++ b/tests/my-game/example/type-aliases.ts @@ -212,6 +212,10 @@ vf64Array():Float64Array|null { return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; } +static getFullyQualifiedName():string { + return 'MyGame.Example.TypeAliases'; +} + static startTypeAliases(builder:flatbuffers.Builder) { builder.startObject(12); } diff --git a/tests/my-game/example/vec3.js b/tests/my-game/example/vec3.js new file mode 100644 index 00000000..5fd24473 --- /dev/null +++ b/tests/my-game/example/vec3.js @@ -0,0 +1,97 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Test } from '../../my-game/example/test'; +export class Vec3 { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + x() { + return this.bb.readFloat32(this.bb_pos); + } + mutate_x(value) { + this.bb.writeFloat32(this.bb_pos + 0, value); + return true; + } + y() { + return this.bb.readFloat32(this.bb_pos + 4); + } + mutate_y(value) { + this.bb.writeFloat32(this.bb_pos + 4, value); + return true; + } + z() { + return this.bb.readFloat32(this.bb_pos + 8); + } + mutate_z(value) { + this.bb.writeFloat32(this.bb_pos + 8, value); + return true; + } + test1() { + return this.bb.readFloat64(this.bb_pos + 16); + } + mutate_test1(value) { + this.bb.writeFloat64(this.bb_pos + 16, value); + return true; + } + test2() { + return this.bb.readUint8(this.bb_pos + 24); + } + mutate_test2(value) { + this.bb.writeUint8(this.bb_pos + 24, value); + return true; + } + test3(obj) { + return (obj || new Test()).__init(this.bb_pos + 26, this.bb); + } + static getFullyQualifiedName() { + return 'MyGame.Example.Vec3'; + } + static sizeOf() { + return 32; + } + static createVec3(builder, x, y, z, test1, test2, test3_a, test3_b) { + builder.prep(8, 32); + builder.pad(2); + builder.prep(2, 4); + builder.pad(1); + builder.writeInt8(test3_b); + builder.writeInt16(test3_a); + builder.pad(1); + builder.writeInt8(test2); + builder.writeFloat64(test1); + builder.pad(4); + builder.writeFloat32(z); + builder.writeFloat32(y); + builder.writeFloat32(x); + return builder.offset(); + } + unpack() { + return new Vec3T(this.x(), this.y(), this.z(), this.test1(), this.test2(), (this.test3() !== null ? this.test3().unpack() : null)); + } + unpackTo(_o) { + _o.x = this.x(); + _o.y = this.y(); + _o.z = this.z(); + _o.test1 = this.test1(); + _o.test2 = this.test2(); + _o.test3 = (this.test3() !== null ? this.test3().unpack() : null); + } +} +export class Vec3T { + constructor(x = 0.0, y = 0.0, z = 0.0, test1 = 0.0, test2 = 0, test3 = null) { + this.x = x; + this.y = y; + this.z = z; + this.test1 = test1; + this.test2 = test2; + this.test3 = test3; + } + pack(builder) { + return Vec3.createVec3(builder, this.x, this.y, this.z, this.test1, this.test2, (this.test3 === null ? 0 : this.test3.a), (this.test3 === null ? 0 : this.test3.b)); + } +} diff --git a/tests/my-game/example/vec3.ts b/tests/my-game/example/vec3.ts index eafc147b..9756977d 100644 --- a/tests/my-game/example/vec3.ts +++ b/tests/my-game/example/vec3.ts @@ -64,6 +64,10 @@ test3(obj?:Test):Test|null { return (obj || new Test()).__init(this.bb_pos + 26, this.bb!); } +static getFullyQualifiedName():string { + return 'MyGame.Example.Vec3'; +} + static sizeOf():number { return 32; } diff --git a/tests/my-game/example2/monster.js b/tests/my-game/example2/monster.js new file mode 100644 index 00000000..17f02b11 --- /dev/null +++ b/tests/my-game/example2/monster.js @@ -0,0 +1,50 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class Monster { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsMonster(bb, obj) { + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsMonster(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getFullyQualifiedName() { + return 'MyGame.Example2.Monster'; + } + static startMonster(builder) { + builder.startObject(0); + } + static endMonster(builder) { + const offset = builder.endObject(); + return offset; + } + static createMonster(builder) { + Monster.startMonster(builder); + return Monster.endMonster(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new MonsterT(); + } + unpackTo(_o) { } +} +export class MonsterT { + constructor() { } + pack(builder) { + return Monster.createMonster(builder); + } +} diff --git a/tests/my-game/example2/monster.ts b/tests/my-game/example2/monster.ts index d1aca42c..14d7685f 100644 --- a/tests/my-game/example2/monster.ts +++ b/tests/my-game/example2/monster.ts @@ -22,6 +22,10 @@ static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Mon return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } +static getFullyQualifiedName():string { + return 'MyGame.Example2.Monster'; +} + static startMonster(builder:flatbuffers.Builder) { builder.startObject(0); } diff --git a/tests/my-game/in-parent-namespace.js b/tests/my-game/in-parent-namespace.js new file mode 100644 index 00000000..48817411 --- /dev/null +++ b/tests/my-game/in-parent-namespace.js @@ -0,0 +1,50 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class InParentNamespace { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsInParentNamespace(bb, obj) { + return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsInParentNamespace(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getFullyQualifiedName() { + return 'MyGame.InParentNamespace'; + } + static startInParentNamespace(builder) { + builder.startObject(0); + } + static endInParentNamespace(builder) { + const offset = builder.endObject(); + return offset; + } + static createInParentNamespace(builder) { + InParentNamespace.startInParentNamespace(builder); + return InParentNamespace.endInParentNamespace(builder); + } + serialize() { + return this.bb.bytes(); + } + static deserialize(buffer) { + return InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer)); + } + unpack() { + return new InParentNamespaceT(); + } + unpackTo(_o) { } +} +export class InParentNamespaceT { + constructor() { } + pack(builder) { + return InParentNamespace.createInParentNamespace(builder); + } +} diff --git a/tests/my-game/in-parent-namespace.ts b/tests/my-game/in-parent-namespace.ts index 9cb46c01..8cfe9b60 100644 --- a/tests/my-game/in-parent-namespace.ts +++ b/tests/my-game/in-parent-namespace.ts @@ -22,6 +22,10 @@ static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:In return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } +static getFullyQualifiedName():string { + return 'MyGame.InParentNamespace'; +} + static startInParentNamespace(builder:flatbuffers.Builder) { builder.startObject(0); } diff --git a/tests/namespace_test/namespace_test1_generated.js b/tests/namespace_test/namespace_test1_generated.js deleted file mode 100644 index 7331f64e..00000000 --- a/tests/namespace_test/namespace_test1_generated.js +++ /dev/null @@ -1,229 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @const - * @namespace - */ -var NamespaceA = NamespaceA || {}; - -/** - * @const - * @namespace - */ -NamespaceA.NamespaceB = NamespaceA.NamespaceB || {}; - -/** - * @enum {number} - */ -NamespaceA.NamespaceB.EnumInNestedNS = { - A: 0, - B: 1, - C: 2 -}; - -/** - * @enum {string} - */ -NamespaceA.NamespaceB.EnumInNestedNSName = { - '0': 'A', - '1': 'B', - '2': 'C' -}; - -/** - * @constructor - */ -NamespaceA.NamespaceB.TableInNestedNS = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {NamespaceA.NamespaceB.TableInNestedNS} - */ -NamespaceA.NamespaceB.TableInNestedNS.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {NamespaceA.NamespaceB.TableInNestedNS=} obj - * @returns {NamespaceA.NamespaceB.TableInNestedNS} - */ -NamespaceA.NamespaceB.TableInNestedNS.getRootAsTableInNestedNS = function(bb, obj) { - 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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new NamespaceA.NamespaceB.TableInNestedNS).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns {number} - */ -NamespaceA.NamespaceB.TableInNestedNS.prototype.foo = function() { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -NamespaceA.NamespaceB.TableInNestedNS.prototype.mutate_foo = function(value) { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {string} - */ -NamespaceA.NamespaceB.TableInNestedNS.getFullyQualifiedName = function() { - return 'NamespaceA.NamespaceB.TableInNestedNS'; -} - -/** - * @param {flatbuffers.Builder} builder - */ -NamespaceA.NamespaceB.TableInNestedNS.startTableInNestedNS = function(builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} foo - */ -NamespaceA.NamespaceB.TableInNestedNS.addFoo = function(builder, foo) { - builder.addFieldInt32(0, foo, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -NamespaceA.NamespaceB.TableInNestedNS.endTableInNestedNS = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} foo - * @returns {flatbuffers.Offset} - */ -NamespaceA.NamespaceB.TableInNestedNS.createTableInNestedNS = function(builder, foo) { - NamespaceA.NamespaceB.TableInNestedNS.startTableInNestedNS(builder); - NamespaceA.NamespaceB.TableInNestedNS.addFoo(builder, foo); - return NamespaceA.NamespaceB.TableInNestedNS.endTableInNestedNS(builder); -} - -/** - * @constructor - */ -NamespaceA.NamespaceB.StructInNestedNS = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {NamespaceA.NamespaceB.StructInNestedNS} - */ -NamespaceA.NamespaceB.StructInNestedNS.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -NamespaceA.NamespaceB.StructInNestedNS.prototype.a = function() { - return this.bb.readInt32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -NamespaceA.NamespaceB.StructInNestedNS.prototype.mutate_a = function(value) { - this.bb.writeInt32(this.bb_pos + 0, value); - return true; -}; - -/** - * @returns {number} - */ -NamespaceA.NamespaceB.StructInNestedNS.prototype.b = function() { - return this.bb.readInt32(this.bb_pos + 4); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -NamespaceA.NamespaceB.StructInNestedNS.prototype.mutate_b = function(value) { - this.bb.writeInt32(this.bb_pos + 4, value); - return true; -}; - -/** - * @returns {string} - */ -NamespaceA.NamespaceB.StructInNestedNS.getFullyQualifiedName = function() { - return 'NamespaceA.NamespaceB.StructInNestedNS'; -} - -/** - * @returns {number} - */ -NamespaceA.NamespaceB.StructInNestedNS.sizeOf = function() { - return 8; -} - -/** - * @param {flatbuffers.Builder} builder - * @param {number} a - * @param {number} b - * @returns {flatbuffers.Offset} - */ -NamespaceA.NamespaceB.StructInNestedNS.createStructInNestedNS = function(builder, a, b) { - builder.prep(4, 8); - builder.writeInt32(b); - builder.writeInt32(a); - return builder.offset(); -}; - -// Exports for Node.js and RequireJS -this.NamespaceA = NamespaceA; diff --git a/tests/namespace_test/namespace_test1_generated.ts b/tests/namespace_test/namespace_test1_generated.ts deleted file mode 100644 index 933a43d2..00000000 --- a/tests/namespace_test/namespace_test1_generated.ts +++ /dev/null @@ -1,269 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @enum {number} - */ -export namespace NamespaceA.NamespaceB{ -export enum EnumInNestedNS{ - A= 0, - B= 1, - C= 2 -}; -} - -/** - * @constructor - */ -export namespace NamespaceA.NamespaceB{ -export class TableInNestedNS { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns TableInNestedNS - */ -__init(i:number, bb:flatbuffers.ByteBuffer):TableInNestedNS { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param TableInNestedNS= obj - * @returns TableInNestedNS - */ -static getRootAsTableInNestedNS(bb:flatbuffers.ByteBuffer, obj?:TableInNestedNS):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 { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TableInNestedNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns number - */ -foo():number { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param number value - * @returns boolean - */ -mutate_foo(value:number):boolean { - var offset = this.bb!.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns string - */ -static getFullyQualifiedName():string { - return 'NamespaceA.NamespaceB.TableInNestedNS'; -} - -/** - * @param flatbuffers.Builder builder - */ -static startTableInNestedNS(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param flatbuffers.Builder builder - * @param number foo - */ -static addFoo(builder:flatbuffers.Builder, foo:number) { - builder.addFieldInt32(0, foo, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endTableInNestedNS(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createTableInNestedNS(builder:flatbuffers.Builder, foo:number):flatbuffers.Offset { - TableInNestedNS.startTableInNestedNS(builder); - TableInNestedNS.addFoo(builder, foo); - return TableInNestedNS.endTableInNestedNS(builder); -} - -/** - * @returns TableInNestedNST - */ -unpack(): TableInNestedNST { - return new TableInNestedNST( - this.foo() - ); -}; - -/** - * @param TableInNestedNST _o - */ -unpackTo(_o: TableInNestedNST): void { - _o.foo = this.foo(); -}; -} - -export class TableInNestedNST { -/** - * @constructor - * @param number foo - */ -constructor( - public foo: number = 0 -){}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return NamespaceA.NamespaceB.TableInNestedNS.createTableInNestedNS(builder, - this.foo - ); -}; -} -} -/** - * @constructor - */ -export namespace NamespaceA.NamespaceB{ -export class StructInNestedNS { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns StructInNestedNS - */ -__init(i:number, bb:flatbuffers.ByteBuffer):StructInNestedNS { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns number - */ -a():number { - return this.bb!.readInt32(this.bb_pos); -}; - -/** - * @param number value - * @returns boolean - */ -mutate_a(value:number):boolean { - this.bb!.writeInt32(this.bb_pos + 0, value); - return true; -}; - -/** - * @returns number - */ -b():number { - return this.bb!.readInt32(this.bb_pos + 4); -}; - -/** - * @param number value - * @returns boolean - */ -mutate_b(value:number):boolean { - this.bb!.writeInt32(this.bb_pos + 4, value); - return true; -}; - -/** - * @returns string - */ -static getFullyQualifiedName():string { - return 'NamespaceA.NamespaceB.StructInNestedNS'; -} - -/** - * @returns number - */ -static sizeOf():number { - return 8; -} - -/** - * @param flatbuffers.Builder builder - * @param number a - * @param number b - * @returns flatbuffers.Offset - */ -static createStructInNestedNS(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset { - builder.prep(4, 8); - builder.writeInt32(b); - builder.writeInt32(a); - return builder.offset(); -}; - - -/** - * @returns StructInNestedNST - */ -unpack(): StructInNestedNST { - return new StructInNestedNST( - this.a(), - this.b() - ); -}; - -/** - * @param StructInNestedNST _o - */ -unpackTo(_o: StructInNestedNST): void { - _o.a = this.a(); - _o.b = this.b(); -}; -} - -export class StructInNestedNST { -/** - * @constructor - * @param number a - * @param number b - */ -constructor( - public a: number = 0, - public b: number = 0 -){}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return NamespaceA.NamespaceB.StructInNestedNS.createStructInNestedNS(builder, - this.a, - this.b - ); -}; -} -} diff --git a/tests/namespace_test/namespace_test2_generated.js b/tests/namespace_test/namespace_test2_generated.js deleted file mode 100644 index 9b2668cb..00000000 --- a/tests/namespace_test/namespace_test2_generated.js +++ /dev/null @@ -1,354 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @const - * @namespace - */ -var NamespaceA = NamespaceA || {}; - -/** - * @const - * @namespace - */ -NamespaceA.NamespaceB = NamespaceA.NamespaceB || {}; - -/** - * @const - * @namespace - */ -var NamespaceC = NamespaceC || {}; - -/** - * @constructor - */ -NamespaceA.TableInFirstNS = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {NamespaceA.TableInFirstNS} - */ -NamespaceA.TableInFirstNS.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {NamespaceA.TableInFirstNS=} obj - * @returns {NamespaceA.TableInFirstNS} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new NamespaceA.TableInFirstNS).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {NamespaceA.NamespaceB.TableInNestedNS=} obj - * @returns {NamespaceA.NamespaceB.TableInNestedNS|null} - */ -NamespaceA.TableInFirstNS.prototype.fooTable = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new NamespaceA.NamespaceB.TableInNestedNS).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; -}; - -/** - * @returns {NamespaceA.NamespaceB.EnumInNestedNS} - */ -NamespaceA.TableInFirstNS.prototype.fooEnum = function() { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? /** @type {NamespaceA.NamespaceB.EnumInNestedNS} */ (this.bb.readInt8(this.bb_pos + offset)) : NamespaceA.NamespaceB.EnumInNestedNS.A; -}; - -/** - * @param {NamespaceA.NamespaceB.EnumInNestedNS} value - * @returns {boolean} - */ -NamespaceA.TableInFirstNS.prototype.mutate_foo_enum = function(value) { - var offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; -}; - -/** - * @param {NamespaceA.NamespaceB.StructInNestedNS=} obj - * @returns {NamespaceA.NamespaceB.StructInNestedNS|null} - */ -NamespaceA.TableInFirstNS.prototype.fooStruct = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? (obj || new NamespaceA.NamespaceB.StructInNestedNS).__init(this.bb_pos + offset, this.bb) : null; -}; - -/** - * @returns {string} - */ -NamespaceA.TableInFirstNS.getFullyQualifiedName = function() { - return 'NamespaceA.TableInFirstNS'; -} - -/** - * @param {flatbuffers.Builder} builder - */ -NamespaceA.TableInFirstNS.startTableInFirstNS = function(builder) { - builder.startObject(3); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} fooTableOffset - */ -NamespaceA.TableInFirstNS.addFooTable = function(builder, fooTableOffset) { - builder.addFieldOffset(0, fooTableOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {NamespaceA.NamespaceB.EnumInNestedNS} fooEnum - */ -NamespaceA.TableInFirstNS.addFooEnum = function(builder, fooEnum) { - builder.addFieldInt8(1, fooEnum, NamespaceA.NamespaceB.EnumInNestedNS.A); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} fooStructOffset - */ -NamespaceA.TableInFirstNS.addFooStruct = function(builder, fooStructOffset) { - builder.addFieldStruct(2, fooStructOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -NamespaceA.TableInFirstNS.endTableInFirstNS = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @constructor - */ -NamespaceC.TableInC = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {NamespaceC.TableInC} - */ -NamespaceC.TableInC.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {NamespaceC.TableInC=} obj - * @returns {NamespaceC.TableInC} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new NamespaceC.TableInC).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {NamespaceA.TableInFirstNS=} obj - * @returns {NamespaceA.TableInFirstNS|null} - */ -NamespaceC.TableInC.prototype.referToA1 = function(obj) { - 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; -}; - -/** - * @param {NamespaceA.SecondTableInA=} obj - * @returns {NamespaceA.SecondTableInA|null} - */ -NamespaceC.TableInC.prototype.referToA2 = function(obj) { - 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; -}; - -/** - * @returns {string} - */ -NamespaceC.TableInC.getFullyQualifiedName = function() { - return 'NamespaceC.TableInC'; -} - -/** - * @param {flatbuffers.Builder} builder - */ -NamespaceC.TableInC.startTableInC = function(builder) { - builder.startObject(2); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} referToA1Offset - */ -NamespaceC.TableInC.addReferToA1 = function(builder, referToA1Offset) { - builder.addFieldOffset(0, referToA1Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} referToA2Offset - */ -NamespaceC.TableInC.addReferToA2 = function(builder, referToA2Offset) { - builder.addFieldOffset(1, referToA2Offset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -NamespaceC.TableInC.endTableInC = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @constructor - */ -NamespaceA.SecondTableInA = function() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -}; - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {NamespaceA.SecondTableInA} - */ -NamespaceA.SecondTableInA.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {NamespaceA.SecondTableInA=} obj - * @returns {NamespaceA.SecondTableInA} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new NamespaceA.SecondTableInA).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {NamespaceC.TableInC=} obj - * @returns {NamespaceC.TableInC|null} - */ -NamespaceA.SecondTableInA.prototype.referToC = function(obj) { - 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; -}; - -/** - * @returns {string} - */ -NamespaceA.SecondTableInA.getFullyQualifiedName = function() { - return 'NamespaceA.SecondTableInA'; -} - -/** - * @param {flatbuffers.Builder} builder - */ -NamespaceA.SecondTableInA.startSecondTableInA = function(builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} referToCOffset - */ -NamespaceA.SecondTableInA.addReferToC = function(builder, referToCOffset) { - builder.addFieldOffset(0, referToCOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -NamespaceA.SecondTableInA.endSecondTableInA = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} referToCOffset - * @returns {flatbuffers.Offset} - */ -NamespaceA.SecondTableInA.createSecondTableInA = function(builder, referToCOffset) { - NamespaceA.SecondTableInA.startSecondTableInA(builder); - NamespaceA.SecondTableInA.addReferToC(builder, referToCOffset); - return NamespaceA.SecondTableInA.endSecondTableInA(builder); -} - -// Exports for Node.js and RequireJS -this.NamespaceA = NamespaceA; -this.NamespaceC = NamespaceC; diff --git a/tests/namespace_test/namespace_test2_generated.ts b/tests/namespace_test/namespace_test2_generated.ts deleted file mode 100644 index bd3c903e..00000000 --- a/tests/namespace_test/namespace_test2_generated.ts +++ /dev/null @@ -1,438 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as NS8755221360535654258 from "./namespace_test1_generated"; -/** - * @constructor - */ -export namespace NamespaceA{ -export class TableInFirstNS { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns TableInFirstNS - */ -__init(i:number, bb:flatbuffers.ByteBuffer):TableInFirstNS { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param TableInFirstNS= obj - * @returns TableInFirstNS - */ -static getRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):TableInFirstNS { - 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 { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TableInFirstNS()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param NamespaceA.NamespaceB.TableInNestedNS= obj - * @returns NamespaceA.NamespaceB.TableInNestedNS|null - */ -fooTable(obj?:NS8755221360535654258.NamespaceA.NamespaceB.TableInNestedNS):NS8755221360535654258.NamespaceA.NamespaceB.TableInNestedNS|null { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new NS8755221360535654258.NamespaceA.NamespaceB.TableInNestedNS()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -}; - -/** - * @returns NamespaceA.NamespaceB.EnumInNestedNS - */ -fooEnum():NS8755221360535654258.NamespaceA.NamespaceB.EnumInNestedNS { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? /** */ (this.bb!.readInt8(this.bb_pos + offset)) : NS8755221360535654258.NamespaceA.NamespaceB.EnumInNestedNS.A; -}; - -/** - * @param NamespaceA.NamespaceB.EnumInNestedNS value - * @returns boolean - */ -mutate_foo_enum(value:NS8755221360535654258.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); - return true; -}; - -/** - * @param NamespaceA.NamespaceB.StructInNestedNS= obj - * @returns NamespaceA.NamespaceB.StructInNestedNS|null - */ -fooStruct(obj?:NS8755221360535654258.NamespaceA.NamespaceB.StructInNestedNS):NS8755221360535654258.NamespaceA.NamespaceB.StructInNestedNS|null { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? (obj || new NS8755221360535654258.NamespaceA.NamespaceB.StructInNestedNS()).__init(this.bb_pos + offset, this.bb!) : null; -}; - -/** - * @returns string - */ -static getFullyQualifiedName():string { - return 'NamespaceA.TableInFirstNS'; -} - -/** - * @param flatbuffers.Builder builder - */ -static startTableInFirstNS(builder:flatbuffers.Builder) { - builder.startObject(3); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset fooTableOffset - */ -static addFooTable(builder:flatbuffers.Builder, fooTableOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, fooTableOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param NamespaceA.NamespaceB.EnumInNestedNS fooEnum - */ -static addFooEnum(builder:flatbuffers.Builder, fooEnum:NS8755221360535654258.NamespaceA.NamespaceB.EnumInNestedNS) { - builder.addFieldInt8(1, fooEnum, NS8755221360535654258.NamespaceA.NamespaceB.EnumInNestedNS.A); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset fooStructOffset - */ -static addFooStruct(builder:flatbuffers.Builder, fooStructOffset:flatbuffers.Offset) { - builder.addFieldStruct(2, fooStructOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endTableInFirstNS(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - - -/** - * @returns TableInFirstNST - */ -unpack(): TableInFirstNST { - return new TableInFirstNST( - (this.fooTable() !== null ? this.fooTable()!.unpack() : null), - this.fooEnum(), - (this.fooStruct() !== null ? this.fooStruct()!.unpack() : null) - ); -}; - -/** - * @param TableInFirstNST _o - */ -unpackTo(_o: TableInFirstNST): void { - _o.fooTable = (this.fooTable() !== null ? this.fooTable()!.unpack() : null); - _o.fooEnum = this.fooEnum(); - _o.fooStruct = (this.fooStruct() !== null ? this.fooStruct()!.unpack() : null); -}; -} - -export class TableInFirstNST { -/** - * @constructor - * @param NS8755221360535654258.NamespaceA.NamespaceB.TableInNestedNST|null fooTable - * @param NS8755221360535654258.NamespaceA.NamespaceB.EnumInNestedNS fooEnum - * @param NS8755221360535654258.NamespaceA.NamespaceB.StructInNestedNST|null fooStruct - */ -constructor( - public fooTable: NS8755221360535654258.NamespaceA.NamespaceB.TableInNestedNST|null = null, - public fooEnum: NS8755221360535654258.NamespaceA.NamespaceB.EnumInNestedNS = NS8755221360535654258.NamespaceA.NamespaceB.EnumInNestedNS.A, - public fooStruct: NS8755221360535654258.NamespaceA.NamespaceB.StructInNestedNST|null = null -){}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - NamespaceA.TableInFirstNS.start(builder); - NamespaceA.TableInFirstNS.addFooTable(builder, (this.fooTable !== null ? this.fooTable!.pack(builder) : 0)); - NamespaceA.TableInFirstNS.addFooEnum(builder, this.fooEnum); - NamespaceA.TableInFirstNS.addFooStruct(builder, (this.fooStruct !== null ? this.fooStruct!.pack(builder) : 0)); - - return NamespaceA.TableInFirstNS.end(builder); -}; -} -} -/** - * @constructor - */ -export namespace NamespaceC{ -export class TableInC { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns TableInC - */ -__init(i:number, bb:flatbuffers.ByteBuffer):TableInC { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param TableInC= obj - * @returns TableInC - */ -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 { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TableInC()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param NamespaceA.TableInFirstNS= obj - * @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; -}; - -/** - * @param NamespaceA.SecondTableInA= obj - * @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; -}; - -/** - * @returns string - */ -static getFullyQualifiedName():string { - return 'NamespaceC.TableInC'; -} - -/** - * @param flatbuffers.Builder builder - */ -static startTableInC(builder:flatbuffers.Builder) { - builder.startObject(2); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset referToA1Offset - */ -static addReferToA1(builder:flatbuffers.Builder, referToA1Offset:flatbuffers.Offset) { - builder.addFieldOffset(0, referToA1Offset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset referToA2Offset - */ -static addReferToA2(builder:flatbuffers.Builder, referToA2Offset:flatbuffers.Offset) { - builder.addFieldOffset(1, referToA2Offset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endTableInC(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - - -/** - * @returns TableInCT - */ -unpack(): TableInCT { - return new TableInCT( - (this.referToA1() !== null ? this.referToA1()!.unpack() : null), - (this.referToA2() !== null ? this.referToA2()!.unpack() : null) - ); -}; - -/** - * @param TableInCT _o - */ -unpackTo(_o: TableInCT): void { - _o.referToA1 = (this.referToA1() !== null ? this.referToA1()!.unpack() : null); - _o.referToA2 = (this.referToA2() !== null ? this.referToA2()!.unpack() : null); -}; -} - -export class TableInCT { -/** - * @constructor - * @param NamespaceA.TableInFirstNST|null referToA1 - * @param NamespaceA.SecondTableInAT|null referToA2 - */ -constructor( - public referToA1: NamespaceA.TableInFirstNST|null = null, - public referToA2: NamespaceA.SecondTableInAT|null = null -){}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - NamespaceC.TableInC.start(builder); - NamespaceC.TableInC.addReferToA1(builder, (this.referToA1 !== null ? this.referToA1!.pack(builder) : 0)); - NamespaceC.TableInC.addReferToA2(builder, (this.referToA2 !== null ? this.referToA2!.pack(builder) : 0)); - - return NamespaceC.TableInC.end(builder); -}; -} -} -/** - * @constructor - */ -export namespace NamespaceA{ -export class SecondTableInA { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns SecondTableInA - */ -__init(i:number, bb:flatbuffers.ByteBuffer):SecondTableInA { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param SecondTableInA= obj - * @returns SecondTableInA - */ -static getRootAsSecondTableInA(bb:flatbuffers.ByteBuffer, obj?:SecondTableInA):SecondTableInA { - 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 { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new SecondTableInA()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param NamespaceC.TableInC= obj - * @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; -}; - -/** - * @returns string - */ -static getFullyQualifiedName():string { - return 'NamespaceA.SecondTableInA'; -} - -/** - * @param flatbuffers.Builder builder - */ -static startSecondTableInA(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset referToCOffset - */ -static addReferToC(builder:flatbuffers.Builder, referToCOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, referToCOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endSecondTableInA(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createSecondTableInA(builder:flatbuffers.Builder, referToCOffset:flatbuffers.Offset):flatbuffers.Offset { - SecondTableInA.startSecondTableInA(builder); - SecondTableInA.addReferToC(builder, referToCOffset); - return SecondTableInA.endSecondTableInA(builder); -} - -/** - * @returns SecondTableInAT - */ -unpack(): SecondTableInAT { - return new SecondTableInAT( - (this.referToC() !== null ? this.referToC()!.unpack() : null) - ); -}; - -/** - * @param SecondTableInAT _o - */ -unpackTo(_o: SecondTableInAT): void { - _o.referToC = (this.referToC() !== null ? this.referToC()!.unpack() : null); -}; -} - -export class SecondTableInAT { -/** - * @constructor - * @param NamespaceC.TableInCT|null referToC - */ -constructor( - public referToC: NamespaceC.TableInCT|null = null -){}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return NamespaceA.SecondTableInA.createSecondTableInA(builder, - (this.referToC !== null ? this.referToC!.pack(builder) : 0) - ); -}; -} -} diff --git a/tests/optional_scalars/optional-byte.js b/tests/optional_scalars/optional-byte.js new file mode 100644 index 00000000..8257f93a --- /dev/null +++ b/tests/optional_scalars/optional-byte.js @@ -0,0 +1,7 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export var OptionalByte; +(function (OptionalByte) { + OptionalByte[OptionalByte["None"] = 0] = "None"; + OptionalByte[OptionalByte["One"] = 1] = "One"; + OptionalByte[OptionalByte["Two"] = 2] = "Two"; +})(OptionalByte || (OptionalByte = {})); diff --git a/tests/optional_scalars/scalar-stuff.js b/tests/optional_scalars/scalar-stuff.js new file mode 100644 index 00000000..7e6f913d --- /dev/null +++ b/tests/optional_scalars/scalar-stuff.js @@ -0,0 +1,341 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { OptionalByte } from '../optional_scalars/optional-byte'; +export class ScalarStuff { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsScalarStuff(bb, obj) { + return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsScalarStuff(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new ScalarStuff()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static bufferHasIdentifier(bb) { + return bb.__has_identifier('NULL'); + } + justI8() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readInt8(this.bb_pos + offset) : 0; + } + maybeI8() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt8(this.bb_pos + offset) : null; + } + defaultI8() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readInt8(this.bb_pos + offset) : 42; + } + justU8() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 0; + } + maybeU8() { + const offset = this.bb.__offset(this.bb_pos, 12); + return offset ? this.bb.readUint8(this.bb_pos + offset) : null; + } + defaultU8() { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint8(this.bb_pos + offset) : 42; + } + justI16() { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? this.bb.readInt16(this.bb_pos + offset) : 0; + } + maybeI16() { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? this.bb.readInt16(this.bb_pos + offset) : null; + } + defaultI16() { + const offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.readInt16(this.bb_pos + offset) : 42; + } + justU16() { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + maybeU16() { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.readUint16(this.bb_pos + offset) : null; + } + defaultU16() { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 42; + } + justI32() { + const offset = this.bb.__offset(this.bb_pos, 28); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + maybeI32() { + const offset = this.bb.__offset(this.bb_pos, 30); + return offset ? this.bb.readInt32(this.bb_pos + offset) : null; + } + defaultI32() { + const offset = this.bb.__offset(this.bb_pos, 32); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 42; + } + justU32() { + const offset = this.bb.__offset(this.bb_pos, 34); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; + } + maybeU32() { + const offset = this.bb.__offset(this.bb_pos, 36); + return offset ? this.bb.readUint32(this.bb_pos + offset) : null; + } + defaultU32() { + const offset = this.bb.__offset(this.bb_pos, 38); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 42; + } + justI64() { + const offset = this.bb.__offset(this.bb_pos, 40); + return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + maybeI64() { + const offset = this.bb.__offset(this.bb_pos, 42); + return offset ? this.bb.readInt64(this.bb_pos + offset) : null; + } + defaultI64() { + const offset = this.bb.__offset(this.bb_pos, 44); + return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(42, 0); + } + justU64() { + const offset = this.bb.__offset(this.bb_pos, 46); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + maybeU64() { + const offset = this.bb.__offset(this.bb_pos, 48); + return offset ? this.bb.readUint64(this.bb_pos + offset) : null; + } + defaultU64() { + const offset = this.bb.__offset(this.bb_pos, 50); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(42, 0); + } + justF32() { + const offset = this.bb.__offset(this.bb_pos, 52); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; + } + maybeF32() { + const offset = this.bb.__offset(this.bb_pos, 54); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : null; + } + defaultF32() { + const offset = this.bb.__offset(this.bb_pos, 56); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 42.0; + } + justF64() { + const offset = this.bb.__offset(this.bb_pos, 58); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0; + } + maybeF64() { + const offset = this.bb.__offset(this.bb_pos, 60); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : null; + } + defaultF64() { + const offset = this.bb.__offset(this.bb_pos, 62); + return offset ? this.bb.readFloat64(this.bb_pos + offset) : 42.0; + } + justBool() { + const offset = this.bb.__offset(this.bb_pos, 64); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + maybeBool() { + const offset = this.bb.__offset(this.bb_pos, 66); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : null; + } + defaultBool() { + const offset = this.bb.__offset(this.bb_pos, 68); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : true; + } + justEnum() { + const offset = this.bb.__offset(this.bb_pos, 70); + return offset ? this.bb.readInt8(this.bb_pos + offset) : OptionalByte.None; + } + maybeEnum() { + const offset = this.bb.__offset(this.bb_pos, 72); + return offset ? this.bb.readInt8(this.bb_pos + offset) : null; + } + defaultEnum() { + const offset = this.bb.__offset(this.bb_pos, 74); + return offset ? this.bb.readInt8(this.bb_pos + offset) : OptionalByte.One; + } + static startScalarStuff(builder) { + builder.startObject(36); + } + static addJustI8(builder, justI8) { + builder.addFieldInt8(0, justI8, 0); + } + static addMaybeI8(builder, maybeI8) { + builder.addFieldInt8(1, maybeI8, 0); + } + static addDefaultI8(builder, defaultI8) { + builder.addFieldInt8(2, defaultI8, 42); + } + static addJustU8(builder, justU8) { + builder.addFieldInt8(3, justU8, 0); + } + static addMaybeU8(builder, maybeU8) { + builder.addFieldInt8(4, maybeU8, 0); + } + static addDefaultU8(builder, defaultU8) { + builder.addFieldInt8(5, defaultU8, 42); + } + static addJustI16(builder, justI16) { + builder.addFieldInt16(6, justI16, 0); + } + static addMaybeI16(builder, maybeI16) { + builder.addFieldInt16(7, maybeI16, 0); + } + static addDefaultI16(builder, defaultI16) { + builder.addFieldInt16(8, defaultI16, 42); + } + static addJustU16(builder, justU16) { + builder.addFieldInt16(9, justU16, 0); + } + static addMaybeU16(builder, maybeU16) { + builder.addFieldInt16(10, maybeU16, 0); + } + static addDefaultU16(builder, defaultU16) { + builder.addFieldInt16(11, defaultU16, 42); + } + static addJustI32(builder, justI32) { + builder.addFieldInt32(12, justI32, 0); + } + static addMaybeI32(builder, maybeI32) { + builder.addFieldInt32(13, maybeI32, 0); + } + static addDefaultI32(builder, defaultI32) { + builder.addFieldInt32(14, defaultI32, 42); + } + static addJustU32(builder, justU32) { + builder.addFieldInt32(15, justU32, 0); + } + static addMaybeU32(builder, maybeU32) { + builder.addFieldInt32(16, maybeU32, 0); + } + static addDefaultU32(builder, defaultU32) { + builder.addFieldInt32(17, defaultU32, 42); + } + static addJustI64(builder, justI64) { + builder.addFieldInt64(18, justI64, builder.createLong(0, 0)); + } + static addMaybeI64(builder, maybeI64) { + builder.addFieldInt64(19, maybeI64, builder.createLong(0, 0)); + } + static addDefaultI64(builder, defaultI64) { + builder.addFieldInt64(20, defaultI64, builder.createLong(42, 0)); + } + static addJustU64(builder, justU64) { + builder.addFieldInt64(21, justU64, builder.createLong(0, 0)); + } + static addMaybeU64(builder, maybeU64) { + builder.addFieldInt64(22, maybeU64, builder.createLong(0, 0)); + } + static addDefaultU64(builder, defaultU64) { + builder.addFieldInt64(23, defaultU64, builder.createLong(42, 0)); + } + static addJustF32(builder, justF32) { + builder.addFieldFloat32(24, justF32, 0.0); + } + static addMaybeF32(builder, maybeF32) { + builder.addFieldFloat32(25, maybeF32, 0); + } + static addDefaultF32(builder, defaultF32) { + builder.addFieldFloat32(26, defaultF32, 42.0); + } + static addJustF64(builder, justF64) { + builder.addFieldFloat64(27, justF64, 0.0); + } + static addMaybeF64(builder, maybeF64) { + builder.addFieldFloat64(28, maybeF64, 0); + } + static addDefaultF64(builder, defaultF64) { + builder.addFieldFloat64(29, defaultF64, 42.0); + } + static addJustBool(builder, justBool) { + builder.addFieldInt8(30, +justBool, +false); + } + static addMaybeBool(builder, maybeBool) { + builder.addFieldInt8(31, +maybeBool, 0); + } + static addDefaultBool(builder, defaultBool) { + builder.addFieldInt8(32, +defaultBool, +true); + } + static addJustEnum(builder, justEnum) { + builder.addFieldInt8(33, justEnum, OptionalByte.None); + } + static addMaybeEnum(builder, maybeEnum) { + builder.addFieldInt8(34, maybeEnum, 0); + } + static addDefaultEnum(builder, defaultEnum) { + builder.addFieldInt8(35, defaultEnum, OptionalByte.One); + } + static endScalarStuff(builder) { + const offset = builder.endObject(); + return offset; + } + static finishScalarStuffBuffer(builder, offset) { + builder.finish(offset, 'NULL'); + } + static finishSizePrefixedScalarStuffBuffer(builder, offset) { + builder.finish(offset, 'NULL', true); + } + static createScalarStuff(builder, justI8, maybeI8, defaultI8, justU8, maybeU8, defaultU8, justI16, maybeI16, defaultI16, justU16, maybeU16, defaultU16, justI32, maybeI32, defaultI32, justU32, maybeU32, defaultU32, justI64, maybeI64, defaultI64, justU64, maybeU64, defaultU64, justF32, maybeF32, defaultF32, justF64, maybeF64, defaultF64, justBool, maybeBool, defaultBool, justEnum, maybeEnum, defaultEnum) { + ScalarStuff.startScalarStuff(builder); + ScalarStuff.addJustI8(builder, justI8); + if (maybeI8 !== null) + ScalarStuff.addMaybeI8(builder, maybeI8); + ScalarStuff.addDefaultI8(builder, defaultI8); + ScalarStuff.addJustU8(builder, justU8); + if (maybeU8 !== null) + ScalarStuff.addMaybeU8(builder, maybeU8); + ScalarStuff.addDefaultU8(builder, defaultU8); + ScalarStuff.addJustI16(builder, justI16); + if (maybeI16 !== null) + ScalarStuff.addMaybeI16(builder, maybeI16); + ScalarStuff.addDefaultI16(builder, defaultI16); + ScalarStuff.addJustU16(builder, justU16); + if (maybeU16 !== null) + ScalarStuff.addMaybeU16(builder, maybeU16); + ScalarStuff.addDefaultU16(builder, defaultU16); + ScalarStuff.addJustI32(builder, justI32); + if (maybeI32 !== null) + ScalarStuff.addMaybeI32(builder, maybeI32); + ScalarStuff.addDefaultI32(builder, defaultI32); + ScalarStuff.addJustU32(builder, justU32); + if (maybeU32 !== null) + ScalarStuff.addMaybeU32(builder, maybeU32); + ScalarStuff.addDefaultU32(builder, defaultU32); + ScalarStuff.addJustI64(builder, justI64); + if (maybeI64 !== null) + ScalarStuff.addMaybeI64(builder, maybeI64); + ScalarStuff.addDefaultI64(builder, defaultI64); + ScalarStuff.addJustU64(builder, justU64); + if (maybeU64 !== null) + ScalarStuff.addMaybeU64(builder, maybeU64); + ScalarStuff.addDefaultU64(builder, defaultU64); + ScalarStuff.addJustF32(builder, justF32); + if (maybeF32 !== null) + ScalarStuff.addMaybeF32(builder, maybeF32); + ScalarStuff.addDefaultF32(builder, defaultF32); + ScalarStuff.addJustF64(builder, justF64); + if (maybeF64 !== null) + ScalarStuff.addMaybeF64(builder, maybeF64); + ScalarStuff.addDefaultF64(builder, defaultF64); + ScalarStuff.addJustBool(builder, justBool); + if (maybeBool !== null) + ScalarStuff.addMaybeBool(builder, maybeBool); + ScalarStuff.addDefaultBool(builder, defaultBool); + ScalarStuff.addJustEnum(builder, justEnum); + if (maybeEnum !== null) + ScalarStuff.addMaybeEnum(builder, maybeEnum); + ScalarStuff.addDefaultEnum(builder, defaultEnum); + return ScalarStuff.endScalarStuff(builder); + } +} diff --git a/tests/package.json b/tests/package.json index bb9fd7c1..654e57fe 100644 --- a/tests/package.json +++ b/tests/package.json @@ -1,6 +1,7 @@ { "dependencies": { "esm": "^3.2.25", - "flatbuffers": "../" + "flatbuffers": "../", + "grpc": "^1.24.6" } } diff --git a/tests/ts/attacker.ts b/tests/ts/attacker.ts deleted file mode 100644 index cd8083d1..00000000 --- a/tests/ts/attacker.ts +++ /dev/null @@ -1,76 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class Attacker { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Attacker { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker { - return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsAttacker(bb:flatbuffers.ByteBuffer, obj?:Attacker):Attacker { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -swordAttackDamage():number { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -} - -static getFullyQualifiedName():string { - return 'Attacker'; -} - -static startAttacker(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addSwordAttackDamage(builder:flatbuffers.Builder, swordAttackDamage:number) { - builder.addFieldInt32(0, swordAttackDamage, 0); -} - -static endAttacker(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createAttacker(builder:flatbuffers.Builder, swordAttackDamage:number):flatbuffers.Offset { - Attacker.startAttacker(builder); - Attacker.addSwordAttackDamage(builder, swordAttackDamage); - return Attacker.endAttacker(builder); -} - -unpack(): AttackerT { - return new AttackerT( - this.swordAttackDamage() - ); -} - - -unpackTo(_o: AttackerT): void { - _o.swordAttackDamage = this.swordAttackDamage(); -} -} - -export class AttackerT { -constructor( - public swordAttackDamage: number = 0 -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return Attacker.createAttacker(builder, - this.swordAttackDamage - ); -} -} diff --git a/tests/ts/book-reader.ts b/tests/ts/book-reader.ts deleted file mode 100644 index f8fb0169..00000000 --- a/tests/ts/book-reader.ts +++ /dev/null @@ -1,58 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class BookReader { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):BookReader { - this.bb_pos = i; - this.bb = bb; - return this; -} - -booksRead():number { - return this.bb!.readInt32(this.bb_pos); -} - -static getFullyQualifiedName():string { - return 'BookReader'; -} - -static sizeOf():number { - return 4; -} - -static createBookReader(builder:flatbuffers.Builder, books_read: number):flatbuffers.Offset { - builder.prep(4, 4); - builder.writeInt32(books_read); - return builder.offset(); -} - - -unpack(): BookReaderT { - return new BookReaderT( - this.booksRead() - ); -} - - -unpackTo(_o: BookReaderT): void { - _o.booksRead = this.booksRead(); -} -} - -export class BookReaderT { -constructor( - public booksRead: number = 0 -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return BookReader.createBookReader(builder, - this.booksRead - ); -} -} diff --git a/tests/ts/character.ts b/tests/ts/character.ts deleted file mode 100644 index dbf8d51d..00000000 --- a/tests/ts/character.ts +++ /dev/null @@ -1,50 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { Attacker, AttackerT } from './attacker'; -import { BookReader, BookReaderT } from './book-reader'; -import { Rapunzel, RapunzelT } from './rapunzel'; - - -export enum Character{ - NONE = 0, - MuLan = 1, - Rapunzel = 2, - Belle = 3, - BookFan = 4, - Other = 5, - Unused = 6 -} - -export function unionToCharacter( - type: Character, - accessor: (obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null -): Attacker|BookReader|Rapunzel|string|null { - switch(Character[type]) { - case 'NONE': return null; - case 'MuLan': return accessor(new Attacker())! as Attacker; - case 'Rapunzel': return accessor(new Rapunzel())! as Rapunzel; - case 'Belle': return accessor(new BookReader())! as BookReader; - case 'BookFan': return accessor(new BookReader())! as BookReader; - case 'Other': return accessor('') as string; - case 'Unused': return accessor('') as string; - default: return null; - } -} - -export function unionListToCharacter( - type: Character, - accessor: (index: number, obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null, - index: number -): Attacker|BookReader|Rapunzel|string|null { - switch(Character[type]) { - case 'NONE': return null; - case 'MuLan': return accessor(index, new Attacker())! as Attacker; - case 'Rapunzel': return accessor(index, new Rapunzel())! as Rapunzel; - case 'Belle': return accessor(index, new BookReader())! as BookReader; - case 'BookFan': return accessor(index, new BookReader())! as BookReader; - case 'Other': return accessor(index, '') as string; - case 'Unused': return accessor(index, '') as string; - default: return null; - } -} - diff --git a/tests/ts/movie.ts b/tests/ts/movie.ts deleted file mode 100644 index b3e83819..00000000 --- a/tests/ts/movie.ts +++ /dev/null @@ -1,211 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { Attacker, AttackerT } from './attacker'; -import { BookReader, BookReaderT } from './book-reader'; -import { Character, unionToCharacter, unionListToCharacter } from './character'; -import { Rapunzel, RapunzelT } from './rapunzel'; - - -export class Movie { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Movie { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie { - return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsMovie(bb:flatbuffers.ByteBuffer, obj?:Movie):Movie { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { - return bb.__has_identifier('MOVI'); -} - -mainCharacterType():Character { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : Character.NONE; -} - -mainCharacter<T extends flatbuffers.Table>(obj:any|string):any|string|null { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__union_with_string(obj, this.bb_pos + offset) : null; -} - -charactersType(index: number):Character|null { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; -} - -charactersTypeLength():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -charactersTypeArray():Uint8Array|null { - const 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; -} - -characters(index: number, obj:any|string):any|string|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__union_with_string(obj, this.bb!.__vector(this.bb_pos + offset) + index * 4) : null; -} - -charactersLength():number { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -static getFullyQualifiedName():string { - return 'Movie'; -} - -static startMovie(builder:flatbuffers.Builder) { - builder.startObject(4); -} - -static addMainCharacterType(builder:flatbuffers.Builder, mainCharacterType:Character) { - builder.addFieldInt8(0, mainCharacterType, Character.NONE); -} - -static addMainCharacter(builder:flatbuffers.Builder, mainCharacterOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, mainCharacterOffset, 0); -} - -static addCharactersType(builder:flatbuffers.Builder, charactersTypeOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, charactersTypeOffset, 0); -} - -static createCharactersTypeVector(builder:flatbuffers.Builder, data:Character[]):flatbuffers.Offset { - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]!); - } - return builder.endVector(); -} - -static startCharactersTypeVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -} - -static addCharacters(builder:flatbuffers.Builder, charactersOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, charactersOffset, 0); -} - -static createCharactersVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startCharactersVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static endMovie(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static finishMovieBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, 'MOVI'); -} - -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); - Movie.addMainCharacter(builder, mainCharacterOffset); - Movie.addCharactersType(builder, charactersTypeOffset); - Movie.addCharacters(builder, charactersOffset); - return Movie.endMovie(builder); -} - -unpack(): MovieT { - return new MovieT( - this.mainCharacterType(), - (() => { - let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); - if(temp === null) { return null; } - if(typeof temp === 'string') { return temp; } - return temp.unpack() - })(), - this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), - (() => { - let ret = []; - for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { - let targetEnum = this.charactersType(targetEnumIndex); - if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; } - - let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); - if(temp === null) { continue; } - if(typeof temp === 'string') { ret.push(temp); continue; } - ret.push(temp.unpack()); - } - return ret; - })() - ); -} - - -unpackTo(_o: MovieT): void { - _o.mainCharacterType = this.mainCharacterType(); - _o.mainCharacter = (() => { - let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); - if(temp === null) { return null; } - if(typeof temp === 'string') { return temp; } - return temp.unpack() - })(); - _o.charactersType = this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()); - _o.characters = (() => { - let ret = []; - for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { - let targetEnum = this.charactersType(targetEnumIndex); - if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; } - - let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); - if(temp === null) { continue; } - if(typeof temp === 'string') { ret.push(temp); continue; } - ret.push(temp.unpack()); - } - return ret; - })(); -} -} - -export class MovieT { -constructor( - public mainCharacterType: Character = Character.NONE, - public mainCharacter: AttackerT|BookReaderT|RapunzelT|string|null = null, - public charactersType: (Character)[] = [], - public characters: (AttackerT|BookReaderT|RapunzelT|string)[] = [] -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const mainCharacter = builder.createObjectOffset(this.mainCharacter); - const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType); - const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters)); - - return Movie.createMovie(builder, - this.mainCharacterType, - mainCharacter, - charactersType, - characters - ); -} -} diff --git a/tests/ts/my-game/example/ability.ts b/tests/ts/my-game/example/ability.ts deleted file mode 100644 index 26395fba..00000000 --- a/tests/ts/my-game/example/ability.ts +++ /dev/null @@ -1,77 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class Ability { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Ability { - this.bb_pos = i; - this.bb = bb; - return this; -} - -id():number { - return this.bb!.readUint32(this.bb_pos); -} - -mutate_id(value:number):boolean { - this.bb!.writeUint32(this.bb_pos + 0, value); - return true; -} - -distance():number { - return this.bb!.readUint32(this.bb_pos + 4); -} - -mutate_distance(value:number):boolean { - this.bb!.writeUint32(this.bb_pos + 4, value); - return true; -} - -static getFullyQualifiedName():string { - return 'MyGame.Example.Ability'; -} - -static sizeOf():number { - return 8; -} - -static createAbility(builder:flatbuffers.Builder, id: number, distance: number):flatbuffers.Offset { - builder.prep(4, 8); - builder.writeInt32(distance); - builder.writeInt32(id); - return builder.offset(); -} - - -unpack(): AbilityT { - return new AbilityT( - this.id(), - this.distance() - ); -} - - -unpackTo(_o: AbilityT): void { - _o.id = this.id(); - _o.distance = this.distance(); -} -} - -export class AbilityT { -constructor( - public id: number = 0, - public distance: number = 0 -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return Ability.createAbility(builder, - this.id, - this.distance - ); -} -} diff --git a/tests/ts/my-game/example/any-ambiguous-aliases.ts b/tests/ts/my-game/example/any-ambiguous-aliases.ts deleted file mode 100644 index 6687a419..00000000 --- a/tests/ts/my-game/example/any-ambiguous-aliases.ts +++ /dev/null @@ -1,39 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { Monster, MonsterT } from '../../my-game/example/monster'; - - -export enum AnyAmbiguousAliases{ - NONE = 0, - M1 = 1, - M2 = 2, - M3 = 3 -} - -export function unionToAnyAmbiguousAliases( - type: AnyAmbiguousAliases, - accessor: (obj:Monster) => Monster|null -): Monster|null { - switch(AnyAmbiguousAliases[type]) { - case 'NONE': return null; - case 'M1': return accessor(new Monster())! as Monster; - case 'M2': return accessor(new Monster())! as Monster; - case 'M3': return accessor(new Monster())! as Monster; - default: return null; - } -} - -export function unionListToAnyAmbiguousAliases( - type: AnyAmbiguousAliases, - accessor: (index: number, obj:Monster) => Monster|null, - index: number -): Monster|null { - switch(AnyAmbiguousAliases[type]) { - case 'NONE': return null; - case 'M1': return accessor(index, new Monster())! as Monster; - case 'M2': return accessor(index, new Monster())! as Monster; - case 'M3': return accessor(index, new Monster())! as Monster; - default: return null; - } -} - diff --git a/tests/ts/my-game/example/any-unique-aliases.ts b/tests/ts/my-game/example/any-unique-aliases.ts deleted file mode 100644 index 51061488..00000000 --- a/tests/ts/my-game/example/any-unique-aliases.ts +++ /dev/null @@ -1,41 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from '../../my-game/example2/monster'; -import { Monster, MonsterT } from '../../my-game/example/monster'; -import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum'; - - -export enum AnyUniqueAliases{ - NONE = 0, - M = 1, - TS = 2, - M2 = 3 -} - -export function unionToAnyUniqueAliases( - type: AnyUniqueAliases, - accessor: (obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null -): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null { - switch(AnyUniqueAliases[type]) { - case 'NONE': return null; - case 'M': return accessor(new Monster())! as Monster; - case 'TS': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum; - case 'M2': return accessor(new MyGameExample2Monster())! as MyGameExample2Monster; - default: return null; - } -} - -export function unionListToAnyUniqueAliases( - type: AnyUniqueAliases, - accessor: (index: number, obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null, - index: number -): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null { - switch(AnyUniqueAliases[type]) { - case 'NONE': return null; - case 'M': return accessor(index, new Monster())! as Monster; - case 'TS': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum; - case 'M2': return accessor(index, new MyGameExample2Monster())! as MyGameExample2Monster; - default: return null; - } -} - diff --git a/tests/ts/my-game/example/any.ts b/tests/ts/my-game/example/any.ts deleted file mode 100644 index 9d8b2a61..00000000 --- a/tests/ts/my-game/example/any.ts +++ /dev/null @@ -1,41 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from '../../my-game/example2/monster'; -import { Monster, MonsterT } from '../../my-game/example/monster'; -import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum'; - - -export enum Any{ - NONE = 0, - Monster = 1, - TestSimpleTableWithEnum = 2, - MyGame_Example2_Monster = 3 -} - -export function unionToAny( - type: Any, - accessor: (obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null -): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null { - switch(Any[type]) { - case 'NONE': return null; - case 'Monster': return accessor(new Monster())! as Monster; - case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum; - case 'MyGame_Example2_Monster': return accessor(new MyGameExample2Monster())! as MyGameExample2Monster; - default: return null; - } -} - -export function unionListToAny( - type: Any, - accessor: (index: number, obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null, - index: number -): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null { - switch(Any[type]) { - case 'NONE': return null; - case 'Monster': return accessor(index, new Monster())! as Monster; - case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum; - case 'MyGame_Example2_Monster': return accessor(index, new MyGameExample2Monster())! as MyGameExample2Monster; - default: return null; - } -} - diff --git a/tests/ts/my-game/example/color.ts b/tests/ts/my-game/example/color.ts deleted file mode 100644 index ceb31f82..00000000 --- a/tests/ts/my-game/example/color.ts +++ /dev/null @@ -1,20 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * Composite components of Monster color. - */ -export enum Color{ - Red = 1, - - /** - * \brief color Green - * Green is bit_flag with value (1u << 1) - */ - Green = 2, - - /** - * \brief color Blue (1u << 3) - */ - Blue = 8 -} - diff --git a/tests/ts/my-game/example/monster.ts b/tests/ts/my-game/example/monster.ts deleted file mode 100644 index b4ee6e3f..00000000 --- a/tests/ts/my-game/example/monster.ts +++ /dev/null @@ -1,1373 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from '../../my-game/example2/monster'; -import { Ability, AbilityT } from '../../my-game/example/ability'; -import { Any, unionToAny, unionListToAny } from '../../my-game/example/any'; -import { AnyAmbiguousAliases, unionToAnyAmbiguousAliases, unionListToAnyAmbiguousAliases } from '../../my-game/example/any-ambiguous-aliases'; -import { AnyUniqueAliases, unionToAnyUniqueAliases, unionListToAnyUniqueAliases } from '../../my-game/example/any-unique-aliases'; -import { Color } from '../../my-game/example/color'; -import { Race } from '../../my-game/example/race'; -import { Referrable, ReferrableT } from '../../my-game/example/referrable'; -import { Stat, StatT } from '../../my-game/example/stat'; -import { Test, TestT } from '../../my-game/example/test'; -import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum'; -import { Vec3, Vec3T } from '../../my-game/example/vec3'; -import { InParentNamespace, InParentNamespaceT } from '../../my-game/in-parent-namespace'; - - -/** - * an example documentation comment: "monster object" - */ -export class Monster { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Monster { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster { - return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { - return bb.__has_identifier('MONS'); -} - -pos(obj?:Vec3):Vec3|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? (obj || new Vec3()).__init(this.bb_pos + offset, this.bb!) : null; -} - -mana():number { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.readInt16(this.bb_pos + offset) : 150; -} - -mutate_mana(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt16(this.bb_pos + offset, value); - return true; -} - -hp():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readInt16(this.bb_pos + offset) : 100; -} - -mutate_hp(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt16(this.bb_pos + offset, value); - return true; -} - -name():string|null -name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -name(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -inventory(index: number):number|null { - const offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; -} - -inventoryLength():number { - const offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -inventoryArray():Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 14); - 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; -} - -color():Color { - const offset = this.bb!.__offset(this.bb_pos, 16); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : Color.Blue; -} - -mutate_color(value:Color):boolean { - const offset = this.bb!.__offset(this.bb_pos, 16); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint8(this.bb_pos + offset, value); - return true; -} - -testType():Any { - const offset = this.bb!.__offset(this.bb_pos, 18); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : Any.NONE; -} - -test<T extends flatbuffers.Table>(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 20); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -test4(index: number, obj?:Test):Test|null { - const offset = this.bb!.__offset(this.bb_pos, 22); - return offset ? (obj || new Test()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 4, this.bb!) : null; -} - -test4Length():number { - const offset = this.bb!.__offset(this.bb_pos, 22); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -testarrayofstring(index: number):string -testarrayofstring(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array -testarrayofstring(index: number,optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 24); - return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; -} - -testarrayofstringLength():number { - const offset = this.bb!.__offset(this.bb_pos, 24); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -/** - * an example documentation comment: this will end up in the generated code - * multiline too - */ -testarrayoftables(index: number, obj?:Monster):Monster|null { - const offset = this.bb!.__offset(this.bb_pos, 26); - return offset ? (obj || new Monster()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -} - -testarrayoftablesLength():number { - const offset = this.bb!.__offset(this.bb_pos, 26); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -enemy(obj?:Monster):Monster|null { - const offset = this.bb!.__offset(this.bb_pos, 28); - return offset ? (obj || new Monster()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -testnestedflatbuffer(index: number):number|null { - const offset = this.bb!.__offset(this.bb_pos, 30); - return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; -} - -testnestedflatbufferLength():number { - const offset = this.bb!.__offset(this.bb_pos, 30); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -testnestedflatbufferArray():Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 30); - 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; -} - -testempty(obj?:Stat):Stat|null { - const offset = this.bb!.__offset(this.bb_pos, 32); - return offset ? (obj || new Stat()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -testbool():boolean { - const offset = this.bb!.__offset(this.bb_pos, 34); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -} - -mutate_testbool(value:boolean):boolean { - const offset = this.bb!.__offset(this.bb_pos, 34); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt8(this.bb_pos + offset, +value); - return true; -} - -testhashs32Fnv1():number { - const offset = this.bb!.__offset(this.bb_pos, 36); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -} - -mutate_testhashs32_fnv1(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 36); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt32(this.bb_pos + offset, value); - return true; -} - -testhashu32Fnv1():number { - const offset = this.bb!.__offset(this.bb_pos, 38); - return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; -} - -mutate_testhashu32_fnv1(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 38); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint32(this.bb_pos + offset, value); - return true; -} - -testhashs64Fnv1():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 40); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_testhashs64_fnv1(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 40); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt64(this.bb_pos + offset, value); - return true; -} - -testhashu64Fnv1():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 42); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_testhashu64_fnv1(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 42); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint64(this.bb_pos + offset, value); - return true; -} - -testhashs32Fnv1a():number { - const offset = this.bb!.__offset(this.bb_pos, 44); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -} - -mutate_testhashs32_fnv1a(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 44); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt32(this.bb_pos + offset, value); - return true; -} - -testhashu32Fnv1a():number { - const offset = this.bb!.__offset(this.bb_pos, 46); - return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; -} - -mutate_testhashu32_fnv1a(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 46); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint32(this.bb_pos + offset, value); - return true; -} - -testhashs64Fnv1a():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 48); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_testhashs64_fnv1a(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 48); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt64(this.bb_pos + offset, value); - return true; -} - -testhashu64Fnv1a():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 50); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_testhashu64_fnv1a(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 50); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint64(this.bb_pos + offset, value); - return true; -} - -testarrayofbools(index: number):boolean|null { - const offset = this.bb!.__offset(this.bb_pos, 52); - return offset ? !!this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index) : false; -} - -testarrayofboolsLength():number { - const offset = this.bb!.__offset(this.bb_pos, 52); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -testarrayofboolsArray():Int8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 52); - return offset ? new Int8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; -} - -testf():number { - const offset = this.bb!.__offset(this.bb_pos, 54); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 3.14159; -} - -mutate_testf(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 54); - - if (offset === 0) { - return false; - } - - this.bb!.writeFloat32(this.bb_pos + offset, value); - return true; -} - -testf2():number { - const offset = this.bb!.__offset(this.bb_pos, 56); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 3.0; -} - -mutate_testf2(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 56); - - if (offset === 0) { - return false; - } - - this.bb!.writeFloat32(this.bb_pos + offset, value); - return true; -} - -testf3():number { - const offset = this.bb!.__offset(this.bb_pos, 58); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0; -} - -mutate_testf3(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 58); - - if (offset === 0) { - return false; - } - - this.bb!.writeFloat32(this.bb_pos + offset, value); - return true; -} - -testarrayofstring2(index: number):string -testarrayofstring2(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array -testarrayofstring2(index: number,optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 60); - return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; -} - -testarrayofstring2Length():number { - const offset = this.bb!.__offset(this.bb_pos, 60); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -testarrayofsortedstruct(index: number, obj?:Ability):Ability|null { - const offset = this.bb!.__offset(this.bb_pos, 62); - return offset ? (obj || new Ability()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 8, this.bb!) : null; -} - -testarrayofsortedstructLength():number { - const offset = this.bb!.__offset(this.bb_pos, 62); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -flex(index: number):number|null { - const offset = this.bb!.__offset(this.bb_pos, 64); - return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; -} - -flexLength():number { - const offset = this.bb!.__offset(this.bb_pos, 64); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -flexArray():Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 64); - 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; -} - -test5(index: number, obj?:Test):Test|null { - const offset = this.bb!.__offset(this.bb_pos, 66); - return offset ? (obj || new Test()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 4, this.bb!) : null; -} - -test5Length():number { - const offset = this.bb!.__offset(this.bb_pos, 66); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -vectorOfLongs(index: number):flatbuffers.Long|null { - const offset = this.bb!.__offset(this.bb_pos, 68); - return offset ? this.bb!.readInt64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0); -} - -vectorOfLongsLength():number { - const offset = this.bb!.__offset(this.bb_pos, 68); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -vectorOfDoubles(index: number):number|null { - const offset = this.bb!.__offset(this.bb_pos, 70); - return offset ? this.bb!.readFloat64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : 0; -} - -vectorOfDoublesLength():number { - const offset = this.bb!.__offset(this.bb_pos, 70); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -vectorOfDoublesArray():Float64Array|null { - const offset = this.bb!.__offset(this.bb_pos, 70); - return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; -} - -parentNamespaceTest(obj?:InParentNamespace):InParentNamespace|null { - const offset = this.bb!.__offset(this.bb_pos, 72); - return offset ? (obj || new InParentNamespace()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -} - -vectorOfReferrables(index: number, obj?:Referrable):Referrable|null { - const offset = this.bb!.__offset(this.bb_pos, 74); - return offset ? (obj || new Referrable()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -} - -vectorOfReferrablesLength():number { - const offset = this.bb!.__offset(this.bb_pos, 74); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -singleWeakReference():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 76); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_single_weak_reference(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 76); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint64(this.bb_pos + offset, value); - return true; -} - -vectorOfWeakReferences(index: number):flatbuffers.Long|null { - const offset = this.bb!.__offset(this.bb_pos, 78); - return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0); -} - -vectorOfWeakReferencesLength():number { - const offset = this.bb!.__offset(this.bb_pos, 78); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -vectorOfStrongReferrables(index: number, obj?:Referrable):Referrable|null { - const offset = this.bb!.__offset(this.bb_pos, 80); - return offset ? (obj || new Referrable()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -} - -vectorOfStrongReferrablesLength():number { - const offset = this.bb!.__offset(this.bb_pos, 80); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -coOwningReference():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 82); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_co_owning_reference(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 82); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint64(this.bb_pos + offset, value); - return true; -} - -vectorOfCoOwningReferences(index: number):flatbuffers.Long|null { - const offset = this.bb!.__offset(this.bb_pos, 84); - return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0); -} - -vectorOfCoOwningReferencesLength():number { - const offset = this.bb!.__offset(this.bb_pos, 84); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -nonOwningReference():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 86); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_non_owning_reference(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 86); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint64(this.bb_pos + offset, value); - return true; -} - -vectorOfNonOwningReferences(index: number):flatbuffers.Long|null { - const offset = this.bb!.__offset(this.bb_pos, 88); - return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : this.bb!.createLong(0, 0); -} - -vectorOfNonOwningReferencesLength():number { - const offset = this.bb!.__offset(this.bb_pos, 88); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -anyUniqueType():AnyUniqueAliases { - const offset = this.bb!.__offset(this.bb_pos, 90); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : AnyUniqueAliases.NONE; -} - -anyUnique<T extends flatbuffers.Table>(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 92); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -anyAmbiguousType():AnyAmbiguousAliases { - const offset = this.bb!.__offset(this.bb_pos, 94); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : AnyAmbiguousAliases.NONE; -} - -anyAmbiguous<T extends flatbuffers.Table>(obj:any):any|null { - const offset = this.bb!.__offset(this.bb_pos, 96); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -} - -vectorOfEnums(index: number):Color|null { - const offset = this.bb!.__offset(this.bb_pos, 98); - return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; -} - -vectorOfEnumsLength():number { - const offset = this.bb!.__offset(this.bb_pos, 98); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -vectorOfEnumsArray():Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 98); - 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; -} - -signedEnum():Race { - const offset = this.bb!.__offset(this.bb_pos, 100); - return offset ? this.bb!.readInt8(this.bb_pos + offset) : Race.None; -} - -mutate_signed_enum(value:Race):boolean { - const offset = this.bb!.__offset(this.bb_pos, 100); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt8(this.bb_pos + offset, value); - return true; -} - -testrequirednestedflatbuffer(index: number):number|null { - const offset = this.bb!.__offset(this.bb_pos, 102); - return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; -} - -testrequirednestedflatbufferLength():number { - const offset = this.bb!.__offset(this.bb_pos, 102); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -testrequirednestedflatbufferArray():Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 102); - 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; -} - -scalarKeySortedTables(index: number, obj?:Stat):Stat|null { - const offset = this.bb!.__offset(this.bb_pos, 104); - return offset ? (obj || new Stat()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -} - -scalarKeySortedTablesLength():number { - const offset = this.bb!.__offset(this.bb_pos, 104); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -static getFullyQualifiedName():string { - return 'MyGame.Example.Monster'; -} - -static startMonster(builder:flatbuffers.Builder) { - builder.startObject(51); -} - -static addPos(builder:flatbuffers.Builder, posOffset:flatbuffers.Offset) { - builder.addFieldStruct(0, posOffset, 0); -} - -static addMana(builder:flatbuffers.Builder, mana:number) { - builder.addFieldInt16(1, mana, 150); -} - -static addHp(builder:flatbuffers.Builder, hp:number) { - builder.addFieldInt16(2, hp, 100); -} - -static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, nameOffset, 0); -} - -static addInventory(builder:flatbuffers.Builder, inventoryOffset:flatbuffers.Offset) { - builder.addFieldOffset(5, inventoryOffset, 0); -} - -static createInventoryVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]!); - } - return builder.endVector(); -} - -static startInventoryVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -} - -static addColor(builder:flatbuffers.Builder, color:Color) { - builder.addFieldInt8(6, color, Color.Blue); -} - -static addTestType(builder:flatbuffers.Builder, testType:Any) { - builder.addFieldInt8(7, testType, Any.NONE); -} - -static addTest(builder:flatbuffers.Builder, testOffset:flatbuffers.Offset) { - builder.addFieldOffset(8, testOffset, 0); -} - -static addTest4(builder:flatbuffers.Builder, test4Offset:flatbuffers.Offset) { - builder.addFieldOffset(9, test4Offset, 0); -} - -static startTest4Vector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 2); -} - -static addTestarrayofstring(builder:flatbuffers.Builder, testarrayofstringOffset:flatbuffers.Offset) { - builder.addFieldOffset(10, testarrayofstringOffset, 0); -} - -static createTestarrayofstringVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startTestarrayofstringVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static addTestarrayoftables(builder:flatbuffers.Builder, testarrayoftablesOffset:flatbuffers.Offset) { - builder.addFieldOffset(11, testarrayoftablesOffset, 0); -} - -static createTestarrayoftablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startTestarrayoftablesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static addEnemy(builder:flatbuffers.Builder, enemyOffset:flatbuffers.Offset) { - builder.addFieldOffset(12, enemyOffset, 0); -} - -static addTestnestedflatbuffer(builder:flatbuffers.Builder, testnestedflatbufferOffset:flatbuffers.Offset) { - builder.addFieldOffset(13, testnestedflatbufferOffset, 0); -} - -static createTestnestedflatbufferVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]!); - } - return builder.endVector(); -} - -static startTestnestedflatbufferVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -} - -static addTestempty(builder:flatbuffers.Builder, testemptyOffset:flatbuffers.Offset) { - builder.addFieldOffset(14, testemptyOffset, 0); -} - -static addTestbool(builder:flatbuffers.Builder, testbool:boolean) { - builder.addFieldInt8(15, +testbool, +false); -} - -static addTesthashs32Fnv1(builder:flatbuffers.Builder, testhashs32Fnv1:number) { - builder.addFieldInt32(16, testhashs32Fnv1, 0); -} - -static addTesthashu32Fnv1(builder:flatbuffers.Builder, testhashu32Fnv1:number) { - builder.addFieldInt32(17, testhashu32Fnv1, 0); -} - -static addTesthashs64Fnv1(builder:flatbuffers.Builder, testhashs64Fnv1:flatbuffers.Long) { - builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0)); -} - -static addTesthashu64Fnv1(builder:flatbuffers.Builder, testhashu64Fnv1:flatbuffers.Long) { - builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 0)); -} - -static addTesthashs32Fnv1a(builder:flatbuffers.Builder, testhashs32Fnv1a:number) { - builder.addFieldInt32(20, testhashs32Fnv1a, 0); -} - -static addTesthashu32Fnv1a(builder:flatbuffers.Builder, testhashu32Fnv1a:number) { - builder.addFieldInt32(21, testhashu32Fnv1a, 0); -} - -static addTesthashs64Fnv1a(builder:flatbuffers.Builder, testhashs64Fnv1a:flatbuffers.Long) { - builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0)); -} - -static addTesthashu64Fnv1a(builder:flatbuffers.Builder, testhashu64Fnv1a:flatbuffers.Long) { - builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 0)); -} - -static addTestarrayofbools(builder:flatbuffers.Builder, testarrayofboolsOffset:flatbuffers.Offset) { - builder.addFieldOffset(24, testarrayofboolsOffset, 0); -} - -static createTestarrayofboolsVector(builder:flatbuffers.Builder, data:boolean[]):flatbuffers.Offset { - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(+data[i]!); - } - return builder.endVector(); -} - -static startTestarrayofboolsVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -} - -static addTestf(builder:flatbuffers.Builder, testf:number) { - builder.addFieldFloat32(25, testf, 3.14159); -} - -static addTestf2(builder:flatbuffers.Builder, testf2:number) { - builder.addFieldFloat32(26, testf2, 3.0); -} - -static addTestf3(builder:flatbuffers.Builder, testf3:number) { - builder.addFieldFloat32(27, testf3, 0.0); -} - -static addTestarrayofstring2(builder:flatbuffers.Builder, testarrayofstring2Offset:flatbuffers.Offset) { - builder.addFieldOffset(28, testarrayofstring2Offset, 0); -} - -static createTestarrayofstring2Vector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startTestarrayofstring2Vector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static addTestarrayofsortedstruct(builder:flatbuffers.Builder, testarrayofsortedstructOffset:flatbuffers.Offset) { - builder.addFieldOffset(29, testarrayofsortedstructOffset, 0); -} - -static startTestarrayofsortedstructVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(8, numElems, 4); -} - -static addFlex(builder:flatbuffers.Builder, flexOffset:flatbuffers.Offset) { - builder.addFieldOffset(30, flexOffset, 0); -} - -static createFlexVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]!); - } - return builder.endVector(); -} - -static startFlexVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -} - -static addTest5(builder:flatbuffers.Builder, test5Offset:flatbuffers.Offset) { - builder.addFieldOffset(31, test5Offset, 0); -} - -static startTest5Vector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 2); -} - -static addVectorOfLongs(builder:flatbuffers.Builder, vectorOfLongsOffset:flatbuffers.Offset) { - builder.addFieldOffset(32, vectorOfLongsOffset, 0); -} - -static createVectorOfLongsVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset { - builder.startVector(8, data.length, 8); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt64(data[i]!); - } - return builder.endVector(); -} - -static startVectorOfLongsVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(8, numElems, 8); -} - -static addVectorOfDoubles(builder:flatbuffers.Builder, vectorOfDoublesOffset:flatbuffers.Offset) { - builder.addFieldOffset(33, vectorOfDoublesOffset, 0); -} - -static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset; -/** - * @deprecated This Uint8Array overload will be removed in the future. - */ -static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; -static createVectorOfDoublesVector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset { - builder.startVector(8, data.length, 8); - for (let i = data.length - 1; i >= 0; i--) { - builder.addFloat64(data[i]!); - } - return builder.endVector(); -} - -static startVectorOfDoublesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(8, numElems, 8); -} - -static addParentNamespaceTest(builder:flatbuffers.Builder, parentNamespaceTestOffset:flatbuffers.Offset) { - builder.addFieldOffset(34, parentNamespaceTestOffset, 0); -} - -static addVectorOfReferrables(builder:flatbuffers.Builder, vectorOfReferrablesOffset:flatbuffers.Offset) { - builder.addFieldOffset(35, vectorOfReferrablesOffset, 0); -} - -static createVectorOfReferrablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startVectorOfReferrablesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static addSingleWeakReference(builder:flatbuffers.Builder, singleWeakReference:flatbuffers.Long) { - builder.addFieldInt64(36, singleWeakReference, builder.createLong(0, 0)); -} - -static addVectorOfWeakReferences(builder:flatbuffers.Builder, vectorOfWeakReferencesOffset:flatbuffers.Offset) { - builder.addFieldOffset(37, vectorOfWeakReferencesOffset, 0); -} - -static createVectorOfWeakReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset { - builder.startVector(8, data.length, 8); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt64(data[i]!); - } - return builder.endVector(); -} - -static startVectorOfWeakReferencesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(8, numElems, 8); -} - -static addVectorOfStrongReferrables(builder:flatbuffers.Builder, vectorOfStrongReferrablesOffset:flatbuffers.Offset) { - builder.addFieldOffset(38, vectorOfStrongReferrablesOffset, 0); -} - -static createVectorOfStrongReferrablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startVectorOfStrongReferrablesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static addCoOwningReference(builder:flatbuffers.Builder, coOwningReference:flatbuffers.Long) { - builder.addFieldInt64(39, coOwningReference, builder.createLong(0, 0)); -} - -static addVectorOfCoOwningReferences(builder:flatbuffers.Builder, vectorOfCoOwningReferencesOffset:flatbuffers.Offset) { - builder.addFieldOffset(40, vectorOfCoOwningReferencesOffset, 0); -} - -static createVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset { - builder.startVector(8, data.length, 8); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt64(data[i]!); - } - return builder.endVector(); -} - -static startVectorOfCoOwningReferencesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(8, numElems, 8); -} - -static addNonOwningReference(builder:flatbuffers.Builder, nonOwningReference:flatbuffers.Long) { - builder.addFieldInt64(41, nonOwningReference, builder.createLong(0, 0)); -} - -static addVectorOfNonOwningReferences(builder:flatbuffers.Builder, vectorOfNonOwningReferencesOffset:flatbuffers.Offset) { - builder.addFieldOffset(42, vectorOfNonOwningReferencesOffset, 0); -} - -static createVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset { - builder.startVector(8, data.length, 8); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt64(data[i]!); - } - return builder.endVector(); -} - -static startVectorOfNonOwningReferencesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(8, numElems, 8); -} - -static addAnyUniqueType(builder:flatbuffers.Builder, anyUniqueType:AnyUniqueAliases) { - builder.addFieldInt8(43, anyUniqueType, AnyUniqueAliases.NONE); -} - -static addAnyUnique(builder:flatbuffers.Builder, anyUniqueOffset:flatbuffers.Offset) { - builder.addFieldOffset(44, anyUniqueOffset, 0); -} - -static addAnyAmbiguousType(builder:flatbuffers.Builder, anyAmbiguousType:AnyAmbiguousAliases) { - builder.addFieldInt8(45, anyAmbiguousType, AnyAmbiguousAliases.NONE); -} - -static addAnyAmbiguous(builder:flatbuffers.Builder, anyAmbiguousOffset:flatbuffers.Offset) { - builder.addFieldOffset(46, anyAmbiguousOffset, 0); -} - -static addVectorOfEnums(builder:flatbuffers.Builder, vectorOfEnumsOffset:flatbuffers.Offset) { - builder.addFieldOffset(47, vectorOfEnumsOffset, 0); -} - -static createVectorOfEnumsVector(builder:flatbuffers.Builder, data:Color[]):flatbuffers.Offset { - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]!); - } - return builder.endVector(); -} - -static startVectorOfEnumsVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -} - -static addSignedEnum(builder:flatbuffers.Builder, signedEnum:Race) { - builder.addFieldInt8(48, signedEnum, Race.None); -} - -static addTestrequirednestedflatbuffer(builder:flatbuffers.Builder, testrequirednestedflatbufferOffset:flatbuffers.Offset) { - builder.addFieldOffset(49, testrequirednestedflatbufferOffset, 0); -} - -static createTestrequirednestedflatbufferVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]!); - } - return builder.endVector(); -} - -static startTestrequirednestedflatbufferVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -} - -static addScalarKeySortedTables(builder:flatbuffers.Builder, scalarKeySortedTablesOffset:flatbuffers.Offset) { - builder.addFieldOffset(50, scalarKeySortedTablesOffset, 0); -} - -static createScalarKeySortedTablesVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]!); - } - return builder.endVector(); -} - -static startScalarKeySortedTablesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -} - -static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 10) // name - return offset; -} - -static finishMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, 'MONS'); -} - -static finishSizePrefixedMonsterBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, 'MONS', true); -} - - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):Monster { - return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)) -} - -unpack(): MonsterT { - return new MonsterT( - (this.pos() !== null ? this.pos()!.unpack() : null), - this.mana(), - this.hp(), - this.name(), - this.bb!.createScalarList(this.inventory.bind(this), this.inventoryLength()), - this.color(), - this.testType(), - (() => { - let temp = unionToAny(this.testType(), this.test.bind(this)); - if(temp === null) { return null; } - return temp.unpack() - })(), - this.bb!.createObjList(this.test4.bind(this), this.test4Length()), - this.bb!.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()), - this.bb!.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), - (this.enemy() !== null ? this.enemy()!.unpack() : null), - this.bb!.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), - (this.testempty() !== null ? this.testempty()!.unpack() : null), - this.testbool(), - this.testhashs32Fnv1(), - this.testhashu32Fnv1(), - this.testhashs64Fnv1(), - this.testhashu64Fnv1(), - this.testhashs32Fnv1a(), - this.testhashu32Fnv1a(), - this.testhashs64Fnv1a(), - this.testhashu64Fnv1a(), - this.bb!.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), - this.testf(), - this.testf2(), - this.testf3(), - this.bb!.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), - this.bb!.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), - this.bb!.createScalarList(this.flex.bind(this), this.flexLength()), - this.bb!.createObjList(this.test5.bind(this), this.test5Length()), - this.bb!.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), - this.bb!.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), - (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null), - this.bb!.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), - this.singleWeakReference(), - this.bb!.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), - this.bb!.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), - this.coOwningReference(), - this.bb!.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), - this.nonOwningReference(), - this.bb!.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), - this.anyUniqueType(), - (() => { - let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); - if(temp === null) { return null; } - return temp.unpack() - })(), - this.anyAmbiguousType(), - (() => { - let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); - if(temp === null) { return null; } - return temp.unpack() - })(), - this.bb!.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()), - this.signedEnum(), - this.bb!.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()), - this.bb!.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()) - ); -} - - -unpackTo(_o: MonsterT): void { - _o.pos = (this.pos() !== null ? this.pos()!.unpack() : null); - _o.mana = this.mana(); - _o.hp = this.hp(); - _o.name = this.name(); - _o.inventory = this.bb!.createScalarList(this.inventory.bind(this), this.inventoryLength()); - _o.color = this.color(); - _o.testType = this.testType(); - _o.test = (() => { - let temp = unionToAny(this.testType(), this.test.bind(this)); - if(temp === null) { return null; } - return temp.unpack() - })(); - _o.test4 = this.bb!.createObjList(this.test4.bind(this), this.test4Length()); - _o.testarrayofstring = this.bb!.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()); - _o.testarrayoftables = this.bb!.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()); - _o.enemy = (this.enemy() !== null ? this.enemy()!.unpack() : null); - _o.testnestedflatbuffer = this.bb!.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()); - _o.testempty = (this.testempty() !== null ? this.testempty()!.unpack() : null); - _o.testbool = this.testbool(); - _o.testhashs32Fnv1 = this.testhashs32Fnv1(); - _o.testhashu32Fnv1 = this.testhashu32Fnv1(); - _o.testhashs64Fnv1 = this.testhashs64Fnv1(); - _o.testhashu64Fnv1 = this.testhashu64Fnv1(); - _o.testhashs32Fnv1a = this.testhashs32Fnv1a(); - _o.testhashu32Fnv1a = this.testhashu32Fnv1a(); - _o.testhashs64Fnv1a = this.testhashs64Fnv1a(); - _o.testhashu64Fnv1a = this.testhashu64Fnv1a(); - _o.testarrayofbools = this.bb!.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()); - _o.testf = this.testf(); - _o.testf2 = this.testf2(); - _o.testf3 = this.testf3(); - _o.testarrayofstring2 = this.bb!.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()); - _o.testarrayofsortedstruct = this.bb!.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()); - _o.flex = this.bb!.createScalarList(this.flex.bind(this), this.flexLength()); - _o.test5 = this.bb!.createObjList(this.test5.bind(this), this.test5Length()); - _o.vectorOfLongs = this.bb!.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()); - _o.vectorOfDoubles = this.bb!.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()); - _o.parentNamespaceTest = (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null); - _o.vectorOfReferrables = this.bb!.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()); - _o.singleWeakReference = this.singleWeakReference(); - _o.vectorOfWeakReferences = this.bb!.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()); - _o.vectorOfStrongReferrables = this.bb!.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()); - _o.coOwningReference = this.coOwningReference(); - _o.vectorOfCoOwningReferences = this.bb!.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()); - _o.nonOwningReference = this.nonOwningReference(); - _o.vectorOfNonOwningReferences = this.bb!.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()); - _o.anyUniqueType = this.anyUniqueType(); - _o.anyUnique = (() => { - let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); - if(temp === null) { return null; } - return temp.unpack() - })(); - _o.anyAmbiguousType = this.anyAmbiguousType(); - _o.anyAmbiguous = (() => { - let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); - if(temp === null) { return null; } - return temp.unpack() - })(); - _o.vectorOfEnums = this.bb!.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()); - _o.signedEnum = this.signedEnum(); - _o.testrequirednestedflatbuffer = this.bb!.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()); - _o.scalarKeySortedTables = this.bb!.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()); -} -} - -export class MonsterT { -constructor( - public pos: Vec3T|null = null, - public mana: number = 150, - public hp: number = 100, - public name: string|Uint8Array|null = null, - public inventory: (number)[] = [], - public color: Color = Color.Blue, - public testType: Any = Any.NONE, - public test: MonsterT|MyGameExample2MonsterT|TestSimpleTableWithEnumT|null = null, - public test4: (TestT)[] = [], - public testarrayofstring: (string)[] = [], - public testarrayoftables: (MonsterT)[] = [], - public enemy: MonsterT|null = null, - public testnestedflatbuffer: (number)[] = [], - public testempty: StatT|null = null, - public testbool: boolean = false, - public testhashs32Fnv1: number = 0, - public testhashu32Fnv1: number = 0, - public testhashs64Fnv1: flatbuffers.Long = flatbuffers.createLong(0, 0), - public testhashu64Fnv1: flatbuffers.Long = flatbuffers.createLong(0, 0), - public testhashs32Fnv1a: number = 0, - public testhashu32Fnv1a: number = 0, - public testhashs64Fnv1a: flatbuffers.Long = flatbuffers.createLong(0, 0), - public testhashu64Fnv1a: flatbuffers.Long = flatbuffers.createLong(0, 0), - public testarrayofbools: (boolean)[] = [], - public testf: number = 3.14159, - public testf2: number = 3.0, - public testf3: number = 0.0, - public testarrayofstring2: (string)[] = [], - public testarrayofsortedstruct: (AbilityT)[] = [], - public flex: (number)[] = [], - public test5: (TestT)[] = [], - public vectorOfLongs: (flatbuffers.Long)[] = [], - public vectorOfDoubles: (number)[] = [], - public parentNamespaceTest: InParentNamespaceT|null = null, - public vectorOfReferrables: (ReferrableT)[] = [], - public singleWeakReference: flatbuffers.Long = flatbuffers.createLong(0, 0), - public vectorOfWeakReferences: (flatbuffers.Long)[] = [], - public vectorOfStrongReferrables: (ReferrableT)[] = [], - public coOwningReference: flatbuffers.Long = flatbuffers.createLong(0, 0), - public vectorOfCoOwningReferences: (flatbuffers.Long)[] = [], - public nonOwningReference: flatbuffers.Long = flatbuffers.createLong(0, 0), - public vectorOfNonOwningReferences: (flatbuffers.Long)[] = [], - public anyUniqueType: AnyUniqueAliases = AnyUniqueAliases.NONE, - public anyUnique: MonsterT|MyGameExample2MonsterT|TestSimpleTableWithEnumT|null = null, - public anyAmbiguousType: AnyAmbiguousAliases = AnyAmbiguousAliases.NONE, - public anyAmbiguous: MonsterT|null = null, - public vectorOfEnums: (Color)[] = [], - public signedEnum: Race = Race.None, - public testrequirednestedflatbuffer: (number)[] = [], - public scalarKeySortedTables: (StatT)[] = [] -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const name = (this.name !== null ? builder.createString(this.name!) : 0); - const inventory = Monster.createInventoryVector(builder, this.inventory); - const test = builder.createObjectOffset(this.test); - const test4 = builder.createStructOffsetList(this.test4, Monster.startTest4Vector); - const testarrayofstring = Monster.createTestarrayofstringVector(builder, builder.createObjectOffsetList(this.testarrayofstring)); - const testarrayoftables = Monster.createTestarrayoftablesVector(builder, builder.createObjectOffsetList(this.testarrayoftables)); - const enemy = (this.enemy !== null ? this.enemy!.pack(builder) : 0); - const testnestedflatbuffer = Monster.createTestnestedflatbufferVector(builder, this.testnestedflatbuffer); - const testempty = (this.testempty !== null ? this.testempty!.pack(builder) : 0); - const testarrayofbools = Monster.createTestarrayofboolsVector(builder, this.testarrayofbools); - const testarrayofstring2 = Monster.createTestarrayofstring2Vector(builder, builder.createObjectOffsetList(this.testarrayofstring2)); - const testarrayofsortedstruct = builder.createStructOffsetList(this.testarrayofsortedstruct, Monster.startTestarrayofsortedstructVector); - const flex = Monster.createFlexVector(builder, this.flex); - const test5 = builder.createStructOffsetList(this.test5, Monster.startTest5Vector); - const vectorOfLongs = Monster.createVectorOfLongsVector(builder, this.vectorOfLongs); - const vectorOfDoubles = Monster.createVectorOfDoublesVector(builder, this.vectorOfDoubles); - const parentNamespaceTest = (this.parentNamespaceTest !== null ? this.parentNamespaceTest!.pack(builder) : 0); - const vectorOfReferrables = Monster.createVectorOfReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfReferrables)); - const vectorOfWeakReferences = Monster.createVectorOfWeakReferencesVector(builder, this.vectorOfWeakReferences); - const vectorOfStrongReferrables = Monster.createVectorOfStrongReferrablesVector(builder, builder.createObjectOffsetList(this.vectorOfStrongReferrables)); - const vectorOfCoOwningReferences = Monster.createVectorOfCoOwningReferencesVector(builder, this.vectorOfCoOwningReferences); - const vectorOfNonOwningReferences = Monster.createVectorOfNonOwningReferencesVector(builder, this.vectorOfNonOwningReferences); - const anyUnique = builder.createObjectOffset(this.anyUnique); - const anyAmbiguous = builder.createObjectOffset(this.anyAmbiguous); - const vectorOfEnums = Monster.createVectorOfEnumsVector(builder, this.vectorOfEnums); - const testrequirednestedflatbuffer = Monster.createTestrequirednestedflatbufferVector(builder, this.testrequirednestedflatbuffer); - const scalarKeySortedTables = Monster.createScalarKeySortedTablesVector(builder, builder.createObjectOffsetList(this.scalarKeySortedTables)); - - Monster.startMonster(builder); - Monster.addPos(builder, (this.pos !== null ? this.pos!.pack(builder) : 0)); - Monster.addMana(builder, this.mana); - Monster.addHp(builder, this.hp); - Monster.addName(builder, name); - Monster.addInventory(builder, inventory); - Monster.addColor(builder, this.color); - Monster.addTestType(builder, this.testType); - Monster.addTest(builder, test); - Monster.addTest4(builder, test4); - Monster.addTestarrayofstring(builder, testarrayofstring); - Monster.addTestarrayoftables(builder, testarrayoftables); - Monster.addEnemy(builder, enemy); - Monster.addTestnestedflatbuffer(builder, testnestedflatbuffer); - Monster.addTestempty(builder, testempty); - Monster.addTestbool(builder, this.testbool); - Monster.addTesthashs32Fnv1(builder, this.testhashs32Fnv1); - Monster.addTesthashu32Fnv1(builder, this.testhashu32Fnv1); - Monster.addTesthashs64Fnv1(builder, this.testhashs64Fnv1); - Monster.addTesthashu64Fnv1(builder, this.testhashu64Fnv1); - Monster.addTesthashs32Fnv1a(builder, this.testhashs32Fnv1a); - Monster.addTesthashu32Fnv1a(builder, this.testhashu32Fnv1a); - Monster.addTesthashs64Fnv1a(builder, this.testhashs64Fnv1a); - Monster.addTesthashu64Fnv1a(builder, this.testhashu64Fnv1a); - Monster.addTestarrayofbools(builder, testarrayofbools); - Monster.addTestf(builder, this.testf); - Monster.addTestf2(builder, this.testf2); - Monster.addTestf3(builder, this.testf3); - Monster.addTestarrayofstring2(builder, testarrayofstring2); - Monster.addTestarrayofsortedstruct(builder, testarrayofsortedstruct); - Monster.addFlex(builder, flex); - Monster.addTest5(builder, test5); - Monster.addVectorOfLongs(builder, vectorOfLongs); - Monster.addVectorOfDoubles(builder, vectorOfDoubles); - Monster.addParentNamespaceTest(builder, parentNamespaceTest); - Monster.addVectorOfReferrables(builder, vectorOfReferrables); - Monster.addSingleWeakReference(builder, this.singleWeakReference); - Monster.addVectorOfWeakReferences(builder, vectorOfWeakReferences); - Monster.addVectorOfStrongReferrables(builder, vectorOfStrongReferrables); - Monster.addCoOwningReference(builder, this.coOwningReference); - Monster.addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferences); - Monster.addNonOwningReference(builder, this.nonOwningReference); - Monster.addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferences); - Monster.addAnyUniqueType(builder, this.anyUniqueType); - Monster.addAnyUnique(builder, anyUnique); - Monster.addAnyAmbiguousType(builder, this.anyAmbiguousType); - Monster.addAnyAmbiguous(builder, anyAmbiguous); - Monster.addVectorOfEnums(builder, vectorOfEnums); - Monster.addSignedEnum(builder, this.signedEnum); - Monster.addTestrequirednestedflatbuffer(builder, testrequirednestedflatbuffer); - Monster.addScalarKeySortedTables(builder, scalarKeySortedTables); - - return Monster.endMonster(builder); -} -} diff --git a/tests/ts/my-game/example/race.ts b/tests/ts/my-game/example/race.ts deleted file mode 100644 index 06ca128b..00000000 --- a/tests/ts/my-game/example/race.ts +++ /dev/null @@ -1,9 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -export enum Race{ - None = -1, - Human = 0, - Dwarf = 1, - Elf = 2 -} - diff --git a/tests/ts/my-game/example/referrable.ts b/tests/ts/my-game/example/referrable.ts deleted file mode 100644 index ce24debb..00000000 --- a/tests/ts/my-game/example/referrable.ts +++ /dev/null @@ -1,95 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class Referrable { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Referrable { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable { - return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsReferrable(bb:flatbuffers.ByteBuffer, obj?:Referrable):Referrable { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Referrable()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -id():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_id(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint64(this.bb_pos + offset, value); - return true; -} - -static getFullyQualifiedName():string { - return 'MyGame.Example.Referrable'; -} - -static startReferrable(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addId(builder:flatbuffers.Builder, id:flatbuffers.Long) { - builder.addFieldInt64(0, id, builder.createLong(0, 0)); -} - -static endReferrable(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createReferrable(builder:flatbuffers.Builder, id:flatbuffers.Long):flatbuffers.Offset { - Referrable.startReferrable(builder); - Referrable.addId(builder, id); - return Referrable.endReferrable(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):Referrable { - return Referrable.getRootAsReferrable(new flatbuffers.ByteBuffer(buffer)) -} - -unpack(): ReferrableT { - return new ReferrableT( - this.id() - ); -} - - -unpackTo(_o: ReferrableT): void { - _o.id = this.id(); -} -} - -export class ReferrableT { -constructor( - public id: flatbuffers.Long = flatbuffers.createLong(0, 0) -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return Referrable.createReferrable(builder, - this.id - ); -} -} diff --git a/tests/ts/my-game/example/stat.ts b/tests/ts/my-game/example/stat.ts deleted file mode 100644 index c0ef62c7..00000000 --- a/tests/ts/my-game/example/stat.ts +++ /dev/null @@ -1,138 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class Stat { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Stat { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat { - return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsStat(bb:flatbuffers.ByteBuffer, obj?:Stat):Stat { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -id():string|null -id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -id(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -} - -val():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_val(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt64(this.bb_pos + offset, value); - return true; -} - -count():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; -} - -mutate_count(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint16(this.bb_pos + offset, value); - return true; -} - -static getFullyQualifiedName():string { - return 'MyGame.Example.Stat'; -} - -static startStat(builder:flatbuffers.Builder) { - builder.startObject(3); -} - -static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, idOffset, 0); -} - -static addVal(builder:flatbuffers.Builder, val:flatbuffers.Long) { - builder.addFieldInt64(1, val, builder.createLong(0, 0)); -} - -static addCount(builder:flatbuffers.Builder, count:number) { - builder.addFieldInt16(2, count, 0); -} - -static endStat(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createStat(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, val:flatbuffers.Long, count:number):flatbuffers.Offset { - Stat.startStat(builder); - Stat.addId(builder, idOffset); - Stat.addVal(builder, val); - Stat.addCount(builder, count); - return Stat.endStat(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):Stat { - return Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer)) -} - -unpack(): StatT { - return new StatT( - this.id(), - this.val(), - this.count() - ); -} - - -unpackTo(_o: StatT): void { - _o.id = this.id(); - _o.val = this.val(); - _o.count = this.count(); -} -} - -export class StatT { -constructor( - public id: string|Uint8Array|null = null, - public val: flatbuffers.Long = flatbuffers.createLong(0, 0), - public count: number = 0 -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const id = (this.id !== null ? builder.createString(this.id!) : 0); - - return Stat.createStat(builder, - id, - this.val, - this.count - ); -} -} diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.ts b/tests/ts/my-game/example/test-simple-table-with-enum.ts deleted file mode 100644 index 99a541f9..00000000 --- a/tests/ts/my-game/example/test-simple-table-with-enum.ts +++ /dev/null @@ -1,96 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { Color } from '../../my-game/example/color'; - - -export class TestSimpleTableWithEnum { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum { - return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsTestSimpleTableWithEnum(bb:flatbuffers.ByteBuffer, obj?:TestSimpleTableWithEnum):TestSimpleTableWithEnum { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -color():Color { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : Color.Green; -} - -mutate_color(value:Color):boolean { - const offset = this.bb!.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint8(this.bb_pos + offset, value); - return true; -} - -static getFullyQualifiedName():string { - return 'MyGame.Example.TestSimpleTableWithEnum'; -} - -static startTestSimpleTableWithEnum(builder:flatbuffers.Builder) { - builder.startObject(1); -} - -static addColor(builder:flatbuffers.Builder, color:Color) { - builder.addFieldInt8(0, color, Color.Green); -} - -static endTestSimpleTableWithEnum(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createTestSimpleTableWithEnum(builder:flatbuffers.Builder, color:Color):flatbuffers.Offset { - TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder); - TestSimpleTableWithEnum.addColor(builder, color); - return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):TestSimpleTableWithEnum { - return TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum(new flatbuffers.ByteBuffer(buffer)) -} - -unpack(): TestSimpleTableWithEnumT { - return new TestSimpleTableWithEnumT( - this.color() - ); -} - - -unpackTo(_o: TestSimpleTableWithEnumT): void { - _o.color = this.color(); -} -} - -export class TestSimpleTableWithEnumT { -constructor( - public color: Color = Color.Green -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return TestSimpleTableWithEnum.createTestSimpleTableWithEnum(builder, - this.color - ); -} -} diff --git a/tests/ts/my-game/example/test.ts b/tests/ts/my-game/example/test.ts deleted file mode 100644 index afed125e..00000000 --- a/tests/ts/my-game/example/test.ts +++ /dev/null @@ -1,78 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class Test { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Test { - this.bb_pos = i; - this.bb = bb; - return this; -} - -a():number { - return this.bb!.readInt16(this.bb_pos); -} - -mutate_a(value:number):boolean { - this.bb!.writeInt16(this.bb_pos + 0, value); - return true; -} - -b():number { - return this.bb!.readInt8(this.bb_pos + 2); -} - -mutate_b(value:number):boolean { - this.bb!.writeInt8(this.bb_pos + 2, value); - return true; -} - -static getFullyQualifiedName():string { - return 'MyGame.Example.Test'; -} - -static sizeOf():number { - return 4; -} - -static createTest(builder:flatbuffers.Builder, a: number, b: number):flatbuffers.Offset { - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(b); - builder.writeInt16(a); - return builder.offset(); -} - - -unpack(): TestT { - return new TestT( - this.a(), - this.b() - ); -} - - -unpackTo(_o: TestT): void { - _o.a = this.a(); - _o.b = this.b(); -} -} - -export class TestT { -constructor( - public a: number = 0, - public b: number = 0 -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return Test.createTest(builder, - this.a, - this.b - ); -} -} diff --git a/tests/ts/my-game/example/type-aliases.ts b/tests/ts/my-game/example/type-aliases.ts deleted file mode 100644 index 58940d01..00000000 --- a/tests/ts/my-game/example/type-aliases.ts +++ /dev/null @@ -1,405 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class TypeAliases { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases { - return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsTypeAliases(bb:flatbuffers.ByteBuffer, obj?:TypeAliases):TypeAliases { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new TypeAliases()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -i8():number { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt8(this.bb_pos + offset) : 0; -} - -mutate_i8(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt8(this.bb_pos + offset, value); - return true; -} - -u8():number { - const offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; -} - -mutate_u8(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint8(this.bb_pos + offset, value); - return true; -} - -i16():number { - const offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readInt16(this.bb_pos + offset) : 0; -} - -mutate_i16(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt16(this.bb_pos + offset, value); - return true; -} - -u16():number { - const offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0; -} - -mutate_u16(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 10); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint16(this.bb_pos + offset, value); - return true; -} - -i32():number { - const offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -} - -mutate_i32(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 12); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt32(this.bb_pos + offset, value); - return true; -} - -u32():number { - const offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; -} - -mutate_u32(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 14); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint32(this.bb_pos + offset, value); - return true; -} - -i64():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 16); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_i64(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 16); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt64(this.bb_pos + offset, value); - return true; -} - -u64():flatbuffers.Long { - const offset = this.bb!.__offset(this.bb_pos, 18); - return offset ? this.bb!.readUint64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -} - -mutate_u64(value:flatbuffers.Long):boolean { - const offset = this.bb!.__offset(this.bb_pos, 18); - - if (offset === 0) { - return false; - } - - this.bb!.writeUint64(this.bb_pos + offset, value); - return true; -} - -f32():number { - const offset = this.bb!.__offset(this.bb_pos, 20); - return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0; -} - -mutate_f32(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 20); - - if (offset === 0) { - return false; - } - - this.bb!.writeFloat32(this.bb_pos + offset, value); - return true; -} - -f64():number { - const offset = this.bb!.__offset(this.bb_pos, 22); - return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0; -} - -mutate_f64(value:number):boolean { - const offset = this.bb!.__offset(this.bb_pos, 22); - - if (offset === 0) { - return false; - } - - this.bb!.writeFloat64(this.bb_pos + offset, value); - return true; -} - -v8(index: number):number|null { - const offset = this.bb!.__offset(this.bb_pos, 24); - return offset ? this.bb!.readInt8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; -} - -v8Length():number { - const offset = this.bb!.__offset(this.bb_pos, 24); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -v8Array():Int8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 24); - return offset ? new Int8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; -} - -vf64(index: number):number|null { - const offset = this.bb!.__offset(this.bb_pos, 26); - return offset ? this.bb!.readFloat64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : 0; -} - -vf64Length():number { - const offset = this.bb!.__offset(this.bb_pos, 26); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -vf64Array():Float64Array|null { - const offset = this.bb!.__offset(this.bb_pos, 26); - return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; -} - -static getFullyQualifiedName():string { - return 'MyGame.Example.TypeAliases'; -} - -static startTypeAliases(builder:flatbuffers.Builder) { - builder.startObject(12); -} - -static addI8(builder:flatbuffers.Builder, i8:number) { - builder.addFieldInt8(0, i8, 0); -} - -static addU8(builder:flatbuffers.Builder, u8:number) { - builder.addFieldInt8(1, u8, 0); -} - -static addI16(builder:flatbuffers.Builder, i16:number) { - builder.addFieldInt16(2, i16, 0); -} - -static addU16(builder:flatbuffers.Builder, u16:number) { - builder.addFieldInt16(3, u16, 0); -} - -static addI32(builder:flatbuffers.Builder, i32:number) { - builder.addFieldInt32(4, i32, 0); -} - -static addU32(builder:flatbuffers.Builder, u32:number) { - builder.addFieldInt32(5, u32, 0); -} - -static addI64(builder:flatbuffers.Builder, i64:flatbuffers.Long) { - builder.addFieldInt64(6, i64, builder.createLong(0, 0)); -} - -static addU64(builder:flatbuffers.Builder, u64:flatbuffers.Long) { - builder.addFieldInt64(7, u64, builder.createLong(0, 0)); -} - -static addF32(builder:flatbuffers.Builder, f32:number) { - builder.addFieldFloat32(8, f32, 0.0); -} - -static addF64(builder:flatbuffers.Builder, f64:number) { - builder.addFieldFloat64(9, f64, 0.0); -} - -static addV8(builder:flatbuffers.Builder, v8Offset:flatbuffers.Offset) { - builder.addFieldOffset(10, v8Offset, 0); -} - -static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array):flatbuffers.Offset; -/** - * @deprecated This Uint8Array overload will be removed in the future. - */ -static createV8Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; -static createV8Vector(builder:flatbuffers.Builder, data:number[]|Int8Array|Uint8Array):flatbuffers.Offset { - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]!); - } - return builder.endVector(); -} - -static startV8Vector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -} - -static addVf64(builder:flatbuffers.Builder, vf64Offset:flatbuffers.Offset) { - builder.addFieldOffset(11, vf64Offset, 0); -} - -static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array):flatbuffers.Offset; -/** - * @deprecated This Uint8Array overload will be removed in the future. - */ -static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; -static createVf64Vector(builder:flatbuffers.Builder, data:number[]|Float64Array|Uint8Array):flatbuffers.Offset { - builder.startVector(8, data.length, 8); - for (let i = data.length - 1; i >= 0; i--) { - builder.addFloat64(data[i]!); - } - return builder.endVector(); -} - -static startVf64Vector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(8, numElems, 8); -} - -static endTypeAliases(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createTypeAliases(builder:flatbuffers.Builder, i8:number, u8:number, i16:number, u16:number, i32:number, u32:number, i64:flatbuffers.Long, u64:flatbuffers.Long, f32:number, f64:number, v8Offset:flatbuffers.Offset, vf64Offset:flatbuffers.Offset):flatbuffers.Offset { - TypeAliases.startTypeAliases(builder); - TypeAliases.addI8(builder, i8); - TypeAliases.addU8(builder, u8); - TypeAliases.addI16(builder, i16); - TypeAliases.addU16(builder, u16); - TypeAliases.addI32(builder, i32); - TypeAliases.addU32(builder, u32); - TypeAliases.addI64(builder, i64); - TypeAliases.addU64(builder, u64); - TypeAliases.addF32(builder, f32); - TypeAliases.addF64(builder, f64); - TypeAliases.addV8(builder, v8Offset); - TypeAliases.addVf64(builder, vf64Offset); - return TypeAliases.endTypeAliases(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):TypeAliases { - return TypeAliases.getRootAsTypeAliases(new flatbuffers.ByteBuffer(buffer)) -} - -unpack(): TypeAliasesT { - return new TypeAliasesT( - this.i8(), - this.u8(), - this.i16(), - this.u16(), - this.i32(), - this.u32(), - this.i64(), - this.u64(), - this.f32(), - this.f64(), - this.bb!.createScalarList(this.v8.bind(this), this.v8Length()), - this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length()) - ); -} - - -unpackTo(_o: TypeAliasesT): void { - _o.i8 = this.i8(); - _o.u8 = this.u8(); - _o.i16 = this.i16(); - _o.u16 = this.u16(); - _o.i32 = this.i32(); - _o.u32 = this.u32(); - _o.i64 = this.i64(); - _o.u64 = this.u64(); - _o.f32 = this.f32(); - _o.f64 = this.f64(); - _o.v8 = this.bb!.createScalarList(this.v8.bind(this), this.v8Length()); - _o.vf64 = this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length()); -} -} - -export class TypeAliasesT { -constructor( - public i8: number = 0, - public u8: number = 0, - public i16: number = 0, - public u16: number = 0, - public i32: number = 0, - public u32: number = 0, - public i64: flatbuffers.Long = flatbuffers.createLong(0, 0), - public u64: flatbuffers.Long = flatbuffers.createLong(0, 0), - public f32: number = 0.0, - public f64: number = 0.0, - public v8: (number)[] = [], - public vf64: (number)[] = [] -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const v8 = TypeAliases.createV8Vector(builder, this.v8); - const vf64 = TypeAliases.createVf64Vector(builder, this.vf64); - - return TypeAliases.createTypeAliases(builder, - this.i8, - this.u8, - this.i16, - this.u16, - this.i32, - this.u32, - this.i64, - this.u64, - this.f32, - this.f64, - v8, - vf64 - ); -} -} diff --git a/tests/ts/my-game/example/vec3.ts b/tests/ts/my-game/example/vec3.ts deleted file mode 100644 index 9756977d..00000000 --- a/tests/ts/my-game/example/vec3.ts +++ /dev/null @@ -1,137 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - -import { Color } from '../../my-game/example/color'; -import { Test, TestT } from '../../my-game/example/test'; - - -export class Vec3 { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Vec3 { - this.bb_pos = i; - this.bb = bb; - return this; -} - -x():number { - return this.bb!.readFloat32(this.bb_pos); -} - -mutate_x(value:number):boolean { - this.bb!.writeFloat32(this.bb_pos + 0, value); - return true; -} - -y():number { - return this.bb!.readFloat32(this.bb_pos + 4); -} - -mutate_y(value:number):boolean { - this.bb!.writeFloat32(this.bb_pos + 4, value); - return true; -} - -z():number { - return this.bb!.readFloat32(this.bb_pos + 8); -} - -mutate_z(value:number):boolean { - this.bb!.writeFloat32(this.bb_pos + 8, value); - return true; -} - -test1():number { - return this.bb!.readFloat64(this.bb_pos + 16); -} - -mutate_test1(value:number):boolean { - this.bb!.writeFloat64(this.bb_pos + 16, value); - return true; -} - -test2():Color { - return this.bb!.readUint8(this.bb_pos + 24); -} - -mutate_test2(value:Color):boolean { - this.bb!.writeUint8(this.bb_pos + 24, value); - return true; -} - -test3(obj?:Test):Test|null { - return (obj || new Test()).__init(this.bb_pos + 26, this.bb!); -} - -static getFullyQualifiedName():string { - return 'MyGame.Example.Vec3'; -} - -static sizeOf():number { - return 32; -} - -static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: Color, test3_a: number, test3_b: number):flatbuffers.Offset { - builder.prep(8, 32); - builder.pad(2); - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(test3_b); - builder.writeInt16(test3_a); - builder.pad(1); - builder.writeInt8(test2); - builder.writeFloat64(test1); - builder.pad(4); - builder.writeFloat32(z); - builder.writeFloat32(y); - builder.writeFloat32(x); - return builder.offset(); -} - - -unpack(): Vec3T { - return new Vec3T( - this.x(), - this.y(), - this.z(), - this.test1(), - this.test2(), - (this.test3() !== null ? this.test3()!.unpack() : null) - ); -} - - -unpackTo(_o: Vec3T): void { - _o.x = this.x(); - _o.y = this.y(); - _o.z = this.z(); - _o.test1 = this.test1(); - _o.test2 = this.test2(); - _o.test3 = (this.test3() !== null ? this.test3()!.unpack() : null); -} -} - -export class Vec3T { -constructor( - public x: number = 0.0, - public y: number = 0.0, - public z: number = 0.0, - public test1: number = 0.0, - public test2: Color = 0, - public test3: TestT|null = null -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return Vec3.createVec3(builder, - this.x, - this.y, - this.z, - this.test1, - this.test2, - (this.test3 === null ? 0 : this.test3.a!), - (this.test3 === null ? 0 : this.test3.b!) - ); -} -} diff --git a/tests/ts/my-game/example2/monster.ts b/tests/ts/my-game/example2/monster.ts deleted file mode 100644 index 14d7685f..00000000 --- a/tests/ts/my-game/example2/monster.ts +++ /dev/null @@ -1,66 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class Monster { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Monster { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster { - return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Monster { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getFullyQualifiedName():string { - return 'MyGame.Example2.Monster'; -} - -static startMonster(builder:flatbuffers.Builder) { - builder.startObject(0); -} - -static endMonster(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createMonster(builder:flatbuffers.Builder):flatbuffers.Offset { - Monster.startMonster(builder); - return Monster.endMonster(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):Monster { - return Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)) -} - -unpack(): MonsterT { - return new MonsterT(); -} - - -unpackTo(_o: MonsterT): void {} -} - -export class MonsterT { -constructor(){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return Monster.createMonster(builder); -} -} diff --git a/tests/ts/my-game/in-parent-namespace.ts b/tests/ts/my-game/in-parent-namespace.ts deleted file mode 100644 index 8cfe9b60..00000000 --- a/tests/ts/my-game/in-parent-namespace.ts +++ /dev/null @@ -1,66 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class InParentNamespace { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace { - this.bb_pos = i; - this.bb = bb; - return this; -} - -static getRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace { - return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:InParentNamespace):InParentNamespace { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -} - -static getFullyQualifiedName():string { - return 'MyGame.InParentNamespace'; -} - -static startInParentNamespace(builder:flatbuffers.Builder) { - builder.startObject(0); -} - -static endInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset { - const offset = builder.endObject(); - return offset; -} - -static createInParentNamespace(builder:flatbuffers.Builder):flatbuffers.Offset { - InParentNamespace.startInParentNamespace(builder); - return InParentNamespace.endInParentNamespace(builder); -} - -serialize():Uint8Array { - return this.bb!.bytes(); -} - -static deserialize(buffer: Uint8Array):InParentNamespace { - return InParentNamespace.getRootAsInParentNamespace(new flatbuffers.ByteBuffer(buffer)) -} - -unpack(): InParentNamespaceT { - return new InParentNamespaceT(); -} - - -unpackTo(_o: InParentNamespaceT): void {} -} - -export class InParentNamespaceT { -constructor(){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return InParentNamespace.createInParentNamespace(builder); -} -} diff --git a/tests/ts/rapunzel.ts b/tests/ts/rapunzel.ts deleted file mode 100644 index 382dc158..00000000 --- a/tests/ts/rapunzel.ts +++ /dev/null @@ -1,58 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; - - - -export class Rapunzel { - bb: flatbuffers.ByteBuffer|null = null; - bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel { - this.bb_pos = i; - this.bb = bb; - return this; -} - -hairLength():number { - return this.bb!.readInt32(this.bb_pos); -} - -static getFullyQualifiedName():string { - return 'Rapunzel'; -} - -static sizeOf():number { - return 4; -} - -static createRapunzel(builder:flatbuffers.Builder, hair_length: number):flatbuffers.Offset { - builder.prep(4, 4); - builder.writeInt32(hair_length); - return builder.offset(); -} - - -unpack(): RapunzelT { - return new RapunzelT( - this.hairLength() - ); -} - - -unpackTo(_o: RapunzelT): void { - _o.hairLength = this.hairLength(); -} -} - -export class RapunzelT { -constructor( - public hairLength: number = 0 -){} - - -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return Rapunzel.createRapunzel(builder, - this.hairLength - ); -} -} diff --git a/tests/tsconfig.json b/tests/tsconfig.json index 4daff463..eff2469c 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -10,9 +10,14 @@ "noImplicitReturns": true, "strictNullChecks": true, "baseUrl": ".", - "noEmit": false, - "outDir": "./ts" + "noEmit": false }, - "include": [ "ts/**/*.ts" ], - "exclude": [] + "include": [ + "my-game/**/*.ts", + "optional_scalars/**/*.ts", + "union_vector/**/*.ts" + ], + "exclude": [ + "namespace_test/**/*.ts" + ] } diff --git a/tests/unicode_test.mon b/tests/unicode_test.mon Binary files differnew file mode 100644 index 00000000..14f5fb4d --- /dev/null +++ b/tests/unicode_test.mon diff --git a/tests/union_vector/attacker.js b/tests/union_vector/attacker.js new file mode 100644 index 00000000..32be94e2 --- /dev/null +++ b/tests/union_vector/attacker.js @@ -0,0 +1,64 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +export class Attacker { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsAttacker(bb, obj) { + return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsAttacker(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + swordAttackDamage() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + mutate_sword_attack_damage(value) { + const offset = this.bb.__offset(this.bb_pos, 4); + if (offset === 0) { + return false; + } + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + static getFullyQualifiedName() { + return 'Attacker'; + } + static startAttacker(builder) { + builder.startObject(1); + } + static addSwordAttackDamage(builder, swordAttackDamage) { + builder.addFieldInt32(0, swordAttackDamage, 0); + } + static endAttacker(builder) { + const offset = builder.endObject(); + return offset; + } + static createAttacker(builder, swordAttackDamage) { + Attacker.startAttacker(builder); + Attacker.addSwordAttackDamage(builder, swordAttackDamage); + return Attacker.endAttacker(builder); + } + unpack() { + return new AttackerT(this.swordAttackDamage()); + } + unpackTo(_o) { + _o.swordAttackDamage = this.swordAttackDamage(); + } +} +export class AttackerT { + constructor(swordAttackDamage = 0) { + this.swordAttackDamage = swordAttackDamage; + } + pack(builder) { + return Attacker.createAttacker(builder, this.swordAttackDamage); + } +} diff --git a/tests/union_vector/book-reader.js b/tests/union_vector/book-reader.js new file mode 100644 index 00000000..0d9e1a57 --- /dev/null +++ b/tests/union_vector/book-reader.js @@ -0,0 +1,44 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export class BookReader { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + booksRead() { + return this.bb.readInt32(this.bb_pos); + } + mutate_books_read(value) { + this.bb.writeInt32(this.bb_pos + 0, value); + return true; + } + static getFullyQualifiedName() { + return 'BookReader'; + } + static sizeOf() { + return 4; + } + static createBookReader(builder, books_read) { + builder.prep(4, 4); + builder.writeInt32(books_read); + return builder.offset(); + } + unpack() { + return new BookReaderT(this.booksRead()); + } + unpackTo(_o) { + _o.booksRead = this.booksRead(); + } +} +export class BookReaderT { + constructor(booksRead = 0) { + this.booksRead = booksRead; + } + pack(builder) { + return BookReader.createBookReader(builder, this.booksRead); + } +} diff --git a/tests/union_vector/character.js b/tests/union_vector/character.js new file mode 100644 index 00000000..c0602981 --- /dev/null +++ b/tests/union_vector/character.js @@ -0,0 +1,38 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import { Attacker } from './attacker'; +import { BookReader } from './book-reader'; +import { Rapunzel } from './rapunzel'; +export var Character; +(function (Character) { + Character[Character["NONE"] = 0] = "NONE"; + Character[Character["MuLan"] = 1] = "MuLan"; + Character[Character["Rapunzel"] = 2] = "Rapunzel"; + Character[Character["Belle"] = 3] = "Belle"; + Character[Character["BookFan"] = 4] = "BookFan"; + Character[Character["Other"] = 5] = "Other"; + Character[Character["Unused"] = 6] = "Unused"; +})(Character || (Character = {})); +export function unionToCharacter(type, accessor) { + switch (Character[type]) { + case 'NONE': return null; + case 'MuLan': return accessor(new Attacker()); + case 'Rapunzel': return accessor(new Rapunzel()); + case 'Belle': return accessor(new BookReader()); + case 'BookFan': return accessor(new BookReader()); + case 'Other': return accessor(''); + case 'Unused': return accessor(''); + default: return null; + } +} +export function unionListToCharacter(type, accessor, index) { + switch (Character[type]) { + case 'NONE': return null; + case 'MuLan': return accessor(index, new Attacker()); + case 'Rapunzel': return accessor(index, new Rapunzel()); + case 'Belle': return accessor(index, new BookReader()); + case 'BookFan': return accessor(index, new BookReader()); + case 'Other': return accessor(index, ''); + case 'Unused': return accessor(index, ''); + default: return null; + } +} diff --git a/tests/union_vector/movie.js b/tests/union_vector/movie.js new file mode 100644 index 00000000..b4d80994 --- /dev/null +++ b/tests/union_vector/movie.js @@ -0,0 +1,185 @@ +// automatically generated by the FlatBuffers compiler, do not modify +import * as flatbuffers from 'flatbuffers'; +import { Character, unionToCharacter, unionListToCharacter } from './character'; +export class Movie { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsMovie(bb, obj) { + return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsMovie(bb, obj) { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static bufferHasIdentifier(bb) { + return bb.__has_identifier('MOVI'); + } + mainCharacterType() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.readUint8(this.bb_pos + offset) : Character.NONE; + } + mainCharacter(obj) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__union_with_string(obj, this.bb_pos + offset) : null; + } + charactersType(index) { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + charactersTypeLength() { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + charactersTypeArray() { + const 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; + } + characters(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__union_with_string(obj, this.bb.__vector(this.bb_pos + offset) + index * 4) : null; + } + charactersLength() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + static getFullyQualifiedName() { + return 'Movie'; + } + static startMovie(builder) { + builder.startObject(4); + } + static addMainCharacterType(builder, mainCharacterType) { + builder.addFieldInt8(0, mainCharacterType, Character.NONE); + } + static addMainCharacter(builder, mainCharacterOffset) { + builder.addFieldOffset(1, mainCharacterOffset, 0); + } + static addCharactersType(builder, charactersTypeOffset) { + builder.addFieldOffset(2, charactersTypeOffset, 0); + } + static createCharactersTypeVector(builder, data) { + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); + } + static startCharactersTypeVector(builder, numElems) { + builder.startVector(1, numElems, 1); + } + static addCharacters(builder, charactersOffset) { + builder.addFieldOffset(3, charactersOffset, 0); + } + static createCharactersVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startCharactersVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endMovie(builder) { + const offset = builder.endObject(); + return offset; + } + static finishMovieBuffer(builder, offset) { + builder.finish(offset, 'MOVI'); + } + static finishSizePrefixedMovieBuffer(builder, offset) { + builder.finish(offset, 'MOVI', true); + } + static createMovie(builder, mainCharacterType, mainCharacterOffset, charactersTypeOffset, charactersOffset) { + Movie.startMovie(builder); + Movie.addMainCharacterType(builder, mainCharacterType); + Movie.addMainCharacter(builder, mainCharacterOffset); + Movie.addCharactersType(builder, charactersTypeOffset); + Movie.addCharacters(builder, charactersOffset); + return Movie.endMovie(builder); + } + unpack() { + return new MovieT(this.mainCharacterType(), (() => { + let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); + if (temp === null) { + return null; + } + if (typeof temp === 'string') { + return temp; + } + return temp.unpack(); + })(), this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), (() => { + let ret = []; + for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { + let targetEnum = this.charactersType(targetEnumIndex); + if (targetEnum === null || Character[targetEnum] === 'NONE') { + continue; + } + let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); + if (temp === null) { + continue; + } + if (typeof temp === 'string') { + ret.push(temp); + continue; + } + ret.push(temp.unpack()); + } + return ret; + })()); + } + unpackTo(_o) { + _o.mainCharacterType = this.mainCharacterType(); + _o.mainCharacter = (() => { + let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); + if (temp === null) { + return null; + } + if (typeof temp === 'string') { + return temp; + } + return temp.unpack(); + })(); + _o.charactersType = this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()); + _o.characters = (() => { + let ret = []; + for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { + let targetEnum = this.charactersType(targetEnumIndex); + if (targetEnum === null || Character[targetEnum] === 'NONE') { + continue; + } + let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); + if (temp === null) { + continue; + } + if (typeof temp === 'string') { + ret.push(temp); + continue; + } + ret.push(temp.unpack()); + } + return ret; + })(); + } +} +export class MovieT { + constructor(mainCharacterType = Character.NONE, mainCharacter = null, charactersType = [], characters = []) { + this.mainCharacterType = mainCharacterType; + this.mainCharacter = mainCharacter; + this.charactersType = charactersType; + this.characters = characters; + } + pack(builder) { + const mainCharacter = builder.createObjectOffset(this.mainCharacter); + const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType); + const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters)); + return Movie.createMovie(builder, this.mainCharacterType, mainCharacter, charactersType, characters); + } +} diff --git a/tests/union_vector/rapunzel.js b/tests/union_vector/rapunzel.js new file mode 100644 index 00000000..67a5e445 --- /dev/null +++ b/tests/union_vector/rapunzel.js @@ -0,0 +1,44 @@ +// automatically generated by the FlatBuffers compiler, do not modify +export class Rapunzel { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + hairLength() { + return this.bb.readInt32(this.bb_pos); + } + mutate_hair_length(value) { + this.bb.writeInt32(this.bb_pos + 0, value); + return true; + } + static getFullyQualifiedName() { + return 'Rapunzel'; + } + static sizeOf() { + return 4; + } + static createRapunzel(builder, hair_length) { + builder.prep(4, 4); + builder.writeInt32(hair_length); + return builder.offset(); + } + unpack() { + return new RapunzelT(this.hairLength()); + } + unpackTo(_o) { + _o.hairLength = this.hairLength(); + } +} +export class RapunzelT { + constructor(hairLength = 0) { + this.hairLength = hairLength; + } + pack(builder) { + return Rapunzel.createRapunzel(builder, this.hairLength); + } +} diff --git a/tests/union_vector/union_vector_generated.js b/tests/union_vector/union_vector_generated.js deleted file mode 100644 index 9e8b76e6..00000000 --- a/tests/union_vector/union_vector_generated.js +++ /dev/null @@ -1,522 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @enum {number} - */ -var Character = { - NONE: 0, - MuLan: 1, - Rapunzel: 2, - Belle: 3, - BookFan: 4, - Other: 5, - Unused: 6 -}; - -/** - * @enum {string} - */ -var CharacterName = { - '0': 'NONE', - '1': 'MuLan', - '2': 'Rapunzel', - '3': 'Belle', - '4': 'BookFan', - '5': 'Other', - '6': 'Unused' -}; - -/** - * @constructor - */ -function Attacker() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -} - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Attacker} - */ -Attacker.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {Attacker=} obj - * @returns {Attacker} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Attacker).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns {number} - */ -Attacker.prototype.swordAttackDamage = function() { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param {number} value - * @returns {boolean} - */ -Attacker.prototype.mutate_sword_attack_damage = function(value) { - var offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns {string} - */ -Attacker.getFullyQualifiedName = function() { - return 'Attacker'; -} - -/** - * @param {flatbuffers.Builder} builder - */ -Attacker.startAttacker = function(builder) { - builder.startObject(1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} swordAttackDamage - */ -Attacker.addSwordAttackDamage = function(builder, swordAttackDamage) { - builder.addFieldInt32(0, swordAttackDamage, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -Attacker.endAttacker = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} swordAttackDamage - * @returns {flatbuffers.Offset} - */ -Attacker.createAttacker = function(builder, swordAttackDamage) { - Attacker.startAttacker(builder); - Attacker.addSwordAttackDamage(builder, swordAttackDamage); - return Attacker.endAttacker(builder); -} - -/** - * @constructor - */ -function Rapunzel() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -} - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Rapunzel} - */ -Rapunzel.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -Rapunzel.prototype.hairLength = function() { - return this.bb.readInt32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -Rapunzel.prototype.mutate_hair_length = function(value) { - this.bb.writeInt32(this.bb_pos + 0, value); - return true; -}; - -/** - * @returns {string} - */ -Rapunzel.getFullyQualifiedName = function() { - return 'Rapunzel'; -} - -/** - * @returns {number} - */ -Rapunzel.sizeOf = function() { - return 4; -} - -/** - * @param {flatbuffers.Builder} builder - * @param {number} hair_length - * @returns {flatbuffers.Offset} - */ -Rapunzel.createRapunzel = function(builder, hair_length) { - builder.prep(4, 4); - builder.writeInt32(hair_length); - return builder.offset(); -}; - -/** - * @constructor - */ -function BookReader() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -} - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {BookReader} - */ -BookReader.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns {number} - */ -BookReader.prototype.booksRead = function() { - return this.bb.readInt32(this.bb_pos); -}; - -/** - * @param {number} value - * @returns {boolean} - */ -BookReader.prototype.mutate_books_read = function(value) { - this.bb.writeInt32(this.bb_pos + 0, value); - return true; -}; - -/** - * @returns {string} - */ -BookReader.getFullyQualifiedName = function() { - return 'BookReader'; -} - -/** - * @returns {number} - */ -BookReader.sizeOf = function() { - return 4; -} - -/** - * @param {flatbuffers.Builder} builder - * @param {number} books_read - * @returns {flatbuffers.Offset} - */ -BookReader.createBookReader = function(builder, books_read) { - builder.prep(4, 4); - builder.writeInt32(books_read); - return builder.offset(); -}; - -/** - * @constructor - */ -function Movie() { - /** - * @type {flatbuffers.ByteBuffer} - */ - this.bb = null; - - /** - * @type {number} - */ - this.bb_pos = 0; -} - -/** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Movie} - */ -Movie.prototype.__init = function(i, bb) { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @param {Movie=} obj - * @returns {Movie} - */ -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) { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Movie).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param {flatbuffers.ByteBuffer} bb - * @returns {boolean} - */ -Movie.bufferHasIdentifier = function(bb) { - return bb.__has_identifier('MOVI'); -}; - -/** - * @returns {Character} - */ -Movie.prototype.mainCharacterType = function() { - var offset = this.bb.__offset(this.bb_pos, 4); - return offset ? /** @type {Character} */ (this.bb.readUint8(this.bb_pos + offset)) : Character.NONE; -}; - -/** - * @param {flatbuffers.Table} obj - * @returns {?flatbuffers.Table} - */ -Movie.prototype.mainCharacter = function(obj) { - var offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; -}; - -/** - * @param {number} index - * @returns {Character} - */ -Movie.prototype.charactersType = function(index) { - 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} - */ -Movie.prototype.charactersTypeLength = function() { - var offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {Uint8Array} - */ -Movie.prototype.charactersTypeArray = function() { - 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; -}; - -/** - * @param {number} index - * @param {flatbuffers.Table=} obj - * @returns {?flatbuffers.Table} - */ -Movie.prototype.characters = function(index, obj) { - 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} - */ -Movie.prototype.charactersLength = function() { - var offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns {string} - */ -Movie.getFullyQualifiedName = function() { - return 'Movie'; -} - -/** - * @param {flatbuffers.Builder} builder - */ -Movie.startMovie = function(builder) { - builder.startObject(4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Character} mainCharacterType - */ -Movie.addMainCharacterType = function(builder, mainCharacterType) { - builder.addFieldInt8(0, mainCharacterType, Character.NONE); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} mainCharacterOffset - */ -Movie.addMainCharacter = function(builder, mainCharacterOffset) { - builder.addFieldOffset(1, mainCharacterOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} charactersTypeOffset - */ -Movie.addCharactersType = function(builder, charactersTypeOffset) { - builder.addFieldOffset(2, charactersTypeOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<Character>} data - * @returns {flatbuffers.Offset} - */ -Movie.createCharactersTypeVector = function(builder, data) { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -Movie.startCharactersTypeVector = function(builder, numElems) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} charactersOffset - */ -Movie.addCharacters = function(builder, charactersOffset) { - builder.addFieldOffset(3, charactersOffset, 0); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {Array.<flatbuffers.Offset>} data - * @returns {flatbuffers.Offset} - */ -Movie.createCharactersVector = function(builder, data) { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ -Movie.startCharactersVector = function(builder, numElems) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ -Movie.endMovie = function(builder) { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} offset - */ -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 - * @param {flatbuffers.Offset} mainCharacterOffset - * @param {flatbuffers.Offset} charactersTypeOffset - * @param {flatbuffers.Offset} charactersOffset - * @returns {flatbuffers.Offset} - */ -Movie.createMovie = function(builder, mainCharacterType, mainCharacterOffset, charactersTypeOffset, charactersOffset) { - Movie.startMovie(builder); - Movie.addMainCharacterType(builder, mainCharacterType); - Movie.addMainCharacter(builder, mainCharacterOffset); - Movie.addCharactersType(builder, charactersTypeOffset); - Movie.addCharacters(builder, charactersOffset); - return Movie.endMovie(builder); -} - -// Exports for Node.js and RequireJS -this.Character = Character; -this.CharacterName = CharacterName; -this.Attacker = Attacker; -this.Rapunzel = Rapunzel; -this.BookReader = BookReader; -this.Movie = Movie; diff --git a/tests/union_vector/union_vector_generated.ts b/tests/union_vector/union_vector_generated.ts deleted file mode 100644 index 806c07f2..00000000 --- a/tests/union_vector/union_vector_generated.ts +++ /dev/null @@ -1,690 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as flatbuffers from 'flatbuffers'; -/** - * @enum {number} - */ -export enum Character{ - NONE= 0, - MuLan= 1, - Rapunzel= 2, - Belle= 3, - BookFan= 4, - Other= 5, - Unused= 6 -}; - -export function unionToCharacter( - type: Character, - accessor: (obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null -): Attacker|BookReader|Rapunzel|string|null { - switch(Character[type]) { - case 'NONE': return null; - case 'MuLan': return accessor(new Attacker())! as Attacker; - case 'Rapunzel': return accessor(new Rapunzel())! as Rapunzel; - case 'Belle': return accessor(new BookReader())! as BookReader; - case 'BookFan': return accessor(new BookReader())! as BookReader; - case 'Other': return accessor('') as string; - case 'Unused': return accessor('') as string; - default: return null; - } -} - -export function unionListToCharacter( - type: Character, - accessor: (index: number, obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null, - index: number -): Attacker|BookReader|Rapunzel|string|null { - switch(Character[type]) { - case 'NONE': return null; - case 'MuLan': return accessor(index, new Attacker())! as Attacker; - case 'Rapunzel': return accessor(index, new Rapunzel())! as Rapunzel; - case 'Belle': return accessor(index, new BookReader())! as BookReader; - case 'BookFan': return accessor(index, new BookReader())! as BookReader; - case 'Other': return accessor(index, '') as string; - case 'Unused': return accessor(index, '') as string; - default: return null; - } -} - -/** - * @constructor - */ -export class Attacker { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Attacker - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Attacker { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Attacker= obj - * @returns Attacker - */ -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 { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns number - */ -swordAttackDamage():number { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param number value - * @returns boolean - */ -mutate_sword_attack_damage(value:number):boolean { - var offset = this.bb!.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb!.writeInt32(this.bb_pos + offset, value); - return true; -}; - -/** - * @returns string - */ -static getFullyQualifiedName():string { - return 'Attacker'; -} - -/** - * @param flatbuffers.Builder builder - */ -static startAttacker(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param flatbuffers.Builder builder - * @param number swordAttackDamage - */ -static addSwordAttackDamage(builder:flatbuffers.Builder, swordAttackDamage:number) { - builder.addFieldInt32(0, swordAttackDamage, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endAttacker(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createAttacker(builder:flatbuffers.Builder, swordAttackDamage:number):flatbuffers.Offset { - Attacker.startAttacker(builder); - Attacker.addSwordAttackDamage(builder, swordAttackDamage); - return Attacker.endAttacker(builder); -} - -/** - * @returns AttackerT - */ -unpack(): AttackerT { - return new AttackerT( - this.swordAttackDamage() - ); -}; - -/** - * @param AttackerT _o - */ -unpackTo(_o: AttackerT): void { - _o.swordAttackDamage = this.swordAttackDamage(); -}; -} - -export class AttackerT { -/** - * @constructor - * @param number swordAttackDamage - */ -constructor( - public swordAttackDamage: number = 0 -){}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return Attacker.createAttacker(builder, - this.swordAttackDamage - ); -}; -} -/** - * @constructor - */ -export class Rapunzel { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Rapunzel - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns number - */ -hairLength():number { - return this.bb!.readInt32(this.bb_pos); -}; - -/** - * @param number value - * @returns boolean - */ -mutate_hair_length(value:number):boolean { - this.bb!.writeInt32(this.bb_pos + 0, value); - return true; -}; - -/** - * @returns string - */ -static getFullyQualifiedName():string { - return 'Rapunzel'; -} - -/** - * @returns number - */ -static sizeOf():number { - return 4; -} - -/** - * @param flatbuffers.Builder builder - * @param number hair_length - * @returns flatbuffers.Offset - */ -static createRapunzel(builder:flatbuffers.Builder, hair_length: number):flatbuffers.Offset { - builder.prep(4, 4); - builder.writeInt32(hair_length); - return builder.offset(); -}; - - -/** - * @returns RapunzelT - */ -unpack(): RapunzelT { - return new RapunzelT( - this.hairLength() - ); -}; - -/** - * @param RapunzelT _o - */ -unpackTo(_o: RapunzelT): void { - _o.hairLength = this.hairLength(); -}; -} - -export class RapunzelT { -/** - * @constructor - * @param number hairLength - */ -constructor( - public hairLength: number = 0 -){}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return Rapunzel.createRapunzel(builder, - this.hairLength - ); -}; -} -/** - * @constructor - */ -export class BookReader { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns BookReader - */ -__init(i:number, bb:flatbuffers.ByteBuffer):BookReader { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @returns number - */ -booksRead():number { - return this.bb!.readInt32(this.bb_pos); -}; - -/** - * @param number value - * @returns boolean - */ -mutate_books_read(value:number):boolean { - this.bb!.writeInt32(this.bb_pos + 0, value); - return true; -}; - -/** - * @returns string - */ -static getFullyQualifiedName():string { - return 'BookReader'; -} - -/** - * @returns number - */ -static sizeOf():number { - return 4; -} - -/** - * @param flatbuffers.Builder builder - * @param number books_read - * @returns flatbuffers.Offset - */ -static createBookReader(builder:flatbuffers.Builder, books_read: number):flatbuffers.Offset { - builder.prep(4, 4); - builder.writeInt32(books_read); - return builder.offset(); -}; - - -/** - * @returns BookReaderT - */ -unpack(): BookReaderT { - return new BookReaderT( - this.booksRead() - ); -}; - -/** - * @param BookReaderT _o - */ -unpackTo(_o: BookReaderT): void { - _o.booksRead = this.booksRead(); -}; -} - -export class BookReaderT { -/** - * @constructor - * @param number booksRead - */ -constructor( - public booksRead: number = 0 -){}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - return BookReader.createBookReader(builder, - this.booksRead - ); -}; -} -/** - * @constructor - */ -export class Movie { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Movie - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Movie { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Movie= obj - * @returns Movie - */ -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 { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @returns boolean - */ -static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean { - return bb.__has_identifier('MOVI'); -}; - -/** - * @returns Character - */ -mainCharacterType():Character { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readUint8(this.bb_pos + offset)) : Character.NONE; -}; - -/** - * @param flatbuffers.Table obj - * @returns ?flatbuffers.Table - */ -mainCharacter<T extends flatbuffers.Table>(obj:T|string):T|string|null { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__union_with_string(obj, this.bb_pos + offset) : null; -}; - -/** - * @param number index - * @returns Character - */ -charactersType(index: number):Character|null { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? /** */ (this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index)) : /** */ (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; -}; - -/** - * @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; -}; - -/** - * @param number index - * @param flatbuffers.Table= obj - * @returns ?flatbuffers.Table - */ -characters<T extends flatbuffers.Table>(index: number, obj:T|string):T|string|null { - var offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__union_with_string(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; -}; - -/** - * @returns string - */ -static getFullyQualifiedName():string { - return 'Movie'; -} - -/** - * @param flatbuffers.Builder builder - */ -static startMovie(builder:flatbuffers.Builder) { - builder.startObject(4); -}; - -/** - * @param flatbuffers.Builder builder - * @param Character mainCharacterType - */ -static addMainCharacterType(builder:flatbuffers.Builder, mainCharacterType:Character) { - builder.addFieldInt8(0, mainCharacterType, Character.NONE); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset mainCharacterOffset - */ -static addMainCharacter(builder:flatbuffers.Builder, mainCharacterOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, mainCharacterOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset charactersTypeOffset - */ -static addCharactersType(builder:flatbuffers.Builder, charactersTypeOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, charactersTypeOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param Array.<Character> data - * @returns flatbuffers.Offset - */ -static createCharactersTypeVector(builder:flatbuffers.Builder, data:Character[]):flatbuffers.Offset { - builder.startVector(1, data.length, 1); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startCharactersTypeVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset charactersOffset - */ -static addCharacters(builder:flatbuffers.Builder, charactersOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, charactersOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param Array.<flatbuffers.Offset> data - * @returns flatbuffers.Offset - */ -static createCharactersVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startCharactersVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endMovie(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset offset - */ -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); - Movie.addMainCharacter(builder, mainCharacterOffset); - Movie.addCharactersType(builder, charactersTypeOffset); - Movie.addCharacters(builder, charactersOffset); - return Movie.endMovie(builder); -} - -/** - * @returns MovieT - */ -unpack(): MovieT { - return new MovieT( - this.mainCharacterType(), - (() => { - let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); - if(temp === null) { return null; } - if(typeof temp === 'string') { return temp; } - return temp.unpack() - })(), - this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), - (() => { - let ret = []; - for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { - let targetEnum = this.charactersType(targetEnumIndex); - if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; } - - let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); - if(temp === null) { continue; } - if(typeof temp === 'string') { ret.push(temp); continue; } - ret.push(temp.unpack()); - } - return ret; - })() - ); -}; - -/** - * @param MovieT _o - */ -unpackTo(_o: MovieT): void { - _o.mainCharacterType = this.mainCharacterType(); - _o.mainCharacter = (() => { - let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); - if(temp === null) { return null; } - if(typeof temp === 'string') { return temp; } - return temp.unpack() - })(); - _o.charactersType = this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()); - _o.characters = (() => { - let ret = []; - for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { - let targetEnum = this.charactersType(targetEnumIndex); - if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; } - - let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); - if(temp === null) { continue; } - if(typeof temp === 'string') { ret.push(temp); continue; } - ret.push(temp.unpack()); - } - return ret; - })(); -}; -} - -export class MovieT { -/** - * @constructor - * @param Character mainCharacterType - * @param AttackerT|BookReaderT|RapunzelT|string|null mainCharacter - * @param (Character)[] charactersType - * @param (AttackerT|BookReaderT|RapunzelT|string)[] characters - */ -constructor( - public mainCharacterType: Character = Character.NONE, - public mainCharacter: AttackerT|BookReaderT|RapunzelT|string|null = null, - public charactersType: (Character)[] = [], - public characters: (AttackerT|BookReaderT|RapunzelT|string)[] = [] -){}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const mainCharacter = builder.createObjectOffset(this.mainCharacter); - const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType); - const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters)); - - return Movie.createMovie(builder, - this.mainCharacterType, - mainCharacter, - charactersType, - characters - ); -}; -} |