1. SWIG/Euphoria

I've posted my beta 1.0 version of SWIG to the Euphoria home page. The
description is a bit cryptic, so I figured I should explain it a bit.

SWIG is a program written by people people much more clever than me. It can
be found at http://www.swig.org. SWIG makes it easy to add C/C++ library
functions into scripting languages such as Tcl/Tl, Python, Perl and Guile.
You feed it an interface file (basically, the library's header file,
slightly modified), and it generates bindings for the language of your
choice. To add the new functions to your favorite language, you just
recompile the language with the new bindings that SWIG produced.

So what does this have to do with Euphoria? Well, I've coded a module onto
SWIG to generate wrappers for Euphoria. That means  it should be fairly easy
to use your favorite C/C++ library in Euphoria.

Since we don't have the source for Euphoria, SWIG/Euphoria takes a slightly
different approach than other SWIG modules. It generates the source for a
DLL file and Euphoria wrappers. Compile the DLL, include the Euphoria
wrappers, and you've added your favorite C/C++ library to Euphoria.

Well, in theory, anyway. Some caveats:

1. This is a beta, so I haven't tested it extensively.
2. It (currently) only supports Windows.
3. You need to be know how to compile the DLL with C/C++.

What might this be useful for? Graphic and sound libraries come to mind
(GLUT/OpenGL, SciTech MGL, Allegro/Win32), as well as GUI toolkits
(GraphApp, FLTK, V, wxWindows). Personally, my goal is to add wxWindows to
Euphoria.

Feedback is welcome!

Thanks!

-- David Cuny

new topic     » topic index » view message » categorize

2. Re: SWIG/Euphoria

hrm....
and someone just asked if u can use .ocx in euphoria
for VB 'including'....
could swig be used for that i wonder???
(see mjaksen:Linking to .OCX files in WinEu)
talk about making the cart beat the horse tho to
make this work ROFL...
----- Original Message -----
From: Cuny, David at DSS <David.Cuny at DSS.CA.GOV>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Friday, August 04, 2000 11:02 AM
Subject: SWIG/Euphoria


> I've posted my beta 1.0 version of SWIG to the Euphoria home page. The
> description is a bit cryptic, so I figured I should explain it a bit.
>
> SWIG is a program written by people people much more clever than me. It
can
> be found at http://www.swig.org. SWIG makes it easy to add C/C++ library
> functions into scripting languages such as Tcl/Tl, Python, Perl and Guile.
> You feed it an interface file (basically, the library's header file,
> slightly modified), and it generates bindings for the language of your
> choice. To add the new functions to your favorite language, you just
> recompile the language with the new bindings that SWIG produced.
>
> So what does this have to do with Euphoria? Well, I've coded a module onto
> SWIG to generate wrappers for Euphoria. That means  it should be fairly
easy
> to use your favorite C/C++ library in Euphoria.
>
> Since we don't have the source for Euphoria, SWIG/Euphoria takes a
slightly
> different approach than other SWIG modules. It generates the source for a
> DLL file and Euphoria wrappers. Compile the DLL, include the Euphoria
> wrappers, and you've added your favorite C/C++ library to Euphoria.
>
> Well, in theory, anyway. Some caveats:
>
> 1. This is a beta, so I haven't tested it extensively.
> 2. It (currently) only supports Windows.
> 3. You need to be know how to compile the DLL with C/C++.
>
> What might this be useful for? Graphic and sound libraries come to mind
> (GLUT/OpenGL, SciTech MGL, Allegro/Win32), as well as GUI toolkits
> (GraphApp, FLTK, V, wxWindows). Personally, my goal is to add wxWindows to
> Euphoria.
>
> Feedback is welcome!
>
> Thanks!
>
> -- David Cuny
>


_____NetZero Free Internet Access and Email______
   http://www.netzero.net/download/index.html

new topic     » goto parent     » topic index » view message » categorize

3. Re: SWIG/Euphoria

Hawke' wrote:

> hrm....
> and someone just asked if u can use .ocx in
> euphoria for VB 'including'....
> could swig be used for that i wonder???

