Add scalar type aliases for int8, uint8, ..., f32, f64 (#4400)

* Add type aliases

* Add generated code

* Rebase master
This commit is contained in:
MikkelFJ
2017-08-02 17:07:43 +02:00
committed by Wouter van Oortmerssen
parent 3282a84e30
commit f2b3705c2c
21 changed files with 2461 additions and 65 deletions

View File

@@ -135,8 +135,8 @@ template<> bool Print<const void *>(const void *val,
type = type.VectorType();
// Call PrintVector above specifically for each element type:
switch (type.base_type) {
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, \
PTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, ALIASTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \
case BASE_TYPE_ ## ENUM: \
if (!PrintVector<CTYPE>( \
*reinterpret_cast<const Vector<CTYPE> *>(val), \
@@ -226,8 +226,8 @@ static bool GenStruct(const StructDef &struct_def, const Table *table,
text += " ";
if (is_present) {
switch (fd.value.type.base_type) {
#define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE, \
PTYPE) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, ALIASTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \
case BASE_TYPE_ ## ENUM: \
if (!GenField<CTYPE>(fd, table, struct_def.fixed, \
opts, indent + Indent(opts), _text)) { \
@@ -237,8 +237,8 @@ static bool GenStruct(const StructDef &struct_def, const Table *table,
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) \
#define FLATBUFFERS_TD(ENUM, IDLTYPE, ALIASTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE) \
case BASE_TYPE_ ## ENUM:
FLATBUFFERS_GEN_TYPES_POINTER(FLATBUFFERS_TD)
#undef FLATBUFFERS_TD