lua-users home
lua-l archive

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


Please check again; for ints, doubles and
chars you can use the types "ref int", "ref double" and "ref char" to
pass these things "by reference" (actually the output value will be
returned by the proxy). For more complex types you use the "pointer"
type and allocate a buffer (a GC-ed chunk of memory that you can read
and write to). You can even do structs with buffers if you know the
exact layout; with alien.sizeof and alien.align you can find out how
your platform lays out structures and do that automatically (didn't
have a need for that yet so didn't write the Lua code to do that).

Some things are still missing, though (no 64-bit integers, no passing
arrays and structures by value), but most of the power (if not the
ease of use right now) of Python's ctypes is available. Contributions
of more "glue" are of course welcome (check how arrays are implemented
to see an example of the kind of glue I'm talking about).

C/Invoke has much of the glue missing right now in Alien implemented,
but I couldn't get it to work when I tried it last year (which is why
I wrote Alien in the first place), and no new code has been release
since then.

Fabio Mascarenhas

On Sun, May 10, 2009 at 5:50 PM, bb <> wrote:
> There is some ingenious library available for Python called ctype, or say it
> is provided with the language as a standard and it only needs to be
> imported.  I have checked the Lua documentation and the Lua mailing list to
> find something equivalent powerful - no success.
> Well, there is the exchange possible via stack but I think that is not the
> philosopher's stone. I found the alien extension
> ( as well, but I found nothing comparable to
> ctypes. ctypes for instance allows to create C datatypes from within Python
> by c-char, c_byte, c_int and so on. In my first check of the docs I could
> not find any mechanism for passing parameters by reference, say pointers.
> May be I did not find the essentials.
> Is there any library I have not jet found for such powerful programming
> techniqes in Lua? Thanks for providing any information.
> Best regards
> BB