From cf0d7829a67de8a1f1d926a4bd11ef831e0e3e2c Mon Sep 17 00:00:00 2001 From: benssson Date: Wed, 26 Oct 2016 18:29:36 +0100 Subject: [PATCH 1/2] Fixed javascript helper for typed arrays of scalars not taking into (#4068) account underlying buffer's byte offset. --- src/idl_gen_js.cpp | 2 +- tests/monster_test.bfbs | Bin 3320 -> 3320 bytes tests/monster_test_generated.js | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/idl_gen_js.cpp b/src/idl_gen_js.cpp index fec578029..23fd52c57 100644 --- a/src/idl_gen_js.cpp +++ b/src/idl_gen_js.cpp @@ -581,7 +581,7 @@ void GenStruct(const Parser &parser, StructDef &struct_def, std::string *code_pt code += object_name + ".prototype." + MakeCamel(field.name, false); code += "Array = function() {\n" + offset_prefix; code += "new " + GenType(vectorType) + "Array(this.bb.bytes().buffer, " - "this.bb.__vector(this.bb_pos + offset), " + "this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), " "this.bb.__vector_len(this.bb_pos + offset)) : null;\n};\n\n"; } } diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs index 41d9edb1c43c2965eddd178a73fa1c7c08409a7c..66d3ee8f215a67b4978d70df9bdb2e6d344e89b8 100644 GIT binary patch delta 53 zcmew%`9pF62af{-1A`9`vjFjA6%G>#4j?0~C^I!LC8rX|Wcc>`|9>FGv^j!f0Sf>~ CpACNi delta 52 zcmew%`9pF6hYAk^1A_z*%K$M45T_Morsk#OR05d{hkpP652TnT^Kh7Kj^J3p0suN8 B4C4R* diff --git a/tests/monster_test_generated.js b/tests/monster_test_generated.js index 774882d7c..6789ebb42 100644 --- a/tests/monster_test_generated.js +++ b/tests/monster_test_generated.js @@ -693,7 +693,7 @@ MyGame.Example.Monster.prototype.inventoryLength = function() { */ 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.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + 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; }; /** @@ -839,7 +839,7 @@ MyGame.Example.Monster.prototype.testnestedflatbufferLength = function() { */ 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.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + 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; }; /** @@ -1080,7 +1080,7 @@ MyGame.Example.Monster.prototype.testarrayofboolsLength = function() { */ 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.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + 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; }; /** From 76ae10df42513d3026c51f86961e90ee5a3c3387 Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Wed, 2 Nov 2016 16:05:31 -0500 Subject: [PATCH 2/2] Add Gitter badge (#4075) --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 38bf355dd..8d05c314d 100755 --- a/readme.md +++ b/readme.md @@ -1,5 +1,7 @@ ![logo](http://google.github.io/flatbuffers/fpl_logo_small.png) FlatBuffers =========== + +[![Join the chat at https://gitter.im/google/flatbuffers](https://badges.gitter.im/google/flatbuffers.svg)](https://gitter.im/google/flatbuffers?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/google/flatbuffers.svg?branch=master)](https://travis-ci.org/google/flatbuffers) [![Build status](https://ci.appveyor.com/api/projects/status/yg5idd2fnusv1n10?svg=true)](https://ci.appveyor.com/project/gwvo/flatbuffers) **FlatBuffers** is an efficient cross platform serialization library for games and