lua-users home
lua-l archive

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


On Fri, Aug 10, 2012 at 12:39 PM, Rob Hoelz <rob@hoelz.ro> wrote:
> Patrick Rapin <toupie300@gmail.com> wrote:
>>
>> > I think the biggest issue with a Lua API on Haiku is the fact that the
>> > Haiku API is heavily dependent on threads, so handling that from within
>> > Lua would be difficult.
>>
>> That can be a real difficulty for sure.
>>
>> > Not to mention that the API is all C++, and we
>> > would have to make Lua and virtual methods play nice.
>>
>> But this is no problem ! All the bindings I wrote for Lua up to now
>> were from C++ projects.
>> And those projects highly depend on virtual methods.
>> I even tend to think it is easier to cleanly bind C++ libraries than C
>> libraries; at least the resulting binding is easier to use (because of
>> the native object model).
>>
>
> Calling virtual functions isn't the hard part, I think ; subclassing is.

You mean creating new subclasses from within Lua code? It's a little
annoying but it's far from difficult. For each target class, create a
C++ subclass that dispatches all of its virtuals to Lua callbacks.
Extremely tedious (you'd definitely want to automate this) but
serviceable.

/s/ Adam