Commit e365c502 authored by Kulikov Alexey's avatar Kulikov Alexey Committed by Wouter van Oortmerssen

Java: Added access object for vector of struct and vector of tables. (#5233)

* Java: Added access object for vector of struct and vector of tables.

* Java: Workarounds removed when accessing the union vector.
parent 97f3aa91
/*
* Copyright 2019 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;
/// @cond FLATBUFFERS_INTERNAL
/**
* All vector access objects derive from this class, and add their own accessors.
*/
public class BaseVector {
/** Used to hold the vector data position. */
private int vector;
/** Used to hold the vector size. */
private int length;
/** Used to hold the vector element size in table. */
private int element_size;
/** The underlying ByteBuffer to hold the data of the vector. */
protected ByteBuffer bb;
/**
* Get the start data of a vector.
*
* @return Returns the start of the vector data.
*/
protected int __vector() {
return vector;
}
/**
* Gets the element position in vector's ByteBuffer.
*
* @param j An `int` index of element into a vector.
* @return Returns the position of the vector element in a ByteBuffer.
*/
protected int __element(int j) {
return vector + j * element_size;
}
/**
* Re-init the internal state with an external buffer {@code ByteBuffer}, an offset within and
* element size.
*
* This method exists primarily to allow recycling vector instances without risking memory leaks
* due to {@code ByteBuffer} references.
*/
protected void __reset(int _vector, int _element_size, ByteBuffer _bb) {
bb = _bb;
if (bb != null) {
vector = _vector;
length = bb.getInt(_vector - Constants.SIZEOF_INT);
element_size = _element_size;
} else {
vector = 0;
length = 0;
element_size = 0;
}
}
/**
* Resets the internal state with a null {@code ByteBuffer} and a zero position.
*
* This method exists primarily to allow recycling vector instances without risking memory leaks
* due to {@code ByteBuffer} references. The instance will be unusable until it is assigned
* again to a {@code ByteBuffer}.
*/
public void reset() {
__reset(0, 0, null);
}
/**
* Get the length of a vector.
*
* @return Returns the length of the vector.
*/
public int length() {
return length;
}
}
/// @endcond
/*
* Copyright 2019 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.Constants.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
/**
* Helper type for accessing vector of booleans.
*/
public final class BooleanVector extends BaseVector {
/**
* Assigns vector access object to vector data.
*
* @param _vector Start data of a vector.
* @param _bb Table's ByteBuffer.
* @return Returns current vector access object assigned to vector data whose offset is stored at
* `vector`.
*/
public BooleanVector __assign(int _vector, ByteBuffer _bb) {
__reset(_vector, Constants.SIZEOF_BYTE, _bb); return this;
}
/**
* Reads the boolean at the given index.
*
* @param j The index from which the boolean will be read.
* @return the boolean value at the given index.
*/
public boolean get(int j) {
return 0 != bb.get(__element(j));
}
}
/*
* Copyright 2019 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.Constants.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
/**
* Helper type for accessing vector of signed or unsigned 8-bit values.
*/
public final class ByteVector extends BaseVector {
/**
* Assigns vector access object to vector data.
*
* @param vector Start data of a vector.
* @param bb Table's ByteBuffer.
* @return Returns current vector access object assigned to vector data whose offset is stored at
* `vector`.
*/
public ByteVector __assign(int vector, ByteBuffer bb) {
__reset(vector, Constants.SIZEOF_BYTE, bb); return this;
}
/**
* Reads the byte at the given index.
*
* @param j The index from which the byte will be read.
* @return the 8-bit value at the given index.
*/
public byte get(int j) {
return bb.get(__element(j));
}
/**
* Reads the byte at the given index, zero-extends it to type int, and returns the result,
* which is therefore in the range 0 through 255.
*
* @param j The index from which the byte will be read.
* @return the unsigned 8-bit at the given index.
*/
public int getAsUnsigned(int j) {
return (int) get(j) & 0xFF;
}
}
/*
* Copyright 2019 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.Constants.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
/**
* Helper type for accessing vector of double values.
*/
public final class DoubleVector extends BaseVector {
/**
* Assigns vector access object to vector data.
*
* @param _vector Start data of a vector.
* @param _bb Table's ByteBuffer.
* @return Returns current vector access object assigned to vector data whose offset is stored at
* `vector`.
*/
public DoubleVector __assign(int _vector, ByteBuffer _bb) {
__reset(_vector, Constants.SIZEOF_DOUBLE, _bb); return this;
}
/**
* Reads the double value at the given index.
*
* @param j The index from which the double value will be read.
* @return the double value at the given index.
*/
public double get(int j) {
return bb.getDouble(__element(j));
}
}
/*
* Copyright 2019 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.Constants.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
/**
* Helper type for accessing vector of float values.
*/
public final class FloatVector extends BaseVector {
/**
* Assigns vector access object to vector data.
*
* @param _vector Start data of a vector.
* @param _bb Table's ByteBuffer.
* @return Returns current vector access object assigned to vector data whose offset is stored at
* `vector`.
*/
public FloatVector __assign(int _vector, ByteBuffer _bb) {
__reset(_vector, Constants.SIZEOF_FLOAT, _bb); return this;
}
/**
* Reads the float value at the given index.
*
* @param j The index from which the float value will be read.
* @return the float value at the given index.
*/
public float get(int j) {
return bb.getFloat(__element(j));
}
}
/*
* Copyright 2019 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.Constants.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
/**
* Helper type for accessing vector of signed or unsigned 32-bit values.
*/
public final class IntVector extends BaseVector {
/**
* Assigns vector access object to vector data.
*
* @param _vector Start data of a vector.
* @param _bb Table's ByteBuffer.
* @return Returns current vector access object assigned to vector data whose offset is stored at
* `vector`.
*/
public IntVector __assign(int _vector, ByteBuffer _bb) {
__reset(_vector, Constants.SIZEOF_INT, _bb); return this;
}
/**
* Reads the integer at the given index.
*
* @param j The index from which the integer will be read.
* @return the 32-bit value at the given index.
*/
public int get(int j) {
return bb.getInt(__element(j));
}
/**
* Reads the integer at the given index, zero-extends it to type long, and returns the result,
* which is therefore in the range 0 through 4294967295.
*
* @param j The index from which the integer will be read.
* @return the unsigned 32-bit at the given index.
*/
public long getAsUnsigned(int j) {
return (long) get(j) & 0xFFFFFFFFL;
}
}
/*
* Copyright 2019 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.Constants.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
/**
* Helper type for accessing vector of long values.
*/
public final class LongVector extends BaseVector {
/**
* Assigns vector access object to vector data.
*
* @param _vector Start data of a vector.
* @param _bb Table's ByteBuffer.
* @return Returns current vector access object assigned to vector data whose offset is stored at
* `vector`.
*/
public LongVector __assign(int _vector, ByteBuffer _bb) {
__reset(_vector, Constants.SIZEOF_LONG, _bb); return this;
}
/**
* Reads the long value at the given index.
*
* @param j The index from which the long value will be read.
* @return the signed 64-bit value at the given index.
*/
public long get(int j) {
return bb.getLong(__element(j));
}
}
/*
* Copyright 2019 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.Constants.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
/**
* Helper type for accessing vector of signed or unsigned 16-bit values.
*/
public final class ShortVector extends BaseVector {
/**
* Assigns vector access object to vector data.
*
* @param _vector Start data of a vector.
* @param _bb Table's ByteBuffer.
* @return Returns current vector access object assigned to vector data whose offset is stored at
* `vector`.
*/
public ShortVector __assign(int _vector, ByteBuffer _bb) {
__reset(_vector, Constants.SIZEOF_SHORT, _bb); return this;
}
/**
* Reads the short value at the given index.
*
* @param j The index from which the short value will be read.
* @return the 16-bit value at the given index.
*/
public short get(int j) {
return bb.getShort(__element(j));
}
/**
* Reads the short at the given index, zero-extends it to type int, and returns the result,
* which is therefore in the range 0 through 65535.
*
* @param j The index from which the short value will be read.
* @return the unsigned 16-bit at the given index.
*/
public int getAsUnsigned(int j) {
return (int) get(j) & 0xFFFF;
}
}
/*
* Copyright 2019 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.Constants.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
/**
* Helper type for accessing vector of String.
*/
public final class StringVector extends BaseVector {
private Utf8 utf8 = Utf8.getDefault();
/**
* Assigns vector access object to vector data.
*
* @param _vector Start data of a vector.
* @param _element_size Size of a vector element.
* @param _bb Table's ByteBuffer.
* @return Returns current vector access object assigned to vector data whose offset is stored at
* `vector`.
*/
public StringVector __assign(int _vector, int _element_size, ByteBuffer _bb) {
__reset(_vector, _element_size, _bb); return this;
}
/**
* Reads the String at the given index.
*
* @param j The index from which the String value will be read.
* @return the String at the given index.
*/
public String get(int j) {
return Table.__string(__element(j), bb, utf8);
}
}
......@@ -75,6 +75,13 @@ public class Table {
return offset + bb.getInt(offset);
}
/**
* Retrieve a relative offset.
*
* @param offset An `int` index into a ByteBuffer containing the relative offset.
* @param bb from which the relative offset will be retrieved.
* @return Returns the relative offset stored at `offset`.
*/
protected static int __indirect(int offset, ByteBuffer bb) {
return offset + bb.getInt(offset);
}
......@@ -91,6 +98,23 @@ public class Table {
* @return Returns a `String` from the data stored inside the FlatBuffer at `offset`.
*/
protected String __string(int offset) {
return __string(offset, bb, utf8);
}
/**
* Create a Java `String` from UTF-8 data stored inside the FlatBuffer.
*
* This allocates a new string and converts to wide chars upon each access,
* which is not very efficient. Instead, each FlatBuffer string also comes with an
* accessor based on __vector_as_bytebuffer below, which is much more efficient,
* assuming your Java program can handle UTF-8 data directly.
*
* @param offset An `int` index into the Table's ByteBuffer.
* @param bb Table ByteBuffer used to read a string at given offset.
* @param utf8 decoder that creates a Java `String` from UTF-8 characters.
* @return Returns a `String` from the data stored inside the FlatBuffer at `offset`.
*/
protected static String __string(int offset, ByteBuffer bb, Utf8 utf8) {
offset += bb.getInt(offset);
int length = bb.getInt(offset);
return utf8.decodeUtf8(bb, offset + SIZEOF_INT, length);
......@@ -169,11 +193,19 @@ public class Table {
* @return Returns the Table that points to the union at `offset`.
*/
protected Table __union(Table t, int offset) {
offset += bb_pos;
t.bb_pos = offset + bb.getInt(offset);
t.bb = bb;
t.vtable_start = t.bb_pos - bb.getInt(t.bb_pos);
t.vtable_size = bb.getShort(t.vtable_start);
return __union(t, offset, bb);
}
/**
* Initialize any Table-derived type to point to the union at the given `offset`.
*
* @param t A `Table`-derived type that should point to the union at `offset`.
* @param offset An `int` index into the Table's ByteBuffer.
* @param bb Table ByteBuffer used to initialize the object Table-derived type.
* @return Returns the Table that points to the union at `offset`.
*/
protected static Table __union(Table t, int offset, ByteBuffer bb) {
t.__reset(__indirect(offset, bb), bb);
return t;
}
......
/*
* Copyright 2019 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.Constants.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
/**
* Helper type for accessing vector of unions.
*/
public final class UnionVector extends BaseVector {
/**
* Assigns vector access object to vector data.
*
* @param _vector Start data of a vector.
* @param _element_size Size of a vector element.
* @param _bb Table's ByteBuffer.
* @return Returns current vector access object assigned to vector data whose offset is stored at
* `vector`.
*/
public UnionVector __assign(int _vector, int _element_size, ByteBuffer _bb) {
__reset(_vector, _element_size, _bb); return this;
}
/**
* Initialize any Table-derived type to point to the union at the given `index`.
*
* @param obj A `Table`-derived type that should point to the union at `index`.
* @param j An `int` index into the union vector.
* @return Returns the Table that points to the union at `index`.
*/
public Table get(Table obj, int j) {
return Table.__union(obj, __element(j), bb);
}
}
......@@ -152,9 +152,8 @@ namespace FlatBuffers
// Initialize any Table-derived type to point to the union at the given offset.
public T __union<T>(int offset) where T : struct, IFlatbufferObject
{
offset += bb_pos;
T t = new T();
t.__init(offset + bb.GetInt(offset), bb);
t.__init(__indirect(offset), bb);
return t;
}
......
......@@ -95,6 +95,12 @@ class SampleBinary {
assert monster.weapons(i).damage() == expectedWeaponDamages[i];
}
Weapon.Vector weaponsVector = monster.weaponsVector();
for (int i = 0; i < weaponsVector.length(); i++) {
assert weaponsVector.get(i).name().equals(expectedWeaponNames[i]);
assert weaponsVector.get(i).damage() == expectedWeaponDamages[i];
}
// Get and test the `equipped` FlatBuffer `union`.
assert monster.equippedType() == Equipment.Weapon;
Weapon equipped = (Weapon)monster.equipped(new Weapon());
......
......@@ -1125,8 +1125,6 @@ class GeneralGenerator : public BaseGenerator {
? index
: lang_.accessor_prefix + "__indirect(" + index + ")";
code += ", " + lang_.accessor_prefix + "bb";
} else if (vectortype.base_type == BASE_TYPE_UNION) {
code += index + " - " + lang_.accessor_prefix + "bb_pos";
} else {
code += index;
}
......@@ -1146,10 +1144,10 @@ class GeneralGenerator : public BaseGenerator {
if (lang_.language == IDLOptions::kCSharp) {
code += "() where TTable : struct, IFlatbufferObject";
code += offset_prefix + "(TTable?)" + getter;
code += "<TTable>(o) : null";
code += "<TTable>(o + " + lang_.accessor_prefix + "bb_pos) : null";
} else {
code += "(" + type_name + " obj)" + offset_prefix + getter;
code += "(obj, o) : null";
code += "(obj, o + " + lang_.accessor_prefix + "bb_pos) : null";
}
break;
default: FLATBUFFERS_ASSERT(0);
......@@ -1201,6 +1199,36 @@ class GeneralGenerator : public BaseGenerator {
}
}
}
// Generate the accessors for vector of structs with vector access object
if (lang_.language == IDLOptions::kJava &&
field.value.type.base_type == BASE_TYPE_VECTOR) {
std::string vector_type_name;
const auto &element_base_type = field.value.type.VectorType().base_type;
if (IsScalar(element_base_type)) {
vector_type_name = MakeCamel(type_name, true) + "Vector";
} else if (element_base_type == BASE_TYPE_STRING) {
vector_type_name = "StringVector";
} else if (element_base_type == BASE_TYPE_UNION) {
vector_type_name = "UnionVector";
} else {
vector_type_name = type_name + ".Vector";
}
auto vector_method_start =
GenNullableAnnotation(field.value.type) + " public " +
vector_type_name + optional + " " +
MakeCamel(field.name, lang_.first_camel_upper) + "Vector";
code += vector_method_start + "() { return ";
code += MakeCamel(field.name, lang_.first_camel_upper) + "Vector";
code += "(new " + vector_type_name + "()); }\n";
code += vector_method_start + "(" + vector_type_name + " obj)";
code += offset_prefix + conditional_cast + obj + ".__assign" + "(";
code += lang_.accessor_prefix + "__vector(o), ";
if (!IsScalar(element_base_type)) {
auto vectortype = field.value.type.VectorType();
code += NumToString(InlineSize(vectortype)) + ", ";
}
code += lang_.accessor_prefix + "bb) : null" + member_suffix + "}\n";
}
// Generate a ByteBuffer accessor for strings & vectors of scalars.
if ((field.value.type.base_type == BASE_TYPE_VECTOR &&
IsScalar(field.value.type.VectorType().base_type)) ||
......@@ -1627,11 +1655,79 @@ class GeneralGenerator : public BaseGenerator {
code += " return null;\n";
code += " }\n";
}
if (lang_.language == IDLOptions::kJava)
GenVectorAccessObject(struct_def, code_ptr);
code += "}";
// Java does not need the closing semi-colon on class definitions.
code += (lang_.language != IDLOptions::kJava) ? ";" : "";
code += "\n\n";
}
void GenVectorAccessObject(StructDef &struct_def,
std::string *code_ptr) const {
auto &code = *code_ptr;
// Generate a vector of structs accessor class.
code += "\n";
code += " ";
if (!struct_def.attributes.Lookup("private"))
code += "public ";
code += "static ";
code += lang_.unsubclassable_decl;
code += lang_.accessor_type + "Vector" + lang_.inheritance_marker;
code += "BaseVector" + lang_.open_curly;
// Generate the __assign method that sets the field in a pre-existing
// accessor object. This is to allow object reuse.
std::string method_indent = " ";
code += method_indent + "public Vector ";
code += "__assign(int _vector, int _element_size, ByteBuffer _bb) { ";
code += "__reset(_vector, _element_size, _bb); return this; }\n\n";
auto type_name = struct_def.name;
auto method_start =
method_indent + "public " + type_name + " " + FunctionStart('G') + "et";
// Generate the accessors that don't do object reuse.
code += method_start + "(int j) { return " + FunctionStart('G') + "et";
code += "(new " + type_name + "(), j); }\n";
code += method_start + "(" + type_name + " obj, int j) { ";
code += " return obj.__assign(";
auto index = lang_.accessor_prefix + "__element(j)";
code += struct_def.fixed
? index
: lang_.accessor_prefix + "__indirect(" + index + ", bb)";
code += ", " + lang_.accessor_prefix + "bb); }\n";
// See if we should generate a by-key accessor.
if (!struct_def.fixed) {
auto &fields = struct_def.fields.vec;
for (auto kit = fields.begin(); kit != fields.end(); ++kit) {
auto &key_field = **kit;
if (key_field.key) {
auto nullable_annotation =
parser_.opts.gen_nullable ? "@Nullable " : "";
code += method_indent + nullable_annotation;
code += "public " + type_name + lang_.optional_suffix + " ";
code += FunctionStart('G') + "et" + "ByKey(";
code += GenTypeNameDest(key_field.value.type) + " key) { ";
code += " return __lookup_by_key(null, ";
code += lang_.accessor_prefix + "__vector(), key, ";
code += lang_.accessor_prefix + "bb); ";
code += "}\n";
code += method_indent + nullable_annotation;
code += "public " + type_name + lang_.optional_suffix + " ";
code += FunctionStart('G') + "et" + "ByKey(";
code += type_name + lang_.optional_suffix + " obj, ";
code += GenTypeNameDest(key_field.value.type) + " key) { ";
code += " return __lookup_by_key(obj, ";
code += lang_.accessor_prefix + "__vector(), key, ";
code += lang_.accessor_prefix + "bb); ";
code += "}\n";
break;
}
}
}
code += " }\n";
}
const LanguageParameters &lang_;
// This tracks the current namespace used to determine if a type need to be
// prefixed by its namespace
......
......@@ -26,8 +26,11 @@ import NamespaceA.NamespaceB.*;
import com.google.flatbuffers.ByteBufferUtil;
import static com.google.flatbuffers.Constants.*;
import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.ByteVector;
import com.google.flatbuffers.FlexBuffersBuilder;
import com.google.flatbuffers.FlexBuffers;
import com.google.flatbuffers.StringVector;
import com.google.flatbuffers.UnionVector;
import MyGame.MonsterExtra;
class JavaTest {
......@@ -126,6 +129,14 @@ class JavaTest {
invsum += monster.inventory(i);
TestEq(invsum, 10);
// Method using a vector access object:
ByteVector inventoryVector = monster.inventoryVector();
TestEq(inventoryVector.length(), 5);
invsum = 0;
for (int i = 0; i < inventoryVector.length(); i++)
invsum += inventoryVector.getAsUnsigned(i);
TestEq(invsum, 10);
// Alternative way of accessing a vector:
ByteBuffer ibb = monster.inventoryAsByteBuffer();
invsum = 0;
......@@ -138,10 +149,22 @@ class JavaTest {
TestEq(monster.test4Length(), 2);
TestEq(test_0.a() + test_0.b() + test_1.a() + test_1.b(), 100);
Test.Vector test4Vector = monster.test4Vector();
test_0 = test4Vector.get(0);
test_1 = test4Vector.get(1);
TestEq(test4Vector.length(), 2);
TestEq(test_0.a() + test_0.b() + test_1.a() + test_1.b(), 100);
TestEq(monster.testarrayofstringLength(), 2);
TestEq(monster.testarrayofstring(0),"test1");
TestEq(monster.testarrayofstring(1),"test2");
// Method using a vector access object:
StringVector testarrayofstringVector = monster.testarrayofstringVector();
TestEq(testarrayofstringVector.length(), 2);
TestEq(testarrayofstringVector.get(0),"test1");
TestEq(testarrayofstringVector.get(1),"test2");
TestEq(monster.testbool(), true);
}
......@@ -218,6 +241,10 @@ class JavaTest {
TestEq(monsterObject.inventory(1), (int)inventory[1]);
TestEq(monsterObject.inventoryLength(), inventory.length);
ByteVector inventoryVector = monsterObject.inventoryVector();
TestEq(inventoryVector.getAsUnsigned(1), (int)inventory[1]);
TestEq(inventoryVector.length(), inventory.length);
TestEq(ByteBuffer.wrap(inventory), monsterObject.inventoryAsByteBuffer());
}
......@@ -239,6 +266,9 @@ class JavaTest {
TestEq(monsterObject.inventory(1), (int)inventory[1]);
TestEq(monsterObject.inventoryLength(), inventory.length);
ByteVector inventoryVector = monsterObject.inventoryVector();
TestEq(inventoryVector.getAsUnsigned(1), (int)inventory[1]);
TestEq(inventoryVector.length(), inventory.length);
TestEq(ByteBuffer.wrap(inventory), monsterObject.inventoryAsByteBuffer());
}
......@@ -388,11 +418,18 @@ class JavaTest {
TestEq(monster.testarrayoftables(0).name(), "Barney");
TestEq(monster.testarrayoftables(1).name(), "Frodo");
TestEq(monster.testarrayoftables(2).name(), "Wilma");
Monster.Vector testarrayoftablesVector = monster.testarrayoftablesVector();
TestEq(testarrayoftablesVector.get(0).name(), "Barney");
TestEq(testarrayoftablesVector.get(1).name(), "Frodo");
TestEq(testarrayoftablesVector.get(2).name(), "Wilma");
// Example of searching for a table by the key
TestEq(monster.testarrayoftablesByKey("Frodo").name(), "Frodo");
TestEq(monster.testarrayoftablesByKey("Barney").name(), "Barney");
TestEq(monster.testarrayoftablesByKey("Wilma").name(), "Wilma");
TestEq(testarrayoftablesVector.getByKey("Frodo").name(), "Frodo");
TestEq(testarrayoftablesVector.getByKey("Barney").name(), "Barney");
TestEq(testarrayoftablesVector.getByKey("Wilma").name(), "Wilma");
// testType is an existing field and mutating it should succeed
TestEq(monster.testType(), (byte)Any.Monster);
......@@ -411,6 +448,10 @@ class JavaTest {
for (int i = 0; i < monster.inventoryLength(); i++) {
TestEq(monster.inventory(i), i + 1);
}
ByteVector inventoryVector = monster.inventoryVector();
for (int i = 0; i < inventoryVector.length(); i++) {
TestEq((int)inventoryVector.get(i), i + 1);
}
//reverse mutation
TestEq(monster.mutateInventory(0, 0), true);
......@@ -453,11 +494,16 @@ class JavaTest {
);
final Movie movie = Movie.getRootAsMovie(fbb.dataBuffer());
ByteVector charactersTypeByteVector = movie.charactersTypeVector();
UnionVector charactersVector = movie.charactersVector();
TestEq(movie.charactersTypeLength(), characterTypeVector.length);
TestEq(charactersTypeByteVector.length(), characterTypeVector.length);
TestEq(movie.charactersLength(), characterVector.length);
TestEq(charactersVector.length(), characterVector.length);
TestEq(movie.charactersType(0), characterTypeVector[0]);
TestEq(charactersTypeByteVector.get(0), characterTypeVector[0]);
TestEq(((Attacker)movie.characters(new Attacker(), 0)).swordAttackDamage(), swordAttackDamage);
}
......
......@@ -23,5 +23,12 @@ public final class Ability extends Struct {
builder.putInt((int)id);
return builder.offset();
}
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 Ability get(int j) { return get(new Ability(), j); }
public Ability get(Ability obj, int j) { return obj.__assign(__element(j), bb); }
}
}
......@@ -53,5 +53,12 @@ public final class ArrayStruct extends Struct {
builder.putFloat(a);
return builder.offset();
}
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 ArrayStruct get(int j) { return get(new ArrayStruct(), j); }
public ArrayStruct get(ArrayStruct obj, int j) { return obj.__assign(__element(j), bb); }
}
}
......@@ -27,5 +27,12 @@ public final class ArrayTable extends Table {
}
public static void finishArrayTableBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset, "ARRT"); }
public static void finishSizePrefixedArrayTableBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset, "ARRT"); }
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 ArrayTable get(int j) { return get(new ArrayTable(), j); }
public ArrayTable get(ArrayTable obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -45,7 +45,7 @@ public struct Monster : IFlatbufferObject
public bool MutateColor(MyGame.Example.Color color) { int o = __p.__offset(16); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)color); return true; } else { return false; } }
public MyGame.Example.Any TestType { get { int o = __p.__offset(18); return o != 0 ? (MyGame.Example.Any)__p.bb.Get(o + __p.bb_pos) : MyGame.Example.Any.NONE; } }
public bool MutateTestType(MyGame.Example.Any test_type) { int o = __p.__offset(18); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)test_type); return true; } else { return false; } }
public TTable? Test<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(20); return o != 0 ? (TTable?)__p.__union<TTable>(o) : null; }
public TTable? Test<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(20); return o != 0 ? (TTable?)__p.__union<TTable>(o + __p.bb_pos) : null; }
public MyGame.Example.Test? Test4(int j) { int o = __p.__offset(22); return o != 0 ? (MyGame.Example.Test?)(new MyGame.Example.Test()).__assign(__p.__vector(o) + j * 4, __p.bb) : null; }
public int Test4Length { get { int o = __p.__offset(22); return o != 0 ? __p.__vector_len(o) : 0; } }
public string Testarrayofstring(int j) { int o = __p.__offset(24); return o != 0 ? __p.__string(__p.__vector(o) + j * 4) : null; }
......@@ -175,10 +175,10 @@ public struct Monster : IFlatbufferObject
public bool MutateVectorOfNonOwningReferences(int j, ulong vector_of_non_owning_references) { int o = __p.__offset(88); if (o != 0) { __p.bb.PutUlong(__p.__vector(o) + j * 8, vector_of_non_owning_references); return true; } else { return false; } }
public MyGame.Example.AnyUniqueAliases AnyUniqueType { get { int o = __p.__offset(90); return o != 0 ? (MyGame.Example.AnyUniqueAliases)__p.bb.Get(o + __p.bb_pos) : MyGame.Example.AnyUniqueAliases.NONE; } }
public bool MutateAnyUniqueType(MyGame.Example.AnyUniqueAliases any_unique_type) { int o = __p.__offset(90); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)any_unique_type); return true; } else { return false; } }
public TTable? AnyUnique<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(92); return o != 0 ? (TTable?)__p.__union<TTable>(o) : null; }
public TTable? AnyUnique<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(92); return o != 0 ? (TTable?)__p.__union<TTable>(o + __p.bb_pos) : null; }
public MyGame.Example.AnyAmbiguousAliases AnyAmbiguousType { get { int o = __p.__offset(94); return o != 0 ? (MyGame.Example.AnyAmbiguousAliases)__p.bb.Get(o + __p.bb_pos) : MyGame.Example.AnyAmbiguousAliases.NONE; } }
public bool MutateAnyAmbiguousType(MyGame.Example.AnyAmbiguousAliases any_ambiguous_type) { int o = __p.__offset(94); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)any_ambiguous_type); return true; } else { return false; } }
public TTable? AnyAmbiguous<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(96); return o != 0 ? (TTable?)__p.__union<TTable>(o) : null; }
public TTable? AnyAmbiguous<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(96); return o != 0 ? (TTable?)__p.__union<TTable>(o + __p.bb_pos) : null; }
public MyGame.Example.Color VectorOfEnums(int j) { int o = __p.__offset(98); return o != 0 ? (MyGame.Example.Color)__p.bb.Get(__p.__vector(o) + j * 1) : (MyGame.Example.Color)0; }
public int VectorOfEnumsLength { get { int o = __p.__offset(98); return o != 0 ? __p.__vector_len(o) : 0; } }
#if ENABLE_SPAN_T
......
......@@ -30,6 +30,8 @@ public final class Monster extends Table {
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 10, 1); }
public int inventory(int j) { int o = __offset(14); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
public int inventoryLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
public ByteVector inventoryVector() { return inventoryVector(new ByteVector()); }
public ByteVector inventoryVector(ByteVector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer inventoryAsByteBuffer() { return __vector_as_bytebuffer(14, 1); }
public ByteBuffer inventoryInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 14, 1); }
public boolean mutateInventory(int j, int inventory) { int o = __offset(14); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)inventory); return true; } else { return false; } }
......@@ -37,12 +39,16 @@ public final class Monster extends Table {
public boolean mutateColor(int color) { int o = __offset(16); if (o != 0) { bb.put(o + bb_pos, (byte)color); return true; } else { return false; } }
public byte testType() { int o = __offset(18); return o != 0 ? bb.get(o + bb_pos) : 0; }
public boolean mutateTestType(byte test_type) { int o = __offset(18); if (o != 0) { bb.put(o + bb_pos, test_type); return true; } else { return false; } }
public Table test(Table obj) { int o = __offset(20); return o != 0 ? __union(obj, o) : null; }
public Table test(Table obj) { int o = __offset(20); return o != 0 ? __union(obj, o + bb_pos) : null; }
public MyGame.Example.Test test4(int j) { return test4(new MyGame.Example.Test(), j); }
public MyGame.Example.Test test4(MyGame.Example.Test obj, int j) { int o = __offset(22); return o != 0 ? obj.__assign(__vector(o) + j * 4, bb) : null; }
public int test4Length() { int o = __offset(22); return o != 0 ? __vector_len(o) : 0; }
public MyGame.Example.Test.Vector test4Vector() { return test4Vector(new MyGame.Example.Test.Vector()); }
public MyGame.Example.Test.Vector test4Vector(MyGame.Example.Test.Vector obj) { int o = __offset(22); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public String testarrayofstring(int j) { int o = __offset(24); return o != 0 ? __string(__vector(o) + j * 4) : null; }
public int testarrayofstringLength() { int o = __offset(24); return o != 0 ? __vector_len(o) : 0; }
public StringVector testarrayofstringVector() { return testarrayofstringVector(new StringVector()); }
public StringVector testarrayofstringVector(StringVector obj) { int o = __offset(24); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
/**
* an example documentation comment: this will end up in the generated code
* multiline too
......@@ -52,10 +58,14 @@ public final class Monster extends Table {
public int testarrayoftablesLength() { int o = __offset(26); return o != 0 ? __vector_len(o) : 0; }
public MyGame.Example.Monster testarrayoftablesByKey(String key) { int o = __offset(26); return o != 0 ? MyGame.Example.Monster.__lookup_by_key(null, __vector(o), key, bb) : null; }
public MyGame.Example.Monster testarrayoftablesByKey(MyGame.Example.Monster obj, String key) { int o = __offset(26); return o != 0 ? MyGame.Example.Monster.__lookup_by_key(obj, __vector(o), key, bb) : null; }
public MyGame.Example.Monster.Vector testarrayoftablesVector() { return testarrayoftablesVector(new MyGame.Example.Monster.Vector()); }
public MyGame.Example.Monster.Vector testarrayoftablesVector(MyGame.Example.Monster.Vector obj) { int o = __offset(26); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public MyGame.Example.Monster enemy() { return enemy(new MyGame.Example.Monster()); }
public MyGame.Example.Monster enemy(MyGame.Example.Monster obj) { int o = __offset(28); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public int testnestedflatbuffer(int j) { int o = __offset(30); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
public int testnestedflatbufferLength() { int o = __offset(30); return o != 0 ? __vector_len(o) : 0; }
public ByteVector testnestedflatbufferVector() { return testnestedflatbufferVector(new ByteVector()); }
public ByteVector testnestedflatbufferVector(ByteVector obj) { int o = __offset(30); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer testnestedflatbufferAsByteBuffer() { return __vector_as_bytebuffer(30, 1); }
public ByteBuffer testnestedflatbufferInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 30, 1); }
public MyGame.Example.Monster testnestedflatbufferAsMonster() { return testnestedflatbufferAsMonster(new MyGame.Example.Monster()); }
......@@ -83,6 +93,8 @@ public final class Monster extends Table {
public boolean mutateTesthashu64Fnv1a(long testhashu64_fnv1a) { int o = __offset(50); if (o != 0) { bb.putLong(o + bb_pos, testhashu64_fnv1a); return true; } else { return false; } }
public boolean testarrayofbools(int j) { int o = __offset(52); return o != 0 ? 0!=bb.get(__vector(o) + j * 1) : false; }
public int testarrayofboolsLength() { int o = __offset(52); return o != 0 ? __vector_len(o) : 0; }
public BooleanVector testarrayofboolsVector() { return testarrayofboolsVector(new BooleanVector()); }
public BooleanVector testarrayofboolsVector(BooleanVector obj) { int o = __offset(52); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer testarrayofboolsAsByteBuffer() { return __vector_as_bytebuffer(52, 1); }
public ByteBuffer testarrayofboolsInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 52, 1); }
public boolean mutateTestarrayofbools(int j, boolean testarrayofbools) { int o = __offset(52); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)(testarrayofbools ? 1 : 0)); return true; } else { return false; } }
......@@ -94,24 +106,36 @@ public final class Monster extends Table {
public boolean mutateTestf3(float testf3) { int o = __offset(58); if (o != 0) { bb.putFloat(o + bb_pos, testf3); return true; } else { return false; } }
public String testarrayofstring2(int j) { int o = __offset(60); return o != 0 ? __string(__vector(o) + j * 4) : null; }
public int testarrayofstring2Length() { int o = __offset(60); return o != 0 ? __vector_len(o) : 0; }
public StringVector testarrayofstring2Vector() { return testarrayofstring2Vector(new StringVector()); }
public StringVector testarrayofstring2Vector(StringVector obj) { int o = __offset(60); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public MyGame.Example.Ability testarrayofsortedstruct(int j) { return testarrayofsortedstruct(new MyGame.Example.Ability(), j); }
public MyGame.Example.Ability testarrayofsortedstruct(MyGame.Example.Ability obj, int j) { int o = __offset(62); return o != 0 ? obj.__assign(__vector(o) + j * 8, bb) : null; }
public int testarrayofsortedstructLength() { int o = __offset(62); return o != 0 ? __vector_len(o) : 0; }
public MyGame.Example.Ability.Vector testarrayofsortedstructVector() { return testarrayofsortedstructVector(new MyGame.Example.Ability.Vector()); }
public MyGame.Example.Ability.Vector testarrayofsortedstructVector(MyGame.Example.Ability.Vector obj) { int o = __offset(62); return o != 0 ? obj.__assign(__vector(o), 8, bb) : null; }
public int flex(int j) { int o = __offset(64); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
public int flexLength() { int o = __offset(64); return o != 0 ? __vector_len(o) : 0; }
public ByteVector flexVector() { return flexVector(new ByteVector()); }
public ByteVector flexVector(ByteVector obj) { int o = __offset(64); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer flexAsByteBuffer() { return __vector_as_bytebuffer(64, 1); }
public ByteBuffer flexInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 64, 1); }
public boolean mutateFlex(int j, int flex) { int o = __offset(64); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)flex); return true; } else { return false; } }
public MyGame.Example.Test test5(int j) { return test5(new MyGame.Example.Test(), j); }
public MyGame.Example.Test test5(MyGame.Example.Test obj, int j) { int o = __offset(66); return o != 0 ? obj.__assign(__vector(o) + j * 4, bb) : null; }
public int test5Length() { int o = __offset(66); return o != 0 ? __vector_len(o) : 0; }
public MyGame.Example.Test.Vector test5Vector() { return test5Vector(new MyGame.Example.Test.Vector()); }
public MyGame.Example.Test.Vector test5Vector(MyGame.Example.Test.Vector obj) { int o = __offset(66); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public long vectorOfLongs(int j) { int o = __offset(68); return o != 0 ? bb.getLong(__vector(o) + j * 8) : 0; }
public int vectorOfLongsLength() { int o = __offset(68); return o != 0 ? __vector_len(o) : 0; }
public LongVector vectorOfLongsVector() { return vectorOfLongsVector(new LongVector()); }
public LongVector vectorOfLongsVector(LongVector obj) { int o = __offset(68); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer vectorOfLongsAsByteBuffer() { return __vector_as_bytebuffer(68, 8); }
public ByteBuffer vectorOfLongsInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 68, 8); }
public boolean mutateVectorOfLongs(int j, long vector_of_longs) { int o = __offset(68); if (o != 0) { bb.putLong(__vector(o) + j * 8, vector_of_longs); return true; } else { return false; } }
public double vectorOfDoubles(int j) { int o = __offset(70); return o != 0 ? bb.getDouble(__vector(o) + j * 8) : 0; }
public int vectorOfDoublesLength() { int o = __offset(70); return o != 0 ? __vector_len(o) : 0; }
public DoubleVector vectorOfDoublesVector() { return vectorOfDoublesVector(new DoubleVector()); }
public DoubleVector vectorOfDoublesVector(DoubleVector obj) { int o = __offset(70); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer vectorOfDoublesAsByteBuffer() { return __vector_as_bytebuffer(70, 8); }
public ByteBuffer vectorOfDoublesInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 70, 8); }
public boolean mutateVectorOfDoubles(int j, double vector_of_doubles) { int o = __offset(70); if (o != 0) { bb.putDouble(__vector(o) + j * 8, vector_of_doubles); return true; } else { return false; } }
......@@ -122,10 +146,14 @@ public final class Monster extends Table {
public int vectorOfReferrablesLength() { int o = __offset(74); return o != 0 ? __vector_len(o) : 0; }
public MyGame.Example.Referrable vectorOfReferrablesByKey(long key) { int o = __offset(74); return o != 0 ? MyGame.Example.Referrable.__lookup_by_key(null, __vector(o), key, bb) : null; }
public MyGame.Example.Referrable vectorOfReferrablesByKey(MyGame.Example.Referrable obj, long key) { int o = __offset(74); return o != 0 ? MyGame.Example.Referrable.__lookup_by_key(obj, __vector(o), key, bb) : null; }
public MyGame.Example.Referrable.Vector vectorOfReferrablesVector() { return vectorOfReferrablesVector(new MyGame.Example.Referrable.Vector()); }
public MyGame.Example.Referrable.Vector vectorOfReferrablesVector(MyGame.Example.Referrable.Vector obj) { int o = __offset(74); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public long singleWeakReference() { int o = __offset(76); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
public boolean mutateSingleWeakReference(long single_weak_reference) { int o = __offset(76); if (o != 0) { bb.putLong(o + bb_pos, single_weak_reference); return true; } else { return false; } }
public long vectorOfWeakReferences(int j) { int o = __offset(78); return o != 0 ? bb.getLong(__vector(o) + j * 8) : 0; }
public int vectorOfWeakReferencesLength() { int o = __offset(78); return o != 0 ? __vector_len(o) : 0; }
public LongVector vectorOfWeakReferencesVector() { return vectorOfWeakReferencesVector(new LongVector()); }
public LongVector vectorOfWeakReferencesVector(LongVector obj) { int o = __offset(78); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer vectorOfWeakReferencesAsByteBuffer() { return __vector_as_bytebuffer(78, 8); }
public ByteBuffer vectorOfWeakReferencesInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 78, 8); }
public boolean mutateVectorOfWeakReferences(int j, long vector_of_weak_references) { int o = __offset(78); if (o != 0) { bb.putLong(__vector(o) + j * 8, vector_of_weak_references); return true; } else { return false; } }
......@@ -134,10 +162,14 @@ public final class Monster extends Table {
public int vectorOfStrongReferrablesLength() { int o = __offset(80); return o != 0 ? __vector_len(o) : 0; }
public MyGame.Example.Referrable vectorOfStrongReferrablesByKey(long key) { int o = __offset(80); return o != 0 ? MyGame.Example.Referrable.__lookup_by_key(null, __vector(o), key, bb) : null; }
public MyGame.Example.Referrable vectorOfStrongReferrablesByKey(MyGame.Example.Referrable obj, long key) { int o = __offset(80); return o != 0 ? MyGame.Example.Referrable.__lookup_by_key(obj, __vector(o), key, bb) : null; }
public MyGame.Example.Referrable.Vector vectorOfStrongReferrablesVector() { return vectorOfStrongReferrablesVector(new MyGame.Example.Referrable.Vector()); }
public MyGame.Example.Referrable.Vector vectorOfStrongReferrablesVector(MyGame.Example.Referrable.Vector obj) { int o = __offset(80); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public long coOwningReference() { int o = __offset(82); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
public boolean mutateCoOwningReference(long co_owning_reference) { int o = __offset(82); if (o != 0) { bb.putLong(o + bb_pos, co_owning_reference); return true; } else { return false; } }
public long vectorOfCoOwningReferences(int j) { int o = __offset(84); return o != 0 ? bb.getLong(__vector(o) + j * 8) : 0; }
public int vectorOfCoOwningReferencesLength() { int o = __offset(84); return o != 0 ? __vector_len(o) : 0; }
public LongVector vectorOfCoOwningReferencesVector() { return vectorOfCoOwningReferencesVector(new LongVector()); }
public LongVector vectorOfCoOwningReferencesVector(LongVector obj) { int o = __offset(84); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer vectorOfCoOwningReferencesAsByteBuffer() { return __vector_as_bytebuffer(84, 8); }
public ByteBuffer vectorOfCoOwningReferencesInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 84, 8); }
public boolean mutateVectorOfCoOwningReferences(int j, long vector_of_co_owning_references) { int o = __offset(84); if (o != 0) { bb.putLong(__vector(o) + j * 8, vector_of_co_owning_references); return true; } else { return false; } }
......@@ -145,17 +177,21 @@ public final class Monster extends Table {
public boolean mutateNonOwningReference(long non_owning_reference) { int o = __offset(86); if (o != 0) { bb.putLong(o + bb_pos, non_owning_reference); return true; } else { return false; } }
public long vectorOfNonOwningReferences(int j) { int o = __offset(88); return o != 0 ? bb.getLong(__vector(o) + j * 8) : 0; }
public int vectorOfNonOwningReferencesLength() { int o = __offset(88); return o != 0 ? __vector_len(o) : 0; }
public LongVector vectorOfNonOwningReferencesVector() { return vectorOfNonOwningReferencesVector(new LongVector()); }
public LongVector vectorOfNonOwningReferencesVector(LongVector obj) { int o = __offset(88); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer vectorOfNonOwningReferencesAsByteBuffer() { return __vector_as_bytebuffer(88, 8); }
public ByteBuffer vectorOfNonOwningReferencesInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 88, 8); }
public boolean mutateVectorOfNonOwningReferences(int j, long vector_of_non_owning_references) { int o = __offset(88); if (o != 0) { bb.putLong(__vector(o) + j * 8, vector_of_non_owning_references); return true; } else { return false; } }
public byte anyUniqueType() { int o = __offset(90); return o != 0 ? bb.get(o + bb_pos) : 0; }
public boolean mutateAnyUniqueType(byte any_unique_type) { int o = __offset(90); if (o != 0) { bb.put(o + bb_pos, any_unique_type); return true; } else { return false; } }
public Table anyUnique(Table obj) { int o = __offset(92); return o != 0 ? __union(obj, o) : null; }
public Table anyUnique(Table obj) { int o = __offset(92); return o != 0 ? __union(obj, o + bb_pos) : null; }
public byte anyAmbiguousType() { int o = __offset(94); return o != 0 ? bb.get(o + bb_pos) : 0; }
public boolean mutateAnyAmbiguousType(byte any_ambiguous_type) { int o = __offset(94); if (o != 0) { bb.put(o + bb_pos, any_ambiguous_type); return true; } else { return false; } }
public Table anyAmbiguous(Table obj) { int o = __offset(96); return o != 0 ? __union(obj, o) : null; }
public Table anyAmbiguous(Table obj) { int o = __offset(96); return o != 0 ? __union(obj, o + bb_pos) : null; }
public int vectorOfEnums(int j) { int o = __offset(98); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
public int vectorOfEnumsLength() { int o = __offset(98); return o != 0 ? __vector_len(o) : 0; }
public ByteVector vectorOfEnumsVector() { return vectorOfEnumsVector(new ByteVector()); }
public ByteVector vectorOfEnumsVector(ByteVector obj) { int o = __offset(98); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer vectorOfEnumsAsByteBuffer() { return __vector_as_bytebuffer(98, 1); }
public ByteBuffer vectorOfEnumsInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 98, 1); }
public boolean mutateVectorOfEnums(int j, int vector_of_enums) { int o = __offset(98); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)vector_of_enums); return true; } else { return false; } }
......@@ -275,5 +311,14 @@ public final class Monster extends Table {
}
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 Monster get(int j) { return get(new Monster(), j); }
public Monster get(Monster obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
public Monster getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
public Monster getByKey(Monster obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
}
}
......@@ -36,5 +36,12 @@ public final class NestedStruct extends Struct {
}
return builder.offset();
}
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 NestedStruct get(int j) { return get(new NestedStruct(), j); }
public NestedStruct get(NestedStruct obj, int j) { return obj.__assign(__element(j), bb); }
}
}
......@@ -59,5 +59,14 @@ public final class Referrable extends Table {
}
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 Referrable get(int j) { return get(new Referrable(), j); }
public Referrable get(Referrable obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
public Referrable getByKey(long key) { return __lookup_by_key(null, __vector(), key, bb); }
public Referrable getByKey(Referrable obj, long key) { return __lookup_by_key(obj, __vector(), key, bb); }
}
}
......@@ -42,5 +42,12 @@ public final class Stat extends Table {
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 Stat get(int j) { return get(new Stat(), j); }
public Stat get(Stat obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -24,5 +24,12 @@ public final class Test extends Struct {
builder.putShort(a);
return builder.offset();
}
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 Test get(int j) { return get(new Test(), j); }
public Test get(Test obj, int j) { return obj.__assign(__element(j), bb); }
}
}
......@@ -31,5 +31,12 @@ final class TestSimpleTableWithEnum extends Table {
int o = builder.endTable();
return o;
}
static final class Vector extends BaseVector {
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
public TestSimpleTableWithEnum get(int j) { return get(new TestSimpleTableWithEnum(), j); }
public TestSimpleTableWithEnum get(TestSimpleTableWithEnum obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -37,11 +37,15 @@ public final class TypeAliases extends Table {
public boolean mutateF64(double f64) { int o = __offset(22); if (o != 0) { bb.putDouble(o + bb_pos, f64); return true; } else { return false; } }
public byte v8(int j) { int o = __offset(24); return o != 0 ? bb.get(__vector(o) + j * 1) : 0; }
public int v8Length() { int o = __offset(24); return o != 0 ? __vector_len(o) : 0; }
public ByteVector v8Vector() { return v8Vector(new ByteVector()); }
public ByteVector v8Vector(ByteVector obj) { int o = __offset(24); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer v8AsByteBuffer() { return __vector_as_bytebuffer(24, 1); }
public ByteBuffer v8InByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 24, 1); }
public boolean mutateV8(int j, byte v8) { int o = __offset(24); if (o != 0) { bb.put(__vector(o) + j * 1, v8); return true; } else { return false; } }
public double vf64(int j) { int o = __offset(26); return o != 0 ? bb.getDouble(__vector(o) + j * 8) : 0; }
public int vf64Length() { int o = __offset(26); return o != 0 ? __vector_len(o) : 0; }
public DoubleVector vf64Vector() { return vf64Vector(new DoubleVector()); }
public DoubleVector vf64Vector(DoubleVector obj) { int o = __offset(26); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer vf64AsByteBuffer() { return __vector_as_bytebuffer(26, 8); }
public ByteBuffer vf64InByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 26, 8); }
public boolean mutateVf64(int j, double vf64) { int o = __offset(26); if (o != 0) { bb.putDouble(__vector(o) + j * 8, vf64); return true; } else { return false; } }
......@@ -96,5 +100,12 @@ public final class TypeAliases extends Table {
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 TypeAliases get(int j) { return get(new TypeAliases(), j); }
public TypeAliases get(TypeAliases obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -41,5 +41,12 @@ public final class Vec3 extends Struct {
builder.putFloat(x);
return builder.offset();
}
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 Vec3 get(int j) { return get(new Vec3(), j); }
public Vec3 get(Vec3 obj, int j) { return obj.__assign(__element(j), bb); }
}
}
......@@ -21,5 +21,12 @@ public final class Monster extends Table {
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 Monster get(int j) { return get(new Monster(), j); }
public Monster get(Monster obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -21,5 +21,12 @@ public final class InParentNamespace extends Table {
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 InParentNamespace get(int j) { return get(new InParentNamespace(), j); }
public InParentNamespace get(InParentNamespace obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -34,11 +34,15 @@ public final class MonsterExtra extends Table {
public boolean mutateF3(float f3) { int o = __offset(18); if (o != 0) { bb.putFloat(o + bb_pos, f3); return true; } else { return false; } }
public double dvec(int j) { int o = __offset(20); return o != 0 ? bb.getDouble(__vector(o) + j * 8) : 0; }
public int dvecLength() { int o = __offset(20); return o != 0 ? __vector_len(o) : 0; }
public DoubleVector dvecVector() { return dvecVector(new DoubleVector()); }
public DoubleVector dvecVector(DoubleVector obj) { int o = __offset(20); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer dvecAsByteBuffer() { return __vector_as_bytebuffer(20, 8); }
public ByteBuffer dvecInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 20, 8); }
public boolean mutateDvec(int j, double dvec) { int o = __offset(20); if (o != 0) { bb.putDouble(__vector(o) + j * 8, dvec); return true; } else { return false; } }
public float fvec(int j) { int o = __offset(22); return o != 0 ? bb.getFloat(__vector(o) + j * 4) : 0; }
public int fvecLength() { int o = __offset(22); return o != 0 ? __vector_len(o) : 0; }
public FloatVector fvecVector() { return fvecVector(new FloatVector()); }
public FloatVector fvecVector(FloatVector obj) { int o = __offset(22); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer fvecAsByteBuffer() { return __vector_as_bytebuffer(22, 4); }
public ByteBuffer fvecInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 22, 4); }
public boolean mutateFvec(int j, float fvec) { int o = __offset(22); if (o != 0) { bb.putFloat(__vector(o) + j * 4, fvec); return true; } else { return false; } }
......@@ -89,5 +93,12 @@ public final class MonsterExtra extends Table {
}
public static void finishMonsterExtraBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset, "MONE"); }
public static void finishSizePrefixedMonsterExtraBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset, "MONE"); }
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 MonsterExtra get(int j) { return get(new MonsterExtra(), j); }
public MonsterExtra get(MonsterExtra obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -23,5 +23,12 @@ public final class StructInNestedNS extends Struct {
builder.putInt(a);
return builder.offset();
}
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 StructInNestedNS get(int j) { return get(new StructInNestedNS(), j); }
public StructInNestedNS get(StructInNestedNS obj, int j) { return obj.__assign(__element(j), bb); }
}
}
......@@ -31,5 +31,12 @@ public final class TableInNestedNS extends Table {
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 TableInNestedNS get(int j) { return get(new TableInNestedNS(), j); }
public TableInNestedNS get(TableInNestedNS obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -31,5 +31,12 @@ public final class SecondTableInA extends Table {
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 SecondTableInA get(int j) { return get(new SecondTableInA(), j); }
public SecondTableInA get(SecondTableInA obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -30,5 +30,12 @@ public final class TableInFirstNS extends Table {
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 TableInFirstNS get(int j) { return get(new TableInFirstNS(), j); }
public TableInFirstNS get(TableInFirstNS obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -36,5 +36,12 @@ public final class TableInC extends Table {
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 TableInC get(int j) { return get(new TableInC(), j); }
public TableInC get(TableInC obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -29,5 +29,12 @@ public final class Attacker extends Table {
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 Attacker get(int j) { return get(new Attacker(), j); }
public Attacker get(Attacker obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -18,5 +18,12 @@ public final class BookReader extends Struct {
builder.putInt(booksRead);
return builder.offset();
}
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 BookReader get(int j) { return get(new BookReader(), j); }
public BookReader get(BookReader obj, int j) { return obj.__assign(__element(j), bb); }
}
}
......@@ -18,7 +18,7 @@ public struct Movie : IFlatbufferObject
public Character MainCharacterType { get { int o = __p.__offset(4); return o != 0 ? (Character)__p.bb.Get(o + __p.bb_pos) : Character.NONE; } }
public bool MutateMainCharacterType(Character main_character_type) { int o = __p.__offset(4); if (o != 0) { __p.bb.Put(o + __p.bb_pos, (byte)main_character_type); return true; } else { return false; } }
public TTable? MainCharacter<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(6); return o != 0 ? (TTable?)__p.__union<TTable>(o) : null; }
public TTable? MainCharacter<TTable>() where TTable : struct, IFlatbufferObject { int o = __p.__offset(6); return o != 0 ? (TTable?)__p.__union<TTable>(o + __p.bb_pos) : null; }
public Character CharactersType(int j) { int o = __p.__offset(8); return o != 0 ? (Character)__p.bb.Get(__p.__vector(o) + j * 1) : (Character)0; }
public int CharactersTypeLength { get { int o = __p.__offset(8); return o != 0 ? __p.__vector_len(o) : 0; } }
#if ENABLE_SPAN_T
......@@ -28,7 +28,7 @@ public struct Movie : IFlatbufferObject
#endif
public Character[] GetCharactersTypeArray() { int o = __p.__offset(8); if (o == 0) return null; int p = __p.__vector(o); int l = __p.__vector_len(o); Character[] a = new Character[l]; for (int i = 0; i < l; i++) { a[i] = (Character)__p.bb.Get(p + i * 1); } return a; }
public bool MutateCharactersType(int j, Character characters_type) { int o = __p.__offset(8); if (o != 0) { __p.bb.Put(__p.__vector(o) + j * 1, (byte)characters_type); return true; } else { return false; } }
public TTable? Characters<TTable>(int j) where TTable : struct, IFlatbufferObject { int o = __p.__offset(10); return o != 0 ? (TTable?)__p.__union<TTable>(__p.__vector(o) + j * 4 - __p.bb_pos) : null; }
public TTable? Characters<TTable>(int j) where TTable : struct, IFlatbufferObject { int o = __p.__offset(10); return o != 0 ? (TTable?)__p.__union<TTable>(__p.__vector(o) + j * 4) : null; }
public int CharactersLength { get { int o = __p.__offset(10); return o != 0 ? __p.__vector_len(o) : 0; } }
public static Offset<Movie> CreateMovie(FlatBufferBuilder builder,
......
......@@ -16,14 +16,18 @@ public final class Movie extends Table {
public byte mainCharacterType() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; }
public boolean mutateMainCharacterType(byte main_character_type) { int o = __offset(4); if (o != 0) { bb.put(o + bb_pos, main_character_type); return true; } else { return false; } }
public Table mainCharacter(Table obj) { int o = __offset(6); return o != 0 ? __union(obj, o) : null; }
public Table mainCharacter(Table obj) { int o = __offset(6); return o != 0 ? __union(obj, o + bb_pos) : null; }
public byte charactersType(int j) { int o = __offset(8); return o != 0 ? bb.get(__vector(o) + j * 1) : 0; }
public int charactersTypeLength() { int o = __offset(8); return o != 0 ? __vector_len(o) : 0; }
public ByteVector charactersTypeVector() { return charactersTypeVector(new ByteVector()); }
public ByteVector charactersTypeVector(ByteVector obj) { int o = __offset(8); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
public ByteBuffer charactersTypeAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
public ByteBuffer charactersTypeInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); }
public boolean mutateCharactersType(int j, byte characters_type) { int o = __offset(8); if (o != 0) { bb.put(__vector(o) + j * 1, characters_type); return true; } else { return false; } }
public Table characters(Table obj, int j) { int o = __offset(10); return o != 0 ? __union(obj, __vector(o) + j * 4 - bb_pos) : null; }
public Table characters(Table obj, int j) { int o = __offset(10); return o != 0 ? __union(obj, __vector(o) + j * 4) : null; }
public int charactersLength() { int o = __offset(10); return o != 0 ? __vector_len(o) : 0; }
public UnionVector charactersVector() { return charactersVector(new UnionVector()); }
public UnionVector charactersVector(UnionVector obj) { int o = __offset(10); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public static int createMovie(FlatBufferBuilder builder,
byte main_character_type,
......@@ -53,5 +57,12 @@ public final class Movie extends Table {
}
public static void finishMovieBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset, "MOVI"); }
public static void finishSizePrefixedMovieBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset, "MOVI"); }
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 Movie get(int j) { return get(new Movie(), j); }
public Movie get(Movie obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
......@@ -18,5 +18,12 @@ public final class Rapunzel extends Struct {
builder.putInt(hairLength);
return builder.offset();
}
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 Rapunzel get(int j) { return get(new Rapunzel(), j); }
public Rapunzel get(Rapunzel obj, int j) { return obj.__assign(__element(j), bb); }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment