From: Thomas Geymayer Date: Wed, 6 Mar 2013 23:17:45 +0000 (+0100) Subject: Fix some warnings X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=79ae0da927e2d6c2ecb09024f3a9068f3a30f744;p=simgear.git Fix some warnings --- diff --git a/simgear/nasal/cppbind/NasalCallContext.hxx b/simgear/nasal/cppbind/NasalCallContext.hxx index 235f619d..0e5be166 100644 --- a/simgear/nasal/cppbind/NasalCallContext.hxx +++ b/simgear/nasal/cppbind/NasalCallContext.hxx @@ -29,104 +29,105 @@ namespace nasal /** * Context passed to a function/method being called from Nasal */ - struct CallContext + class CallContext { - CallContext(naContext c, size_t argc, naRef* args): - c(c), - argc(argc), - args(args) - {} - - bool isNumeric(size_t index) const - { - return (index < argc && naIsNum(args[index])); - } - - bool isString(size_t index) const - { - return (index < argc && naIsString(args[index])); - } - - bool isHash(size_t index) const - { - return (index < argc && naIsHash(args[index])); - } - - bool isVector(size_t index) const - { - return (index < argc && naIsVector(args[index])); - } - - bool isGhost(size_t index) const - { - return (index < argc && naIsGhost(args[index])); - } - - void popFront(size_t num = 1) - { - if( argc < num ) - return; - - args += num; - argc -= num; - } - - void popBack(size_t num = 1) - { - if( argc < num ) - return; - - argc -= num; - } - - /** - * Get the argument with given index if it exists. Otherwise returns the - * passed default value. - * - * @tparam T Type of argument (converted using ::from_nasal) - * @param index Index of requested argument - * @param def Default value returned if too few arguments available - */ - template - typename from_nasal_ptr::return_type - getArg(size_t index, const T& def = T()) const - { - if( index >= argc ) - return def; - - return from_nasal(args[index]); - } - - /** - * Get the argument with given index. Raises a Nasal runtime error if there - * are to few arguments available. - */ - template - typename from_nasal_ptr::return_type - requireArg(size_t index) const - { - if( index >= argc ) - naRuntimeError(c, "Missing required arg #%d", index); - - return from_nasal(args[index]); - } - - template - naRef to_nasal(T arg) const - { - return nasal::to_nasal(c, arg); - } - - template - typename from_nasal_ptr::return_type - from_nasal(naRef ref) const - { - return (*from_nasal_ptr::get())(c, ref); - } - - naContext c; - size_t argc; - naRef *args; + public: + CallContext(naContext c, size_t argc, naRef* args): + c(c), + argc(argc), + args(args) + {} + + bool isNumeric(size_t index) const + { + return (index < argc && naIsNum(args[index])); + } + + bool isString(size_t index) const + { + return (index < argc && naIsString(args[index])); + } + + bool isHash(size_t index) const + { + return (index < argc && naIsHash(args[index])); + } + + bool isVector(size_t index) const + { + return (index < argc && naIsVector(args[index])); + } + + bool isGhost(size_t index) const + { + return (index < argc && naIsGhost(args[index])); + } + + void popFront(size_t num = 1) + { + if( argc < num ) + return; + + args += num; + argc -= num; + } + + void popBack(size_t num = 1) + { + if( argc < num ) + return; + + argc -= num; + } + + /** + * Get the argument with given index if it exists. Otherwise returns the + * passed default value. + * + * @tparam T Type of argument (converted using ::from_nasal) + * @param index Index of requested argument + * @param def Default value returned if too few arguments available + */ + template + typename from_nasal_ptr::return_type + getArg(size_t index, const T& def = T()) const + { + if( index >= argc ) + return def; + + return from_nasal(args[index]); + } + + /** + * Get the argument with given index. Raises a Nasal runtime error if + * there are to few arguments available. + */ + template + typename from_nasal_ptr::return_type + requireArg(size_t index) const + { + if( index >= argc ) + naRuntimeError(c, "Missing required arg #%d", index); + + return from_nasal(args[index]); + } + + template + naRef to_nasal(T arg) const + { + return nasal::to_nasal(c, arg); + } + + template + typename from_nasal_ptr::return_type + from_nasal(naRef ref) const + { + return (*from_nasal_ptr::get())(c, ref); + } + + naContext c; + size_t argc; + naRef *args; }; } // namespace nasal diff --git a/simgear/props/condition.cxx b/simgear/props/condition.cxx index 3770049a..86f627f4 100644 --- a/simgear/props/condition.cxx +++ b/simgear/props/condition.cxx @@ -22,7 +22,6 @@ using std::istream; using std::ostream; - /** * Condition for a single property. * @@ -162,7 +161,6 @@ SGCondition::~SGCondition () } - //////////////////////////////////////////////////////////////////////// // Implementation of SGPropertyCondition. //////////////////////////////////////////////////////////////////////// @@ -178,7 +176,6 @@ SGPropertyCondition::~SGPropertyCondition () } - //////////////////////////////////////////////////////////////////////// // Implementation of SGNotCondition. //////////////////////////////////////////////////////////////////////// @@ -199,7 +196,6 @@ SGNotCondition::test () const } - //////////////////////////////////////////////////////////////////////// // Implementation of SGAndCondition. //////////////////////////////////////////////////////////////////////// @@ -215,8 +211,8 @@ SGAndCondition::~SGAndCondition () bool SGAndCondition::test () const { - int nConditions = _conditions.size(); - for (int i = 0; i < nConditions; i++) { + for( size_t i = 0; i < _conditions.size(); i++ ) + { if (!_conditions[i]->test()) return false; } @@ -230,7 +226,6 @@ SGAndCondition::addCondition (SGCondition * condition) } - //////////////////////////////////////////////////////////////////////// // Implementation of SGOrCondition. //////////////////////////////////////////////////////////////////////// @@ -246,8 +241,8 @@ SGOrCondition::~SGOrCondition () bool SGOrCondition::test () const { - int nConditions = _conditions.size(); - for (int i = 0; i < nConditions; i++) { + for( size_t i = 0; i < _conditions.size(); i++ ) + { if (_conditions[i]->test()) return true; } @@ -261,7 +256,6 @@ SGOrCondition::addCondition (SGCondition * condition) } - //////////////////////////////////////////////////////////////////////// // Implementation of SGComparisonCondition. //////////////////////////////////////////////////////////////////////// @@ -427,8 +421,7 @@ SGComparisonCondition::setPrecisionDExpression(SGExpressiond* dexp) { _precision_property = new SGPropertyNode(); _precision_dexp = dexp; -} -//////////////////////////////////////////////////////////////////////// +}//////////////////////////////////////////////////////////////////////// // Read a condition and use it if necessary. //////////////////////////////////////////////////////////////////////// @@ -583,7 +576,6 @@ readCondition( SGPropertyNode *prop_root, const SGPropertyNode *node ) } - //////////////////////////////////////////////////////////////////////// // Implementation of SGConditional. //////////////////////////////////////////////////////////////////////// @@ -610,7 +602,6 @@ SGConditional::test () const } - // The top-level is always an implicit 'and' group SGCondition * sgReadCondition( SGPropertyNode *prop_root, const SGPropertyNode *node ) diff --git a/simgear/structure/SGExpression.cxx b/simgear/structure/SGExpression.cxx index df0aa9d7..93174aba 100644 --- a/simgear/structure/SGExpression.cxx +++ b/simgear/structure/SGExpression.cxx @@ -865,7 +865,7 @@ Expression* logicopParser(const SGPropertyNode* exp, Parser* parser) ExpParserRegistrar andRegistrar("and", logicopParser); ExpParserRegistrar orRegistrar("or", logicopParser); -int BindingLayout::addBinding(const string& name, Type type) +size_t BindingLayout::addBinding(const string& name, Type type) { //XXX error checkint vector::iterator itr @@ -873,7 +873,7 @@ int BindingLayout::addBinding(const string& name, Type type) boost::bind(&VariableBinding::name, _1) == name); if (itr != bindings.end()) return itr->location; - int result = bindings.size(); + size_t result = bindings.size(); bindings.push_back(VariableBinding(name, type, bindings.size())); return result; } diff --git a/simgear/structure/SGExpression.hxx b/simgear/structure/SGExpression.hxx index 440f41a2..1832c3a3 100644 --- a/simgear/structure/SGExpression.hxx +++ b/simgear/structure/SGExpression.hxx @@ -983,7 +983,7 @@ namespace simgear class BindingLayout { public: - int addBinding(const std::string& name, expression::Type type); + size_t addBinding(const std::string& name, expression::Type type); bool findBinding(const string& name, VariableBinding& result) const; std::vector bindings; }; diff --git a/simgear/structure/subsystem_mgr.cxx b/simgear/structure/subsystem_mgr.cxx index 1e142552..5ce69831 100644 --- a/simgear/structure/subsystem_mgr.cxx +++ b/simgear/structure/subsystem_mgr.cxx @@ -117,7 +117,6 @@ void SGSubsystem::stamp(const string& name) timingInfo.push_back(TimingInfo(name, SGTimeStamp::now())); } - //////////////////////////////////////////////////////////////////////// // Implementation of SGSubsystemGroup. //////////////////////////////////////////////////////////////////////// @@ -157,7 +156,7 @@ SGSubsystemGroup::SGSubsystemGroup () : SGSubsystemGroup::~SGSubsystemGroup () { // reverse order to prevent order dependency problems - for (unsigned int i = _members.size(); i > 0; i--) + for( size_t i = _members.size(); i > 0; i-- ) { delete _members[i-1]; } @@ -166,7 +165,7 @@ SGSubsystemGroup::~SGSubsystemGroup () void SGSubsystemGroup::init () { - for (unsigned int i = 0; i < _members.size(); i++) + for( size_t i = 0; i < _members.size(); i++ ) _members[i]->subsystem->init(); } @@ -190,14 +189,14 @@ SGSubsystemGroup::incrementalInit() void SGSubsystemGroup::postinit () { - for (unsigned int i = 0; i < _members.size(); i++) + for( size_t i = 0; i < _members.size(); i++ ) _members[i]->subsystem->postinit(); } void SGSubsystemGroup::reinit () { - for (unsigned int i = 0; i < _members.size(); i++) + for( size_t i = 0; i < _members.size(); i++ ) _members[i]->subsystem->reinit(); } @@ -205,7 +204,7 @@ void SGSubsystemGroup::shutdown () { // reverse order to prevent order dependency problems - for (unsigned int i = _members.size(); i > 0; i--) + for( size_t i = _members.size(); i > 0; i-- ) _members[i-1]->subsystem->shutdown(); _initPosition = 0; } @@ -213,7 +212,7 @@ SGSubsystemGroup::shutdown () void SGSubsystemGroup::bind () { - for (unsigned int i = 0; i < _members.size(); i++) + for( size_t i = 0; i < _members.size(); i++ ) _members[i]->subsystem->bind(); } @@ -221,7 +220,7 @@ void SGSubsystemGroup::unbind () { // reverse order to prevent order dependency problems - for (unsigned int i = _members.size(); i > 0; i--) + for( size_t i = _members.size(); i > 0; i-- ) _members[i-1]->subsystem->unbind(); } @@ -242,7 +241,7 @@ SGSubsystemGroup::update (double delta_time_sec) bool recordTime = (reportTimingCb != NULL); SGTimeStamp timeStamp; while (loopCount-- > 0) { - for (unsigned int i = 0; i < _members.size(); i++) + for( size_t i = 0; i < _members.size(); i++ ) { if (recordTime) timeStamp = SGTimeStamp::now(); @@ -261,7 +260,7 @@ SGSubsystemGroup::update (double delta_time_sec) void SGSubsystemGroup::reportTiming(void) { - for (unsigned int i = _members.size(); i > 0; i--) + for( size_t i = _members.size(); i > 0; i-- ) { _members[i-1]->reportTiming(); } @@ -270,14 +269,14 @@ SGSubsystemGroup::reportTiming(void) void SGSubsystemGroup::suspend () { - for (unsigned int i = 0; i < _members.size(); i++) + for( size_t i = 0; i < _members.size(); i++ ) _members[i]->subsystem->suspend(); } void SGSubsystemGroup::resume () { - for (unsigned int i = 0; i < _members.size(); i++) + for( size_t i = 0; i < _members.size(); i++ ) _members[i]->subsystem->resume(); } @@ -285,7 +284,7 @@ string_list SGSubsystemGroup::member_names() const { string_list result; - for (unsigned int i = 0; i < _members.size(); i++) + for( size_t i = 0; i < _members.size(); i++ ) result.push_back( _members[i]->name ); return result; @@ -322,7 +321,7 @@ SGSubsystemGroup::get_subsystem (const string &name) void SGSubsystemGroup::remove_subsystem (const string &name) { - for (unsigned int i = 0; i < _members.size(); i++) { + for( size_t i = 0; i < _members.size(); i++ ) { if (name == _members[i]->name) { _members.erase(_members.begin() + i); return; @@ -345,7 +344,7 @@ SGSubsystemGroup::has_subsystem (const string &name) const SGSubsystemGroup::Member * SGSubsystemGroup::get_member (const string &name, bool create) { - for (unsigned int i = 0; i < _members.size(); i++) { + for( size_t i = 0; i < _members.size(); i++ ) { if (_members[i]->name == name) return _members[i]; } @@ -359,7 +358,6 @@ SGSubsystemGroup::get_member (const string &name, bool create) } - //////////////////////////////////////////////////////////////////////// // Implementation of SGSubsystemGroup::Member ////////////////////////////////////////////////////////////////////////