Stefano Moratto | 1 Aug 2008 08:46
Picon

Re: DELPHI (Object Pascal) Module

Thanks Olly!

Stefano

On Fri, Aug 1, 2008 at 12:46 AM, Olly Betts <olly <at> survex.com> wrote:
On 2008-07-31, William S Fulton <wsf <at> fultondesigns.co.uk> wrote: 

> I need to check, but if gcc doesn't support it, I doubt it is in the
> standard and so shouldn't be used.

No, strlwr() isn't ISO C.

> By all means write a replacement and
> as it is string based, prefer a DOH version and add it into DOH/string.c.

There's already one: Swig_string_lower() in misc.c (prototyped in swig.h).

Cheers,
   Olly


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swig-devel mailing list
Swig-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-devel



--
Dr.Eng. Stefano Moratto
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
SourceForge.net | 2 Aug 2008 10:30
Picon
Favicon

[ swig-Patches-2019314 ] Allegro List fixes & small Chicken Scheme fix

Patches item #2019314, was opened at 2008-07-16 03:53
Message generated for change (Comment added) made by wuzzeb
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=301645&aid=2019314&group_id=1645

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Lorenz Msenlechner (moesenle)
Assigned to: Nobody/Anonymous (nobody)
Summary: Allegro List fixes & small Chicken Scheme fix

Initial Comment:
The generator module for Chicken Scheme seems to have a small bug. On our Debian etch system, it is necessary
to add #include <assert.h> by hand to the c++ file generated by SWIG. The problem can be easily solved by
adding the include line to chicken.swg.

The generator module for Allegro Lisp seems to be quite broken, especially for c++. 
First of all, it is not possible to specify absolute path names for the input file because the path for the
common lisp output file is generated wrong, based on the input file path. 
Further, when generating bindings from a c++ library, the resulting c++ binding file cannot be compiled
due to a missing condition for methods with no return value in the generator module. In the try-block, a
return expression is still created.
The lispification-function in allegrocl.swg also behaves strange. It inserts a '-' whenever a change
from lowercase to uppercase is detected in a symbol name, but also when a change from uppercase to
lowercase is detected. This is wrong and leads to e.g. the following symbol names: The method 'open' of
class Bottle is transformed to bottle_open without lispification and with lispification to b-ottle-open.

Apart from these issues, the generated lisp file cannot be compiled in some cases, when some type synonyms
cannot be resolved, which leads to empty lines in the lisp code. Further, template classes are causing
problems because of the class renaming done in these cases.
This can be fixed by changing the lisp-function full-name to take into account type synonyms.

Attached, you find a patch to fix all of these issues.
It was made against SVN revision 10659.

Best regards,
Lorenz

----------------------------------------------------------------------

>Comment By: John Lenz (wuzzeb)
Date: 2008-08-02 03:30

Message:
Logged In: YES 
user_id=153408
Originator: NO

Ok, I committed this patch in 10726.  I am not really familiar with
allegro cl and had no way to test it, but looking at the changes they look
ok.

