本文整理汇总了C++中ASObject::findSettable方法的典型用法代码示例。如果您正苦于以下问题:C++ ASObject::findSettable方法的具体用法?C++ ASObject::findSettable怎么用?C++ ASObject::findSettable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASObject
的用法示例。
在下文中一共展示了ASObject::findSettable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setVariableByMultiname
void ASObject::setVariableByMultiname(const multiname& name, ASObject* o, Class_base* cls)
{
check();
assert(!cls || classdef->isSubClass(cls));
//NOTE: we assume that [gs]etSuper and [sg]etProperty correctly manipulate the cur_level (for getActualClass)
bool has_getter=false;
variable* obj=findSettable(name, false, &has_getter);
if(!obj && cls)
{
//Look for borrowed traits before
//It's valid to override only a getter, so keep
//looking for a settable even if a super class sets
//has_getter to true.
obj=cls->findSettable(name,true,&has_getter);
}
if(!obj && cls)
{
//Look in prototype chain
ASObject* proto = cls->prototype.getPtr();
while(proto)
{
variable* tmp = proto->findSettable(name, false, NULL /*prototypes never have getters/setters*/);
if(tmp)
{
if (tmp->kind != DYNAMIC_TRAIT) // dynamic prototype properties can be overridden
obj = tmp;
break;
}
proto = proto->getprop_prototype();
}
}
if(!obj)
{
if(has_getter)
{
tiny_string err=tiny_string("Error #1074: Illegal write to read-only property ")+name.normalizedName();
if(cls)
err+=tiny_string(" on type ")+cls->getQualifiedClassName();
throw Class<ReferenceError>::getInstanceS(err);
}
//Create a new dynamic variable
obj=Variables.findObjVar(name,DYNAMIC_TRAIT,DYNAMIC_TRAIT);
}
if(obj->setter)
{
//Call the setter
LOG(LOG_CALLS,_("Calling the setter"));
//Overriding function is automatically done by using cur_level
IFunction* setter=obj->setter;
//One argument can be passed without creating an array
ASObject* target=this;
target->incRef();
_R<ASObject> ret= _MR( setter->call(target,&o,1) );
assert_and_throw(ret->is<Undefined>());
LOG(LOG_CALLS,_("End of setter"));
}
else
{
assert_and_throw(!obj->getter);
obj->setVar(o);
}
}