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

View File

@ -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)
{}
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 isNumeric(size_t index) const
{
return (index < argc && naIsNum(args[index]));
}
bool isString(size_t index) const
{
return (index < argc && naIsString(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 isHash(size_t index) const
{
return (index < argc && naIsHash(args[index]));
}
bool isVector(size_t index) const
{
return (index < argc && naIsVector(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]));
}
bool isGhost(size_t index) const
{
return (index < argc && naIsGhost(args[index]));
}
void popFront(size_t num = 1)
{
if( argc < num )
return;
void popFront(size_t num = 1)
{
if( argc < num )
return;
args += num;
argc -= num;
}
args += num;
argc -= num;
}
void popBack(size_t num = 1)
{
if( argc < num )
return;
void popBack(size_t num = 1)
{
if( argc < num )
return;
argc -= num;
}
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<class T>
typename from_nasal_ptr<T>::return_type
getArg(size_t index, const T& def = T()) const
{
if( index >= argc )
return def;
/**
* 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<class T>
typename from_nasal_ptr<T>::return_type
getArg(size_t index, const T& def = T()) const
{
if( index >= argc )
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
* are to few arguments available.
*/
template<class T>
typename from_nasal_ptr<T>::return_type
requireArg(size_t index) const
{
if( index >= argc )
naRuntimeError(c, "Missing required arg #%d", index);
/**
* Get the argument with given index. Raises a Nasal runtime error if
* there are to few arguments available.
*/
template<class T>
typename from_nasal_ptr<T>::return_type
requireArg(size_t index) const
{
if( index >= argc )
naRuntimeError(c, "Missing required arg #%d", index);
return from_nasal<T>(args[index]);
}
return from_nasal<T>(args[index]);
}
template<class T>
naRef to_nasal(T arg) const
{
return nasal::to_nasal(c, arg);
}
template<class T>
naRef to_nasal(T arg) const
{
return nasal::to_nasal(c, arg);
}
template<class T>
typename from_nasal_ptr<T>::return_type
from_nasal(naRef ref) const
{
return (*from_nasal_ptr<T>::get())(c, ref);
}
template<class T>
typename from_nasal_ptr<T>::return_type
from_nasal(naRef ref) const
{
return (*from_nasal_ptr<T>::get())(c, ref);
}
naContext c;
size_t argc;
naRef *args;
naContext c;
size_t argc;
naRef *args;
};
} // namespace nasal

View File

@ -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 )

View File

@ -865,7 +865,7 @@ Expression* logicopParser(const SGPropertyNode* exp, Parser* parser)
ExpParserRegistrar andRegistrar("and", logicopParser<AndExpression>);
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
vector<VariableBinding>::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;
}

View File

@ -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<VariableBinding> bindings;
};

View File

@ -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
////////////////////////////////////////////////////////////////////////