Fixed VS2010 build

This commit is contained in:
Wouter van Oortmerssen 2016-07-20 18:13:11 -07:00
parent 05b00c50ad
commit bdd668df7b
3 changed files with 9 additions and 5 deletions

View File

@ -3,7 +3,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>..\..\tests</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>-j -c -n -g --php --no-includes --gen-mutable monster_test.fbs</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>-j -c -n -g --php --no-includes --gen-mutable --gen-object-api monster_test.fbs</LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerWorkingDirectory>..\..</LocalDebuggerWorkingDirectory>

View File

@ -966,7 +966,7 @@ class CppGenerator : public BaseGenerator {
auto dest = deref + field.name;
auto assign = prefix + dest + " = ";
auto gen_unpack_val = [&](const Type &type, const std::string &val,
bool invector) {
bool invector) -> std::string {
switch (type.base_type) {
case BASE_TYPE_STRING:
return val + "->str()";
@ -987,14 +987,18 @@ class CppGenerator : public BaseGenerator {
}
};
switch (field.value.type.base_type) {
case BASE_TYPE_VECTOR:
case BASE_TYPE_VECTOR: {
code += prefix;
code += "{ for (size_t _i = 0; _i < _e->size(); _i++) { ";
code += dest + ".push_back(";
std::string indexing = "_e->Get(_i)";
if (field.value.type.element == BASE_TYPE_BOOL)
indexing += "!=0";
code += gen_unpack_val(field.value.type.VectorType(),
"_e->Get(_i)", true);
indexing, true);
code += "); } }";
break;
}
case BASE_TYPE_UTYPE: {
auto &union_field = **(it + 1);
assert(union_field.value.type.base_type == BASE_TYPE_UNION);

View File

@ -645,7 +645,7 @@ inline std::unique_ptr<MonsterT> Monster::UnPack() const {
{ auto _e = testhashu32_fnv1a(); _o->testhashu32_fnv1a = _e; };
{ auto _e = testhashs64_fnv1a(); _o->testhashs64_fnv1a = _e; };
{ auto _e = testhashu64_fnv1a(); _o->testhashu64_fnv1a = _e; };
{ auto _e = testarrayofbools(); if (_e) { for (size_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools.push_back(_e->Get(_i)); } } };
{ auto _e = testarrayofbools(); if (_e) { for (size_t _i = 0; _i < _e->size(); _i++) { _o->testarrayofbools.push_back(_e->Get(_i)!=0); } } };
{ auto _e = testf(); _o->testf = _e; };
{ auto _e = testf2(); _o->testf2 = _e; };
{ auto _e = testf3(); _o->testf3 = _e; };