[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C module and a Lua stub with the same name
- From: "D Burgess" <dburgess@...>
- Date: Wed, 12 Apr 2006 08:48:22 +1000
> I guess if require passed as an argument to the Lua module the directory where it was found, then the Lua stub could easily load the .dll from the same directory.
Well you are in luck.
Try,
table.foreach(debug.getregistry(),print)
you will see stuff like
LOADLIB: .\mypackage.dll userdata: 0032BC88
This is the path where the package was found.
> Is there a simple solution to this problem?
Add you own loader to package.loaders or change the order
of the loaders.
Re: the Blue PIL, the description for require is pretty good.
David B.
On 4/12/06, Ivan Kolev <ikolev@abac.com> wrote:
> Hi,
>
> I recently discovered that Lua 5.1 was finally officially released. Congratulations. The list of changes is impressive and worth the waiting.
>
> I returned to Lua (my job in the last few years didn't have any touching points with Lua, which I regretted) when I decided to code an automation tool for Windows, similar to the popular AutoIt ( http://www.autoitscript.com/ ). There exist a few such tools written in Python and Perl, but for me it was a better solution to write my own in Lua for several reasons (for the same reasons I decided not to use AutoIt).
>
> So, after studying the new module system I couldn't find how to easily make a C module and Lua stub with the same name. E.g., I have a MyModule.dll and MyModule.lua. Naturally, MyModule.lua is the first found by require "MyModule" somewhere on the LUA_PATH. Then MyModule.lua needs to load MyModule.dll from its own directory, but this cannot be done so easily. I cannot use require which would search the LUA_CPATH, and if I decide to use package.loadlib, I'd need to enumerate the package.path or cpath myself to find the directory where MyModule.lua is. And it may happen that my search finds *another* copy of MyModule.dll instead of the one placed next to the currently loaded MyModule.lua...
> Is there a simple solution to this problem? Currently I simply name the .dll and the Lua stub differently (e.g. MyModule.lua and MyModuleDLL.dll) (which suffers from the same incorrect-copy-from-another-directory problem).
> I guess if require passed as an argument to the Lua module the directory where it was found, then the Lua stub could easily load the .dll from the same directory.
>
> BTW, the manual uses a bit terse style, which is understandable, but sometimes the matters are a bit complex for a short description, and the module system is one of them. A few examples of typical usages would be welcome. I guess the second edition of Roberto's book has such examples, and I may get it eventually (though I already have the first edition).
>
> Best Regards,
> Ivan
>
>