diff --git a/java/src/main/java/com/google/flatbuffers/reflection/AdvancedFeatures.java b/java/src/main/java/com/google/flatbuffers/reflection/AdvancedFeatures.java new file mode 100644 index 000000000..cf49086cd --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/AdvancedFeatures.java @@ -0,0 +1,16 @@ +// 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/java/src/main/java/com/google/flatbuffers/reflection/BaseType.java b/java/src/main/java/com/google/flatbuffers/reflection/BaseType.java new file mode 100644 index 000000000..fc4574a7c --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/BaseType.java @@ -0,0 +1,32 @@ +// 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 MaxBaseType = 18; + + public static final String[] names = { "None", "UType", "Bool", "Byte", "UByte", "Short", "UShort", "Int", "UInt", "Long", "ULong", "Float", "Double", "String", "Vector", "Obj", "Union", "Array", "MaxBaseType", }; + + public static String name(int e) { return names[e]; } +} + diff --git a/java/src/main/java/com/google/flatbuffers/reflection/Enum.java b/java/src/main/java/com/google/flatbuffers/reflection/Enum.java new file mode 100644 index 000000000..dde70405a --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/Enum.java @@ -0,0 +1,135 @@ +// 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_23_1_21(); } + 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/java/src/main/java/com/google/flatbuffers/reflection/EnumVal.java b/java/src/main/java/com/google/flatbuffers/reflection/EnumVal.java new file mode 100644 index 000000000..f832fcea8 --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/EnumVal.java @@ -0,0 +1,116 @@ +// 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_23_1_21(); } + 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/java/src/main/java/com/google/flatbuffers/reflection/Field.java b/java/src/main/java/com/google/flatbuffers/reflection/Field.java new file mode 100644 index 000000000..8107def6f --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/Field.java @@ -0,0 +1,148 @@ +// 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_23_1_21(); } + 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; } + + 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) { + builder.startTable(13); + 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.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(13); } + 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 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/java/src/main/java/com/google/flatbuffers/reflection/KeyValue.java b/java/src/main/java/com/google/flatbuffers/reflection/KeyValue.java new file mode 100644 index 000000000..7f1ab6ddf --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/KeyValue.java @@ -0,0 +1,88 @@ +// 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_23_1_21(); } + 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/java/src/main/java/com/google/flatbuffers/reflection/Object.java b/java/src/main/java/com/google/flatbuffers/reflection/Object.java new file mode 100644 index 000000000..22f68ca7c --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/Object.java @@ -0,0 +1,137 @@ +// 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_23_1_21(); } + 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/java/src/main/java/com/google/flatbuffers/reflection/RPCCall.java b/java/src/main/java/com/google/flatbuffers/reflection/RPCCall.java new file mode 100644 index 000000000..5ea5884b4 --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/RPCCall.java @@ -0,0 +1,115 @@ +// 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_23_1_21(); } + 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/java/src/main/java/com/google/flatbuffers/reflection/Schema.java b/java/src/main/java/com/google/flatbuffers/reflection/Schema.java new file mode 100644 index 000000000..13ba7b59b --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/Schema.java @@ -0,0 +1,127 @@ +// 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_23_1_21(); } + 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/java/src/main/java/com/google/flatbuffers/reflection/SchemaFile.java b/java/src/main/java/com/google/flatbuffers/reflection/SchemaFile.java new file mode 100644 index 000000000..b159848f1 --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/SchemaFile.java @@ -0,0 +1,102 @@ +// 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_23_1_21(); } + 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/java/src/main/java/com/google/flatbuffers/reflection/Service.java b/java/src/main/java/com/google/flatbuffers/reflection/Service.java new file mode 100644 index 000000000..0acabb4b7 --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/Service.java @@ -0,0 +1,124 @@ +// 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_23_1_21(); } + 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/java/src/main/java/com/google/flatbuffers/reflection/Type.java b/java/src/main/java/com/google/flatbuffers/reflection/Type.java new file mode 100644 index 000000000..b434da896 --- /dev/null +++ b/java/src/main/java/com/google/flatbuffers/reflection/Type.java @@ -0,0 +1,79 @@ +// 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_23_1_21(); } + 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/scripts/generate_code.py b/scripts/generate_code.py index 82981d418..49dfe34e1 100755 --- a/scripts/generate_code.py +++ b/scripts/generate_code.py @@ -507,6 +507,12 @@ if not args.skip_gen_reflection: # Python Reflection flatc_reflection(["-p"], "python/flatbuffers", "reflection") +# Java Reflection +flatc_reflection( + ["-j", "--java-package-prefix", "com.google.flatbuffers"], + "java/src/main/java", "com/google/flatbuffers/reflection" +) + # Annotation