Esempio n. 1
2
//! initMembers
void Object::init(EScript::Namespace & globals) {
	Type * typeObject = getTypeObject();
	typeObject->allowUserInheritance(true);
	initPrintableName(typeObject,getClassName());

	declareConstant(&globals,getClassName(),typeObject);

	//! [ESMF] Object new Object
	ES_CTOR(typeObject,0,0,new Object(thisType))

	//! [ESMF] Object Object.clone()
	ES_FUN(typeObject,"clone",0,0,thisEObj->clone())

	//! [ESMF] Number Object.toNumber()
	ES_FUN(typeObject,"toNumber",0,0,thisEObj->toDouble())

	//! [ESMF] String Object.toString()
	ES_FUN(typeObject,"toString",0,0,thisEObj->toString())

	//! [ESMF] String Object.toDbgString()
	ES_FUN(typeObject,"toDbgString",0,0,thisEObj->toDbgString())

	//! [ESMF] Bool Object.isA(Object o)
	ES_FUN(typeObject,"isA",1,1,thisEObj->isA(parameter[0].castTo<Type>()))

	//! [ESMF] Bool Object ---|> Object
	ES_FUN(typeObject,"---|>",1,1,thisEObj->isA(parameter[0].castTo<Type>()))

	/*!	[ESMF] Bool Object.!=(Object o)
		\note Uses isEqual(...) which calls "=="-Operator
	*/
	ES_FUN(typeObject,"!=",1,1,!thisEObj->isEqual(rt,parameter[0]) )

	/*!	[ESMF] Bool Object.==(Object o)
		\note this is probably the only place where rt_isEqual(...) is called directly.	*/
	ES_FUN(typeObject,"==",1,1,thisEObj->rt_isEqual(rt,parameter[0]))

	//! [ESMF] Bool Object.===(Object o)
	ES_FUN(typeObject,"===",1,1,thisEObj->isIdentical(rt,parameter[0]))

	//! [ESMF] Bool Object.!==(Object o)
	ES_FUN(typeObject,"!==",1,1,!thisEObj->isIdentical(rt,parameter[0]))

	//! [ESMF] Bool !Object()
	ES_FUN(typeObject,"!_pre",0,0,!thisEObj->toBool())

	//! [ESMF] string Object.getTypeName()
	ES_FUN(typeObject,"getTypeName",0,0,thisEObj->getTypeName())

	//! [ESMF] Object Object.getType()
	ES_FUN(typeObject,"getType",0,0,thisEObj->getType())

	//! [ESMF] int Object.hash()
	ES_FUN(typeObject,"hash",0,0,thisEObj->hash().getValue())

	//! [ESMF] Object Object.getAttribute(key)
	ES_FUN(typeObject,"getAttribute",1,1,thisEObj->getAttribute(parameter[0].toString()).getValue())

	//! [ESMF] Object Object.getAttributeProperties(key)
	ES_FUN(typeObject,"getAttributeProperties",1,1,
				static_cast<unsigned int>(thisEObj->getAttribute(parameter[0].toString()).getProperties()))

	//! [ESMF] Object Object.getLocalAttribute(key)
	ES_FUN(typeObject,"getLocalAttribute",1,1,thisEObj->getLocalAttribute(parameter[0].toString()).getValue())

	//! [ESMF] Bool Object.isSet(key)
	ES_FUN(typeObject,"isSet",1,1,!thisEObj->getAttribute(parameter[0].toString()).isNull())

	//! [ESMF] Bool Object.isSetLocally(key)
	ES_FUN(typeObject,"isSetLocally",1,1,!thisEObj->getLocalAttribute(parameter[0].toString()).isNull())

	//! [ESMF] Bool Object.setAttribute(key,value(,flags = ATTR_NORMAL_ATTRIBUTE))
	ES_FUN(typeObject,"setAttribute",2,3,
				thisEObj->setAttribute(parameter[0].toString(),
													Attribute(parameter[1],
													static_cast<Attribute::flag_t>(parameter[2].to<int>(rt)))))

	//! [ESMF] Bool Object.assignAttribute(key,value)
	ES_FUN(typeObject,"assignAttribute",2,2,rt.assignToAttribute(thisEObj,parameter[0].toString(),parameter[1]))

	typedef std::unordered_map<StringId,Object *> attrMap_t; // has to be defined here, due to compiler (gcc) bug.

	//! Map Object._getAttributes()
	ES_FUNCTION(typeObject,"_getAttributes",0,0,{
		attrMap_t attrs;
		thisEObj->collectLocalAttributes(attrs);
		return Map::create(attrs);
	})
Esempio n. 2
0
// -----
//! [static]
void E_ScriptedState::init(EScript::Namespace & lib) {
    EScript::Type * typeObject = getTypeObject();
    declareConstant(&lib, getClassName(), typeObject);
    addFactory<ScriptedState,E_ScriptedState>();
    typeObject->allowUserInheritance(true);

    //! [ESF] new MinSG.ScriptedState()
    ES_CTOR(typeObject,0,0, EScript::create(new ScriptedState( thisType,rt) ))


    //!	[ESMF] void MinSG.ScriptedState.doEnableState(Node,RenderParam) \note ObjectAttribute
    ES_FUN(typeObject,"doEnableState",2,2,(EScript::Number::create(State::STATE_OK)))
    EScript::markAttributeAsObjectAttribute(typeObject,"doEnableState");

    //!	[ESMF] void MinSG.ScriptedState.doDisableState(Node,RenderParam) \note ObjectAttribute
    ES_FUN(typeObject,"doDisableState",2,2,(EScript::Number::create(State::STATE_OK)))
    EScript::markAttributeAsObjectAttribute(typeObject,"doDisableState");

}