This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Guile to C++ library link.


John Carter <john@dwaf-hri.pwv.gov.za> writes:

> My situation is this. I have a largish (64000+ lines of C++) library
> of C++ code. The library mostly provides numerical and statistical and
> database like functions for environmental modelling. It includes some
> LGPL'd code and hence itself will be LGPL'd.

Sounds familiar.

<interesting project details elided>

> Glitches I can think of are...
> 1) Conflicts between C++ new/delete memory management and Guile
> garbage collection. Can I attach a finaliser to the Guile version of
> the object that calls in the C++ destructor?

This works no problem with smobs.  In short, you can create a new type
of scheme object that wraps one of you C++ objects, and then arrange
for the Guile garbage collector to call your finalizer whenever an
object becomes unreachable.  It works for me.  The gtcltk guile
extension has a nice example of how to do this.

> 2) The library essentially provides a rich new set of intrinsic objects
> for Guile, so I would like to add recognition for some these new
> beasties at scanner level. eg. Guile scanner recognises SEXP's,
> floats, ints, strings, symbols, vectors. I want to add things like
> dates, tensors of elements of type X.
> 
> How easy would it be to monkey with something that much in the heart
> of Guile, ie the scanner?

I can't help in the reader macros department.  Hopefully someone else
on the list can help with this.

> 3) I can get a list about 2900 "Class::methodName( type,type,type...)"
> out of the library file using "nm". What is the easiest way of
> translating that into calls from Guile?

g-wrap and swig have been used to automate the process of producing
'glue' code between and guile and C or C++ code.  Unfortunately, there
is nothing that I know of that can directly snarf header files and
output something useful with guile.  (As a hopelessly off-topic aside,
I think Allegro Common Lisp can do this, though).  Using the output
of 'nm' is an interesting idea, though.

I tend to generate the glue code as it's needed, and I use a couple
of handy emacs commands to make this easier.  I hope this helps.

-russ


--
There are two kinds of people in the world:  people who think there 
are two kinds of people and people who don't.