www.digitalmars.com         C & C++   DMDScript  

D - SWIG can provide C++ class wrapping and header import.

reply Ilya Minkov <midiclub 8ung.at> writes:
http://www.swig.org/exec.html

Is probably worth taking a look.

This utility has been developed to allow to use native-compiled 
libraries written in C and C++ from scripting languages. It has a 
powerful parser which deals with any imaginable problem, and currently 
has export modules not only for scripting languages such as Python, 
Perl, and others, but also to statically typed languages such as Java 
and OCaml.

I can see 2 uses for it - first, to generate D import units, including 
the code to wrap C++ classes into D classes (dunno whether it actually 
works), and OTOH to allow scripting languages to use D libraries.

It has more than 7 years of development in it - and a lot of thought. 
Definately more than i could spend for a similar project. :) It handles 
all the things which are not at all trivial. Overwhelming.

-i.
Mar 06 2003
next sibling parent Mark Evans <Mark_member pathlink.com> writes:
SWIG is a fantastic tool and well-known in the scripting world, e.g. for
interfacing C++ GUI libraries to alien tongues.  It even supports O'Caml!

Only in the case of Python would I recommend an alternative, the Boost Python
Library, and then only because BPL is custom-made for Python.

SWIG support for D is a good idea.  Still...I wonder a bit.  D is already so
close to C/C++ that interfacing should be built directly into the language.  To
an extent it is; D can invoke C code directly.  Yet it cannot invoke C++ code,
that is the lack.

Walter might be able to cook up something in the special case when the C++ code
is compiled by DMC++.  What intrigues me here is the concept of porting C++ code
to D.  That seamless capability would make porting C++ to D much easier, and
would be a good selling point to people with an interest in D but much legacy
C++ code on their hands.

Mark
Mar 06 2003
prev sibling parent Bill Cox <Bill_member pathlink.com> writes:
In article <b48mep$ue5$1 digitaldaemon.com>, Ilya Minkov says...
http://www.swig.org/exec.html

Is probably worth taking a look.

This utility has been developed to allow to use native-compiled 
libraries written in C and C++ from scripting languages. It has a 
powerful parser which deals with any imaginable problem, and currently 
has export modules not only for scripting languages such as Python, 
Perl, and others, but also to statically typed languages such as Java 
and OCaml.

I can see 2 uses for it - first, to generate D import units, including 
the code to wrap C++ classes into D classes (dunno whether it actually 
works), and OTOH to allow scripting languages to use D libraries.

It has more than 7 years of development in it - and a lot of thought. 
Definately more than i could spend for a similar project. :) It handles 
all the things which are not at all trivial. Overwhelming.

-i.
We use it for our TCL scripting. I'm currently stuck on a problem, though. I haven't been able to figure out how to pass variable parameters to my routines so I can deal with options. We may have to drop it, if it get's in the way of parameter parsing, but for the most part, it's been very useful. I'm sure a D version will be available soon enough. They seem to add support for just about everything. Bill
Mar 06 2003