mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7341 from samuele3hu/v3_3
Fix some type conversion error and add manual lua binding for Node::enumerateChildren
This commit is contained in:
commit
2398f6b8f0
|
@ -2604,7 +2604,7 @@ static int tolua_Cocos2d_glLineWidth00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
float arg0 = (float)tolua_tonumber(tolua_S, 1, 0);
|
||||
glLineWidth((GLfloat)arg0 );
|
||||
glLineWidth(arg0);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -2684,9 +2684,9 @@ static int tolua_Cocos2d_glPolygonOffset00(lua_State* tolua_S)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
glPolygonOffset((GLfloat)arg0 , (GLfloat)arg1 );
|
||||
float arg0 = (float)tolua_tonumber(tolua_S, 1, 0);
|
||||
float arg1 = (float)tolua_tonumber(tolua_S, 2, 0);
|
||||
glPolygonOffset(arg0, arg1);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -3165,7 +3165,7 @@ static int tolua_Cocos2d_glTexParameterf00(lua_State* tolua_S)
|
|||
{
|
||||
unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0);
|
||||
unsigned int arg1 = (unsigned int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
float arg2 = (float)tolua_tonumber(tolua_S, 3, 0);
|
||||
glTexParameterf((GLenum)arg0 , (GLenum)arg1 , (GLfloat)arg2 );
|
||||
}
|
||||
return 0;
|
||||
|
@ -3287,8 +3287,8 @@ static int tolua_Cocos2d_glUniform1f00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
glUniform1f((GLint)arg0 , (GLfloat)arg1 );
|
||||
float arg1 = (float)tolua_tonumber(tolua_S, 2, 0);
|
||||
glUniform1f(arg0,arg1);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -3426,9 +3426,9 @@ static int tolua_Cocos2d_glUniform2f00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
glUniform2f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2);
|
||||
float arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
float arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
glUniform2f(arg0, arg1, arg2);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -3569,10 +3569,10 @@ static int tolua_Cocos2d_glUniform3f00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
int arg3 = (int)tolua_tonumber(tolua_S, 4, 0);
|
||||
glUniform3f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 );
|
||||
float arg1 = (float)tolua_tonumber(tolua_S, 2, 0);
|
||||
float arg2 = (float)tolua_tonumber(tolua_S, 3, 0);
|
||||
float arg3 = (float)tolua_tonumber(tolua_S, 4, 0);
|
||||
glUniform3f(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -3716,11 +3716,11 @@ static int tolua_Cocos2d_glUniform4f00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
int arg0 = (int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
int arg3 = (int)tolua_tonumber(tolua_S, 4, 0);
|
||||
int arg4 = (int)tolua_tonumber(tolua_S, 5, 0);
|
||||
glUniform4f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 );
|
||||
float arg1 = (float)tolua_tonumber(tolua_S, 2, 0);
|
||||
float arg2 = (float)tolua_tonumber(tolua_S, 3, 0);
|
||||
float arg3 = (float)tolua_tonumber(tolua_S, 4, 0);
|
||||
float arg4 = (float)tolua_tonumber(tolua_S, 5, 0);
|
||||
glUniform4f(arg0 , arg1, arg2, arg3, arg4);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -4042,8 +4042,8 @@ static int tolua_Cocos2d_glVertexAttrib1f00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
glVertexAttrib1f((GLuint)arg0 , (GLfloat)arg1 );
|
||||
float arg1 = (float)tolua_tonumber(tolua_S, 2, 0);
|
||||
glVertexAttrib1f(arg0 , arg1);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -4113,9 +4113,9 @@ static int tolua_Cocos2d_glVertexAttrib2f00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
glVertexAttrib2f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 );
|
||||
float arg1 = (float)tolua_tonumber(tolua_S, 2, 0);
|
||||
float arg2 = (float)tolua_tonumber(tolua_S, 3, 0);
|
||||
glVertexAttrib2f(arg0, arg1, arg2);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -4186,10 +4186,10 @@ static int tolua_Cocos2d_glVertexAttrib3f00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
int arg3 = (int)tolua_tonumber(tolua_S, 4, 0);
|
||||
glVertexAttrib3f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 );
|
||||
float arg1 = (float)tolua_tonumber(tolua_S, 2, 0);
|
||||
float arg2 = (float)tolua_tonumber(tolua_S, 3, 0);
|
||||
float arg3 = (float)tolua_tonumber(tolua_S, 4, 0);
|
||||
glVertexAttrib3f(arg0 , arg1, arg2, arg3);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -4261,11 +4261,11 @@ static int tolua_Cocos2d_glVertexAttrib4f00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
unsigned int arg0 = (unsigned int)tolua_tonumber(tolua_S, 1, 0);
|
||||
int arg1 = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
int arg2 = (int)tolua_tonumber(tolua_S, 3, 0);
|
||||
int arg3 = (int)tolua_tonumber(tolua_S, 4, 0);
|
||||
int arg4 = (int)tolua_tonumber(tolua_S, 5, 0);
|
||||
glVertexAttrib4f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 );
|
||||
float arg1 = (float)tolua_tonumber(tolua_S, 2, 0);
|
||||
float arg2 = (float)tolua_tonumber(tolua_S, 3, 0);
|
||||
float arg3 = (float)tolua_tonumber(tolua_S, 4, 0);
|
||||
float arg4 = (float)tolua_tonumber(tolua_S, 5, 0);
|
||||
glVertexAttrib4f(arg0, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -5031,10 +5031,10 @@ static int tolua_cocos2d_DrawPrimitives_drawColor4F00(lua_State* tolua_S)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
unsigned char r = (( unsigned char) tolua_tonumber(tolua_S,1,0));
|
||||
unsigned char g = (( unsigned char) tolua_tonumber(tolua_S,2,0));
|
||||
unsigned char b = (( unsigned char) tolua_tonumber(tolua_S,3,0));
|
||||
unsigned char a = (( unsigned char) tolua_tonumber(tolua_S,4,0));
|
||||
float r = (float)tolua_tonumber(tolua_S,1,0);
|
||||
float g = (float)tolua_tonumber(tolua_S,2,0);
|
||||
float b = (float)tolua_tonumber(tolua_S,3,0);
|
||||
float a = (float)tolua_tonumber(tolua_S,4,0);
|
||||
DrawPrimitives::setDrawColor4F(r,g,b,a);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -2215,6 +2215,66 @@ tolua_lerror:
|
|||
#endif
|
||||
}
|
||||
|
||||
static int lua_cocos2dx_Node_enumerateChildren(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Node* cobj = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_enumerateChildren'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 2)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err) ||
|
||||
!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string name = (std::string)tolua_tocppstring(tolua_S,2,0);
|
||||
LUA_FUNCTION handler = toluafix_ref_function(tolua_S,3,0);
|
||||
|
||||
cobj->enumerateChildren(name, [=](Node* node)->bool{
|
||||
int id = node ? (int)node->_ID : -1;
|
||||
int* luaID = node ? &node->_luaID : nullptr;
|
||||
toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)node,"cc.Node");
|
||||
bool ret = LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1);
|
||||
LuaEngine::getInstance()->removeScriptHandler(handler);
|
||||
return ret;
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "enumerateChildren",argc, 2);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_enumerateChildren'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_cocos2d_Spawn_create(lua_State* tolua_S)
|
||||
{
|
||||
if (NULL == tolua_S)
|
||||
|
@ -3920,6 +3980,9 @@ static void extendNode(lua_State* tolua_S)
|
|||
lua_pushstring(tolua_S, "setAnchorPoint");
|
||||
lua_pushcfunction(tolua_S, tolua_cocos2d_Node_setAnchorPoint);
|
||||
lua_rawset(tolua_S, -3);
|
||||
lua_pushstring(tolua_S, "enumerateChildren");
|
||||
lua_pushcfunction(tolua_S, lua_cocos2dx_Node_enumerateChildren);
|
||||
lua_rawset(tolua_S, -3);
|
||||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
}
|
||||
|
|
|
@ -561,5 +561,13 @@ end
|
|||
|
||||
cc.KeyCode.KEY_BACK = cc.KeyCode.KEY_ESCAPE
|
||||
|
||||
cc.EventCode =
|
||||
{
|
||||
BEGAN = 0,
|
||||
MOVED = 1,
|
||||
ENDED = 2,
|
||||
CANCELLED = 3,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* M
|
|||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||
# functions from all classes.
|
||||
|
||||
skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$ setContentSize setAnchorPoint],
|
||||
skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$ setContentSize setAnchorPoint enumerateChildren],
|
||||
Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc],
|
||||
SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants],
|
||||
MotionStreak::[getBlendFunc setBlendFunc draw update],
|
||||
|
|
Loading…
Reference in New Issue