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
a4f9d1bf
Commit
a4f9d1bf
authored
Oct 08, 2018
by
Michael Edwards
Committed by
Wouter van Oortmerssen
Oct 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix expected type of enum values in reflection tables (#4944)
Fixes #4930
parent
a4c362a1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
15 deletions
+15
-15
flatbuffers.h
include/flatbuffers/flatbuffers.h
+1
-1
minireflect.h
include/flatbuffers/minireflect.h
+5
-5
monster_generated.h
samples/monster_generated.h
+1
-1
idl_gen_cpp.cpp
src/idl_gen_cpp.cpp
+1
-1
monster_test_generated.h
tests/monster_test_generated.h
+4
-4
namespace_test1_generated.h
tests/namespace_test/namespace_test1_generated.h
+1
-1
union_vector_generated.h
tests/union_vector/union_vector_generated.h
+2
-2
No files found.
include/flatbuffers/flatbuffers.h
View file @
a4f9d1bf
...
...
@@ -2470,7 +2470,7 @@ struct TypeTable {
size_t
num_elems
;
// of type_codes, values, names (but not type_refs).
const
TypeCode
*
type_codes
;
// num_elems count
const
TypeFunction
*
type_refs
;
// less than num_elems entries (see TypeCode).
const
int
32
_t
*
values
;
// Only set for non-consecutive enum/union or structs.
const
int
64
_t
*
values
;
// Only set for non-consecutive enum/union or structs.
const
char
*
const
*
names
;
// Only set if compiled with --reflect-names.
};
...
...
include/flatbuffers/minireflect.h
View file @
a4f9d1bf
...
...
@@ -88,27 +88,27 @@ inline size_t InlineSize(ElementaryType type, const TypeTable *type_table) {
switch
(
type_table
->
st
)
{
case
ST_TABLE
:
case
ST_UNION
:
return
4
;
case
ST_STRUCT
:
return
type_table
->
values
[
type_table
->
num_elems
]
;
case
ST_STRUCT
:
return
static_cast
<
size_t
>
(
type_table
->
values
[
type_table
->
num_elems
])
;
default:
FLATBUFFERS_ASSERT
(
false
);
return
1
;
}
default:
FLATBUFFERS_ASSERT
(
false
);
return
1
;
}
}
inline
int
32_t
LookupEnum
(
int32_t
enum_val
,
const
int32
_t
*
values
,
inline
int
64_t
LookupEnum
(
int64_t
enum_val
,
const
int64
_t
*
values
,
size_t
num_values
)
{
if
(
!
values
)
return
enum_val
;
for
(
size_t
i
=
0
;
i
<
num_values
;
i
++
)
{
if
(
enum_val
==
values
[
i
])
return
static_cast
<
int
32
_t
>
(
i
);
if
(
enum_val
==
values
[
i
])
return
static_cast
<
int
64
_t
>
(
i
);
}
return
-
1
;
// Unknown enum value.
}
template
<
typename
T
>
const
char
*
EnumName
(
T
tval
,
const
TypeTable
*
type_table
)
{
if
(
!
type_table
||
!
type_table
->
names
)
return
nullptr
;
auto
i
=
LookupEnum
(
static_cast
<
int
32
_t
>
(
tval
),
type_table
->
values
,
auto
i
=
LookupEnum
(
static_cast
<
int
64
_t
>
(
tval
),
type_table
->
values
,
type_table
->
num_elems
);
if
(
i
>=
0
&&
i
<
static_cast
<
int
32
_t
>
(
type_table
->
num_elems
))
{
if
(
i
>=
0
&&
i
<
static_cast
<
int
64
_t
>
(
type_table
->
num_elems
))
{
return
type_table
->
names
[
i
];
}
return
nullptr
;
...
...
samples/monster_generated.h
View file @
a4f9d1bf
...
...
@@ -704,7 +704,7 @@ inline const flatbuffers::TypeTable *Vec3TypeTable() {
{
flatbuffers
::
ET_FLOAT
,
0
,
-
1
},
{
flatbuffers
::
ET_FLOAT
,
0
,
-
1
}
};
static
const
int
32
_t
values
[]
=
{
0
,
4
,
8
,
12
};
static
const
int
64
_t
values
[]
=
{
0
,
4
,
8
,
12
};
static
const
char
*
const
names
[]
=
{
"x"
,
"y"
,
...
...
src/idl_gen_cpp.cpp
View file @
a4f9d1bf
...
...
@@ -863,7 +863,7 @@ class CppGenerator : public BaseGenerator {
code_
+=
" };"
;
}
if
(
!
vs
.
empty
())
{
code_
+=
" static const int
32
_t values[] = { {{VALUES}} };"
;
code_
+=
" static const int
64
_t values[] = { {{VALUES}} };"
;
}
auto
has_names
=
num_fields
&&
parser_
.
opts
.
mini_reflect
==
IDLOptions
::
kTypesAndNames
;
...
...
tests/monster_test_generated.h
View file @
a4f9d1bf
...
...
@@ -2358,7 +2358,7 @@ inline const flatbuffers::TypeTable *ColorTypeTable() {
static
const
flatbuffers
::
TypeFunction
type_refs
[]
=
{
ColorTypeTable
};
static
const
int
32
_t
values
[]
=
{
1
,
2
,
8
};
static
const
int
64
_t
values
[]
=
{
1
,
2
,
8
};
static
const
char
*
const
names
[]
=
{
"Red"
,
"Green"
,
...
...
@@ -2421,7 +2421,7 @@ inline const flatbuffers::TypeTable *TestTypeTable() {
{
flatbuffers
::
ET_SHORT
,
0
,
-
1
},
{
flatbuffers
::
ET_CHAR
,
0
,
-
1
}
};
static
const
int
32
_t
values
[]
=
{
0
,
2
,
4
};
static
const
int
64
_t
values
[]
=
{
0
,
2
,
4
};
static
const
char
*
const
names
[]
=
{
"a"
,
"b"
...
...
@@ -2461,7 +2461,7 @@ inline const flatbuffers::TypeTable *Vec3TypeTable() {
ColorTypeTable
,
TestTypeTable
};
static
const
int
32
_t
values
[]
=
{
0
,
4
,
8
,
16
,
24
,
26
,
32
};
static
const
int
64
_t
values
[]
=
{
0
,
4
,
8
,
16
,
24
,
26
,
32
};
static
const
char
*
const
names
[]
=
{
"x"
,
"y"
,
...
...
@@ -2481,7 +2481,7 @@ inline const flatbuffers::TypeTable *AbilityTypeTable() {
{
flatbuffers
::
ET_UINT
,
0
,
-
1
},
{
flatbuffers
::
ET_UINT
,
0
,
-
1
}
};
static
const
int
32
_t
values
[]
=
{
0
,
4
,
8
};
static
const
int
64
_t
values
[]
=
{
0
,
4
,
8
};
static
const
char
*
const
names
[]
=
{
"id"
,
"distance"
...
...
tests/namespace_test/namespace_test1_generated.h
View file @
a4f9d1bf
...
...
@@ -161,7 +161,7 @@ inline const flatbuffers::TypeTable *StructInNestedNSTypeTable() {
{
flatbuffers
::
ET_INT
,
0
,
-
1
},
{
flatbuffers
::
ET_INT
,
0
,
-
1
}
};
static
const
int
32
_t
values
[]
=
{
0
,
4
,
8
};
static
const
int
64
_t
values
[]
=
{
0
,
4
,
8
};
static
const
char
*
const
names
[]
=
{
"a"
,
"b"
...
...
tests/union_vector/union_vector_generated.h
View file @
a4f9d1bf
...
...
@@ -718,7 +718,7 @@ inline const flatbuffers::TypeTable *RapunzelTypeTable() {
static
const
flatbuffers
::
TypeCode
type_codes
[]
=
{
{
flatbuffers
::
ET_INT
,
0
,
-
1
}
};
static
const
int
32
_t
values
[]
=
{
0
,
4
};
static
const
int
64
_t
values
[]
=
{
0
,
4
};
static
const
char
*
const
names
[]
=
{
"hair_length"
};
...
...
@@ -732,7 +732,7 @@ inline const flatbuffers::TypeTable *BookReaderTypeTable() {
static
const
flatbuffers
::
TypeCode
type_codes
[]
=
{
{
flatbuffers
::
ET_INT
,
0
,
-
1
}
};
static
const
int
32
_t
values
[]
=
{
0
,
4
};
static
const
int
64
_t
values
[]
=
{
0
,
4
};
static
const
char
*
const
names
[]
=
{
"books_read"
};
...
...
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