Added proper constructor for JS Array object.
git-svn-id: http://voip.null.ro/svn/yate@5789 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
072f8d720c
commit
42f71895c5
|
@ -543,6 +543,27 @@ bool JsArray::runField(ObjList& stack, const ExpOperation& oper, GenObject* cont
|
|||
return JsObject::runField(stack,oper,context);
|
||||
}
|
||||
|
||||
JsObject* JsArray::runConstructor(ObjList& stack, const ExpOperation& oper, GenObject* context)
|
||||
{
|
||||
if (!ref())
|
||||
return 0;
|
||||
JsArray* obj = static_cast<JsArray*>(clone("[object " + oper.name() + "]"));
|
||||
unsigned int len = oper.number();
|
||||
for (unsigned int i = len; i; i--) {
|
||||
ExpOperation* op = obj->popValue(stack,context);
|
||||
if ((len == 1) && op->isInteger() && (op->number() >= 0) && (op->number() <= 0xffffffff)) {
|
||||
len = op->number();
|
||||
TelEngine::destruct(op);
|
||||
break;
|
||||
}
|
||||
const_cast<String&>(op->name()) = i - 1;
|
||||
obj->params().paramList()->insert(op);
|
||||
}
|
||||
obj->setLength(len);
|
||||
obj->params().addParam(new ExpWrapper(this,protoName()));
|
||||
return obj;
|
||||
}
|
||||
|
||||
bool JsArray::runNative(ObjList& stack, const ExpOperation& oper, GenObject* context)
|
||||
{
|
||||
XDebug(DebugAll,"JsArray::runNative() '%s' in '%s' [%p]",
|
||||
|
|
|
@ -2251,6 +2251,15 @@ public:
|
|||
*/
|
||||
virtual bool runField(ObjList& stack, const ExpOperation& oper, GenObject* context);
|
||||
|
||||
/**
|
||||
* Array object constructor, it's run on the prototype
|
||||
* @param stack Evaluation stack in use
|
||||
* @param oper Constructor function to evaluate
|
||||
* @param context Pointer to arbitrary object passed from evaluation methods
|
||||
* @return New created and populated Javascript Array object
|
||||
*/
|
||||
virtual JsObject* runConstructor(ObjList& stack, const ExpOperation& oper, GenObject* context);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Clone and rename method
|
||||
|
|
Loading…
Reference in New Issue