// Don't output empty comment blocks with 0 lines of comment content.
return;
}
-
+
std::string &code = *code_ptr;
if (config != nullptr && config->first_line != nullptr) {
code += std::string(prefix) + std::string(config->first_line) + "\n";
const char *bool_type;
const char *open_curly;
const char *const_decl;
+ const char *unsubclassable_decl;
const char *inheritance_marker;
const char *namespace_ident;
const char *namespace_begin;
"boolean ",
" {\n",
" final ",
+ "final ",
" extends ",
"package ",
";",
"bool ",
"\n{\n",
" readonly ",
+ "sealed ",
" : ",
"namespace ",
"\n{",
"bool ",
"\n{\n",
"const ",
+ " ",
"",
"package ",
"",
// to map directly to how they're used in C/C++ and file formats.
// That, and Java Enums are expensive, and not universally liked.
GenComment(enum_def.doc_comment, code_ptr, &lang.comment_config);
- code += "public class " + enum_def.name + lang.open_curly;
+ code += std::string("public ") + lang.unsubclassable_decl;
+ code += "class " + enum_def.name + lang.open_curly;
+ code += " private " + enum_def.name + "() { }\n";
for (auto it = enum_def.vals.vec.begin();
it != enum_def.vals.vec.end();
++it) {
// int o = __offset(offset); return o != 0 ? bb.getType(o + i) : default;
// }
GenComment(struct_def.doc_comment, code_ptr, &lang.comment_config);
- code += "public class " + struct_def.name + lang.inheritance_marker;
+ code += std::string("public ") + lang.unsubclassable_decl;
+ code += "class " + struct_def.name + lang.inheritance_marker;
code += struct_def.fixed ? "Struct" : "Table";
code += " {\n";
if (!struct_def.fixed) {
namespace MyGame.Example
{
-public class Any
+public sealed class Any
{
+ private Any() { }
public static readonly byte NONE = 0;
public static readonly byte Monster = 1;
package MyGame.Example;
-public class Any {
+public final class Any {
+ private Any() { }
public static final byte NONE = 0;
public static final byte Monster = 1;
namespace MyGame.Example
{
-public class Color
+public sealed class Color
{
+ private Color() { }
public static readonly sbyte Red = 1;
public static readonly sbyte Green = 2;
public static readonly sbyte Blue = 8;
package MyGame.Example;
-public class Color {
+public final class Color {
+ private Color() { }
public static final byte Red = 1;
public static final byte Green = 2;
public static final byte Blue = 8;
using FlatBuffers;
-public class Monster : Table {
+public sealed class Monster : Table {
public static Monster GetRootAsMonster(ByteBuffer _bb) { return GetRootAsMonster(_bb, new Monster()); }
public static Monster GetRootAsMonster(ByteBuffer _bb, Monster obj) { return (obj.__init(_bb.GetInt(_bb.position()) + _bb.position(), _bb)); }
public static bool MonsterBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MONS"); }
}
/// an example documentation comment: this will end up in the generated code
-
/// multiline too
-
func (rcv *Monster) Testarrayoftables(obj *Monster, j int) bool {
o := flatbuffers.UOffsetT(rcv._tab.Offset(26))
if o != 0 {
import java.util.*;
import com.google.flatbuffers.*;
-public class Monster extends Table {
+public final class Monster extends Table {
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.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public static boolean MonsterBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MONS"); }
using FlatBuffers;
-public class Stat : Table {
+public sealed class Stat : Table {
public static Stat GetRootAsStat(ByteBuffer _bb) { return GetRootAsStat(_bb, new Stat()); }
public static Stat GetRootAsStat(ByteBuffer _bb, Stat obj) { return (obj.__init(_bb.GetInt(_bb.position()) + _bb.position(), _bb)); }
public Stat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
import java.util.*;
import com.google.flatbuffers.*;
-public class Stat extends Table {
+public final class Stat extends Table {
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.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public Stat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
using FlatBuffers;
-public class Test : Struct {
+public sealed class Test : Struct {
public Test __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
public short A() { return bb.GetShort(bb_pos + 0); }
import java.util.*;
import com.google.flatbuffers.*;
-public class Test extends Struct {
+public final class Test extends Struct {
public Test __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
public short a() { return bb.getShort(bb_pos + 0); }
using FlatBuffers;
-public class Vec3 : Struct {
+public sealed class Vec3 : Struct {
public Vec3 __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
public float X() { return bb.GetFloat(bb_pos + 0); }
import java.util.*;
import com.google.flatbuffers.*;
-public class Vec3 extends Struct {
+public final class Vec3 extends Struct {
public Vec3 __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
public float x() { return bb.getFloat(bb_pos + 0); }