Also, I notice now that the chicken test suite spits out a whole bunch of
warnings... the output of make check-chicken-test-suite used to be so clean
:(  Will have to clean up the warnings.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=301645&aid=2019314&group_id=1645

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Haoyu Bai | 5 Aug 2008 11:00
Picon

GSoC Python 3.0 Support Weekly Status Report #15

Hello,

Last week I finished the Python 3.0's abstract base class support.
(See PEP 3119 -- Introducing Abstract Base Classes for detail of the
ABC: http://www.python.org/dev/peps/pep-3119/)

If you have ever used SWIG to wrap STL classes, now you can try to add
an include line in your interface file:

%include<pyabc.i>

Then your std::list, std::vector, std::set, std::map and other STL
containers will automatically gain an ABC base class. For example, you
can try:

issubclass(IntSet, collections.MutableSet)  #True
issubclass(IntVector, collections.MutableSequence) #also True

At this point, almost all the proposed Python 3 related features are
implemented. Though there still codes need to review and polish, also
some documentation works. Hopefully we can merge the code back to
trunk at the end of GSoC.

--

-- 
Haoyu Bai

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Florian Hackenberger | 6 Aug 2008 20:45
Picon

Re: Java directors and typemaps

I crosspost this to swig-user so it is obvious that the discussion 
continues on swig-devel.

On Wednesday 06 August 2008, Florian Hackenberger wrote:
> How would I go about wrapping the user_data in a byte array (or maybe
> a String) for java? Typemaps don't seem to work in this direction
> because they would not know the size of the buffer.
Ok I found out how to do the mapping:

Basically I have to instruct swig to create code for mapping from void* 
to byte[] and vice versa. I added the following to my .i file:
/* void* shall be handled as byte arrays */
%typemap(jni) void * "void *"
%typemap(jtype) void * "byte[]"
%typemap(jstype) void * "byte[]"
%typemap(javain) void * "$javainput"
%typemap(in) void * %{
	$1 = $input;
%}
/*The following typemap is just for testing and does not even compile*/
%typemap(directorin,descriptor="[B") void * %{
	$input = new ByteArray();
%}
%typemap(javadirectorin) void * "$jniinput"
%typemap(out) void * %{ 
	$result = $1; 
%}
/* %typemap(directorout) void * %{
	$result = (void *)$input;
%}*/
%typemap(javaout) void * {
	return $jnicall;
}

swig inserts the code specified using the directorin typemap into the 
wrapper code:
$input = new ByteArray();

and generated the Java files accordingly (with byte[] as parameters), 
but there is one problem. It tries to call the following method:
"SwigDirector_Callback_on_pager_status", "(Lorg/pjsip/pjsua/Callback;Lorg/pjsip/pjsua/SWIGTYPE_p_void_p;I)V"

Which is set up in .*swig_1module_1init. That does not work because this 
method has byte[] as a first parameter. The relevant code in swig1.3.33 
is in java.cxx around line 3536:
      /* Get parameter's intermediary C type */
      if ((c_param_type = Getattr(p, "tmap:jni"))) {
        Parm *tp = NewParmFromNode(c_param_type, empty_str, n);
        String *desc_tm = NULL, *jdesc = NULL, *cdesc = NULL;

        /* Add to local variables */
        Printf(c_decl, "%s %s", c_param_type, arg);
        if (!ignored_method)
          Wrapper_add_localv(w, arg, c_decl, (!
(SwigType_ispointer(pt) || SwigType_isreference(pt)) ? "" : "= 0"), 
NIL);

        /* Add input marshalling code and update JNI field descriptor */
        if ((desc_tm = Swig_typemap_lookup_new("directorin", tp, "", 0))
            && (jdesc = Getattr(tp, "tmap:directorin:descriptor"))
            && (tm = Getattr(p, "tmap:directorin"))
            && (cdesc = Getattr(p, "tmap:directorin:descriptor"))) {

          // Objects marshalled by passing a Java class across the JNI 
boundary use jobject as the JNI type -
          // the nouse flag indicates this. We need the specific Java 
class name instead of the generic 'Ljava/lang/Object;'
          if (GetFlag(tp, "tmap:directorin:nouse"))
            jdesc = cdesc;
          String *jni_canon = canonicalizeJNIDescriptor(jdesc, tp);
          Append(jnidesc, jni_canon);
          Delete(jni_canon);

the string jnidesc forms the signature of the method. The relevant state 
of the program is as follows:
print (char*)String_data(DohGetattr(p, "tmap:jni"))
"void *" 
print (char*)String_data(DohGetattr(p, "name"))
"user_data"
print (char*)String_data(DohGetattr(tp, "tmap:directorin:descriptor"))
"L$packagepath/$&javaclassname;" 
print (char*)String_data(DohGetattr(p, "tmap:directorin:descriptor"))
"[B"
print (char*)String_data(DohGetattr(p, "tmap:directorin"))
"\n\t$input = new ByteArray();\n"

As you can see the correct JNI type descriptor is there ("[B"), but the 
default descriptor from the 'tp' node is applied 
("L$packagepath/$&javaclassname;"). Am I missing something or is that a 
bug in swig?

Cheers,
	Florian

--

-- 
DI Florian Hackenberger
florian <at> hackenberger.at
www.hackenberger.at

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Jan Jezabek | 7 Aug 2008 13:45
Picon
Favicon

Some problems with function hiding (C# new)

Hi,

I ran across a bug (?) in Allocate::function_is_defined_in_bases shown 
by this example:

%module bbase

%rename (aaa2) B::aaa();
%rename (bbb) B::bbb2();

%inline %{

class A {
   public:
   int aaa();
   int bbb();
   int ccc;
};

class B : public A {
   public:
   int aaa();
   int bbb2();
   void ccc(int);
};

%}

The problem is the incorrect generation of the "hides" attribute - 
B::aaa2 has this attribute set while B::bbb has it cleared. Thus B::aaa2 
is declared as "new" in C# and B::bbb is not, leading to complaints from 
the compiler in both cases.
A somewhat related problem arises with ccc - here mcs (version 0.96) 
also complains that the "new" keyword is needed; the parameters of 
B::ccc do not matter. I am unable to test under MS .NET, but I believe 
that mcs is right.

Regarding the first problem - it seems that marking methods as "hides" 
should be done in case of the same "sym:name", while marking them as 
"overrides" needs to be done based on "name". Am I right here? I will 
try to come up with a patch shortly to show what I have in mind.
I have not yet really looked at the second problem.

I am planning to do a small change to 
Allocate::function_is_defined_in_bases for the COM module - I need to 
check whether a function is overloading a name which was defined in a 
superclass, e.g.:

class X {
   public:
   void aaa();
};

class Y : public X {
   public:
   void aaa(int);
};

COM cannot handle overloading and thus I need to ignore aaa(int). 
Therefore I plan to add an "overloads_base" attribute for this case. 
This situation is very similar to the situation when "hides" is set so I 
decided that Allocate::function_is_defined_in_bases is the right place 
to detect this case. I will send the relevant code as a separate patch.

Thanks,
Jan Jezabek

--

-- 
My GSoC 2008 development blog: http://jezabekgsoc.wordpress.com/

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Jan Jezabek | 7 Aug 2008 15:01
Picon
Favicon

Re: Some problems with function hiding (C# new)

Here's a follow-up with some further (related) bugs:

%module bbase

%rename (aaa2) B::aaa();
%rename (bbb) B::bbb2();

%ignore C;

%rename (aaa2) G::aaa();

%inline %{

class A {
   public:
   int aaa();
   int bbb();
   int ccc;
};

class B : public A {
   public:
   int aaa();
   int bbb2();
   void ccc(int);
};

class C {
   public:
   virtual int aaa();
};

class D : public C {
   public:
   int aaa();
};

class E : public D {
   public:
   int aaa();
};

class F {
   public:
   virtual int aaa();
};

class G : public F {
   public:
   virtual int aaa();
};

%}

(A and B are the same as in the previous mail). The problem with C, D 
and E is that C is ignored. Therefore D::aaa() is not marked as virtual 
and E::aaa() is marked as "new" instead of "override".
Regarding F and G - despite G::aaa being renamed to G::aaa2 is is still 
marked as "override". I can't imagine a situation where I would want to 
do something like this, but still it's valid and generates code that 
does not compile (the previous problems resulted in warnings, this 
results in an error).

Thanks,
Jan Jezabek

--

-- 
My GSoC 2008 development blog: http://jezabekgsoc.wordpress.com/

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Jan Jezabek | 7 Aug 2008 22:03
Picon
Favicon

Re: Some problems with function hiding (C# new)

Hi everyone,

I have come up with a patch for the issues mentioned previously. There 
is still a warning if you overload a name that has been used as a 
variable in a base class (see A::ccc and B::ccc(int) in the previous 
message) - I am still not sure how to handle this.

The main part of the patch - consisting of modifications to allocate.cxx 
- is here (rev 10739 in my branch):
http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-jezabek/Source/Modules/allocate.cxx?r1=10418&r2=10739

If you prefer the resulting file then you can find it here:
http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-jezabek/Source/Modules/allocate.cxx?revision=10739&view=markup

The patch separates the part of function_is_defined_in_bases which was 
responsible for checking if the function is virtual - this part should 
not be sensitive to %ignore and %rename. The remaining part of 
function_is_defined_in_bases only checks the bases that are superclasses 
in the target language (this was not exactly the case earlier - if a 
base class B was ignored but its superclass A was not then a class 
deriving from B could have methods with the 'override' modifier - see 
inherit_same_name4 test-case).

I have tested this change using check-csharp-test-suite; the only 
difference was that the rname testcase stopped complaining about an 
unnecessary 'new' modifier.

I have also created test cases that trigger warnings and errors with the 
previous code - these are revisions 10740 and 10742, available here:
http://swig.svn.sourceforge.net/viewvc/swig?view=rev&revision=10740
http://swig.svn.sourceforge.net/viewvc/swig?view=rev&revision=10742

Finally I have made a minor change to allocate.cxx for finding methods 
that have been overloaded in a subclass (see my first message in this 
thread):
http://swig.svn.sourceforge.net/viewvc/swig?view=rev&revision=10741

All of these changes are still in my branch, but they are not really 
COM-specific (apart of 10741) so I'd be happy to merge them to trunk 
once they are reviewed and accepted as correct.

Thanks,
Jan Jezabek

--

-- 
My GSoC 2008 development blog: http://jezabekgsoc.wordpress.com/

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Florian Hackenberger | 10 Aug 2008 21:02
Picon

Re: [Swig-user] Java directors and typemaps

On Wednesday 06 August 2008, Florian Hackenberger wrote:
> On Wednesday 06 August 2008, Florian Hackenberger wrote:
> > How would I go about wrapping the user_data in a byte array (or
> > maybe a String) for java? Typemaps don't seem to work in this
> > direction because they would not know the size of the buffer.
>
> Ok I found out how to do the mapping:
Has somebody ever done type mapping using directors with Java?

Cheers,
	Florian
--

-- 
DI Florian Hackenberger
florian <at> hackenberger.at
www.hackenberger.at

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
zhiyang jiang | 10 Aug 2008 10:31
Picon

Re: Better improvement for the multi inheritance



2008/7/30 William S Fulton <wsf <at> fultondesigns.co.uk>
zhiyang jiang wrote:


2008/7/14 William S Fulton <wsf <at> fultondesigns.co.uk <mailto:wsf <at> fultondesigns.co.uk>>:


   zhiyang jiang wrote:


       Hi William
       Through a few days' work, i make some changes in SWIG source for
       bettering the multi inheritance .Now  the multi inheritance
       likes this:


   Hi,

   Hope you are well. Thanks for this. I'm a bit overloaded at the
   moment, but will have a look in the next few days.

   William


this is a new patch!

--
I am sorry for taking so long to look at this, there is too much going on at the moment.

I think you have left out the .i test and runtime test for multiple_inheritance_abstract in your second patch, so I looked for these in your first patch... not a problem unless you changed them.

Having looked at the patch, the following change is a big concern:

-    super($imclassname.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn);
+    //super($imclassname.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn);

This upcast is absolutely necessary as the pointer to the base class might not be the same value as the pointer to a derived class, therefore the original pointer must be stored in the derived class as well as the pointer value up cast to the base class.
The  SWIG$javaclassnameUpcast(cPtr) just return the pointer of derived classes' first base class,so i don't think it is useful when up cast to the case class.But it will get undefined behavior when calling a c++ function  that it has a Base classes as parameter ,see testcase's function foo6(),foo7(),foo8() in java.  i  think it may be caused by the conversion of pointer from java to c++,when the address of a class  is converted from java to c++,some type info will lost,i am not sure about it.

The following also won't work when a null pointer is being used:

-%typemap(javain) SWIGTYPE *& "$*javaclassname.getCPtr($javainput)"
+/*%typemap(javain) SWIGTYPE *& "$*javaclassname.getCPtr($javainput)"*/
+%typemap(javain) SWIGTYPE *& "$javainput.getCPtr()"
The new patch will check the $javainput use a condition  expression now!

I suggest you add another test method to your testcase, one which takes ABase1* as a parameter. Also CBase1*, CBase2* as both return types and input parameters.
I add some new functions into testcase, they test the base classes as parameters, but unfortunately, it will get unexpected results when use these functions, 

For any future patches, can I suggest you post them publicly. One of the lessons to be learnt in open source programming, which is encouraged for all Google summer of code students, is to develop in the open.

William

This patch works well when there is no c++ function that has a base class as its parameter,or it will get unexpected results ,and it will be ok when there are functions that has base class parameters in java, see the testcase about that.I am now finding what's wrong with it.


--
Best Regards
Jiang

Index: /home/jazy/workspace/SWIG/Examples/test-suite/common.mk
===================================================================
--- /home/jazy/workspace/SWIG/Examples/test-suite/common.mk	(revision 10659)
+++ /home/jazy/workspace/SWIG/Examples/test-suite/common.mk	(working copy)
 <at>  <at>  -221,6 +221,7  <at>  <at> 
 	minherit2 \
 	mixed_types \
 	multiple_inheritance \
+       multiple_inheritance_abstract \
 	name_cxx \
 	name_warnings \
 	namespace_class \
Index: /home/jazy/workspace/SWIG/Examples/test-suite/java/multiple_inheritance_abstract_runme.java
===================================================================
---
/home/jazy/workspace/SWIG/Examples/test-suite/java/multiple_inheritance_abstract_runme.java	(revision 0)
+++
/home/jazy/workspace/SWIG/Examples/test-suite/java/multiple_inheritance_abstract_runme.java	(revision 0)
 <at>  <at>  -0,0 +1,109  <at>  <at> 
+import multiple_inheritance_abstract.*;
+
+public class multiple_inheritance_abstract_runme {
+
+  static {
+    try {
+      System.loadLibrary("multiple_inheritance_abstract");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in
the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+//Test base class as a parameter in java
+int jfoo1(CBase1 cb1){
+return cb1.foo1();
+}
+int jbar1(ABase1 ab1){
+return ab1.bar1();
+}
+int jfoo2(CBase2 cb2){
+return cb2.foo2();
+}
+  public static void main(String argv[]) {
+ //Test Derived1
+   Derived1 d1=new Derived1();
+   if(d1.foo1()!=3)
+     throw new RuntimeException("Derived1::foo1() failed in multiple_inheritance_abstract");
+   if(d1.foo2()!=4)
+       throw new RuntimeException("Derived::foo2() failed in multiple_inheritance_abstract");
+//Test Derived2
+   Derived2 d2=new Derived2();
+   if(d2.foo1()!=6)
+       throw new RuntimeException("Derived2::foo1() failed in multiple_inheritance_abstract");
+   if(d2.bar1()!=5)
+       throw new RuntimeException("Derived2::bar1() failed in multiple_inheritance_abstract");
+//Test Derived3
+   Derived3 d3=new Derived3();
+   if( d3.foo1()!=7)
+       throw new RuntimeException("Derived3::foo1() failed in multiple_inheritance_abstract");
+   if(d3.foo2()!=8)
+       throw new RuntimeException("Derived3::foo2() failed in multiple_inheritance_abstract");
+   if(d3.bar1()!=9)
+       throw new RuntimeException("Derived3::bar1() failed in multiple_inheritance_abstract");
+//Test interfaces from c++ classes 
+   CBase1 cb1=new SWIGTYPE_CBase1();
+   CBase2 cb2=new SWIGTYPE_CBase2();
+   if(cb1.foo1()!=1)
+      throw new RuntimeException("CBase1::foo1() failed in multiple_inheritance_abstract");
+   if(cb2.foo2()!=2)
+      throw new RuntimeException("CBase2::foo2() failed in multiple_inheritance_abstract");
+   //Test abstract class as return value
+   ABase1 ab1=d3.clone();
+   if( ab1.bar1()!=9)
+       throw new RuntimeException("Derived3::bar1() through ABase1 failed in multiple_inheritance_abstract");
+//Test concrete base class as return value
+  CBase1 cb6=d2.clone();
+  CBase2 cb7=d1.clone();
+if(cb6.foo1()!=6)
+      throw new RuntimeException("Derived2::foo1() through CBase1 failed in multiple_inheritance_abstract");
+if(cb7.foo2()!=4)
+         throw new RuntimeException("Derived1:foo2() through ABase1 failed in multiple_inheritance_abstract");
+   //Test multi inheritance 
+   CBase1 cb3=new Derived1();
+   CBase1 cb4=new Derived3();
+   CBase2 cb5=new Derived3();
+   ABase1 ab6=new Derived2();
+   if(cb3.foo1()!=3)
+      throw new RuntimeException("Derived1::foo1()through CBase1 failed in multiple_inheritance_abstract");
+   if(cb4.foo1()!=7)
+      throw new RuntimeException("Derived3::foo1()through CBase1 failed in multiple_inheritance_abstract");
+   if(cb5.foo2()!=8)
+      throw new RuntimeException("Derived3::foo2()through CBase2 failed in multiple_inheritance_abstract");
+   if(ab6.bar1()!=5)
+      throw new RuntimeException("Derived2::bar1()through ABase1 failed in
multiple_inheritance_abstract");  
+//Test base classes as parameter in java 
+multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
+if(mhar.jfoo1(d1)!=3)
+   throw new RuntimeException("jfoo1()through Derived1 as parameter failed in multiple_inheritance_abstract");
+if(mhar.jfoo1(d2)!=6)
+   throw new RuntimeException("jfoo1()through Derived2 as parameter failed in multiple_inheritance_abstract");
+if(mhar.jfoo1(d3)!=7)
+   throw new RuntimeException("jfoo1()through Derived3 as parameter failed in multiple_inheritance_abstract");
+if(mhar.jfoo2(d1)!=4)
+   throw new RuntimeException("jfoo2()through Derived1 as parameter failed in multiple_inheritance_abstract");
+if(mhar.jfoo2(d3)!=8)
+   throw new RuntimeException("jfoo2()through Derived3 as parameter failed in multiple_inheritance_abstract");
+if(mhar.jbar1(d2)!=5)
+   throw new RuntimeException("jbar1()through Derived2 as parameter failed in multiple_inheritance_abstract");
+if(mhar.jbar1(d3)!=9)
+   throw new RuntimeException("jbar1()through Derived3 as parameter failed in multiple_inheritance_abstract");
+/*//Test ABase1 as a parameter
+ if(multiple_inheritance_abstract.foo6(d2)!=5)
+       throw new RuntimeException("foo6() through Derived2 as a parameter failed in multiple_inheritance_abstract");
+if(multiple_inheritance_abstract.foo6(d3)!=9)
+       throw new RuntimeException("foo6() through Derived3 as a parameter failed in multiple_inheritance_abstract");
+//Test CBase1 CBase2 as parameters
+if(multiple_inheritance_abstract.foo7(d3)!=7)
+       throw new RuntimeException("foo7() ,Derived3 as  a parameter failed in multiple_inheritance_abstract");
+if(multiple_inheritance_abstract.foo7(d1)!=3)
+       throw new RuntimeException("foo7() ,Derived1 as  a parameter failed in multiple_inheritance_abstract");
+if(multiple_inheritance_abstract.foo7(d2)!=6)
+       throw new RuntimeException("foo7() ,Derived3 as  a parameter failed in multiple_inheritance_abstract");
+if(multiple_inheritance_abstract.foo8(d3)!=4)
+       throw new RuntimeException("foo8() ,Derived3 as  a parameter failed in multiple_inheritance_abstract");
+if(multiple_inheritance_abstract.foo8(d1)!=8)
+       throw new RuntimeException("foo8() ,Derived1 as  a parameter failed in multiple_inheritance_abstract");*/
+   
+}
+}
Index: /home/jazy/workspace/SWIG/Examples/test-suite/multiple_inheritance_abstract.i
===================================================================
--- /home/jazy/workspace/SWIG/Examples/test-suite/multiple_inheritance_abstract.i	(revision 0)
+++ /home/jazy/workspace/SWIG/Examples/test-suite/multiple_inheritance_abstract.i	(revision 0)
 <at>  <at>  -0,0 +1,105  <at>  <at> 
+%module  multiple_inheritance_abstract
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+	    SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+	    SWIGWARN_PHP4_MULTIPLE_INHERITANCE) Derived1;	/* C#, Java, Php4 multiple inheritance */
+
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+	    SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+	    SWIGWARN_PHP4_MULTIPLE_INHERITANCE) Derived2;	/* C#, Java, Php4 multiple inheritance */
+%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
+	    SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+	    SWIGWARN_PHP4_MULTIPLE_INHERITANCE) Derived3;	/* C#, Java, Php4 multiple inheritance */
+%feature("interface") ABase1;
+%feature("interface") CBase1;
+%feature("interface") CBase2;
+
+
+%inline %{
+struct CBase1 {
+virtual void foo9(){
+return ;
+} 
+virtual int foo1(){
+ return 1;
+}
+int foo3(){
+return 10;
+}
+virtual ~CBase1(){
+}
+};
+struct CBase2{
+virtual int foo2(){
+return 2;
+}
+virtual ~CBase2(){
+}
+};
+struct ABase1{
+virtual int  bar1()=0;
+virtual ~ABase1(){
+}
+};
+
+struct Derived1 : CBase2,CBase1{
+  virtual int foo1(){
+return 3;
+}
+virtual void foo9(){
+return;
+}
+virtual int foo2(){
+return 4;
+}
+virtual CBase2* clone(){
+return new Derived1(*this);
+}
+};
+struct Derived2:CBase1,ABase1{
+virtual int bar1(){
+return 5;
+}
+virtual int foo1(){
+return 6;
+}
+virtual void foo9(){
+return;
+}
+virtual CBase1* clone(){
+return new Derived2(*this);
+}
+};
+struct Derived3:ABase1,CBase1,CBase2{
+virtual int foo1(){
+return 7;
+}
+virtual int foo2(){
+return 8;
+}
+virtual int bar1(){
+return 9;
+}
+virtual void foo9(){
+}
+virtual ABase1* clone(){
+return new Derived3(*this);
+}
+};
+ABase1* foo4(Derived3 d){
+return d.clone();
+}
+int foo5(CBase1 cb1,CBase2 cb2){
+return cb1.foo1()+cb2.foo2();
+}
+int foo6(ABase1* pab1){
+return  pab1->bar1();
+}
+int foo7(CBase1* pcb1){
+return pcb1->foo1();
+}
+int foo8(CBase2* pcb2){
+return pcb2->foo2();
+}
+
+%}

Property changes on: /home/jazy/workspace/SWIG/Examples/test-suite/multiple_inheritance_abstract.i
___________________________________________________________________
Name: svn:executable
   + *

Index: /home/jazy/workspace/SWIG/Lib/java/java.swg
===================================================================
--- /home/jazy/workspace/SWIG/Lib/java/java.swg	(revision 10659)
+++ /home/jazy/workspace/SWIG/Lib/java/java.swg	(working copy)
 <at>  <at>  -967,9 +967,10  <at>  <at> 
                  jdoubleArray,
                  jobjectArray
     "$javainput"
-%typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)"
-%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "$javaclassname.getCPtr($javainput)"
-
+/*%typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)"
+%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "$javaclassname.getCPtr($javainput)"*/
+%typemap(javain) SWIGTYPE "(($javainput!=null)?$javainput.getCPtr():0)"
+%typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "(($javainput!=null)?$javainput.getCPtr():0)"
 /* The javaout typemap is used for converting function return types from the return type
  * used in the JNI class to the type returned by the proxy, module or type wrapper class. */
 %typemap(javaout) bool,               const bool &,
 <at>  <at>  -1030,7 +1031,8  <at>  <at> 
 %typemap(jni) SWIGTYPE *& "jlong"
 %typemap(jtype) SWIGTYPE *& "long"
 %typemap(jstype) SWIGTYPE *& "$*javaclassname"
-%typemap(javain) SWIGTYPE *& "$*javaclassname.getCPtr($javainput)"
+/*%typemap(javain) SWIGTYPE *& "$*javaclassname.getCPtr($javainput)"*/
+%typemap(javain) SWIGTYPE *& "(($javainput!=null)?$javainput.getCPtr():0)"
 %typemap(javaout) SWIGTYPE *& {
     long cPtr = $jnicall;
     return (cPtr == 0) ? null : new $*javaclassname(cPtr, $owner);
 <at>  <at>  -1064,8 +1066,11  <at>  <at> 
     swigCPtr = cPtr;
   }

-  CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
+/*  CPTR_VISIBILITY  long getCPtr($javaclassname obj) {
     return (obj == null) ? 0 : obj.swigCPtr;
+  }*/
+  public  long getCPtr() {
+    return swigCPtr;
   }
 %}

 <at>  <at>  -1072,15 +1077,23  <at>  <at> 
 // Derived proxy classes
 %typemap(javabody_derived) TYPENAME %{
   private long swigCPtr;
-
+  protected boolean swigCMemOwn;
+  //private long swigPPtr;
   PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
-    super($imclassname.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn);
+    //super($imclassname.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn);
+    //swigPPtr=$imclassname.SWIG$javaclassnameUpcast(cPtr);
     swigCPtr = cPtr;
   }

-  CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
+  /*CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
     return (obj == null) ? 0 : obj.swigCPtr;
+  }*/
+  public  long getCPtr() {
+    return swigCPtr;
   }
+ /* public long getPPtr(){
+  return swigPPtr;
+  }*/
 %}
 %enddef

 <at>  <at>  -1101,8 +1114,11  <at>  <at> 
     swigCPtr = 0;
   }

-  protected static long getCPtr($javaclassname obj) {
+ /* protected static long getCPtr($javaclassname obj) {
     return (obj == null) ? 0 : obj.swigCPtr;
+  }*/
+  public  long getCPtr() {
+    return swigCPtr;
   }
 %}

 <at>  <at>  -1160,7 +1176,8  <at>  <at> 
       $jnicall;
     }
     swigCPtr = 0;
-    super.delete();
+    //super.delete();
+   // swigPPtr=0;
   }

 %typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{
Index: /home/jazy/workspace/SWIG/Source/CParse/parser.y
===================================================================
--- /home/jazy/workspace/SWIG/Source/CParse/parser.y	(revision 10659)
+++ /home/jazy/workspace/SWIG/Source/CParse/parser.y	(working copy)
 <at>  <at>  -3189,8 +3189,8  <at>  <at> 
 		       nscope_inner = 0;
 		     }
 		   }
