X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/10b959e3729a77b95ab15614d1bdce74da327d8b..89c684ef8280e2d91096da2d96ba36e24a1fb917:/src/common/wxexpr.cpp?ds=sidebyside diff --git a/src/common/wxexpr.cpp b/src/common/wxexpr.cpp index bb046c5fa8..e7cabf24f0 100644 --- a/src/common/wxexpr.cpp +++ b/src/common/wxexpr.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -20,7 +20,12 @@ #pragma hdrstop #endif -#include +#if wxUSE_IOSTREAMH + #include +#else + #include +#endif + #include #include #include @@ -34,11 +39,10 @@ extern "C" void add_expr(char *); extern "C" void LexFromFile(FILE *fd); extern "C" void LexFromString(char *buf); + wxExprDatabase *thewxExprDatabase = NULL; wxExprErrorHandler currentwxExprErrorHandler; -IMPLEMENT_DYNAMIC_CLASS(wxExprDatabase, wxList) - wxExpr::wxExpr(const wxString& functor) { type = wxExprList; @@ -109,7 +113,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 +432,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 +588,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 +718,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) @@ -831,7 +847,14 @@ void wxExpr::WriteLispExpr(ostream& stream) } } -// wxExpr 'database' (list of expressions) +/* + * wxExpr 'database' (list of expressions) + */ + +#if !USE_SHARED_LIBRARIES +IMPLEMENT_DYNAMIC_CLASS(wxExprDatabase, wxList) +#endif + wxExprDatabase::wxExprDatabase(wxExprErrorHandler handler) { position = NULL; @@ -924,7 +947,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) @@ -1112,19 +1135,19 @@ bool wxExprIsFunctor(wxExpr *expr, const wxString& functor) * */ -char *make_integer(char *str) +char *wxmake_integer(char *str) { wxExpr *x = new wxExpr(atol(str)); return (char *)x; } -char *make_real(char *str1, char *str2) +char *wxmake_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; @@ -1132,19 +1155,19 @@ char *make_real(char *str1, char *str2) // extern "C" double exp10(double); -char *make_exp(char *str1, char *str2) +char *wxmake_exp(char *str1, char *str2) { double mantissa = (double)atoi(str1); double exponent = (double)atoi(str2); double d = mantissa * pow(10.0, exponent); - wxExpr *x = new wxExpr((float)d); + wxExpr *x = new wxExpr(d); return (char *)x; } -char *make_exp2(char *str1, char *str2, char *str3) +char *wxmake_exp2(char *str1, char *str2, char *str3) { char buf[50]; @@ -1154,18 +1177,18 @@ 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; } -char *make_word(char *str) +char *wxmake_word(char *str) { wxExpr *x = new wxExpr(wxExprWord, str); return (char *)x; } -char *make_string(char *str) +char *wxmake_string(char *str) { char *s, *t; int len, i; @@ -1218,7 +1241,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");