[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
This commit is contained in:
mustiikhalil
2020-10-07 19:56:30 +03:00
committed by GitHub
parent 3359e3042f
commit 7b9e61fccf
31 changed files with 1414 additions and 159 deletions

View File

@@ -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 + "_";