Lines Matching full:flatbuffers

18 var flatbuffers = {};  variable
23 flatbuffers.Offset;
27 * bb: flatbuffers.ByteBuffer,
31 flatbuffers.Table;
37 flatbuffers.SIZEOF_SHORT = 2;
43 flatbuffers.SIZEOF_INT = 4;
49 flatbuffers.FILE_IDENTIFIER_LENGTH = 4;
55 flatbuffers.SIZE_PREFIX_LENGTH = 4;
60 flatbuffers.Encoding = {
69 flatbuffers.int32 = new Int32Array(2);
75 flatbuffers.float32 = new Float32Array(flatbuffers.int32.buffer);
81 flatbuffers.float64 = new Float64Array(flatbuffers.int32.buffer);
87 flatbuffers.isLittleEndian = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
96 flatbuffers.Long = function(low, high) {
113 * @returns {!flatbuffers.Long}
115 flatbuffers.Long.create = function(low, high) {
117 return low == 0 && high == 0 ? flatbuffers.Long.ZERO : new flatbuffers.Long(low, high);
123 flatbuffers.Long.prototype.toFloat64 = function() {
128 * @param {flatbuffers.Long} other
131 flatbuffers.Long.prototype.equals = function(other) {
136 * @type {!flatbuffers.Long}
139 flatbuffers.Long.ZERO = new flatbuffers.Long(0, 0);
149 flatbuffers.Builder = function(opt_initial_size) {
157 * @type {flatbuffers.ByteBuffer}
160 this.bb = flatbuffers.ByteBuffer.allocate(initial_size);
235 flatbuffers.Builder.prototype.clear = function() {
255 flatbuffers.Builder.prototype.forceDefaults = function(forceDefaults) {
264 * @returns {flatbuffers.ByteBuffer}
266 flatbuffers.Builder.prototype.dataBuffer = function() {
276 flatbuffers.Builder.prototype.asUint8Array = function() {
290 flatbuffers.Builder.prototype.prep = function(size, additional_bytes) {
303 this.bb = flatbuffers.Builder.growByteBuffer(this.bb);
313 flatbuffers.Builder.prototype.pad = function(byte_size) {
322 flatbuffers.Builder.prototype.writeInt8 = function(value) {
329 flatbuffers.Builder.prototype.writeInt16 = function(value) {
336 flatbuffers.Builder.prototype.writeInt32 = function(value) {
341 * @param {flatbuffers.Long} value
343 flatbuffers.Builder.prototype.writeInt64 = function(value) {
350 flatbuffers.Builder.prototype.writeFloat32 = function(value) {
357 flatbuffers.Builder.prototype.writeFloat64 = function(value) {
366 flatbuffers.Builder.prototype.addInt8 = function(value) {
375 flatbuffers.Builder.prototype.addInt16 = function(value) {
384 flatbuffers.Builder.prototype.addInt32 = function(value) {
391 * @param {flatbuffers.Long} value The `int64` to add the the buffer.
393 flatbuffers.Builder.prototype.addInt64 = function(value) {
402 flatbuffers.Builder.prototype.addFloat32 = function(value) {
411 flatbuffers.Builder.prototype.addFloat64 = function(value) {
422 flatbuffers.Builder.prototype.addFieldInt8 = function(voffset, value, defaultValue) {
434 flatbuffers.Builder.prototype.addFieldInt16 = function(voffset, value, defaultValue) {
446 flatbuffers.Builder.prototype.addFieldInt32 = function(voffset, value, defaultValue) {
455 * @param {flatbuffers.Long} value
456 * @param {flatbuffers.Long} defaultValue
458 flatbuffers.Builder.prototype.addFieldInt64 = function(voffset, value, defaultValue) {
470 flatbuffers.Builder.prototype.addFieldFloat32 = function(voffset, value, defaultValue) {
482 flatbuffers.Builder.prototype.addFieldFloat64 = function(voffset, value, defaultValue) {
491 * @param {flatbuffers.Offset} value
492 * @param {flatbuffers.Offset} defaultValue
494 flatbuffers.Builder.prototype.addFieldOffset = function(voffset, value, defaultValue) {
505 * @param {flatbuffers.Offset} value
506 * @param {flatbuffers.Offset} defaultValue
508 flatbuffers.Builder.prototype.addFieldStruct = function(voffset, value, defaultValue) {
520 * @param {flatbuffers.Offset} obj The offset of the created object
522 flatbuffers.Builder.prototype.nested = function(obj) {
524 throw new Error('FlatBuffers: struct must be serialized inline.');
532 flatbuffers.Builder.prototype.notNested = function() {
534 throw new Error('FlatBuffers: object serialization must not be nested.');
543 flatbuffers.Builder.prototype.slot = function(voffset) {
548 * @returns {flatbuffers.Offset} Offset relative to the end of the buffer.
550 flatbuffers.Builder.prototype.offset = function() {
558 * @param {flatbuffers.ByteBuffer} bb The current buffer with the existing data
559 * @returns {!flatbuffers.ByteBuffer} A new byte buffer with the old data copied
566 flatbuffers.Builder.growByteBuffer = function(bb) {
571 throw new Error('FlatBuffers: cannot grow buffer beyond 2 gigabytes.');
575 var nbb = flatbuffers.ByteBuffer.allocate(new_buf_size);
585 * @param {flatbuffers.Offset} offset The offset to add.
587 flatbuffers.Builder.prototype.addOffset = function(offset) {
588 this.prep(flatbuffers.SIZEOF_INT, 0); // Ensure alignment is already done.
589 this.writeInt32(this.offset() - offset + flatbuffers.SIZEOF_INT);
595 * call this directly. The FlatBuffers compiler will generate helper methods
600 flatbuffers.Builder.prototype.startObject = function(numfields) {
616 * @returns {flatbuffers.Offset} The offset to the object inside `dataBuffer`
618 flatbuffers.Builder.prototype.endObject = function() {
620 throw new Error('FlatBuffers: endObject called without startObject');
639 var len = (trimmed_size + standard_fields) * flatbuffers.SIZEOF_SHORT;
649 for (var j = flatbuffers.SIZEOF_SHORT; j < len; j += flatbuffers.SIZEOF_SHORT) {
683 * @param {flatbuffers.Offset} root_table
687 flatbuffers.Builder.prototype.finish = function(root_table, opt_file_identifier, opt_size_prefix) {
688 var size_prefix = opt_size_prefix ? flatbuffers.SIZE_PREFIX_LENGTH : 0;
691 this.prep(this.minalign, flatbuffers.SIZEOF_INT +
692 flatbuffers.FILE_IDENTIFIER_LENGTH + size_prefix);
693 if (file_identifier.length != flatbuffers.FILE_IDENTIFIER_LENGTH) {
694 throw new Error('FlatBuffers: file identifier must be length ' +
695 flatbuffers.FILE_IDENTIFIER_LENGTH);
697 for (var i = flatbuffers.FILE_IDENTIFIER_LENGTH - 1; i >= 0; i--) {
701 this.prep(this.minalign, flatbuffers.SIZEOF_INT + size_prefix);
712 * @param {flatbuffers.Offset} root_table
715 flatbuffers.Builder.prototype.finishSizePrefixed = function (root_table, opt_file_identifier) {
724 * @param {flatbuffers.Offset} table
727 flatbuffers.Builder.prototype.requiredField = function(table, field) {
734 throw new Error('FlatBuffers: field ' + field + ' must be set');
740 * this directly. The FlatBuffers compiler will create a start/end
747 flatbuffers.Builder.prototype.startVector = function(elem_size, num_elems, alignment) {
750 this.prep(flatbuffers.SIZEOF_INT, elem_size * num_elems);
758 * @returns {flatbuffers.Offset} The offset at which the newly created array
761 flatbuffers.Builder.prototype.endVector = function() {
772 * @return {flatbuffers.Offset} The offset in the buffer where the encoded string starts
774 flatbuffers.Builder.prototype.createString = function(s) {
828 * @returns {!flatbuffers.Long}
830 flatbuffers.Builder.prototype.createLong = function(low, high) {
831 return flatbuffers.Long.create(low, high);
841 flatbuffers.ByteBuffer = function(bytes) {
859 * @returns {!flatbuffers.ByteBuffer}
861 flatbuffers.ByteBuffer.allocate = function(byte_size) {
862 return new flatbuffers.ByteBuffer(new Uint8Array(byte_size));
865 flatbuffers.ByteBuffer.prototype.clear = function() {
874 flatbuffers.ByteBuffer.prototype.bytes = function() {
883 flatbuffers.ByteBuffer.prototype.position = function() {
892 flatbuffers.ByteBuffer.prototype.setPosition = function(position) {
901 flatbuffers.ByteBuffer.prototype.capacity = function() {
909 flatbuffers.ByteBuffer.prototype.readInt8 = function(offset) {
917 flatbuffers.ByteBuffer.prototype.readUint8 = function(offset) {
925 flatbuffers.ByteBuffer.prototype.readInt16 = function(offset) {
933 flatbuffers.ByteBuffer.prototype.readUint16 = function(offset) {
941 flatbuffers.ByteBuffer.prototype.readInt32 = function(offset) {
949 flatbuffers.ByteBuffer.prototype.readUint32 = function(offset) {
955 * @returns {!flatbuffers.Long}
957 flatbuffers.ByteBuffer.prototype.readInt64 = function(offset) {
958 return new flatbuffers.Long(this.readInt32(offset), this.readInt32(offset + 4));
963 * @returns {!flatbuffers.Long}
965 flatbuffers.ByteBuffer.prototype.readUint64 = function(offset) {
966 return new flatbuffers.Long(this.readUint32(offset), this.readUint32(offset + 4));
973 flatbuffers.ByteBuffer.prototype.readFloat32 = function(offset) {
974 flatbuffers.int32[0] = this.readInt32(offset);
975 return flatbuffers.float32[0];
982 flatbuffers.ByteBuffer.prototype.readFloat64 = function(offset) {
983 flatbuffers.int32[flatbuffers.isLittleEndian ? 0 : 1] = this.readInt32(offset);
984 flatbuffers.int32[flatbuffers.isLittleEndian ? 1 : 0] = this.readInt32(offset + 4);
985 return flatbuffers.float64[0];
992 flatbuffers.ByteBuffer.prototype.writeInt8 = function(offset, value) {
1000 flatbuffers.ByteBuffer.prototype.writeUint8 = function(offset, value) {
1008 flatbuffers.ByteBuffer.prototype.writeInt16 = function(offset, value) {
1017 flatbuffers.ByteBuffer.prototype.writeUint16 = function(offset, value) {
1026 flatbuffers.ByteBuffer.prototype.writeInt32 = function(offset, value) {
1037 flatbuffers.ByteBuffer.prototype.writeUint32 = function(offset, value) {
1046 * @param {flatbuffers.Long} value
1048 flatbuffers.ByteBuffer.prototype.writeInt64 = function(offset, value) {
1055 * @param {flatbuffers.Long} value
1057 flatbuffers.ByteBuffer.prototype.writeUint64 = function(offset, value) {
1066 flatbuffers.ByteBuffer.prototype.writeFloat32 = function(offset, value) {
1067 flatbuffers.float32[0] = value;
1068 this.writeInt32(offset, flatbuffers.int32[0]);
1075 flatbuffers.ByteBuffer.prototype.writeFloat64 = function(offset, value) {
1076 flatbuffers.float64[0] = value;
1077 this.writeInt32(offset, flatbuffers.int32[flatbuffers.isLittleEndian ? 0 : 1]);
1078 this.writeInt32(offset + 4, flatbuffers.int32[flatbuffers.isLittleEndian ? 1 : 0]);
1082 * Return the file identifier. Behavior is undefined for FlatBuffers whose
1087 flatbuffers.ByteBuffer.prototype.getBufferIdentifier = function() {
1088 if (this.bytes_.length < this.position_ + flatbuffers.SIZEOF_INT +
1089 flatbuffers.FILE_IDENTIFIER_LENGTH) {
1091 'FlatBuffers: ByteBuffer is too short to contain an identifier.');
1094 for (var i = 0; i < flatbuffers.FILE_IDENTIFIER_LENGTH; i++) {
1096 this.readInt8(this.position_ + flatbuffers.SIZEOF_INT + i));
1109 flatbuffers.ByteBuffer.prototype.__offset = function(bb_pos, vtable_offset) {
1117 * @param {flatbuffers.Table} t
1119 * @returns {flatbuffers.Table}
1121 flatbuffers.ByteBuffer.prototype.__union = function(t, offset) {
1131 * To avoid the conversion to UTF-16, pass flatbuffers.Encoding.UTF8_BYTES as
1137 * @param {flatbuffers.Encoding=} opt_encoding Defaults to UTF16_STRING
1140 flatbuffers.ByteBuffer.prototype.__string = function(offset, opt_encoding) {
1147 offset += flatbuffers.SIZEOF_INT;
1149 if (opt_encoding === flatbuffers.Encoding.UTF8_BYTES) {
1203 flatbuffers.ByteBuffer.prototype.__indirect = function(offset) {
1213 flatbuffers.ByteBuffer.prototype.__vector = function(offset) {
1214 return offset + this.readInt32(offset) + flatbuffers.SIZEOF_INT; // data starts after the length
1223 flatbuffers.ByteBuffer.prototype.__vector_len = function(offset) {
1231 flatbuffers.ByteBuffer.prototype.__has_identifier = function(ident) {
1232 if (ident.length != flatbuffers.FILE_IDENTIFIER_LENGTH) {
1233 throw new Error('FlatBuffers: file identifier must be length ' +
1234 flatbuffers.FILE_IDENTIFIER_LENGTH);
1236 for (var i = 0; i < flatbuffers.FILE_IDENTIFIER_LENGTH; i++) {
1237 if (ident.charCodeAt(i) != this.readInt8(this.position_ + flatbuffers.SIZEOF_INT + i)) {
1249 * @returns {!flatbuffers.Long}
1251 flatbuffers.ByteBuffer.prototype.createLong = function(low, high) {
1252 return flatbuffers.Long.create(low, high);
1256 this.flatbuffers = flatbuffers;