本文整理汇总了C++中IFunction::call方法的典型用法代码示例。如果您正苦于以下问题:C++ IFunction::call方法的具体用法?C++ IFunction::call怎么用?C++ IFunction::call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFunction
的用法示例。
在下文中一共展示了IFunction::call方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ASFUNCTIONBODY(Array,forEach)
{
assert_and_throw(argslen == 1 || argslen == 2);
Array* th=static_cast<Array*>(obj);
IFunction* f = static_cast<IFunction*>(args[0]);
ASObject* params[3];
std::map<uint32_t, data_slot>::iterator it=th->data.begin();
for(;it != th->data.end();++it)
{
assert_and_throw(it->second.type==DATA_OBJECT);
params[0] = it->second.data;
it->second.data->incRef();
params[1] = abstract_i(it->first);
params[2] = th;
th->incRef();
ASObject *funcret;
if( argslen == 1 )
{
funcret=f->call(getSys()->getNullRef(), params, 3);
}
else
{
args[1]->incRef();
funcret=f->call(args[1], params, 3);
}
if(funcret)
funcret->decRef();
}
return NULL;
}
示例2:
ASFUNCTIONBODY(Array,forEach)
{
assert_and_throw(argslen == 1 || argslen == 2);
Array* th=static_cast<Array*>(obj);
IFunction* f = static_cast<IFunction*>(args[0]);
ASObject* params[3];
for(unsigned int i=0; i < th->data.size(); i++)
{
assert_and_throw(th->data[i].type==DATA_OBJECT);
params[0] = th->data[i].data;
th->data[i].data->incRef();
params[1] = abstract_i(i);
params[2] = th;
th->incRef();
ASObject *funcret;
if( argslen == 1 )
{
funcret=f->call(new Null, params, 3);
}
else
{
args[1]->incRef();
funcret=f->call(args[1], params, 3);
}
if(funcret)
funcret->decRef();
}
return NULL;
}
示例3: abstract_b
ASFUNCTIONBODY(Vector, every)
{
Vector* th=static_cast<Vector*>(obj);
if (argslen < 1)
throw Class<ArgumentError>::getInstanceS("Error #1063");
if (!args[0]->is<IFunction>())
throw Class<TypeError>::getInstanceS("Error #1034");
IFunction* f = static_cast<IFunction*>(args[0]);
ASObject* params[3];
ASObject *funcRet;
for(unsigned int i=0; i < th->size(); i++)
{
if (th->vec[i])
{
params[0] = th->vec[i];
th->vec[i]->incRef();
}
else
params[0] = getSys()->getNullRef();
params[1] = abstract_i(i);
params[2] = th;
th->incRef();
if(argslen==1)
{
funcRet=f->call(getSys()->getNullRef(), params, 3);
}
else
{
args[1]->incRef();
funcRet=f->call(args[1], params, 3);
}
if(funcRet)
{
if (funcRet->is<Undefined>() || funcRet->is<Null>())
throw Class<TypeError>::getInstanceS("Error #1006");
if(!Boolean_concrete(funcRet))
{
return funcRet;
}
funcRet->decRef();
}
}
return abstract_b(true);
}
示例4: abstract_b
ASFUNCTIONBODY(Vector, every)
{
Vector* th=static_cast<Vector*>(obj);
if (argslen < 1)
throwError<ArgumentError>(kWrongArgumentCountError, "Vector.some", "1", Integer::toString(argslen));
if (!args[0]->is<IFunction>())
throwError<TypeError>(kCheckTypeFailedError, args[0]->getClassName(), "Function");
IFunction* f = static_cast<IFunction*>(args[0]);
ASObject* params[3];
ASObject *funcRet;
for(unsigned int i=0; i < th->size(); i++)
{
if (th->vec[i])
{
params[0] = th->vec[i];
th->vec[i]->incRef();
}
else
params[0] = obj->getSystemState()->getNullRef();
params[1] = abstract_i(obj->getSystemState(),i);
params[2] = th;
th->incRef();
if(argslen==1)
{
funcRet=f->call(obj->getSystemState()->getNullRef(), params, 3);
}
else
{
args[1]->incRef();
funcRet=f->call(args[1], params, 3);
}
if(funcRet)
{
if (funcRet->is<Undefined>() || funcRet->is<Null>())
throwError<TypeError>(kCallOfNonFunctionError, funcRet->toString());
if(!Boolean_concrete(funcRet))
{
return funcRet;
}
funcRet->decRef();
}
}
return abstract_b(obj->getSystemState(),true);
}
示例5:
ASFUNCTIONBODY(Vector,filter)
{
if (argslen < 1 || argslen > 2)
throw Class<ArgumentError>::getInstanceS("Error #1063");
if (!args[0]->is<IFunction>())
throw Class<TypeError>::getInstanceS("Error #1034");
Vector* th=static_cast<Vector*>(obj);
IFunction* f = static_cast<IFunction*>(args[0]);
ASObject* params[3];
Vector* ret= (Vector*)obj->getClass()->getInstance(true,NULL,0);
ASObject *funcRet;
for(unsigned int i=0;i<th->size();i++)
{
if (!th->vec[i])
continue;
params[0] = th->vec[i];
th->vec[i]->incRef();
params[1] = abstract_i(i);
params[2] = th;
th->incRef();
if(argslen==1)
{
funcRet=f->call(getSys()->getNullRef(), params, 3);
}
else
{
args[1]->incRef();
funcRet=f->call(args[1], params, 3);
}
if(funcRet)
{
if(Boolean_concrete(funcRet))
{
th->vec[i]->incRef();
ret->vec.push_back(th->vec[i]);
}
funcRet->decRef();
}
}
return ret;
}
示例6:
ASFUNCTIONBODY(Vector,filter)
{
if (argslen < 1 || argslen > 2)
throwError<ArgumentError>(kWrongArgumentCountError, "Vector.filter", "1", Integer::toString(argslen));
if (!args[0]->is<IFunction>())
throwError<TypeError>(kCheckTypeFailedError, args[0]->getClassName(), "Function");
Vector* th=static_cast<Vector*>(obj);
IFunction* f = static_cast<IFunction*>(args[0]);
ASObject* params[3];
Vector* ret= (Vector*)obj->getClass()->getInstance(true,NULL,0);
ASObject *funcRet;
for(unsigned int i=0;i<th->size();i++)
{
if (!th->vec[i])
continue;
params[0] = th->vec[i];
th->vec[i]->incRef();
params[1] = abstract_i(obj->getSystemState(),i);
params[2] = th;
th->incRef();
if(argslen==1)
{
funcRet=f->call(obj->getSystemState()->getNullRef(), params, 3);
}
else
{
args[1]->incRef();
funcRet=f->call(args[1], params, 3);
}
if(funcRet)
{
if(Boolean_concrete(funcRet))
{
th->vec[i]->incRef();
ret->vec.push_back(th->vec[i]);
}
funcRet->decRef();
}
}
return ret;
}
示例7: abstract_b
ASFUNCTIONBODY(Vector, some)
{
if (argslen < 1)
throw Class<ArgumentError>::getInstanceS("Error #1063");
if (!args[0]->is<IFunction>())
throw Class<TypeError>::getInstanceS("Error #1034");
Vector* th=static_cast<Vector*>(obj);
IFunction* f = static_cast<IFunction*>(args[0]);
ASObject* params[3];
ASObject *funcRet;
for(unsigned int i=0; i < th->size(); i++)
{
if (!th->vec[i])
continue;
params[0] = th->vec[i];
th->vec[i]->incRef();
params[1] = abstract_i(i);
params[2] = th;
th->incRef();
if(argslen==1)
{
funcRet=f->call(new Null, params, 3);
}
else
{
args[1]->incRef();
funcRet=f->call(args[1], params, 3);
}
if(funcRet)
{
if(Boolean_concrete(funcRet))
{
return funcRet;
}
funcRet->decRef();
}
}
return abstract_b(false);
}
示例8: abstract_b
ASFUNCTIONBODY(EventDispatcher,dispatchEvent)
{
EventDispatcher* th=Class<EventDispatcher>::cast(obj);
if(args[0]->getClass()==NULL || !(args[0]->getClass()->isSubClass(Class<Event>::getClass())))
return abstract_b(false);
args[0]->incRef();
_R<Event> e=_MR(Class<Event>::cast(args[0]));
assert_and_throw(e->type!="");
if(!e->target.isNull())
{
//Object must be cloned, closing is implemented with the clone AS method
multiname cloneName;
cloneName.name_type=multiname::NAME_STRING;
cloneName.name_s="clone";
cloneName.ns.push_back(nsNameAndKind("",PACKAGE_NAMESPACE));
_NR<ASObject> clone=e->getVariableByMultiname(cloneName);
if(!clone.isNull() && clone->getObjectType()==T_FUNCTION)
{
IFunction* f = static_cast<IFunction*>(clone.getPtr());
e->incRef();
ASObject* funcRet=f->call(e.getPtr(),NULL,0);
//Verify that the returned object is actually an event
Event* newEvent=dynamic_cast<Event*>(funcRet);
if(newEvent==NULL)
{
if(funcRet)
funcRet->decRef();
return abstract_b(false);
}
e=_MR(newEvent);
}
else
{
//TODO: support cloning of actual type
LOG(LOG_NOT_IMPLEMENTED,"Event cloning not supported!");
e=_MR(Class<Event>::getInstanceS(e->type,e->bubbles, e->cancelable));
}
}
th->incRef();
ABCVm::publicHandleEvent(_MR(th), e);
return abstract_b(true);
}
示例9: abstract_b
ASFUNCTIONBODY(EventDispatcher,dispatchEvent)
{
EventDispatcher* th=Class<EventDispatcher>::cast(obj);
if(args[0]->getClass()==NULL || !(args[0]->getClass()->isSubClass(Class<Event>::getClass())))
return abstract_b(false);
args[0]->incRef();
_R<Event> e=_MR(Class<Event>::cast(args[0]));
assert_and_throw(e->type!="");
if(!e->target.isNull())
{
//Object must be cloned, closing is implemented with the clone AS method
multiname cloneName(NULL);
cloneName.name_type=multiname::NAME_STRING;
cloneName.name_s_id=getSys()->getUniqueStringId("clone");
cloneName.ns.push_back(nsNameAndKind("",NAMESPACE));
_NR<ASObject> clone=e->getVariableByMultiname(cloneName);
//Clone always exists since it's implemented in Event itself
assert(!clone.isNull());
IFunction* f = static_cast<IFunction*>(clone.getPtr());
e->incRef();
ASObject* funcRet=f->call(e.getPtr(),NULL,0);
//Verify that the returned object is actually an event
Event* newEvent=dynamic_cast<Event*>(funcRet);
if(newEvent==NULL)
{
if(funcRet)
funcRet->decRef();
return abstract_b(false);
}
e=_MR(newEvent);
}
if(!th->forcedTarget.isNull())
e->setTarget(th->forcedTarget);
th->incRef();
ABCVm::publicHandleEvent(_MR(th), e);
return abstract_b(true);
}