Fixed Array.push() method that was not copying objects correctly and not copying non-objects at all.

Added some more XDEBUG for iterators.


git-svn-id: http://yate.null.ro/svn/yate/trunk@5149 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2012-06-25 15:41:47 +00:00
parent 1d97a1eb67
commit 207552e4ea
3 changed files with 16 additions and 13 deletions

View File

@ -1837,6 +1837,7 @@ bool JsCode::runOperation(ObjList& stack, const ExpOperation& oper, GenObject* c
bool ok = false;
String* n = iter->get();
if (n) {
XDebug(DebugInfo,"Iterator got item: '%s'",n->c_str());
static const ExpOperation s_assign(OpcAssign);
pushOne(stack,iter->field().clone());
if (iter->name())

View File

@ -223,6 +223,11 @@ void JsObject::fillFieldNames(ObjList& names)
const NamedList* native = nativeParams();
if (native)
ScriptContext::fillFieldNames(names,*native);
#ifdef XDEBUG
String tmp;
tmp.append(names,",");
Debug(DebugInfo,"JsObject::fillFieldNames: %s",tmp.c_str());
#endif
}
bool JsObject::hasField(ObjList& stack, const String& name, GenObject* context) const
@ -465,21 +470,13 @@ bool JsArray::runNative(ObjList& stack, const ExpOperation& oper, GenObject* con
oper.name().c_str(),toString().c_str(),this);
if (oper.name() == YSTRING("push")) {
// Adds one or more elements to the end of an array and returns the new length of the array.
if (!oper.number())
ObjList args;
if (!extractArgs(this,stack,oper,context,args))
return false;
for (long int i = oper.number(); i; i--) {
ExpOperation* op = popValue(stack,context);
ExpWrapper* obj = YOBJECT(ExpWrapper,op);
if (!obj)
continue;
JsObject* jo = (JsObject*)obj->getObject(YSTRING("JsObject"));
if (!jo)
continue;
jo->ref();
params().addParam(new NamedPointer(String((unsigned int)(m_length + i - 1)),jo));
TelEngine::destruct(op);
while (ExpOperation* op = static_cast<ExpOperation*>(args.remove(false))) {
const_cast<String&>(op->name()) = (unsigned int)m_length++;
params().addParam(op);
}
m_length += oper.number();
setLength();
ExpEvaluator::pushOne(stack,new ExpOperation(length()));
}

View File

@ -189,6 +189,11 @@ void ScriptContext::fillFieldNames(ObjList& names)
const NamedList* native = nativeParams();
if (native)
fillFieldNames(names,*native);
#ifdef XDEBUG
String tmp;
tmp.append(names,",");
Debug(DebugInfo,"ScriptContext::fillFieldNames: %s",tmp.c_str());
#endif
}
void ScriptContext::fillFieldNames(ObjList& names, const NamedList& list, const char* skip)