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

* WIP size prefix support

* Consider size prefix in overloaded variant

* Work on code gen

* Disabled helper functions in code gen

* Enabled helper functions in code gen

* Fix size prefixed test

* Fix bad function call

* Add SIZE_PREFIX_LENGTH

* Fix review comments
This commit is contained in:
Björn Harrtell
2019-05-16 20:43:31 +02:00
committed by Wouter van Oortmerssen
parent b56d60f058
commit 0bb3ce6935
11 changed files with 370 additions and 61 deletions

View File

@@ -137,6 +137,15 @@ MyGame.InParentNamespace.getRootAsInParentNamespace = function(bb, obj) {
return (obj || new MyGame.InParentNamespace).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.InParentNamespace=} obj
* @returns {MyGame.InParentNamespace}
*/
MyGame.InParentNamespace.getSizePrefixedRootAsInParentNamespace = function(bb, obj) {
return (obj || new MyGame.InParentNamespace).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.Builder} builder
*/
@@ -197,6 +206,15 @@ MyGame.Example2.Monster.getRootAsMonster = function(bb, obj) {
return (obj || new MyGame.Example2.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example2.Monster=} obj
* @returns {MyGame.Example2.Monster}
*/
MyGame.Example2.Monster.getSizePrefixedRootAsMonster = function(bb, obj) {
return (obj || new MyGame.Example2.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.Builder} builder
*/
@@ -341,6 +359,15 @@ MyGame.Example.TestSimpleTableWithEnum.getRootAsTestSimpleTableWithEnum = functi
return (obj || new MyGame.Example.TestSimpleTableWithEnum).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example.TestSimpleTableWithEnum=} obj
* @returns {MyGame.Example.TestSimpleTableWithEnum}
*/
MyGame.Example.TestSimpleTableWithEnum.getSizePrefixedRootAsTestSimpleTableWithEnum = function(bb, obj) {
return (obj || new MyGame.Example.TestSimpleTableWithEnum).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns {MyGame.Example.Color}
*/
@@ -689,6 +716,15 @@ MyGame.Example.Stat.getRootAsStat = function(bb, obj) {
return (obj || new MyGame.Example.Stat).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example.Stat=} obj
* @returns {MyGame.Example.Stat}
*/
MyGame.Example.Stat.getSizePrefixedRootAsStat = function(bb, obj) {
return (obj || new MyGame.Example.Stat).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.Encoding=} optionalEncoding
* @returns {string|Uint8Array|null}
@@ -834,6 +870,15 @@ MyGame.Example.Referrable.getRootAsReferrable = function(bb, obj) {
return (obj || new MyGame.Example.Referrable).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example.Referrable=} obj
* @returns {MyGame.Example.Referrable}
*/
MyGame.Example.Referrable.getSizePrefixedRootAsReferrable = function(bb, obj) {
return (obj || new MyGame.Example.Referrable).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns {flatbuffers.Long}
*/
@@ -929,6 +974,15 @@ MyGame.Example.Monster.getRootAsMonster = function(bb, obj) {
return (obj || new MyGame.Example.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example.Monster=} obj
* @returns {MyGame.Example.Monster}
*/
MyGame.Example.Monster.getSizePrefixedRootAsMonster = function(bb, obj) {
return (obj || new MyGame.Example.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @returns {boolean}
@@ -2597,6 +2651,14 @@ MyGame.Example.Monster.finishMonsterBuffer = function(builder, offset) {
builder.finish(offset, 'MONS');
};
/**
* @param {flatbuffers.Builder} builder
* @param {flatbuffers.Offset} offset
*/
MyGame.Example.Monster.finishSizePrefixedMonsterBuffer = function(builder, offset) {
builder.finish(offset, 'MONS', true);
};
/**
* @param {flatbuffers.Builder} builder
* @param {flatbuffers.Offset} posOffset
@@ -2735,6 +2797,15 @@ MyGame.Example.TypeAliases.getRootAsTypeAliases = function(bb, obj) {
return (obj || new MyGame.Example.TypeAliases).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @param {flatbuffers.ByteBuffer} bb
* @param {MyGame.Example.TypeAliases=} obj
* @returns {MyGame.Example.TypeAliases}
*/
MyGame.Example.TypeAliases.getSizePrefixedRootAsTypeAliases = function(bb, obj) {
return (obj || new MyGame.Example.TypeAliases).__init(bb.readInt32(bb.position()) + bb.position(), bb);
};
/**
* @returns {number}
*/