PDA

View Full Version : Luabind?


eddie
11-04-2005, 09:57 AM
Anyone here use Luabind to expose scripting to their game?

I'm attempting to bind a function using luabind currently, and I'm having an issue. It seems to have issues with binding a class member function that's templated.

i.e.:



class MyClass
{
public:
template<class MySpecialization>
void Foo() {} ;
};

int main(void)
{
module(L)
[
class_< MyClass >("MyClass").def("Foo", &MyClass::Foo);
]
}




This gives something like:



error C2780: 'luabind::class_<T> &luabind::class_<T>::def(luabind::detail::operator_<Derived>)' : expects 1 arguments - 2 provided



Which I find odd.. It's obviously having trouble with the template.. Anyone know what I'm doing wrong?

Cheers,

-e-

john
11-04-2005, 01:44 PM
Try this changing this:

class_< MyClass >("MyClass").def("Foo", &MyClass::Foo);
to:


class_< MyClass >("MyClass").def("Foo", void(MyClass::*)()&MyClass::Foo);


Hope that helps.

eddie
11-04-2005, 02:43 PM
Sigh. I'm an idiot.

First off, I didn't post my true issue as clearly as I should have:


class MyClass
{
public:
template<class MySpecialization>
void Foo(MySpecialization mySpec) {} ;
};

int main(void)
{
module(L)
[
class_< MyClass >("MyClass").def("Foo", &MyClass::Foo);
]
}


But your suggestion still fixed my woes. Turns out I was casting improperly. Stupid function pointers.

Thanks!