diff --git a/dtool/src/cppparser/cppExpression.cxx b/dtool/src/cppparser/cppExpression.cxx index 2b344c36ef..25bb2140f7 100644 --- a/dtool/src/cppparser/cppExpression.cxx +++ b/dtool/src/cppparser/cppExpression.cxx @@ -26,6 +26,7 @@ #include "cppFunctionGroup.h" #include "cppFunctionType.h" #include "cppBison.h" +#include "pdtoa.h" #include @@ -1079,7 +1080,13 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { break; case T_real: - out << _u._real; + { + // We use our own dtoa implementation here because it guarantees + // to never format the number as an integer. + char buffer[32]; + pdtoa(_u._real, buffer); + out << buffer; + } break; case T_string: @@ -1155,14 +1162,15 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { break; case T_construct: - out << "(" << _u._typecast._to->get_typedef_name(scope) - << "("; + _u._typecast._to->output(out, indent_level, scope, false); + out << "("; _u._typecast._op1->output(out, indent_level, scope, false); - out << "))"; + out << ")"; break; case T_default_construct: - out << "(" << _u._typecast._to->get_typedef_name(scope) << "())"; + _u._typecast._to->output(out, indent_level, scope, false); + out << "()"; break; case T_new: diff --git a/dtool/src/cppparser/cppInstance.cxx b/dtool/src/cppparser/cppInstance.cxx index aaaff2eb24..94b0924460 100644 --- a/dtool/src/cppparser/cppInstance.cxx +++ b/dtool/src/cppparser/cppInstance.cxx @@ -558,7 +558,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, out << " = 0"; } if (_initializer != NULL) { - out << " = (" << *_initializer << ")"; + out << " = " << *_initializer; } }