[Nim] Bfbs Nim Generator (#7534)

* Bfbs Nim Generator

* Remove commented out tests

* add missing line to idl.h

* Commit python reflection changes

* Commit python reflection changes and move tests

* Remove default string addition

* Move tests to python file

* Fix element size check when element is table

* remove whitespace changes

* add element_type docs and commit further to namer and remove kkeep

* Bfbs Nim Generator

* Remove commented out tests

* add missing line to idl.h

* Commit python reflection changes

* Commit python reflection changes and move tests

* Remove default string addition

* Move tests to python file

* Fix element size check when element is table

* remove whitespace changes

* add element_type docs and commit further to namer and remove kkeep

* remove unused variables

* added tests to ci

* added tests to ci

* fixes

* Added reflection type Field, Variable to namer

* Moved reflection namer impl to bfbsnamer

* Remove whitespace at end of line

* Added nim to generated code

* Revert whitespace removal

Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
Dan Lapid
2022-10-21 21:30:04 +03:00
committed by GitHub
parent e301702964
commit 872a497464
57 changed files with 3344 additions and 34 deletions

View File

@@ -175,7 +175,7 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
// Skip writing deprecated fields altogether.
if (field->deprecated()) { return; }
const std::string field_name = namer_.Field(field->name()->str());
const std::string field_name = namer_.Field(*field);
const r::BaseType base_type = field->type()->base_type();
// Generate some fixed strings so we don't repeat outselves later.
@@ -367,9 +367,8 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
ForAllFields(object, /*reverse=*/false, [&](const r::Field *field) {
if (field->deprecated()) { return; }
const std::string field_name = namer_.Field(field->name()->str());
const std::string variable_name =
namer_.Variable(field->name()->str());
const std::string field_name = namer_.Field(*field);
const std::string variable_name = namer_.Variable(*field);
code += "function " + object_name + ".Add" + field_name +
"(builder, " + variable_name + ")\n";
@@ -428,9 +427,9 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
if (IsStructOrTable(field->type()->base_type())) {
const r::Object *field_object = GetObject(field->type());
signature += GenerateStructBuilderArgs(
field_object, prefix + namer_.Variable(field->name()->str()) + "_");
field_object, prefix + namer_.Variable(*field) + "_");
} else {
signature += ", " + prefix + namer_.Variable(field->name()->str());
signature += ", " + prefix + namer_.Variable(*field);
}
});
return signature;
@@ -451,11 +450,11 @@ class LuaBfbsGenerator : public BaseBfbsGenerator {
}
if (IsStructOrTable(field->type()->base_type())) {
const r::Object *field_object = GetObject(field->type());
code += AppendStructBuilderBody(
field_object, prefix + namer_.Variable(field->name()->str()) + "_");
code += AppendStructBuilderBody(field_object,
prefix + namer_.Variable(*field) + "_");
} else {
code += " builder:Prepend" + GenerateMethod(field) + "(" + prefix +
namer_.Variable(field->name()->str()) + ")\n";
namer_.Variable(*field) + ")\n";
}
});