summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/idl_gen_lobster.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/idl_gen_lobster.cpp b/src/idl_gen_lobster.cpp
index 6f1ce565..0487d17a 100644
--- a/src/idl_gen_lobster.cpp
+++ b/src/idl_gen_lobster.cpp
@@ -116,7 +116,7 @@ class LobsterGenerator : public BaseGenerator {
if (struct_def.fixed) {
code += name + "{ buf_, pos_ + " + offsets + " }\n";
} else {
- code += std::string("o := buf_.flatbuffers_field_") +
+ code += std::string("o := buf_.flatbuffers_field_") +
(field.value.type.struct_def->fixed ? "struct" : "table") +
"(pos_, " + offsets + ")\n if o: " + name +
" { buf_, o } else: nil\n";
@@ -149,11 +149,15 @@ class LobsterGenerator : public BaseGenerator {
break;
}
case BASE_TYPE_UNION: {
- for (auto &ev : field.value.type.enum_def->vals.vec) if (ev->value) {
- code += def + "_as_" + ev->name + "():\n " +
- NamespacedName(*ev->union_type.struct_def) +
- " { buf_, buf_.flatbuffers_field_table(pos_, " + offsets +
- ") }\n";
+ for (auto it = field.value.type.enum_def->vals.vec.begin();
+ it != field.value.type.enum_def->vals.vec.end(); ++it) {
+ auto &ev = **it;
+ if (ev.value) {
+ code += def + "_as_" + ev.name + "():\n " +
+ NamespacedName(*ev.union_type.struct_def) +
+ " { buf_, buf_.flatbuffers_field_table(pos_, " + offsets +
+ ") }\n";
+ }
}
break;
}
@@ -293,7 +297,7 @@ class LobsterGenerator : public BaseGenerator {
void StructBuilderBody(const StructDef &struct_def,
const char *nameprefix, std::string *code_ptr) {
std::string &code = *code_ptr;
- code += " b_.Prep(" + NumToString(struct_def.minalign) + ", " +
+ code += " b_.Prep(" + NumToString(struct_def.minalign) + ", " +
NumToString(struct_def.bytesize) + ")\n";
for (auto it = struct_def.fields.vec.rbegin();
it != struct_def.fields.vec.rend(); ++it) {