コード例 #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);
	})
コード例 #2
0
void E_OccludeeRenderer::init(EScript::Namespace & lib) {
	declareConstant(&lib, getClassName(), getTypeObject());
	addFactory<MinSG::OccludeeRenderer,E_OccludeeRenderer>();

	//! [ESF] OccludeeRenderer new OccludeeRenderer()
	ES_CTOR(getTypeObject(), 0, 0, new E_OccludeeRenderer(new MinSG::OccludeeRenderer))

}
コード例 #3
0
//! (static) initMembers
void Identifier::init(EScript::Namespace & globals) {
	Type * typeObject=getTypeObject();
	initPrintableName(typeObject,getClassName());

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

	//!	[ESMF] Identifier new Identifier( string )
	ESF_DECLARE(typeObject,"_constructor",1,1,Identifier::create(parameter[0].toString()))

}
コード例 #4
0
//! initMembers
void Namespace::init(EScript::Namespace & globals) {
	// [Namespace] ---|> [ExtObject] ---|> [Object]
	Type * typeObject = getTypeObject();
	initPrintableName(typeObject,getClassName());

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

	//! [ESMF] Namespace new Namespace
	ES_CTOR(typeObject,0,0, new Namespace)
}
コード例 #5
0
//! (static) initMembers
void Function::init(EScript::Namespace & globals) {
	Type * typeObject = getTypeObject();
	initPrintableName(typeObject,getClassName());

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

	//! [ESMF] Number|false Function.getMaxParamCount()
	ES_MFUNCTION(typeObject,Function,"getMaxParamCount",0,0,{
		if(thisObj->getMaxParamCount()<0 )
			return false;
		return thisObj->getMaxParamCount();
	})
コード例 #6
0
void E_TextRenderer::init(EScript::Namespace & lib) {
	EScript::Type * typeObject = getTypeObject();
	EScript::declareConstant(&lib, getClassName(), typeObject);

	//! [ESF] new TextRenderer(String, Number)
	ES_CONSTRUCTOR(typeObject, 2, 2, {
		Util::FontRenderer fontRenderer(parameter[0].toString());
		std::u32string wideString(256, 0);
		std::iota(wideString.begin(), wideString.end(), 0);
		const auto result = fontRenderer.createGlyphBitmap(parameter[1].toUInt(), wideString);
		return new E_TextRenderer(*result.first.get(), result.second);
	})
コード例 #7
0
//! (static) initMembers
void ExtObject::init(EScript::Namespace & globals) {
	Type * typeObject = getTypeObject();
	typeObject->allowUserInheritance(true);
	initPrintableName(typeObject,getClassName());

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

	//!	[ESF] ExtObject new ExtObject( [Map objAttributes] )
	ES_CONSTRUCTOR(typeObject,0,1,{
		ERef<ExtObject> result(new ExtObject(thisType));
		if(parameter.count()>0){
			Map * m = assertType<Map>(rt,parameter[0]);
			for(const auto & keyValuePair : *m) {
				result->setAttribute(keyValuePair.first, Attribute(keyValuePair.second.value));
			}
		}
		return result.detachAndDecrease();
	})
コード例 #8
0
ファイル: Type.cpp プロジェクト: BackupTheBerlios/escript-svn
//! initMembers
void Type::init(EScript::Namespace & globals) {
	// [Type] ---|> [Object]
	Type * typeObject = getTypeObject();
	initPrintableName(typeObject,getClassName());

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

	//! [ESMF] Type new Type( [BaseType = ExtObject] )
	ES_FUNCTION_DECLARE(typeObject,"_constructor",0,1,{
		Type * baseType = parameter.count() == 0 ? ExtObject::getTypeObject() : assertType<Type>(runtime,parameter[0]);
		if(!baseType->allowsUserInheritance()){
			runtime.setException("Basetype '"+baseType->toString()+"' does not allow user inheritance.");
			return nullptr;
		}
		Type * newType = new Type(baseType);
		newType->allowUserInheritance(true); // user defined Types allow user inheritance per default.
		return newType;
	})
コード例 #9
0
ファイル: E_ScriptedState.cpp プロジェクト: eikel/E_MinSG
// -----
//! [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");

}
コード例 #10
0
//! (ctor)
Identifier::Identifier(const StringId &_id):
		Object(getTypeObject()),id(_id) {
	//ctor
}
コード例 #11
0
//! (ctor)
Function::Function(functionPtr _fnptr) :
		Object(getTypeObject()),fnptr(_fnptr),minParamCount(0),maxParamCount(-1),originalName(0),callCounter(0) {
}
コード例 #12
0
//! (ctor)
Function::Function(StringId _originalName, int _minParamCount, int _maxParamCount, functionPtr _fnptr) :
		Object(getTypeObject()),fnptr(_fnptr),minParamCount(_minParamCount),maxParamCount(_maxParamCount),
		originalName(_originalName),callCounter(0) {
}
コード例 #13
0
Collection::Collection(Type * type):ExtObject(type?type:getTypeObject()) {
    //ctor
}
コード例 #14
0
ファイル: PyView.cpp プロジェクト: SASfit/SASfit
PyView::PyView(const c4_View& o, PyView *owner, int state)
  : PyHead(PyViewtype), c4_View(o), _base (owner), _state(state) {
  ob_type = getTypeObject(_state);
  if (owner && owner->_base)
    _base = owner->_base;
}
コード例 #15
0
//! initMembers
void Object::init(EScript::Namespace & globals) {
	Type * typeObject=getTypeObject();
	declareConstant(&globals,getClassName(),typeObject);

	//! [ESMF] Object new Object()
	ESF_DECLARE(typeObject,"_constructor",0,0,new Object(dynamic_cast<Type*>(caller)))

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

	//! [ESMF] Number Object.toNumber()
	ESF_DECLARE(typeObject,"toNumber",0,0,Number::create(caller->toDouble()))

	//! [ESMF] String Object.toString()
	ESF_DECLARE(typeObject,"toString",0,0,String::create(caller->toString()))

	//! [ESMF] String Object.toDbgString()
	ESF_DECLARE(typeObject,"toDbgString",0,0,String::create(caller->toDbgString()))

	//! [ESMF] Object Object.execute()
	ESF_DECLARE(typeObject,"execute",0,0,runtime.executeObj(caller))

	//! [ESMF] Bool Object.isA(Object o)
	ESF_DECLARE(typeObject,"isA",1,1,Bool::create(caller->isA(parameter[0].toType<Type>())))

	//! [ESMF] Bool Object ---|> Object
	ESF_DECLARE(typeObject,"---|>",1,1,Bool::create(caller->isA(parameter[0].toType<Type>())))

	/*!	[ESMF] Bool Object.!=(Object o)
		\note Uses isEqual(...) which calls "=="-Operator
	*/
	ESF_DECLARE(typeObject,"!=",1,1,Bool::create(! caller->isEqual(runtime,parameter[0]) ))

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

	//! [ESMF] Bool Object.===(Object o)
	ESF_DECLARE(typeObject,"===",1,1,Bool::create(caller->isIdentical(runtime,parameter[0])))

	//! [ESMF] Bool Object.!==(Object o)
	ESF_DECLARE(typeObject,"!==",1,1,Bool::create(!caller->isIdentical(runtime,parameter[0])))

	//! [ESMF] Bool !Object()
	ESF_DECLARE(typeObject,"!_pre",0,0,Bool::create(!caller->toBool()))

	//! [ESMF] string Object.getTypeName()
	ESF_DECLARE(typeObject,"getTypeName",0,0,String::create(caller->getTypeName()))

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

	//! [ESMF] int Object.hash()
	ESF_DECLARE(typeObject,"hash",0,0,Number::create(caller->hash()))

	//! [ESMF] Object Object.getAttribute(key)
	ESF_DECLARE(typeObject,"getAttribute",1,1,caller->getAttribute(parameter[0]->hash()))

	//! [ESMF] Bool Object.isSet(key)
	ESF_DECLARE(typeObject,"isSet",1,1,Bool::create(caller->getAttribute(parameter[0]->hash())!=NULL))

	//! [ESMF] Bool Object.setObjAttribute(key,value)
	ESF_DECLARE(typeObject,"setObjAttribute",2,2,Bool::create(caller->setObjAttribute(parameter[0]->hash(),parameter[1])))

	//! [ESMF] Bool Object.assignAttribute(key,value)
	ESF_DECLARE(typeObject,"assignAttribute",2,2,Bool::create(caller->assignAttribute(parameter[0]->hash(),parameter[1])))

	typedef std::map<identifierId,Object *> attrMap_t; // has to be defined here, due to compiler (gcc) bug.
	//! Map Object._getAttributes()
	ES_FUNCTION_DECLARE(typeObject,"_getAttributes",0,0,{
		attrMap_t attrs;
		caller->getAttributes(attrs);
		return Map::create(attrs);
	})