-		   Setattr($$,"name",$3);
-
+		   Setattr($$,"name",$3);	  
+            /*Printf(stdout,"the cpares features are %s\n.",Getattr(Swig_cparse_features(),"feature:interface"));*/
 		   Delete(class_rename);
                    class_rename = make_name($$,$3,0);
 		   Classprefix = NewString($3);
 <at>  <at>  -3223,6 +3223,13  <at>  <at> 
 		   if (bases) {
 		     Iterator s;
 		     for (s = First(bases); s.item; s = Next(s)) {
+		     /*set the Derived class has a interface base feature*/
+	         if(GetFlag(s.item,"feature:interface")){
+	             String* interface=NewStringf("feature:interface:%s",Getattr(s.item,"name"));
+		         SetFlag($$,interface);
+		         Delete(interface);
+	         }
+	         
 		       Symtab *st = Getattr(s.item,"symtab");
 		       if (st) {
 			 Setfile(st,Getfile(s.item));
Index: /home/jazy/workspace/SWIG/Source/Modules/java.cxx
===================================================================
--- /home/jazy/workspace/SWIG/Source/Modules/java.cxx	(revision 10659)
+++ /home/jazy/workspace/SWIG/Source/Modules/java.cxx	(working copy)
 <at>  <at>  -32,7 +32,8  <at>  <at> 
   File *f_directors;
   File *f_directors_h;
   List *filenames_list;
-
+  List *interfaces_list; //list to save interfaces
+  
   bool proxy_flag;		// Flag for generating proxy classes
   bool nopgcpp_flag;		// Flag for suppressing the premature garbage collection prevention parameter
   bool native_function_flag;	// Flag for when wrapping a native function
 <at>  <at>  -70,7 +71,7  <at>  <at> 
   String *imclass_cppcasts_code;	//C++ casts up inheritance hierarchies intermediary class code
   String *imclass_directors;	// Intermediate class director code
   String *destructor_call;	//C++ destructor call if any
-
+  String *interface_code;  // C++ base class from %feature("interface")
   // Director method stuff:
   List *dmethods_seq;
   Hash *dmethods_table;
 <at>  <at>  -106,6 +107,7  <at>  <at> 
       f_directors(NULL),
       f_directors_h(NULL),
       filenames_list(NULL),
+      interfaces_list(NULL),
       proxy_flag(true),
       nopgcpp_flag(false),
       native_function_flag(false),
 <at>  <at>  -141,6 +143,7  <at>  <at> 
       imclass_cppcasts_code(NULL),
       imclass_directors(NULL),
       destructor_call(NULL),
+      interface_code(NULL),
       dmethods_seq(NULL),
       dmethods_table(NULL),
       n_dmethods(0),
 <at>  <at>  -167,7 +170,18  <at>  <at> 
     }
     return NULL;
   }
-
+   /*isInterface()
+    * Test wheather "name" is a interface in "l"
+    */
+bool isInterface(List* l,String* name){
+	Iterator i;
+	for(i=First(l);i.item;i=Next(i)){
+		if(Cmp(name,i.item)==0){		
+			return true;
+		}
+	}
+	return false;
+}
   /* -----------------------------------------------------------------------------
    * makeValidJniName()
    * ----------------------------------------------------------------------------- */
 <at>  <at>  -195,7 +209,7  <at>  <at> 

     return dirclassname;
   }
