From 7d6c567fde81e82fc94b6ae98aeb166b12ab2382 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Fri, 17 Jul 2009 14:54:12 +0200 Subject: [PATCH] Refer to property types using props:: namespace BOOL, FLOAT etc. conflict with typedefs in windows.h. --- src/AIModel/AIMultiplayer.cxx | 44 +++++++++++++------------- src/GUI/dialog.cxx | 24 +++++++------- src/GUI/property_list.cxx | 54 ++++++++++++++++---------------- src/Main/main.cxx | 8 ++--- src/MultiPlayer/multiplaymgr.cxx | 16 +++++----- src/Network/multiplay.cxx | 16 +++++----- src/Network/props.cxx | 20 ++++++------ src/Scripting/NasalSys.cxx | 32 +++++++++---------- src/Scripting/nasal-props.cxx | 40 +++++++++++------------ 9 files changed, 127 insertions(+), 127 deletions(-) diff --git a/src/AIModel/AIMultiplayer.cxx b/src/AIModel/AIMultiplayer.cxx index 40de4253c..d9b44305a 100755 --- a/src/AIModel/AIMultiplayer.cxx +++ b/src/AIModel/AIMultiplayer.cxx @@ -97,7 +97,7 @@ void FGAIMultiplayer::unbind() { void FGAIMultiplayer::update(double dt) { - using namespace simgear::props; + using namespace simgear; if (dt <= 0) return; @@ -202,19 +202,19 @@ void FGAIMultiplayer::update(double dt) { //cout << "Found " << pIt->second->getPath() << ":"; switch ((*firstPropIt)->type) { - case INT: - case BOOL: - case LONG: + case props::INT: + case props::BOOL: + case props::LONG: pIt->second->setIntValue((*firstPropIt)->int_value); //cout << "Int: " << (*firstPropIt)->int_value << "\n"; break; - case FLOAT: - case DOUBLE: + case props::FLOAT: + case props::DOUBLE: pIt->second->setFloatValue((*firstPropIt)->float_value); //cout << "Flo: " << (*firstPropIt)->float_value << "\n"; break; - case STRING: - case UNSPECIFIED: + case props::STRING: + case props::UNSPECIFIED: pIt->second->setStringValue((*firstPropIt)->string_value); //cout << "Str: " << (*firstPropIt)->string_value << "\n"; break; @@ -276,23 +276,23 @@ void FGAIMultiplayer::update(double dt) int ival; float val; switch ((*prevPropIt)->type) { - case INT: - case BOOL: - case LONG: + case props::INT: + case props::BOOL: + case props::LONG: ival = (int) (0.5+(1-tau)*((double) (*prevPropIt)->int_value) + tau*((double) (*nextPropIt)->int_value)); pIt->second->setIntValue(ival); //cout << "Int: " << ival << "\n"; break; - case FLOAT: - case DOUBLE: + case props::FLOAT: + case props::DOUBLE: val = (1-tau)*(*prevPropIt)->float_value + tau*(*nextPropIt)->float_value; //cout << "Flo: " << val << "\n"; pIt->second->setFloatValue(val); break; - case STRING: - case UNSPECIFIED: + case props::STRING: + case props::UNSPECIFIED: //cout << "Str: " << (*nextPropIt)->string_value << "\n"; pIt->second->setStringValue((*nextPropIt)->string_value); break; @@ -389,19 +389,19 @@ void FGAIMultiplayer::update(double dt) if (pIt != mPropertyMap.end()) { switch ((*firstPropIt)->type) { - case INT: - case BOOL: - case LONG: + case props::INT: + case props::BOOL: + case props::LONG: pIt->second->setIntValue((*firstPropIt)->int_value); //cout << "Int: " << (*firstPropIt)->int_value << "\n"; break; - case FLOAT: - case DOUBLE: + case props::FLOAT: + case props::DOUBLE: pIt->second->setFloatValue((*firstPropIt)->float_value); //cout << "Flo: " << (*firstPropIt)->float_value << "\n"; break; - case STRING: - case UNSPECIFIED: + case props::STRING: + case props::UNSPECIFIED: pIt->second->setStringValue((*firstPropIt)->string_value); //cout << "Str: " << (*firstPropIt)->string_value << "\n"; break; diff --git a/src/GUI/dialog.cxx b/src/GUI/dialog.cxx index a6d4f270f..8fd21a333 100644 --- a/src/GUI/dialog.cxx +++ b/src/GUI/dialog.cxx @@ -390,7 +390,7 @@ action_callback (puObject *object) static void copy_to_pui (SGPropertyNode *node, puObject *object) { - using namespace simgear::props; + using namespace simgear; GUIInfo *info = (GUIInfo *)object->getUserData(); if (!info) { SG_LOG(SG_GENERAL, SG_ALERT, "dialog: widget without GUIInfo!"); @@ -410,13 +410,13 @@ copy_to_pui (SGPropertyNode *node, puObject *object) } switch (node->getType()) { - case BOOL: - case INT: - case LONG: + case props::BOOL: + case props::INT: + case props::LONG: object->setValue(node->getIntValue()); break; - case FLOAT: - case DOUBLE: + case props::FLOAT: + case props::DOUBLE: object->setValue(node->getFloatValue()); break; default: @@ -430,19 +430,19 @@ copy_to_pui (SGPropertyNode *node, puObject *object) static void copy_from_pui (puObject *object, SGPropertyNode *node) { - using namespace simgear::props; + using namespace simgear; // puText objects are immutable, so should not be copied out if (object->getType() & PUCLASS_TEXT) return; switch (node->getType()) { - case BOOL: - case INT: - case LONG: + case props::BOOL: + case props::INT: + case props::LONG: node->setIntValue(object->getIntegerValue()); break; - case FLOAT: - case DOUBLE: + case props::FLOAT: + case props::DOUBLE: node->setFloatValue(object->getFloatValue()); break; default: diff --git a/src/GUI/property_list.cxx b/src/GUI/property_list.cxx index d711d3023..5bcb46a35 100644 --- a/src/GUI/property_list.cxx +++ b/src/GUI/property_list.cxx @@ -44,29 +44,29 @@ typedef string stdString; // puObject has a "string" member static string getValueTypeString(const SGPropertyNode *node) { - using namespace simgear::props; + using namespace simgear; string result; - Type type = node->getType(); - if (type == UNSPECIFIED) + props::Type type = node->getType(); + if (type == props::UNSPECIFIED) result = "unspecified"; - else if (type == NONE) + else if (type == props::NONE) result = "none"; - else if (type == BOOL) + else if (type == props::BOOL) result = "bool"; - else if (type == INT) + else if (type == props::INT) result = "int"; - else if (type == LONG) + else if (type == props::LONG) result = "long"; - else if (type == FLOAT) + else if (type == props::FLOAT) result = "float"; - else if (type == DOUBLE) + else if (type == props::DOUBLE) result = "double"; - else if (type == STRING) + else if (type == props::STRING) result = "string"; - else if (type == VEC3D) + else if (type == props::VEC3D) result = "vec3d"; - else if (type == VEC4D) + else if (type == props::VEC4D) result = "vec4d"; return result; @@ -75,12 +75,12 @@ static string getValueTypeString(const SGPropertyNode *node) static void dumpProperties(const SGPropertyNode *node) { - using namespace simgear::props; + using namespace simgear; cout << node->getPath() << '/' << endl; for (int i = 0; i < node->nChildren(); i++) { const SGPropertyNode *c = node->getChild(i); - Type type = c->getType(); - if (type == ALIAS || c->nChildren()) + props::Type type = c->getType(); + if (type == props::ALIAS || c->nChildren()) continue; int index = c->getIndex(); @@ -90,25 +90,25 @@ static void dumpProperties(const SGPropertyNode *node) cout << " = "; switch (c->getType()) { - case DOUBLE: - case FLOAT: - case VEC3D: - case VEC4D: + case props::DOUBLE: + case props::FLOAT: + case props::VEC3D: + case props::VEC4D: { streamsize precision = cout.precision(15); c->printOn(cout); cout.precision(precision); } break; - case LONG: - case INT: - case BOOL: + case props::LONG: + case props::INT: + case props::BOOL: c->printOn(cout); break; - case STRING: + case props::STRING: cout << '"' << c->getStringValue() << '"'; break; - case NONE: + case props::NONE: break; default: cout << '\'' << c->getStringValue() << '\''; @@ -309,7 +309,7 @@ void PropertyList::update(bool restore_pos) void PropertyList::updateTextForEntry(NodeData& data) { - using namespace simgear::props; + using namespace simgear; SGPropertyNode *node = data.node; stdString name = node->getDisplayName(true); stdString type = getValueTypeString(node); @@ -323,8 +323,8 @@ void PropertyList::updateTextForEntry(NodeData& data) line << '/'; if (!children || (_verbose && node->hasValue())) { - if (node->getType() == STRING - || node->getType() == UNSPECIFIED) + if (node->getType() == props::STRING + || node->getType() == props::UNSPECIFIED) sanitize(value); line << " = '" << value << "' (" << type; diff --git a/src/Main/main.cxx b/src/Main/main.cxx index b86e9b01e..d9a2516ad 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -894,17 +894,17 @@ static void fgIdleFunction ( void ) { static void upper_case_property(const char *name) { - using namespace simgear::props; + using namespace simgear; SGPropertyNode *p = fgGetNode(name, false); if (!p) { p = fgGetNode(name, true); p->setStringValue(""); } else { - Type t = p->getType(); - if (t == NONE || t == UNSPECIFIED) + props::Type t = p->getType(); + if (t == props::NONE || t == props::UNSPECIFIED) p->setStringValue(""); else - assert(t == STRING); + assert(t == props::STRING); } p->addChangeListener(new FGMakeUpperCase); } diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index cf4ddd53e..4c7a1792f 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -268,7 +268,7 @@ namespace { bool verifyProperties(const xdr_data_t* data, const xdr_data_t* end) { - using namespace simgear::props; + using namespace simgear; const xdr_data_t* xdr = data; while (xdr < end) { unsigned id = XDR_decode_uint32(*xdr); @@ -279,13 +279,13 @@ namespace xdr++; // How we decode the remainder of the property depends on the type switch (plist->type) { - case INT: - case BOOL: - case LONG: + case props::INT: + case props::BOOL: + case props::LONG: xdr++; break; - case FLOAT: - case DOUBLE: + case props::FLOAT: + case props::DOUBLE: { float val = XDR_decode_float(*xdr); if (osg::isNaN(val)) @@ -293,8 +293,8 @@ namespace xdr++; break; } - case STRING: - case UNSPECIFIED: + case props::STRING: + case props::UNSPECIFIED: { // String is complicated. It consists of // The length of the string diff --git a/src/Network/multiplay.cxx b/src/Network/multiplay.cxx index ce6f1b61e..f6e0e30c7 100644 --- a/src/Network/multiplay.cxx +++ b/src/Network/multiplay.cxx @@ -119,7 +119,7 @@ bool FGMultiplay::open() { * or receive data over the network ******************************************************************/ bool FGMultiplay::process() { - using namespace simgear::props; + using namespace simgear; if (get_direction() == SG_IO_OUT) { // check if we have left initialization phase. That will not provide @@ -202,17 +202,17 @@ bool FGMultiplay::process() { pData->type = it->second->getType(); switch (pData->type) { - case INT: - case LONG: - case BOOL: + case props::INT: + case props::LONG: + case props::BOOL: pData->int_value = it->second->getIntValue(); break; - case FLOAT: - case DOUBLE: + case props::FLOAT: + case props::DOUBLE: pData->float_value = it->second->getFloatValue(); break; - case STRING: - case UNSPECIFIED: + case props::STRING: + case props::UNSPECIFIED: { // FIXME: We assume unspecified are strings for the moment. diff --git a/src/Network/props.cxx b/src/Network/props.cxx index abbf0e5d1..e6760eaff 100644 --- a/src/Network/props.cxx +++ b/src/Network/props.cxx @@ -118,7 +118,7 @@ PropsChannel::collectIncomingData( const char* s, int n ) static string getValueTypeString( const SGPropertyNode *node ) { - using namespace simgear::props; + using namespace simgear; string result; @@ -127,22 +127,22 @@ getValueTypeString( const SGPropertyNode *node ) return "unknown"; } - Type type = node->getType(); - if ( type == UNSPECIFIED ) { + props::Type type = node->getType(); + if ( type == props::UNSPECIFIED ) { result = "unspecified"; - } else if ( type == NONE ) { + } else if ( type == props::NONE ) { result = "none"; - } else if ( type == BOOL ) { + } else if ( type == props::BOOL ) { result = "bool"; - } else if ( type == INT ) { + } else if ( type == props::INT ) { result = "int"; - } else if ( type == LONG ) { + } else if ( type == props::LONG ) { result = "long"; - } else if ( type == FLOAT ) { + } else if ( type == props::FLOAT ) { result = "float"; - } else if ( type == DOUBLE ) { + } else if ( type == props::DOUBLE ) { result = "double"; - } else if ( type == STRING ) { + } else if ( type == props::STRING ) { result = "string"; } diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 4fee5cfd2..c893d0510 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -177,25 +177,25 @@ static SGPropertyNode* findnode(naContext c, naRef* vec, int len) // nil if it doesn't exist. static naRef f_getprop(naContext c, naRef me, int argc, naRef* args) { - using namespace simgear::props; + using namespace simgear; const SGPropertyNode* p = findnode(c, args, argc); if(!p) return naNil(); switch(p->getType()) { - case BOOL: case INT: - case LONG: case FLOAT: - case DOUBLE: + case props::BOOL: case props::INT: + case props::LONG: case props::FLOAT: + case props::DOUBLE: return naNum(p->getDoubleValue()); - case STRING: - case UNSPECIFIED: + case props::STRING: + case props::UNSPECIFIED: { naRef nastr = naNewString(c); const char* val = p->getStringValue(); naStr_fromdata(nastr, (char*)val, strlen(val)); return nastr; } - case ALIAS: // <--- FIXME, recurse? + case props::ALIAS: // <--- FIXME, recurse? default: return naNil(); } @@ -1061,24 +1061,24 @@ void FGNasalListener::childRemoved(SGPropertyNode*, SGPropertyNode* child) bool FGNasalListener::changed(SGPropertyNode* node) { - using namespace simgear::props; - Type type = node->getType(); - if(type == NONE) return false; - if(type == UNSPECIFIED) return true; + using namespace simgear; + props::Type type = node->getType(); + if(type == props::NONE) return false; + if(type == props::UNSPECIFIED) return true; bool result; switch(type) { - case BOOL: - case INT: - case LONG: + case props::BOOL: + case props::INT: + case props::LONG: { long l = node->getLongValue(); result = l != _last_int; _last_int = l; return result; } - case FLOAT: - case DOUBLE: + case props::FLOAT: + case props::DOUBLE: { double d = node->getDoubleValue(); result = d != _last_float; diff --git a/src/Scripting/nasal-props.cxx b/src/Scripting/nasal-props.cxx index ab21f2a24..83f90ab0f 100644 --- a/src/Scripting/nasal-props.cxx +++ b/src/Scripting/nasal-props.cxx @@ -58,21 +58,21 @@ naRef FGNasalSys::propNodeGhost(SGPropertyNode* handle) static naRef f_getType(naContext c, naRef me, int argc, naRef* args) { - using namespace simgear::props; + using namespace simgear; NODEARG(); const char* t = "unknown"; switch((*node)->getType()) { - case NONE: t = "NONE"; break; - case ALIAS: t = "ALIAS"; break; - case BOOL: t = "BOOL"; break; - case INT: t = "INT"; break; - case LONG: t = "LONG"; break; - case FLOAT: t = "FLOAT"; break; - case DOUBLE: t = "DOUBLE"; break; - case STRING: t = "STRING"; break; - case UNSPECIFIED: t = "UNSPECIFIED"; break; - case VEC3D: t = "VEC3D"; break; - case VEC4D: t = "VEC4D"; break; + case props::NONE: t = "NONE"; break; + case props::ALIAS: t = "ALIAS"; break; + case props::BOOL: t = "BOOL"; break; + case props::INT: t = "INT"; break; + case props::LONG: t = "LONG"; break; + case props::FLOAT: t = "FLOAT"; break; + case props::DOUBLE: t = "DOUBLE"; break; + case props::STRING: t = "STRING"; break; + case props::UNSPECIFIED: t = "UNSPECIFIED"; break; + case props::VEC3D: t = "VEC3D"; break; + case props::VEC4D: t = "VEC4D"; break; } return NASTR(t); } @@ -157,19 +157,19 @@ naRef makeVectorFromVec(naContext c, const T& vec) static naRef f_getValue(naContext c, naRef me, int argc, naRef* args) { - using namespace simgear::props; + using namespace simgear; NODEARG(); switch((*node)->getType()) { - case BOOL: case INT: - case LONG: case FLOAT: - case DOUBLE: + case props::BOOL: case props::INT: + case props::LONG: case props::FLOAT: + case props::DOUBLE: return naNum((*node)->getDoubleValue()); - case STRING: - case UNSPECIFIED: + case props::STRING: + case props::UNSPECIFIED: return NASTR((*node)->getStringValue()); - case VEC3D: + case props::VEC3D: return makeVectorFromVec(c, (*node)->getValue()); - case VEC4D: + case props::VEC4D: return makeVectorFromVec(c, (*node)->getValue()); default: return naNil();