mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 22:31:38 +00:00
idl_gen_cpp.cpp: clang-format run, to better separate changes in content from formatting.
This commit is contained in:
@@ -43,7 +43,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
float_const_gen_("std::numeric_limits<double>::",
|
float_const_gen_("std::numeric_limits<double>::",
|
||||||
"std::numeric_limits<float>::", "quiet_NaN()",
|
"std::numeric_limits<float>::", "quiet_NaN()",
|
||||||
"infinity()") {
|
"infinity()") {
|
||||||
static const char * const keywords[] = {
|
static const char *const keywords[] = {
|
||||||
"alignas",
|
"alignas",
|
||||||
"alignof",
|
"alignof",
|
||||||
"and",
|
"and",
|
||||||
@@ -139,7 +139,8 @@ class CppGenerator : public BaseGenerator {
|
|||||||
"while",
|
"while",
|
||||||
"xor",
|
"xor",
|
||||||
"xor_eq",
|
"xor_eq",
|
||||||
nullptr };
|
nullptr,
|
||||||
|
};
|
||||||
for (auto kw = keywords; *kw; kw++) keywords_.insert(*kw);
|
for (auto kw = keywords; *kw; kw++) keywords_.insert(*kw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,8 +495,8 @@ 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 * const 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, \
|
||||||
RTYPE) \
|
RTYPE) \
|
||||||
#CTYPE,
|
#CTYPE,
|
||||||
@@ -581,8 +582,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
bool is_constructor) {
|
bool is_constructor) {
|
||||||
auto &ptr_type = PtrType(field);
|
auto &ptr_type = PtrType(field);
|
||||||
if (ptr_type != "naked") {
|
if (ptr_type != "naked") {
|
||||||
return (ptr_type != "default_ptr_type" ? ptr_type :
|
return (ptr_type != "default_ptr_type" ? ptr_type : parser_.opts.cpp_object_api_pointer_type) + "<" + type + ">";
|
||||||
parser_.opts.cpp_object_api_pointer_type) + "<" + type + ">";
|
|
||||||
} else if (is_constructor) {
|
} else if (is_constructor) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
@@ -1395,7 +1395,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string GenDefaultConstant(const FieldDef &field) {
|
std::string GenDefaultConstant(const FieldDef &field) {
|
||||||
if(IsFloat(field.value.type.base_type))
|
if (IsFloat(field.value.type.base_type))
|
||||||
return float_const_gen_.GenFloatConstant(field);
|
return float_const_gen_.GenFloatConstant(field);
|
||||||
else
|
else
|
||||||
return field.value.constant;
|
return field.value.constant;
|
||||||
@@ -1706,7 +1706,6 @@ class CppGenerator : public BaseGenerator {
|
|||||||
code_ += " }";
|
code_ += " }";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GenFullyQualifiedNameGetter(struct_def, Name(struct_def));
|
GenFullyQualifiedNameGetter(struct_def, Name(struct_def));
|
||||||
|
|
||||||
// Generate field id constants.
|
// Generate field id constants.
|
||||||
@@ -2064,7 +2063,8 @@ class CppGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
// Generate a CreateXDirect function with vector types as parameters
|
// Generate a CreateXDirect function with vector types as parameters
|
||||||
if (has_string_or_vector_fields) {
|
if (has_string_or_vector_fields) {
|
||||||
code_ += "inline flatbuffers::Offset<{{STRUCT_NAME}}> "
|
code_ +=
|
||||||
|
"inline flatbuffers::Offset<{{STRUCT_NAME}}> "
|
||||||
"Create{{STRUCT_NAME}}Direct(";
|
"Create{{STRUCT_NAME}}Direct(";
|
||||||
code_ += " flatbuffers::FlatBufferBuilder &_fbb\\";
|
code_ += " flatbuffers::FlatBufferBuilder &_fbb\\";
|
||||||
for (auto it = struct_def.fields.vec.begin();
|
for (auto it = struct_def.fields.vec.begin();
|
||||||
@@ -2294,7 +2294,6 @@ class CppGenerator : public BaseGenerator {
|
|||||||
type + ">((*_rehasher)(" + value + GenPtrGet(field) + ")) : 0";
|
type + ">((*_rehasher)(" + value + GenPtrGet(field) + ")) : 0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string code;
|
std::string code;
|
||||||
switch (field.value.type.base_type) {
|
switch (field.value.type.base_type) {
|
||||||
// String fields are of the form:
|
// String fields are of the form:
|
||||||
|
|||||||
Reference in New Issue
Block a user