From 79222bf100aed80940efab986a84904e2bdc8e0e Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Wed, 14 Oct 2015 21:25:16 -0700 Subject: [PATCH] Update monster_test_generated.js baseline after rebase --- src/idl_gen_js.cpp | 7 +++-- tests/monster_test.bfbs | Bin 2744 -> 2784 bytes tests/monster_test_generated.js | 48 +++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/idl_gen_js.cpp b/src/idl_gen_js.cpp index d46f41179..0e95830d9 100644 --- a/src/idl_gen_js.cpp +++ b/src/idl_gen_js.cpp @@ -579,8 +579,11 @@ static void GenStruct(const Parser &parser, StructDef &struct_def, code += " builder.startVector(" + NumToString(elem_size); code += ", data.length, " + NumToString(alignment) + ");\n"; code += " for (var i = data.length - 1; i >= 0; i--) {\n"; - code += " builder.add" + GenWriteMethod(vector_type); - code += "(data[i]);\n"; + code += " builder.add" + GenWriteMethod(vector_type) + "("; + if (vector_type.base_type == BASE_TYPE_BOOL) { + code += "+"; + } + code += "data[i]);\n"; code += " }\n"; code += " return builder.endVector();\n"; code += "};\n\n"; diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs index e5f51face696a1ee9b3aa64b70bba83df1c4645a..8d54ead7e9a3a5047063843fdf0f38af5266385b 100644 GIT binary patch literal 2784 zcmaKuOK6-`6vxjblTI?3Owt&qQG$e0N{~=&T8gWpv8^%CRQiaULY*Yvn8?gG!#slN zLPUxyS6y^bBr6dYr4$!I#8nn9y68$=Ns%n13m0A0cgNrV-nm~t>*K?678Wi=J^)uJ%F-Wts=a!tTc*mg!(8n3G zeazo8pURot8bTg=GY^k_0d2C8!%6`hBQwK~Y)I!9kGfs)AZP0X=F8AzZ~tn%#VYT7 zEuaatPWBEC;$AWiu(}wv+7~uzjcRnUyi$$c+Gwwzjyp9@^2lVd@8!qf%wo|QWsRG5 zwjQ_IQPYauZdZPZmd-7mX0kPSX`d@UJD>X{uUNbdDIU^00KHbP)|MiMzkAbv;50gY$al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0I84=K$jw5)gyMth(-R*VUy0hJJFSmo%d2iUoN)9#&>~HM3_bGS|oeM&d zi@rAq+`i-{lL_OX)GpP|L&+BA$eH=6LXwbI{Epv;CjS=XEQEe<{h_?$^!+RBI0vfJ zLBH#rp=&vDjWH1yjfZ=@+IL+Kt7WZ|!I6jM&As1p8(KkD5*5=N6SD|m9`le3eZTv< zx6>ImT(#x=8-{1r?3sf#nVCKKL{6d2rqdDG2j1p@`$u#34E}!&GM~cP5{!2tKjZ(m z&~?afkaPH7fNVi{zJ37q6UaR}gT4X%0FP&(uR=GVKZkw{AwC1lO>kJ0RgIJ}FlPa3 z?)3Z4*l%w8erJFw@&0BFigR~?KO!qr{Gkxvat5v8+Uk|2H#+TL?#Z88vs?nHTX;u_yu$fD@FcMK7$DUn!%^{fPYF(PVqM0D1W$- zZwx;7J@AL+#7w;9PyFv8|9#*O$?=(Z%b)mTe`&m#VJflpqZRa~?_;rR-9sqlbZH-1aB zc@Z|eo#=ZBVrv@O41#{!dk@`|!A;7ZVPApMd>?jMsi+-$m7EyIDi8(5n!5_v5{|xH z2R?&nZ478B#Y4%mo_7sRZUdK=!-`{WY%Z?^?*lN8K|W4!cj2l?!T zcic5&qj%a#6WAgEqrWO^D zeUcSD9R+Y_KI|aR7-npK_Ur;Q^WSwmULW!j@(7jm^jz4R*t{Eh{y^@S^%C_L0?wo;Ae@Nf-z4s%YZ$LhR&^{UV5pBtvXPbt< zm_77NkAO>ry%X($73~3@6?<+(&)!Yo;~LRHAJgw?Aipzy3%7x>Ib+;B=pR7%E{4iK z#Ci;oFkh@I*LiL;+MTvPC4V0{n^R)0Lg-uaMKCzX9lx8n&k}^V|N9Q%I(vp4z#GHV zg&8u#)`c@w2dxUDHnh diff --git a/tests/monster_test_generated.js b/tests/monster_test_generated.js index 39cd3d2e8..5687308e8 100644 --- a/tests/monster_test_generated.js +++ b/tests/monster_test_generated.js @@ -631,11 +631,28 @@ MyGame.Example.Monster.prototype.testhashu64Fnv1a = function() { return offset ? this.bb.readUint64(this.bb_pos + offset) : flatbuffers.Long.ZERO; }; +/** + * @param {number} index + * @returns {boolean} + */ +MyGame.Example.Monster.prototype.testarrayofbools = function(index) { + var offset = this.bb.__offset(this.bb_pos, 52); + return offset ? !!this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : false; +}; + +/** + * @returns {number} + */ +MyGame.Example.Monster.prototype.testarrayofboolsLength = function() { + var offset = this.bb.__offset(this.bb_pos, 52); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; +}; + /** * @param {flatbuffers.Builder} builder */ MyGame.Example.Monster.startMonster = function(builder) { - builder.startObject(24); + builder.startObject(25); }; /** @@ -914,6 +931,35 @@ MyGame.Example.Monster.addTesthashu64Fnv1a = function(builder, testhashu64Fnv1a) builder.addFieldInt64(23, testhashu64Fnv1a, flatbuffers.Long.ZERO); }; +/** + * @param {flatbuffers.Builder} builder + * @param {flatbuffers.Offset} testarrayofboolsOffset + */ +MyGame.Example.Monster.addTestarrayofbools = function(builder, testarrayofboolsOffset) { + builder.addFieldOffset(24, testarrayofboolsOffset, 0); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {Array.} data + * @returns {flatbuffers.Offset} + */ +MyGame.Example.Monster.createTestarrayofboolsVector = function(builder, data) { + builder.startVector(1, data.length, 1); + for (var i = data.length - 1; i >= 0; i--) { + builder.addInt8(+data[i]); + } + return builder.endVector(); +}; + +/** + * @param {flatbuffers.Builder} builder + * @param {number} numElems + */ +MyGame.Example.Monster.startTestarrayofboolsVector = function(builder, numElems) { + builder.startVector(1, numElems, 1); +}; + /** * @param {flatbuffers.Builder} builder * @returns {flatbuffers.Offset}