Fix some warnings

This commit is contained in:
Thomas Geymayer
2013-03-07 00:17:45 +01:00
parent e179bda57a
commit 79ae0da927
5 changed files with 104 additions and 114 deletions
+82 -81
View File
@@ -29,104 +29,105 @@ namespace nasal
/** /**
* Context passed to a function/method being called from Nasal * Context passed to a function/method being called from Nasal
*/ */
struct CallContext class CallContext
{ {
CallContext(naContext c, size_t argc, naRef* args): public:
c(c), CallContext(naContext c, size_t argc, naRef* args):
argc(argc), c(c),
args(args) argc(argc),
{} args(args)
{}
bool isNumeric(size_t index) const bool isNumeric(size_t index) const
{ {
return (index < argc && naIsNum(args[index])); return (index < argc && naIsNum(args[index]));
} }
bool isString(size_t index) const bool isString(size_t index) const
{ {
return (index < argc && naIsString(args[index])); return (index < argc && naIsString(args[index]));
} }
bool isHash(size_t index) const bool isHash(size_t index) const
{ {
return (index < argc && naIsHash(args[index])); return (index < argc && naIsHash(args[index]));
} }
bool isVector(size_t index) const bool isVector(size_t index) const
{ {
return (index < argc && naIsVector(args[index])); return (index < argc && naIsVector(args[index]));
} }
bool isGhost(size_t index) const bool isGhost(size_t index) const
{ {
return (index < argc && naIsGhost(args[index])); return (index < argc && naIsGhost(args[index]));
} }
void popFront(size_t num = 1) void popFront(size_t num = 1)
{ {
if( argc < num ) if( argc < num )
return; return;
args += num; args += num;
argc -= num; argc -= num;
} }
void popBack(size_t num = 1) void popBack(size_t num = 1)
{ {
if( argc < num ) if( argc < num )
return; return;
argc -= num; argc -= num;
} }
/** /**
* Get the argument with given index if it exists. Otherwise returns the * Get the argument with given index if it exists. Otherwise returns the
* passed default value. * passed default value.
* *
* @tparam T Type of argument (converted using ::from_nasal) * @tparam T Type of argument (converted using ::from_nasal)
* @param index Index of requested argument * @param index Index of requested argument
* @param def Default value returned if too few arguments available * @param def Default value returned if too few arguments available
*/ */
template<class T> template<class T>
typename from_nasal_ptr<T>::return_type typename from_nasal_ptr<T>::return_type
getArg(size_t index, const T& def = T()) const getArg(size_t index, const T& def = T()) const
{ {
if( index >= argc ) if( index >= argc )
return def; return def;
return from_nasal<T>(args[index]); return from_nasal<T>(args[index]);
} }
/** /**
* Get the argument with given index. Raises a Nasal runtime error if there * Get the argument with given index. Raises a Nasal runtime error if
* are to few arguments available. * there are to few arguments available.
*/ */
template<class T> template<class T>
typename from_nasal_ptr<T>::return_type typename from_nasal_ptr<T>::return_type
requireArg(size_t index) const requireArg(size_t index) const
{ {
if( index >= argc ) if( index >= argc )
naRuntimeError(c, "Missing required arg #%d", index); naRuntimeError(c, "Missing required arg #%d", index);
return from_nasal<T>(args[index]); return from_nasal<T>(args[index]);
} }
template<class T> template<class T>
naRef to_nasal(T arg) const naRef to_nasal(T arg) const
{ {
return nasal::to_nasal(c, arg); return nasal::to_nasal(c, arg);
} }
template<class T> template<class T>
typename from_nasal_ptr<T>::return_type typename from_nasal_ptr<T>::return_type
from_nasal(naRef ref) const from_nasal(naRef ref) const
{ {
return (*from_nasal_ptr<T>::get())(c, ref); return (*from_nasal_ptr<T>::get())(c, ref);
} }
naContext c; naContext c;
size_t argc; size_t argc;
naRef *args; naRef *args;
}; };
} // namespace nasal } // namespace nasal
+5 -14
View File
@@ -22,7 +22,6 @@
using std::istream; using std::istream;
using std::ostream; using std::ostream;
/** /**
* Condition for a single property. * Condition for a single property.
* *
@@ -162,7 +161,6 @@ SGCondition::~SGCondition ()
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Implementation of SGPropertyCondition. // Implementation of SGPropertyCondition.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@@ -178,7 +176,6 @@ SGPropertyCondition::~SGPropertyCondition ()
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Implementation of SGNotCondition. // Implementation of SGNotCondition.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@@ -199,7 +196,6 @@ SGNotCondition::test () const
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Implementation of SGAndCondition. // Implementation of SGAndCondition.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@@ -215,8 +211,8 @@ SGAndCondition::~SGAndCondition ()
bool bool
SGAndCondition::test () const SGAndCondition::test () const
{ {
int nConditions = _conditions.size(); for( size_t i = 0; i < _conditions.size(); i++ )
for (int i = 0; i < nConditions; i++) { {
if (!_conditions[i]->test()) if (!_conditions[i]->test())
return false; return false;
} }
@@ -230,7 +226,6 @@ SGAndCondition::addCondition (SGCondition * condition)
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Implementation of SGOrCondition. // Implementation of SGOrCondition.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@@ -246,8 +241,8 @@ SGOrCondition::~SGOrCondition ()
bool bool
SGOrCondition::test () const SGOrCondition::test () const
{ {
int nConditions = _conditions.size(); for( size_t i = 0; i < _conditions.size(); i++ )
for (int i = 0; i < nConditions; i++) { {
if (_conditions[i]->test()) if (_conditions[i]->test())
return true; return true;
} }
@@ -261,7 +256,6 @@ SGOrCondition::addCondition (SGCondition * condition)
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Implementation of SGComparisonCondition. // Implementation of SGComparisonCondition.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@@ -427,8 +421,7 @@ SGComparisonCondition::setPrecisionDExpression(SGExpressiond* dexp)
{ {
_precision_property = new SGPropertyNode(); _precision_property = new SGPropertyNode();
_precision_dexp = dexp; _precision_dexp = dexp;
} }////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// Read a condition and use it if necessary. // Read a condition and use it if necessary.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@@ -583,7 +576,6 @@ readCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Implementation of SGConditional. // Implementation of SGConditional.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@@ -610,7 +602,6 @@ SGConditional::test () const
} }
// The top-level is always an implicit 'and' group // The top-level is always an implicit 'and' group
SGCondition * SGCondition *
sgReadCondition( SGPropertyNode *prop_root, const SGPropertyNode *node ) sgReadCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
+2 -2
View File
@@ -865,7 +865,7 @@ Expression* logicopParser(const SGPropertyNode* exp, Parser* parser)
ExpParserRegistrar andRegistrar("and", logicopParser<AndExpression>); ExpParserRegistrar andRegistrar("and", logicopParser<AndExpression>);
ExpParserRegistrar orRegistrar("or", logicopParser<OrExpression>); ExpParserRegistrar orRegistrar("or", logicopParser<OrExpression>);
int BindingLayout::addBinding(const string& name, Type type) size_t BindingLayout::addBinding(const string& name, Type type)
{ {
//XXX error checkint //XXX error checkint
vector<VariableBinding>::iterator itr vector<VariableBinding>::iterator itr
@@ -873,7 +873,7 @@ int BindingLayout::addBinding(const string& name, Type type)
boost::bind(&VariableBinding::name, _1) == name); boost::bind(&VariableBinding::name, _1) == name);
if (itr != bindings.end()) if (itr != bindings.end())
return itr->location; return itr->location;
int result = bindings.size(); size_t result = bindings.size();
bindings.push_back(VariableBinding(name, type, bindings.size())); bindings.push_back(VariableBinding(name, type, bindings.size()));
return result; return result;
} }
+1 -1
View File
@@ -983,7 +983,7 @@ namespace simgear
class BindingLayout class BindingLayout
{ {
public: 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; bool findBinding(const string& name, VariableBinding& result) const;
std::vector<VariableBinding> bindings; std::vector<VariableBinding> bindings;
}; };
+14 -16
View File
@@ -117,7 +117,6 @@ void SGSubsystem::stamp(const string& name)
timingInfo.push_back(TimingInfo(name, SGTimeStamp::now())); timingInfo.push_back(TimingInfo(name, SGTimeStamp::now()));
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Implementation of SGSubsystemGroup. // Implementation of SGSubsystemGroup.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@@ -157,7 +156,7 @@ SGSubsystemGroup::SGSubsystemGroup () :
SGSubsystemGroup::~SGSubsystemGroup () SGSubsystemGroup::~SGSubsystemGroup ()
{ {
// reverse order to prevent order dependency problems // 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]; delete _members[i-1];
} }
@@ -166,7 +165,7 @@ SGSubsystemGroup::~SGSubsystemGroup ()
void void
SGSubsystemGroup::init () SGSubsystemGroup::init ()
{ {
for (unsigned int i = 0; i < _members.size(); i++) for( size_t i = 0; i < _members.size(); i++ )
_members[i]->subsystem->init(); _members[i]->subsystem->init();
} }
@@ -190,14 +189,14 @@ SGSubsystemGroup::incrementalInit()
void void
SGSubsystemGroup::postinit () SGSubsystemGroup::postinit ()
{ {
for (unsigned int i = 0; i < _members.size(); i++) for( size_t i = 0; i < _members.size(); i++ )
_members[i]->subsystem->postinit(); _members[i]->subsystem->postinit();
} }
void void
SGSubsystemGroup::reinit () SGSubsystemGroup::reinit ()
{ {
for (unsigned int i = 0; i < _members.size(); i++) for( size_t i = 0; i < _members.size(); i++ )
_members[i]->subsystem->reinit(); _members[i]->subsystem->reinit();
} }
@@ -205,7 +204,7 @@ void
SGSubsystemGroup::shutdown () SGSubsystemGroup::shutdown ()
{ {
// reverse order to prevent order dependency problems // 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(); _members[i-1]->subsystem->shutdown();
_initPosition = 0; _initPosition = 0;
} }
@@ -213,7 +212,7 @@ SGSubsystemGroup::shutdown ()
void void
SGSubsystemGroup::bind () SGSubsystemGroup::bind ()
{ {
for (unsigned int i = 0; i < _members.size(); i++) for( size_t i = 0; i < _members.size(); i++ )
_members[i]->subsystem->bind(); _members[i]->subsystem->bind();
} }
@@ -221,7 +220,7 @@ void
SGSubsystemGroup::unbind () SGSubsystemGroup::unbind ()
{ {
// reverse order to prevent order dependency problems // 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(); _members[i-1]->subsystem->unbind();
} }
@@ -242,7 +241,7 @@ SGSubsystemGroup::update (double delta_time_sec)
bool recordTime = (reportTimingCb != NULL); bool recordTime = (reportTimingCb != NULL);
SGTimeStamp timeStamp; SGTimeStamp timeStamp;
while (loopCount-- > 0) { while (loopCount-- > 0) {
for (unsigned int i = 0; i < _members.size(); i++) for( size_t i = 0; i < _members.size(); i++ )
{ {
if (recordTime) if (recordTime)
timeStamp = SGTimeStamp::now(); timeStamp = SGTimeStamp::now();
@@ -261,7 +260,7 @@ SGSubsystemGroup::update (double delta_time_sec)
void void
SGSubsystemGroup::reportTiming(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(); _members[i-1]->reportTiming();
} }
@@ -270,14 +269,14 @@ SGSubsystemGroup::reportTiming(void)
void void
SGSubsystemGroup::suspend () SGSubsystemGroup::suspend ()
{ {
for (unsigned int i = 0; i < _members.size(); i++) for( size_t i = 0; i < _members.size(); i++ )
_members[i]->subsystem->suspend(); _members[i]->subsystem->suspend();
} }
void void
SGSubsystemGroup::resume () SGSubsystemGroup::resume ()
{ {
for (unsigned int i = 0; i < _members.size(); i++) for( size_t i = 0; i < _members.size(); i++ )
_members[i]->subsystem->resume(); _members[i]->subsystem->resume();
} }
@@ -285,7 +284,7 @@ string_list
SGSubsystemGroup::member_names() const SGSubsystemGroup::member_names() const
{ {
string_list result; 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 ); result.push_back( _members[i]->name );
return result; return result;
@@ -322,7 +321,7 @@ SGSubsystemGroup::get_subsystem (const string &name)
void void
SGSubsystemGroup::remove_subsystem (const string &name) 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) { if (name == _members[i]->name) {
_members.erase(_members.begin() + i); _members.erase(_members.begin() + i);
return; return;
@@ -345,7 +344,7 @@ SGSubsystemGroup::has_subsystem (const string &name) const
SGSubsystemGroup::Member * SGSubsystemGroup::Member *
SGSubsystemGroup::get_member (const string &name, bool create) 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) if (_members[i]->name == name)
return _members[i]; return _members[i];
} }
@@ -359,7 +358,6 @@ SGSubsystemGroup::get_member (const string &name, bool create)
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Implementation of SGSubsystemGroup::Member // Implementation of SGSubsystemGroup::Member
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////