lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


En réponse à Brian Zhou <b88zhou@hotmail.com>:

Hi,

You are right, "require" was defined and used by luagnome (see
<http://luagnome.free.fr>) to dynamically load "dynamic library" modules.
Unfortunately, this same name has been used in 4.1-alpha to implement a Lua
"dofile" function with path searching. Therefore, 'require' has been renamed
'dynload' in newer versions of luagnome (not release yet).
2 solutions: either stick with Lua 4.0 or wait a few days until I package a
luagtk release compatible with 4.1-alpha.

On the other hand, for what you intend to do, you can also statically link a lua
executable including your extensions (just call the appropriate initialize
function as Lua itself initializes its library).

Finally, for examples on how to use Lua-swig to do the OO wrapping you mention,
the best pointer is to look at the sources (*.i files) of luagtk, that does
exactly that with the gtk+ library.
Can't compare with toLua, since I'm the author of Lua-swig ;-)

Hope it helps.

> Hi,
> 
> I'm trying to use the luaswig to wrap some C functions. In one of its
> examples has the function call like this:
> 
>     require("./1.so")
> 
> When running,
> 
> error: invalid control char;
>   last token read: `0x7F' at line 1 in file `././1.so'
> stack traceback:
>    1:  function `require' [C]
>    2:  main of file `t_1.lua' at line 1
> 
> I realized it's a new standard function but could not find any
> documentation
> for it. How does it load shared library?
> 
> I also want to know, how does luaswig compare with toLua? I want to wrap
> and
> group extern "C" functions and make them OO in the Lua. Something like
> (in
> SWIG-python interface syntax):
> 
> %addmethods Queue {
>     Queue(int capacity) { return q_new(capacity); }
>     ~Queue() { q_delete(self); }
>     BOOL isEmpty() { return q_isEmpty(self); }
>     BOOL isFull() { return q_isFull(self); }
> }
> 
> What's your recommendation?
> 
> Thanks for any pointers,
> 
> -Brian
> 
>