Re: Expose functions in need?
ZouYabin <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Nigel,
Thanks for your reply. With your help, I changed the luabind module like this:
#define LUABIND_REGISTER_CLASS_BEGIN( classname ) \
luabind::class_<classname> x(#classname); \
x.def(luabind::construtor<>());
#define LUABIND_REGISTER_CLASS_FUNC(classname, funcname) \
if ( FuncInUse(#funcname) ) \
{ \
x.def(#funcname, &classname::funcname); \
}
#define LUABIND_REGISTER_CLASS_END(L) \
luabind::module(L)[ x ];
FuncInUse() is for checking if the "funcname" is needed in particular lua file (actually i go through the file and
get the set of functions being used, and then check if the registering func is in the set).
I am happy to see that it works fine. And the total memory use sharply shrink. Thanks again!
Albin
在2010-06-09 18:04:13,"Nigel Atkinson" <[email protected]> 写道:
>Hi,
>
>Short answer: yes.
>
>Do you really have 500+ in one class?!?! Anyhow, you could create
>several similar functions that register a different set of functions and
>call one depending on which set your script your needs.
>
>Another option: You can also split bindings up (see the docs) - which
>you could switch in and out with if statements.
>
>Nigel
>
>On Wed, 2010-06-09 at 17:23 +0800, ZouYabin wrote:
>> Hi all,
>> I am asking if luabind can expose functions when the lua script
>> file really needs?
>> Now I have 500+ functions, but not every lua file need all the
>> functions, mostly, each lua file
>> will only call a few (< 10) of them.
>> My luabind module is like this:
>> luabind::module(L)
>> [
>> luabind:class_<MyClass>("MyClass")
>> .def(luabind:constructor<>())
>> .def("Func1", &MyClass:Func1)
>> .def("Func2", &MyClass:Func2)
>> ...
>> ...
>>
>> .def("Func500", &MyClass:Func500)
>> ];
>> My Application has about 2000 lua files, each one owns a seperate
>> lua_State. Before load the lua file, I will register the module above
>> to each lua_State. Now the problem is that it seems kinda a waste
>> registering 500 functions for
>> each lua_State. Is there any way to just register functions needed
>> indeed?
>>
>> Regards
>> Albin
>>
>>
>>
>>
>>
>>
>> ______________________________________________________________________
>> 网易为中小企业免费提供企业邮箱(自主域名)
>> ------------------------------------------------------------------------------
>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>> lucky parental unit. See the prize list and enter to win:
>> http://p.sf.net/sfu/thinkgeek-promo
>> _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
>
>------------------------------------------------------------------------------
>ThinkGeek and WIRED's GeekDad team up for the Ultimate
>GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>lucky parental unit. See the prize list and enter to win:
>http://p.sf.net/sfu/thinkgeek-promo
>_______________________________________________
>luabind-user mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/luabind-user
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user