Commit 79f62ee3 authored by Flaviu's avatar Flaviu Committed by Wouter van Oortmerssen

Const correctness in generated code and in code generators. Added missing…

Const correctness in generated code and in code generators. Added missing \reflection\generate_code.bat file. (#4679)
parent c0a6e512
...@@ -2185,8 +2185,8 @@ enum ElementaryType { ...@@ -2185,8 +2185,8 @@ enum ElementaryType {
#undef FLATBUFFERS_ET #undef FLATBUFFERS_ET
}; };
inline const char **ElementaryTypeNames() { inline const char * const *ElementaryTypeNames() {
static const char *names[] = { static const char * const names[] = {
#define FLATBUFFERS_ET(E) #E, #define FLATBUFFERS_ET(E) #E,
FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET) FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET)
#undef FLATBUFFERS_ET #undef FLATBUFFERS_ET
...@@ -2207,7 +2207,7 @@ static_assert(sizeof(TypeCode) == 2, "TypeCode"); ...@@ -2207,7 +2207,7 @@ static_assert(sizeof(TypeCode) == 2, "TypeCode");
struct TypeTable; struct TypeTable;
// Signature of the static method present in each type. // Signature of the static method present in each type.
typedef TypeTable *(*TypeFunction)(); typedef const TypeTable *(*TypeFunction)();
struct TypeTable { struct TypeTable {
SequenceType st; SequenceType st;
...@@ -2215,7 +2215,7 @@ struct TypeTable { ...@@ -2215,7 +2215,7 @@ struct TypeTable {
const TypeCode *type_codes; const TypeCode *type_codes;
const TypeFunction *type_refs; const TypeFunction *type_refs;
const int32_t *values; // Only set for non-consecutive enum/union or structs. const int32_t *values; // Only set for non-consecutive enum/union or structs.
const char **names; // Only set if compiled with --reflect-names. const char * const *names; // Only set if compiled with --reflect-names.
}; };
// String which identifies the current version of FlatBuffers. // String which identifies the current version of FlatBuffers.
......
...@@ -600,10 +600,10 @@ class Parser : public ParserState { ...@@ -600,10 +600,10 @@ class Parser : public ParserState {
FLATBUFFERS_CHECKED_ERROR ParseHexNum(int nibbles, uint64_t *val); FLATBUFFERS_CHECKED_ERROR ParseHexNum(int nibbles, uint64_t *val);
FLATBUFFERS_CHECKED_ERROR Next(); FLATBUFFERS_CHECKED_ERROR Next();
FLATBUFFERS_CHECKED_ERROR SkipByteOrderMark(); FLATBUFFERS_CHECKED_ERROR SkipByteOrderMark();
bool Is(int t); bool Is(int t) const;
bool IsIdent(const char *id); bool IsIdent(const char *id) const;
FLATBUFFERS_CHECKED_ERROR Expect(int t); FLATBUFFERS_CHECKED_ERROR Expect(int t);
std::string TokenToStringId(int t); std::string TokenToStringId(int t) const;
EnumDef *LookupEnum(const std::string &id); EnumDef *LookupEnum(const std::string &id);
FLATBUFFERS_CHECKED_ERROR ParseNamespacing(std::string *id, FLATBUFFERS_CHECKED_ERROR ParseNamespacing(std::string *id,
std::string *last); std::string *last);
......
...@@ -42,8 +42,8 @@ enum BaseType { ...@@ -42,8 +42,8 @@ enum BaseType {
Union = 16 Union = 16
}; };
inline BaseType (&EnumValuesBaseType())[17] { inline const BaseType (&EnumValuesBaseType())[17] {
static BaseType values[] = { static const BaseType values[] = {
None, None,
UType, UType,
Bool, Bool,
...@@ -65,8 +65,8 @@ inline BaseType (&EnumValuesBaseType())[17] { ...@@ -65,8 +65,8 @@ inline BaseType (&EnumValuesBaseType())[17] {
return values; return values;
} }
inline const char **EnumNamesBaseType() { inline const char * const *EnumNamesBaseType() {
static const char *names[] = { static const char * const names[] = {
"None", "None",
"UType", "UType",
"Bool", "Bool",
...@@ -130,7 +130,7 @@ struct TypeBuilder { ...@@ -130,7 +130,7 @@ struct TypeBuilder {
void add_index(int32_t index) { void add_index(int32_t index) {
fbb_.AddElement<int32_t>(Type::VT_INDEX, index, -1); fbb_.AddElement<int32_t>(Type::VT_INDEX, index, -1);
} }
TypeBuilder(flatbuffers::FlatBufferBuilder &_fbb) explicit TypeBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) { : fbb_(_fbb) {
start_ = fbb_.StartTable(); start_ = fbb_.StartTable();
} }
...@@ -190,7 +190,7 @@ struct KeyValueBuilder { ...@@ -190,7 +190,7 @@ struct KeyValueBuilder {
void add_value(flatbuffers::Offset<flatbuffers::String> value) { void add_value(flatbuffers::Offset<flatbuffers::String> value) {
fbb_.AddOffset(KeyValue::VT_VALUE, value); fbb_.AddOffset(KeyValue::VT_VALUE, value);
} }
KeyValueBuilder(flatbuffers::FlatBufferBuilder &_fbb) explicit KeyValueBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) { : fbb_(_fbb) {
start_ = fbb_.StartTable(); start_ = fbb_.StartTable();
} }
...@@ -283,7 +283,7 @@ struct EnumValBuilder { ...@@ -283,7 +283,7 @@ struct EnumValBuilder {
void add_union_type(flatbuffers::Offset<Type> union_type) { void add_union_type(flatbuffers::Offset<Type> union_type) {
fbb_.AddOffset(EnumVal::VT_UNION_TYPE, union_type); fbb_.AddOffset(EnumVal::VT_UNION_TYPE, union_type);
} }
EnumValBuilder(flatbuffers::FlatBufferBuilder &_fbb) explicit EnumValBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) { : fbb_(_fbb) {
start_ = fbb_.StartTable(); start_ = fbb_.StartTable();
} }
...@@ -398,7 +398,7 @@ struct EnumBuilder { ...@@ -398,7 +398,7 @@ struct EnumBuilder {
void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) {
fbb_.AddOffset(Enum::VT_DOCUMENTATION, documentation); fbb_.AddOffset(Enum::VT_DOCUMENTATION, documentation);
} }
EnumBuilder(flatbuffers::FlatBufferBuilder &_fbb) explicit EnumBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) { : fbb_(_fbb) {
start_ = fbb_.StartTable(); start_ = fbb_.StartTable();
} }
...@@ -561,7 +561,7 @@ struct FieldBuilder { ...@@ -561,7 +561,7 @@ struct FieldBuilder {
void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) {
fbb_.AddOffset(Field::VT_DOCUMENTATION, documentation); fbb_.AddOffset(Field::VT_DOCUMENTATION, documentation);
} }
FieldBuilder(flatbuffers::FlatBufferBuilder &_fbb) explicit FieldBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) { : fbb_(_fbb) {
start_ = fbb_.StartTable(); start_ = fbb_.StartTable();
} }
...@@ -712,7 +712,7 @@ struct ObjectBuilder { ...@@ -712,7 +712,7 @@ struct ObjectBuilder {
void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) { void add_documentation(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> documentation) {
fbb_.AddOffset(Object::VT_DOCUMENTATION, documentation); fbb_.AddOffset(Object::VT_DOCUMENTATION, documentation);
} }
ObjectBuilder(flatbuffers::FlatBufferBuilder &_fbb) explicit ObjectBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) { : fbb_(_fbb) {
start_ = fbb_.StartTable(); start_ = fbb_.StartTable();
} }
...@@ -825,7 +825,7 @@ struct SchemaBuilder { ...@@ -825,7 +825,7 @@ struct SchemaBuilder {
void add_root_table(flatbuffers::Offset<Object> root_table) { void add_root_table(flatbuffers::Offset<Object> root_table) {
fbb_.AddOffset(Schema::VT_ROOT_TABLE, root_table); fbb_.AddOffset(Schema::VT_ROOT_TABLE, root_table);
} }
SchemaBuilder(flatbuffers::FlatBufferBuilder &_fbb) explicit SchemaBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) { : fbb_(_fbb) {
start_ = fbb_.StartTable(); start_ = fbb_.StartTable();
} }
...@@ -875,6 +875,10 @@ inline const reflection::Schema *GetSchema(const void *buf) { ...@@ -875,6 +875,10 @@ inline const reflection::Schema *GetSchema(const void *buf) {
return flatbuffers::GetRoot<reflection::Schema>(buf); return flatbuffers::GetRoot<reflection::Schema>(buf);
} }
inline const reflection::Schema *GetSizePrefixedSchema(const void *buf) {
return flatbuffers::GetSizePrefixedRoot<reflection::Schema>(buf);
}
inline const char *SchemaIdentifier() { inline const char *SchemaIdentifier() {
return "BFBS"; return "BFBS";
} }
...@@ -889,6 +893,11 @@ inline bool VerifySchemaBuffer( ...@@ -889,6 +893,11 @@ inline bool VerifySchemaBuffer(
return verifier.VerifyBuffer<reflection::Schema>(SchemaIdentifier()); return verifier.VerifyBuffer<reflection::Schema>(SchemaIdentifier());
} }
inline bool VerifySizePrefixedSchemaBuffer(
flatbuffers::Verifier &verifier) {
return verifier.VerifySizePrefixedBuffer<reflection::Schema>(SchemaIdentifier());
}
inline const char *SchemaExtension() { inline const char *SchemaExtension() {
return "bfbs"; return "bfbs";
} }
...@@ -899,6 +908,12 @@ inline void FinishSchemaBuffer( ...@@ -899,6 +908,12 @@ inline void FinishSchemaBuffer(
fbb.Finish(root, SchemaIdentifier()); fbb.Finish(root, SchemaIdentifier());
} }
inline void FinishSizePrefixedSchemaBuffer(
flatbuffers::FlatBufferBuilder &fbb,
flatbuffers::Offset<reflection::Schema> root) {
fbb.FinishSizePrefixed(root, SchemaIdentifier());
}
} // namespace reflection } // namespace reflection
#endif // FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_ #endif // FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_
...@@ -321,7 +321,7 @@ inline int FromUTF8(const char **in) { ...@@ -321,7 +321,7 @@ inline int FromUTF8(const char **in) {
break; break;
} }
} }
if ((static_cast<unsigned char>(**in) << len) & 0x80) return -1; // Bit after leading 1's must be 0. if ((static_cast<const unsigned char>(**in) << len) & 0x80) return -1; // Bit after leading 1's must be 0.
if (!len) return *(*in)++; if (!len) return *(*in)++;
// UTF-8 encoded values with a length are between 2 and 4 bytes. // UTF-8 encoded values with a length are between 2 and 4 bytes.
if (len < 2 || len > 4) { return -1; } if (len < 2 || len > 4) { return -1; }
......
:: Copyright 2015 Google Inc. All rights reserved.
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
set buildtype=Release
if "%1"=="-b" set buildtype=%2
..\%buildtype%\flatc.exe --cpp --no-prefix -o ../include/flatbuffers reflection.fbs
...@@ -17,11 +17,11 @@ struct MonsterT; ...@@ -17,11 +17,11 @@ struct MonsterT;
struct Weapon; struct Weapon;
struct WeaponT; struct WeaponT;
inline flatbuffers::TypeTable *Vec3TypeTable(); inline const flatbuffers::TypeTable *Vec3TypeTable();
inline flatbuffers::TypeTable *MonsterTypeTable(); inline const flatbuffers::TypeTable *MonsterTypeTable();
inline flatbuffers::TypeTable *WeaponTypeTable(); inline const flatbuffers::TypeTable *WeaponTypeTable();
enum Color { enum Color {
Color_Red = 0, Color_Red = 0,
...@@ -31,8 +31,8 @@ enum Color { ...@@ -31,8 +31,8 @@ enum Color {
Color_MAX = Color_Blue Color_MAX = Color_Blue
}; };
inline Color (&EnumValuesColor())[3] { inline const Color (&EnumValuesColor())[3] {
static Color values[] = { static const Color values[] = {
Color_Red, Color_Red,
Color_Green, Color_Green,
Color_Blue Color_Blue
...@@ -40,8 +40,8 @@ inline Color (&EnumValuesColor())[3] { ...@@ -40,8 +40,8 @@ inline Color (&EnumValuesColor())[3] {
return values; return values;
} }
inline const char **EnumNamesColor() { inline const char * const *EnumNamesColor() {
static const char *names[] = { static const char * const names[] = {
"Red", "Red",
"Green", "Green",
"Blue", "Blue",
...@@ -62,16 +62,16 @@ enum Equipment { ...@@ -62,16 +62,16 @@ enum Equipment {
Equipment_MAX = Equipment_Weapon Equipment_MAX = Equipment_Weapon
}; };
inline Equipment (&EnumValuesEquipment())[2] { inline const Equipment (&EnumValuesEquipment())[2] {
static Equipment values[] = { static const Equipment values[] = {
Equipment_NONE, Equipment_NONE,
Equipment_Weapon Equipment_Weapon
}; };
return values; return values;
} }
inline const char **EnumNamesEquipment() { inline const char * const *EnumNamesEquipment() {
static const char *names[] = { static const char * const names[] = {
"NONE", "NONE",
"Weapon", "Weapon",
nullptr nullptr
...@@ -191,7 +191,7 @@ struct MonsterT : public flatbuffers::NativeTable { ...@@ -191,7 +191,7 @@ struct MonsterT : public flatbuffers::NativeTable {
struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef MonsterT NativeTableType; typedef MonsterT NativeTableType;
static flatbuffers::TypeTable *MiniReflectTypeTable() { static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return MonsterTypeTable(); return MonsterTypeTable();
} }
enum { enum {
...@@ -393,7 +393,7 @@ struct WeaponT : public flatbuffers::NativeTable { ...@@ -393,7 +393,7 @@ struct WeaponT : public flatbuffers::NativeTable {
struct Weapon FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { struct Weapon FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef WeaponT NativeTableType; typedef WeaponT NativeTableType;
static flatbuffers::TypeTable *MiniReflectTypeTable() { static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return WeaponTypeTable(); return WeaponTypeTable();
} }
enum { enum {
...@@ -615,64 +615,64 @@ inline void EquipmentUnion::Reset() { ...@@ -615,64 +615,64 @@ inline void EquipmentUnion::Reset() {
type = Equipment_NONE; type = Equipment_NONE;
} }
inline flatbuffers::TypeTable *ColorTypeTable() { inline const flatbuffers::TypeTable *ColorTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_CHAR, 0, 0 }, { flatbuffers::ET_CHAR, 0, 0 },
{ flatbuffers::ET_CHAR, 0, 0 }, { flatbuffers::ET_CHAR, 0, 0 },
{ flatbuffers::ET_CHAR, 0, 0 } { flatbuffers::ET_CHAR, 0, 0 }
}; };
static flatbuffers::TypeFunction type_refs[] = { static const flatbuffers::TypeFunction type_refs[] = {
ColorTypeTable ColorTypeTable
}; };
static const char *names[] = { static const char * const names[] = {
"Red", "Red",
"Green", "Green",
"Blue" "Blue"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, names flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, names
}; };
return &tt; return &tt;
} }
inline flatbuffers::TypeTable *EquipmentTypeTable() { inline const flatbuffers::TypeTable *EquipmentTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_SEQUENCE, 0, -1 }, { flatbuffers::ET_SEQUENCE, 0, -1 },
{ flatbuffers::ET_SEQUENCE, 0, 0 } { flatbuffers::ET_SEQUENCE, 0, 0 }
}; };
static flatbuffers::TypeFunction type_refs[] = { static const flatbuffers::TypeFunction type_refs[] = {
WeaponTypeTable WeaponTypeTable
}; };
static const char *names[] = { static const char * const names[] = {
"NONE", "NONE",
"Weapon" "Weapon"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_UNION, 2, type_codes, type_refs, nullptr, names flatbuffers::ST_UNION, 2, type_codes, type_refs, nullptr, names
}; };
return &tt; return &tt;
} }
inline flatbuffers::TypeTable *Vec3TypeTable() { inline const flatbuffers::TypeTable *Vec3TypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_FLOAT, 0, -1 }, { flatbuffers::ET_FLOAT, 0, -1 },
{ flatbuffers::ET_FLOAT, 0, -1 }, { flatbuffers::ET_FLOAT, 0, -1 },
{ flatbuffers::ET_FLOAT, 0, -1 } { flatbuffers::ET_FLOAT, 0, -1 }
}; };
static const int32_t values[] = { 0, 4, 8, 12 }; static const int32_t values[] = { 0, 4, 8, 12 };
static const char *names[] = { static const char * const names[] = {
"x", "x",
"y", "y",
"z" "z"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_STRUCT, 3, type_codes, nullptr, values, names flatbuffers::ST_STRUCT, 3, type_codes, nullptr, values, names
}; };
return &tt; return &tt;
} }
inline flatbuffers::TypeTable *MonsterTypeTable() { inline const flatbuffers::TypeTable *MonsterTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_SEQUENCE, 0, 0 }, { flatbuffers::ET_SEQUENCE, 0, 0 },
{ flatbuffers::ET_SHORT, 0, -1 }, { flatbuffers::ET_SHORT, 0, -1 },
{ flatbuffers::ET_SHORT, 0, -1 }, { flatbuffers::ET_SHORT, 0, -1 },
...@@ -684,13 +684,13 @@ inline flatbuffers::TypeTable *MonsterTypeTable() { ...@@ -684,13 +684,13 @@ inline flatbuffers::TypeTable *MonsterTypeTable() {
{ flatbuffers::ET_UTYPE, 0, 3 }, { flatbuffers::ET_UTYPE, 0, 3 },
{ flatbuffers::ET_SEQUENCE, 0, 3 } { flatbuffers::ET_SEQUENCE, 0, 3 }
}; };
static flatbuffers::TypeFunction type_refs[] = { static const flatbuffers::TypeFunction type_refs[] = {
Vec3TypeTable, Vec3TypeTable,
ColorTypeTable, ColorTypeTable,
WeaponTypeTable, WeaponTypeTable,
EquipmentTypeTable EquipmentTypeTable
}; };
static const char *names[] = { static const char * const names[] = {
"pos", "pos",
"mana", "mana",
"hp", "hp",
...@@ -702,22 +702,22 @@ inline flatbuffers::TypeTable *MonsterTypeTable() { ...@@ -702,22 +702,22 @@ inline flatbuffers::TypeTable *MonsterTypeTable() {
"equipped_type", "equipped_type",
"equipped" "equipped"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_TABLE, 10, type_codes, type_refs, nullptr, names flatbuffers::ST_TABLE, 10, type_codes, type_refs, nullptr, names
}; };
return &tt; return &tt;
} }
inline flatbuffers::TypeTable *WeaponTypeTable() { inline const flatbuffers::TypeTable *WeaponTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_STRING, 0, -1 }, { flatbuffers::ET_STRING, 0, -1 },
{ flatbuffers::ET_SHORT, 0, -1 } { flatbuffers::ET_SHORT, 0, -1 }
}; };
static const char *names[] = { static const char * const names[] = {
"name", "name",
"damage" "damage"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_TABLE, 2, type_codes, nullptr, nullptr, names flatbuffers::ST_TABLE, 2, type_codes, nullptr, nullptr, names
}; };
return &tt; return &tt;
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "flatbuffers/idl.h" #include "flatbuffers/idl.h"
#include "flatbuffers/util.h" #include "flatbuffers/util.h"
#include <unordered_set>
namespace flatbuffers { namespace flatbuffers {
// Pedantic warning free version of toupper(). // Pedantic warning free version of toupper().
...@@ -38,7 +40,8 @@ class CppGenerator : public BaseGenerator { ...@@ -38,7 +40,8 @@ class CppGenerator : public BaseGenerator {
const std::string &file_name) const std::string &file_name)
: BaseGenerator(parser, path, file_name, "", "::"), : BaseGenerator(parser, path, file_name, "", "::"),
cur_name_space_(nullptr) { cur_name_space_(nullptr) {
const char *keywords[] = { "alignas", static const char * const keywords[] = {
"alignas",
"alignof", "alignof",
"and", "and",
"and_eq", "and_eq",
...@@ -142,7 +145,7 @@ class CppGenerator : public BaseGenerator { ...@@ -142,7 +145,7 @@ class CppGenerator : public BaseGenerator {
std::string guard = file_name_; std::string guard = file_name_;
// Remove any non-alpha-numeric characters that may appear in a filename. // Remove any non-alpha-numeric characters that may appear in a filename.
struct IsAlnum { struct IsAlnum {
bool operator()(char c) { return !isalnum(c); } bool operator()(char c) const { return !isalnum(c); }
}; };
guard.erase(std::remove_if(guard.begin(), guard.end(), IsAlnum()), guard.erase(std::remove_if(guard.begin(), guard.end(), IsAlnum()),
guard.end()); guard.end());
...@@ -445,7 +448,7 @@ class CppGenerator : public BaseGenerator { ...@@ -445,7 +448,7 @@ class CppGenerator : public BaseGenerator {
private: private:
CodeWriter code_; CodeWriter code_;
std::set<std::string> keywords_; std::unordered_set<std::string> keywords_;
// This tracks the current namespace so we can insert namespace declarations. // This tracks the current namespace so we can insert namespace declarations.
const Namespace *cur_name_space_; const Namespace *cur_name_space_;
...@@ -472,7 +475,7 @@ class CppGenerator : public BaseGenerator { ...@@ -472,7 +475,7 @@ class CppGenerator : public BaseGenerator {
// Return a C++ type from the table in idl.h // Return a C++ type from the table in idl.h
std::string GenTypeBasic(const Type &type, bool user_facing_type) const { std::string GenTypeBasic(const Type &type, bool user_facing_type) const {
static const char *ctypename[] = { static const char * const ctypename[] = {
// clang-format off // clang-format off
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \ #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \
#CTYPE, #CTYPE,
...@@ -734,7 +737,7 @@ class CppGenerator : public BaseGenerator { ...@@ -734,7 +737,7 @@ class CppGenerator : public BaseGenerator {
void GenMiniReflectPre(const StructDef *struct_def) { void GenMiniReflectPre(const StructDef *struct_def) {
code_.SetValue("NAME", struct_def->name); code_.SetValue("NAME", struct_def->name);
code_ += "inline flatbuffers::TypeTable *{{NAME}}TypeTable();"; code_ += "inline const flatbuffers::TypeTable *{{NAME}}TypeTable();";
code_ += ""; code_ += "";
} }
...@@ -830,14 +833,14 @@ class CppGenerator : public BaseGenerator { ...@@ -830,14 +833,14 @@ class CppGenerator : public BaseGenerator {
code_.SetValue("REFS", rs); code_.SetValue("REFS", rs);
code_.SetValue("NAMES", ns); code_.SetValue("NAMES", ns);
code_.SetValue("VALUES", vs); code_.SetValue("VALUES", vs);
code_ += "inline flatbuffers::TypeTable *{{NAME}}TypeTable() {"; code_ += "inline const flatbuffers::TypeTable *{{NAME}}TypeTable() {";
if (num_fields) { if (num_fields) {
code_ += " static flatbuffers::TypeCode type_codes[] = {"; code_ += " static const flatbuffers::TypeCode type_codes[] = {";
code_ += " {{TYPES}}"; code_ += " {{TYPES}}";
code_ += " };"; code_ += " };";
} }
if (!type_refs.empty()) { if (!type_refs.empty()) {
code_ += " static flatbuffers::TypeFunction type_refs[] = {"; code_ += " static const flatbuffers::TypeFunction type_refs[] = {";
code_ += " {{REFS}}"; code_ += " {{REFS}}";
code_ += " };"; code_ += " };";
} }
...@@ -847,11 +850,11 @@ class CppGenerator : public BaseGenerator { ...@@ -847,11 +850,11 @@ class CppGenerator : public BaseGenerator {
auto has_names = auto has_names =
num_fields && parser_.opts.mini_reflect == IDLOptions::kTypesAndNames; num_fields && parser_.opts.mini_reflect == IDLOptions::kTypesAndNames;
if (has_names) { if (has_names) {
code_ += " static const char *names[] = {"; code_ += " static const char * const names[] = {";
code_ += " {{NAMES}}"; code_ += " {{NAMES}}";
code_ += " };"; code_ += " };";
} }
code_ += " static flatbuffers::TypeTable tt = {"; code_ += " static const flatbuffers::TypeTable tt = {";
code_ += std::string(" flatbuffers::{{SEQ_TYPE}}, {{NUM_FIELDS}}, ") + code_ += std::string(" flatbuffers::{{SEQ_TYPE}}, {{NUM_FIELDS}}, ") +
(num_fields ? "type_codes, " : "nullptr, ") + (num_fields ? "type_codes, " : "nullptr, ") +
(!type_refs.empty() ? "type_refs, " : "nullptr, ") + (!type_refs.empty() ? "type_refs, " : "nullptr, ") +
...@@ -925,9 +928,9 @@ class CppGenerator : public BaseGenerator { ...@@ -925,9 +928,9 @@ class CppGenerator : public BaseGenerator {
// Generate an array of all enumeration values // Generate an array of all enumeration values
auto num_fields = NumToString(enum_def.vals.vec.size()); auto num_fields = NumToString(enum_def.vals.vec.size());
code_ += "inline {{ENUM_NAME}} (&EnumValues{{ENUM_NAME}}())[" + num_fields + code_ += "inline const {{ENUM_NAME}} (&EnumValues{{ENUM_NAME}}())[" + num_fields +
"] {"; "] {";
code_ += " static {{ENUM_NAME}} values[] = {"; code_ += " static const {{ENUM_NAME}} values[] = {";
for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
++it) { ++it) {
const auto &ev = **it; const auto &ev = **it;
...@@ -951,8 +954,8 @@ class CppGenerator : public BaseGenerator { ...@@ -951,8 +954,8 @@ class CppGenerator : public BaseGenerator {
static const int kMaxSparseness = 5; static const int kMaxSparseness = 5;
if (range / static_cast<int64_t>(enum_def.vals.vec.size()) < if (range / static_cast<int64_t>(enum_def.vals.vec.size()) <
kMaxSparseness) { kMaxSparseness) {
code_ += "inline const char **EnumNames{{ENUM_NAME}}() {"; code_ += "inline const char * const *EnumNames{{ENUM_NAME}}() {";
code_ += " static const char *names[] = {"; code_ += " static const char * const names[] = {";
auto val = enum_def.vals.vec.front()->value; auto val = enum_def.vals.vec.front()->value;
for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end(); for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
...@@ -1548,7 +1551,7 @@ class CppGenerator : public BaseGenerator { ...@@ -1548,7 +1551,7 @@ class CppGenerator : public BaseGenerator {
code_ += " typedef {{NATIVE_NAME}} NativeTableType;"; code_ += " typedef {{NATIVE_NAME}} NativeTableType;";
} }
if (parser_.opts.mini_reflect != IDLOptions::kNone) { if (parser_.opts.mini_reflect != IDLOptions::kNone) {
code_ += " static flatbuffers::TypeTable *MiniReflectTypeTable() {"; code_ += " static const flatbuffers::TypeTable *MiniReflectTypeTable() {";
code_ += " return {{STRUCT_NAME}}TypeTable();"; code_ += " return {{STRUCT_NAME}}TypeTable();";
code_ += " }"; code_ += " }";
} }
......
This diff is collapsed.
...@@ -43,7 +43,7 @@ static std::string GeneratedFileName(const std::string &path, ...@@ -43,7 +43,7 @@ static std::string GeneratedFileName(const std::string &path,
namespace go { namespace go {
// see https://golang.org/ref/spec#Keywords // see https://golang.org/ref/spec#Keywords
static const char *g_golang_keywords[] = { static const char * const g_golang_keywords[] = {
"break", "default", "func", "interface", "select", "case", "defer", "break", "default", "func", "interface", "select", "case", "defer",
"go", "map", "struct", "chan", "else", "goto", "package", "go", "map", "struct", "chan", "else", "goto", "package",
"switch", "const", "fallthrough", "if", "range", "type", "continue", "switch", "const", "fallthrough", "if", "range", "type", "continue",
......
...@@ -205,7 +205,7 @@ enum { ...@@ -205,7 +205,7 @@ enum {
}; };
static std::string TokenToString(int t) { static std::string TokenToString(int t) {
static const char *tokens[] = { static const char * const tokens[] = {
#define FLATBUFFERS_TOKEN(NAME, VALUE, STRING) STRING, #define FLATBUFFERS_TOKEN(NAME, VALUE, STRING) STRING,
FLATBUFFERS_GEN_TOKENS(FLATBUFFERS_TOKEN) FLATBUFFERS_GEN_TOKENS(FLATBUFFERS_TOKEN)
#undef FLATBUFFERS_TOKEN #undef FLATBUFFERS_TOKEN
...@@ -225,7 +225,7 @@ static std::string TokenToString(int t) { ...@@ -225,7 +225,7 @@ static std::string TokenToString(int t) {
} }
// clang-format on // clang-format on
std::string Parser::TokenToStringId(int t) { std::string Parser::TokenToStringId(int t) const {
return t == kTokenIdentifier ? attribute_ : TokenToString(t); return t == kTokenIdentifier ? attribute_ : TokenToString(t);
} }
...@@ -478,9 +478,9 @@ CheckedError Parser::Next() { ...@@ -478,9 +478,9 @@ CheckedError Parser::Next() {
} }
// Check if a given token is next. // Check if a given token is next.
bool Parser::Is(int t) { return t == token_; } bool Parser::Is(int t) const { return t == token_; }
bool Parser::IsIdent(const char *id) { bool Parser::IsIdent(const char *id) const {
return token_ == kTokenIdentifier && attribute_ == id; return token_ == kTokenIdentifier && attribute_ == id;
} }
......
No preview for this file type
This diff is collapsed.
...@@ -13,9 +13,9 @@ struct TableInNestedNS; ...@@ -13,9 +13,9 @@ struct TableInNestedNS;
struct StructInNestedNS; struct StructInNestedNS;
inline flatbuffers::TypeTable *TableInNestedNSTypeTable(); inline const flatbuffers::TypeTable *TableInNestedNSTypeTable();
inline flatbuffers::TypeTable *StructInNestedNSTypeTable(); inline const flatbuffers::TypeTable *StructInNestedNSTypeTable();
enum EnumInNestedNS { enum EnumInNestedNS {
EnumInNestedNS_A = 0, EnumInNestedNS_A = 0,
...@@ -25,8 +25,8 @@ enum EnumInNestedNS { ...@@ -25,8 +25,8 @@ enum EnumInNestedNS {
EnumInNestedNS_MAX = EnumInNestedNS_C EnumInNestedNS_MAX = EnumInNestedNS_C
}; };
inline EnumInNestedNS (&EnumValuesEnumInNestedNS())[3] { inline const EnumInNestedNS (&EnumValuesEnumInNestedNS())[3] {
static EnumInNestedNS values[] = { static const EnumInNestedNS values[] = {
EnumInNestedNS_A, EnumInNestedNS_A,
EnumInNestedNS_B, EnumInNestedNS_B,
EnumInNestedNS_C EnumInNestedNS_C
...@@ -34,8 +34,8 @@ inline EnumInNestedNS (&EnumValuesEnumInNestedNS())[3] { ...@@ -34,8 +34,8 @@ inline EnumInNestedNS (&EnumValuesEnumInNestedNS())[3] {
return values; return values;
} }
inline const char **EnumNamesEnumInNestedNS() { inline const char * const *EnumNamesEnumInNestedNS() {
static const char *names[] = { static const char * const names[] = {
"A", "A",
"B", "B",
"C", "C",
...@@ -78,7 +78,7 @@ MANUALLY_ALIGNED_STRUCT(4) StructInNestedNS FLATBUFFERS_FINAL_CLASS { ...@@ -78,7 +78,7 @@ MANUALLY_ALIGNED_STRUCT(4) StructInNestedNS FLATBUFFERS_FINAL_CLASS {
STRUCT_END(StructInNestedNS, 8); STRUCT_END(StructInNestedNS, 8);
struct TableInNestedNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { struct TableInNestedNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
static flatbuffers::TypeTable *MiniReflectTypeTable() { static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return TableInNestedNSTypeTable(); return TableInNestedNSTypeTable();
} }
enum { enum {
...@@ -123,50 +123,50 @@ inline flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS( ...@@ -123,50 +123,50 @@ inline flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(
return builder_.Finish(); return builder_.Finish();
} }
inline flatbuffers::TypeTable *EnumInNestedNSTypeTable() { inline const flatbuffers::TypeTable *EnumInNestedNSTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_CHAR, 0, 0 }, { flatbuffers::ET_CHAR, 0, 0 },
{ flatbuffers::ET_CHAR, 0, 0 }, { flatbuffers::ET_CHAR, 0, 0 },
{ flatbuffers::ET_CHAR, 0, 0 } { flatbuffers::ET_CHAR, 0, 0 }
}; };
static flatbuffers::TypeFunction type_refs[] = { static const flatbuffers::TypeFunction type_refs[] = {
EnumInNestedNSTypeTable EnumInNestedNSTypeTable
}; };
static const char *names[] = { static const char * const names[] = {
"A", "A",
"B", "B",
"C" "C"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, names flatbuffers::ST_ENUM, 3, type_codes, type_refs, nullptr, names
}; };
return &tt; return &tt;
} }
inline flatbuffers::TypeTable *TableInNestedNSTypeTable() { inline const flatbuffers::TypeTable *TableInNestedNSTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_INT, 0, -1 } { flatbuffers::ET_INT, 0, -1 }
}; };
static const char *names[] = { static const char * const names[] = {
"foo" "foo"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, names flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, names
}; };
return &tt; return &tt;
} }
inline flatbuffers::TypeTable *StructInNestedNSTypeTable() { inline const flatbuffers::TypeTable *StructInNestedNSTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_INT, 0, -1 }, { flatbuffers::ET_INT, 0, -1 },
{ flatbuffers::ET_INT, 0, -1 } { flatbuffers::ET_INT, 0, -1 }
}; };
static const int32_t values[] = { 0, 4, 8 }; static const int32_t values[] = { 0, 4, 8 };
static const char *names[] = { static const char * const names[] = {
"a", "a",
"b" "b"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_STRUCT, 2, type_codes, nullptr, values, names flatbuffers::ST_STRUCT, 2, type_codes, nullptr, values, names
}; };
return &tt; return &tt;
......
...@@ -24,22 +24,22 @@ namespace NamespaceA { ...@@ -24,22 +24,22 @@ namespace NamespaceA {
struct SecondTableInA; struct SecondTableInA;
inline flatbuffers::TypeTable *TableInFirstNSTypeTable(); inline const flatbuffers::TypeTable *TableInFirstNSTypeTable();
} // namespace NamespaceA } // namespace NamespaceA
namespace NamespaceC { namespace NamespaceC {
inline flatbuffers::TypeTable *TableInCTypeTable(); inline const flatbuffers::TypeTable *TableInCTypeTable();
} // namespace NamespaceC } // namespace NamespaceC
namespace NamespaceA { namespace NamespaceA {
inline flatbuffers::TypeTable *SecondTableInATypeTable(); inline const flatbuffers::TypeTable *SecondTableInATypeTable();
struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { struct TableInFirstNS FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
static flatbuffers::TypeTable *MiniReflectTypeTable() { static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return TableInFirstNSTypeTable(); return TableInFirstNSTypeTable();
} }
enum { enum {
...@@ -116,7 +116,7 @@ inline flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS( ...@@ -116,7 +116,7 @@ inline flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS(
namespace NamespaceC { namespace NamespaceC {
struct TableInC FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { struct TableInC FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
static flatbuffers::TypeTable *MiniReflectTypeTable() { static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return TableInCTypeTable(); return TableInCTypeTable();
} }
enum { enum {
...@@ -181,7 +181,7 @@ inline flatbuffers::Offset<TableInC> CreateTableInC( ...@@ -181,7 +181,7 @@ inline flatbuffers::Offset<TableInC> CreateTableInC(
namespace NamespaceA { namespace NamespaceA {
struct SecondTableInA FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { struct SecondTableInA FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
static flatbuffers::TypeTable *MiniReflectTypeTable() { static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return SecondTableInATypeTable(); return SecondTableInATypeTable();
} }
enum { enum {
...@@ -235,23 +235,23 @@ namespace NamespaceC { ...@@ -235,23 +235,23 @@ namespace NamespaceC {
namespace NamespaceA { namespace NamespaceA {
inline flatbuffers::TypeTable *TableInFirstNSTypeTable() { inline const flatbuffers::TypeTable *TableInFirstNSTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_SEQUENCE, 0, 0 }, { flatbuffers::ET_SEQUENCE, 0, 0 },
{ flatbuffers::ET_CHAR, 0, 1 }, { flatbuffers::ET_CHAR, 0, 1 },
{ flatbuffers::ET_SEQUENCE, 0, 2 } { flatbuffers::ET_SEQUENCE, 0, 2 }
}; };
static flatbuffers::TypeFunction type_refs[] = { static const flatbuffers::TypeFunction type_refs[] = {
NamespaceA::NamespaceB::TableInNestedNSTypeTable, NamespaceA::NamespaceB::TableInNestedNSTypeTable,
NamespaceA::NamespaceB::EnumInNestedNSTypeTable, NamespaceA::NamespaceB::EnumInNestedNSTypeTable,
NamespaceA::NamespaceB::StructInNestedNSTypeTable NamespaceA::NamespaceB::StructInNestedNSTypeTable
}; };
static const char *names[] = { static const char * const names[] = {
"foo_table", "foo_table",
"foo_enum", "foo_enum",
"foo_struct" "foo_struct"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_TABLE, 3, type_codes, type_refs, nullptr, names flatbuffers::ST_TABLE, 3, type_codes, type_refs, nullptr, names
}; };
return &tt; return &tt;
...@@ -261,20 +261,20 @@ inline flatbuffers::TypeTable *TableInFirstNSTypeTable() { ...@@ -261,20 +261,20 @@ inline flatbuffers::TypeTable *TableInFirstNSTypeTable() {
namespace NamespaceC { namespace NamespaceC {
inline flatbuffers::TypeTable *TableInCTypeTable() { inline const flatbuffers::TypeTable *TableInCTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_SEQUENCE, 0, 0 }, { flatbuffers::ET_SEQUENCE, 0, 0 },
{ flatbuffers::ET_SEQUENCE, 0, 1 } { flatbuffers::ET_SEQUENCE, 0, 1 }
}; };
static flatbuffers::TypeFunction type_refs[] = { static const flatbuffers::TypeFunction type_refs[] = {
NamespaceA::TableInFirstNSTypeTable, NamespaceA::TableInFirstNSTypeTable,
NamespaceA::SecondTableInATypeTable NamespaceA::SecondTableInATypeTable
}; };
static const char *names[] = { static const char * const names[] = {
"refer_to_a1", "refer_to_a1",
"refer_to_a2" "refer_to_a2"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_TABLE, 2, type_codes, type_refs, nullptr, names flatbuffers::ST_TABLE, 2, type_codes, type_refs, nullptr, names
}; };
return &tt; return &tt;
...@@ -284,17 +284,17 @@ inline flatbuffers::TypeTable *TableInCTypeTable() { ...@@ -284,17 +284,17 @@ inline flatbuffers::TypeTable *TableInCTypeTable() {
namespace NamespaceA { namespace NamespaceA {
inline flatbuffers::TypeTable *SecondTableInATypeTable() { inline const flatbuffers::TypeTable *SecondTableInATypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_SEQUENCE, 0, 0 } { flatbuffers::ET_SEQUENCE, 0, 0 }
}; };
static flatbuffers::TypeFunction type_refs[] = { static const flatbuffers::TypeFunction type_refs[] = {
NamespaceC::TableInCTypeTable NamespaceC::TableInCTypeTable
}; };
static const char *names[] = { static const char * const names[] = {
"refer_to_c" "refer_to_c"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_TABLE, 1, type_codes, type_refs, nullptr, names flatbuffers::ST_TABLE, 1, type_codes, type_refs, nullptr, names
}; };
return &tt; return &tt;
......
// automatically generated by the FlatBuffers compiler, do not modify // automatically generated by the FlatBuffers compiler, do not modify
import * as NS4989953370203581498 from "./namespace_test1_generated"; import * as NS39599748 from "./namespace_test1_generated";
/** /**
* @constructor * @constructor
*/ */
...@@ -39,24 +39,24 @@ static getRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):T ...@@ -39,24 +39,24 @@ static getRootAsTableInFirstNS(bb:flatbuffers.ByteBuffer, obj?:TableInFirstNS):T
* @param {NamespaceA.NamespaceB.TableInNestedNS=} obj * @param {NamespaceA.NamespaceB.TableInNestedNS=} obj
* @returns {NamespaceA.NamespaceB.TableInNestedNS|null} * @returns {NamespaceA.NamespaceB.TableInNestedNS|null}
*/ */
fooTable(obj?:NS4989953370203581498.NamespaceA.NamespaceB.TableInNestedNS):NS4989953370203581498.NamespaceA.NamespaceB.TableInNestedNS|null { fooTable(obj?:NS39599748.NamespaceA.NamespaceB.TableInNestedNS):NS39599748.NamespaceA.NamespaceB.TableInNestedNS|null {
var offset = this.bb!.__offset(this.bb_pos, 4); var offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? (obj || new NS4989953370203581498.NamespaceA.NamespaceB.TableInNestedNS).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; return offset ? (obj || new NS39599748.NamespaceA.NamespaceB.TableInNestedNS).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}; };
/** /**
* @returns {NamespaceA.NamespaceB.EnumInNestedNS} * @returns {NamespaceA.NamespaceB.EnumInNestedNS}
*/ */
fooEnum():NS4989953370203581498.NamespaceA.NamespaceB.EnumInNestedNS { fooEnum():NS39599748.NamespaceA.NamespaceB.EnumInNestedNS {
var offset = this.bb!.__offset(this.bb_pos, 6); var offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? /** @type {NamespaceA.NamespaceB.EnumInNestedNS} */ (this.bb!.readInt8(this.bb_pos + offset)) : NS4989953370203581498.NamespaceA.NamespaceB.EnumInNestedNS.A; return offset ? /** @type {NamespaceA.NamespaceB.EnumInNestedNS} */ (this.bb!.readInt8(this.bb_pos + offset)) : NS39599748.NamespaceA.NamespaceB.EnumInNestedNS.A;
}; };
/** /**
* @param {NamespaceA.NamespaceB.EnumInNestedNS} value * @param {NamespaceA.NamespaceB.EnumInNestedNS} value
* @returns {boolean} * @returns {boolean}
*/ */
mutate_foo_enum(value:NS4989953370203581498.NamespaceA.NamespaceB.EnumInNestedNS):boolean { mutate_foo_enum(value:NS39599748.NamespaceA.NamespaceB.EnumInNestedNS):boolean {
var offset = this.bb!.__offset(this.bb_pos, 6); var offset = this.bb!.__offset(this.bb_pos, 6);
if (offset === 0) { if (offset === 0) {
...@@ -71,9 +71,9 @@ mutate_foo_enum(value:NS4989953370203581498.NamespaceA.NamespaceB.EnumInNestedNS ...@@ -71,9 +71,9 @@ mutate_foo_enum(value:NS4989953370203581498.NamespaceA.NamespaceB.EnumInNestedNS
* @param {NamespaceA.NamespaceB.StructInNestedNS=} obj * @param {NamespaceA.NamespaceB.StructInNestedNS=} obj
* @returns {NamespaceA.NamespaceB.StructInNestedNS|null} * @returns {NamespaceA.NamespaceB.StructInNestedNS|null}
*/ */
fooStruct(obj?:NS4989953370203581498.NamespaceA.NamespaceB.StructInNestedNS):NS4989953370203581498.NamespaceA.NamespaceB.StructInNestedNS|null { fooStruct(obj?:NS39599748.NamespaceA.NamespaceB.StructInNestedNS):NS39599748.NamespaceA.NamespaceB.StructInNestedNS|null {
var offset = this.bb!.__offset(this.bb_pos, 8); var offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? (obj || new NS4989953370203581498.NamespaceA.NamespaceB.StructInNestedNS).__init(this.bb_pos + offset, this.bb!) : null; return offset ? (obj || new NS39599748.NamespaceA.NamespaceB.StructInNestedNS).__init(this.bb_pos + offset, this.bb!) : null;
}; };
/** /**
...@@ -95,8 +95,8 @@ static addFooTable(builder:flatbuffers.Builder, fooTableOffset:flatbuffers.Offse ...@@ -95,8 +95,8 @@ static addFooTable(builder:flatbuffers.Builder, fooTableOffset:flatbuffers.Offse
* @param {flatbuffers.Builder} builder * @param {flatbuffers.Builder} builder
* @param {NamespaceA.NamespaceB.EnumInNestedNS} fooEnum * @param {NamespaceA.NamespaceB.EnumInNestedNS} fooEnum
*/ */
static addFooEnum(builder:flatbuffers.Builder, fooEnum:NS4989953370203581498.NamespaceA.NamespaceB.EnumInNestedNS) { static addFooEnum(builder:flatbuffers.Builder, fooEnum:NS39599748.NamespaceA.NamespaceB.EnumInNestedNS) {
builder.addFieldInt8(1, fooEnum, NS4989953370203581498.NamespaceA.NamespaceB.EnumInNestedNS.A); builder.addFieldInt8(1, fooEnum, NS39599748.NamespaceA.NamespaceB.EnumInNestedNS.A);
}; };
/** /**
......
...@@ -16,13 +16,13 @@ struct BookReader; ...@@ -16,13 +16,13 @@ struct BookReader;
struct Movie; struct Movie;
struct MovieT; struct MovieT;
inline flatbuffers::TypeTable *AttackerTypeTable(); inline const flatbuffers::TypeTable *AttackerTypeTable();
inline flatbuffers::TypeTable *RapunzelTypeTable(); inline const flatbuffers::TypeTable *RapunzelTypeTable();
inline flatbuffers::TypeTable *BookReaderTypeTable(); inline const flatbuffers::TypeTable *BookReaderTypeTable();
inline flatbuffers::TypeTable *MovieTypeTable(); inline const flatbuffers::TypeTable *MovieTypeTable();
enum Character { enum Character {
Character_NONE = 0, Character_NONE = 0,
...@@ -36,8 +36,8 @@ enum Character { ...@@ -36,8 +36,8 @@ enum Character {
Character_MAX = Character_Unused Character_MAX = Character_Unused
}; };
inline Character (&EnumValuesCharacter())[7] { inline const Character (&EnumValuesCharacter())[7] {
static Character values[] = { static const Character values[] = {
Character_NONE, Character_NONE,
Character_MuLan, Character_MuLan,
Character_Rapunzel, Character_Rapunzel,
...@@ -49,8 +49,8 @@ inline Character (&EnumValuesCharacter())[7] { ...@@ -49,8 +49,8 @@ inline Character (&EnumValuesCharacter())[7] {
return values; return values;
} }
inline const char **EnumNamesCharacter() { inline const char * const *EnumNamesCharacter() {
static const char *names[] = { static const char * const names[] = {
"NONE", "NONE",
"MuLan", "MuLan",
"Rapunzel", "Rapunzel",
...@@ -191,7 +191,7 @@ struct AttackerT : public flatbuffers::NativeTable { ...@@ -191,7 +191,7 @@ struct AttackerT : public flatbuffers::NativeTable {
struct Attacker FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { struct Attacker FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef AttackerT NativeTableType; typedef AttackerT NativeTableType;
static flatbuffers::TypeTable *MiniReflectTypeTable() { static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return AttackerTypeTable(); return AttackerTypeTable();
} }
enum { enum {
...@@ -251,7 +251,7 @@ struct MovieT : public flatbuffers::NativeTable { ...@@ -251,7 +251,7 @@ struct MovieT : public flatbuffers::NativeTable {
struct Movie FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { struct Movie FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
typedef MovieT NativeTableType; typedef MovieT NativeTableType;
static flatbuffers::TypeTable *MiniReflectTypeTable() { static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return MovieTypeTable(); return MovieTypeTable();
} }
enum { enum {
...@@ -609,8 +609,8 @@ inline void CharacterUnion::Reset() { ...@@ -609,8 +609,8 @@ inline void CharacterUnion::Reset() {
type = Character_NONE; type = Character_NONE;
} }
inline flatbuffers::TypeTable *CharacterTypeTable() { inline const flatbuffers::TypeTable *CharacterTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_SEQUENCE, 0, -1 }, { flatbuffers::ET_SEQUENCE, 0, -1 },
{ flatbuffers::ET_SEQUENCE, 0, 0 }, { flatbuffers::ET_SEQUENCE, 0, 0 },
{ flatbuffers::ET_SEQUENCE, 0, 1 }, { flatbuffers::ET_SEQUENCE, 0, 1 },
...@@ -619,12 +619,12 @@ inline flatbuffers::TypeTable *CharacterTypeTable() { ...@@ -619,12 +619,12 @@ inline flatbuffers::TypeTable *CharacterTypeTable() {
{ flatbuffers::ET_STRING, 0, -1 }, { flatbuffers::ET_STRING, 0, -1 },
{ flatbuffers::ET_STRING, 0, -1 } { flatbuffers::ET_STRING, 0, -1 }
}; };
static flatbuffers::TypeFunction type_refs[] = { static const flatbuffers::TypeFunction type_refs[] = {
AttackerTypeTable, AttackerTypeTable,
RapunzelTypeTable, RapunzelTypeTable,
BookReaderTypeTable BookReaderTypeTable
}; };
static const char *names[] = { static const char * const names[] = {
"NONE", "NONE",
"MuLan", "MuLan",
"Rapunzel", "Rapunzel",
...@@ -633,70 +633,70 @@ inline flatbuffers::TypeTable *CharacterTypeTable() { ...@@ -633,70 +633,70 @@ inline flatbuffers::TypeTable *CharacterTypeTable() {
"Other", "Other",
"Unused" "Unused"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_UNION, 7, type_codes, type_refs, nullptr, names flatbuffers::ST_UNION, 7, type_codes, type_refs, nullptr, names
}; };
return &tt; return &tt;
} }
inline flatbuffers::TypeTable *AttackerTypeTable() { inline const flatbuffers::TypeTable *AttackerTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_INT, 0, -1 } { flatbuffers::ET_INT, 0, -1 }
}; };
static const char *names[] = { static const char * const names[] = {
"sword_attack_damage" "sword_attack_damage"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, names flatbuffers::ST_TABLE, 1, type_codes, nullptr, nullptr, names
}; };
return &tt; return &tt;
} }
inline flatbuffers::TypeTable *RapunzelTypeTable() { inline const flatbuffers::TypeTable *RapunzelTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_INT, 0, -1 } { flatbuffers::ET_INT, 0, -1 }
}; };
static const int32_t values[] = { 0, 4 }; static const int32_t values[] = { 0, 4 };
static const char *names[] = { static const char * const names[] = {
"hair_length" "hair_length"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_STRUCT, 1, type_codes, nullptr, values, names flatbuffers::ST_STRUCT, 1, type_codes, nullptr, values, names
}; };
return &tt; return &tt;
} }
inline flatbuffers::TypeTable *BookReaderTypeTable() { inline const flatbuffers::TypeTable *BookReaderTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_INT, 0, -1 } { flatbuffers::ET_INT, 0, -1 }
}; };
static const int32_t values[] = { 0, 4 }; static const int32_t values[] = { 0, 4 };
static const char *names[] = { static const char * const names[] = {
"books_read" "books_read"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_STRUCT, 1, type_codes, nullptr, values, names flatbuffers::ST_STRUCT, 1, type_codes, nullptr, values, names
}; };
return &tt; return &tt;
} }
inline flatbuffers::TypeTable *MovieTypeTable() { inline const flatbuffers::TypeTable *MovieTypeTable() {
static flatbuffers::TypeCode type_codes[] = { static const flatbuffers::TypeCode type_codes[] = {
{ flatbuffers::ET_UTYPE, 0, 0 }, { flatbuffers::ET_UTYPE, 0, 0 },
{ flatbuffers::ET_SEQUENCE, 0, 0 }, { flatbuffers::ET_SEQUENCE, 0, 0 },
{ flatbuffers::ET_UTYPE, 1, 0 }, { flatbuffers::ET_UTYPE, 1, 0 },
{ flatbuffers::ET_SEQUENCE, 1, 0 } { flatbuffers::ET_SEQUENCE, 1, 0 }
}; };
static flatbuffers::TypeFunction type_refs[] = { static const flatbuffers::TypeFunction type_refs[] = {
CharacterTypeTable CharacterTypeTable
}; };
static const char *names[] = { static const char * const names[] = {
"main_character_type", "main_character_type",
"main_character", "main_character",
"characters_type", "characters_type",
"characters" "characters"
}; };
static flatbuffers::TypeTable tt = { static const flatbuffers::TypeTable tt = {
flatbuffers::ST_TABLE, 4, type_codes, type_refs, nullptr, names flatbuffers::ST_TABLE, 4, type_codes, type_refs, nullptr, names
}; };
return &tt; return &tt;
......
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