Jump to content


Luabind?


2 replies to this topic

#1 eddie

    Senior Member

  • Members
  • PipPipPipPip
  • 751 posts

Posted 04 November 2005 - 05:57 PM

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:

Quote


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-

#2 john

    Member

  • Members
  • PipPip
  • 84 posts

Posted 04 November 2005 - 09: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.

#3 eddie

    Senior Member

  • Members
  • PipPipPipPip
  • 751 posts

Posted 04 November 2005 - 10: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!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users