-
+  
   /* ------------------------------------------------------------
    * main()
    * ------------------------------------------------------------ */
 <at>  <at>  -327,7 +341,7  <at>  <at> 

     swig_types_hash = NewHash();
     filenames_list = NewList();
-
+    interfaces_list=NewList();
     // Make the intermediary class and module class names. The intermediary class name can be set in the module directive.
     if (!imclass_name) {
       imclass_name = NewStringf("%sJNI", Getattr(n, "name"));
 <at>  <at>  -343,6 +357,7  <at>  <at> 
     imclass_class_code = NewString("");
     proxy_class_def = NewString("");
     proxy_class_code = NewString("");
+    interface_code=NewString("");
     module_class_constants_code = NewString("");
     imclass_baseclass = NewString("");
     imclass_interfaces = NewString("");
 <at>  <at>  -596,6 +611,8  <at>  <at> 
     proxy_class_def = NULL;
     Delete(proxy_class_code);
     proxy_class_code = NULL;
+    Delete(interface_code);
+    interface_code=NULL;
     Delete(module_class_constants_code);
     module_class_constants_code = NULL;
     Delete(imclass_baseclass);
 <at>  <at>  -1552,14 +1569,18  <at>  <at> 
     String *baseclass = NULL;
     String *c_baseclassname = NULL;
     String *typemap_lookup_type = Getattr(n, "classtypeobj");
+    String *interface=NewStringf("");
     bool feature_director = Swig_directorclass(n) ? true : false;
-
+    bool isExtend=true; //wheather the keyword extend is needed
     // Inheritance from pure Java classes
     Node *attributes = NewHash();
-    const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE, attributes);
+   const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE, attributes);
     bool purebase_replace = GetFlag(attributes, "tmap:javabase:replace") ? true : false;
     Delete(attributes);
