Fixed boolean evaluation for objects and function objects.

git-svn-id: http://voip.null.ro/svn/yate@5329 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2012-11-20 16:03:44 +00:00
parent 4cdd8136b0
commit b92a1a66cb
2 changed files with 22 additions and 2 deletions

View File

@ -1499,6 +1499,13 @@ ExpOperation* ExpWrapper::copy(Mutex* mtx) const
return op;
}
bool ExpWrapper::valBoolean() const
{
if (!m_object)
return false;
return !JsParser::isNull(*this);
}
void* ExpWrapper::getObject(const String& name) const
{
if (name == YSTRING("ExpWrapper"))

View File

@ -963,13 +963,13 @@ public:
{ m_number = num; String::operator=((int)num); return num; }
/**
* Retrive the numeric value of the operation
* Retrieve the numeric value of the operation
* @return Number contained in operation, zero if not a number
*/
virtual long int valInteger() const;
/**
* Retrive the boolean value of the operation
* Retrieve the boolean value of the operation
* @return True if the operation is to be interpreted as true value
*/
virtual bool valBoolean() const;
@ -1020,6 +1020,13 @@ public:
: ExpOperation(ExpEvaluator::OpcFunc,name,argc)
{ if (name) (*this) << "[function " << name << "()]"; }
/**
* Retrieve the boolean value of the function (not of its result)
* @return Always true
*/
virtual bool valBoolean() const
{ return true; }
/**
* Clone and rename method
* @param name Name of the cloned operation
@ -1070,6 +1077,12 @@ public:
*/
virtual void* getObject(const String& name) const;
/**
* Retrieve the boolean value of the operation
* @return True if the wrapped object is to be interpreted as true value
*/
virtual bool valBoolean() const;
/**
* Clone and rename method
* @param name Name of the cloned operation