summaryrefslogtreecommitdiff
path: root/src/idl_gen_lobster.cpp
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2018-08-06 12:06:59 -0700
committerWouter van Oortmerssen <aardappel@gmail.com>2018-08-06 12:06:59 -0700
commitfc3ce7d1ab908115e7e59cbea9ddc2e55a97286f (patch)
treeb8829afa38902e7641f09081794eca035492fce5 /src/idl_gen_lobster.cpp
parent4898809eca4c01a0bc51f31044ab2ffd1408350b (diff)
downloadflatbuffers-fc3ce7d1ab908115e7e59cbea9ddc2e55a97286f.tar.gz
flatbuffers-fc3ce7d1ab908115e7e59cbea9ddc2e55a97286f.tar.bz2
flatbuffers-fc3ce7d1ab908115e7e59cbea9ddc2e55a97286f.zip
Fixed VS2010 compile error.
Change-Id: Ibd970d30b51f77a2ac9c125e400c9f1b19a81cbc
Diffstat (limited to 'src/idl_gen_lobster.cpp')
-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) {