-
+    //the interface itself is the base of the classes like SWIGTYEP_XXX 
+    if(GetFlag(n,"feature:interface")){
+    	Printf(interface,"%s",Getattr(n,"name"));
+    }
     // C++ inheritance
     if (!purebase_replace) {
       List *baselist = Getattr(n, "bases");
 <at>  <at>  -1570,6 +1591,17  <at>  <at> 
         }
         if (base.item) {
           c_baseclassname = Getattr(base.item, "name");
+          
+          //we get the fist base class from here
+          String* aFeature=NewStringf("feature:interface:%s",c_baseclassname);
+          if(GetFlag(n,aFeature)){
+        	                 isExtend=false;
+                      	   Printf(interface,"%s",c_baseclassname);
+                      		if(Next(base).item&&!GetFlag(Next(base).item,"feature:ignore")){
+                      		            	Printf(interface,",");
+                      	}
+                      }
+          Delete(aFeature);
           baseclass = Copy(getProxyName(c_baseclassname));
           if (baseclass)
             c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
 <at>  <at>  -1576,10 +1608,20  <at>  <at> 
           base = Next(base);
           /* Warn about multiple inheritance for additional base class(es) */
           while (base.item) {
+        	  //add other interfaces into string "interface"
+        	  aFeature=NewStringf("feature:interface:%s",Getattr(base.item, "name"));
             if (GetFlag(base.item, "feature:ignore")) {
               base = Next(base);
               continue;
+            }else{
+            	if(GetFlag(n,aFeature)){
+            		Printf(interface,"%s",Getattr(base.item, "name"));
+            		if(Next(base).item&&!GetFlag(Next(base).item,"feature:ignore")){
+            		            	Printf(interface,",");
+            	}
             }
+            }
+            Delete(aFeature);
             String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
             String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
             Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
 <at>  <at>  -1585,6 +1627,8  <at>  <at> 
             Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
                          "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n",
proxyclassname, baseclassname);
             base = Next(base);
+            
+            
           }
         }
       }
 <at>  <at>  -1591,8 +1635,11  <at>  <at> 
     }

     bool derived = baseclass && getProxyName(c_baseclassname);
