Java: Added ByteBufferFactory interface and sizedInputStream method. (#4379)

The ByteBufferFactory interface gives the user an option to specify
the method in which the internal ByteBuffer is allocated. This provides
flexibility in the type of ByteBuffer that can be used.
The sizedInputStream method is an alternative to sizedByteArray that
does not make a copy of the data in memory.
This commit is contained in:
Alex Wasserman
2017-07-13 10:33:32 -05:00
committed by Wouter van Oortmerssen
parent f20204180d
commit 625c989875
7 changed files with 308 additions and 173 deletions

View File

@@ -1,6 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify
import * as NS9459827973991502386 from "./namespace_test1_generated";
import * as NS3029350602 from "./namespace_test1_generated";
/**
* @constructor
*/
@@ -39,24 +39,24 @@ static getRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):T
* @param {NamespaceA.NamespaceB.TableInNestedNS=} obj
* @returns {NamespaceA.NamespaceB.TableInNestedNS|null}
*/
fooTable(obj?:NS9459827973991502386.NamespaceA.NamespaceB.TableInNestedNS):NS9459827973991502386.NamespaceA.NamespaceB.TableInNestedNS|null {
fooTable(obj?:NS3029350602.NamespaceA.NamespaceB.TableInNestedNS):NS3029350602.NamespaceA.NamespaceB.TableInNestedNS|null {
var offset = this.bb.__offset(this.bb_pos, 4);
return offset ? (obj || new NS9459827973991502386.NamespaceA.NamespaceB.TableInNestedNS).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
return offset ? (obj || new NS3029350602.NamespaceA.NamespaceB.TableInNestedNS).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
};
/**
* @returns {NamespaceA.NamespaceB.EnumInNestedNS}
*/
fooEnum():NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS {
fooEnum():NS3029350602.NamespaceA.NamespaceB.EnumInNestedNS {
var offset = this.bb.__offset(this.bb_pos, 6);
return offset ? /** @type {NamespaceA.NamespaceB.EnumInNestedNS} */ (this.bb.readInt8(this.bb_pos + offset)) : NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS.A;
return offset ? /** @type {NamespaceA.NamespaceB.EnumInNestedNS} */ (this.bb.readInt8(this.bb_pos + offset)) : NS3029350602.NamespaceA.NamespaceB.EnumInNestedNS.A;
};
/**
* @param {NamespaceA.NamespaceB.EnumInNestedNS} value
* @returns {boolean}
*/
mutate_foo_enum(value:NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS):boolean {
mutate_foo_enum(value:NS3029350602.NamespaceA.NamespaceB.EnumInNestedNS):boolean {
var offset = this.bb.__offset(this.bb_pos, 6);
if (offset === 0) {
@@ -71,9 +71,9 @@ mutate_foo_enum(value:NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS
* @param {NamespaceA.NamespaceB.StructInNestedNS=} obj
* @returns {NamespaceA.NamespaceB.StructInNestedNS|null}
*/
fooStruct(obj?:NS9459827973991502386.NamespaceA.NamespaceB.StructInNestedNS):NS9459827973991502386.NamespaceA.NamespaceB.StructInNestedNS|null {
fooStruct(obj?:NS3029350602.NamespaceA.NamespaceB.StructInNestedNS):NS3029350602.NamespaceA.NamespaceB.StructInNestedNS|null {
var offset = this.bb.__offset(this.bb_pos, 8);
return offset ? (obj || new NS9459827973991502386.NamespaceA.NamespaceB.StructInNestedNS).__init(this.bb_pos + offset, this.bb) : null;
return offset ? (obj || new NS3029350602.NamespaceA.NamespaceB.StructInNestedNS).__init(this.bb_pos + offset, this.bb) : null;
};
/**
@@ -95,8 +95,8 @@ static addFooTable(builder:flatbuffers.Builder, fooTableOffset:flatbuffers.Offse
* @param {flatbuffers.Builder} builder
* @param {NamespaceA.NamespaceB.EnumInNestedNS} fooEnum
*/
static addFooEnum(builder:flatbuffers.Builder, fooEnum:NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS) {
builder.addFieldInt8(1, fooEnum, NS9459827973991502386.NamespaceA.NamespaceB.EnumInNestedNS.A);
static addFooEnum(builder:flatbuffers.Builder, fooEnum:NS3029350602.NamespaceA.NamespaceB.EnumInNestedNS) {
builder.addFieldInt8(1, fooEnum, NS3029350602.NamespaceA.NamespaceB.EnumInNestedNS.A);
};
/**