lua-users home
lua-l archive

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


Nick Trout wrote:

> Possibly, I know wxLua uses ctags to parse wxWindows, 
> then Lua to parse the output and generate a binding. I'd 
> hate to have to maintain the binding to something like 
> wxWindows (its enormous!). 

I see ParseTags.lua in the source code, but I'm not convinced that Paul is 
using it to generate wxLuaWrap.i. If he's using it as a tool, I'm guessing 
he's adding the prototypes it generates to wxLuaWrap.i by hand.

If you look in wxLuaWrap.i, you'll see stuff like wxPalette::GetPixel, which 
is stubbed out because the wrappers don't support passing by reference. And 
there's stuff like wxList::Insert, which is manually renamed to InsertAt 
because the wrappers don't support polymorphism within the same class. 

So this stuff isn't entirely autogenerated.

And there's another reason you can't just run ctags to generate the 
prototypes, although it's probably fairly unique to wxWindows. wxWindows is 
cross-platform, so the implementation of similar-looking classes on different 
platforms is accomplished by implementing subclasses which may not exist on 
other platforms. For example, consider this (imaginary) scenario:

   - The wxDrawable class is implemented in Windows by inheriting 
     from the Bitmap base class. It inherits the ::DrawLine method.

   - The wxDrawable class is implemented in Gtk via the gtk_drawable class.
     ::DrawLine is implemented in the same class.

   - The wxDrawable class is implemented in X11 via inheriting from Pixmap.
     ::DrawLine is implemented in yet another class, XWindowCalls.

If you ran ctags on the Windows source files, you would end up with prototypes 
for the Bitmap base class, which doesn't exist in the Gtk or X11 versions. If 
you ran it on the X11 source files, you'd end up including the XWindows 
class, which doesn't exist on Windows (Gtk is derived from XWindows and 
probably has it, but we'll ignore that).

So what can be done? You can't just automaticall exclude the base classes that 
aren't common across platforms, because you wouldn't get a wrapper for 
::DrawLine - not using the Windows or X11 source, anyway.

So to get portable wrappers, you have to rely on the documentation, which is 
supposed to list only the routines that are common across all platforms. 

In the case of wxWindows, you could write a program to parse the documentation 
(it's in HTML format) and grabs the prototypes, but you still have to go 
through it by hand and make corrections. That's because there are still 
polymorphic name conflicts, routines that rely on passing by reference, and 
many cases where the documentation is just plain wrong - bad parameters, 
deprecated classes, etc.

I'm not sure this is indicitive of anything, other than that sometime wrappers 
are tedious, even with automated tools.

-- David Cuny