+    if(!isExtend){
+        	 baseclass=NULL;
+    	  
+        }
     const String *wanted_base = baseclass ? baseclass : pure_baseclass;
-
     if (purebase_replace) {
       wanted_base = pure_baseclass;
       derived = false;
 <at>  <at>  -1610,8 +1657,9  <at>  <at> 
     Printv(proxy_class_def, typemapLookup("javaimports", typemap_lookup_type, WARN_NONE),	//
Import statements
 	   "\n", typemapLookup("javaclassmodifiers", typemap_lookup_type,
WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF),	// Class modifiers
 	   " $javaclassname",	// Class name and bases
-	   (*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(pure_interfaces) ?	// Pure Java interfaces
-	   " implements " : "", pure_interfaces, " {", derived ? typemapLookup("javabody_derived",
typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) :	// main body of class
+	   (*Char(wanted_base)) ? " extends " : "", wanted_base,
*Char(pure_interfaces)||(Cmp(interface,"")) ?	
+	   " implements " : "",interface,*Char(pure_interfaces)?",":"", pure_interfaces, // Pure Java interfaces
+	   " {", derived ? typemapLookup("javabody_derived", typemap_lookup_type,
WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) :	// main body of class
 	   typemapLookup("javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF),	// main
body of class
 	   NIL);

 <at>  <at>  -1673,6 +1721,7  <at>  <at> 
       Delete(destruct_jnicall);
       Delete(release_jnicall);
       Delete(take_jnicall);
+      Delete(interface);
     }

     Delete(attributes);
 <at>  <at>  -1683,8 +1732,17  <at>  <at> 
 	   "\n", NIL);

     // Substitute various strings into the above template
-    Replaceall(proxy_class_code, "$javaclassname", proxy_class_name);
-    Replaceall(proxy_class_def, "$javaclassname", proxy_class_name);
+    if(GetFlag(n,"feature:interface")){
+    	String* mangleName=NewStringf("SWIGTYPE_%s",proxy_class_name);
+    	Replaceall(proxy_class_code, "$javaclassname", mangleName);
+    	Replaceall(proxy_class_def, "$javaclassname", mangleName);
+    	Delete(mangleName);
+    }else{
+    	Replaceall(proxy_class_code, "$javaclassname", proxy_class_name);
+    	Replaceall(proxy_class_def, "$javaclassname", proxy_class_name);
+    }
+    
+    

     Replaceall(proxy_class_def, "$module", module_class_name);
     Replaceall(proxy_class_code, "$module", module_class_name);
 <at>  <at>  -1740,8 +1798,15  <at>  <at> 
 	Printf(stderr, "Class name cannot be equal to module class name: %s\n", proxy_class_name);
 	SWIG_exit(EXIT_FAILURE);
       }
-
-      String *filen = NewStringf("%s%s.java", SWIG_output_directory(), proxy_class_name);
+      
+      String *filen=NULL;
+      //add the class name declared by %feauture("interface") into interfaces_list
+      if(GetFlag(n,"feature:interface")){
+    	  Append(interfaces_list,Getattr(n,"name"));
+    	  filen = NewStringf("SWIGTYPE_%s%s.java", SWIG_output_directory(), proxy_class_name);
+      }else{
+    	  filen = NewStringf("%s%s.java", SWIG_output_directory(), proxy_class_name);
+      }
       f_proxy = NewFile(filen, "w");
       if (!f_proxy) {
 	FileErrorDisplay(filen);
 <at>  <at>  -1759,7 +1824,7  <at>  <at> 

       Clear(proxy_class_def);
       Clear(proxy_class_code);
-
+      Clear(interface_code);
       destructor_call = NewString("");
       proxy_class_constants_code = NewString("");
     }
 <at>  <at>  -1812,7 +1877,22  <at>  <at> 
 	Wrapper_print(dcast_wrap, f_wrappers);
 	DelWrapper(dcast_wrap);
       }
