1. wrapping wxWindows
Could this be done?
I realize that wxWindows is a C++ lib, so its not directly compatible for
Euphoria.
However, I once considered wrapping Qt for Euphoria (Qt is another C++ lib,
used by such things as Opera and KDE), and I was going to do this by cheating.
There is a library, QtC, which wraps the C++ calls to Qt in normal C functions,
which, in turn, can be easily wrapped in Euphoria.
("control::function(...)" becomes "controltype_function(control, ...)" for
example.)
I was wondering why this hasn't been done for wxWindows, however.
If this approach would work for wxWindows, then that would make it wrappable
in Euphoria.
Can anyone think of a reason why this approach wouldn't work?
jbrown
--
/"\ ASCII ribbon
\ / campain against
X HTML e-mail and
/ \ news
2. Re: wrapping wxWindows
On Mon, Dec 23, 2002 at 06:35:45PM -0500, Matthew Lewis wrote:
>
>
> > Can anyone think of a reason why this approach wouldn't work?
>
> I was just playing around with wxWindows a week or so ago (for windows, at
> least). I was using a dll version that came from Ray Smith (IIRC). I think
> I may have been able to create an instance of a wxObject. There are several
> challenges to wrapping this for Eu, at least with the approach that I was
> taking (it might be simpler to write a C++ wrapper that exposes everything
> as C and recompile).
That was my idea, to use a C++ wrapper which exposes everything as
C (as QtC does for the Qt widget library).
>
> First, we must deal with name decoration. Using Depedency Walker, I was
> able to undecorate the names, and import functions using ordinals. I don't
> believe that such a linking method exists for Linux, so you'd probably have
> to import decorated names.
Perhaps /bin/nm could help here ...
> Using fptr.e, I'm able to call functions by
> pointer, so that's not a problem.
Does that work for Linux? It would seem that it should for i386 at the
very least ...
> The v-tables were exported in the dll, so
> I could find the virtual functions. It would take some research to figure
> out how to overload a virtual function, however (do we need to allocate a
> new vtable? how do we communicate this for the new class? overwrite the
> function pointer that's there?).
Yes, thats why I wanted a C wrapper lib. To avoid all this trouble.
> Finally, wxWindows works sorta funny
> (IMHO). It's going to take a lot of time going through the macros to figure
> out what's really going on.
If we used the wrapper lib idea, then the MACROs could be wrapped as well, into
exportable functions.
>
> Matt Lewis
>
>
>
jbrown
--
/"\ ASCII ribbon
\ / campain against
X HTML e-mail and
/ \ news
3. Re: wrapping wxWindows
jbrown wrote:
> Could this be done?
Yes, I've done it already.
> ("control::function(...)" becomes "controltype_function(control, ...)" =
for
> example.)
That's the same approach I take as well. Actually, a bit more involved, s=
o=20
inheritance works and it supports variable number of arguments.
> Can anyone think of a reason why this approach wouldn't work?
The approach works just fine - I use it in wxBasic, as does the author of=
=20
wxLua (who uses a rewritten version of my wrappers).
The problem is linking it to Euphoria. Euphoria is compiled as a C librar=
y,=20
and (despite turning the wrappers into C functions), the application gets=
=20
compiled as C++ code. I'm an idiot about makefiles, so I don't have the=20
technical knowledge of how to link my C++ wrappers to Euphoria.
I suspect that you could just wrap the Euphoria code with PLAIN C { ... }=
=20
macro (or whatever it is) it would compile just fine. If anyone with acce=
ss=20
to the Euphoria source (I have my own copy) is interested in helping with=
=20
this project, I'd be glad to work with them.
I've made this offer a number of times, but there hasn't yet been any tak=
ers.
-- David Cuny
4. Re: wrapping wxWindows
I wrote:
> I suspect that you could just wrap the Euphoria code with PLAIN C { ...=
}
> macro (or whatever it is) it would compile just fine.
That would be:
extern "C" {
/* Euphoria source code */
}
-- David Cuny
5. Re: wrapping wxWindows
On Mon, Dec 23, 2002 at 12:24:47PM -0800, David Cuny wrote:
>
> I wrote:
>
> > I suspect that you could just wrap the Euphoria code with PLAIN C { ... }
> > macro (or whatever it is) it would compile just fine.
>
> That would be:
>
> extern "C" {
> /* Euphoria source code */
> }
>
> -- David Cuny
>
Oh. I didn't know that.
I was hoping that I could make a C library, not a C++ library.
Perhaps if I did a 2-step triple C wrap.
wxWindows -> wrapped in plain C, exported as a C++ library.
C++ wrapper lib -> wrapped again in plain C, but exported as a normal C lib this
time.
C wrapper lib -> wraps cleanly in Euphoria.
would that work instead?
jbrown
> ==^^===============================================================
> This email was sent to: jbrown1050 at hotpop.com
>
>
--
/"\ ASCII ribbon
\ / campain against
X HTML e-mail and
/ \ news
6. Re: wrapping wxWindows
On Tue, Dec 24, 2002 at 10:04:11AM +0000, Ray Smith wrote:
>
>
> jbrown1050 at hotpop.com wrote:
> > I was hoping that I could make a C library, not a C++ library.
> >
> > Perhaps if I did a 2-step triple C wrap.
> >
> > wxWindows -> wrapped in plain C, exported as a C++ library.
> > C++ wrapper lib -> wrapped again in plain C, but exported as a normal C
> > lib this time.
> > C wrapper lib -> wraps cleanly in Euphoria.
>
> I "think" the easiest path is to write a C++ library (since wxWindows
> is written in C++) but create the "wrapped" routines in a "C friendly"
> way (by using extern C{...} ).
> A library such as this wrapped in a DLL looks just like a C DLL
> (and I assume the same for shared libraries on *nix).
> This is the approach I was using for FLTK and FOX and it seemed to
> work fine.
>
Yes, that sounds much easier. I'll try this method out, thanks for the
tip.
> Regards,
>
> Ray Smith
> http://rays-web.com
Very Grateful,
jbrown
>
>
>
--
/"\ ASCII ribbon
\ / campain against
X HTML e-mail and
/ \ news