Re: Member function using templates

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Member function using templates

Stefan Schwarzbach
Hi Arvid,

I updated to the luabind 0.7 rc, just one day after you supposed that to me.
But the definition of the template function does not seem to work. I get
compiler errors at the line of the function definition

Here is the definition:

        class_<UserInterface>("UserInterface")
            [...]
            .def("GetModuleCharacterInfo",
&UserInterface::GetModule<UICharacterInfo>)

And here is the declaration the the template function:

class UserInterface
{
    [...]
    template<class ModuleType>
    ModuleType *GetModule()
    {
        [...]
    }
    [...]
}

Can you help me with that problem? Or has someone else already
registered template functions?

Best regards,
Stefan Schwarzbach



Arvid Norberg schrieb:

>
> On Jan 8, 2006, at 16:55, Stefan Schwarzbach wrote:
>
>> Hi,
>>
>> I want to register a member function to lua, which uses templates. Here
>> is my scenario:
>>
>> class UserInterface
>> {
>>     [...]
>>     template<class ModuleType>
>>     ModuleType *GetModule()
>>     {
>>         [...]
>>     }
>> }
>>
>> void UserInterface::LuaScriptRegister()
>> {
>>     using namespace luabind;
>>     module(GetLuaScript()->GetState())
>>     [
>>         class_<UserInterface>("UserInterface")
>>             .def(constructor<>())
>>             .def("GetMouseCurrent", &UserInterface::GetMouseCurrent)
>>             .def("GetMouseOld", &UserInterface::GetMouseOld)
>>             .def("GetModuleCharacterInfo",
>> &UserInterface::GetModule<CharacterInfo>)
>>             .def("GetModuleCharacterSkills",
>> &UserInterface::GetModule<CharacterSkills>)
>>             .def("GetModuleCharacterDiary",
>> &UserInterface::GetModule<Diary>)
>>     ]
>> }
>>
>> The registration of the three functions using templates give errors. How
>> do I have to register these functions? Can functions using templates be
>> registered for lua at all?
>
> I believe that is supposed to work.
>
> What errors do you get?
> Which compiler do you use?
> Which version of luabind are you using?
>
> Maybe you could try the release candidate for luabind 0.7 from the
> cvs. It's in the branch called:
>
> luabind_rc_0_7
>
> --
> Arvid Norberg
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Member function using templates

Daniel Wallin-2
Stefan Schwarzbach wrote:

> Hi Arvid,
>
> I updated to the luabind 0.7 rc, just one day after you supposed that to me.
> But the definition of the template function does not seem to work. I get
> compiler errors at the line of the function definition
>
> Here is the definition:
>
>         class_<UserInterface>("UserInterface")
>             [...]
>             .def("GetModuleCharacterInfo",
> &UserInterface::GetModule<UICharacterInfo>)
>
> And here is the declaration the the template function:
>
> class UserInterface
> {
>     [...]
>     template<class ModuleType>
>     ModuleType *GetModule()
>     {
>         [...]
>     }
>     [...]
> }
>
> Can you help me with that problem? Or has someone else already
> registered template functions?

This should work. If it doesn't, it's probably a bug in VC7.1. You can
try something like:

  class_<UserInterface>("UserInterface")
    .def(
        "GetModuleCharacterInfo"
      , (UICharacterInfo*(UserInterface::*)())&UserInterface::GetModule
    )

--
Daniel Wallin



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user