[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaJIT FFI callbacks (was Re: Calling lua functions from C when using luajit ffi.)
- From: Michael Gogins <michael.gogins@...>
- Date: Mon, 14 Nov 2011 19:55:00 -0500
Congratulations. I'm sure I'll be using this callback stuff even if
there is some overhead and limitations.
I'm a composer of computer music, and I've switched to using
LuaJIT/FFI as my main language for composing. I've introduced LuaJIT
inside Csound as an alternative way of writing unit generators for
this user-programmable software synthesizer, my presentation on it may
be found here:
Mike, and I correct is thinking that the callbacks I implemented using
the Lua C API would be more efficient than your FFI callbacks? Or
should I change my code to use the new callbacks? These calls could
occur thousands, tends of thousands, or even hundreds of thousands of
times per second of rendered audio.
On Mon, Nov 14, 2011 at 6:27 PM, Mike Pall <email@example.com> wrote:
> Dimiter 'malkia' Stanev wrote:
>> Mike just put support for callbacks for x86/x64
> Yep. Attached are two examples using FFI callbacks. You'll need
> LuaJIT git HEAD on x86 or x64 to run these.
> The first example is for Windows that lists all window titles, the
> other is a simple GTK+ demo (tested on Linux). Excuse the length
> of the GTK+ demo, but programming in GTK+ gets rather verbose.
> Docs are here: http://luajit.org/ext_ffi_semantics.html#callback
> tl;dr: Just pass a Lua function to a C function taking a callback
> argument and the FFI will do all the magic in the background.
> The FFI callback feature for x86/x64 has been sponsored by a
> corporate sponsor, who wishes to remain anonymous at this time.
> Ports to other architectures will follow, depending on sponsorship.
> Or if someone wants to grind their teeth at a really challenging
> assembler project for the CPU of your choice. :-)
Michael dot Gogins at gmail dot com