diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 20 | ||||
-rw-r--r-- | cpp/src/Slice/Scanner.l | 2 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 18 |
3 files changed, 34 insertions, 6 deletions
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 0c800c87ac4..79725c6f4b4 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -88,6 +88,26 @@ Slice::printVersionCheck(Output& out) } void +Slice::printDefInt64Macro(Output& out) +{ + out << "\n"; + out << "\n#if defined(_WIN32)"; + out << "\n# define INT64LITERAL(n) n##i64"; + out << "\n#elif defined(__linux__) && defined(i386)"; + out << "\n# define INT64LITERAL(n) n##LL"; + out << "\n#else"; + out << "\n# error \"Unsupported operating system or platform!\""; + out << "\n#endif"; +} + +void +Slice::printUndefInt64Macro(Output& out) +{ + out << "\n"; + out << "\n#undef INT64LITERAL"; +} + +void Slice::printDllExportStuff(Output& out, const string& dllExport) { if(dllExport.size()) diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l index 4cb68b02448..ea280da5d96 100644 --- a/cpp/src/Slice/Scanner.l +++ b/cpp/src/Slice/Scanner.l @@ -317,7 +317,7 @@ floating_literal (({fractional_constant}{exponent_part}?)|([[:digit:]]+{exponent } #else itp->v = strtoll(yytext, 0, 0); - if(errno == ERANGE) + if(errno == ERANGE && (itp->v == INT64_MIN || itp->v == INT64_MAX)) { string msg = "integer constant `"; msg += yytext; diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index db6643bf6ba..06bec36200c 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -214,6 +214,8 @@ Slice::Gen::generate(const UnitPtr& unit) _dllExport += " "; } + printDefInt64Macro(H); + ProxyDeclVisitor proxyDeclVisitor(H, C, _dllExport); unit->visit(&proxyDeclVisitor); @@ -263,6 +265,8 @@ Slice::Gen::generate(const UnitPtr& unit) ImplVisitor implVisitor(implH, implC, _dllExport); unit->visit(&implVisitor); } + + printUndefInt64Macro(H); } Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllExport) : @@ -935,11 +939,7 @@ Slice::Gen::TypesVisitor::visitConstDef(const ConstDefPtr& p) H << nl << "const " << typeToString(p->type()) << " " << p->name() << " = "; BuiltinPtr bp = BuiltinPtr::dynamicCast(p->type()); - if(bp && bp->kind() != Builtin::KindString) - { - H << p->value(); - } - else + if(bp && bp->kind() == Builtin::KindString) { // // Expand strings into the basic source character set. We can't use isalpha() and the like @@ -981,6 +981,14 @@ Slice::Gen::TypesVisitor::visitConstDef(const ConstDefPtr& p) H << "\""; // Closing " } + else if(bp && bp->kind() == Builtin::KindLong) + { + H << "INT64LITERAL(" << p->value() << ")"; + } + else + { + H << p->value(); + } H << ";"; } |