[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to add C functions to a Lua module within the require process?
- From: Hisham <hisham.hm@...>
- Date: Thu, 3 Dec 2009 17:43:40 -0200
2009/12/3 Ignacio Burgueño <ignaciob@inconcertcc.com>:
> Jerome Vuarand wrote:
>>
>> 2009/12/3 Javier Guerra <javier@guerrag.com>:
>
> ...
>>
>> Thanks to the "all-in-one" loader, you can put Foo.Bar.core
>> (luaopen_Foo_Bar_core) in Foo.dll. The C code will be loaded in memory
>> with the Foo module, but it won't be loaded into the Lua interpreter
>> until you require Foo.Bar.core.
>>
>
> Thanks both. I ended doing what Javier suggested, but I just tested this
> suggestion and it works fine. Sadly, it does not work under LuaRocks (at
> least v1), because I can't find a way to declare that in the rockspec
> (that's way I'm crossposting this to LR list)
>
> This is the relevant part of the rockspec.
>
> build = {
> type = "command",
> build_command = [[ a command for building my library ]],
> install = {
> lib = {
> ["Foo"] = [[Foo.dll]],
> },
> lua = {
> ["Foo.Bar"] = [[Lua\Bar.lua]]
> }
> }
> }
>
> I can't find a way to let LR know that Foo.dll is responsible for modules
> "Foo" and "Foo.Bar.Core"
I see -- that's not an issue in LuaRocks 2 because the custom loader
is not needed. Did you try adding install.lib["Foo.Bar.Core"] =
"Foo.dll"? Even if tries to install the dll twice, it's a hack that
may work for LR1.
-- Hisham