I suspect that if someone found the C API, it would be just as easy to code
it in 'pure' Euphoria. The issue is that the .OCX control would then need to
be integrated into whatever toolkit you were using (for example, Win32Lib).

I've wondered about this; if someone could supply a link, I'll take a look.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

4. Re: SWIG/Euphoria

On Fri, 4 Aug 2000 11:02:55 -0700, Cuny, David at DSS <David.Cuny at DSS.CA.GOV>
wrote:

>
>Feedback is welcome!
>


    shapes.e is redefining PI which is defined in misc.e which included

    by msgbox.e

    Wouldn't it be easier to build a win32lib using C++ into a DLL.

    Then build a interface using the same proto types that you have

    all ready designed for win32lib to call the DLL like Dan and Gary

    did.

new topic     » goto parent     » topic index » view message » categorize

5. Re: SWIG/Euphoria

Bernie wrote:

> shapes.e is redefining PI which is defined in misc.e which included
>  by msgbox.e

Yeah, my documentation addresses it. There's a directive that I'm too lazy
to look up, where you can write something like:

    %name MY_PI #declare PI ....

and that would take care of it.

> Wouldn't it be easier to build a win32lib using
> C++ into a DLL.

No, not for me. There's a lot of support stuff that Win32Lib does, and I'm
not really a competent C/C++ code. If I was a good C++ code, that route
would probably be very appealing.

Despite my C incompetence, I am working hard on getting wxWindows running
under Euphoria. wxWindows is a cross-platform library, supporting Linux
(with Xt, Motif and GTK+), Win32 (using native controls) and the Mac (also
with native controls). So I think that this would be a *big* win over
Win32Lib - *if* I can do it. Fortunately, I can borrow a lot of code from
wxPython. Once I get even the simplest demo up and running, I'll be making a
lot more noise about it.

BTW, there's a small bug in SWIG/Euphoria that causes structures accessor
wrappers to be misnamed; I've just sent Robert a fix.

Thanks for the feedback!

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

6. Re: SWIG/Euphoria

Hi David,

Forgive MY C++ ignorance and incompetence as well... but don't you need
to "destroy" the "circle" and "square" objects somewhere in the shapes.exw
demo?

Lee.


David Cuny wrote:

>Despite my C incompetence...

new topic     » goto parent     » topic index » view message » categorize

7. Re: SWIG/Euphoria

Lee West wrote:

> Forgive MY C++ ignorance and incompetence as
> well... but don't you need to "destroy" the "circle" and
> "square" objects somewhere in the shapes.exw
> demo?

I should, but I just grabbed the code from the SWIG examples. There's no
destructor in the Shapes class. If you added:

   ~Circle();

you would end up with a destructor method in the code. Since SWIG expects
that it will create the objects. This ends up looking like this:

#define delete_Circle(_swigobj) (delete _swigobj)
extern "C" void  __declspec(dllexport) _wrap_swig_delete_Circle(Circle
*self)
    delete_Circle(self);
}

The problem is that SWIG is expecting that the object to be deleted is
supposed to be a SWIG object. SWIG has a bunch of cool stuff that wraps the
pointers, makes them typesafe, and so on. Of course, SWIG/Euphoria uses none
of this.

As a result, there's no delete() behavior defined. At least, I don't think
so. If 'delete' is a legitimate way to destroy C++ objects, then everything
is cool. If not, I'll need to take a look at how SWIG handles it internally,
and see if I can duplicate it without the overhead.

I was naively thinking I could write:

#define delete _swigobj (~_swigobj)

but I *really* doubt this would work.

Anyone want to whack me with a cluestick here?

Thanks!

-- David "I don't know C" Cuny

new topic     » goto parent     » topic index » view message » categorize

8. Re: SWIG/Euphoria

I wrote:

> If 'delete' is a legitimate way to destroy C++ objects,
> then everything is cool.

According to the O'Reilly 'Core C++' book at my local Tower Books, 'delete'
is the proper keyword for destroying objects. So if you include the method:

   ~Class();

for any given class, SWIG will generate the wrapper:

   delete_Class( atom self )

at the Euphoria level, which will ultimately call

  delete self;

at the C++ level. I hope that clears things up!

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu