diff options
author | Wouter van Oortmerssen <wvo@google.com> | 2014-09-11 14:36:33 -0700 |
---|---|---|
committer | Wouter van Oortmerssen <wvo@google.com> | 2014-09-15 16:19:27 -0700 |
commit | cb58fc6fa13fc632ebb50225aaedaa2c68ac3094 (patch) | |
tree | 577986d61beef7aa584c9bd5981d24e6d303055e /tests/MyGame | |
parent | 858e9961e2d9291ef47ee3a9e23971ac429121b3 (diff) | |
download | flatbuffers-cb58fc6fa13fc632ebb50225aaedaa2c68ac3094.tar.gz flatbuffers-cb58fc6fa13fc632ebb50225aaedaa2c68ac3094.tar.bz2 flatbuffers-cb58fc6fa13fc632ebb50225aaedaa2c68ac3094.zip |
Added convenient vector from array construction for Java.
Change-Id: Ib3fd576cf9fa4b4058a9fd1bbe24a0859bc3917a
Tested: on Linux.
Diffstat (limited to 'tests/MyGame')
-rwxr-xr-x | tests/MyGame/Example/Monster.java | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/MyGame/Example/Monster.java b/tests/MyGame/Example/Monster.java index fa7bc21e..f8148980 100755 --- a/tests/MyGame/Example/Monster.java +++ b/tests/MyGame/Example/Monster.java @@ -50,6 +50,7 @@ public class Monster extends Table { public static void addHp(FlatBufferBuilder builder, short hp) { builder.addShort(2, hp, 100); } public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(3, nameOffset, 0); } public static void addInventory(FlatBufferBuilder builder, int inventoryOffset) { builder.addOffset(5, inventoryOffset, 0); } + public static int createInventoryVector(FlatBufferBuilder builder, byte[] data) { builder.startVector(1, data.length, 1); for (int i = data.length - 1; i >= 0; i--) builder.addByte(data[i]); return builder.endVector(); } public static void startInventoryVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); } public static void addColor(FlatBufferBuilder builder, byte color) { builder.addByte(6, color, 8); } public static void addTestType(FlatBufferBuilder builder, byte testType) { builder.addByte(7, testType, 0); } @@ -57,11 +58,14 @@ public class Monster extends Table { public static void addTest4(FlatBufferBuilder builder, int test4Offset) { builder.addOffset(9, test4Offset, 0); } public static void startTest4Vector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 2); } public static void addTestarrayofstring(FlatBufferBuilder builder, int testarrayofstringOffset) { builder.addOffset(10, testarrayofstringOffset, 0); } + public static int createTestarrayofstringVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); } public static void startTestarrayofstringVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } public static void addTestarrayoftables(FlatBufferBuilder builder, int testarrayoftablesOffset) { builder.addOffset(11, testarrayoftablesOffset, 0); } + public static int createTestarrayoftablesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); } public static void startTestarrayoftablesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } public static void addEnemy(FlatBufferBuilder builder, int enemyOffset) { builder.addOffset(12, enemyOffset, 0); } public static void addTestnestedflatbuffer(FlatBufferBuilder builder, int testnestedflatbufferOffset) { builder.addOffset(13, testnestedflatbufferOffset, 0); } + public static int createTestnestedflatbufferVector(FlatBufferBuilder builder, byte[] data) { builder.startVector(1, data.length, 1); for (int i = data.length - 1; i >= 0; i--) builder.addByte(data[i]); return builder.endVector(); } public static void startTestnestedflatbufferVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); } public static void addTestempty(FlatBufferBuilder builder, int testemptyOffset) { builder.addOffset(14, testemptyOffset, 0); } public static int endMonster(FlatBufferBuilder builder) { return builder.endObject(); } |