From be9d562d57e832bf858bd104306878294e2c9fa1 Mon Sep 17 00:00:00 2001
From: Siarhei Fedartsou
- * The expected sequence of calls is:
- *
- * For example, to create an array of strings, do:
- *
- * For example, using the "Monster" code found on the "landing page". An
- * object of type `Monster` can be created using the following code:
- *
- *
- * Here:
- *
- * It's not recommended to call this method directly. If it's called manually, you must ensure
- * to audit all calls to it whenever fields are added or removed from your schema. This is
- * automatically done by the code generated by the `FlatBuffers` compiler.
- *
- * @param numfields The number of fields found in this object.
- */
- public void startTable(int numfields) {
- notNested();
- if (vtable == null || vtable.length < numfields) vtable = new int[numfields];
- vtable_in_use = numfields;
- Arrays.fill(vtable, 0, vtable_in_use, 0);
- nested = true;
- object_start = offset();
- }
-
- /**
- * Add a `boolean` to a table at `o` into its vtable, with value `x` and default `d`.
- *
- * @param o The index into the vtable.
- * @param x A `boolean` to put into the buffer, depending on how defaults are handled. If
- * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the
- * default value, it can be skipped.
- * @param d A `boolean` default value to compare against when `force_defaults` is `false`.
- */
- public void addBoolean(int o, boolean x, boolean d) { if(force_defaults || x != d) { addBoolean(x); slot(o); } }
-
- /**
- * Add a `byte` to a table at `o` into its vtable, with value `x` and default `d`.
- *
- * @param o The index into the vtable.
- * @param x A `byte` to put into the buffer, depending on how defaults are handled. If
- * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the
- * default value, it can be skipped.
- * @param d A `byte` default value to compare against when `force_defaults` is `false`.
- */
- public void addByte (int o, byte x, int d) { if(force_defaults || x != d) { addByte (x); slot(o); } }
-
- /**
- * Add a `short` to a table at `o` into its vtable, with value `x` and default `d`.
- *
- * @param o The index into the vtable.
- * @param x A `short` to put into the buffer, depending on how defaults are handled. If
- * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the
- * default value, it can be skipped.
- * @param d A `short` default value to compare against when `force_defaults` is `false`.
- */
- public void addShort (int o, short x, int d) { if(force_defaults || x != d) { addShort (x); slot(o); } }
-
- /**
- * Add an `int` to a table at `o` into its vtable, with value `x` and default `d`.
- *
- * @param o The index into the vtable.
- * @param x An `int` to put into the buffer, depending on how defaults are handled. If
- * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the
- * default value, it can be skipped.
- * @param d An `int` default value to compare against when `force_defaults` is `false`.
- */
- public void addInt (int o, int x, int d) { if(force_defaults || x != d) { addInt (x); slot(o); } }
-
- /**
- * Add a `long` to a table at `o` into its vtable, with value `x` and default `d`.
- *
- * @param o The index into the vtable.
- * @param x A `long` to put into the buffer, depending on how defaults are handled. If
- * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the
- * default value, it can be skipped.
- * @param d A `long` default value to compare against when `force_defaults` is `false`.
- */
- public void addLong (int o, long x, long d) { if(force_defaults || x != d) { addLong (x); slot(o); } }
-
- /**
- * Add a `float` to a table at `o` into its vtable, with value `x` and default `d`.
- *
- * @param o The index into the vtable.
- * @param x A `float` to put into the buffer, depending on how defaults are handled. If
- * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the
- * default value, it can be skipped.
- * @param d A `float` default value to compare against when `force_defaults` is `false`.
- */
- public void addFloat (int o, float x, double d) { if(force_defaults || x != d) { addFloat (x); slot(o); } }
-
- /**
- * Add a `double` to a table at `o` into its vtable, with value `x` and default `d`.
- *
- * @param o The index into the vtable.
- * @param x A `double` to put into the buffer, depending on how defaults are handled. If
- * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the
- * default value, it can be skipped.
- * @param d A `double` default value to compare against when `force_defaults` is `false`.
- */
- public void addDouble (int o, double x, double d) { if(force_defaults || x != d) { addDouble (x); slot(o); } }
-
- /**
- * Add an `offset` to a table at `o` into its vtable, with value `x` and default `d`.
- *
- * @param o The index into the vtable.
- * @param x An `offset` to put into the buffer, depending on how defaults are handled. If
- * `force_defaults` is `false`, compare `x` against the default value `d`. If `x` contains the
- * default value, it can be skipped.
- * @param d An `offset` default value to compare against when `force_defaults` is `false`.
- */
- public void addOffset (int o, int x, int d) { if(force_defaults || x != d) { addOffset (x); slot(o); } }
-
- /**
- * Add a struct to the table. Structs are stored inline, so nothing additional is being added.
- *
- * @param voffset The index into the vtable.
- * @param x The offset of the created struct.
- * @param d The default value is always `0`.
- */
- public void addStruct(int voffset, int x, int d) {
- if(x != d) {
- Nested(x);
- slot(voffset);
- }
- }
-
- /**
- * Set the current vtable at `voffset` to the current location in the buffer.
- *
- * @param voffset The index into the vtable to store the offset relative to the end of the
- * buffer.
- */
- public void slot(int voffset) {
- vtable[voffset] = offset();
- }
-
- /**
- * Finish off writing the object that is under construction.
- *
- * @return The offset to the object inside {@link #dataBuffer()}.
- * @see #startTable(int)
- */
- public int endTable() {
- if (vtable == null || !nested)
- throw new AssertionError("FlatBuffers: endTable called without startTable");
- addInt(0);
- int vtableloc = offset();
- // Write out the current vtable.
- int i = vtable_in_use - 1;
- // Trim trailing zeroes.
- for (; i >= 0 && vtable[i] == 0; i--) {}
- int trimmed_size = i + 1;
- for (; i >= 0 ; i--) {
- // Offset relative to the start of the table.
- short off = (short)(vtable[i] != 0 ? vtableloc - vtable[i] : 0);
- addShort(off);
- }
-
- final int standard_fields = 2; // The fields below:
- addShort((short)(vtableloc - object_start));
- addShort((short)((trimmed_size + standard_fields) * SIZEOF_SHORT));
-
- // Search for an existing vtable that matches the current one.
- int existing_vtable = 0;
- outer_loop:
- for (i = 0; i < num_vtables; i++) {
- int vt1 = bb.capacity() - vtables[i];
- int vt2 = space;
- short len = bb.getShort(vt1);
- if (len == bb.getShort(vt2)) {
- for (int j = SIZEOF_SHORT; j < len; j += SIZEOF_SHORT) {
- if (bb.getShort(vt1 + j) != bb.getShort(vt2 + j)) {
- continue outer_loop;
- }
- }
- existing_vtable = vtables[i];
- break outer_loop;
- }
- }
-
- if (existing_vtable != 0) {
- // Found a match:
- // Remove the current vtable.
- space = bb.capacity() - vtableloc;
- // Point table to existing vtable.
- bb.putInt(space, existing_vtable - vtableloc);
- } else {
- // No match:
- // Add the location of the current vtable to the list of vtables.
- if (num_vtables == vtables.length) vtables = Arrays.copyOf(vtables, num_vtables * 2);
- vtables[num_vtables++] = offset();
- // Point table to current vtable.
- bb.putInt(bb.capacity() - vtableloc, offset() - vtableloc);
- }
-
- nested = false;
- return vtableloc;
- }
-
- /**
- * Checks that a required field has been set in a given table that has
- * just been constructed.
- *
- * @param table The offset to the start of the table from the `ByteBuffer` capacity.
- * @param field The offset to the field in the vtable.
- */
- public void required(int table, int field) {
- int table_start = bb.capacity() - table;
- int vtable_start = table_start - bb.getInt(table_start);
- boolean ok = bb.getShort(vtable_start + field) != 0;
- // If this fails, the caller will show what field needs to be set.
- if (!ok)
- throw new AssertionError("FlatBuffers: field " + field + " must be set");
- }
- /// @endcond
-
- /**
- * Finalize a buffer, pointing to the given `root_table`.
- *
- * @param root_table An offset to be added to the buffer.
- * @param size_prefix Whether to prefix the size to the buffer.
- */
- protected void finish(int root_table, boolean size_prefix) {
- prep(minalign, SIZEOF_INT + (size_prefix ? SIZEOF_INT : 0));
- addOffset(root_table);
- if (size_prefix) {
- addInt(bb.capacity() - space);
- }
- bb.position(space);
- finished = true;
- }
-
- /**
- * Finalize a buffer, pointing to the given `root_table`.
- *
- * @param root_table An offset to be added to the buffer.
- */
- public void finish(int root_table) {
- finish(root_table, false);
- }
-
- /**
- * Finalize a buffer, pointing to the given `root_table`, with the size prefixed.
- *
- * @param root_table An offset to be added to the buffer.
- */
- public void finishSizePrefixed(int root_table) {
- finish(root_table, true);
- }
-
- /**
- * Finalize a buffer, pointing to the given `root_table`.
- *
- * @param root_table An offset to be added to the buffer.
- * @param file_identifier A FlatBuffer file identifier to be added to the buffer before
- * `root_table`.
- * @param size_prefix Whether to prefix the size to the buffer.
- */
- protected void finish(int root_table, String file_identifier, boolean size_prefix) {
- prep(minalign, SIZEOF_INT + FILE_IDENTIFIER_LENGTH + (size_prefix ? SIZEOF_INT : 0));
- if (file_identifier.length() != FILE_IDENTIFIER_LENGTH)
- throw new AssertionError("FlatBuffers: file identifier must be length " +
- FILE_IDENTIFIER_LENGTH);
- for (int i = FILE_IDENTIFIER_LENGTH - 1; i >= 0; i--) {
- addByte((byte)file_identifier.charAt(i));
- }
- finish(root_table, size_prefix);
- }
-
- /**
- * Finalize a buffer, pointing to the given `root_table`.
- *
- * @param root_table An offset to be added to the buffer.
- * @param file_identifier A FlatBuffer file identifier to be added to the buffer before
- * `root_table`.
- */
- public void finish(int root_table, String file_identifier) {
- finish(root_table, file_identifier, false);
- }
-
- /**
- * Finalize a buffer, pointing to the given `root_table`, with the size prefixed.
- *
- * @param root_table An offset to be added to the buffer.
- * @param file_identifier A FlatBuffer file identifier to be added to the buffer before
- * `root_table`.
- */
- public void finishSizePrefixed(int root_table, String file_identifier) {
- finish(root_table, file_identifier, true);
- }
-
- /**
- * In order to save space, fields that are set to their default value
- * don't get serialized into the buffer. Forcing defaults provides a
- * way to manually disable this optimization.
- *
- * @param forceDefaults When set to `true`, always serializes default values.
- * @return Returns `this`.
- */
- public FlatBufferBuilder forceDefaults(boolean forceDefaults){
- this.force_defaults = forceDefaults;
- return this;
- }
-
- /**
- * Get the ByteBuffer representing the FlatBuffer. Only call this after you've
- * called `finish()`. The actual data starts at the ByteBuffer's current position,
- * not necessarily at `0`.
- *
- * @return The {@link ByteBuffer} representing the FlatBuffer
- */
- public ByteBuffer dataBuffer() {
- finished();
- return bb;
- }
-
- /**
- * The FlatBuffer data doesn't start at offset 0 in the {@link ByteBuffer}, but
- * now the {@code ByteBuffer}'s position is set to that location upon {@link #finish(int)}.
- *
- * @return The {@link ByteBuffer#position() position} the data starts in {@link #dataBuffer()}
- * @deprecated This method should not be needed anymore, but is left
- * here for the moment to document this API change. It will be removed in the future.
- */
- @Deprecated
- private int dataStart() {
- finished();
- return space;
- }
-
- /**
- * A utility function to copy and return the ByteBuffer data from `start` to
- * `start` + `length` as a `byte[]`.
- *
- * @param start Start copying at this offset.
- * @param length How many bytes to copy.
- * @return A range copy of the {@link #dataBuffer() data buffer}.
- * @throws IndexOutOfBoundsException If the range of bytes is ouf of bound.
- */
- public byte[] sizedByteArray(int start, int length){
- finished();
- byte[] array = new byte[length];
- bb.position(start);
- bb.get(array);
- return array;
- }
-
- /**
- * A utility function to copy and return the ByteBuffer data as a `byte[]`.
- *
- * @return A full copy of the {@link #dataBuffer() data buffer}.
- */
- public byte[] sizedByteArray() {
- return sizedByteArray(space, bb.capacity() - space);
- }
-
- /**
- * A utility function to return an InputStream to the ByteBuffer data
- *
- * @return An InputStream that starts at the beginning of the ByteBuffer data
- * and can read to the end of it.
- */
- public InputStream sizedInputStream() {
- finished();
- ByteBuffer duplicate = bb.duplicate();
- duplicate.position(space);
- duplicate.limit(bb.capacity());
- return new ByteBufferBackedInputStream(duplicate);
- }
-
- /**
- * A class that allows a user to create an InputStream from a ByteBuffer.
- */
- static class ByteBufferBackedInputStream extends InputStream {
-
- ByteBuffer buf;
-
- public ByteBufferBackedInputStream(ByteBuffer buf) {
- this.buf = buf;
- }
-
- public int read() throws IOException {
- try {
- return buf.get() & 0xFF;
- } catch(BufferUnderflowException e) {
- return -1;
- }
- }
- }
-
-}
-
-/// @}
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/FlexBuffers.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/FlexBuffers.java
deleted file mode 100644
index 75a0595f6..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/FlexBuffers.java
+++ /dev/null
@@ -1,1221 +0,0 @@
-/*
- * Copyright 2014 Google Inc. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.flatbuffers;
-
-
-import static com.google.flatbuffers.FlexBuffers.Unsigned.byteToUnsignedInt;
-import static com.google.flatbuffers.FlexBuffers.Unsigned.intToUnsignedLong;
-import static com.google.flatbuffers.FlexBuffers.Unsigned.shortToUnsignedInt;
-
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
-
-/// @file
-/// @addtogroup flatbuffers_java_api
-/// @{
-
-/**
- * This class can be used to parse FlexBuffer messages.
- *
- * For generating FlexBuffer messages, use {@link FlexBuffersBuilder}.
- *
- * Example of usage:
- * For vector element, it will return size of the vector For String element, it will type to be parsed as integer Unsigned elements will become negative Float elements will be casted to integer For vector element, it will return size of the vector For String element, it will type to be parsed as integer Negative signed elements will become unsigned counterpart Float elements will be casted to integer For vector element, it will return size of the vector For String element, it will type to be parsed as integer Unsigned elements will become negative Float elements will be casted to integer For vector element, it will return size of the vector For String element, it will type to be parsed as integer If element type is not boolean, it will be casted to integer and compared against 0 It can be converted to `ReadBuf` using {@link data()},
- * copied into a byte[] using {@link getBytes()} or
- * have individual bytes accessed individually using {@link get(int)} This class presents all necessary APIs to create FlexBuffers. A `ByteBuffer` will be used to store the
- * data. It can be created internally, or passed down in the constructor. There are some limitations when compared to original implementation in C++. Most notably:
- * No support for mutations (might change in the future). Buffer size limited to {@link Integer#MAX_VALUE} Since Java does not support unsigned type, all unsigned operations accepts an immediate higher representation
- * of similar type.
- *
- * {@code
- * // Need 10 strings
- * FlatBufferBuilder builder = new FlatBufferBuilder(existingBuffer);
- * int[] offsets = new int[10];
- *
- * for (int i = 0; i < 10; i++) {
- * offsets[i] = fbb.createString(" " + i);
- * }
- *
- * // Have the strings in the buffer, but don't have a vector.
- * // Add a vector that references the newly created strings:
- * builder.startVector(4, offsets.length, 4);
- *
- * // Add each string to the newly created vector
- * // The strings are added in reverse order since the buffer
- * // is filled in back to front
- * for (int i = offsets.length - 1; i >= 0; i--) {
- * builder.addOffset(offsets[i]);
- * }
- *
- * // Finish off the vector
- * int offsetOfTheVector = fbb.endVector();
- * }
- *
- * @param elem_size The size of each element in the array.
- * @param num_elems The number of elements in the array.
- * @param alignment The alignment of the array.
- */
- public void startVector(int elem_size, int num_elems, int alignment) {
- notNested();
- vector_num_elems = num_elems;
- prep(SIZEOF_INT, elem_size * num_elems);
- prep(alignment, elem_size * num_elems); // Just in case alignment > int.
- nested = true;
- }
-
- /**
- * Finish off the creation of an array and all its elements. The array
- * must be created with {@link #startVector(int, int, int)}.
- *
- * @return The offset at which the newly created array starts.
- * @see #startVector(int, int, int)
- */
- public int endVector() {
- if (!nested)
- throw new AssertionError("FlatBuffers: endVector called without startVector");
- nested = false;
- putInt(vector_num_elems);
- return offset();
- }
- /// @endcond
-
- /**
- * Create a new array/vector and return a ByteBuffer to be filled later.
- * Call {@link #endVector} after this method to get an offset to the beginning
- * of vector.
- *
- * @param elem_size the size of each element in bytes.
- * @param num_elems number of elements in the vector.
- * @param alignment byte alignment.
- * @return ByteBuffer with position and limit set to the space allocated for the array.
- */
- public ByteBuffer createUnintializedVector(int elem_size, int num_elems, int alignment) {
- int length = elem_size * num_elems;
- startVector(elem_size, num_elems, alignment);
-
- bb.position(space -= length);
-
- // Slice and limit the copy vector to point to the 'array'
- ByteBuffer copy = bb.slice().order(ByteOrder.LITTLE_ENDIAN);
- copy.limit(length);
- return copy;
- }
-
- /**
- * Create a vector of tables.
- *
- * @param offsets Offsets of the tables.
- * @return Returns offset of the vector.
- */
- public int createVectorOfTables(int[] offsets) {
- notNested();
- startVector(Constants.SIZEOF_INT, offsets.length, Constants.SIZEOF_INT);
- for(int i = offsets.length - 1; i >= 0; i--) addOffset(offsets[i]);
- return endVector();
- }
-
- /**
- * Create a vector of sorted by the key tables.
- *
- * @param obj Instance of the table subclass.
- * @param offsets Offsets of the tables.
- * @return Returns offset of the sorted vector.
- */
- public {@code
- * int testArrayOfString = Monster.createTestarrayofstringVector(fbb, new int[] {
- * fbb.createString("test1"),
- * fbb.createString("test2")
- * });
- *
- * Monster.startMonster(fbb);
- * Monster.addPos(fbb, Vec3.createVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0,
- * Color.Green, (short)5, (byte)6));
- * Monster.addHp(fbb, (short)80);
- * Monster.addName(fbb, str);
- * Monster.addInventory(fbb, inv);
- * Monster.addTestType(fbb, (byte)Any.Monster);
- * Monster.addTest(fbb, mon2);
- * Monster.addTest4(fbb, test4);
- * Monster.addTestarrayofstring(fbb, testArrayOfString);
- * int mon = Monster.endMonster(fbb);
- * }
- *
- *
- *
- * ReadBuf bb = ... // load message from file or network
- * FlexBuffers.Reference r = FlexBuffers.getRoot(bb); // Reads the root element
- * FlexBuffers.Map map = r.asMap(); // We assumed root object is a map
- * System.out.println(map.get("name").asString()); // prints element with key "name"
- *
- */
-public class FlexBuffers {
-
- // These are used as the upper 6 bits of a type field to indicate the actual
- // type.
- /** Represent a null type */
- public static final int FBT_NULL = 0;
- /** Represent a signed integer type */
- public static final int FBT_INT = 1;
- /** Represent a unsigned type */
- public static final int FBT_UINT = 2;
- /** Represent a float type */
- public static final int FBT_FLOAT = 3; // Types above stored inline, types below store an offset.
- /** Represent a key to a map type */
- public static final int FBT_KEY = 4;
- /** Represent a string type */
- public static final int FBT_STRING = 5;
- /** Represent a indirect signed integer type */
- public static final int FBT_INDIRECT_INT = 6;
- /** Represent a indirect unsigned integer type */
- public static final int FBT_INDIRECT_UINT = 7;
- /** Represent a indirect float type */
- public static final int FBT_INDIRECT_FLOAT = 8;
- /** Represent a map type */
- public static final int FBT_MAP = 9;
- /** Represent a vector type */
- public static final int FBT_VECTOR = 10; // Untyped.
- /** Represent a vector of signed integers type */
- public static final int FBT_VECTOR_INT = 11; // Typed any size = stores no type table).
- /** Represent a vector of unsigned integers type */
- public static final int FBT_VECTOR_UINT = 12;
- /** Represent a vector of floats type */
- public static final int FBT_VECTOR_FLOAT = 13;
- /** Represent a vector of keys type */
- public static final int FBT_VECTOR_KEY = 14;
- /** Represent a vector of strings type */
- // DEPRECATED, use FBT_VECTOR or FBT_VECTOR_KEY instead.
- // more info on thttps://github.com/google/flatbuffers/issues/5627.
- public static final int FBT_VECTOR_STRING_DEPRECATED = 15;
-
- /// @cond FLATBUFFERS_INTERNAL
- public static final int FBT_VECTOR_INT2 = 16; // Typed tuple = no type table; no size field).
- public static final int FBT_VECTOR_UINT2 = 17;
- public static final int FBT_VECTOR_FLOAT2 = 18;
- public static final int FBT_VECTOR_INT3 = 19; // Typed triple = no type table; no size field).
- public static final int FBT_VECTOR_UINT3 = 20;
- public static final int FBT_VECTOR_FLOAT3 = 21;
- public static final int FBT_VECTOR_INT4 = 22; // Typed quad = no type table; no size field).
- public static final int FBT_VECTOR_UINT4 = 23;
- public static final int FBT_VECTOR_FLOAT4 = 24;
- /// @endcond FLATBUFFERS_INTERNAL
-
- /** Represent a blob type */
- public static final int FBT_BLOB = 25;
- /** Represent a boolean type */
- public static final int FBT_BOOL = 26;
- /** Represent a vector of booleans type */
- public static final int FBT_VECTOR_BOOL = 36; // To Allow the same type of conversion of type to vector type
-
- private static final ReadBuf EMPTY_BB = new ArrayReadWriteBuf(new byte[] {0}, 1);
-
- /**
- * Checks where a type is a typed vector
- *
- * @param type type to be checked
- * @return true if typed vector
- */
- static boolean isTypedVector(int type) {
- return (type >= FBT_VECTOR_INT && type <= FBT_VECTOR_STRING_DEPRECATED) || type == FBT_VECTOR_BOOL;
- }
-
- /**
- * Check whether you can access type directly (no indirection) or not.
- *
- * @param type type to be checked
- * @return true if inline type
- */
- static boolean isTypeInline(int type) {
- return type <= FBT_FLOAT || type == FBT_BOOL;
- }
-
- static int toTypedVectorElementType(int original_type) {
- return original_type - FBT_VECTOR_INT + FBT_INT;
- }
-
- /**
- * Return a vector type our of a original element type
- *
- * @param type element type
- * @param fixedLength size of element
- * @return typed vector type
- */
- static int toTypedVector(int type, int fixedLength) {
- assert (isTypedVectorElementType(type));
- switch (fixedLength) {
- case 0: return type - FBT_INT + FBT_VECTOR_INT;
- case 2: return type - FBT_INT + FBT_VECTOR_INT2;
- case 3: return type - FBT_INT + FBT_VECTOR_INT3;
- case 4: return type - FBT_INT + FBT_VECTOR_INT4;
- default:
- assert (false);
- return FBT_NULL;
- }
- }
-
- static boolean isTypedVectorElementType(int type) {
- return (type >= FBT_INT && type <= FBT_KEY) || type == FBT_BOOL;
- }
-
- // return position of the element that the offset is pointing to
- private static int indirect(ReadBuf bb, int offset, int byteWidth) {
- // we assume all offset fits on a int, since ReadBuf operates with that assumption
- return (int) (offset - readUInt(bb, offset, byteWidth));
- }
-
- // read unsigned int with size byteWidth and return as a 64-bit integer
- private static long readUInt(ReadBuf buff, int end, int byteWidth) {
- switch (byteWidth) {
- case 1: return byteToUnsignedInt(buff.get(end));
- case 2: return shortToUnsignedInt(buff.getShort(end));
- case 4: return intToUnsignedLong(buff.getInt(end));
- case 8: return buff.getLong(end); // We are passing signed long here. Losing information (user should know)
- default: return -1; // we should never reach here
- }
- }
-
- // read signed int of size byteWidth and return as 32-bit int
- private static int readInt(ReadBuf buff, int end, int byteWidth) {
- return (int) readLong(buff, end, byteWidth);
- }
-
- // read signed int of size byteWidth and return as 64-bit int
- private static long readLong(ReadBuf buff, int end, int byteWidth) {
- switch (byteWidth) {
- case 1: return buff.get(end);
- case 2: return buff.getShort(end);
- case 4: return buff.getInt(end);
- case 8: return buff.getLong(end);
- default: return -1; // we should never reach here
- }
- }
-
- private static double readDouble(ReadBuf buff, int end, int byteWidth) {
- switch (byteWidth) {
- case 4: return buff.getFloat(end);
- case 8: return buff.getDouble(end);
- default: return -1; // we should never reach here
- }
- }
-
- /**
- * Reads a FlexBuffer message in ReadBuf and returns {@link Reference} to
- * the root element.
- * @param buffer ReadBuf containing FlexBuffer message
- * @return {@link Reference} to the root object
- */
- @Deprecated
- public static Reference getRoot(ByteBuffer buffer) {
- return getRoot( buffer.hasArray() ? new ArrayReadWriteBuf(buffer.array(), buffer.limit()) : new ByteBufferReadWriteBuf(buffer));
- }
-
- /**
- * Reads a FlexBuffer message in ReadBuf and returns {@link Reference} to
- * the root element.
- * @param buffer ReadBuf containing FlexBuffer message
- * @return {@link Reference} to the root object
- */
- public static Reference getRoot(ReadBuf buffer) {
- // See Finish() below for the serialization counterpart of this.
- // The root ends at the end of the buffer, so we parse backwards from there.
- int end = buffer.limit();
- int byteWidth = buffer.get(--end);
- int packetType = byteToUnsignedInt(buffer.get(--end));
- end -= byteWidth; // The root data item.
- return new Reference(buffer, end, byteWidth, packetType);
- }
-
- /**
- * Represents an generic element in the buffer.
- */
- public static class Reference {
-
- private static final Reference NULL_REFERENCE = new Reference(EMPTY_BB, 0, 1, 0);
- private ReadBuf bb;
- private int end;
- private int parentWidth;
- private int byteWidth;
- private int type;
-
- Reference(ReadBuf bb, int end, int parentWidth, int packedType) {
- this(bb, end, parentWidth, (1 << (packedType & 3)), packedType >> 2);
- }
-
- Reference(ReadBuf bb, int end, int parentWidth, int byteWidth, int type) {
- this.bb = bb;
- this.end = end;
- this.parentWidth = parentWidth;
- this.byteWidth = byteWidth;
- this.type = type;
- }
-
- /**
- * Return element type
- * @return element type as integer
- */
- public int getType() {
- return type;
- }
-
- /**
- * Checks whether the element is null type
- * @return true if null type
- */
- public boolean isNull() {
- return type == FBT_NULL;
- }
-
- /**
- * Checks whether the element is boolean type
- * @return true if boolean type
- */
- public boolean isBoolean() {
- return type == FBT_BOOL;
- }
-
- /**
- * Checks whether the element type is numeric (signed/unsigned integers and floats)
- * @return true if numeric type
- */
- public boolean isNumeric() {
- return isIntOrUInt() || isFloat();
- }
-
- /**
- * Checks whether the element type is signed or unsigned integers
- * @return true if an integer type
- */
- public boolean isIntOrUInt() {
- return isInt() || isUInt();
- }
-
- /**
- * Checks whether the element type is float
- * @return true if a float type
- */
- public boolean isFloat() {
- return type == FBT_FLOAT || type == FBT_INDIRECT_FLOAT;
- }
-
- /**
- * Checks whether the element type is signed integer
- * @return true if a signed integer type
- */
- public boolean isInt() {
- return type == FBT_INT || type == FBT_INDIRECT_INT;
- }
-
- /**
- * Checks whether the element type is signed integer
- * @return true if a signed integer type
- */
- public boolean isUInt() {
- return type == FBT_UINT || type == FBT_INDIRECT_UINT;
- }
-
- /**
- * Checks whether the element type is string
- * @return true if a string type
- */
- public boolean isString() {
- return type == FBT_STRING;
- }
-
- /**
- * Checks whether the element type is key
- * @return true if a key type
- */
- public boolean isKey() {
- return type == FBT_KEY;
- }
-
- /**
- * Checks whether the element type is vector
- * @return true if a vector type
- */
- public boolean isVector() {
- return type == FBT_VECTOR || type == FBT_MAP;
- }
-
- /**
- * Checks whether the element type is typed vector
- * @return true if a typed vector type
- */
- public boolean isTypedVector() {
- return FlexBuffers.isTypedVector(type);
- }
-
- /**
- * Checks whether the element type is a map
- * @return true if a map type
- */
- public boolean isMap() {
- return type == FBT_MAP;
- }
-
- /**
- * Checks whether the element type is a blob
- * @return true if a blob type
- */
- public boolean isBlob() {
- return type == FBT_BLOB;
- }
-
- /**
- * Returns element as 32-bit integer.
- *
- *
- *
Selects an optimal algorithm based on the type of {@link ByteBuffer} (i.e. heap or direct)
- * and the capabilities of the platform.
- *
- * @param in the source string to be encoded
- * @param out the target buffer to receive the encoded string.
- */
- public abstract void encodeUtf8(CharSequence in, ByteBuffer out);
-
- /**
- * Decodes the given UTF-8 portion of the {@link ByteBuffer} into a {@link String}.
- *
- * @throws IllegalArgumentException if the input is not valid UTF-8.
- */
- public abstract String decodeUtf8(ByteBuffer buffer, int offset, int length);
-
- private static Utf8 DEFAULT;
-
- /**
- * Get the default UTF-8 processor.
- * @return the default processor
- */
- public static Utf8 getDefault() {
- if (DEFAULT == null) {
- DEFAULT = new Utf8Safe();
- }
- return DEFAULT;
- }
-
- /**
- * Set the default instance of the UTF-8 processor.
- * @param instance the new instance to use
- */
- public static void setDefault(Utf8 instance) {
- DEFAULT = instance;
- }
-
- /**
- * Encode a Java's CharSequence UTF8 codepoint into a byte array.
- * @param in CharSequence to be encoded
- * @param start start position of the first char in the codepoint
- * @param out byte array of 4 bytes to be filled
- * @return return the amount of bytes occupied by the codepoint
- */
- public static int encodeUtf8CodePoint(CharSequence in, int start, byte[] out) {
- // utf8 codepoint needs at least 4 bytes
- assert out.length >= 4;
-
- final int inLength = in.length();
- if (start >= inLength) {
- return 0;
- }
-
- char c = in.charAt(start);
- if (c < 0x80) {
- // One byte (0xxx xxxx)
- out[0] = (byte) c;
- return 1;
- } else if (c < 0x800) {
- // Two bytes (110x xxxx 10xx xxxx)
- out[0] = (byte) (0xC0 | (c >>> 6));
- out[1] = (byte) (0x80 | (0x3F & c));
- return 2;
- } else if (c < MIN_SURROGATE || MAX_SURROGATE < c) {
- // Three bytes (1110 xxxx 10xx xxxx 10xx xxxx)
- // Maximum single-char code point is 0xFFFF, 16 bits.
- out[0] = (byte) (0xE0 | (c >>> 12));
- out[1] =(byte) (0x80 | (0x3F & (c >>> 6)));
- out[2] = (byte) (0x80 | (0x3F & c));
- return 3;
- } else {
- // Four bytes (1111 xxxx 10xx xxxx 10xx xxxx 10xx xxxx)
- // Minimum code point represented by a surrogate pair is 0x10000, 17 bits, four UTF-8
- // bytes
- final char low;
- if (start + 1 == inLength || !isSurrogatePair(c, (low = in.charAt(start+1)))) {
- throw new UnpairedSurrogateException(start, inLength);
- }
- int codePoint = toCodePoint(c, low);
- out[0] = (byte) ((0xF << 4) | (codePoint >>> 18));
- out[1] = (byte) (0x80 | (0x3F & (codePoint >>> 12)));
- out[2] = (byte) (0x80 | (0x3F & (codePoint >>> 6)));
- out[3] = (byte) (0x80 | (0x3F & codePoint));
- return 4;
- }
- }
-
- /**
- * Utility methods for decoding bytes into {@link String}. Callers are responsible for extracting
- * bytes (possibly using Unsafe methods), and checking remaining bytes. All other UTF-8 validity
- * checks and codepoint conversion happen in this class.
- */
- static class DecodeUtil {
-
- /**
- * Returns whether this is a single-byte codepoint (i.e., ASCII) with the form '0XXXXXXX'.
- */
- static boolean isOneByte(byte b) {
- return b >= 0;
- }
-
- /**
- * Returns whether this is a two-byte codepoint with the form '10XXXXXX'.
- */
- static boolean isTwoBytes(byte b) {
- return b < (byte) 0xE0;
- }
-
- /**
- * Returns whether this is a three-byte codepoint with the form '110XXXXX'.
- */
- static boolean isThreeBytes(byte b) {
- return b < (byte) 0xF0;
- }
-
- static void handleOneByte(byte byte1, char[] resultArr, int resultPos) {
- resultArr[resultPos] = (char) byte1;
- }
-
- static void handleTwoBytes(
- byte byte1, byte byte2, char[] resultArr, int resultPos)
- throws IllegalArgumentException {
- // Simultaneously checks for illegal trailing-byte in leading position (<= '11000000') and
- // overlong 2-byte, '11000001'.
- if (byte1 < (byte) 0xC2) {
- throw new IllegalArgumentException("Invalid UTF-8: Illegal leading byte in 2 bytes utf");
- }
- if (isNotTrailingByte(byte2)) {
- throw new IllegalArgumentException("Invalid UTF-8: Illegal trailing byte in 2 bytes utf");
- }
- resultArr[resultPos] = (char) (((byte1 & 0x1F) << 6) | trailingByteValue(byte2));
- }
-
- static void handleThreeBytes(
- byte byte1, byte byte2, byte byte3, char[] resultArr, int resultPos)
- throws IllegalArgumentException {
- if (isNotTrailingByte(byte2)
- // overlong? 5 most significant bits must not all be zero
- || (byte1 == (byte) 0xE0 && byte2 < (byte) 0xA0)
- // check for illegal surrogate codepoints
- || (byte1 == (byte) 0xED && byte2 >= (byte) 0xA0)
- || isNotTrailingByte(byte3)) {
- throw new IllegalArgumentException("Invalid UTF-8");
- }
- resultArr[resultPos] = (char)
- (((byte1 & 0x0F) << 12) | (trailingByteValue(byte2) << 6) | trailingByteValue(byte3));
- }
-
- static void handleFourBytes(
- byte byte1, byte byte2, byte byte3, byte byte4, char[] resultArr, int resultPos)
- throws IllegalArgumentException{
- if (isNotTrailingByte(byte2)
- // Check that 1 <= plane <= 16. Tricky optimized form of:
- // valid 4-byte leading byte?
- // if (byte1 > (byte) 0xF4 ||
- // overlong? 4 most significant bits must not all be zero
- // byte1 == (byte) 0xF0 && byte2 < (byte) 0x90 ||
- // codepoint larger than the highest code point (U+10FFFF)?
- // byte1 == (byte) 0xF4 && byte2 > (byte) 0x8F)
- || (((byte1 << 28) + (byte2 - (byte) 0x90)) >> 30) != 0
- || isNotTrailingByte(byte3)
- || isNotTrailingByte(byte4)) {
- throw new IllegalArgumentException("Invalid UTF-8");
- }
- int codepoint = ((byte1 & 0x07) << 18)
- | (trailingByteValue(byte2) << 12)
- | (trailingByteValue(byte3) << 6)
- | trailingByteValue(byte4);
- resultArr[resultPos] = DecodeUtil.highSurrogate(codepoint);
- resultArr[resultPos + 1] = DecodeUtil.lowSurrogate(codepoint);
- }
-
- /**
- * Returns whether the byte is not a valid continuation of the form '10XXXXXX'.
- */
- private static boolean isNotTrailingByte(byte b) {
- return b > (byte) 0xBF;
- }
-
- /**
- * Returns the actual value of the trailing byte (removes the prefix '10') for composition.
- */
- private static int trailingByteValue(byte b) {
- return b & 0x3F;
- }
-
- private static char highSurrogate(int codePoint) {
- return (char) ((MIN_HIGH_SURROGATE - (MIN_SUPPLEMENTARY_CODE_POINT >>> 10))
- + (codePoint >>> 10));
- }
-
- private static char lowSurrogate(int codePoint) {
- return (char) (MIN_LOW_SURROGATE + (codePoint & 0x3ff));
- }
- }
-
- // These UTF-8 handling methods are copied from Guava's Utf8Unsafe class with a modification to throw
- // a protocol buffer local exception. This exception is then caught in CodedOutputStream so it can
- // fallback to more lenient behavior.
- static class UnpairedSurrogateException extends IllegalArgumentException {
- UnpairedSurrogateException(int index, int length) {
- super("Unpaired surrogate at index " + index + " of " + length);
- }
- }
-}
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/Utf8Old.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/Utf8Old.java
deleted file mode 100644
index c568105a0..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/Utf8Old.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2014 Google Inc. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.flatbuffers;
-
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CoderResult;
-import java.nio.charset.StandardCharsets;
-
-/**
- * This class implements the Utf8 API using the Java Utf8 encoder. Use
- * Utf8.setDefault(new Utf8Old()); to use it.
- */
-public class Utf8Old extends Utf8 {
-
- private static class Cache {
- final CharsetEncoder encoder;
- final CharsetDecoder decoder;
- CharSequence lastInput = null;
- ByteBuffer lastOutput = null;
-
- Cache() {
- encoder = StandardCharsets.UTF_8.newEncoder();
- decoder = StandardCharsets.UTF_8.newDecoder();
- }
- }
-
- // ThreadLocal.withInitial() is not used to make the following code compatible with Android API
- // level 23.
- private static final ThreadLocal There are several variants of UTF-8. The one implemented by
- * this class is the restricted definition of UTF-8 introduced in
- * Unicode 3.1, which mandates the rejection of "overlong" byte
- * sequences as well as rejection of 3-byte surrogate codepoint byte
- * sequences. Note that the UTF-8 decoder included in Oracle's JDK
- * has been modified to also reject "overlong" byte sequences, but (as
- * of 2011) still accepts 3-byte surrogate codepoint byte sequences.
- *
- * The byte sequences considered valid by this class are exactly
- * those that can be roundtrip converted to Strings and back to bytes
- * using the UTF-8 charset, without loss: See the Unicode Standard,
- * Table 3-6. UTF-8 Bit Distribution,
- * Table 3-7. Well Formed UTF-8 Byte Sequences.
- */
-final public class Utf8Safe extends Utf8 {
-
- /**
- * Returns the number of bytes in the UTF-8-encoded form of {@code sequence}. For a string,
- * this method is equivalent to {@code string.getBytes(UTF_8).length}, but is more efficient in
- * both time and space.
- *
- * @throws IllegalArgumentException if {@code sequence} contains ill-formed UTF-16 (unpaired
- * surrogates)
- */
- private static int computeEncodedLength(CharSequence sequence) {
- // Warning to maintainers: this implementation is highly optimized.
- int utf16Length = sequence.length();
- int utf8Length = utf16Length;
- int i = 0;
-
- // This loop optimizes for pure ASCII.
- while (i < utf16Length && sequence.charAt(i) < 0x80) {
- i++;
- }
-
- // This loop optimizes for chars less than 0x800.
- for (; i < utf16Length; i++) {
- char c = sequence.charAt(i);
- if (c < 0x800) {
- utf8Length += ((0x7f - c) >>> 31); // branch free!
- } else {
- utf8Length += encodedLengthGeneral(sequence, i);
- break;
- }
- }
-
- if (utf8Length < utf16Length) {
- // Necessary and sufficient condition for overflow because of maximum 3x expansion
- throw new IllegalArgumentException("UTF-8 length does not fit in int: "
- + (utf8Length + (1L << 32)));
- }
- return utf8Length;
- }
-
- private static int encodedLengthGeneral(CharSequence sequence, int start) {
- int utf16Length = sequence.length();
- int utf8Length = 0;
- for (int i = start; i < utf16Length; i++) {
- char c = sequence.charAt(i);
- if (c < 0x800) {
- utf8Length += (0x7f - c) >>> 31; // branch free!
- } else {
- utf8Length += 2;
- // jdk7+: if (Character.isSurrogate(c)) {
- if (Character.MIN_SURROGATE <= c && c <= Character.MAX_SURROGATE) {
- // Check that we have a well-formed surrogate pair.
- int cp = Character.codePointAt(sequence, i);
- if (cp < MIN_SUPPLEMENTARY_CODE_POINT) {
- throw new Utf8Safe.UnpairedSurrogateException(i, utf16Length);
- }
- i++;
- }
- }
- }
- return utf8Length;
- }
-
- public static String decodeUtf8Array(byte[] bytes, int index, int size) {
- // Bitwise OR combines the sign bits so any negative value fails the check.
- if ((index | size | bytes.length - index - size) < 0) {
- throw new ArrayIndexOutOfBoundsException(
- String.format("buffer length=%d, index=%d, size=%d", bytes.length, index, size));
- }
-
- int offset = index;
- final int limit = offset + size;
-
- // The longest possible resulting String is the same as the number of input bytes, when it is
- // all ASCII. For other cases, this over-allocates and we will truncate in the end.
- char[] resultArr = new char[size];
- int resultPos = 0;
-
- // Optimize for 100% ASCII (Hotspot loves small simple top-level loops like this).
- // This simple loop stops when we encounter a byte >= 0x80 (i.e. non-ASCII).
- while (offset < limit) {
- byte b = bytes[offset];
- if (!DecodeUtil.isOneByte(b)) {
- break;
- }
- offset++;
- DecodeUtil.handleOneByte(b, resultArr, resultPos++);
- }
-
- while (offset < limit) {
- byte byte1 = bytes[offset++];
- if (DecodeUtil.isOneByte(byte1)) {
- DecodeUtil.handleOneByte(byte1, resultArr, resultPos++);
- // It's common for there to be multiple ASCII characters in a run mixed in, so add an
- // extra optimized loop to take care of these runs.
- while (offset < limit) {
- byte b = bytes[offset];
- if (!DecodeUtil.isOneByte(b)) {
- break;
- }
- offset++;
- DecodeUtil.handleOneByte(b, resultArr, resultPos++);
- }
- } else if (DecodeUtil.isTwoBytes(byte1)) {
- if (offset >= limit) {
- throw new IllegalArgumentException("Invalid UTF-8");
- }
- DecodeUtil.handleTwoBytes(byte1, /* byte2 */ bytes[offset++], resultArr, resultPos++);
- } else if (DecodeUtil.isThreeBytes(byte1)) {
- if (offset >= limit - 1) {
- throw new IllegalArgumentException("Invalid UTF-8");
- }
- DecodeUtil.handleThreeBytes(
- byte1,
- /* byte2 */ bytes[offset++],
- /* byte3 */ bytes[offset++],
- resultArr,
- resultPos++);
- } else {
- if (offset >= limit - 2) {
- throw new IllegalArgumentException("Invalid UTF-8");
- }
- DecodeUtil.handleFourBytes(
- byte1,
- /* byte2 */ bytes[offset++],
- /* byte3 */ bytes[offset++],
- /* byte4 */ bytes[offset++],
- resultArr,
- resultPos++);
- // 4-byte case requires two chars.
- resultPos++;
- }
- }
-
- return new String(resultArr, 0, resultPos);
- }
-
- public static String decodeUtf8Buffer(ByteBuffer buffer, int offset,
- int length) {
- // Bitwise OR combines the sign bits so any negative value fails the check.
- if ((offset | length | buffer.limit() - offset - length) < 0) {
- throw new ArrayIndexOutOfBoundsException(
- String.format("buffer limit=%d, index=%d, limit=%d", buffer.limit(),
- offset, length));
- }
-
- final int limit = offset + length;
-
- // The longest possible resulting String is the same as the number of input bytes, when it is
- // all ASCII. For other cases, this over-allocates and we will truncate in the end.
- char[] resultArr = new char[length];
- int resultPos = 0;
-
- // Optimize for 100% ASCII (Hotspot loves small simple top-level loops like this).
- // This simple loop stops when we encounter a byte >= 0x80 (i.e. non-ASCII).
- while (offset < limit) {
- byte b = buffer.get(offset);
- if (!DecodeUtil.isOneByte(b)) {
- break;
- }
- offset++;
- DecodeUtil.handleOneByte(b, resultArr, resultPos++);
- }
-
- while (offset < limit) {
- byte byte1 = buffer.get(offset++);
- if (DecodeUtil.isOneByte(byte1)) {
- DecodeUtil.handleOneByte(byte1, resultArr, resultPos++);
- // It's common for there to be multiple ASCII characters in a run mixed in, so add an
- // extra optimized loop to take care of these runs.
- while (offset < limit) {
- byte b = buffer.get(offset);
- if (!DecodeUtil.isOneByte(b)) {
- break;
- }
- offset++;
- DecodeUtil.handleOneByte(b, resultArr, resultPos++);
- }
- } else if (DecodeUtil.isTwoBytes(byte1)) {
- if (offset >= limit) {
- throw new IllegalArgumentException("Invalid UTF-8");
- }
- DecodeUtil.handleTwoBytes(
- byte1, /* byte2 */ buffer.get(offset++), resultArr, resultPos++);
- } else if (DecodeUtil.isThreeBytes(byte1)) {
- if (offset >= limit - 1) {
- throw new IllegalArgumentException("Invalid UTF-8");
- }
- DecodeUtil.handleThreeBytes(
- byte1,
- /* byte2 */ buffer.get(offset++),
- /* byte3 */ buffer.get(offset++),
- resultArr,
- resultPos++);
- } else {
- if (offset >= limit - 2) {
- throw new IllegalArgumentException("Invalid UTF-8");
- }
- DecodeUtil.handleFourBytes(
- byte1,
- /* byte2 */ buffer.get(offset++),
- /* byte3 */ buffer.get(offset++),
- /* byte4 */ buffer.get(offset++),
- resultArr,
- resultPos++);
- // 4-byte case requires two chars.
- resultPos++;
- }
- }
-
- return new String(resultArr, 0, resultPos);
- }
-
- @Override
- public int encodedLength(CharSequence in) {
- return computeEncodedLength(in);
- }
-
- /**
- * Decodes the given UTF-8 portion of the {@link ByteBuffer} into a {@link String}.
- *
- * @throws IllegalArgumentException if the input is not valid UTF-8.
- */
- @Override
- public String decodeUtf8(ByteBuffer buffer, int offset, int length)
- throws IllegalArgumentException {
- if (buffer.hasArray()) {
- return decodeUtf8Array(buffer.array(), buffer.arrayOffset() + offset, length);
- } else {
- return decodeUtf8Buffer(buffer, offset, length);
- }
- }
-
-
- private static void encodeUtf8Buffer(CharSequence in, ByteBuffer out) {
- final int inLength = in.length();
- int outIx = out.position();
- int inIx = 0;
-
- // Since ByteBuffer.putXXX() already checks boundaries for us, no need to explicitly check
- // access. Assume the buffer is big enough and let it handle the out of bounds exception
- // if it occurs.
- try {
- // Designed to take advantage of
- // https://wikis.oracle.com/display/HotSpotInternals/RangeCheckElimination
- for (char c; inIx < inLength && (c = in.charAt(inIx)) < 0x80; ++inIx) {
- out.put(outIx + inIx, (byte) c);
- }
- if (inIx == inLength) {
- // Successfully encoded the entire string.
- out.position(outIx + inIx);
- return;
- }
-
- outIx += inIx;
- for (char c; inIx < inLength; ++inIx, ++outIx) {
- c = in.charAt(inIx);
- if (c < 0x80) {
- // One byte (0xxx xxxx)
- out.put(outIx, (byte) c);
- } else if (c < 0x800) {
- // Two bytes (110x xxxx 10xx xxxx)
-
- // Benchmarks show put performs better than putShort here (for HotSpot).
- out.put(outIx++, (byte) (0xC0 | (c >>> 6)));
- out.put(outIx, (byte) (0x80 | (0x3F & c)));
- } else if (c < MIN_SURROGATE || MAX_SURROGATE < c) {
- // Three bytes (1110 xxxx 10xx xxxx 10xx xxxx)
- // Maximum single-char code point is 0xFFFF, 16 bits.
-
- // Benchmarks show put performs better than putShort here (for HotSpot).
- out.put(outIx++, (byte) (0xE0 | (c >>> 12)));
- out.put(outIx++, (byte) (0x80 | (0x3F & (c >>> 6))));
- out.put(outIx, (byte) (0x80 | (0x3F & c)));
- } else {
- // Four bytes (1111 xxxx 10xx xxxx 10xx xxxx 10xx xxxx)
-
- // Minimum code point represented by a surrogate pair is 0x10000, 17 bits, four UTF-8
- // bytes
- final char low;
- if (inIx + 1 == inLength || !isSurrogatePair(c, (low = in.charAt(++inIx)))) {
- throw new UnpairedSurrogateException(inIx, inLength);
- }
- // TODO(nathanmittler): Consider using putInt() to improve performance.
- int codePoint = toCodePoint(c, low);
- out.put(outIx++, (byte) ((0xF << 4) | (codePoint >>> 18)));
- out.put(outIx++, (byte) (0x80 | (0x3F & (codePoint >>> 12))));
- out.put(outIx++, (byte) (0x80 | (0x3F & (codePoint >>> 6))));
- out.put(outIx, (byte) (0x80 | (0x3F & codePoint)));
- }
- }
-
- // Successfully encoded the entire string.
- out.position(outIx);
- } catch (IndexOutOfBoundsException e) {
- // TODO(nathanmittler): Consider making the API throw IndexOutOfBoundsException instead.
-
- // If we failed in the outer ASCII loop, outIx will not have been updated. In this case,
- // use inIx to determine the bad write index.
- int badWriteIndex = out.position() + Math.max(inIx, outIx - out.position() + 1);
- throw new ArrayIndexOutOfBoundsException(
- "Failed writing " + in.charAt(inIx) + " at index " + badWriteIndex);
- }
- }
-
- private static int encodeUtf8Array(CharSequence in, byte[] out,
- int offset, int length) {
- int utf16Length = in.length();
- int j = offset;
- int i = 0;
- int limit = offset + length;
- // Designed to take advantage of
- // https://wikis.oracle.com/display/HotSpotInternals/RangeCheckElimination
- for (char c; i < utf16Length && i + j < limit && (c = in.charAt(i)) < 0x80; i++) {
- out[j + i] = (byte) c;
- }
- if (i == utf16Length) {
- return j + utf16Length;
- }
- j += i;
- for (char c; i < utf16Length; i++) {
- c = in.charAt(i);
- if (c < 0x80 && j < limit) {
- out[j++] = (byte) c;
- } else if (c < 0x800 && j <= limit - 2) { // 11 bits, two UTF-8 bytes
- out[j++] = (byte) ((0xF << 6) | (c >>> 6));
- out[j++] = (byte) (0x80 | (0x3F & c));
- } else if ((c < Character.MIN_SURROGATE || Character.MAX_SURROGATE < c) && j <= limit - 3) {
- // Maximum single-char code point is 0xFFFF, 16 bits, three UTF-8 bytes
- out[j++] = (byte) ((0xF << 5) | (c >>> 12));
- out[j++] = (byte) (0x80 | (0x3F & (c >>> 6)));
- out[j++] = (byte) (0x80 | (0x3F & c));
- } else if (j <= limit - 4) {
- // Minimum code point represented by a surrogate pair is 0x10000, 17 bits,
- // four UTF-8 bytes
- final char low;
- if (i + 1 == in.length()
- || !Character.isSurrogatePair(c, (low = in.charAt(++i)))) {
- throw new UnpairedSurrogateException((i - 1), utf16Length);
- }
- int codePoint = Character.toCodePoint(c, low);
- out[j++] = (byte) ((0xF << 4) | (codePoint >>> 18));
- out[j++] = (byte) (0x80 | (0x3F & (codePoint >>> 12)));
- out[j++] = (byte) (0x80 | (0x3F & (codePoint >>> 6)));
- out[j++] = (byte) (0x80 | (0x3F & codePoint));
- } else {
- // If we are surrogates and we're not a surrogate pair, always throw an
- // UnpairedSurrogateException instead of an ArrayOutOfBoundsException.
- if ((Character.MIN_SURROGATE <= c && c <= Character.MAX_SURROGATE)
- && (i + 1 == in.length()
- || !Character.isSurrogatePair(c, in.charAt(i + 1)))) {
- throw new UnpairedSurrogateException(i, utf16Length);
- }
- throw new ArrayIndexOutOfBoundsException("Failed writing " + c + " at index " + j);
- }
- }
- return j;
- }
-
- /**
- * Encodes the given characters to the target {@link ByteBuffer} using UTF-8 encoding.
- *
- * Selects an optimal algorithm based on the type of {@link ByteBuffer} (i.e. heap or direct)
- * and the capabilities of the platform.
- *
- * @param in the source string to be encoded
- * @param out the target buffer to receive the encoded string.
- */
- @Override
- public void encodeUtf8(CharSequence in, ByteBuffer out) {
- if (out.hasArray()) {
- int start = out.arrayOffset();
- int end = encodeUtf8Array(in, out.array(), start + out.position(),
- out.remaining());
- out.position(end - start);
- } else {
- encodeUtf8Buffer(in, out);
- }
- }
-
- // These UTF-8 handling methods are copied from Guava's Utf8Unsafe class with
- // a modification to throw a local exception. This exception can be caught
- // to fallback to more lenient behavior.
- static class UnpairedSurrogateException extends IllegalArgumentException {
- UnpairedSurrogateException(int index, int length) {
- super("Unpaired surrogate at index " + index + " of " + length);
- }
- }
-}
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/AdvancedFeatures.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/AdvancedFeatures.java
deleted file mode 100644
index cf49086cd..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/AdvancedFeatures.java
+++ /dev/null
@@ -1,16 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-/**
- * New schema language features that are not supported by old code generators.
- */
-@SuppressWarnings("unused")
-public final class AdvancedFeatures {
- private AdvancedFeatures() { }
- public static final long AdvancedArrayFeatures = 1L;
- public static final long AdvancedUnionFeatures = 2L;
- public static final long OptionalScalars = 4L;
- public static final long DefaultVectorsAndStrings = 8L;
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/BaseType.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/BaseType.java
deleted file mode 100644
index ef6ba2d40..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/BaseType.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-@SuppressWarnings("unused")
-public final class BaseType {
- private BaseType() { }
- public static final byte None = 0;
- public static final byte UType = 1;
- public static final byte Bool = 2;
- public static final byte Byte = 3;
- public static final byte UByte = 4;
- public static final byte Short = 5;
- public static final byte UShort = 6;
- public static final byte Int = 7;
- public static final byte UInt = 8;
- public static final byte Long = 9;
- public static final byte ULong = 10;
- public static final byte Float = 11;
- public static final byte Double = 12;
- public static final byte String = 13;
- public static final byte Vector = 14;
- public static final byte Obj = 15;
- public static final byte Union = 16;
- public static final byte Array = 17;
- public static final byte Vector64 = 18;
- public static final byte MaxBaseType = 19;
-
- public static final String[] names = { "None", "UType", "Bool", "Byte", "UByte", "Short", "UShort", "Int", "UInt", "Long", "ULong", "Float", "Double", "String", "Vector", "Obj", "Union", "Array", "Vector64", "MaxBaseType", };
-
- public static String name(int e) { return names[e]; }
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Enum.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Enum.java
deleted file mode 100644
index 6c8a41866..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Enum.java
+++ /dev/null
@@ -1,135 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-import com.google.flatbuffers.BaseVector;
-import com.google.flatbuffers.BooleanVector;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.Constants;
-import com.google.flatbuffers.DoubleVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FloatVector;
-import com.google.flatbuffers.IntVector;
-import com.google.flatbuffers.LongVector;
-import com.google.flatbuffers.ShortVector;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.Struct;
-import com.google.flatbuffers.Table;
-import com.google.flatbuffers.UnionVector;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@SuppressWarnings("unused")
-public final class Enum extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
- public static Enum getRootAsEnum(ByteBuffer _bb) { return getRootAsEnum(_bb, new Enum()); }
- public static Enum getRootAsEnum(ByteBuffer _bb, Enum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public Enum __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
- public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
- public com.google.flatbuffers.reflection.EnumVal values(int j) { return values(new com.google.flatbuffers.reflection.EnumVal(), j); }
- public com.google.flatbuffers.reflection.EnumVal values(com.google.flatbuffers.reflection.EnumVal obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int valuesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.EnumVal valuesByKey(long key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.EnumVal.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.EnumVal valuesByKey(com.google.flatbuffers.reflection.EnumVal obj, long key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.EnumVal.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.EnumVal.Vector valuesVector() { return valuesVector(new com.google.flatbuffers.reflection.EnumVal.Vector()); }
- public com.google.flatbuffers.reflection.EnumVal.Vector valuesVector(com.google.flatbuffers.reflection.EnumVal.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public boolean isUnion() { int o = __offset(8); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
- public com.google.flatbuffers.reflection.Type underlyingType() { return underlyingType(new com.google.flatbuffers.reflection.Type()); }
- public com.google.flatbuffers.reflection.Type underlyingType(com.google.flatbuffers.reflection.Type obj) { int o = __offset(10); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
- public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(12); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int attributesLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(12); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(12); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public String documentation(int j) { int o = __offset(14); return o != 0 ? __string(__vector(o) + j * 4) : null; }
- public int documentationLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
- public StringVector documentationVector() { return documentationVector(new StringVector()); }
- public StringVector documentationVector(StringVector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- /**
- * File that this Enum is declared in.
- */
- public String declarationFile() { int o = __offset(16); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer declarationFileAsByteBuffer() { return __vector_as_bytebuffer(16, 1); }
- public ByteBuffer declarationFileInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 16, 1); }
-
- public static int createEnum(FlatBufferBuilder builder,
- int nameOffset,
- int valuesOffset,
- boolean isUnion,
- int underlyingTypeOffset,
- int attributesOffset,
- int documentationOffset,
- int declarationFileOffset) {
- builder.startTable(7);
- Enum.addDeclarationFile(builder, declarationFileOffset);
- Enum.addDocumentation(builder, documentationOffset);
- Enum.addAttributes(builder, attributesOffset);
- Enum.addUnderlyingType(builder, underlyingTypeOffset);
- Enum.addValues(builder, valuesOffset);
- Enum.addName(builder, nameOffset);
- Enum.addIsUnion(builder, isUnion);
- return Enum.endEnum(builder);
- }
-
- public static void startEnum(FlatBufferBuilder builder) { builder.startTable(7); }
- public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
- public static void addValues(FlatBufferBuilder builder, int valuesOffset) { builder.addOffset(1, valuesOffset, 0); }
- public static int createValuesVector(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 startValuesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addIsUnion(FlatBufferBuilder builder, boolean isUnion) { builder.addBoolean(2, isUnion, false); }
- public static void addUnderlyingType(FlatBufferBuilder builder, int underlyingTypeOffset) { builder.addOffset(3, underlyingTypeOffset, 0); }
- public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(4, attributesOffset, 0); }
- public static int createAttributesVector(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 startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(5, documentationOffset, 0); }
- public static int createDocumentationVector(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 startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addDeclarationFile(FlatBufferBuilder builder, int declarationFileOffset) { builder.addOffset(6, declarationFileOffset, 0); }
- public static int endEnum(FlatBufferBuilder builder) {
- int o = builder.endTable();
- builder.required(o, 4); // name
- builder.required(o, 6); // values
- builder.required(o, 10); // underlying_type
- return o;
- }
-
- @Override
- protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
-
- public static Enum __lookup_by_key(Enum obj, int vectorLocation, String key, ByteBuffer bb) {
- byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
- int span = bb.getInt(vectorLocation - 4);
- int start = 0;
- while (span != 0) {
- int middle = span / 2;
- int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
- int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
- if (comp > 0) {
- span = middle;
- } else if (comp < 0) {
- middle++;
- start += middle;
- span -= middle;
- } else {
- return (obj == null ? new Enum() : obj).__assign(tableOffset, bb);
- }
- }
- return null;
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public Enum get(int j) { return get(new Enum(), j); }
- public Enum get(Enum obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- public Enum getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
- public Enum getByKey(Enum obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
- }
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/EnumVal.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/EnumVal.java
deleted file mode 100644
index 732371714..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/EnumVal.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-import com.google.flatbuffers.BaseVector;
-import com.google.flatbuffers.BooleanVector;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.Constants;
-import com.google.flatbuffers.DoubleVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FloatVector;
-import com.google.flatbuffers.IntVector;
-import com.google.flatbuffers.LongVector;
-import com.google.flatbuffers.ShortVector;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.Struct;
-import com.google.flatbuffers.Table;
-import com.google.flatbuffers.UnionVector;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@SuppressWarnings("unused")
-public final class EnumVal extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
- public static EnumVal getRootAsEnumVal(ByteBuffer _bb) { return getRootAsEnumVal(_bb, new EnumVal()); }
- public static EnumVal getRootAsEnumVal(ByteBuffer _bb, EnumVal obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public EnumVal __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
- public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
- public long value() { int o = __offset(6); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
- public com.google.flatbuffers.reflection.Type unionType() { return unionType(new com.google.flatbuffers.reflection.Type()); }
- public com.google.flatbuffers.reflection.Type unionType(com.google.flatbuffers.reflection.Type obj) { int o = __offset(10); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
- public String documentation(int j) { int o = __offset(12); return o != 0 ? __string(__vector(o) + j * 4) : null; }
- public int documentationLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; }
- public StringVector documentationVector() { return documentationVector(new StringVector()); }
- public StringVector documentationVector(StringVector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
- public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(14); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int attributesLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
-
- public static int createEnumVal(FlatBufferBuilder builder,
- int nameOffset,
- long value,
- int unionTypeOffset,
- int documentationOffset,
- int attributesOffset) {
- builder.startTable(6);
- EnumVal.addValue(builder, value);
- EnumVal.addAttributes(builder, attributesOffset);
- EnumVal.addDocumentation(builder, documentationOffset);
- EnumVal.addUnionType(builder, unionTypeOffset);
- EnumVal.addName(builder, nameOffset);
- return EnumVal.endEnumVal(builder);
- }
-
- public static void startEnumVal(FlatBufferBuilder builder) { builder.startTable(6); }
- public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(0, nameOffset, 0); }
- public static void addValue(FlatBufferBuilder builder, long value) { builder.addLong(value); builder.slot(1); }
- public static void addUnionType(FlatBufferBuilder builder, int unionTypeOffset) { builder.addOffset(3, unionTypeOffset, 0); }
- public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(4, documentationOffset, 0); }
- public static int createDocumentationVector(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 startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(5, attributesOffset, 0); }
- public static int createAttributesVector(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 startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static int endEnumVal(FlatBufferBuilder builder) {
- int o = builder.endTable();
- builder.required(o, 4); // name
- return o;
- }
-
- @Override
- protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) {
- long val_1 = _bb.getLong(__offset(6, o1, _bb));
- long val_2 = _bb.getLong(__offset(6, o2, _bb));
- return val_1 > val_2 ? 1 : val_1 < val_2 ? -1 : 0;
- }
-
- public static EnumVal __lookup_by_key(EnumVal obj, int vectorLocation, long key, ByteBuffer bb) {
- int span = bb.getInt(vectorLocation - 4);
- int start = 0;
- while (span != 0) {
- int middle = span / 2;
- int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
- long val = bb.getLong(__offset(6, bb.capacity() - tableOffset, bb));
- int comp = val > key ? 1 : val < key ? -1 : 0;
- if (comp > 0) {
- span = middle;
- } else if (comp < 0) {
- middle++;
- start += middle;
- span -= middle;
- } else {
- return (obj == null ? new EnumVal() : obj).__assign(tableOffset, bb);
- }
- }
- return null;
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public EnumVal get(int j) { return get(new EnumVal(), j); }
- public EnumVal get(EnumVal obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- public EnumVal getByKey(long key) { return __lookup_by_key(null, __vector(), key, bb); }
- public EnumVal getByKey(EnumVal obj, long key) { return __lookup_by_key(obj, __vector(), key, bb); }
- }
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Field.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Field.java
deleted file mode 100644
index d5c1c13a5..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Field.java
+++ /dev/null
@@ -1,155 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-import com.google.flatbuffers.BaseVector;
-import com.google.flatbuffers.BooleanVector;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.Constants;
-import com.google.flatbuffers.DoubleVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FloatVector;
-import com.google.flatbuffers.IntVector;
-import com.google.flatbuffers.LongVector;
-import com.google.flatbuffers.ShortVector;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.Struct;
-import com.google.flatbuffers.Table;
-import com.google.flatbuffers.UnionVector;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@SuppressWarnings("unused")
-public final class Field extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
- public static Field getRootAsField(ByteBuffer _bb) { return getRootAsField(_bb, new Field()); }
- public static Field getRootAsField(ByteBuffer _bb, Field obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public Field __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
- public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
- public com.google.flatbuffers.reflection.Type type() { return type(new com.google.flatbuffers.reflection.Type()); }
- public com.google.flatbuffers.reflection.Type type(com.google.flatbuffers.reflection.Type obj) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
- public int id() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
- public int offset() { int o = __offset(10); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
- public long defaultInteger() { int o = __offset(12); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
- public double defaultReal() { int o = __offset(14); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
- public boolean deprecated() { int o = __offset(16); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
- public boolean required() { int o = __offset(18); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
- public boolean key() { int o = __offset(20); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
- public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
- public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(22); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int attributesLength() { int o = __offset(22); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(22); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(22); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(22); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public String documentation(int j) { int o = __offset(24); return o != 0 ? __string(__vector(o) + j * 4) : null; }
- public int documentationLength() { int o = __offset(24); return o != 0 ? __vector_len(o) : 0; }
- public StringVector documentationVector() { return documentationVector(new StringVector()); }
- public StringVector documentationVector(StringVector obj) { int o = __offset(24); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public boolean optional() { int o = __offset(26); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
- /**
- * Number of padding octets to always add after this field. Structs only.
- */
- public int padding() { int o = __offset(28); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
- /**
- * If the field uses 64-bit offsets.
- */
- public boolean offset64() { int o = __offset(30); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
-
- public static int createField(FlatBufferBuilder builder,
- int nameOffset,
- int typeOffset,
- int id,
- int offset,
- long defaultInteger,
- double defaultReal,
- boolean deprecated,
- boolean required,
- boolean key,
- int attributesOffset,
- int documentationOffset,
- boolean optional,
- int padding,
- boolean offset64) {
- builder.startTable(14);
- Field.addDefaultReal(builder, defaultReal);
- Field.addDefaultInteger(builder, defaultInteger);
- Field.addDocumentation(builder, documentationOffset);
- Field.addAttributes(builder, attributesOffset);
- Field.addType(builder, typeOffset);
- Field.addName(builder, nameOffset);
- Field.addPadding(builder, padding);
- Field.addOffset(builder, offset);
- Field.addId(builder, id);
- Field.addOffset64(builder, offset64);
- Field.addOptional(builder, optional);
- Field.addKey(builder, key);
- Field.addRequired(builder, required);
- Field.addDeprecated(builder, deprecated);
- return Field.endField(builder);
- }
-
- public static void startField(FlatBufferBuilder builder) { builder.startTable(14); }
- public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
- public static void addType(FlatBufferBuilder builder, int typeOffset) { builder.addOffset(1, typeOffset, 0); }
- public static void addId(FlatBufferBuilder builder, int id) { builder.addShort(2, (short) id, (short) 0); }
- public static void addOffset(FlatBufferBuilder builder, int offset) { builder.addShort(3, (short) offset, (short) 0); }
- public static void addDefaultInteger(FlatBufferBuilder builder, long defaultInteger) { builder.addLong(4, defaultInteger, 0L); }
- public static void addDefaultReal(FlatBufferBuilder builder, double defaultReal) { builder.addDouble(5, defaultReal, 0.0); }
- public static void addDeprecated(FlatBufferBuilder builder, boolean deprecated) { builder.addBoolean(6, deprecated, false); }
- public static void addRequired(FlatBufferBuilder builder, boolean required) { builder.addBoolean(7, required, false); }
- public static void addKey(FlatBufferBuilder builder, boolean key) { builder.addBoolean(8, key, false); }
- public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(9, attributesOffset, 0); }
- public static int createAttributesVector(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 startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(10, documentationOffset, 0); }
- public static int createDocumentationVector(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 startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addOptional(FlatBufferBuilder builder, boolean optional) { builder.addBoolean(11, optional, false); }
- public static void addPadding(FlatBufferBuilder builder, int padding) { builder.addShort(12, (short) padding, (short) 0); }
- public static void addOffset64(FlatBufferBuilder builder, boolean offset64) { builder.addBoolean(13, offset64, false); }
- public static int endField(FlatBufferBuilder builder) {
- int o = builder.endTable();
- builder.required(o, 4); // name
- builder.required(o, 6); // type
- return o;
- }
-
- @Override
- protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
-
- public static Field __lookup_by_key(Field obj, int vectorLocation, String key, ByteBuffer bb) {
- byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
- int span = bb.getInt(vectorLocation - 4);
- int start = 0;
- while (span != 0) {
- int middle = span / 2;
- int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
- int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
- if (comp > 0) {
- span = middle;
- } else if (comp < 0) {
- middle++;
- start += middle;
- span -= middle;
- } else {
- return (obj == null ? new Field() : obj).__assign(tableOffset, bb);
- }
- }
- return null;
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public Field get(int j) { return get(new Field(), j); }
- public Field get(Field obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- public Field getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
- public Field getByKey(Field obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
- }
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/KeyValue.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/KeyValue.java
deleted file mode 100644
index 546404bc2..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/KeyValue.java
+++ /dev/null
@@ -1,88 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-import com.google.flatbuffers.BaseVector;
-import com.google.flatbuffers.BooleanVector;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.Constants;
-import com.google.flatbuffers.DoubleVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FloatVector;
-import com.google.flatbuffers.IntVector;
-import com.google.flatbuffers.LongVector;
-import com.google.flatbuffers.ShortVector;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.Struct;
-import com.google.flatbuffers.Table;
-import com.google.flatbuffers.UnionVector;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@SuppressWarnings("unused")
-public final class KeyValue extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
- public static KeyValue getRootAsKeyValue(ByteBuffer _bb) { return getRootAsKeyValue(_bb, new KeyValue()); }
- public static KeyValue getRootAsKeyValue(ByteBuffer _bb, KeyValue obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public KeyValue __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public String key() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer keyAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
- public ByteBuffer keyInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
- public String value() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer valueAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
- public ByteBuffer valueInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); }
-
- public static int createKeyValue(FlatBufferBuilder builder,
- int keyOffset,
- int valueOffset) {
- builder.startTable(2);
- KeyValue.addValue(builder, valueOffset);
- KeyValue.addKey(builder, keyOffset);
- return KeyValue.endKeyValue(builder);
- }
-
- public static void startKeyValue(FlatBufferBuilder builder) { builder.startTable(2); }
- public static void addKey(FlatBufferBuilder builder, int keyOffset) { builder.addOffset(keyOffset); builder.slot(0); }
- public static void addValue(FlatBufferBuilder builder, int valueOffset) { builder.addOffset(1, valueOffset, 0); }
- public static int endKeyValue(FlatBufferBuilder builder) {
- int o = builder.endTable();
- builder.required(o, 4); // key
- return o;
- }
-
- @Override
- protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
-
- public static KeyValue __lookup_by_key(KeyValue obj, int vectorLocation, String key, ByteBuffer bb) {
- byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
- int span = bb.getInt(vectorLocation - 4);
- int start = 0;
- while (span != 0) {
- int middle = span / 2;
- int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
- int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
- if (comp > 0) {
- span = middle;
- } else if (comp < 0) {
- middle++;
- start += middle;
- span -= middle;
- } else {
- return (obj == null ? new KeyValue() : obj).__assign(tableOffset, bb);
- }
- }
- return null;
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public KeyValue get(int j) { return get(new KeyValue(), j); }
- public KeyValue get(KeyValue obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- public KeyValue getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
- public KeyValue getByKey(KeyValue obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
- }
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Object.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Object.java
deleted file mode 100644
index 70d73263a..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Object.java
+++ /dev/null
@@ -1,137 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-import com.google.flatbuffers.BaseVector;
-import com.google.flatbuffers.BooleanVector;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.Constants;
-import com.google.flatbuffers.DoubleVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FloatVector;
-import com.google.flatbuffers.IntVector;
-import com.google.flatbuffers.LongVector;
-import com.google.flatbuffers.ShortVector;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.Struct;
-import com.google.flatbuffers.Table;
-import com.google.flatbuffers.UnionVector;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@SuppressWarnings("unused")
-public final class Object extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
- public static Object getRootAsObject(ByteBuffer _bb) { return getRootAsObject(_bb, new Object()); }
- public static Object getRootAsObject(ByteBuffer _bb, Object obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public Object __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
- public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
- public com.google.flatbuffers.reflection.Field fields(int j) { return fields(new com.google.flatbuffers.reflection.Field(), j); }
- public com.google.flatbuffers.reflection.Field fields(com.google.flatbuffers.reflection.Field obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int fieldsLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.Field fieldsByKey(String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Field.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.Field fieldsByKey(com.google.flatbuffers.reflection.Field obj, String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Field.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.Field.Vector fieldsVector() { return fieldsVector(new com.google.flatbuffers.reflection.Field.Vector()); }
- public com.google.flatbuffers.reflection.Field.Vector fieldsVector(com.google.flatbuffers.reflection.Field.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public boolean isStruct() { int o = __offset(8); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
- public int minalign() { int o = __offset(10); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
- public int bytesize() { int o = __offset(12); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
- public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
- public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(14); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int attributesLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public String documentation(int j) { int o = __offset(16); return o != 0 ? __string(__vector(o) + j * 4) : null; }
- public int documentationLength() { int o = __offset(16); return o != 0 ? __vector_len(o) : 0; }
- public StringVector documentationVector() { return documentationVector(new StringVector()); }
- public StringVector documentationVector(StringVector obj) { int o = __offset(16); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- /**
- * File that this Object is declared in.
- */
- public String declarationFile() { int o = __offset(18); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer declarationFileAsByteBuffer() { return __vector_as_bytebuffer(18, 1); }
- public ByteBuffer declarationFileInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 18, 1); }
-
- public static int createObject(FlatBufferBuilder builder,
- int nameOffset,
- int fieldsOffset,
- boolean isStruct,
- int minalign,
- int bytesize,
- int attributesOffset,
- int documentationOffset,
- int declarationFileOffset) {
- builder.startTable(8);
- Object.addDeclarationFile(builder, declarationFileOffset);
- Object.addDocumentation(builder, documentationOffset);
- Object.addAttributes(builder, attributesOffset);
- Object.addBytesize(builder, bytesize);
- Object.addMinalign(builder, minalign);
- Object.addFields(builder, fieldsOffset);
- Object.addName(builder, nameOffset);
- Object.addIsStruct(builder, isStruct);
- return Object.endObject(builder);
- }
-
- public static void startObject(FlatBufferBuilder builder) { builder.startTable(8); }
- public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
- public static void addFields(FlatBufferBuilder builder, int fieldsOffset) { builder.addOffset(1, fieldsOffset, 0); }
- public static int createFieldsVector(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 startFieldsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addIsStruct(FlatBufferBuilder builder, boolean isStruct) { builder.addBoolean(2, isStruct, false); }
- public static void addMinalign(FlatBufferBuilder builder, int minalign) { builder.addInt(3, minalign, 0); }
- public static void addBytesize(FlatBufferBuilder builder, int bytesize) { builder.addInt(4, bytesize, 0); }
- public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(5, attributesOffset, 0); }
- public static int createAttributesVector(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 startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(6, documentationOffset, 0); }
- public static int createDocumentationVector(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 startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addDeclarationFile(FlatBufferBuilder builder, int declarationFileOffset) { builder.addOffset(7, declarationFileOffset, 0); }
- public static int endObject(FlatBufferBuilder builder) {
- int o = builder.endTable();
- builder.required(o, 4); // name
- builder.required(o, 6); // fields
- return o;
- }
-
- @Override
- protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
-
- public static Object __lookup_by_key(Object obj, int vectorLocation, String key, ByteBuffer bb) {
- byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
- int span = bb.getInt(vectorLocation - 4);
- int start = 0;
- while (span != 0) {
- int middle = span / 2;
- int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
- int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
- if (comp > 0) {
- span = middle;
- } else if (comp < 0) {
- middle++;
- start += middle;
- span -= middle;
- } else {
- return (obj == null ? new Object() : obj).__assign(tableOffset, bb);
- }
- }
- return null;
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public Object get(int j) { return get(new Object(), j); }
- public Object get(Object obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- public Object getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
- public Object getByKey(Object obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
- }
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/RPCCall.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/RPCCall.java
deleted file mode 100644
index f970d6ecb..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/RPCCall.java
+++ /dev/null
@@ -1,115 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-import com.google.flatbuffers.BaseVector;
-import com.google.flatbuffers.BooleanVector;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.Constants;
-import com.google.flatbuffers.DoubleVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FloatVector;
-import com.google.flatbuffers.IntVector;
-import com.google.flatbuffers.LongVector;
-import com.google.flatbuffers.ShortVector;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.Struct;
-import com.google.flatbuffers.Table;
-import com.google.flatbuffers.UnionVector;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@SuppressWarnings("unused")
-public final class RPCCall extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
- public static RPCCall getRootAsRPCCall(ByteBuffer _bb) { return getRootAsRPCCall(_bb, new RPCCall()); }
- public static RPCCall getRootAsRPCCall(ByteBuffer _bb, RPCCall obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public RPCCall __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
- public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
- public com.google.flatbuffers.reflection.Object request() { return request(new com.google.flatbuffers.reflection.Object()); }
- public com.google.flatbuffers.reflection.Object request(com.google.flatbuffers.reflection.Object obj) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
- public com.google.flatbuffers.reflection.Object response() { return response(new com.google.flatbuffers.reflection.Object()); }
- public com.google.flatbuffers.reflection.Object response(com.google.flatbuffers.reflection.Object obj) { int o = __offset(8); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
- public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(10); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int attributesLength() { int o = __offset(10); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(10); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(10); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(10); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public String documentation(int j) { int o = __offset(12); return o != 0 ? __string(__vector(o) + j * 4) : null; }
- public int documentationLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; }
- public StringVector documentationVector() { return documentationVector(new StringVector()); }
- public StringVector documentationVector(StringVector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
-
- public static int createRPCCall(FlatBufferBuilder builder,
- int nameOffset,
- int requestOffset,
- int responseOffset,
- int attributesOffset,
- int documentationOffset) {
- builder.startTable(5);
- RPCCall.addDocumentation(builder, documentationOffset);
- RPCCall.addAttributes(builder, attributesOffset);
- RPCCall.addResponse(builder, responseOffset);
- RPCCall.addRequest(builder, requestOffset);
- RPCCall.addName(builder, nameOffset);
- return RPCCall.endRPCCall(builder);
- }
-
- public static void startRPCCall(FlatBufferBuilder builder) { builder.startTable(5); }
- public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
- public static void addRequest(FlatBufferBuilder builder, int requestOffset) { builder.addOffset(1, requestOffset, 0); }
- public static void addResponse(FlatBufferBuilder builder, int responseOffset) { builder.addOffset(2, responseOffset, 0); }
- public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(3, attributesOffset, 0); }
- public static int createAttributesVector(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 startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(4, documentationOffset, 0); }
- public static int createDocumentationVector(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 startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static int endRPCCall(FlatBufferBuilder builder) {
- int o = builder.endTable();
- builder.required(o, 4); // name
- builder.required(o, 6); // request
- builder.required(o, 8); // response
- return o;
- }
-
- @Override
- protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
-
- public static RPCCall __lookup_by_key(RPCCall obj, int vectorLocation, String key, ByteBuffer bb) {
- byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
- int span = bb.getInt(vectorLocation - 4);
- int start = 0;
- while (span != 0) {
- int middle = span / 2;
- int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
- int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
- if (comp > 0) {
- span = middle;
- } else if (comp < 0) {
- middle++;
- start += middle;
- span -= middle;
- } else {
- return (obj == null ? new RPCCall() : obj).__assign(tableOffset, bb);
- }
- }
- return null;
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public RPCCall get(int j) { return get(new RPCCall(), j); }
- public RPCCall get(RPCCall obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- public RPCCall getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
- public RPCCall getByKey(RPCCall obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
- }
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Schema.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Schema.java
deleted file mode 100644
index 1cbe7b3b6..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Schema.java
+++ /dev/null
@@ -1,127 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-import com.google.flatbuffers.BaseVector;
-import com.google.flatbuffers.BooleanVector;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.Constants;
-import com.google.flatbuffers.DoubleVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FloatVector;
-import com.google.flatbuffers.IntVector;
-import com.google.flatbuffers.LongVector;
-import com.google.flatbuffers.ShortVector;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.Struct;
-import com.google.flatbuffers.Table;
-import com.google.flatbuffers.UnionVector;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@SuppressWarnings("unused")
-public final class Schema extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
- public static Schema getRootAsSchema(ByteBuffer _bb) { return getRootAsSchema(_bb, new Schema()); }
- public static Schema getRootAsSchema(ByteBuffer _bb, Schema obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public static boolean SchemaBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "BFBS"); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public Schema __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public com.google.flatbuffers.reflection.Object objects(int j) { return objects(new com.google.flatbuffers.reflection.Object(), j); }
- public com.google.flatbuffers.reflection.Object objects(com.google.flatbuffers.reflection.Object obj, int j) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int objectsLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.Object objectsByKey(String key) { int o = __offset(4); return o != 0 ? com.google.flatbuffers.reflection.Object.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.Object objectsByKey(com.google.flatbuffers.reflection.Object obj, String key) { int o = __offset(4); return o != 0 ? com.google.flatbuffers.reflection.Object.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.Object.Vector objectsVector() { return objectsVector(new com.google.flatbuffers.reflection.Object.Vector()); }
- public com.google.flatbuffers.reflection.Object.Vector objectsVector(com.google.flatbuffers.reflection.Object.Vector obj) { int o = __offset(4); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public com.google.flatbuffers.reflection.Enum enums(int j) { return enums(new com.google.flatbuffers.reflection.Enum(), j); }
- public com.google.flatbuffers.reflection.Enum enums(com.google.flatbuffers.reflection.Enum obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int enumsLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.Enum enumsByKey(String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Enum.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.Enum enumsByKey(com.google.flatbuffers.reflection.Enum obj, String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Enum.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.Enum.Vector enumsVector() { return enumsVector(new com.google.flatbuffers.reflection.Enum.Vector()); }
- public com.google.flatbuffers.reflection.Enum.Vector enumsVector(com.google.flatbuffers.reflection.Enum.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public String fileIdent() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer fileIdentAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
- public ByteBuffer fileIdentInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); }
- public String fileExt() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer fileExtAsByteBuffer() { return __vector_as_bytebuffer(10, 1); }
- public ByteBuffer fileExtInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 10, 1); }
- public com.google.flatbuffers.reflection.Object rootTable() { return rootTable(new com.google.flatbuffers.reflection.Object()); }
- public com.google.flatbuffers.reflection.Object rootTable(com.google.flatbuffers.reflection.Object obj) { int o = __offset(12); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
- public com.google.flatbuffers.reflection.Service services(int j) { return services(new com.google.flatbuffers.reflection.Service(), j); }
- public com.google.flatbuffers.reflection.Service services(com.google.flatbuffers.reflection.Service obj, int j) { int o = __offset(14); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int servicesLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.Service servicesByKey(String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.Service.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.Service servicesByKey(com.google.flatbuffers.reflection.Service obj, String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.Service.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.Service.Vector servicesVector() { return servicesVector(new com.google.flatbuffers.reflection.Service.Vector()); }
- public com.google.flatbuffers.reflection.Service.Vector servicesVector(com.google.flatbuffers.reflection.Service.Vector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public long advancedFeatures() { int o = __offset(16); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
- /**
- * All the files used in this compilation. Files are relative to where
- * flatc was invoked.
- */
- public com.google.flatbuffers.reflection.SchemaFile fbsFiles(int j) { return fbsFiles(new com.google.flatbuffers.reflection.SchemaFile(), j); }
- public com.google.flatbuffers.reflection.SchemaFile fbsFiles(com.google.flatbuffers.reflection.SchemaFile obj, int j) { int o = __offset(18); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int fbsFilesLength() { int o = __offset(18); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.SchemaFile fbsFilesByKey(String key) { int o = __offset(18); return o != 0 ? com.google.flatbuffers.reflection.SchemaFile.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.SchemaFile fbsFilesByKey(com.google.flatbuffers.reflection.SchemaFile obj, String key) { int o = __offset(18); return o != 0 ? com.google.flatbuffers.reflection.SchemaFile.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.SchemaFile.Vector fbsFilesVector() { return fbsFilesVector(new com.google.flatbuffers.reflection.SchemaFile.Vector()); }
- public com.google.flatbuffers.reflection.SchemaFile.Vector fbsFilesVector(com.google.flatbuffers.reflection.SchemaFile.Vector obj) { int o = __offset(18); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
-
- public static int createSchema(FlatBufferBuilder builder,
- int objectsOffset,
- int enumsOffset,
- int fileIdentOffset,
- int fileExtOffset,
- int rootTableOffset,
- int servicesOffset,
- long advancedFeatures,
- int fbsFilesOffset) {
- builder.startTable(8);
- Schema.addAdvancedFeatures(builder, advancedFeatures);
- Schema.addFbsFiles(builder, fbsFilesOffset);
- Schema.addServices(builder, servicesOffset);
- Schema.addRootTable(builder, rootTableOffset);
- Schema.addFileExt(builder, fileExtOffset);
- Schema.addFileIdent(builder, fileIdentOffset);
- Schema.addEnums(builder, enumsOffset);
- Schema.addObjects(builder, objectsOffset);
- return Schema.endSchema(builder);
- }
-
- public static void startSchema(FlatBufferBuilder builder) { builder.startTable(8); }
- public static void addObjects(FlatBufferBuilder builder, int objectsOffset) { builder.addOffset(0, objectsOffset, 0); }
- public static int createObjectsVector(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 startObjectsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addEnums(FlatBufferBuilder builder, int enumsOffset) { builder.addOffset(1, enumsOffset, 0); }
- public static int createEnumsVector(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 startEnumsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addFileIdent(FlatBufferBuilder builder, int fileIdentOffset) { builder.addOffset(2, fileIdentOffset, 0); }
- public static void addFileExt(FlatBufferBuilder builder, int fileExtOffset) { builder.addOffset(3, fileExtOffset, 0); }
- public static void addRootTable(FlatBufferBuilder builder, int rootTableOffset) { builder.addOffset(4, rootTableOffset, 0); }
- public static void addServices(FlatBufferBuilder builder, int servicesOffset) { builder.addOffset(5, servicesOffset, 0); }
- public static int createServicesVector(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 startServicesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addAdvancedFeatures(FlatBufferBuilder builder, long advancedFeatures) { builder.addLong(6, advancedFeatures, 0L); }
- public static void addFbsFiles(FlatBufferBuilder builder, int fbsFilesOffset) { builder.addOffset(7, fbsFilesOffset, 0); }
- public static int createFbsFilesVector(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 startFbsFilesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static int endSchema(FlatBufferBuilder builder) {
- int o = builder.endTable();
- builder.required(o, 4); // objects
- builder.required(o, 6); // enums
- return o;
- }
- public static void finishSchemaBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset, "BFBS"); }
- public static void finishSizePrefixedSchemaBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset, "BFBS"); }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public Schema get(int j) { return get(new Schema(), j); }
- public Schema get(Schema obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- }
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/SchemaFile.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/SchemaFile.java
deleted file mode 100644
index a9a7630c7..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/SchemaFile.java
+++ /dev/null
@@ -1,102 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-import com.google.flatbuffers.BaseVector;
-import com.google.flatbuffers.BooleanVector;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.Constants;
-import com.google.flatbuffers.DoubleVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FloatVector;
-import com.google.flatbuffers.IntVector;
-import com.google.flatbuffers.LongVector;
-import com.google.flatbuffers.ShortVector;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.Struct;
-import com.google.flatbuffers.Table;
-import com.google.flatbuffers.UnionVector;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * File specific information.
- * Symbols declared within a file may be recovered by iterating over all
- * symbols and examining the `declaration_file` field.
- */
-@SuppressWarnings("unused")
-public final class SchemaFile extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
- public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb) { return getRootAsSchemaFile(_bb, new SchemaFile()); }
- public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb, SchemaFile obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public SchemaFile __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- /**
- * Filename, relative to project root.
- */
- public String filename() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer filenameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
- public ByteBuffer filenameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
- /**
- * Names of included files, relative to project root.
- */
- public String includedFilenames(int j) { int o = __offset(6); return o != 0 ? __string(__vector(o) + j * 4) : null; }
- public int includedFilenamesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
- public StringVector includedFilenamesVector() { return includedFilenamesVector(new StringVector()); }
- public StringVector includedFilenamesVector(StringVector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
-
- public static int createSchemaFile(FlatBufferBuilder builder,
- int filenameOffset,
- int includedFilenamesOffset) {
- builder.startTable(2);
- SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset);
- SchemaFile.addFilename(builder, filenameOffset);
- return SchemaFile.endSchemaFile(builder);
- }
-
- public static void startSchemaFile(FlatBufferBuilder builder) { builder.startTable(2); }
- public static void addFilename(FlatBufferBuilder builder, int filenameOffset) { builder.addOffset(filenameOffset); builder.slot(0); }
- public static void addIncludedFilenames(FlatBufferBuilder builder, int includedFilenamesOffset) { builder.addOffset(1, includedFilenamesOffset, 0); }
- public static int createIncludedFilenamesVector(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 startIncludedFilenamesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static int endSchemaFile(FlatBufferBuilder builder) {
- int o = builder.endTable();
- builder.required(o, 4); // filename
- return o;
- }
-
- @Override
- protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
-
- public static SchemaFile __lookup_by_key(SchemaFile obj, int vectorLocation, String key, ByteBuffer bb) {
- byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
- int span = bb.getInt(vectorLocation - 4);
- int start = 0;
- while (span != 0) {
- int middle = span / 2;
- int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
- int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
- if (comp > 0) {
- span = middle;
- } else if (comp < 0) {
- middle++;
- start += middle;
- span -= middle;
- } else {
- return (obj == null ? new SchemaFile() : obj).__assign(tableOffset, bb);
- }
- }
- return null;
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public SchemaFile get(int j) { return get(new SchemaFile(), j); }
- public SchemaFile get(SchemaFile obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- public SchemaFile getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
- public SchemaFile getByKey(SchemaFile obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
- }
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Service.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Service.java
deleted file mode 100644
index d33a6e955..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Service.java
+++ /dev/null
@@ -1,124 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-import com.google.flatbuffers.BaseVector;
-import com.google.flatbuffers.BooleanVector;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.Constants;
-import com.google.flatbuffers.DoubleVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FloatVector;
-import com.google.flatbuffers.IntVector;
-import com.google.flatbuffers.LongVector;
-import com.google.flatbuffers.ShortVector;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.Struct;
-import com.google.flatbuffers.Table;
-import com.google.flatbuffers.UnionVector;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@SuppressWarnings("unused")
-public final class Service extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
- public static Service getRootAsService(ByteBuffer _bb) { return getRootAsService(_bb, new Service()); }
- public static Service getRootAsService(ByteBuffer _bb, Service obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public Service __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
- public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
- public com.google.flatbuffers.reflection.RPCCall calls(int j) { return calls(new com.google.flatbuffers.reflection.RPCCall(), j); }
- public com.google.flatbuffers.reflection.RPCCall calls(com.google.flatbuffers.reflection.RPCCall obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int callsLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.RPCCall callsByKey(String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.RPCCall.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.RPCCall callsByKey(com.google.flatbuffers.reflection.RPCCall obj, String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.RPCCall.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.RPCCall.Vector callsVector() { return callsVector(new com.google.flatbuffers.reflection.RPCCall.Vector()); }
- public com.google.flatbuffers.reflection.RPCCall.Vector callsVector(com.google.flatbuffers.reflection.RPCCall.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
- public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(8); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int attributesLength() { int o = __offset(8); return o != 0 ? __vector_len(o) : 0; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(8); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(8); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
- public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(8); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public String documentation(int j) { int o = __offset(10); return o != 0 ? __string(__vector(o) + j * 4) : null; }
- public int documentationLength() { int o = __offset(10); return o != 0 ? __vector_len(o) : 0; }
- public StringVector documentationVector() { return documentationVector(new StringVector()); }
- public StringVector documentationVector(StringVector obj) { int o = __offset(10); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- /**
- * File that this Service is declared in.
- */
- public String declarationFile() { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer declarationFileAsByteBuffer() { return __vector_as_bytebuffer(12, 1); }
- public ByteBuffer declarationFileInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 12, 1); }
-
- public static int createService(FlatBufferBuilder builder,
- int nameOffset,
- int callsOffset,
- int attributesOffset,
- int documentationOffset,
- int declarationFileOffset) {
- builder.startTable(5);
- Service.addDeclarationFile(builder, declarationFileOffset);
- Service.addDocumentation(builder, documentationOffset);
- Service.addAttributes(builder, attributesOffset);
- Service.addCalls(builder, callsOffset);
- Service.addName(builder, nameOffset);
- return Service.endService(builder);
- }
-
- public static void startService(FlatBufferBuilder builder) { builder.startTable(5); }
- public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
- public static void addCalls(FlatBufferBuilder builder, int callsOffset) { builder.addOffset(1, callsOffset, 0); }
- public static int createCallsVector(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 startCallsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(2, attributesOffset, 0); }
- public static int createAttributesVector(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 startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(3, documentationOffset, 0); }
- public static int createDocumentationVector(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 startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addDeclarationFile(FlatBufferBuilder builder, int declarationFileOffset) { builder.addOffset(4, declarationFileOffset, 0); }
- public static int endService(FlatBufferBuilder builder) {
- int o = builder.endTable();
- builder.required(o, 4); // name
- return o;
- }
-
- @Override
- protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
-
- public static Service __lookup_by_key(Service obj, int vectorLocation, String key, ByteBuffer bb) {
- byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
- int span = bb.getInt(vectorLocation - 4);
- int start = 0;
- while (span != 0) {
- int middle = span / 2;
- int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
- int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
- if (comp > 0) {
- span = middle;
- } else if (comp < 0) {
- middle++;
- start += middle;
- span -= middle;
- } else {
- return (obj == null ? new Service() : obj).__assign(tableOffset, bb);
- }
- }
- return null;
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public Service get(int j) { return get(new Service(), j); }
- public Service get(Service obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- public Service getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
- public Service getByKey(Service obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
- }
-}
-
diff --git a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Type.java b/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Type.java
deleted file mode 100644
index ca0e18ac6..000000000
--- a/third_party/flatbuffers/java/src/main/java/com/google/flatbuffers/reflection/Type.java
+++ /dev/null
@@ -1,79 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package com.google.flatbuffers.reflection;
-
-import com.google.flatbuffers.BaseVector;
-import com.google.flatbuffers.BooleanVector;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.Constants;
-import com.google.flatbuffers.DoubleVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FloatVector;
-import com.google.flatbuffers.IntVector;
-import com.google.flatbuffers.LongVector;
-import com.google.flatbuffers.ShortVector;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.Struct;
-import com.google.flatbuffers.Table;
-import com.google.flatbuffers.UnionVector;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-@SuppressWarnings("unused")
-public final class Type extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
- public static Type getRootAsType(ByteBuffer _bb) { return getRootAsType(_bb, new Type()); }
- public static Type getRootAsType(ByteBuffer _bb, Type obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public Type __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public byte baseType() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; }
- public byte element() { int o = __offset(6); return o != 0 ? bb.get(o + bb_pos) : 0; }
- public int index() { int o = __offset(8); return o != 0 ? bb.getInt(o + bb_pos) : -1; }
- public int fixedLength() { int o = __offset(10); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
- /**
- * The size (octets) of the `base_type` field.
- */
- public long baseSize() { int o = __offset(12); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 4L; }
- /**
- * The size (octets) of the `element` field, if present.
- */
- public long elementSize() { int o = __offset(14); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
-
- public static int createType(FlatBufferBuilder builder,
- byte baseType,
- byte element,
- int index,
- int fixedLength,
- long baseSize,
- long elementSize) {
- builder.startTable(6);
- Type.addElementSize(builder, elementSize);
- Type.addBaseSize(builder, baseSize);
- Type.addIndex(builder, index);
- Type.addFixedLength(builder, fixedLength);
- Type.addElement(builder, element);
- Type.addBaseType(builder, baseType);
- return Type.endType(builder);
- }
-
- public static void startType(FlatBufferBuilder builder) { builder.startTable(6); }
- public static void addBaseType(FlatBufferBuilder builder, byte baseType) { builder.addByte(0, baseType, 0); }
- public static void addElement(FlatBufferBuilder builder, byte element) { builder.addByte(1, element, 0); }
- public static void addIndex(FlatBufferBuilder builder, int index) { builder.addInt(2, index, -1); }
- public static void addFixedLength(FlatBufferBuilder builder, int fixedLength) { builder.addShort(3, (short) fixedLength, (short) 0); }
- public static void addBaseSize(FlatBufferBuilder builder, long baseSize) { builder.addInt(4, (int) baseSize, (int) 4L); }
- public static void addElementSize(FlatBufferBuilder builder, long elementSize) { builder.addInt(5, (int) elementSize, (int) 0L); }
- public static int endType(FlatBufferBuilder builder) {
- int o = builder.endTable();
- return o;
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public Type get(int j) { return get(new Type(), j); }
- public Type get(Type obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- }
-}
-
diff --git a/third_party/flatbuffers/java/src/test/java/DictionaryLookup b/third_party/flatbuffers/java/src/test/java/DictionaryLookup
deleted file mode 120000
index 231bcd800..000000000
--- a/third_party/flatbuffers/java/src/test/java/DictionaryLookup
+++ /dev/null
@@ -1 +0,0 @@
-../../../../tests/DictionaryLookup
\ No newline at end of file
diff --git a/third_party/flatbuffers/java/src/test/java/JavaTest.java b/third_party/flatbuffers/java/src/test/java/JavaTest.java
deleted file mode 100644
index c392e040e..000000000
--- a/third_party/flatbuffers/java/src/test/java/JavaTest.java
+++ /dev/null
@@ -1,1533 +0,0 @@
-
-import static com.google.flatbuffers.Constants.*;
-import static com.google.common.truth.Truth.assertThat;
-
-import DictionaryLookup.*;
-import MyGame.Example.*;
-import com.google.common.io.ByteStreams;
-import optional_scalars.ScalarStuff;
-import optional_scalars.OptionalByte;
-import NamespaceA.*;
-import NamespaceA.NamespaceB.*;
-import com.google.flatbuffers.ByteBufferUtil;
-import com.google.flatbuffers.ByteVector;
-import com.google.flatbuffers.FlatBufferBuilder;
-import com.google.flatbuffers.FlexBuffers;
-import com.google.flatbuffers.FlexBuffersBuilder;
-import com.google.flatbuffers.StringVector;
-import com.google.flatbuffers.UnionVector;
-
-import com.google.flatbuffers.FlexBuffers.FlexBufferException;
-import com.google.flatbuffers.FlexBuffers.Reference;
-import com.google.flatbuffers.FlexBuffers.Vector;
-import com.google.flatbuffers.ArrayReadWriteBuf;
-import com.google.flatbuffers.FlexBuffers.KeyVector;
-
-import java.io.*;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.channels.FileChannel;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.Rule;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-
-/*
- * Copyright 2014 Google Inc. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@RunWith(JUnit4.class)
-public class JavaTest {
-
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
-
- @org.junit.Test
- public void mainTest() throws IOException {
- // First, let's test reading a FlatBuffer generated by C++ code:
- // This file was generated from monsterdata_test.json
- byte[] data = ByteStreams.toByteArray(
- JavaTest.class.getClassLoader().getResourceAsStream("monsterdata_test.mon"));
-
- // Now test it:
- ByteBuffer bb = ByteBuffer.wrap(data);
- TestBuffer(bb);
- TestPackUnpack(bb);
- }
-
- @org.junit.Test
- public void testFlatBufferBuilder() {
- // We use an initial size of 1 to exercise the reallocation algorithm,
- // normally a size larger than the typical FlatBuffer you generate would be
- // better for performance.
- FlatBufferBuilder fbb = new FlatBufferBuilder(1);
- TestBuilderBasics(fbb, true);
- TestBuilderBasics(fbb, false);
- TestExtendedBuffer(fbb.dataBuffer().asReadOnlyBuffer());
- }
-
- @org.junit.Test
- public void TestEnums() {
- assertThat(Color.name(Color.Red)).isEqualTo("Red");
- assertThat(Color.name(Color.Blue)).isEqualTo("Blue");
- assertThat(Any.name(Any.NONE)).isEqualTo("NONE");
- assertThat(Any.name(Any.Monster)).isEqualTo("Monster");
- }
-
- static void TestBuffer(ByteBuffer bb) {
- assertThat(Monster.MonsterBufferHasIdentifier(bb)).isEqualTo(true);
-
- Monster monster = Monster.getRootAsMonster(bb);
-
- assertThat(monster.hp()).isEqualTo((short) 80);
- // default
- assertThat(monster.mana()).isEqualTo((short) 150);
-
- assertThat(monster.name()).isEqualTo("MyMonster");
- // monster.friendly() // can't access, deprecated
-
- Vec3 pos = monster.pos();
- assertThat(pos.x()).isEqualTo(1.0f);
- assertThat(pos.y()).isEqualTo(2.0f);
- assertThat(pos.z()).isEqualTo(3.0f);
- assertThat(pos.test1()).isEqualTo(3.0);
- // issue: int != byte
- assertThat(pos.test2()).isEqualTo((int) Color.Green);
- Test t = pos.test3();
- assertThat(t.a()).isEqualTo((short) 5);
- assertThat(t.b()).isEqualTo((byte) 6);
-
- assertThat(monster.testType()).isEqualTo((byte) Any.Monster);
- Monster monster2 = new Monster();
- assertThat(monster.test(monster2) != null).isTrue();
- assertThat(monster2.name()).isEqualTo("Fred");
-
- assertThat(monster.inventoryLength()).isEqualTo(5);
- int invsum = 0;
- for (int i = 0; i < monster.inventoryLength(); i++)
- invsum += monster.inventory(i);
- assertThat(invsum).isEqualTo(10);
-
- // Method using a vector access object:
- ByteVector inventoryVector = monster.inventoryVector();
- assertThat(inventoryVector.length()).isEqualTo(5);
- invsum = 0;
- for (int i = 0; i < inventoryVector.length(); i++)
- invsum += inventoryVector.getAsUnsigned(i);
- assertThat(invsum).isEqualTo(10);
-
- // Alternative way of accessing a vector:
- ByteBuffer ibb = monster.inventoryAsByteBuffer();
- invsum = 0;
- while (ibb.position() < ibb.limit())
- invsum += ibb.get();
- assertThat(invsum).isEqualTo(10);
-
- Test test_0 = monster.test4(0);
- Test test_1 = monster.test4(1);
- assertThat(monster.test4Length()).isEqualTo(2);
- assertThat(test_0.a() + test_0.b() + test_1.a() + test_1.b()).isEqualTo((Integer) 100);
-
- Test.Vector test4Vector = monster.test4Vector();
- test_0 = test4Vector.get(0);
- test_1 = test4Vector.get(1);
- assertThat(test4Vector.length()).isEqualTo(2);
- assertThat(test_0.a() + test_0.b() + test_1.a() + test_1.b()).isEqualTo((Integer) 100);
-
- assertThat(monster.testarrayofstringLength()).isEqualTo(2);
- assertThat(monster.testarrayofstring(0)).isEqualTo("test1");
- assertThat(monster.testarrayofstring(1)).isEqualTo("test2");
-
- // Method using a vector access object:
- StringVector testarrayofstringVector = monster.testarrayofstringVector();
- assertThat(testarrayofstringVector.length()).isEqualTo(2);
- assertThat(testarrayofstringVector.get(0)).isEqualTo("test1");
- assertThat(testarrayofstringVector.get(1)).isEqualTo("test2");
-
- assertThat(monster.testbool()).isEqualTo(true);
- }
-
- // this method checks additional fields not present in the binary buffer read from file
- // these new tests are performed on top of the regular tests
- static void TestExtendedBuffer(ByteBuffer bb) {
- TestBuffer(bb);
-
- Monster monster = Monster.getRootAsMonster(bb);
-
- assertThat(monster.testhashu32Fnv1()).isEqualTo((Integer.MAX_VALUE + 1L));
- }
-
-
- @org.junit.Test public void TestNamespaceNesting() {
- // reference / manipulate these to verify compilation
- FlatBufferBuilder fbb = new FlatBufferBuilder(1);
-
- TableInNestedNS.startTableInNestedNS(fbb);
- TableInNestedNS.addFoo(fbb, 1234);
- int nestedTableOff = TableInNestedNS.endTableInNestedNS(fbb);
-
- TableInFirstNS.startTableInFirstNS(fbb);
- TableInFirstNS.addFooTable(fbb, nestedTableOff);
- int off = TableInFirstNS.endTableInFirstNS(fbb);
- }
-
- @org.junit.Test public void TestNestedFlatBuffer() {
- final String nestedMonsterName = "NestedMonsterName";
- final short nestedMonsterHp = 600;
- final short nestedMonsterMana = 1024;
-
- FlatBufferBuilder fbb1 = new FlatBufferBuilder(16);
- int str1 = fbb1.createString(nestedMonsterName);
- Monster.startMonster(fbb1);
- Monster.addName(fbb1, str1);
- Monster.addHp(fbb1, nestedMonsterHp);
- Monster.addMana(fbb1, nestedMonsterMana);
- int monster1 = Monster.endMonster(fbb1);
- Monster.finishMonsterBuffer(fbb1, monster1);
- byte[] fbb1Bytes = fbb1.sizedByteArray();
- fbb1 = null;
-
- FlatBufferBuilder fbb2 = new FlatBufferBuilder(16);
- int str2 = fbb2.createString("My Monster");
- int nestedBuffer = Monster.createTestnestedflatbufferVector(fbb2, fbb1Bytes);
- Monster.startMonster(fbb2);
- Monster.addName(fbb2, str2);
- Monster.addHp(fbb2, (short)50);
- Monster.addMana(fbb2, (short)32);
- Monster.addTestnestedflatbuffer(fbb2, nestedBuffer);
- int monster = Monster.endMonster(fbb2);
- Monster.finishMonsterBuffer(fbb2, monster);
-
- // Now test the data extracted from the nested buffer
- Monster mons = Monster.getRootAsMonster(fbb2.dataBuffer());
- Monster nestedMonster = mons.testnestedflatbufferAsMonster();
-
- assertThat(nestedMonsterMana).isEqualTo(nestedMonster.mana());
- assertThat(nestedMonsterHp).isEqualTo(nestedMonster.hp());
- assertThat(nestedMonsterName).isEqualTo(nestedMonster.name());
- }
-
- @org.junit.Test public void TestCreateByteVector() {
- FlatBufferBuilder fbb = new FlatBufferBuilder(16);
- int str = fbb.createString("MyMonster");
- byte[] inventory = new byte[] { 0, 1, 2, 3, 4 };
- int vec = fbb.createByteVector(inventory);
- Monster.startMonster(fbb);
- Monster.addInventory(fbb, vec);
- Monster.addName(fbb, str);
- int monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject = Monster.getRootAsMonster(fbb.dataBuffer());
-
- assertThat((Integer) monsterObject.inventory(1)).isEqualTo((int)inventory[1]);
- assertThat(monsterObject.inventoryLength()).isEqualTo(inventory.length);
- ByteVector inventoryVector = monsterObject.inventoryVector();
- assertThat(inventoryVector.getAsUnsigned(1)).isEqualTo((int)inventory[1]);
- assertThat(inventoryVector.length()).isEqualTo(inventory.length);
-
- assertThat(ByteBuffer.wrap(inventory)).isEqualTo(
- monsterObject.inventoryAsByteBuffer());
- }
-
- @org.junit.Test public void TestCreateUninitializedVector() {
- FlatBufferBuilder fbb = new FlatBufferBuilder(16);
- int str = fbb.createString("MyMonster");
- byte[] inventory = new byte[] { 0, 1, 2, 3, 4 };
- ByteBuffer bb = fbb.createUnintializedVector(1, inventory.length, 1);
- for (byte i:inventory) {
- bb.put(i);
- }
- int vec = fbb.endVector();
- Monster.startMonster(fbb);
- Monster.addInventory(fbb, vec);
- Monster.addName(fbb, str);
- int monster1 = Monster.endMonster(fbb);
- Monster.finishMonsterBuffer(fbb, monster1);
- Monster monsterObject = Monster.getRootAsMonster(fbb.dataBuffer());
-
- assertThat((Integer) monsterObject.inventory(1)).isEqualTo((int)inventory[1]);
- assertThat(monsterObject.inventoryLength()).isEqualTo(inventory.length);
- ByteVector inventoryVector = monsterObject.inventoryVector();
- assertThat(inventoryVector.getAsUnsigned(1)).isEqualTo((int)inventory[1]);
- assertThat(inventoryVector.length()).isEqualTo(inventory.length);
- assertThat(ByteBuffer.wrap(inventory)).isEqualTo(
- monsterObject.inventoryAsByteBuffer());
- }
-
- @org.junit.Test public void TestByteBufferFactory() throws IOException {
- File file = tempFolder.newFile("javatest.bin");
- final class MappedByteBufferFactory extends FlatBufferBuilder.ByteBufferFactory {
- @Override
- public ByteBuffer newByteBuffer(int capacity) {
- ByteBuffer bb;
- try {
- RandomAccessFile f = new RandomAccessFile(file, "rw");
- bb = f.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, capacity).order(ByteOrder.LITTLE_ENDIAN);
- f.close();
- } catch(Throwable e) {
- System.out.println("FlatBuffers test: couldn't map ByteBuffer to a file");
- bb = null;
- }
- return bb;
- }
- }
-
- FlatBufferBuilder fbb = new FlatBufferBuilder(1, new MappedByteBufferFactory());
-
- TestBuilderBasics(fbb, false);
- }
-
- @org.junit.Test public void TestSizedInputStream() {
- // Test on default FlatBufferBuilder that uses HeapByteBuffer
- FlatBufferBuilder fbb = new FlatBufferBuilder(1);
-
- TestBuilderBasics(fbb, false);
-
- InputStream in = fbb.sizedInputStream();
- byte[] array = fbb.sizedByteArray();
- int count = 0;
- int currentVal = 0;
-
- while (currentVal != -1 && count < array.length) {
- try {
- currentVal = in.read();
- } catch(java.io.IOException e) {
- System.out.println("FlatBuffers test: couldn't read from InputStream");
- return;
- }
- assertThat((byte)currentVal).isEqualTo(array[count]);
- count++;
- }
- assertThat(count).isEqualTo(array.length);
- }
-
- void TestBuilderBasics(FlatBufferBuilder fbb, boolean sizePrefix) {
- int[] names = {fbb.createString("Frodo"), fbb.createString("Barney"), fbb.createString("Wilma")};
- int[] off = new int[3];
- Monster.startMonster(fbb);
- Monster.addName(fbb, names[0]);
- off[0] = Monster.endMonster(fbb);
- Monster.startMonster(fbb);
- Monster.addName(fbb, names[1]);
- off[1] = Monster.endMonster(fbb);
- Monster.startMonster(fbb);
- Monster.addName(fbb, names[2]);
- off[2] = Monster.endMonster(fbb);
- int sortMons = fbb.createSortedVectorOfTables(new Monster(), off);
-
- // We set up the same values as monsterdata.json:
-
- int str = fbb.createString("MyMonster");
-
- int inv = Monster.createInventoryVector(fbb, new byte[] { 0, 1, 2, 3, 4 });
-
- int fred = fbb.createString("Fred");
- Monster.startMonster(fbb);
- Monster.addName(fbb, fred);
- int mon2 = Monster.endMonster(fbb);
-
- Monster.startTest4Vector(fbb, 2);
- Test.createTest(fbb, (short)10, (byte)20);
- Test.createTest(fbb, (short)30, (byte)40);
- int test4 = fbb.endVector();
-
- int testArrayOfString = Monster.createTestarrayofstringVector(fbb, new int[] {
- fbb.createString("test1"),
- fbb.createString("test2")
- });
-
- Monster.startMonster(fbb);
- Monster.addPos(fbb, Vec3.createVec3(fbb, 1.0f, 2.0f, 3.0f, 3.0,
- Color.Green, (short)5, (byte)6));
- Monster.addHp(fbb, (short)80);
- Monster.addName(fbb, str);
- Monster.addInventory(fbb, inv);
- Monster.addTestType(fbb, (byte)Any.Monster);
- Monster.addTest(fbb, mon2);
- Monster.addTest4(fbb, test4);
- Monster.addTestarrayofstring(fbb, testArrayOfString);
- Monster.addTestbool(fbb, true);
- Monster.addTesthashu32Fnv1(fbb, Integer.MAX_VALUE + 1L);
- Monster.addTestarrayoftables(fbb, sortMons);
- int mon = Monster.endMonster(fbb);
-
- if (sizePrefix) {
- Monster.finishSizePrefixedMonsterBuffer(fbb, mon);
- } else {
- Monster.finishMonsterBuffer(fbb, mon);
- }
-
- // Write the result to a file for debugging purposes:
- // Note that the binaries are not necessarily identical, since the JSON
- // parser may serialize in a slightly different order than the above
- // Java code. They are functionally equivalent though.
-
- try {
- String filename = "monsterdata_java_wire" + (sizePrefix ? "_sp" : "") + ".mon";
- FileChannel fc = new FileOutputStream(tempFolder.newFile(filename)).getChannel();
- fc.write(fbb.dataBuffer().duplicate());
- fc.close();
- } catch(java.io.IOException e) {
- System.out.println("FlatBuffers test: couldn't write file");
- return;
- }
-
- // Test it:
- ByteBuffer dataBuffer = fbb.dataBuffer();
- if (sizePrefix) {
- assertThat(ByteBufferUtil.getSizePrefix(dataBuffer) + SIZE_PREFIX_LENGTH).isEqualTo(
- dataBuffer.remaining());
- dataBuffer = ByteBufferUtil.removeSizePrefix(dataBuffer);
- }
- TestExtendedBuffer(dataBuffer);
-
- // Make sure it also works with read only ByteBuffers. This is slower,
- // since creating strings incurs an additional copy
- // (see Table.__string).
- TestExtendedBuffer(dataBuffer.asReadOnlyBuffer());
-
- //Attempt to mutate Monster fields and check whether the buffer has been mutated properly
- // revert to original values after testing
- Monster monster = Monster.getRootAsMonster(dataBuffer);
-
- // mana is optional and does not exist in the buffer so the mutation should fail
- // the mana field should retain its default value
- assertThat(monster.mutateMana((short)10)).isFalse();
- assertThat(monster.mana()).isEqualTo((short) 150);
-
- // Accessing a vector of sorted by the key tables
- assertThat(monster.testarrayoftables(0).name()).isEqualTo("Barney");
- assertThat(monster.testarrayoftables(1).name()).isEqualTo("Frodo");
- assertThat(monster.testarrayoftables(2).name()).isEqualTo("Wilma");
- Monster.Vector testarrayoftablesVector = monster.testarrayoftablesVector();
- assertThat(testarrayoftablesVector.get(0).name()).isEqualTo("Barney");
- assertThat(testarrayoftablesVector.get(1).name()).isEqualTo("Frodo");
- assertThat(testarrayoftablesVector.get(2).name()).isEqualTo("Wilma");
-
- // Example of searching for a table by the key
- assertThat(monster.testarrayoftablesByKey("Frodo").name()).isEqualTo("Frodo");
- assertThat(monster.testarrayoftablesByKey("Barney").name()).isEqualTo("Barney");
- assertThat(monster.testarrayoftablesByKey("Wilma").name()).isEqualTo("Wilma");
- assertThat(testarrayoftablesVector.getByKey("Frodo").name()).isEqualTo("Frodo");
- assertThat(testarrayoftablesVector.getByKey("Barney").name()).isEqualTo("Barney");
- assertThat(testarrayoftablesVector.getByKey("Wilma").name()).isEqualTo("Wilma");
-
- // testType is an existing field and mutating it should succeed
- assertThat(monster.testType()).isEqualTo((byte) Any.Monster);
-
- //mutate the inventory vector
- assertThat(monster.mutateInventory(0, 1)).isTrue();
- assertThat(monster.mutateInventory(1, 2)).isTrue();
- assertThat(monster.mutateInventory(2, 3)).isTrue();
- assertThat(monster.mutateInventory(3, 4)).isTrue();
- assertThat(monster.mutateInventory(4, 5)).isTrue();
-
- for (int i = 0; i < monster.inventoryLength(); i++) {
- assertThat((Integer) monster.inventory(i)).isEqualTo(i + 1);
- }
- ByteVector inventoryVector = monster.inventoryVector();
- for (int i = 0; i < inventoryVector.length(); i++) {
- assertThat((int)inventoryVector.get(i)).isEqualTo(i + 1);
- }
-
- //reverse mutation
- assertThat(monster.mutateInventory(0, 0)).isTrue();
- assertThat(monster.mutateInventory(1, 1)).isTrue();
- assertThat(monster.mutateInventory(2, 2)).isTrue();
- assertThat(monster.mutateInventory(3, 3)).isTrue();
- assertThat(monster.mutateInventory(4, 4)).isTrue();
-
- // get a struct field and edit one of its fields
- Vec3 pos = monster.pos();
- assertThat(pos.x()).isEqualTo(1.0f);
- pos.mutateX(55.0f);
- assertThat(pos.x()).isEqualTo(55.0f);
- pos.mutateX(1.0f);
- assertThat(pos.x()).isEqualTo(1.0f);
- }
-
- @org.junit.Test public void TestVectorOfUnions() {
- final FlatBufferBuilder fbb = new FlatBufferBuilder();
-
- final int swordAttackDamage = 1;
-
- final int[] characterVector = new int[] {
- Attacker.createAttacker(fbb, swordAttackDamage),
- };
-
- final byte[] characterTypeVector = new byte[]{
- Character.MuLan,
- };
-
- Movie.finishMovieBuffer(
- fbb,
- Movie.createMovie(
- fbb,
- (byte)0,
- (byte)0,
- Movie.createCharactersTypeVector(fbb, characterTypeVector),
- Movie.createCharactersVector(fbb, characterVector)
- )
- );
-
- final Movie movie = Movie.getRootAsMovie(fbb.dataBuffer());
- ByteVector charactersTypeByteVector = movie.charactersTypeVector();
- UnionVector charactersVector = movie.charactersVector();
-
- assertThat(movie.charactersTypeLength()).isEqualTo(characterTypeVector.length);
- assertThat(charactersTypeByteVector.length()).isEqualTo(characterTypeVector.length);
- assertThat(movie.charactersLength()).isEqualTo(characterVector.length);
- assertThat(charactersVector.length()).isEqualTo(characterVector.length);
-
- assertThat((Byte) movie.charactersType(0)).isEqualTo(characterTypeVector[0]);
- assertThat(charactersTypeByteVector.get(0)).isEqualTo(characterTypeVector[0]);
-
- assertThat(((Attacker)movie.characters(new Attacker(), 0)).swordAttackDamage()).isEqualTo(
- swordAttackDamage);
- }
-
- @org.junit.Test public void TestFixedLengthArrays() {
- FlatBufferBuilder builder = new FlatBufferBuilder(0);
-
- float a;
- int[] b = new int[15];
- byte c;
- int[][] d_a = new int[2][2];
- byte[] d_b = new byte[2];
- byte[][] d_c = new byte[2][2];
- long[][] d_d = new long[2][2];
- int e;
- long[] f = new long[2];
-
- a = 0.5f;
- for (int i = 0; i < 15; i++) b[i] = i;
- c = 1;
- d_a[0][0] = 1;
- d_a[0][1] = 2;
- d_a[1][0] = 3;
- d_a[1][1] = 4;
- d_b[0] = TestEnum.B;
- d_b[1] = TestEnum.C;
- d_c[0][0] = TestEnum.A;
- d_c[0][1] = TestEnum.B;
- d_c[1][0] = TestEnum.C;
- d_c[1][1] = TestEnum.B;
- d_d[0][0] = -1;
- d_d[0][1] = 1;
- d_d[1][0] = -2;
- d_d[1][1] = 2;
- e = 2;
- f[0] = -1;
- f[1] = 1;
-
- int arrayOffset = ArrayStruct.createArrayStruct(builder,
- a, b, c, d_a, d_b, d_c, d_d, e, f);
-
- // Create a table with the ArrayStruct.
- ArrayTable.startArrayTable(builder);
- ArrayTable.addA(builder, arrayOffset);
- int tableOffset = ArrayTable.endArrayTable(builder);
-
- ArrayTable.finishArrayTableBuffer(builder, tableOffset);
-
- ArrayTable table = ArrayTable.getRootAsArrayTable(builder.dataBuffer());
- NestedStruct nested = new NestedStruct();
-
- assertThat(table.a().a()).isEqualTo(0.5f);
- for (int i = 0; i < 15; i++)
- assertThat(table.a().b(i)).isEqualTo(i);
- assertThat(table.a().c()).isEqualTo((byte)1);
- assertThat(table.a().d(nested, 0).a(0)).isEqualTo(1);
- assertThat(table.a().d(nested, 0).a(1)).isEqualTo(2);
- assertThat(table.a().d(nested, 1).a(0)).isEqualTo(3);
- assertThat(table.a().d(nested, 1).a(1)).isEqualTo(4);
- assertThat(table.a().d(nested, 0).b()).isEqualTo(TestEnum.B);
- assertThat(table.a().d(nested, 1).b()).isEqualTo(TestEnum.C);
- assertThat(table.a().d(nested, 0).c(0)).isEqualTo(TestEnum.A);
- assertThat(table.a().d(nested, 0).c(1)).isEqualTo(TestEnum.B);
- assertThat(table.a().d(nested, 1).c(0)).isEqualTo(TestEnum.C);
- assertThat(table.a().d(nested, 1).c(1)).isEqualTo(TestEnum.B);
- assertThat(table.a().d(nested, 0).d(0)).isEqualTo((long)-1);
- assertThat(table.a().d(nested, 0).d(1)).isEqualTo((long)1);
- assertThat(table.a().d(nested, 1).d(0)).isEqualTo((long)-2);
- assertThat(table.a().d(nested, 1).d(1)).isEqualTo((long)2);
- assertThat(table.a().e()).isEqualTo(2);
- assertThat(table.a().f(0)).isEqualTo((long)-1);
- assertThat(table.a().f(1)).isEqualTo((long)1);
- }
-
- @org.junit.Test public void testFlexBuffersTest() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(512),
- FlexBuffersBuilder.BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
- testFlexBuffersTest(builder);
- int bufferLimit1 = ((ArrayReadWriteBuf) builder.getBuffer()).limit();
-
- // Repeat after clearing the builder to ensure the builder is reusable
- builder.clear();
- testFlexBuffersTest(builder);
- int bufferLimit2 = ((ArrayReadWriteBuf) builder.getBuffer()).limit();
- assertThat(bufferLimit1).isEqualTo(bufferLimit2);
- }
-
- public static void testFlexBuffersTest(FlexBuffersBuilder builder) {
- // Write the equivalent of:
- // { vec: [ -100, "Fred", 4.0, false ], bar: [ 1, 2, 3 ], bar3: [ 1, 2, 3 ],
- // foo: 100, bool: true, mymap: { foo: "Fred" } }
- // It's possible to do this without std::function support as well.
- int map1 = builder.startMap();
-
- int vec1 = builder.startVector();
- builder.putInt(-100);
- builder.putString("Fred");
- builder.putBlob(new byte[]{(byte) 77});
- builder.putBoolean(false);
- builder.putInt(Long.MAX_VALUE);
-
- int map2 = builder.startMap();
- builder.putInt("test", 200);
- builder.endMap(null, map2);
-
- builder.putFloat(150.9);
- builder.putFloat(150.9999998);
- builder.endVector("vec", vec1, false, false);
-
- vec1 = builder.startVector();
- builder.putInt(1);
- builder.putInt(2);
- builder.putInt(3);
- builder.endVector("bar", vec1, true, false);
-
- vec1 = builder.startVector();
- builder.putBoolean(true);
- builder.putBoolean(false);
- builder.putBoolean(true);
- builder.putBoolean(false);
- builder.endVector("bools", vec1, true, false);
-
- builder.putBoolean("bool", true);
- builder.putFloat("foo", 100);
-
- map2 = builder.startMap();
- builder.putString("bar", "Fred"); // Testing key and string reuse.
- builder.putInt("int", -120);
- builder.putFloat("float", -123.0f);
- builder.putBlob("blob", new byte[]{ 65, 67 });
- builder.endMap("mymap", map2);
-
- builder.endMap(null, map1);
- builder.finish();
-
- FlexBuffers.Map m = FlexBuffers.getRoot(builder.getBuffer()).asMap();
-
- assertThat(m.size()).isEqualTo(6);
-
- // test empty (an null)
- // empty if fail
- assertThat(m.get("no_key").asString()).isEqualTo("");
- // empty if fail
- assertThat(m.get("no_key").asMap()).isEqualTo(FlexBuffers.Map.empty());
- // empty if fail
- assertThat(m.get("no_key").asKey()).isEqualTo(FlexBuffers.Key.empty());
- // empty if fail
- assertThat(m.get("no_key").asVector()).isEqualTo(Vector.empty());
- // empty if fail
- assertThat(m.get("no_key").asBlob()).isEqualTo(FlexBuffers.Blob.empty());
- assert(m.get("no_key").asVector().isEmpty()); // empty if fail
-
- // testing "vec" field
- FlexBuffers.Vector vec = m.get("vec").asVector();
- assertThat(vec.size()).isEqualTo(8);
- assertThat(vec.get(0).asLong()).isEqualTo((long) -100);
- assertThat(vec.get(1).asString()).isEqualTo("Fred");
- assertThat(vec.get(2).isBlob()).isTrue();
- assertThat(vec.get(2).asBlob().size()).isEqualTo(1);
- assertThat(vec.get(2).asBlob().data().get(0)).isEqualTo((byte) 77);
- // Check if type is a bool
- assertThat(vec.get(3).isBoolean()).isTrue();
- // Check if value is false
- assertThat(vec.get(3).asBoolean()).isFalse();
- assertThat(vec.get(4).asLong()).isEqualTo(Long.MAX_VALUE);
- assertThat(vec.get(5).isMap()).isTrue();
- assertThat(vec.get(5).asMap().get("test").asInt()).isEqualTo(200);
- assertThat(Float.compare((float)vec.get(6).asFloat(), 150.9f)).isEqualTo(0);
- assertThat(Double.compare(vec.get(7).asFloat(), 150.9999998)).isEqualTo(0);
- //conversion fail returns 0 as C++
- assertThat((long)0).isEqualTo((long)vec.get(1).asLong());
-
- // bar vector
- FlexBuffers.Vector tvec = m.get("bar").asVector();
- assertThat(tvec.size()).isEqualTo(3);
- assertThat(tvec.get(0).asInt()).isEqualTo(1);
- assertThat(tvec.get(1).asInt()).isEqualTo(2);
- assertThat(tvec.get(2).asInt()).isEqualTo(3);
- assertThat(((FlexBuffers.TypedVector) tvec).getElemType()).isEqualTo(FlexBuffers.FBT_INT);
-
- // bools vector
- FlexBuffers.Vector bvec = m.get("bools").asVector();
- assertThat(bvec.size()).isEqualTo(4);
- assertThat(bvec.get(0).asBoolean()).isTrue();
- assertThat(bvec.get(1).asBoolean()).isFalse();
- assertThat(bvec.get(2).asBoolean()).isTrue();
- assertThat(bvec.get(3).asBoolean()).isFalse();
- assertThat(((FlexBuffers.TypedVector) bvec).getElemType()).isEqualTo(FlexBuffers.FBT_BOOL);
-
- assertThat((float)m.get("foo").asFloat()).isEqualTo((float) 100);
- assertThat(m.get("unknown").isNull()).isTrue();
-
- // mymap vector
- FlexBuffers.Map mymap = m.get("mymap").asMap();
- // These should be equal by pointer equality, since key and value are shared.
- assertThat(mymap.keys().get(0)).isEqualTo(m.keys().get(0));
- assertThat(mymap.keys().get(0).toString()).isEqualTo("bar");
- assertThat(mymap.values().get(0).asString()).isEqualTo(vec.get(1).asString());
- assertThat(mymap.get("int").asInt()).isEqualTo(-120);
- assertThat((float)mymap.get("float").asFloat()).isEqualTo(-123.0f);
- assertThat(Arrays.equals(mymap.get("blob").asBlob().getBytes(), new byte[]{ 65, 67 })).isEqualTo(
- true);
- assertThat(mymap.get("blob").asBlob().toString()).isEqualTo("AC");
- assertThat(mymap.get("blob").toString()).isEqualTo("\"AC\"");
- }
-
- @org.junit.Test public void testFlexBufferVectorStrings() {
- FlexBuffersBuilder builder = new FlexBuffersBuilder(ByteBuffer.allocate(10000000));
-
- int size = 3000;
- StringBuilder sb = new StringBuilder();
- for (int i=0; i< size; i++) {
- sb.append("a");
- }
-
- String text = sb.toString();
- assertThat(text.length()).isEqualTo(size);
-
- int pos = builder.startVector();
-
- for (int i=0; i {@code
- * Arrays.equals(bytes, new String(bytes, Internal.UTF_8).getBytes(Internal.UTF_8))
- * }
- *
- *