/* set function: A::B::b */
static int tolua_set_B_b(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
 tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
  A::B::b = ((int)  tolua_tonumber(tolua_S,2,0));
 return 0;
}
Exemple #2
0
static int tolua_EQUIPINFO_getEquipHole(lua_State *tolua_S)
{
#ifndef TOLUA_TXGUI_RELEASE
	tolua_Error tolua_err;
	if(!tolua_isusertype(tolua_S,1,"EQUIPINFO",0,&tolua_err) ||
		!tolua_isnoobj(tolua_S, 2, &tolua_err)
		)
	{
		tolua_error(tolua_S,"#ferror in function 'EQUIPINFO::getEquipHole'",&tolua_err);
		return 0;
	}
#endif
	EQUIPINFO* self = (EQUIPINFO*)tolua_tousertype(tolua_S,1,0);
	int pos = tolua_tonumber(tolua_S, 2, 0);

	lua_newtable(tolua_S);
	for(std::map<unsigned int,EQUIPHOLE>::iterator it = self->m_equipHoles.begin();
		it != self->m_equipHoles.end(); ++it)
	{
		unsigned int holePos = it->first;
		EQUIPHOLE hole = it->second;

		lua_pushnumber(tolua_S,hole.hole_index);
		lua_newtable(tolua_S);

		lua_pushstring(tolua_S,"hole_index");
		lua_pushnumber(tolua_S,hole.hole_index);
		lua_settable(tolua_S, -3);

		lua_pushstring(tolua_S,"item_gem_id");
		lua_pushnumber(tolua_S,hole.item_gem_id);
		lua_settable(tolua_S, -3);

		lua_pushstring(tolua_S,"attr_key");
		lua_pushnumber(tolua_S,hole.attr_key);
		lua_settable(tolua_S, -3);

		lua_pushstring(tolua_S,"attr_value");
		lua_pushnumber(tolua_S,hole.attr_value);
		lua_settable(tolua_S, -3);

		lua_pushstring(tolua_S,"max_value");
		lua_pushnumber(tolua_S,hole.max_value);
		lua_settable(tolua_S, -3);

		lua_pushstring(tolua_S,"min_value");
		lua_pushnumber(tolua_S,hole.min_value);
		lua_settable(tolua_S, -3);

		lua_settable(tolua_S, -3);
	}

	return 1;
	
}
static int tolua_cocos2d_Control_registerControlEventHandler(lua_State* tolua_S)
{
    if (NULL == tolua_S)
        return 0;

    int argc = 0;
    Control* self = nullptr;

#if COCOS2D_DEBUG >= 1
    tolua_Error tolua_err;
    if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror;
#endif

    self = static_cast<Control*>(tolua_tousertype(tolua_S,1,0));

#if COCOS2D_DEBUG >= 1
    if (nullptr == self) {
        tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_Control_registerControlEventHandler'\n", NULL);
        return 0;
    }
#endif

    argc = lua_gettop(tolua_S) - 1;

    if (2 == argc)
    {
#if COCOS2D_DEBUG >= 1
        if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
                !tolua_isnumber(tolua_S, 3, 0, &tolua_err) )
        {
            goto tolua_lerror;
        }
#endif
        LUA_FUNCTION handler = (  toluafix_ref_function(tolua_S,2,0));
        int controlevent = (int)tolua_tonumber(tolua_S,3,0);
        for (int i = 0; i < kControlEventTotalNumber; i++)
        {
            if ((controlevent & (1 << i)))
            {
                ScriptHandlerMgr::HandlerType handlerevent  = ScriptHandlerMgr::HandlerType((int)ScriptHandlerMgr::HandlerType::CONTROL_TOUCH_DOWN + i);
                ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerevent);
            }
        }
        return 0;
    }

    luaL_error(tolua_S, "%s function of Control has wrong number of arguments: %d, was expecting %d\n", "cc.Control:registerControlEventHandler", argc, 2);
    return 0;

#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_Control_registerControlEventHandler'.",&tolua_err);
    return 0;
