lyle@knology.net | 14 Aug 2002 14:39

Re: calling target language from C; multilanguage extensions


On Wed, 14 Aug 2002 02:28:31 -0400 (EDT), Peter Amstutz
<tetron <at> interreality.org> wrote :

> My second question is about dealing with typemaps for various languages.
> Right now I have all my typemaps written for Perl at the top of my
> interface file, but I'd like to write an equivilent set of typemaps for
> other languages (guile scheme for example).  How can I specify to SWIG
> which set of typemaps to use, based on the target language?

I don't know if this is deprecated, since I don't see it mentioned in the
updated SWIG documentation, but instead of writing a typemap like this:

    %typemap(in) MySpecialType {
        /* feh */
    }

you can specify the target language for a typemap:

    %typemap(perl, in) MySpecialType {
        /* do it the Perl way */
    }

    %typemap(python, in) MySpecialType {
        /* do it the Python way */
    }

Another way would be to use SWIG preprocessor directives. Depending on the
language for which SWIG is generating code, it will define a preprocessor
symbol (e.g. SWIGPERL or SWIGPYTHON) that you can check for:
(Continue reading)

Max Okumoto | 14 Aug 2002 14:50
Favicon

Feature request (output included files)


Hi,
	I wonder if it is possible to add a option to output
the files included via '%include'.  I would like to use the
output to generate Makefile dependancies.

			Max Okumoto
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

David Beazley | 14 Aug 2002 14:57
Favicon

Feature request (output included files)

Max Okumoto writes:
 > 
 > Hi,
 > 	I wonder if it is possible to add a option to output
 > the files included via '%include'.  I would like to use the
 > output to generate Makefile dependancies.
 > 

Make a proposal.   What is the option name?  What is the format of the
output?   Otherwise, it sounds like it might be easy enough to implement.

Cheers,

Dave
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

David Beazley | 14 Aug 2002 14:59
Favicon

Re: calling target language from C; multilanguage extensions

lyle <at> knology.net writes:
 > 
 > On Wed, 14 Aug 2002 02:28:31 -0400 (EDT), Peter Amstutz
 > <tetron <at> interreality.org> wrote :
 > 
 > > My second question is about dealing with typemaps for various languages.
 > > Right now I have all my typemaps written for Perl at the top of my
 > > interface file, but I'd like to write an equivilent set of typemaps for
 > > other languages (guile scheme for example).  How can I specify to SWIG
 > > which set of typemaps to use, based on the target language?
 > 
 > I don't know if this is deprecated, since I don't see it mentioned in the
 > updated SWIG documentation, but instead of writing a typemap like this:
 > 
 >     %typemap(in) MySpecialType {
 >         /* feh */
 >     }
 > 
 > you can specify the target language for a typemap:
 > 
 >     %typemap(perl, in) MySpecialType {
 >         /* do it the Perl way */
 >     }
 > 
 >     %typemap(python, in) MySpecialType {
 >         /* do it the Python way */
 >     }
 >

This form of typemaps is deprecated.  It still works, but it's being
(Continue reading)

Charles Reitzel | 14 Aug 2002 15:26
Favicon

Re: calling target language from C; multilanguage extensions

Hi Peter,

I recently asked something very similar.  Digging into the docs, I found this:

http://www.swig.org/papers/Perl98/swigperl.htm

Check out section 5.1.2 "Callbacks".   It sounds like you have done 
something similar already (the hard part, anyway).  To respond your 
specific question about automating the stuff, I seems like you could use a 
typemap to generate calls to a "registration" function.  There is an 
example of this in the paper.

To respond to your second question, you can do this with %include.  Create 
a top-level interface file that %include's a language specific interface 
file.  On the SWIG command line, use a different include path to locate 
%includes so that, when generating Python, you will bring in the Python 
version.  When generating Tcl, bring in the Tcl version.  And so on.

%{
#include "foo.h"
%}

/* Create a different one of these for each language */
%include lang.i
%include foo.h

take it easy,
Charlie

At 02:28 AM 8/14/2002 -0400, Peter Amstutz wrote:
(Continue reading)

Andres Corrada-Emmanuel | 14 Aug 2002 15:21
Picon

Re: Type checking / inheritance in C++ wrappers for Python

Hi Dave,

The -c switch had no effect. I'm now trying to construct a simple
interface file to see if I can reproduce the effect.

One question - is it right that the self.this string for an object looks
like this?:

<C Foo instance at _000da450_p_Bar>

I thought self.this should be equal to just "_000da450_p_Bar"

Andres Corrada-Emmanuel
Senior Research Fellow
Center for Intelligent Information Retrieval
University of Massachusetts, Amherst

On Tue, 13 Aug 2002, David Beazley wrote:

> Andres Corrada-Emmanuel writes:
>  > Hi Dave,
>  >
>  > Yes, I made a mistake in the typedef. I do include the typedef and SWIG
>  > obviously learns from it because it represents the Bar object as somewhat
>  > derived from Foo eventhough it is declared as derived from NewFooName. But
>  > if that is the case why does the type error occur?
>  >
> I don't know.  You shouldn't get a type error---there are tests for
> this in the SWIG test-suite (and they all pass).
>
(Continue reading)

David Beazley | 14 Aug 2002 15:34
Favicon

Re: Type checking / inheritance in C++ wrappers for Python

Andres Corrada-Emmanuel writes:
 > Hi Dave,
 > 
 > The -c switch had no effect. I'm now trying to construct a simple
 > interface file to see if I can reproduce the effect.
 > 
 > One question - is it right that the self.this string for an object looks
 > like this?:
 > 
 > <C Foo instance at _000da450_p_Bar>
 > 
 > I thought self.this should be equal to just "_000da450_p_Bar"
 > 

It should be something like "_00da450_p_Bar".   It is in the examples I
try.  You didn't do anything like redefine the constructor did you?

-- Dave
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Andres Corrada-Emmanuel | 14 Aug 2002 15:44
Picon

Re: Type checking / inheritance in C++ wrappers for Python

No, I don't have any redefiniton of the constructor.

Andres Corrada-Emmanuel
Senior Research Fellow
Center for Intelligent Information Retrieval
University of Massachusetts, Amherst

On Wed, 14 Aug 2002, David Beazley wrote:

>
> It should be something like "_00da450_p_Bar".   It is in the examples I
> try.  You didn't do anything like redefine the constructor did you?
>
> -- Dave
>

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

David Beazley | 14 Aug 2002 15:53
Favicon

Re: Type checking / inheritance in C++ wrappers for Python

Andres Corrada-Emmanuel writes:
 > No, I don't have any redefiniton of the constructor.
 > 

I'll need a specific example that illustrates this behavior in order
to fix it.  I'm not seeing anything wrong in any of the examples.

-- Dave

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Phillip Tomson | 14 Aug 2002 23:17
Picon

Re: SWIG-1.3.14 temporarily withdrawn


On Tue, 13 Aug 2002, David Beazley wrote:

>
> Unfortunately, a critical last minute bug has appeared in the 1.3.14
> release I just announced.   I'm withdrawing the release and will put a
> new version online in a few hours.  Sorry about this.
>
> Cheers,
>
> Dave

I see 1.3.14 on the download page.  Does that mean that it has been fixed
and un-withdrawn?

BTW: The overloaded method handling in 1.3.14 sounds very cool!

Phil

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig


Gmane