Fixed missing code from @javax.annotation PR.

https://github.com/google/flatbuffers/pull/4986 missed part of the
implementation.

Change-Id: Ie41771eb018a550c289c77ebe9ef5c50d1ad6751
parent b6c3d7b8
...@@ -105,6 +105,8 @@ Additional options: ...@@ -105,6 +105,8 @@ Additional options:
output (by default the case for C++ and JS), all code will end up in output (by default the case for C++ and JS), all code will end up in
this one file. this one file.
- `--gen-generated`: Add @Generated annotation for Java
- `--no-js-exports` : Removes Node.js style export lines (useful for JS) - `--no-js-exports` : Removes Node.js style export lines (useful for JS)
- `--goog-js-export` : Uses goog.exportsSymbol and goog.exportsProperty - `--goog-js-export` : Uses goog.exportsSymbol and goog.exportsProperty
......
...@@ -391,6 +391,7 @@ struct IDLOptions { ...@@ -391,6 +391,7 @@ struct IDLOptions {
std::string cpp_object_api_pointer_type; std::string cpp_object_api_pointer_type;
std::string cpp_object_api_string_type; std::string cpp_object_api_string_type;
bool gen_nullable; bool gen_nullable;
bool gen_generated;
std::string object_prefix; std::string object_prefix;
std::string object_suffix; std::string object_suffix;
bool union_value_namespacing; bool union_value_namespacing;
...@@ -465,6 +466,7 @@ struct IDLOptions { ...@@ -465,6 +466,7 @@ struct IDLOptions {
gen_compare(false), gen_compare(false),
cpp_object_api_pointer_type("std::unique_ptr"), cpp_object_api_pointer_type("std::unique_ptr"),
gen_nullable(false), gen_nullable(false),
gen_generated(false),
object_suffix("T"), object_suffix("T"),
union_value_namespacing(true), union_value_namespacing(true),
allow_non_utf8(false), allow_non_utf8(false),
......
...@@ -93,6 +93,7 @@ std::string FlatCompiler::GetUsageString(const char *program_name) const { ...@@ -93,6 +93,7 @@ std::string FlatCompiler::GetUsageString(const char *program_name) const {
" --cpp-str-type T Set object API string type (default std::string)\n" " --cpp-str-type T Set object API string type (default std::string)\n"
" T::c_str() and T::length() must be supported\n" " T::c_str() and T::length() must be supported\n"
" --gen-nullable Add Clang _Nullable for C++ pointer. or @Nullable for Java\n" " --gen-nullable Add Clang _Nullable for C++ pointer. or @Nullable for Java\n"
" --gen-generated Add @Generated annotation for Java\n"
" --object-prefix Customise class prefix for C++ object-based API.\n" " --object-prefix Customise class prefix for C++ object-based API.\n"
" --object-suffix Customise class suffix for C++ object-based API.\n" " --object-suffix Customise class suffix for C++ object-based API.\n"
" Default value is \"T\"\n" " Default value is \"T\"\n"
...@@ -233,6 +234,8 @@ int FlatCompiler::Compile(int argc, const char **argv) { ...@@ -233,6 +234,8 @@ int FlatCompiler::Compile(int argc, const char **argv) {
opts.cpp_object_api_string_type = argv[argi]; opts.cpp_object_api_string_type = argv[argi];
} else if (arg == "--gen-nullable") { } else if (arg == "--gen-nullable") {
opts.gen_nullable = true; opts.gen_nullable = true;
} else if (arg == "--gen-generated") {
opts.gen_generated = true;
} else if (arg == "--object-prefix") { } else if (arg == "--object-prefix") {
if (++argi >= argc) Error("missing prefix following" + arg, true); if (++argi >= argc) Error("missing prefix following" + arg, true);
opts.object_prefix = argv[argi]; opts.object_prefix = argv[argi];
......
...@@ -221,7 +221,9 @@ class GeneralGenerator : public BaseGenerator { ...@@ -221,7 +221,9 @@ class GeneralGenerator : public BaseGenerator {
} }
code += lang_.class_annotation; code += lang_.class_annotation;
} }
if (parser_.opts.gen_generated) {
code += lang_.generated_type_annotation; code += lang_.generated_type_annotation;
}
code += classcode; code += classcode;
if (!namespace_name.empty()) code += lang_.namespace_end; if (!namespace_name.empty()) code += lang_.namespace_end;
auto filename = NamespaceDir(ns) + defname + lang_.file_extension; auto filename = NamespaceDir(ns) + defname + lang_.file_extension;
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class Ability extends Struct {
@javax.annotation.Generated(value="flatc")
public final class Ability extends Struct {
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
public Ability __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } public Ability __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
package MyGame.Example; package MyGame.Example;
@javax.annotation.Generated(value="flatc")
public final class Any { public final class Any {
private Any() { } private Any() { }
public static final byte NONE = 0; public static final byte NONE = 0;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
package MyGame.Example; package MyGame.Example;
@javax.annotation.Generated(value="flatc")
public final class AnyAmbiguousAliases { public final class AnyAmbiguousAliases {
private AnyAmbiguousAliases() { } private AnyAmbiguousAliases() { }
public static final byte NONE = 0; public static final byte NONE = 0;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
package MyGame.Example; package MyGame.Example;
@javax.annotation.Generated(value="flatc")
public final class AnyUniqueAliases { public final class AnyUniqueAliases {
private AnyUniqueAliases() { } private AnyUniqueAliases() { }
public static final byte NONE = 0; public static final byte NONE = 0;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
package MyGame.Example; package MyGame.Example;
@javax.annotation.Generated(value="flatc")
public final class Color { public final class Color {
private Color() { } private Color() { }
public static final byte Red = 1; public static final byte Red = 1;
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")/**
@javax.annotation.Generated(value="flatc")
/**
* an example documentation comment: monster object * an example documentation comment: monster object
*/ */
public final class Monster extends Table { public final class Monster extends Table {
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class Referrable extends Table {
@javax.annotation.Generated(value="flatc")
public final class Referrable extends Table {
public static Referrable getRootAsReferrable(ByteBuffer _bb) { return getRootAsReferrable(_bb, new Referrable()); } public static Referrable getRootAsReferrable(ByteBuffer _bb) { return getRootAsReferrable(_bb, new Referrable()); }
public static Referrable getRootAsReferrable(ByteBuffer _bb, Referrable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public static Referrable getRootAsReferrable(ByteBuffer _bb, Referrable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class Stat extends Table {
@javax.annotation.Generated(value="flatc")
public final class Stat extends Table {
public static Stat getRootAsStat(ByteBuffer _bb) { return getRootAsStat(_bb, new Stat()); } public static Stat getRootAsStat(ByteBuffer _bb) { return getRootAsStat(_bb, new Stat()); }
public static Stat getRootAsStat(ByteBuffer _bb, Stat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public static Stat getRootAsStat(ByteBuffer _bb, Stat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class Test extends Struct {
@javax.annotation.Generated(value="flatc")
public final class Test extends Struct {
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
public Test __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } public Test __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")final class TestSimpleTableWithEnum extends Table {
@javax.annotation.Generated(value="flatc")
final class TestSimpleTableWithEnum extends Table {
public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return getRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); } public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return getRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); }
public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class TypeAliases extends Table {
@javax.annotation.Generated(value="flatc")
public final class TypeAliases extends Table {
public static TypeAliases getRootAsTypeAliases(ByteBuffer _bb) { return getRootAsTypeAliases(_bb, new TypeAliases()); } public static TypeAliases getRootAsTypeAliases(ByteBuffer _bb) { return getRootAsTypeAliases(_bb, new TypeAliases()); }
public static TypeAliases getRootAsTypeAliases(ByteBuffer _bb, TypeAliases obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public static TypeAliases getRootAsTypeAliases(ByteBuffer _bb, TypeAliases obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class Vec3 extends Struct {
@javax.annotation.Generated(value="flatc")
public final class Vec3 extends Struct {
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
public Vec3 __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } public Vec3 __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class Monster extends Table {
@javax.annotation.Generated(value="flatc")
public final class Monster extends Table {
public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); } public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class InParentNamespace extends Table {
@javax.annotation.Generated(value="flatc")
public final class InParentNamespace extends Table {
public static InParentNamespace getRootAsInParentNamespace(ByteBuffer _bb) { return getRootAsInParentNamespace(_bb, new InParentNamespace()); } public static InParentNamespace getRootAsInParentNamespace(ByteBuffer _bb) { return getRootAsInParentNamespace(_bb, new InParentNamespace()); }
public static InParentNamespace getRootAsInParentNamespace(ByteBuffer _bb, InParentNamespace obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public static InParentNamespace getRootAsInParentNamespace(ByteBuffer _bb, InParentNamespace obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
package NamespaceA.NamespaceB; package NamespaceA.NamespaceB;
@javax.annotation.Generated(value="flatc")
public final class EnumInNestedNS { public final class EnumInNestedNS {
private EnumInNestedNS() { } private EnumInNestedNS() { }
public static final byte A = 0; public static final byte A = 0;
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class StructInNestedNS extends Struct {
@javax.annotation.Generated(value="flatc")
public final class StructInNestedNS extends Struct {
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
public StructInNestedNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } public StructInNestedNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class TableInNestedNS extends Table {
@javax.annotation.Generated(value="flatc")
public final class TableInNestedNS extends Table {
public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb) { return getRootAsTableInNestedNS(_bb, new TableInNestedNS()); } public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb) { return getRootAsTableInNestedNS(_bb, new TableInNestedNS()); }
public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class SecondTableInA extends Table {
@javax.annotation.Generated(value="flatc")
public final class SecondTableInA extends Table {
public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb) { return getRootAsSecondTableInA(_bb, new SecondTableInA()); } public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb) { return getRootAsSecondTableInA(_bb, new SecondTableInA()); }
public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class TableInFirstNS extends Table {
@javax.annotation.Generated(value="flatc")
public final class TableInFirstNS extends Table {
public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb) { return getRootAsTableInFirstNS(_bb, new TableInFirstNS()); } public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb) { return getRootAsTableInFirstNS(_bb, new TableInFirstNS()); }
public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb, TableInFirstNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb, TableInFirstNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
......
...@@ -7,9 +7,7 @@ import java.lang.*; ...@@ -7,9 +7,7 @@ import java.lang.*;
import java.util.*; import java.util.*;
import com.google.flatbuffers.*; import com.google.flatbuffers.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")public final class TableInC extends Table {
@javax.annotation.Generated(value="flatc")
public final class TableInC extends Table {
public static TableInC getRootAsTableInC(ByteBuffer _bb) { return getRootAsTableInC(_bb, new TableInC()); } public static TableInC getRootAsTableInC(ByteBuffer _bb) { return getRootAsTableInC(_bb, new TableInC()); }
public static TableInC getRootAsTableInC(ByteBuffer _bb, TableInC obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public static TableInC getRootAsTableInC(ByteBuffer _bb, TableInC obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _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