#763 Typemaps are ignored inside %extend block


I am extending a class. The typemaps that were
declared outside the %extend{} block are ignored; the
typemaps from within the block are used.

machine!user:~/swigbug [321]> cat bug.i
%module bug;

class B {

%typemap(out) int { print("Int typemap\n"); }
%extend B {
%typemap(out) long { print("long typemap\n"); }
int fn1();
long fn2();

machine!user:~/swigbug [322]> ../swig-
1.3.29/bin/swig -c++ -perl5 bug.i
machine!user:~/swigbug [323]> grep typemap *cxx
/* The TmpMask is for in/out typemaps that use
temporal objects */
print("long typemap\n");
machine!user:~/swigbug [324]>

The expected outcome is that the "grep" shows
both "Int typemap" and "long typemap". What happens
is that the "long typemap" (the one defined inside %
extend block) is applied but the "Int typemap" (the
one defined outside) is not.


  • David M. Beazley

    Logged In: YES

    Not a bug. %extend extends the class in the place where
    the class is defined---typemaps must be in effect before the
    class definition.

  • David M. Beazley

    • status: open --> closed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks