From: Torsten Dreyer Date: Sat, 8 Jan 2011 12:06:25 +0000 (+0100) Subject: SGExpression bugfix: allow within X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=58c7edfed6a848f555bb0eaa65593162b5a206ce;p=simgear.git SGExpression bugfix: allow within --- diff --git a/simgear/structure/SGExpression.cxx b/simgear/structure/SGExpression.cxx index 78d6daf0..6f292e46 100644 --- a/simgear/structure/SGExpression.cxx +++ b/simgear/structure/SGExpression.cxx @@ -127,7 +127,7 @@ SGReadValueFromContent(const SGPropertyNode *node, T& value) template static SGExpression* -SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression); +SGReadExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression); template static bool @@ -136,7 +136,7 @@ SGReadNaryOperands(SGNaryExpression* nary, { for (int i = 0; i < expression->nChildren(); ++i) { SGExpression* inputExpression; - inputExpression = SGReadIExpression(inputRoot, expression->getChild(i)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(i)); if (!inputExpression) return false; nary->addOperand(inputExpression); @@ -166,12 +166,13 @@ SGReadNaryOperands(SGNaryExpression* nary, template static SGExpression* -SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) +SGReadExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) { if (!expression) return 0; std::string name = expression->getName(); + if (name == "value") { T value; if (!SGReadValueFromContent(expression, value)) { @@ -202,7 +203,7 @@ SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadIExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -216,7 +217,7 @@ SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadIExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -241,7 +242,7 @@ SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) SGSharedPtr > inputExpression; for (int i = 0; !inputExpression && i < expression->nChildren(); ++i) - inputExpression = SGReadIExpression(inputRoot, expression->getChild(i)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(i)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -255,8 +256,8 @@ SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpressions[2] = { - SGReadIExpression(inputRoot, expression->getChild(0)), - SGReadIExpression(inputRoot, expression->getChild(1)) + SGReadExpression(inputRoot, expression->getChild(0)), + SGReadExpression(inputRoot, expression->getChild(1)) }; if (!inputExpressions[0] || !inputExpressions[1]) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); @@ -270,8 +271,8 @@ SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpressions[2] = { - SGReadIExpression(inputRoot, expression->getChild(0)), - SGReadIExpression(inputRoot, expression->getChild(1)) + SGReadExpression(inputRoot, expression->getChild(0)), + SGReadExpression(inputRoot, expression->getChild(1)) }; if (!inputExpressions[0] || !inputExpressions[1]) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); @@ -371,7 +372,7 @@ SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) } SGSharedPtr > inputExpression; - inputExpression = SGReadIExpression(inputRoot, inputNode); + inputExpression = SGReadExpression(inputRoot, inputNode); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -380,29 +381,13 @@ SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return new SGInterpTableExpression(inputExpression, tab); } - return 0; -} - - -template -static SGExpression* -SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) -{ - SGExpression* r = SGReadIExpression(inputRoot, expression); - if (r) - return r; - - if (!expression) - return 0; - - std::string name = expression->getName(); if (name == "acos") { if (expression->nChildren() != 1) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -416,7 +401,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -430,7 +415,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -444,7 +429,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -458,7 +443,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -472,7 +457,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -486,7 +471,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -500,7 +485,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -514,7 +499,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -528,7 +513,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -542,7 +527,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -556,7 +541,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -570,7 +555,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -584,7 +569,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -598,7 +583,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -612,7 +597,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -626,7 +611,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpression; - inputExpression = SGReadFExpression(inputRoot, expression->getChild(0)); + inputExpression = SGReadExpression(inputRoot, expression->getChild(0)); if (!inputExpression) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); return 0; @@ -645,8 +630,8 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpressions[2] = { - SGReadFExpression(inputRoot, expression->getChild(0)), - SGReadFExpression(inputRoot, expression->getChild(1)) + SGReadExpression(inputRoot, expression->getChild(0)), + SGReadExpression(inputRoot, expression->getChild(1)) }; if (!inputExpressions[0] || !inputExpressions[1]) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); @@ -660,8 +645,8 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpressions[2] = { - SGReadFExpression(inputRoot, expression->getChild(0)), - SGReadFExpression(inputRoot, expression->getChild(1)) + SGReadExpression(inputRoot, expression->getChild(0)), + SGReadExpression(inputRoot, expression->getChild(1)) }; if (!inputExpressions[0] || !inputExpressions[1]) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); @@ -675,8 +660,8 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpressions[2] = { - SGReadFExpression(inputRoot, expression->getChild(0)), - SGReadFExpression(inputRoot, expression->getChild(1)) + SGReadExpression(inputRoot, expression->getChild(0)), + SGReadExpression(inputRoot, expression->getChild(1)) }; if (!inputExpressions[0] || !inputExpressions[1]) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); @@ -690,8 +675,8 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return 0; } SGSharedPtr > inputExpressions[2] = { - SGReadIExpression(inputRoot, expression->getChild(0)), - SGReadIExpression(inputRoot, expression->getChild(1)) + SGReadExpression(inputRoot, expression->getChild(0)), + SGReadExpression(inputRoot, expression->getChild(1)) }; if (!inputExpressions[0] || !inputExpressions[1]) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); @@ -706,17 +691,17 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) SGExpression* SGReadIntExpression(SGPropertyNode *inputRoot, const SGPropertyNode *configNode) -{ return SGReadIExpression(inputRoot, configNode); } +{ return SGReadExpression(inputRoot, configNode); } SGExpression* SGReadFloatExpression(SGPropertyNode *inputRoot, const SGPropertyNode *configNode) -{ return SGReadFExpression(inputRoot, configNode); } +{ return SGReadExpression(inputRoot, configNode); } SGExpression* SGReadDoubleExpression(SGPropertyNode *inputRoot, const SGPropertyNode *configNode) -{ return SGReadFExpression(inputRoot, configNode); } +{ return SGReadExpression(inputRoot, configNode); } // SGExpression* // SGReadBoolExpression(SGPropertyNode *inputRoot,