当前位置: 首页>>代码示例>>C++>>正文


C++ ASObject::findGettable方法代码示例

本文整理汇总了C++中ASObject::findGettable方法的典型用法代码示例。如果您正苦于以下问题:C++ ASObject::findGettable方法的具体用法?C++ ASObject::findGettable怎么用?C++ ASObject::findGettable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ASObject的用法示例。


在下文中一共展示了ASObject::findGettable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: hasPropertyByMultiname

bool ASObject::hasPropertyByMultiname(const multiname& name, bool considerDynamic)
{
	//We look in all the object's levels
	uint32_t validTraits=DECLARED_TRAIT;
	if(considerDynamic)
		validTraits|=DYNAMIC_TRAIT;

	if(Variables.findObjVar(name, NO_CREATE_TRAIT, validTraits)!=NULL)
		return true;

	if(classdef && classdef->Variables.findObjVar(name, NO_CREATE_TRAIT, BORROWED_TRAIT)!=NULL)
		return true;

	//Check prototype inheritance chain
	if(getClass())
	{
		ASObject* proto = getClass()->prototype.getPtr();
		while(proto)
		{
			if(proto->findGettable(name, false) != NULL)
				return true;
			proto = proto->getprop_prototype();
		}
	}

	//Must not ask for non borrowed traits as static class member are not valid
	return false;
}
开发者ID:lu-zero,项目名称:lightspark,代码行数:28,代码来源:asobject.cpp

示例2: _MNR

_NR<ASObject> ASObject::getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt, Class_base* cls)
{
	check();
	assert(!cls || classdef->isSubClass(cls));
	//Get from the current object without considering borrowed properties
	variable* obj=findGettable(name, false);

	if(!obj && cls)
	{
		//Look for borrowed traits before
		obj=cls->findGettable(name,true);
	}

	if(!obj && cls)
	{
		//Check prototype chain
		ASObject* proto = cls->prototype.getPtr();
		while(proto)
		{
			obj = proto->findGettable(name, false);
			if(obj)
			{
				obj->var->incRef();
				return _MNR(obj->var);
			}
			proto = proto->getprop_prototype();
		}
	}

	if(!obj)
		return NullRef;

	if(obj->getter)
	{
		//Call the getter
		ASObject* target=this;
		if(target->classdef)
		{
			LOG(LOG_CALLS,_("Calling the getter on type ") << target->classdef->class_name);
		}
		else
		{
			LOG(LOG_CALLS,_("Calling the getter"));
		}
		IFunction* getter=obj->getter;
		target->incRef();
		ASObject* ret=getter->call(target,NULL,0);
		LOG(LOG_CALLS,_("End of getter"));
		// No incRef because ret is a new instance
		return _MNR(ret);
	}
	else
	{
		assert_and_throw(!obj->setter);
		assert_and_throw(obj->var);
		if(obj->var->getObjectType()==T_FUNCTION && obj->var->as<IFunction>()->isMethod())
		{
			LOG(LOG_CALLS,"Attaching this " << this << " to function " << name);
			//the obj reference is acquired by the smart reference
			this->incRef();
			IFunction* f=obj->var->as<IFunction>()->bind(_MR(this),-1);
			//No incref is needed, as the function is a new instance
			return _MNR(f);
		}
		obj->var->incRef();
		return _MNR(obj->var);
	}
}
开发者ID:lu-zero,项目名称:lightspark,代码行数:68,代码来源:asobject.cpp


注:本文中的ASObject::findGettable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。