diff options
author | Mark Klara <mrhappyasthma@google.com> | 2015-12-03 20:30:54 -0800 |
---|---|---|
committer | Mark Klara <mrhappyasthma@google.com> | 2016-01-19 14:31:17 -0800 |
commit | 69a31b807a85e9a5ca4efb839f37ecb6dcf3eed5 (patch) | |
tree | 1b20b2ec1aa2749b693122ced5b3394cc355cb08 /js | |
parent | d75d29e2feb23debf2745c185a328294aa80d8be (diff) | |
download | flatbuffers-69a31b807a85e9a5ca4efb839f37ecb6dcf3eed5.tar.gz flatbuffers-69a31b807a85e9a5ca4efb839f37ecb6dcf3eed5.tar.bz2 flatbuffers-69a31b807a85e9a5ca4efb839f37ecb6dcf3eed5.zip |
Revamping the FlatBuffers docs.
Adding an API reference for the supported languages.
General docs cleanup, including a new `tutorial` section that
supports all of the supported languages.
Added samples for each supported language to mirror the new
tutorial page.
Cleaned up all the links by making them `@ref` style links,
instead of referencing the names of the generated `.html` files.
Removed all generated files that were unnecessarily committed.
Also fixed the C# tests (two were failing due to a missing file).
Bug: b/25801305
Tested: Tested all samples on Ubuntu, Mac, and Android. Docs were
generated using doxygen and viewed on Chrome.
Change-Id: I2acaba6e332a15ae2deff5f26a4a25da7bd2c954
Diffstat (limited to 'js')
-rw-r--r-- | js/flatbuffers.js | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/js/flatbuffers.js b/js/flatbuffers.js index efa76d94..f3c48342 100644 --- a/js/flatbuffers.js +++ b/js/flatbuffers.js @@ -1,3 +1,7 @@ +/// @file +/// @addtogroup flatbuffers_javascript_api +/// @{ +/// @cond FLATBUFFERS_INTERNAL var flatbuffers = {}; /** @@ -105,9 +109,11 @@ flatbuffers.Long.prototype.equals = function(other) { */ flatbuffers.Long.ZERO = new flatbuffers.Long(0, 0); +/// @endcond //////////////////////////////////////////////////////////////////////////////// - /** + * Create a FlatBufferBuilder. + * * @constructor * @param {number=} initial_size */ @@ -228,6 +234,7 @@ flatbuffers.Builder.prototype.asUint8Array = function() { return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset()); }; +/// @cond FLATBUFFERS_INTERNAL /** * Prepare to write an element of `size` after `additional_bytes` have been * written, e.g. if you write a string, you need to align such the int length @@ -307,9 +314,11 @@ flatbuffers.Builder.prototype.writeFloat32 = function(value) { flatbuffers.Builder.prototype.writeFloat64 = function(value) { this.bb.writeFloat64(this.space -= 8, value); }; +/// @endcond /** - * @param {number} value + * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {number} value The `int8` to add the the buffer. */ flatbuffers.Builder.prototype.addInt8 = function(value) { this.prep(1, 0); @@ -317,7 +326,8 @@ flatbuffers.Builder.prototype.addInt8 = function(value) { }; /** - * @param {number} value + * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {number} value The `int16` to add the the buffer. */ flatbuffers.Builder.prototype.addInt16 = function(value) { this.prep(2, 0); @@ -325,7 +335,8 @@ flatbuffers.Builder.prototype.addInt16 = function(value) { }; /** - * @param {number} value + * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {number} value The `int32` to add the the buffer. */ flatbuffers.Builder.prototype.addInt32 = function(value) { this.prep(4, 0); @@ -333,7 +344,8 @@ flatbuffers.Builder.prototype.addInt32 = function(value) { }; /** - * @param {flatbuffers.Long} value + * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {flatbuffers.Long} value The `int64` to add the the buffer. */ flatbuffers.Builder.prototype.addInt64 = function(value) { this.prep(8, 0); @@ -341,7 +353,8 @@ flatbuffers.Builder.prototype.addInt64 = function(value) { }; /** - * @param {number} value + * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {number} value The `float32` to add the the buffer. */ flatbuffers.Builder.prototype.addFloat32 = function(value) { this.prep(4, 0); @@ -349,13 +362,15 @@ flatbuffers.Builder.prototype.addFloat32 = function(value) { }; /** - * @param {number} value + * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary). + * @param {number} value The `float64` to add the the buffer. */ flatbuffers.Builder.prototype.addFloat64 = function(value) { this.prep(8, 0); this.writeFloat64(value); }; +/// @cond FLATBUFFERS_INTERNAL /** * @param {number} voffset * @param {number} value @@ -515,17 +530,19 @@ flatbuffers.Builder.growByteBuffer = function(bb) { nbb.bytes().set(bb.bytes(), new_buf_size - old_buf_size); return nbb; }; +/// @endcond /** * Adds on offset, relative to where it will be written. * - * @param {flatbuffers.Offset} offset The offset to add + * @param {flatbuffers.Offset} offset The offset to add. */ flatbuffers.Builder.prototype.addOffset = function(offset) { this.prep(flatbuffers.SIZEOF_INT, 0); // Ensure alignment is already done. this.writeInt32(this.offset() - offset + flatbuffers.SIZEOF_INT); }; +/// @cond FLATBUFFERS_INTERNAL /** * Start encoding a new object in the buffer. Users will not usually need to * call this directly. The FlatBuffers compiler will generate helper methods @@ -606,8 +623,11 @@ outer_loop: this.isNested = false; return vtableloc; }; +/// @endcond /** + * Finalize a buffer, poiting to the given `root_table`. + * * @param {flatbuffers.Offset} root_table * @param {string=} file_identifier */ @@ -628,6 +648,7 @@ flatbuffers.Builder.prototype.finish = function(root_table, file_identifier) { this.bb.setPosition(this.space); }; +/// @cond FLATBUFFERS_INTERNAL /** * This checks a required field has been set in a given table that has * just been constructed. @@ -673,6 +694,7 @@ flatbuffers.Builder.prototype.endVector = function() { this.writeInt32(this.vector_num_elems); return this.offset(); }; +/// @endcond /** * Encode the string `s` in the buffer using UTF-8. If a Uint8Array is passed @@ -729,10 +751,11 @@ flatbuffers.Builder.prototype.createString = function(s) { } return this.endVector(); }; - //////////////////////////////////////////////////////////////////////////////// - +/// @cond FLATBUFFERS_INTERNAL /** + * Create a new ByteBuffer with a given array of bytes (`Uint8Array`). + * * @constructor * @param {Uint8Array} bytes */ @@ -751,6 +774,8 @@ flatbuffers.ByteBuffer = function(bytes) { }; /** + * Create and allocate a new ByteBuffer with a given size. + * * @param {number} byte_size * @returns {flatbuffers.ByteBuffer} */ @@ -759,6 +784,8 @@ flatbuffers.ByteBuffer.allocate = function(byte_size) { }; /** + * Get the underlying `Uint8Array`. + * * @returns {Uint8Array} */ flatbuffers.ByteBuffer.prototype.bytes = function() { @@ -766,6 +793,8 @@ flatbuffers.ByteBuffer.prototype.bytes = function() { }; /** + * Get the buffer's position. + * * @returns {number} */ flatbuffers.ByteBuffer.prototype.position = function() { @@ -773,6 +802,8 @@ flatbuffers.ByteBuffer.prototype.position = function() { }; /** + * Set the buffer's position. + * * @param {number} position */ flatbuffers.ByteBuffer.prototype.setPosition = function(position) { @@ -780,6 +811,8 @@ flatbuffers.ByteBuffer.prototype.setPosition = function(position) { }; /** + * Get the buffer's capacity. + * * @returns {number} */ flatbuffers.ByteBuffer.prototype.capacity = function() { @@ -1070,3 +1103,6 @@ flatbuffers.ByteBuffer.prototype.__has_identifier = function(ident) { // Exports for Node.js and RequireJS this.flatbuffers = flatbuffers; + +/// @endcond +/// @} |