#endif
}
Exemple #4
0
static int tolua_ShowWaitingLayer(lua_State *tolua_S)
{
#ifndef TOLUA_TXGUI_RELEASE
	bool bHasBooleanParam = false;
	bool bHasFloatParam = false;
	bool bShowRightNow = true;
	float fHideTimer = 0;

	tolua_Error tolua_err;
	if (tolua_isboolean(tolua_S, 1, 0, &tolua_err))
	{
		bHasBooleanParam = true;
		bShowRightNow = tolua_toboolean(tolua_S, 1, 0);
		if (tolua_isnumber(tolua_S, 2, 0, &tolua_err))
		{
			bHasFloatParam = true;
			fHideTimer = tolua_tonumber(tolua_S, 2, 0);
		}
	}
	
	int lastIndex = 1;
	if (bHasBooleanParam)
	{
		lastIndex ++;
		if (bHasFloatParam)
		{
			lastIndex++;
		}
	}
	if(!tolua_isnoobj(tolua_S, lastIndex, &tolua_err))
	{
		tolua_error(tolua_S,"#ferror in function 'ShowWaitingLayer'",&tolua_err);
		return 0;
	}
#endif

	if (false == bHasBooleanParam)
	{
		ShowWaitingLayer();
	}
	else
	{
		if (false == bHasFloatParam)
		{
			ShowWaitingLayer(bShowRightNow);
		}
		else
		{
			ShowWaitingLayer(bShowRightNow,fHideTimer);
		}
	}

	return 0;
}
Exemple #5
0
static int tolua_ship_set_coast(lua_State * L)
{
    ship *self = (ship *)tolua_tousertype(L, 1, 0);
    if (lua_isnil(L, 2)) {
        self->coast = NODIRECTION;
    }
    else if (lua_isnumber(L, 2)) {
        self->coast = (direction_t)tolua_tonumber(L, 2, 0);
    }
    return 0;
}
Exemple #6
0
static int tolua_set_wyDevice_scaledDensity(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
  tolua_Error tolua_err;
  if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
   tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
  wyDevice::scaledDensity = ((float)  tolua_tonumber(tolua_S,2,0))
;
 return 0;
}
Exemple #7
0
static int tolua_set_wyDevice_realHeight(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
  tolua_Error tolua_err;
  if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
   tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
  wyDevice::realHeight = ((int)  tolua_tonumber(tolua_S,2,0))
;
 return 0;
}
static int tolua_cocos2dx_Controller_getKeyStatus(lua_State* tolua_S)
{
    if (nullptr == tolua_S)
        return 0;
    
    int argc = 0;
    cocos2d::Controller* self = nullptr;
#if COCOS2D_DEBUG >= 1
    tolua_Error tolua_err;
    if (!tolua_isusertype(tolua_S, 1, "cc.Controller", 0, &tolua_err))  goto tolua_lerror;
#endif
    
    self = static_cast<cocos2d::Controller*>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
    if (nullptr == self) {
		tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Controller_getKeyStatus'\n", nullptr);
		return 0;
	}
#endif
    
    argc = lua_gettop(tolua_S) - 1;
    
    if (argc == 1)
    {
#if COCOS2D_DEBUG >= 1
        if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
            goto tolua_lerror;
#endif
        int keyCode = (int)tolua_tonumber(tolua_S, 2, 0);
        cocos2d::Controller::KeyStatus keyStatus = self->getKeyStatus(keyCode);
        
        lua_newtable(tolua_S);                                    /* L: table */
        lua_pushstring(tolua_S, "isPressed");                     /* L: table key */
        lua_pushboolean(tolua_S, (int)keyStatus.isPressed);            /* L: table key value*/
        lua_rawset(tolua_S, -3);                                  /* table[key] = value, L: table */
        lua_pushstring(tolua_S, "value");                         /* L: table key */
        lua_pushnumber(tolua_S, (lua_Number) keyStatus.value);    /* L: table key value*/
        lua_rawset(tolua_S, -3);                                  /* table[key] = value, L: table */
        lua_pushstring(tolua_S, "isAnalog");                         /* L: table key */
        lua_pushnumber(tolua_S, (int) keyStatus.isAnalog);           /* L: table key value*/
        lua_rawset(tolua_S, -3);                                  /* table[key] = value, L: table */

        return 1;
    }
    
    CCLOG("'clone' has wrong number of arguments: %d, was expecting %d\n", argc, 0);
    return 0;
    
#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'getKeyStatus'.",&tolua_err);
    return 0;
#endif
}
Exemple #9
0
void cLuaState::GetStackValue(int a_StackPos, eWeather & a_ReturnedVal)
{
	if (!lua_isnumber(m_LuaState, a_StackPos))
	{
		return;
	}
	a_ReturnedVal = static_cast<eWeather>(Clamp(
		static_cast<int>(tolua_tonumber(m_LuaState, a_StackPos, a_ReturnedVal)),
		static_cast<int>(wSunny), static_cast<int>(wThunderstorm))
	);
}
static int tolua_set_FADEUTILITYPARAMS_EndFadeAmount (lua_State* tolua_S) {
  FADEUTILITYPARAMS*self = (FADEUTILITYPARAMS*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
 if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'EndFadeAmount'",NULL);
#endif
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
 self->EndFadeAmount=(( float) tolua_tonumber(tolua_S,2,0));
 return 0;}
Exemple #11
0
static int tolua_region_get_next(lua_State * L)
{
    region *self = (region *)tolua_tousertype(L, 1, 0);
    direction_t dir = (direction_t)tolua_tonumber(L, 2, 0);

    if (dir >= 0 && dir < MAXDIRECTIONS) {
        tolua_pushusertype(L, (void *)r_connect(self, dir), TOLUA_CAST "region");
        return 1;
    }
    return 0;
}
static int tolua_set_ADDDECALSPRITEMESSAGE_m_Size (lua_State* tolua_S) {
    ADDDECALSPRITEMESSAGE*self = (ADDDECALSPRITEMESSAGE*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
    if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'm_Size'",NULL);
#endif
#ifndef TOLUA_RELEASE
    tolua_Error tolua_err;
    if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
    self->m_Size=(( float) tolua_tonumber(tolua_S,2,0));
    return 0;
}
Exemple #13
0
static int tolua_region_set_flag(lua_State * L)
{
    region *self = (region *)tolua_tousertype(L, 1, 0);
    int bit = (int)tolua_tonumber(L, 2, 0);
    int set = tolua_toboolean(L, 3, 1);

    if (set)
        self->flags |= (1 << bit);
    else
        self->flags &= ~(1 << bit);
    return 0;
}
Exemple #14
0
static int lua_ftk_text_view_insert_text(lua_State* L)
{
	tolua_Error err = {0};
	Ret retv;
	FtkWidget* thiz;
	int pos;
	const char* text;
	int len;
	int param_ok = tolua_isusertype(L, 1, "FtkWidget", 0, &err) && tolua_isnumber(L, 2, 0, &err) && tolua_isstring(L, 3, 0, &err) && tolua_isnumber(L, 4, 0, &err);

	return_val_if_fail(param_ok, 0);

	thiz = tolua_tousertype(L, 1, 0);
	pos = tolua_tonumber(L, 2, 0);
	text = tolua_tostring(L, 3, 0);
	len = tolua_tonumber(L, 4, 0);
	retv = ftk_text_view_insert_text(thiz, pos, text, len);
	tolua_pushnumber(L, (lua_Number)retv);

	return 1;
}
	///
	/// 检查当前脚本运行实例是否有某个脚本列表
	///
	/// ret = HasVarList( operType )
	/// @param operType: VT_SCRIPT脚本本身,只在技能脚本里有效;
	/// VT_SRCSHAPE源对象;VT_DESTSHAPE目标对象;
	/// VT_GLOBAL全局变量
	/// @return 1表示存在
	///
	static int HasVarList( lua_State *L )
	{
		Script *script = GetInst( ScriptSys ).GetScript( L );
		int ret = 1;
		long operType = (long) tolua_tonumber( L, 1, 0 );
		if( script == NULL || script->GetVarList( operType ) == NULL )
		{
			ret = 0;	
		}
		lua_pushboolean( L, ret );
		return 1;
	}
Exemple #16
0
bool cLuaState::GetStackValue(int a_StackPos, eBlockFace & a_ReturnedVal)
{
	if (!lua_isnumber(m_LuaState, a_StackPos))
	{
		return false;
	}
	a_ReturnedVal = static_cast<eBlockFace>(Clamp(
		static_cast<int>(tolua_tonumber(m_LuaState, a_StackPos, a_ReturnedVal)),
		static_cast<int>(BLOCK_FACE_MIN), static_cast<int>(BLOCK_FACE_MAX))
	);
	return true;
}
Exemple #17
0
/* set function: y of class  Point */
static int tolua_set_Point_y(lua_State* tolua_S)
{
  Point* self = (Point*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL);
 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
 tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
  self->y = ((float)  tolua_tonumber(tolua_S,2,0));
 return 0;
}
// QVariant
QVariant tolua_toQVariant(lua_State* L, int lo, void* def) {

	if (lua_gettop(L) < abs(lo)) {

		return QVariant();
	};

	int type = lua_type(L, lo);
	switch (type) {

	case LUA_TNIL:
		return QVariant();

	case LUA_TSTRING:
		return QVariant(tolua_tostring(L, lo, 0));

	case LUA_TBOOLEAN:
		return QVariant(tolua_toboolean(L, lo, 0)==0?false:true);
	case LUA_TNUMBER:
		return QVariant(tolua_tonumber(L, lo, 0));

	case LUA_TUSERDATA:

		tolua_Error err;
		if (tolua_isusertype(L, lo, "QVariant", (int)def, &err)) {

			return (QVariant)*(QVariant*)tolua_tousertype(L, -1, def);
		};

		lua_pushstring(L, ".QVariant");
		lua_gettable(L, lo);
		if (lua_isfunction(L, -1)) {

			lua_pushvalue(L, lo);
			lua_call(L, 1, 1);

			if (tolua_isusertype(L, lua_gettop(L), "QVariant", 0, &err)) {

				QVariant ret(*((QVariant*)tolua_tousertype(L, -1, def)));
				lua_pop(L, 1);
				return ret;
			};
		};

		/* fallthrough */

	default:
		; // wtf?
	};

	return QVariant();
};
static int tolua_cocos2d_control_unregisterControlEventHandler(lua_State* tolua_S)
{
    if (NULL == tolua_S)
        return 0;
    
    int argc = 0;
    Control* self = nullptr;
    
#ifndef TOLUA_RELEASE
    tolua_Error tolua_err;
	if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror;
#endif
    
    self = static_cast<Control*>(tolua_tousertype(tolua_S,1,0));
    
#ifndef TOLUA_RELEASE
	if (nullptr == self) {
		tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_control_unregisterControlEventHandler'\n", NULL);
		return 0;
	}
#endif
    
    argc = lua_gettop(tolua_S) - 1;
    
    if (1 == argc)
    {
#ifndef TOLUA_RELEASE
        if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
            goto tolua_lerror;
#endif
        int controlevent = (int)tolua_tonumber(tolua_S,2,0);
        for (int i = 0; i < kControlEventTotalNumber; i++)
        {
            if ((controlevent & (1 << i)))
            {
                ScriptHandlerMgr::HandlerType handlerevent  = ScriptHandlerMgr::HandlerType((int)ScriptHandlerMgr::HandlerType::CONTROL_TOUCH_DOWN + i);
                ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerevent);
                break;
            }
        }
        return 0;
    }
    
    luaL_error(tolua_S, "%s function of Control  has wrong number of arguments: %d, was expecting %d\n", "cc.Control:unregisterControlEventHandler", argc, 1);
    return 0;
    
#ifndef TOLUA_RELEASE
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_control_unregisterControlEventHandler'.",&tolua_err);
    return 0;
#endif
}
Exemple #20
0
/* set function: a of class  Array */
static int tolua_set_tarray_Array_a(lua_State* tolua_S)
{
 int tolua_index;
  Array* self;
 lua_pushstring(tolua_S,".self");
 lua_rawget(tolua_S,1);
 self = (Array*)  lua_touserdata(tolua_S,-1);
#ifndef TOLUA_RELEASE
 {
 tolua_Error tolua_err;
 if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
 tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);
 }
#endif
 tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;
#ifndef TOLUA_RELEASE
 if (tolua_index<0 || tolua_index>=10)
 tolua_error(tolua_S,"array indexing out of range.",NULL);
#endif
  self->a[tolua_index] = ((int)  tolua_tonumber(tolua_S,3,0));
 return 0;
}
Exemple #21
0
int tolua_toid(lua_State * L, int idx, int def)
{
    int no = 0;
    int type = lua_type(L, idx);
    if (type == LUA_TNUMBER) {
        no = (int)tolua_tonumber(L, idx, def);
    }
    else {
        const char *str = tolua_tostring(L, idx, NULL);
        no = str ? atoi36(str) : def;
    }
    return no;
}
Exemple #22
0
static int tolua_faction_set_id(lua_State * L)
{
    faction *self = (faction *)tolua_tousertype(L, 1, 0);
    int id = (int)tolua_tonumber(L, 2, 0);
    if (findfaction(id) == NULL) {
        renumber_faction(self, id);
        lua_pushboolean(L, 1);
    }
    else {
        lua_pushboolean(L, 0);
    }
    return 1;
}
int lua_register_sls_world_getGeo(lua_State* tolua_S)
{
  int argc = 0;
  sls::World* cobj = nullptr;

  cobj = (sls::World*)tolua_tousertype(tolua_S,1,0);
  if (!cobj) return 0;

  argc = lua_gettop(tolua_S) - 1;
  if (argc == 2) {
    tolua_Error tolua_err;
    if (tolua_isnumber(tolua_S,2,0,&tolua_err) &&
        tolua_isnumber(tolua_S,3,0,&tolua_err)) {
      int w = tolua_tonumber(tolua_S, 2, 0);
      int h = tolua_tonumber(tolua_S, 3, 0);
      sls::Geo* ret = &(cobj->getGeo(w, h));
      tolua_pushusertype(tolua_S,(void*)ret,"sls.Geo");
      return 1;
    }
  }
  return 0;
}
Exemple #24
0
static int tolua_set_region_money(lua_State* tolua_S)
{
  region* self = (region*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  tolua_Error tolua_err;
  if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'money'",NULL);
  if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
   tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
  self->money = ((int)  tolua_tonumber(tolua_S,2,0))
;
 return 0;
}
static int tolua_Cocos2dx_CCTableView_registerScriptHandler(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
    tolua_Error tolua_err;
    if (
        !tolua_isusertype(tolua_S,1,"CCTableView",0,&tolua_err) ||
        !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
        !tolua_isnumber(tolua_S, 3, 0, &tolua_err)               ||
        !tolua_isnoobj(tolua_S,4,&tolua_err)
        )
        goto tolua_lerror;
    else
#endif
    {
        CCTableView* self = (CCTableView*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
        if (!self) tolua_error(tolua_S,"invalid 'self' in function 'registerScriptHandler'", NULL);
#endif
        if (NULL == self->getDelegate())
        {
            LUA_TableViewDelegate* delegate = new LUA_TableViewDelegate();
            if (NULL == delegate)
                return 0;
            
            CCDictionary* userDict = static_cast<CCDictionary*>(self->getUserObject());
            if (NULL == userDict)
            {
                userDict = new CCDictionary();
                if (NULL == userDict)
                    return 0;
                
                self->setUserObject(userDict);
                userDict->release();
            }
            
            userDict->setObject(delegate, KEY_TABLEVIEW_DELEGATE);
            self->setDelegate(delegate);
            delegate->release();
        }
        
        LUA_FUNCTION nFunID = (  toluafix_ref_function(tolua_S,2,0));
        int scriptHandlerType = ((int)  tolua_tonumber(tolua_S,3,0));
        self->registerScriptHandler(nFunID,scriptHandlerType);
    }
    return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
    return 0;
#endif
}
Exemple #26
0
static int lua_ftk_text_view_create(lua_State* L)
{
	tolua_Error err = {0};
	FtkTextView* retv;
	FtkWidget* parent;
	int x;
	int y;
	int width;
	int height;
	int param_ok = tolua_isusertype(L, 1, "FtkWidget", 0, &err) && tolua_isnumber(L, 2, 0, &err) && tolua_isnumber(L, 3, 0, &err) && tolua_isnumber(L, 4, 0, &err) && tolua_isnumber(L, 5, 0, &err);

	return_val_if_fail(param_ok, 0);

	parent = tolua_tousertype(L, 1, 0);
	x = tolua_tonumber(L, 2, 0);
	y = tolua_tonumber(L, 3, 0);
	width = tolua_tonumber(L, 4, 0);
	height = tolua_tonumber(L, 5, 0);
	retv = ftk_text_view_create(parent, x, y, width, height);
	tolua_pushusertype(L, (FtkTextView*)retv, "FtkTextView");

	return 1;
}
Exemple #27
0
static int tolua_storage_write(lua_State * L)
{
  gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0);
  if (data->version && tolua_isnumber(L, 2, 0, 0)) {
    lua_Number num = tolua_tonumber(L, 2, 0);
    double n;
    if (modf(num, &n) == 0.0) {
      WRITE_INT(data->store, (int)num);
    } else {
      WRITE_FLT(data->store, (float)num);
    }
  }
  return 0;
}
Exemple #28
0
static int tolua_CCGLProgram_CCGLProgram_setUniformLocationWith4f00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"CCGLProgram",0,&tolua_err) ||
     !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
     !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
     !tolua_isnumber(tolua_S,4,0,&tolua_err) ||
     !tolua_isnumber(tolua_S,5,0,&tolua_err) ||
     !tolua_isnumber(tolua_S,6,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,7,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  CCGLProgram* self = (CCGLProgram*)  tolua_tousertype(tolua_S,1,0);
  int location = ((int)  tolua_tonumber(tolua_S,2,0));
  float f1 = ((float)  tolua_tonumber(tolua_S,3,0));
  float f2 = ((float)  tolua_tonumber(tolua_S,4,0));
  float f3 = ((float)  tolua_tonumber(tolua_S,5,0));
  float f4 = ((float)  tolua_tonumber(tolua_S,6,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUniformLocationWith4f'", NULL);
#endif
  {
   self->setUniformLocationWith4f(location,f1,f2,f3,f4);
  }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'setUniformLocationWith4f'.",&tolua_err);
 return 0;
#endif
}
static int tolua_cocos2d_CCBProxy_setCallback(lua_State* tolua_S)
{
    if (nullptr == tolua_S)
        return 0;
    
    int argc = 0;
    CCBProxy* self = nullptr;
    
#if COCOS2D_DEBUG >= 1
    tolua_Error tolua_err;
	if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror;
#endif
    
    self = static_cast<CCBProxy*>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
	if (nullptr == self) {
		tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_CCBProxy_setCallback'\n", NULL);
		return 0;
	}
#endif
    
    argc = lua_gettop(tolua_S) - 1;
    
    if ( argc >= 2 && argc <= 3 )
    {
#if COCOS2D_DEBUG >= 1
        if (!tolua_isusertype(tolua_S,2,"cc.Node",0,&tolua_err) ||
            !toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err) ||
            !tolua_isnumber(tolua_S, 4, 1, &tolua_err)
            )
            goto tolua_lerror;
#endif
        
        Node* node = ((Node*)tolua_tousertype(tolua_S,2,0));
        LUA_FUNCTION funID = (  toluafix_ref_function(tolua_S,3,0));
        int   controlEvents = (int)tolua_tonumber(tolua_S, 4, 1);
        self->setCallback(node, funID, controlEvents);
        return 0;
    }
    
    CCLOG(" %s has wrong number of arguments: %d, was expecting %d\n", "cc.CCBProxy:setCallback", argc, 2);
    return 0;
    
#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_CCBProxy_setCallback'.",&tolua_err);
    return 0;
#endif
}
Exemple #30
0
static int tolua_order_get_token(lua_State *L) {
    order *ord = (order *)tolua_tousertype(L, 1, 0);
    int n = (int)tolua_tonumber(L, 2, 0);
    const char * str = 0;
    init_order(ord);
    while (n-->0) {
        str = getstrtoken();
        if (!str) {
            return 0;
        }
    }

    tolua_pushstring(L, str);
    return 1;
}