lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I don't know if you are already aware of this problem:
when I have to overloaded functions that has some optional parameters tolua
soemtimes can't find the correct function to call if I don't provide all the
parameters. for example:

I have 

class my_class {
void some_function(char *);
void some_function(int x,int y,int w=80,int h=80);

}

tolua generates something like this for the second one: 

 static ...... my_class_some_function01(lua_State *tolua_S)
{
	if (
	!tolua_istype(tolua_S,2,LUA_TNUMBER,0) ||
	!tolua_istype(tolua_S,3,LUA_TNUMBER,0) ||
	!tolua_istype(tolua_S,4,LUA_TNUMBER,0) ||
	!tolua_istype(tolua_S,5,LUA_TNUMBER,0) )
	//call the second one
	else
	//call the first one
}
that's ok if I call some_function(10,10,100,100) but if I call
some_function(10,10) it will try to execute the one with char * with an
error

a quick workaround is either putting the functions with optional parameters
first. But it would be better to make sure the optional parameters are not
checked, what do you think?



-- 
Juan Pablo Sousa
http://insomnia.sourceforge.net
gotem@users.sourceforge.net