Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
flatbuffers
Commits
075e8d67
Commit
075e8d67
authored
Nov 25, 2019
by
Vladimir Glavnyy
Committed by
Wouter van Oortmerssen
Nov 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify declarations of x-macro FLATBUFFERS_TD (#5638)
parent
bcf1bd5c
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
102 additions
and
110 deletions
+102
-110
idl.h
include/flatbuffers/idl.h
+19
-7
idl_gen_cpp.cpp
src/idl_gen_cpp.cpp
+3
-4
idl_gen_csharp.cpp
src/idl_gen_csharp.cpp
+3
-4
idl_gen_go.cpp
src/idl_gen_go.cpp
+3
-4
idl_gen_java.cpp
src/idl_gen_java.cpp
+5
-7
idl_gen_kotlin.cpp
src/idl_gen_kotlin.cpp
+6
-6
idl_gen_lobster.cpp
src/idl_gen_lobster.cpp
+4
-4
idl_gen_lua.cpp
src/idl_gen_lua.cpp
+7
-7
idl_gen_php.cpp
src/idl_gen_php.cpp
+7
-7
idl_gen_python.cpp
src/idl_gen_python.cpp
+3
-3
idl_gen_rust.cpp
src/idl_gen_rust.cpp
+9
-9
idl_gen_text.cpp
src/idl_gen_text.cpp
+11
-14
idl_parser.cpp
src/idl_parser.cpp
+22
-34
No files found.
include/flatbuffers/idl.h
View file @
075e8d67
...
...
@@ -91,6 +91,20 @@ switch (type) {
}
*/
// If not all FLATBUFFERS_GEN_() arguments are necessary for implementation
// of FLATBUFFERS_TD, you can use a variadic macro (with __VA_ARGS__ if needed).
// In the above example, only CTYPE is used to generate the code, it can be rewritten:
/*
switch (type) {
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
case BASE_TYPE_ ## ENUM: \
// do something specific to CTYPE here
FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
#undef FLATBUFFERS_TD
}
*/
#define FLATBUFFERS_GEN_TYPES(TD) \
FLATBUFFERS_GEN_TYPES_SCALAR(TD) \
FLATBUFFERS_GEN_TYPES_POINTER(TD) \
...
...
@@ -101,17 +115,15 @@ switch (type) {
__extension__
// Stop GCC complaining about trailing comma with -Wpendantic.
#endif
enum
BaseType
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, \
RTYPE, KTYPE) \
BASE_TYPE_ ## ENUM,
#define FLATBUFFERS_TD(ENUM, ...) \
BASE_TYPE_ ## ENUM,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
};
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, \
RTYPE, KTYPE) \
static_assert(sizeof(CTYPE) <= sizeof(largest_scalar_t), \
"define largest_scalar_t as " #CTYPE);
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
static_assert(sizeof(CTYPE) <= sizeof(largest_scalar_t), \
"define largest_scalar_t as " #CTYPE);
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
...
...
src/idl_gen_cpp.cpp
View file @
075e8d67
...
...
@@ -545,11 +545,10 @@ class CppGenerator : public BaseGenerator {
std
::
string
GenTypeBasic
(
const
Type
&
type
,
bool
user_facing_type
)
const
{
// clang-format off
static
const
char
*
const
ctypename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, \
RTYPE, KTYPE) \
#CTYPE,
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
#CTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
#undef FLATBUFFERS_TD
};
// clang-format on
if
(
user_facing_type
)
{
...
...
src/idl_gen_csharp.cpp
View file @
075e8d67
...
...
@@ -119,11 +119,10 @@ class CSharpGenerator : public BaseGenerator {
std
::
string
GenTypeBasic
(
const
Type
&
type
,
bool
enableLangOverrides
)
const
{
// clang-format off
static
const
char
*
const
csharp_typename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, ...) \
#NTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
};
// clang-format on
...
...
src/idl_gen_go.cpp
View file @
075e8d67
...
...
@@ -1162,15 +1162,14 @@ class GoGenerator : public BaseGenerator {
}
std
::
string
GenTypeBasic
(
const
Type
&
type
)
{
static
const
char
*
ctypename
[]
=
{
// clang-format off
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE
) \
static
const
char
*
ctypename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, ...
) \
#GTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// clang-format on
};
// clang-format on
return
ctypename
[
type
.
base_type
];
}
...
...
src/idl_gen_java.cpp
View file @
075e8d67
...
...
@@ -142,15 +142,13 @@ class JavaGenerator : public BaseGenerator {
std
::
string
GenTypeBasic
(
const
Type
&
type
)
const
{
// clang-format off
static
const
char
*
const
java_typename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
static
const
char
*
const
java_typename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, ...) \
#JTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
};
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
};
// clang-format on
return
java_typename
[
type
.
base_type
];
}
...
...
src/idl_gen_kotlin.cpp
View file @
075e8d67
...
...
@@ -139,14 +139,14 @@ class KotlinGenerator : public BaseGenerator {
static
std
::
string
GenTypeBasic
(
const
BaseType
&
type
)
{
// clang-format off
static
const
char
*
const
kotlin_typename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#KTYPE,
static
const
char
*
const
kotlin_typename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#KTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// clang-format on
#undef FLATBUFFERS_TD
};
// clang-format on
return
kotlin_typename
[
type
];
}
...
...
src/idl_gen_lobster.cpp
View file @
075e8d67
...
...
@@ -83,15 +83,15 @@ class LobsterGenerator : public BaseGenerator {
// This uses Python names for now..
std
::
string
GenTypeBasic
(
const
Type
&
type
)
{
static
const
char
*
ctypename
[]
=
{
// clang-format off
static
const
char
*
ctypename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE
) \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, ...
) \
#PTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// clang-format on
};
// clang-format on
return
ctypename
[
type
.
base_type
];
}
...
...
src/idl_gen_lua.cpp
View file @
075e8d67
...
...
@@ -595,15 +595,15 @@ class LuaGenerator : public BaseGenerator {
}
std
::
string
GenTypeBasic
(
const
Type
&
type
)
{
static
const
char
*
ctypename
[]
=
{
// clang-format off
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE)
\
#PTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// clang-format on
static
const
char
*
ctypename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE,
\
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, ...) \
#PTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
};
// clang-format on
return
ctypename
[
type
.
base_type
];
}
...
...
src/idl_gen_php.cpp
View file @
075e8d67
...
...
@@ -860,15 +860,15 @@ class PhpGenerator : public BaseGenerator {
}
static
std
::
string
GenTypeBasic
(
const
Type
&
type
)
{
static
const
char
*
ctypename
[]
=
{
// clang-format off
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE)
\
#NTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// clang-format on
static
const
char
*
ctypename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE,
\
CTYPE, JTYPE, GTYPE, NTYPE, ...) \
#NTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
};
// clang-format on
return
ctypename
[
type
.
base_type
];
}
...
...
src/idl_gen_python.cpp
View file @
075e8d67
...
...
@@ -667,15 +667,15 @@ class PythonGenerator : public BaseGenerator {
}
std
::
string
GenTypeBasic
(
const
Type
&
type
)
{
static
const
char
*
ctypename
[]
=
{
// clang-format off
static
const
char
*
ctypename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE
) \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, ...
) \
#PTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// clang-format on
};
// clang-format on
return
ctypename
[
IsArray
(
type
)
?
type
.
VectorType
().
base_type
:
type
.
base_type
];
}
...
...
src/idl_gen_rust.cpp
View file @
075e8d67
...
...
@@ -457,12 +457,12 @@ class RustGenerator : public BaseGenerator {
// clang-format off
static
const
char
*
const
ctypename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, \
RTYPE,
KTYPE
) \
#RTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
RTYPE,
...
) \
#RTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// clang-format on
};
// clang-format on
if
(
type
.
enum_def
)
{
return
WrapInNameSpace
(
*
type
.
enum_def
);
}
return
ctypename
[
type
.
base_type
];
...
...
@@ -476,15 +476,15 @@ class RustGenerator : public BaseGenerator {
FLATBUFFERS_ASSERT
(
false
&&
"precondition failed in GetEnumTypeForDecl"
);
}
static
const
char
*
ctypename
[]
=
{
// clang-format off
static
const
char
*
ctypename
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, \
RTYPE,
KTYPE
) \
#RTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
RTYPE,
...
) \
#RTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// clang-format on
};
// clang-format on
// Enums can be bools, but their Rust representation must be a u8, as used
// in the repr attribute (#[repr(bool)] is an invalid attribute).
...
...
src/idl_gen_text.cpp
View file @
075e8d67
...
...
@@ -167,8 +167,7 @@ bool Print<const void *>(const void *val, Type type, int indent,
// Call PrintVector above specifically for each element type:
// clang-format off
switch
(
vec_type
.
base_type
)
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
case BASE_TYPE_ ## ENUM: \
if (!PrintVector<CTYPE>( \
*reinterpret_cast<const Vector<CTYPE> *>(val), \
...
...
@@ -187,8 +186,7 @@ bool Print<const void *>(const void *val, Type type, int indent,
// Call PrintArray above specifically for each element type:
// clang-format off
switch
(
vec_type
.
base_type
)
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
case BASE_TYPE_ ## ENUM: \
if (!PrintArray<CTYPE>( \
*reinterpret_cast<const Array<CTYPE, 0xFFFF> *>(val), \
...
...
@@ -198,6 +196,7 @@ bool Print<const void *>(const void *val, Type type, int indent,
} \
break;
FLATBUFFERS_GEN_TYPES_SCALAR
(
FLATBUFFERS_TD
)
// Arrays of scalars or structs are only possible.
FLATBUFFERS_GEN_TYPES_POINTER
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
case
BASE_TYPE_ARRAY
:
FLATBUFFERS_ASSERT
(
0
);
...
...
@@ -286,19 +285,17 @@ static bool GenStruct(const StructDef &struct_def, const Table *table,
text
+=
" "
;
switch
(
fd
.
value
.
type
.
base_type
)
{
// clang-format off
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
case BASE_TYPE_ ## ENUM: \
if (!GenField<CTYPE>(fd, table, struct_def.fixed, \
opts, indent + Indent(opts), _text)) { \
return false; \
} \
break;
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
case BASE_TYPE_ ## ENUM: \
if (!GenField<CTYPE>(fd, table, struct_def.fixed, \
opts, indent + Indent(opts), _text)) { \
return false; \
} \
break;
FLATBUFFERS_GEN_TYPES_SCALAR
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// Generate drop-thru case statements for all pointer types:
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, ...) \
case BASE_TYPE_ ## ENUM:
FLATBUFFERS_GEN_TYPES_POINTER
(
FLATBUFFERS_TD
)
FLATBUFFERS_GEN_TYPE_ARRAY
(
FLATBUFFERS_TD
)
...
...
src/idl_parser.cpp
View file @
075e8d67
...
...
@@ -37,26 +37,22 @@ const char *FLATBUFFERS_VERSION() {
const
double
kPi
=
3.14159265358979323846
;
const
char
*
const
kTypeNames
[]
=
{
// clang-format off
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE
) \
const
char
*
const
kTypeNames
[]
=
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, ...
) \
IDLTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// clang-format on
nullptr
};
const
char
kTypeSizes
[]
=
{
// clang-format off
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
sizeof(CTYPE),
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
sizeof(CTYPE),
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
// clang-format on
};
// clang-format on
// The enums in the reflection schema should match the ones we use internally.
// Compare the last element to check if these go out of sync.
...
...
@@ -222,8 +218,7 @@ static std::string TokenToString(int t) {
#define FLATBUFFERS_TOKEN(NAME, VALUE, STRING) STRING,
FLATBUFFERS_GEN_TOKENS
(
FLATBUFFERS_TOKEN
)
#undef FLATBUFFERS_TOKEN
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, ...) \
IDLTYPE,
FLATBUFFERS_GEN_TYPES
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
...
...
@@ -1179,8 +1174,7 @@ CheckedError Parser::ParseTable(const StructDef &struct_def, std::string *value,
size
==
SizeOf
(
field_value
.
type
.
base_type
))
{
switch
(
field_value
.
type
.
base_type
)
{
// clang-format off
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
case BASE_TYPE_ ## ENUM: \
builder_.Pad(field->padding); \
if (struct_def.fixed) { \
...
...
@@ -1194,10 +1188,9 @@ CheckedError Parser::ParseTable(const StructDef &struct_def, std::string *value,
builder_.AddElement(field_value.offset, val, valdef); \
} \
break;
FLATBUFFERS_GEN_TYPES_SCALAR
(
FLATBUFFERS_TD
)
;
FLATBUFFERS_GEN_TYPES_SCALAR
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
case BASE_TYPE_ ## ENUM: \
builder_.Pad(field->padding); \
if (IsStruct(field->value.type)) { \
...
...
@@ -1208,7 +1201,7 @@ CheckedError Parser::ParseTable(const StructDef &struct_def, std::string *value,
builder_.AddOffset(field_value.offset, val); \
} \
break;
FLATBUFFERS_GEN_TYPES_POINTER
(
FLATBUFFERS_TD
)
;
FLATBUFFERS_GEN_TYPES_POINTER
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
case
BASE_TYPE_ARRAY
:
builder_
.
Pad
(
field
->
padding
);
...
...
@@ -1258,8 +1251,7 @@ CheckedError Parser::ParseVectorDelimiters(uoffset_t &count, F body) {
static
bool
CompareType
(
const
uint8_t
*
a
,
const
uint8_t
*
b
,
BaseType
ftype
)
{
switch
(
ftype
)
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, \
RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
case BASE_TYPE_##ENUM: return ReadScalar<CTYPE>(a) < ReadScalar<CTYPE>(b);
FLATBUFFERS_GEN_TYPES_SCALAR
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
...
...
@@ -1314,8 +1306,7 @@ CheckedError Parser::ParseVector(const Type &type, uoffset_t *ovalue,
auto
&
val
=
field_stack_
.
back
().
first
;
switch
(
val
.
type
.
base_type
)
{
// clang-format off
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE,...) \
case BASE_TYPE_ ## ENUM: \
if (IsStruct(val.type)) SerializeStruct(*val.type.struct_def, val); \
else { \
...
...
@@ -1429,8 +1420,7 @@ CheckedError Parser::ParseArray(Value &array) {
auto
&
val
=
*
it
;
// clang-format off
switch
(
val
.
type
.
base_type
)
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
case BASE_TYPE_ ## ENUM: \
if (IsStruct(val.type)) { \
SerializeStruct(builder, *val.type.struct_def, val); \
...
...
@@ -1782,14 +1772,13 @@ CheckedError Parser::ParseSingleValue(const std::string *name, Value &e,
if
(
check_now
&&
IsScalar
(
match_type
))
{
// clang-format off
switch
(
match_type
)
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
case BASE_TYPE_ ## ENUM: {\
CTYPE val; \
ECHECK(atot(e.constant.c_str(), *this, &val)); \
SingleValueRepack(e, val); \
break; }
FLATBUFFERS_GEN_TYPES_SCALAR
(
FLATBUFFERS_TD
);
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
case BASE_TYPE_ ## ENUM: {\
CTYPE val; \
ECHECK(atot(e.constant.c_str(), *this, &val)); \
SingleValueRepack(e, val); \
break; }
FLATBUFFERS_GEN_TYPES_SCALAR
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
default
:
break
;
}
...
...
@@ -2018,13 +2007,12 @@ struct EnumValBuilder {
FLATBUFFERS_CHECKED_ERROR
ValidateValue
(
int64_t
*
ev
,
bool
next
)
{
// clang-format off
switch
(
enum_def
.
underlying_type
.
base_type
)
{
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, \
PTYPE, RTYPE, KTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, ...) \
case BASE_TYPE_##ENUM: { \
if (!IsInteger(BASE_TYPE_##ENUM)) break; \
return ValidateImpl<BASE_TYPE_##ENUM, CTYPE>(ev, next ? 1 : 0); \
}
FLATBUFFERS_GEN_TYPES_SCALAR
(
FLATBUFFERS_TD
)
;
FLATBUFFERS_GEN_TYPES_SCALAR
(
FLATBUFFERS_TD
)
#undef FLATBUFFERS_TD
default
:
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment