/**
* 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<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]);
- }
-
- /**
- * 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]);
- }
-
- 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);
- }
-
- 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<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]);
+ }
+
+ /**
+ * 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]);
+ }
+
+ 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);
+ }
+
+ naContext c;
+ size_t argc;
+ naRef *args;
};
} // namespace nasal
using std::istream;
using std::ostream;
-\f
/**
* Condition for a single property.
*
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGPropertyCondition.
////////////////////////////////////////////////////////////////////////
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGNotCondition.
////////////////////////////////////////////////////////////////////////
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of 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;
}
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of 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;
}
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGComparisonCondition.
////////////////////////////////////////////////////////////////////////
{
_precision_property = new SGPropertyNode();
_precision_dexp = dexp;
-}\f
-////////////////////////////////////////////////////////////////////////
+}////////////////////////////////////////////////////////////////////////
// Read a condition and use it if necessary.
////////////////////////////////////////////////////////////////////////
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGConditional.
////////////////////////////////////////////////////////////////////////
}
-\f
// The top-level is always an implicit 'and' group
SGCondition *
sgReadCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
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
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;
}
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;
};
timingInfo.push_back(TimingInfo(name, SGTimeStamp::now()));
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of 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];
}
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();
}
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();
}
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;
}
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();
}
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();
}
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();
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();
}
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();
}
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;
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;
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];
}
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGSubsystemGroup::Member
////////////////////////////////////////////////////////////////////////