-
+     //if the class is declared as interface in SWIG,generate a java interface
+      if(GetFlag(n,"feature:interface")){
+          	String *interfaceName=NewStringf("%s%s.java",SWIG_output_directory(),proxy_class_name);
+          	    File* f_interface= NewFile(interfaceName, "w");
+          	    emitBanner(f_interface);
+          	    if (Len(package) > 0)
+          	    	Printf(f_interface, "package %s;\n", package);
+          	    Printf(f_interface,"public interface %s%s",SWIG_output_directory(),proxy_class_name);
+          	    Printf(f_interface,"{\n");
+          	    Printv(f_interface,interface_code, NIL);
+          	    // add two common methods in java interface
+          	    Printf(f_interface,"long getCPtr();\n");
+          	    Printf(f_interface,"void delete();\n");
+          	    Printf(f_interface,"}");
+          	    Delete(interfaceName);
+          }
       emitDirectorExtraMethods(n);

       Delete(proxy_class_name);
 <at>  <at>  -1822,7 +1902,9  <at>  <at> 
       Delete(proxy_class_constants_code);
       proxy_class_constants_code = NULL;
     }
-
+   
+    
+    
     return SWIG_OK;
   }

 <at>  <at>  -1884,6 +1966,7  <at>  <at> 
   void proxyClassFunctionHandler(Node *n) {
     SwigType *t = Getattr(n, "type");
     ParmList *l = Getattr(n, "parms");
+    String*  storage=Getattr(n,"storage");
     String *intermediary_function_name = Getattr(n, "imfuncname");
     String *proxy_function_name = Getattr(n, "proxyfuncname");
     String *tm;
 <at>  <at>  -1895,7 +1978,9  <at>  <at> 
     bool setter_flag = false;
     String *pre_code = NewString("");
     String *post_code = NewString("");
-
+    
+    String *interfaceBody=NewString("");
+   
     if (!proxy_flag)
       return;

 <at>  <at>  -1924,7 +2009,8  <at>  <at> 
       // Note that in the case of polymorphic (covariant) return types, the method's return type is changed to be
the base of the C++ return type
       SwigType *covariant = Getattr(n, "covariant");
       substituteClassname(covariant ? covariant : t, tm);
-      Printf(return_type, "%s", tm);
+      
+        Printf(return_type, "%s", tm);
       if (covariant)
 	Swig_warning(WARN_JAVA_COVARIANT_RET, input_file, line_number,
 		     "Covariant return types not supported in Java. Proxy method will return %s.\n",
SwigType_str(covariant, 0));
 <at>  <at>  -1941,10 +2027,14  <at>  <at> 
     const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
     methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
     Printf(function_code, "  %s ", methodmods);
+   
     if (static_flag)
       Printf(function_code, "static ");
     Printf(function_code, "%s %s(", return_type, proxy_function_name);
-
+    // extract virtual function return type  for java interface
+    if(Cmp(storage,"virtual")==0){
+       Printf(interfaceBody, "%s %s(", return_type, proxy_function_name);
+    }
     Printv(imcall, imclass_name, ".$imfuncname(", NIL);
     if (!static_flag) {
       Printf(imcall, "swigCPtr");
 <at>  <at>  -1994,7 +2084,7  <at>  <at> 
 	/* Get the Java parameter type */
 	if ((tm = Getattr(p, "tmap:jstype"))) {
 	  substituteClassname(pt, tm);
-	  Printf(param_type, "%s", tm);
+	    Printf(param_type, "%s", tm);
 	} else {
 	  Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap
defined for %s\n", SwigType_str(pt, 0));
 	}
 <at>  <at>  -2031,10 +2121,17  <at>  <at> 
 	}

 	/* Add parameter to proxy function */
-	if (gencomma >= 2)
+	if (gencomma >= 2){
 	  Printf(function_code, ", ");
+	  if(Cmp(storage,"virtual")==0){
+	     Printf(interfaceBody, ", ");
+	  }
+	}
 	gencomma = 2;
 	Printf(function_code, "%s %s", param_type, arg);
+	// extract virtual function param type  for java interface
+	 if(Cmp(storage,"virtual")==0)
+	    Printf(interfaceBody, "%s %s", param_type, arg);

 	if (prematureGarbageCollectionPreventionParameter(pt, p)) {
           String *pgcppname = Getattr(p, "tmap:javain:pgcppname");
 <at>  <at>  -2056,7 +2153,9  <at>  <at> 

     Printf(imcall, ")");
     Printf(function_code, ")");
-
+    if(Cmp(storage,"virtual")==0){
+       Printf(interfaceBody,")");
+    }
     // Transform return type used in JNI function (in intermediary class) to type used in Java wrapper function
(in proxy class)
     if ((tm = Swig_typemap_lookup("javaout", n, "", 0))) {
       addThrows(n, "tmap:javaout", n);
 <at>  <at>  -2081,7 +2180,7  <at>  <at> 
 	Replaceall(tm, "$owner", "true");
       else
 	Replaceall(tm, "$owner", "false");
-      substituteClassname(t, tm);
+      substituteClassnameJavaout(t, tm);

       // For director methods: generate code to selectively make a normal polymorphic call or 
       // an explicit method call - needed to prevent infinite recursion calls in director methods.
 <at>  <at>  -2112,11 +2211,20  <at>  <at> 
     } else {
       Swig_warning(WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF, input_file, line_number, "No javaout typemap
defined for %s\n", SwigType_str(t, 0));
     }
-
+    
     generateThrowsClause(n, function_code);
+    
+    
     Printf(function_code, " %s\n\n", tm ? (const String *) tm : empty_string);
+    if(Cmp(storage,"virtual")==0){
+       Printf(interfaceBody,";\n");
+    }
+   
     Printv(proxy_class_code, function_code, NIL);
-
+    //add the interface body into interface_code
+    if(Cmp(storage,"virtual")==0){
+       Printv(interface_code, interfaceBody, NIL);
+    }
     Delete(pre_code);
     Delete(post_code);
     Delete(function_code);
 <at>  <at>  -2122,6 +2230,7  <at>  <at> 
     Delete(function_code);
     Delete(return_type);
     Delete(imcall);
+    Delete(interfaceBody);
   }

   /* ----------------------------------------------------------------------
 <at>  <at>  -2158,8 +2267,13  <at>  <at> 

       tm = Getattr(n, "tmap:jtype"); // typemaps were attached earlier to the node
       Printf(im_return_type, "%s", tm);
-
-      Printf(function_code, "  %s %s(", methodmods, proxy_class_name);
+      if(!isInterface(interfaces_list,proxy_class_name)){
+         Printf(function_code, "  %s %s(", methodmods, proxy_class_name);
+      }else{
+    	  //if the class is a interface in java,we also need the concrete class with another name
+    	  String* ctorName=NewStringf("SWIGTYPE_%s",proxy_class_name);
+    	  Printf(function_code, "  %s %s(", methodmods, ctorName);
+      }
       Printf(helper_code, "  static private %s SwigConstruct%s(", im_return_type, proxy_class_name);

       Printv(imcall, imclass_name, ".", mangled_overname, "(", NIL);
 <at>  <at>  -2266,9 +2380,14  <at>  <at> 
       generateThrowsClause(n, function_code);

       /* Insert the javaconstruct typemap, doing the replacement for $directorconnect, as needed */
+     
       Hash *attributes = NewHash();
-      String *construct_tm = Copy(typemapLookup("javaconstruct", Getattr(n, "name"),
-						WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF, attributes));
+     
+      
+      String * construct_tm = Copy(typemapLookup("javaconstruct", Getattr(n,"name"),
+    	 						WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF, attributes));
+    	  
+           
       if (construct_tm) {
 	if (!feature_director) {
 	  Replaceall(construct_tm, "$directorconnect", "");
 <at>  <at>  -2303,16 +2422,18  <at>  <at> 
           Printv(helper_code, "    return ", imcall, ";", NIL);
         }
         Printf(helper_code, "\n  }\n");
-        String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args);
+           String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args);
+     
         Printv(proxy_class_code, helper_code, "\n", NIL);
         Replaceall(function_code, "$imcall", helper_name);
+        
         Delete(helper_name);
       } else {
         Replaceall(function_code, "$imcall", imcall);
+        
       }

       Printv(proxy_class_code, function_code, "\n", NIL);
