X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/10b959e3729a77b95ab15614d1bdce74da327d8b..ff528365c8fdff9af65d3121d9f0954bf216b82f:/src/common/wxexpr.cpp?ds=sidebyside diff --git a/src/common/wxexpr.cpp b/src/common/wxexpr.cpp index bb046c5fa8..3d4979ef4c 100644 --- a/src/common/wxexpr.cpp +++ b/src/common/wxexpr.cpp @@ -20,7 +20,15 @@ #pragma hdrstop #endif +#if wxUSE_IOSTREAMH #include +#else +#include +# ifdef _MSC_VER + using namespace std; +# endif +#endif + #include #include #include @@ -109,7 +117,7 @@ wxExpr::wxExpr(long the_integer) next = NULL; } -wxExpr::wxExpr(float the_real) +wxExpr::wxExpr(double the_real) { type = wxExprReal; value.real = the_real; @@ -428,7 +436,7 @@ void wxExpr::AddAttributeValue(const wxString& attribute, long val) Append(listExpr); } -void wxExpr::AddAttributeValue(const wxString& attribute, float val) +void wxExpr::AddAttributeValue(const wxString& attribute, double val) { if (type != wxExprList) { @@ -584,6 +592,18 @@ bool wxExpr::GetAttributeValue(const wxString& att, long& var) const } bool wxExpr::GetAttributeValue(const wxString& att, float& var) const +{ + wxExpr *expr = AttributeValue(att); + if (expr && (expr->Type() == wxExprInteger || expr->Type() == wxExprReal)) + { + var = (float) expr->RealValue(); + return TRUE; + } + else + return FALSE; +} + +bool wxExpr::GetAttributeValue(const wxString& att, double& var) const { wxExpr *expr = AttributeValue(att); if (expr && (expr->Type() == wxExprInteger || expr->Type() == wxExprReal)) @@ -702,7 +722,7 @@ void wxExpr::WriteExpr(ostream& stream) // Write as any other subexpression } case wxExprReal: { - float f = value.real; + double f = value.real; /* Now the parser can cope with this. // Prevent printing in 'e' notation. Any better way? if (fabs(f) < 0.00001) @@ -924,7 +944,7 @@ wxExpr *wxExprDatabase::FindClause(const wxString& word, long val) return found; } -wxExpr *wxExprDatabase::FindClause(const wxString& word, float val) +wxExpr *wxExprDatabase::FindClause(const wxString& word, double val) { wxExpr *found = NULL; while (position && !found) @@ -1124,7 +1144,7 @@ char *make_real(char *str1, char *str2) char buf[50]; sprintf(buf, "%s.%s", str1, str2); - float f = (float)atof(buf); + double f = (double)atof(buf); wxExpr *x = new wxExpr(f); return (char *)x; @@ -1139,7 +1159,7 @@ char *make_exp(char *str1, char *str2) double d = mantissa * pow(10.0, exponent); - wxExpr *x = new wxExpr((float)d); + wxExpr *x = new wxExpr(d); return (char *)x; } @@ -1154,7 +1174,7 @@ char *make_exp2(char *str1, char *str2, char *str3) double d = mantissa * pow(10.0, exponent); - wxExpr *x = new wxExpr((float)d); + wxExpr *x = new wxExpr(d); return (char *)x; } @@ -1218,7 +1238,7 @@ void process_command(char * cexpr) add_expr(expr); } -void syntax_error(char *s) +void syntax_error(char *WXUNUSED(s)) { if (currentwxExprErrorHandler) (void)(*(currentwxExprErrorHandler))(WXEXPR_ERROR_SYNTAX, "syntax error");