Subject:                Re: [Metakit] Ruby bindings using SWIG
From:                   Jean-Claude Wippler <[EMAIL PROTECTED]>
To:                     Metakit mailing list <[EMAIL PROTECTED]>
Date sent:              Mon, 9 Jun 2003 22:09:54 +0200

> John,
> 
> > I have made quite a lot of progress with binding Metakit, using
> > SWIG (http://www.swig.org/).  All that this needs, once you have
> > SWIG, is to make a local copy of the Metakit header and run this
> > SWIG file
> >
> > -----------------------
> >  /* File : mk4.i */
> > %module mk4
> >
> > %{
> > #include "mk4.h"
> > %}
> >
> > /* First attempt at mk4 interface */
> >
> > %include "mk4.h"
> > ----------------------
> 
> Thanks for sharing.  Looks like SWIG has come a *long* way since I last 
> looked at it!  Whee - this means Perl and Java binding might now also 
> be within easy reach...
> 

Yes it has.  Support for templates and overloaded operators is 
much improved.

> Is it ok to add your .i file and Ruby sample code on one of the pages 
> on www.equi4.com?  I'd like to support this and help people who want to 
> create more bindings and sample code.  Or perhaps wait for things to 
> settle a bit more?
> 

See below

> -jcw
> 
> _______________________________________________
> metakit mailing list  -  [EMAIL PROTECTED]
> http://www.equi4.com/mailman/listinfo/metakit
> 

JCW

Have a look at http://www.equi4.com/metakit/wiki.cgi/224 on the 
metakit wiki. 

I have already put the same code up there.  If you want to make it 
Ruby page on your web site as well, feel free to do so.  I suggest 
you put in a link to SWIG.  I searched for SWIG and Ruby on the 
MK wiki before I started this and found nothing.

I am sure what is posted can be improved to add back the [ ] 
operator.  
= operator has to be renamed as e.g. equals
!= operator is not needed (implemented in Ruby as !(a == b)  )

The big one is whether to rename all the classes in Metakit with 
capital letters. I have a version of the mk4.i where I use %rename a 
lot, which gets rid of a lot of the SWIG warnings.  In most cases I 
think this will do all that is needed.  

The exception I have found (with Metakit) is when a renamed object 
is a member in a C++ class which is also translated.  e.g. I have a 
class which has a member object of type e4_Storage (the E4Graph 
equivalent of c4_Storage ).  I cannot get that properly renamed by 
SWIG to be type E4_Storage and access to it from Ruby fails.  
The workaround is to reimplement the needed member functions in 
the upper class.

This means that from a strategic point of view, implementations will 
start to be target language specific.  For example the Ruby 
interface has direct support for the STL vector and string via an stl.i

I am happy to post all that I have done so far on Metakit/Ruby.  I 
will do so in the next few days.  I am not interested to develop the 
interface Metakit interface myself, as my main interest is in 
E4Graph, which I have also done, including E4xml.  This hides me 
from direct use of Metakit.

It may be for the most efficient operation that SWIG is a stepping 
stone to a crafted implementation.  What it certainly does is 
generate something that works very quickly.

Cheers

John

-------------------------------------------------------------------
Dr John P. Fletcher          Tel: (44) 121 359 3611 ext 4625
Chemical Engineering and Applied Chemistry (CEAC),
School of Engineering and Applied Science (SEAS),
Aston University,            Fax: (44) 121 359 4094
Aston Triangle,              Email: [EMAIL PROTECTED]
BIRMINGHAM B4 7ET  U.K.      CEAC Web site http://www.ceac.aston.ac.uk/

_______________________________________________
metakit mailing list  -  [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit

Reply via email to