static int tolua_AIObjectScript_COMMANDSEQUENCEPARAMS_SIZEOF00(lua_State* tolua_S)
{
 tolua_Error tolua_err;
 if (
 !tolua_isusertype(tolua_S,1,"COMMANDSEQUENCEPARAMS",0,&tolua_err) ||
 !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
 goto tolua_lerror;
 else
 {
  COMMANDSEQUENCEPARAMS* self = (COMMANDSEQUENCEPARAMS*)  tolua_tousertype(tolua_S,1,0);
 if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SIZEOF'",NULL);
 {
   CLuaDWORD tolua_ret = (  CLuaDWORD)  sizeof(COMMANDSEQUENCEPARAMS);
 {
#ifdef __cplusplus
 void* tolua_obj = new CLuaDWORD(tolua_ret);
 tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CLuaDWORD");
#else
 void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CLuaDWORD));
 tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CLuaDWORD");
#endif
 }
 }
 }
 return 1;
tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'SIZEOF'.",&tolua_err);
 return 0;
}
static int tolua_DecalScript_ADDDECALSPRITEMESSAGE_SIZEOF00(lua_State* tolua_S)
{
    tolua_Error tolua_err;
    if (
        !tolua_isusertype(tolua_S,1,"ADDDECALSPRITEMESSAGE",0,&tolua_err) ||
        !tolua_isnoobj(tolua_S,2,&tolua_err)
    )
        goto tolua_lerror;
    else
    {
        ADDDECALSPRITEMESSAGE* self = (ADDDECALSPRITEMESSAGE*)  tolua_tousertype(tolua_S,1,0);
        if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SIZEOF'",NULL);
        {
            CLuaDWORD tolua_ret = (  CLuaDWORD)  sizeof(ADDDECALSPRITEMESSAGE);
            {
#ifdef __cplusplus
                void* tolua_obj = new CLuaDWORD(tolua_ret);
                tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CLuaDWORD");
#else
                void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(CLuaDWORD));
                tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"CLuaDWORD");
#endif
            }
        }
    }
    return 1;
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'SIZEOF'.",&tolua_err);
    return 0;
}
static int tolua_list_of_trees_Nonempty_new00_local(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertable(tolua_S,1,"Nonempty",0,&tolua_err) ||
     !tolua_isusertype(tolua_S,2,"Tree",0,&tolua_err) ||
     !tolua_isusertype(tolua_S,3,"ListOfTrees",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,4,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  Tree* first = ((Tree*)  tolua_tousertype(tolua_S,2,0));
  ListOfTrees* rest = ((ListOfTrees*)  tolua_tousertype(tolua_S,3,0));
  {
   Nonempty* tolua_ret = (Nonempty*)  new Nonempty(first,rest);
   tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"Nonempty");
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
 return 0;
#endif
}
示例#4
0
int lua_ftk_event_create(lua_State* L)
{
	FtkEvent* retv = calloc(1, sizeof(FtkEvent));
	tolua_pushusertype_and_takeownership(L, (void*)retv, "FtkEvent");

	return 1;
}
static int tolua_list_of_trees_Branch_new00_local(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertable(tolua_S,1,"Branch",0,&tolua_err) ||
     !tolua_isusertype(tolua_S,2,"Tree",0,&tolua_err) ||
     !tolua_isusertype(tolua_S,3,"Tree",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,4,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  Tree* left = ((Tree*)  tolua_tousertype(tolua_S,2,0));
  Tree* right = ((Tree*)  tolua_tousertype(tolua_S,3,0));
  {
   Branch* tolua_ret = (Branch*)  new Branch(left,right);
   tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"Branch");
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
 return 0;
#endif
}
static int tolua_list_of_trees_Leaf_new00_local(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertable(tolua_S,1,"Leaf",0,&tolua_err) ||
     !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  int value = ((int)  tolua_tonumber(tolua_S,2,0));
  {
   Leaf* tolua_ret = (Leaf*)  new Leaf(value);
   tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"Leaf");
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
 return 0;
#endif
}
示例#7
0
int lua_ftk_gc_create(lua_State* L)
{
	FtkGc* retv = calloc(1, sizeof(FtkGc));
	tolua_pushusertype_and_takeownership(L, (void*)retv, "FtkGc");

	return 1;
}
int player_trade_new_local(lua_State* L)
{
#ifdef _DEBUG
	tolua_Error err;
	if(!tolua_isusertable(L,1,"CPlayerTrade",0,&err) ||
		!tolua_isnoobj(L,2,&err) )
	{
		tolua_error(L,"#ferror in function 'player_trade_new_local'.",&err);
		return 0;
	}
#endif
	CPlayerTrade* ret = new CPlayerTrade();
	tolua_pushusertype_and_takeownership(L,(void*)ret,"CPlayerTrade");
	return 1;
}
示例#9
0
static int tolua_maudio_maudio_Sound_getVelocity00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
 !tolua_isusertype(tolua_S,1,"const maudio::Sound",0,&tolua_err) ||
 !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
 goto tolua_lerror;
 else
#endif
 {
  const maudio::Sound* self = (const maudio::Sound*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
 if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getVelocity'",NULL);
#endif
 {
  osg::Vec3 tolua_ret = (osg::Vec3)  self->getVelocity();
 {
#ifdef __cplusplus
 void* tolua_obj = new osg::Vec3(tolua_ret);
 tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"osg::Vec3");
#else
 void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(osg::Vec3));
 tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"osg::Vec3");
#endif
 }
 }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'getVelocity'.",&tolua_err);
 return 0;
#endif
}
static int tolua_DecalScript_ADDDECALSPRITEMESSAGE_new00_local(lua_State* tolua_S)
{
    tolua_Error tolua_err;
    if (
        !tolua_isusertable(tolua_S,1,"ADDDECALSPRITEMESSAGE",0,&tolua_err) ||
        !tolua_isnoobj(tolua_S,2,&tolua_err)
    )
        goto tolua_lerror;
    else
    {
        {
            ADDDECALSPRITEMESSAGE* tolua_ret = (ADDDECALSPRITEMESSAGE*)  new ADDDECALSPRITEMESSAGE();
            tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"ADDDECALSPRITEMESSAGE");
        }
    }
    return 1;
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
    return 0;
}
static int tolua_AIObjectScript_COMMANDSEQUENCEPARAMS_new00_local(lua_State* tolua_S)
{
 tolua_Error tolua_err;
 if (
 !tolua_isusertable(tolua_S,1,"COMMANDSEQUENCEPARAMS",0,&tolua_err) ||
 !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
 goto tolua_lerror;
 else
 {
 {
  COMMANDSEQUENCEPARAMS* tolua_ret = (COMMANDSEQUENCEPARAMS*)  new COMMANDSEQUENCEPARAMS();
 tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"COMMANDSEQUENCEPARAMS");
 }
 }
 return 1;
tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
 return 0;
}
static int tolua_FadeUtility_FADEUTILITYPARAMS_new00_local(lua_State* tolua_S)
{
 tolua_Error tolua_err;
 if (
 !tolua_isusertable(tolua_S,1,"FADEUTILITYPARAMS",0,&tolua_err) ||
 !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
 goto tolua_lerror;
 else
 {
 {
  FADEUTILITYPARAMS* tolua_ret = (FADEUTILITYPARAMS*)  new FADEUTILITYPARAMS();
 tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"FADEUTILITYPARAMS");
 }
 }
 return 1;
tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
 return 0;
}
static int tolua_list_of_trees_Empty_new00_local(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertable(tolua_S,1,"Empty",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  {
   Empty* tolua_ret = (Empty*)  new Empty();
   tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"Empty");
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
 return 0;
#endif
}
示例#14
0
Atlas::Message::MapType EntityRecipe::createEntity(Eris::TypeService& typeService)
{
	S_LOG_VERBOSE("Creating entity.");

	ScriptingService& scriptingService = EmberServices::getSingleton().getScriptingService();
	// Loading script code
	scriptingService.executeCode(mScript, "LuaScriptingProvider");

	// Walking through adapter bindings
	for (BindingsStore::iterator I = mBindings.begin(); I != mBindings.end(); ++I) {
		const std::string& func = I->second->getFunc();

		S_LOG_VERBOSE(" binding: " << I->first << " to func " << func);

		if (func.empty()) {
			std::vector<std::string>& adapters = I->second->getAdapters();

			if (adapters.size() == 1) {
				std::string adapterName = adapters[0];
				Atlas::Message::Element val = mGUIAdapters[adapterName]->getValue();
				I->second->setValue(val);
			} else {
				S_LOG_WARNING("Should be only one adapter without calling function.");
			}
		} else {
			Lua::LuaScriptingCallContext callContext;

			lua_State* L = static_cast<Lua::LuaScriptingProvider*> (scriptingService.getProviderFor("LuaScriptingProvider"))->getLuaState();

			// Pushing function params
			std::vector<std::string>& adapters = I->second->getAdapters();
			for (std::vector<std::string>::iterator J = adapters.begin(); J != adapters.end(); J++) {
				std::string adapterName = *J;
				Atlas::Message::Element* val = new Atlas::Message::Element(mGUIAdapters[adapterName]->getValue());
				tolua_pushusertype_and_takeownership(L, val, "Atlas::Message::Element");
			}

			// Calling test function
			scriptingService.callFunction(func, adapters.size(), "LuaScriptingProvider", &callContext);

			LuaRef returnValue(callContext.getReturnValue());

			Atlas::Message::Element returnObj;
			returnObj = returnValue.asObject<Atlas::Message::Element> ("Atlas::Message::Element");
			I->second->setValue(returnObj);
		}
	}
	//Inject all default attributes that aren't yet added.
	// 	TiXmlElement *elem = mEntitySpec->FirstChildElement("atlas");
	// 	if (elem)
	// 	{
	// 		Eris::TypeInfo* erisType = mConn->getTypeService()->getTypeByName(getEntityType());
	// 		if (erisType) {
	// 			const Atlas::Message::MapType& defaultAttributes = erisType->getAttributes();
	// 			for (Atlas::Message::MapType::const_iterator I = defaultAttributes.begin(); I != defaultAttributes.end(); ++I) {
	// 				bool hasAttribute = false;
	// 				TiXmlNode* child(0);
	// 				while(child = elem->IterateChildren(child)) {
	// 					if (child->ToElement()) {
	// 						if (std::string(child->ToElement()->Attribute("name")) == I->first) {
	// 							hasAttribute = true;
	// 							break;
	// 						}
	// 					}
	// 				}
	//
	// 				if (!hasAttribute) {
	// 					//The attribute isn't present, we'll inject it
	// 					//This a bit contrived, since we'll now first convert the atlas into xml and inject it into the TiXmlElement (which will convert the xml strings into TiXml structures). And then later on we'll parse the xml again and create the final atlas data from it. However, the main reason for doing it this way is that in the future we would want to have nested child elements, which could be repeated. And in those cases we'll want to work directly with xml.
	// 				}
	// 			}
	// 		}
	// 	}
	/*
	 std::stringstream str;

	 Atlas::Message::Element element(message);

	 Atlas::Message::QueuedDecoder decoder;

	 Atlas::Codecs::XML codec(str, decoder);
	 Atlas::Formatter formatter(str, codec);
	 Atlas::Message::Encoder encoder(formatter);
	 formatter.streamBegin();
	 encoder.streamMessageElement(message);
	 formatter.streamEnd();
	 */
	if (mEntitySpec) {
		// Print entity into string
		TiXmlPrinter printer;
		printer.SetStreamPrinting();
		mEntitySpec->Accept(&printer);

		S_LOG_VERBOSE("Composed entity: " << printer.Str());

		std::stringstream strStream(printer.CStr(), std::ios::in);

		// Create objects
		Atlas::Message::QueuedDecoder decoder;
		Atlas::Codecs::XML codec(strStream, decoder);

		// Read whole stream into decoder queue
		while (!strStream.eof()) {
			codec.poll();
		}

		// Read decoder queue
		while (decoder.queueSize() > 0) {
			Atlas::Message::MapType m = decoder.popMessage();
			Eris::TypeInfo* erisType = typeService.getTypeByName(getEntityType());
			if (erisType) {
				const Atlas::Message::MapType& defaultAttributes = erisType->getAttributes();
				for (Atlas::Message::MapType::const_iterator I = defaultAttributes.begin(); I != defaultAttributes.end(); ++I) {
					if (m.find(I->first) == m.end()) {
						m.insert(Atlas::Message::MapType::value_type(I->first, I->second));
					}
				}
			}
			return m;
		}
	} else {
		Atlas::Message::MapType msg;
		msg["parents"] = Atlas::Message::ListType(1, mEntityType);
		msg["name"] = getName();
		return msg;
	}
	S_LOG_WARNING("No entity composed");
	return Atlas::Message::MapType();
}
void tolua_pushQVariant__raw(lua_State* L, const QVariant& p_var) {

	QVariant* nvar = new QVariant(p_var);

	tolua_pushusertype_and_takeownership(L, nvar, "QVariant");
};
void tolua_pushQVariant(lua_State* L, const QVariant& val) {

	QVariant::Type type = val.type();

	// convert to native object
	switch (type) {

	case QVariant::Invalid:
		lua_pushnil(L);
		return;

	case QVariant::Bool:
		tolua_pushboolean(L, val.toBool());
		return;

	case QVariant::Int:
	case QVariant::UInt:
	case QVariant::LongLong:
	case QVariant::ULongLong:
	case QVariant::Char:
	case QVariant::Double:
		tolua_pushnumber(L, val.toDouble());
		return;

	case QVariant::String:
		tolua_pushqtstring(L, val.toString());
		return;

	PUSH_TYPE(BitArray);
	PUSH_TYPE(ByteArray);
	PUSH_TYPE(Date);
	PUSH_TYPE(DateTime);
	PUSH_TYPE(LineF);
	PUSH_TYPE(Line);
	PUSH_TYPE(Point);
	PUSH_TYPE(PointF);
	PUSH_TYPE(Rect);
	PUSH_TYPE(RectF);
	PUSH_TYPE(Size);
	PUSH_TYPE(SizeF);
	PUSH_TYPE(StringList);
	PUSH_TYPE(Time);
	PUSH_TYPE(Locale);
	PUSH_TYPE(Url);

	case QVariant::List: {

		QList<QVariant>* obj = new QList<QVariant>(val.value<QList<QVariant> >());
		tolua_pushusertype_and_takeownership(L, obj, "QList<QVariant>");
		return;
	};
	case QVariant::Map: {

		QMap<QString,QVariant>* obj = new QMap<QString,QVariant>(val.value<QMap<QString,QVariant> >());
		tolua_pushusertype_and_takeownership(L, obj, "QList<QVariant>");
		return;
	};

	#ifdef QT_GUI
	PUSH_TYPE(Bitmap);
	PUSH_TYPE(Brush);
	PUSH_TYPE(Color);
	PUSH_TYPE(Cursor);
	PUSH_TYPE(Font);
	PUSH_TYPE(Icon);
	PUSH_TYPE(Image);
	PUSH_TYPE(KeySequence);
	PUSH_TYPE(Palette);
	PUSH_TYPE(Pen);
	PUSH_TYPE(Pixmap);
	PUSH_TYPE(Polygon);
	PUSH_TYPE(Region);
	PUSH_TYPE(SizePolicy);
	PUSH_TYPE(TextLength);
	PUSH_TYPE(TextFormat);
	PUSH_TYPE(PointArray);
	#endif

	case QVariant::UserType:
	default: {

		const char* type_name = val.typeName();
		QVariant* obj = new QVariant(val);
		tolua_pushusertype_and_takeownership(L, obj, "QVariant");

		if (type_name) {
			luaL_getmetatable(L, "QVariant");
			lua_pushstring(L, "tolua_push_value");
			lua_gettable(L, -2);
			lua_pushvalue(L, -3);
			lua_call(L, 1, 1);
			lua_remove(L, -2); // QVariant mt
			if (lua_isnil(L, -1)) {
				lua_pop(L, 1);
			} else {
				lua_remove(L, -2);
			};
		};
		return;
	};

	}; // switch
};
示例#17
0
文件: lua_ftk.c 项目: bbw2008good/ftk
static int lua_ftk_default_log_level(lua_State* L)
{
	FtkLogLevel retv;
	retv = ftk_default_log_level();
	{FtkLogLevel* copy=malloc(sizeof(FtkLogLevel)); if(copy != NULL) memcpy(copy, &retv, sizeof(FtkLogLevel));tolua_pushusertype_and_takeownership(L, (FtkLogLevel*)copy, "FtkLogLevel");}

	return 1;
}