Re: method default arguments
Teto <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Jul 17, 2009 at 4:46 PM, Serg Buslovsky<[email protected]> wrote: > Hi, All. > > I'm having the following method: > std::string someClass::someMethod( std::string arg1, std::string arg2, > std::vector<std::string> arg3, int arg4 = 5, int arg5 = 70, int arg6 = 3 ); > > I wan't to bind this class method as 2 methods in lua able to be called with > 3 and 6 arguments. > Using the following construct: > .def("someMethod", > (std::string(someClass::*)(std::string,std::string,std::vector<std::string>)) > &someClass::someMethod) > .def("someMethod", > (std::string(someClass::*)(std::string,std::string,std::vector<std::string>,int,int,int)) > &someClass::someMethod), > > However if I call the method from lua with 3 arguments(arg1,arg2,arg3) the > other 3(arg4,arg5,arg6) are filled with junk. > I want them to be the default values as defined in the header. > > Is there any way to achieve that? > Personnally I define all prototypes possible and it works: .def("someMethod", (std::string(someClass::*)(std::string,std::string,std::vector<std::string>)) &someClass::someMethod) .def("someMethod", (std::string(someClass::*)(std::string,std::string,std::vector<std::string>,int,int,int)) &someClass::someMethod), .def("someMethod", (std::string(someClass::*)(std::string,std::string,std::vector<std::string>,int,int)) &someClass::someMethod), .def("someMethod", (std::string(someClass::*)(std::string,std::string,std::vector<std::string>,int)) &someClass::someMethod), > https://lists.sourceforge.net/lists/listinfo/luabind-user ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge