Lua wrapping overloaded functions situation.
Posted: Sun Oct 19, 2008 4:51 pm
So I've decided that I'm pretty much screwed, but I'd like to come here and bitch about it. Sort of like a rape victim, I have just taken it in the ass, but in order for my experience to mean something to myself, I have to make light of the situation and convince myself that I can use this experience to help others.
I have these functions in inventory:
I want to be able to do either AddItem("potion") or AddItem(3) to add a potion. But nooooooo! I CAN'T.
I am pretty sure that this situation isn't restricted to toLua++. Or maybe it is, but I'm boned nonetheless. When you pass it a 3, it considers that also a valid Lua string. Which is okay, but it appears that toLua++ doesn't handle that. There should be a way to specify a priority or something. Like if the function signature with "int" works, go with it, otherwise go to "string." An int is a valid int and string, but a string is not a valid integer. But I don't see any way that toLua++ would let you do this.
How does LuaBind/SWIG/whatever wrapper generator you guys are using handle this shitty scenario?
I have these functions in inventory:
Code: Select all
AddItem(int number)
AddItem(char *name)
I am pretty sure that this situation isn't restricted to toLua++. Or maybe it is, but I'm boned nonetheless. When you pass it a 3, it considers that also a valid Lua string. Which is okay, but it appears that toLua++ doesn't handle that. There should be a way to specify a priority or something. Like if the function signature with "int" works, go with it, otherwise go to "string." An int is a valid int and string, but a string is not a valid integer. But I don't see any way that toLua++ would let you do this.
How does LuaBind/SWIG/whatever wrapper generator you guys are using handle this shitty scenario?