-
       Delete(helper_args);
       Delete(im_return_type);
       Delete(pre_code);
 <at>  <at>  -2433,7 +2554,7  <at>  <at> 
     /* Get return types */
     if ((tm = Swig_typemap_lookup("jstype", n, "", 0))) {
       substituteClassname(t, tm);
-      Printf(return_type, "%s", tm);
+        Printf(return_type, "%s", tm);
     } else {
       Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap defined
for %s\n", SwigType_str(t, 0));
     }
 <at>  <at>  -2480,7 +2601,7  <at>  <at> 
       /* Get the Java parameter type */
       if ((tm = Getattr(p, "tmap:jstype"))) {
 	substituteClassname(pt, tm);
-	Printf(param_type, "%s", tm);
+	  Printf(param_type, "%s", tm);
       } else {
 	Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap
defined for %s\n", SwigType_str(pt, 0));
       }
 <at>  <at>  -2566,7 +2687,7  <at>  <at> 
 	Replaceall(tm, "$owner", "true");
       else
 	Replaceall(tm, "$owner", "false");
-      substituteClassname(t, tm);
+      substituteClassnameJavaout(t, tm);
       Replaceall(tm, "$jnicall", imcall);
     } else {
       Swig_warning(WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF, input_file, line_number, "No javaout typemap
defined for %s\n", SwigType_str(t, 0));
 <at>  <at>  -2727,6 +2848,42  <at>  <at> 
     return substitution_performed;
   }

+  /*
+   * substituteClassnameJavaout()
+   * almost same as substituteClassname(),it is used replace the $javaclassname in javaout
+   * when the SwigType is declared as interface through %feature("interface")
+   */
+  bool substituteClassnameJavaout(SwigType *pt, String *tm, bool jnidescriptor = false) {
+      bool substitution_performed = false;
+      SwigType *type = Copy(SwigType_typedef_resolve_all(pt));
+      SwigType *strippedtype = SwigType_strip_qualifiers(type);
+
+      if (Strstr(tm, "$javaclassname")) {
+        SwigType *classnametype = Copy(strippedtype);
+        substituteClassnameSpecialVariableJavaout(classnametype, tm, "$javaclassname", jnidescriptor);
+        substitution_performed = true;
+        Delete(classnametype);
+      }
+      if (Strstr(tm, "$*javaclassname")) {
+        SwigType *classnametype = Copy(strippedtype);
+        Delete(SwigType_pop(classnametype));
+        substituteClassnameSpecialVariableJavaout(classnametype, tm, "$*javaclassname", jnidescriptor);
+        substitution_performed = true;
+        Delete(classnametype);
+      }
+      if (Strstr(tm, "$&javaclassname")) {
+        SwigType *classnametype = Copy(strippedtype);
+        SwigType_add_pointer(classnametype);
+        substituteClassnameSpecialVariableJavaout(classnametype, tm, "$&javaclassname", jnidescriptor);
+        substitution_performed = true;
+        Delete(classnametype);
+      }
+
+      Delete(strippedtype);
+      Delete(type);
+
+      return substitution_performed;
+    }
   /* -----------------------------------------------------------------------------
    * substituteClassnameSpecialVariable()
    * ----------------------------------------------------------------------------- */
 <at>  <at>  -2740,8 +2897,12  <at>  <at> 
 	Replaceall(tm, classnamespecialvariable, NewStringf("int"));
     } else {
       String *classname = getProxyName(classnametype);
+     
       if (classname) {
-	Replaceall(tm, classnamespecialvariable, classname);	// getProxyName() works for pointers to
classes too
+    	  
+	          Replaceall(tm, classnamespecialvariable, classname);	// getProxyName() works for pointers to
classes too
+	          
+    	 
       } else {			// use $descriptor if SWIG does not know anything about this type. Note that any typedefs are resolved.
 	String *descriptor = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype));
 	Replaceall(tm, classnamespecialvariable, descriptor);
 <at>  <at>  -2752,7 +2913,39  <at>  <at> 
       }
     }
   }
+/*
+ * substituteClassnameSpecialVariableJavaout
+ */
+  void substituteClassnameSpecialVariableJavaout(SwigType *classnametype, String *tm, const char
*classnamespecialvariable, bool jnidescriptor) {
+      if (SwigType_isenum(classnametype)) {
+        String *enumname = getEnumName(classnametype, jnidescriptor);
+        if (enumname)
+  	Replaceall(tm, classnamespecialvariable, enumname);
+        else
+  	Replaceall(tm, classnamespecialvariable, NewStringf("int"));
+      } else {
+        String *classname = getProxyName(classnametype);
+       
+        if (classname) {
+      	  
+        	 if(!isInterface(interfaces_list,classname)){
+        		          Replaceall(tm, classnamespecialvariable, classname);	// getProxyName() works for pointers to
classes too
+        		          
+        	    	  }else{
+        	    		  classname=NewStringf("SWIGTYPE_%s",classname);
+        	    		  Replaceall(tm, classnamespecialvariable, classname);
+        	    	  }
+      	
+        } else {			// use $descriptor if SWIG does not know anything about this type. Note that any typedefs are resolved.
+  	String *descriptor = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype));
+  	Replaceall(tm, classnamespecialvariable, descriptor);

+  	// Add to hash table so that the type wrapper classes can be created later
+  	Setattr(swig_types_hash, descriptor, classnametype);
+  	Delete(descriptor);
+        }
+      }
+    }
   /* -----------------------------------------------------------------------------
    * makeParameterName()
    *
Attachment (multiple_inheritance_abstract.i): application/octet-stream, 1805 bytes
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Haoyu Bai | 11 Aug 2008 17:22
Picon

Python 1.x and -apply support

Hi,

I just found my implementation of the Python backend accidentally
dropped the '-apply' feature. Should we continue to support the
-apply?

As I know, the apply() is only useful in Python 1.x, since 2.0
introduced the extended call syntax, eg. the foo(*arg, **kw) calling
style. However, Python 1.x is so old, could we drop it?

Thanks.

--

-- 
Haoyu Bai

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

Gmane