diff options
author | mustiikhalil <mustii@mmk.one> | 2020-10-07 19:56:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-07 09:56:30 -0700 |
commit | 7b9e61fccffbaf9a673ae51f89c490508fd39670 (patch) | |
tree | e3a985a85a0cb8e10f06b026bc0d52d1f4dd1fa8 /src/idl_gen_cpp.cpp | |
parent | 3359e3042fd1dd947c4093b90ecce24d1839fbdd (diff) | |
download | flatbuffers-7b9e61fccffbaf9a673ae51f89c490508fd39670.tar.gz flatbuffers-7b9e61fccffbaf9a673ae51f89c490508fd39670.tar.bz2 flatbuffers-7b9e61fccffbaf9a673ae51f89c490508fd39670.zip |
[TS] GRPC Implementation (#6141)
* GRPC implementation for Typescript
* Fixes a couple of issues
* Finished implementing the typescript support for grpc
* Updated generated code
* Fixes CI
Diffstat (limited to 'src/idl_gen_cpp.cpp')
-rw-r--r-- | src/idl_gen_cpp.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 9cb01696..f6535f0c 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -1714,9 +1714,7 @@ class CppGenerator : public BaseGenerator { auto native_default = field.attributes.Lookup("native_default"); // Scalar types get parsed defaults, raw pointers get nullptrs. if (IsScalar(field.value.type.base_type)) { - if (!initializer_list.empty()) { - initializer_list += ",\n "; - } + if (!initializer_list.empty()) { initializer_list += ",\n "; } initializer_list += Name(field); initializer_list += "(" + @@ -1992,8 +1990,7 @@ class CppGenerator : public BaseGenerator { code_ += " {{FIELD_TYPE}}{{FIELD_NAME}}() const {"; code_ += " return {{FIELD_VALUE}};"; code_ += " }"; - } - else { + } else { auto wire_type = GenTypeBasic(type, false); auto face_type = GenTypeBasic(type, true); auto opt_value = "GetOptional<" + wire_type + ", " + face_type + ">(" + @@ -2011,7 +2008,7 @@ class CppGenerator : public BaseGenerator { const auto &type = field.value.type; const bool is_scalar = IsScalar(type.base_type); if (is_scalar && IsUnion(type)) - return; // changing of a union's type is forbidden + return; // changing of a union's type is forbidden auto offset_str = GenFieldOffsetName(field); if (is_scalar) { @@ -2109,9 +2106,7 @@ class CppGenerator : public BaseGenerator { code_.SetValue("FIELD_NAME", Name(field)); GenTableFieldGetter(field); - if (opts_.mutable_buffer) { - GenTableFieldSetter(field); - } + if (opts_.mutable_buffer) { GenTableFieldSetter(field); } auto nested = field.attributes.Lookup("nested_flatbuffer"); if (nested) { @@ -2252,8 +2247,7 @@ class CppGenerator : public BaseGenerator { for (auto it = struct_def.fields.vec.begin(); it != struct_def.fields.vec.end(); ++it) { const auto &field = **it; - if (field.deprecated) - continue; + if (field.deprecated) continue; const bool is_scalar = IsScalar(field.value.type.base_type); const bool is_default_scalar = is_scalar && !field.IsScalarOptional(); const bool is_string = field.value.type.base_type == BASE_TYPE_STRING; @@ -2813,15 +2807,17 @@ class CppGenerator : public BaseGenerator { code_ += "inline " + TableUnPackSignature(struct_def, false, opts_) + " {"; - if(opts_.g_cpp_std == cpp::CPP_STD_X0) { + if (opts_.g_cpp_std == cpp::CPP_STD_X0) { auto native_name = NativeName(WrapInNameSpace(struct_def), &struct_def, parser_.opts); code_.SetValue("POINTER_TYPE", GenTypeNativePtr(native_name, nullptr, false)); code_ += " {{POINTER_TYPE}} _o = {{POINTER_TYPE}}(new {{NATIVE_NAME}}());"; - } else if(opts_.g_cpp_std == cpp::CPP_STD_11) { - code_ += " auto _o = std::unique_ptr<{{NATIVE_NAME}}>(new {{NATIVE_NAME}}());"; + } else if (opts_.g_cpp_std == cpp::CPP_STD_11) { + code_ += + " auto _o = std::unique_ptr<{{NATIVE_NAME}}>(new " + "{{NATIVE_NAME}}());"; } else { code_ += " auto _o = std::make_unique<{{NATIVE_NAME}}>();"; } @@ -2958,8 +2954,7 @@ class CppGenerator : public BaseGenerator { int padding_initializer_id = 0; int padding_body_id = 0; for (auto it = struct_def.fields.vec.begin(); - it != struct_def.fields.vec.end(); - ++it) { + it != struct_def.fields.vec.end(); ++it) { const auto field = *it; const auto field_name = field->name + "_"; |