Merge branch 'interfaces'

* interfaces:
  Documentation and CHANGES entry for interface feature
  interface macro argument name tweaks
  Change the name of the interface in %feature to be more portable
  Interface feature fix for typedef types
  Add limited support for %interface_impl and %shared_ptr
  Multiple inheritance warning wording tweak
  C# "override" fix for "extend" case
  Add checks for interface name symbol clashes
  interface feature test changes for the tests to pass for all languages
  Rename feature_interface.i to swiginterface.i
  Re-organization of the interface feature common code
  Port Java interface tests to C#
  Test %interface
  Test %interface_impl
  Use rstrip instead of regex encoder in %feature_rename
  Add rstrip encoder for use in %rename.
  Interface macros: %interface %interface_impl %interface_custom
  Add $interfacename family of special variable expansions
  Add multiple_inheritance_nspace testcase
  Interface name handling improvements and special variable changes
  Correct regex example comment
  Properly hide unexposed naming functions in naming.c
  C++ namespace testing for interface feature
  interface feature - SWIG_JAVABODY_PROXY does not need to be overridden
  Support namespaces and nspace with the interface feature for C#
  Support namespaces and nspace with the interface feature for Java
  Cosmetic test case changes
  Add Java premature garbage collection prevention parameter (pgcpp) to interface feature
  Create javainterfacecode and csinterfacecode typemaps
  IntPtr & HandleRef absolute names used
  virtual/override fix
  Improve interface feature checks
  Add another interface test selecting just one base as an interface
  Comments added to interface feature implementation and cosmetic code changes
  Add overloading tests for interface feature
  Refactor multiple inheritance warnings
  director generation fixes
  interface feature updates for C# latest on master
  interfaces branch merge fixes
  Remove unnecessary interfaces for concrete classes
  cosmetic code formatting changes
  Correct interface name attributes that are internal
  interface macro changes to support templates
  Test non-virtual method in Derived classes
  interface tests for a most derived class inheriting the interfaces further up the chain
  Rename GetCPtr/getCPtr to SWIGInterfaceUpcast
  interface feature support for const ref pointers (used by the STL)
  Interface feature support for arrays
  More interface feature testing for return values
  interface feature support for passing by value
  interface feature support for references
  Multiple inheritance parameters as pointers testing
  Simplify multiple_inheritance_abstract Java runtime test
  Warning fixes
  Rename test functions in multiple_inheritance_abstract testcase
  Formatting fixes in generated code for interface feature
  Cosmetic spacing changes in test case
  interface feature typemap corrections to handle NULL pointers
  interface test added
  javadirectorin fix
  interface implementation visibility
  interface inheritance (2)
  interface inheritance (1)
  feature:interface ported to Java
  propagate non-abstract "interface" base methods (3)
  propagate non-abstract "interface" base methods (2)
  propagate non-abstract "interface" base methods (1)
  namespace support added GetCPtr now returns HandleRef "feature:interface:name" is now mandatory attribute
  interfaces (1)
  interfaces (1)

Conflicts:
	CHANGES.current
This commit is contained in:
William S Fulton 2016-03-11 20:01:41 +00:00
commit 0f0345c214
39 changed files with 4624 additions and 255 deletions

View file

@ -5,6 +5,26 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 3.0.9 (in progress)
===========================
2016-03-11: wsfulton
[Java C#] Add support for treating C++ base classes as Java interfaces
instead of Java proxy classes. This enable some sort of support for
multiple inheritance. The implementation is in swiginterface.i and
provides additional macros (see Java.html for full documentation):
%interface(CTYPE)
%interface_impl(CTYPE)
%interface_custom("PROXY", "INTERFACE", CTYPE)
2016-03-01: wsfulton
Add rstrip encoder for use in %rename. This is like the strip encoder but
strips the symbol's suffix instead of the prefix. The example below
will rename SomeThingCls to SomeThing and AnotherThingCls to AnotherThing:
%rename("%(rstrip:[Cls])s") "";
class SomeThingCls {};
struct AnotherThingCls {};
2016-03-01: olly
[Python] Fix isfinite() check to work with GCC6. Fixes
https://github.com/swig/swig/issues/615 reported by jplesnik.

View file

@ -233,6 +233,7 @@ javabody -> csbody
javafinalize -> csfinalize
javadestruct -> csdestruct
javadestruct_derived -> csdestruct_derived
javainterfacecode -> csinterfacecode
</pre></div>
</li>
@ -300,6 +301,9 @@ $*javaclassname -&gt; $*csclassname
$javaclazzname -&gt; $csclazzname
$javainput -&gt; $csinput
$jnicall -&gt; $imcall
$javainterfacename -&gt; $csinterfacename
$&amp;javainterfacename -&gt; $&amp;csinterfacename
$*javainterfacename -&gt; $*csinterfacename
</pre></div>
</li>

View file

@ -997,6 +997,7 @@
<li><a href="Java.html#Java_proper_enums_classes">Proper Java enum classes</a>
<li><a href="Java.html#Java_typeunsafe_enums_classes">Type unsafe enum classes</a>
</ul>
<li><a href="Java.html#Java_interfaces">Interfaces</a>
</ul>
<li><a href="Java.html#Java_directors">Cross language polymorphism using directors</a>
<ul>

View file

@ -83,6 +83,7 @@
<li><a href="#Java_proper_enums_classes">Proper Java enum classes</a>
<li><a href="#Java_typeunsafe_enums_classes">Type unsafe enum classes</a>
</ul>
<li><a href="#Java_interfaces">Interfaces</a>
</ul>
<li><a href="#Java_directors">Cross language polymorphism using directors</a>
<ul>
@ -3331,6 +3332,251 @@ public final class Beverage {
</pre>
</div>
<H3><a name="Java_interfaces">25.4.6 Interfaces</a></H3>
<p>
By default SWIG wraps all C++ classes as Java classes.
As Java only supports derivation from a single base class, SWIG has to ignore all
bases except the first when a C++ class inherits from more than one base class.
However, there is a family of SWIG macros that change the default wrapping and allows a C++ class
to be wrapped as a Java interface instead of a Java class.
These macros provide a way to support some sort of multiple inheritance as there is no limit to
the number of interfaces that a Java class can inherit from.
</p>
<p>
When a C++ class is wrapped as a Java interface, a Java proxy class is still needed.
The <tt>swiginterface.i</tt> library file provides three macros for marking a C++ class to be
wrapped as a Java interface.
There is more than one macro in order to provide a choice for choosing the Java interface and Java proxy names.
</p>
<table BORDER summary="Java interface macros">
<tr VALIGN=TOP>
<td><b>Interface Macro Name</b></td>
<td><b>Description</b></td>
</tr>
<tr>
<td><tt>%interface(CTYPE)</tt></td>
<td>Proxy class name is unchanged, interface name has <tt>SwigInterface</tt> added as a suffix for C++ class <tt>CTYPE</tt>.</td>
</tr>
<tr>
<td><tt>%interface_impl(CTYPE)</tt></td>
<td>Proxy class name has <tt>SwigImpl</tt> as a suffix, interface name has <tt>SwigInterface</tt> added as a suffix for C++ class <tt>CTYPE</tt>.</td>
</tr>
<tr>
<td><tt>%interface_custom("PROXY", "INTERFACE", CTYPE)</tt></td>
<td>Proxy class name is given by the string <tt>PROXY</tt>, interface name is given by the string <tt>INTERFACE</tt> for C++ class <tt>CTYPE</tt>. The <tt>PROXY</tt> and <tt>INTERFACE</tt> names can use the <a href="SWIG.html#SWIG_advanced_renaming">string formatting functions</a> used in <tt>%rename</tt>.</td>
</tr>
</table>
<p>
The table below has a few examples showing the resulting proxy and interface names.
</p>
<table BORDER summary="Java interface macro examples">
<tr VALIGN=TOP>
<td><b>Example Usage</b></td>
<td><b>Proxy Class Name</b></td>
<td><b>Interface Class Name</b></td>
</tr>
<tr>
<td><tt>%interface(Base)</tt></td>
<td><tt>Base</tt></td>
<td><tt>BaseSwigInterface</tt></td>
</tr>
<tr>
<td><tt>%interface_impl(Base)</tt></td>
<td><tt>BaseSwigImpl</tt></td>
<td><tt>Base</tt></td>
</tr>
<tr>
<td><tt>%interface_custom("BaseProxy", "IBase", Base)</tt></td>
<td><tt>BaseProxy</tt></td>
<td><tt>IBase</tt></td>
</tr>
<tr>
<td><tt>%interface_custom("%sProxy", "IBase", Base)</tt></td>
<td><tt>BaseProxy</tt></td>
<td><tt>IBase</tt></td>
</tr>
<tr>
<td><tt>%interface_custom("%sProxy", "%sInterface", Base)</tt></td>
<td><tt>BaseProxy</tt></td>
<td><tt>BaseProxyInterface</tt></td>
</tr>
<tr>
<td><tt>%interface_custom("%sProxy", "%(rstrip:[Proxy])sInterface", Base)</tt></td>
<td><tt>BaseProxy</tt></td>
<td><tt>BaseInterface</tt></td>
</tr>
</table>
<p>
The 2nd last example shows the names used in the string formatting functions.
The input for <tt>PROXY</tt> that <tt>"%s"</tt> expands to is the proxy name, that is, Base.
The input for <tt>INTERFACE</tt> that <tt>"%s"</tt> expands to is the proxy name, that is, <tt>BaseProxy</tt>.
</p>
<p>
The last example shows <tt>rstrip</tt> and in this case strips the <tt>Proxy</tt> suffix and then adds on <tt>Interface</tt>.
</p>
<p>
Consider the following C++ code:
</p>
<div class="code">
<pre>
namespace Space {
struct Base1 {
virtual void Method1();
};
struct Base2 {
virtual void Method2();
};
struct Derived : Base1, Base2 {
};
void UseBases(const Base1 &amp;b1, const Base2 &amp;b2);
}
</pre>
</div>
<p>
By default all classes are wrapped and are available in Java, but, <tt>Derived</tt>
has all bases ignored except the first.
SWIG generates a warning for the above code:
</p>
<div class="shell">
<pre>
example.i:10: Warning 813: Warning for Derived, base Base2 ignored.
Multiple inheritance is not supported in Java.
</pre>
</div>
<p>
If we decide to wrap the two base classes as interfaces and add the following before SWIG parses the above example code:
</p>
<div class="code">
<pre>
%include &lt;swiginterface.i&gt;
%interface_impl(Space::Base1);
%interface_impl(Space::Base2);
</pre>
</div>
<p>
then two interface files are generated, Base1.java and Base2.java in addition to proxy class files, Base1SwigImpl.java and Base2SwigImpl.java.
The contents of interface file Base1.java for <tt>Base1</tt> is shown below:
</p>
<div class="code">
<pre>
public interface Base1 {
long Base1_GetInterfaceCPtr();
void Method1();
}
</pre>
</div>
<p>
The proxy class in Base1SwigImpl.java for Base1 is as it would have been if <tt>%interface</tt> was not used,
except the name has changed to <tt>Base1SwigImpl</tt> and it implements the appropriate base:
</p>
<div class="code">
<pre>
public class Base1SwigImpl implements Base1 {
...
public long Base1_GetInterfaceCPtr() {
return exampleJNI.Base1SwigImpl_Base1_GetInterfaceCPtr(swigCPtr);
}
public void Method1() {
exampleJNI.Base1SwigImpl_Method1(swigCPtr, this);
}
...
}
</pre>
</div>
<p>
In fact any class deriving from <tt>Base</tt> will now implement the interface instead of
deriving from it (or ignoring the base in the case of multiple base classes).
Hence the <tt>Derived</tt> proxy class will now implement both bases:
</p>
<div class="code">
<pre>
public class Derived implements Base1, Base2 {
...
public long Base1_GetInterfaceCPtr() {
return exampleJNI.Derived_Base1_GetInterfaceCPtr(swigCPtr);
}
public long Base2_GetInterfaceCPtr() {
return exampleJNI.Derived_Base2_GetInterfaceCPtr(swigCPtr);
}
public void Method1() {
exampleJNI.Derived_Method1(swigCPtr, this);
}
public void Method2() {
exampleJNI.Derived_Method2(swigCPtr, this);
}
...
}
</pre>
</div>
<p>
Wherever a class marked as an interface is used, such as the <tt>UseBases</tt> method in the example,
the interface name is used as the type in the Java layer:
</p>
<div class="code">
<pre>
public static void UseBases(Base1 b1, Base2 b2) {
exampleJNI.UseBases(b1.Base1_GetInterfaceCPtr(), b1, b2.Base2_GetInterfaceCPtr(), b2);
}
</pre>
</div>
<p>
Note that each Java interface has a method added to obtain the correct C++ pointer for passing to the native function -
<tt>Base1_GetInterfaceCPtr</tt> for <tt>Base1</tt>.
This method is similar to the <tt>getCPtr</tt> method in the proxy classes.
In fact, as shown above in the <tt>Derived</tt> class, the proxy classes implement
this generated interface by calling a native method (<tt>Derived_Base1_GetInterfaceCPtr</tt>)
which calls an appropriate C++ cast of the pointer up the inheritance chain.
</p>
<p>
The interface macros are implemented using the <tt>interface</tt> feature and typemaps.
For example:
</p>
<div class="code">
<pre>
%define %interface(CTYPE...)
%feature("interface", name="%sSwigInterface") CTYPE;
INTERFACE_TYPEMAPS(CTYPE)
%enddef
</pre>
</div>
<p>
The feature accepts one attribute called <tt>name</tt>, which is the name of the Java interface mentioned earlier.
The <tt>INTERFACE_TYPEMAPS</tt> macro implements the typemaps and can be viewed in the
<tt>swiginterface.i</tt> file and contain
the usual Java typemaps for generating code plus the <tt>javainterfacecode</tt>
typemap which is only used when a class is marked with the <tt>interface</tt> feature.
See <a href="Java.html#Java_code_typemaps">Java code typemaps</a> for details.
</p>
<H2><a name="Java_directors">25.5 Cross language polymorphism using directors</a></H2>
@ -5585,6 +5831,8 @@ For example, <tt>$javaclassname</tt> is replaced by the proxy classname <tt>Foo<
expands to the proxy classname when wrapping <tt>Foo *&amp;</tt>.
If the type does not have an associated proxy class, it expands to the type wrapper class name, for example,
<tt>SWIGTYPE_p_unsigned_short</tt> is generated when wrapping <tt>unsigned short *</tt>.
The class name is fully qualified with the package name when using the
<a href="SWIGPlus.html#SWIGPlus_nspace">nspace feature</a>.
</p>
<p>
@ -5715,6 +5963,35 @@ This special variable expands to the intermediary class name. Usually this is th
unless the jniclassname attribute is specified in the <a href="Java.html#Java_module_directive">%module directive</a>.
</p>
<p>
<b><tt>$javainterfacename</tt></b><br>
This special variable is only expanded when the <tt>interface</tt> feature is applied to a class.
It works much like <tt>$javaclassname</tt>, but instead of expanding to the proxy classname,
it expands to the value in the <tt>name</tt> attribute in the <tt>interface</tt> feature.
For example:
</p>
<div class="code"><pre>
%feature("interface", name="MyInterface") MyClass;
%typemap(jstype) MyClass "$&amp;javainterfacename"
%typemap(jstype) MyClass * "$javainterfacename"
</pre></div>
<p>
will result in the <tt>jstype</tt> typemap expanding to <tt>MyInterface</tt> for both
<tt>MyClass</tt> and <tt>MyClass *</tt>.
The interface name is fully qualified with the package name when using the
<a href="SWIGPlus.html#SWIGPlus_nspace">nspace feature</a>.
</p>
<p>
<b><tt>$interfacename</tt></b><br>
This special variable is only expanded when the <tt>interface</tt> feature is applied to a class.
It expands to just the interface name and is thus different to <tt>$javainterfacename</tt>
in that it is not fully qualified with the package name when using the
<a href="SWIGPlus.html#SWIGPlus_nspace">nspace feature</a>.
</p>
<H3><a name="Java_typemaps_for_c_and_cpp">25.9.8 Typemaps for both C and C++ compilation</a></H3>
@ -5848,9 +6125,39 @@ Below shows an example modifying the finalizer, assuming the <tt>delete</tt> met
</div>
<p><tt>%typemap(javainterfacecode, declaration="...", cptrmethod="...")</tt></p>
<div class="indent">
<p>
The code in this typemap is added to the body of a Java proxy class but only when a class is
marked with the <tt>interface</tt> feature.
The typemap is used in the proxy class marked with the interface feature as well as all proxy classes derived from the marked C++ class,
as they are all generated as implementing the Java interface.
The default typemap used in the <tt>%interface</tt> family of macros mentioned in
the <a href="Java.html#Java_interfaces">Java interfaces</a> section,
where <tt>CTYPE</tt> is the C++ class macro argument,
is as follows:
</p>
<div class="code"><pre>
%typemap(javainterfacecode,
declaration=" long $interfacename_GetInterfaceCPtr();\n",
cptrmethod="$interfacename_GetInterfaceCPtr") CTYPE %{
public long $interfacename_GetInterfaceCPtr() {
return $imclassname.$javaclazzname$interfacename_GetInterfaceCPtr(swigCPtr);
}
%}
</pre></div>
</div>
<p>
The special variable <tt>$interfacename</tt> is expanded into the
name specified in the <tt>interface</tt> feature.
</p>
<p>
<b>Compatibility Note:</b> In SWIG-1.3.21 and earlier releases, typemaps called "javagetcptr" and "javaptrconstructormodifiers" were available.
These are deprecated and the "javabody" typemap can be used instead.
The <tt>javainterfacecode</tt> typemap and interface feature was introduced in SWIG-3.0.9.
</p>
<p>
@ -5866,6 +6173,7 @@ In summary the contents of the typemaps make up a proxy class like this:
[ javafinalize typemap ]
public synchronized void <i>delete</i>() [ javadestruct OR javadestruct_derived typemap ]
[ javacode typemap ]
[ javainterfacecode typemap]
... proxy functions ...
}
</pre>
@ -5875,6 +6183,11 @@ public synchronized void <i>delete</i>() [ javadestruct OR javadestruct_derived
Note the <tt><i>delete</i>()</tt> methodname and method modifiers are configurable, see "javadestruct" and "javadestruct_derived" typemaps above.
</p>
<p>
The <tt>javainterfacecode</tt> typemap is only used when bases are marked by the <tt>interface</tt>
feature and the <tt>implements</tt> list will also then be expanded to include these Java interfaces.
</p>
<p>
The type wrapper class is similar in construction:
</p>
@ -5907,8 +6220,23 @@ The type wrapper class is similar in construction:
The "javaimports" typemap is ignored if the enum class is wrapped by an inner Java class, that is when wrapping an enum declared within a C++ class.
</p>
<p>The Java interface turned on by the <tt>interface</tt> feature is fairly simple:</p>
<div class="code">
<pre>
[ javaimports typemap ]
public interface [ javainterfacename ] {
[ javainterfacecode:cptrmethod typemap attribute ]
... interface declarations ...
}
</pre>
</div>
<p>
The defaults can be overridden to tailor these classes.
where <tt>javainterfacename</tt> is the <tt>name</tt> attribute in the <a href="Java.html#Java_interfaces">interface feature</a>.
</p>
<p>
The defaults can be overridden to tailor the generated classes.
Here is an example which will change the <tt>getCPtr</tt> method and constructor from the default public access to protected access.
If the classes in one package are not using the classes in another package, then these methods need not be public and removing access to these low level implementation details, is a good thing.
If you are invoking SWIG more than once and generating the wrapped classes into different packages in each invocation, then you cannot do this as you will then have different packages.

View file

@ -1888,6 +1888,13 @@ and a more descriptive one, but the two functions are otherwise equivalent:
literally, e.g. <tt>%rename("strip:[wx]")</tt></td>
<td><tt>wxPrint</tt></td><td><tt>Print</tt></td>
</tr>
<tr>
<td><tt>rstrip:[suffix]</tt></td>
<td>String without the given suffix or the original string if it doesn't
end with this suffix. Note that square brackets should be used
literally, e.g. <tt>%rename("rstrip:[Cls]")</tt></td>
<td><tt>PrintCls</tt></td><td><tt>Print</tt></td>
</tr>
<tr>
<td><span style="white-space: nowrap;"><tt>regex:/pattern/subst/</tt></span></td>
<td>String after (Perl-like) regex substitution operation. This function

View file

@ -546,7 +546,7 @@ example.i(4) : Syntax error in input(1).
<li>810. No jni typemap defined for <em>type</em> (Java).
<li>811. No jtype typemap defined for <em>type</em> (Java).
<li>812. No jstype typemap defined for <em>type</em> (Java).
<li>813. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in Java. (Java).
<li>813. Warning for <em>classname</em>, base <em>baseclass</em> ignored. Multiple inheritance is not supported in Java. (Java).
<li>814.
<li>815. No javafinalize typemap defined for <em>type</em> (Java).
<li>816. No javabody typemap defined for <em>type</em> (Java).
@ -566,7 +566,7 @@ example.i(4) : Syntax error in input(1).
<li>830. No ctype typemap defined for <em>type</em> (C#).
<li>831. No cstype typemap defined for <em>type</em> (C#).
<li>832. No cswtype typemap defined for <em>type</em> (C#).
<li>833. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in C#. (C#).
<li>833. Warning for <em>classname</em>, base <em>baseclass</em> ignored. Multiple inheritance is not supported in C#. (C#).
<li>834.
<li>835. No csfinalize typemap defined for <em>type</em> (C#).
<li>836. No csbody typemap defined for <em>type</em> (C#).
@ -582,7 +582,7 @@ example.i(4) : Syntax error in input(1).
</ul>
<ul>
<li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in PHP.
<li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in PHP. (Php).
<li>871. Unrecognized pragma <em>pragma</em>. (Php).
</ul>

View file

@ -282,6 +282,10 @@ CPP_TEST_CASES += \
minherit2 \
mixed_types \
multiple_inheritance \
multiple_inheritance_abstract \
multiple_inheritance_interfaces \
multiple_inheritance_nspace \
multiple_inheritance_shared_ptr \
name_cxx \
name_warnings \
namespace_class \
@ -341,6 +345,7 @@ CPP_TEST_CASES += \
rename2 \
rename3 \
rename4 \
rename_rstrip_encoder \
rename_scope \
rename_simple \
rename_strip_encoder \

View file

@ -0,0 +1,245 @@
using System;
using multiple_inheritance_abstractNamespace;
public class multiple_inheritance_abstract_runme {
//Test base class as a parameter in C#
int jcbase1b(CBase1 cb1){
return cb1.cbase1y();
}
int jabase1(ABase1 ab1){
return ab1.abase1();
}
int jcbase2(CBase2 cb2){
return cb2.cbase2();
}
public static void check(bool fail, string msg) {
if (fail)
throw new Exception(msg);
}
public static void Main() {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1 cb1=new CBase1SwigImpl();
CBase2 cb2=new CBase2SwigImpl();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test abstract class as return value
ABase1 ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1 cb6=d2.cloneit();
CBase2 cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1 cb3=new Derived1();
CBase1 cb4=new Derived3();
CBase2 cb5=new Derived3();
ABase1 ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in C#
multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_abstract.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_abstract.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_abstract.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_abstract.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_abstract.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_abstract.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_abstract.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_abstract.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_abstract.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_abstract.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_abstract.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_abstract.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_abstract.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_abstract.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_abstract.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_abstract.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_abstract.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_abstract.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_abstract.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_abstract.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_abstract.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_abstract.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_abstract.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_abstract.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_abstract.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_abstract.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_abstract.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_abstract.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_abstract.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_abstract.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_abstract.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using multiple_inheritance_interfacesNamespace;
public class multiple_inheritance_interfaces_runme {
static string SortArrayToString(string[] types) {
Array.Sort<string>(types);
return string.Join(" ", types);
}
static string SortArrayToString(Type[] types) {
List<string> stypes = new List<string>();
foreach (Type t in types)
stypes.Add(t.Name);
return SortArrayToString(stypes.ToArray());
}
private static void checkBaseAndInterfaces(Type cls, bool interfaceExpected, string baseClass, string[] interfaces) {
string[] expectedInterfaces = new string[interfaces.Length + (interfaceExpected ? 0 : 1)];
for (int i=0; i<interfaces.Length; ++i)
expectedInterfaces[i] = interfaces[i];
if (!interfaceExpected)
expectedInterfaces[interfaces.Length] = "IDisposable";
Type[] actualInterfaces = cls.GetInterfaces();
string expectedInterfacesString = SortArrayToString(expectedInterfaces);
string actualInterfacesString = SortArrayToString(actualInterfaces);
if (expectedInterfacesString != actualInterfacesString)
throw new Exception("Expected interfaces for " + cls.Name + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
string expectedBaseString = null;
if (interfaceExpected) {
// expecting an interface
if (!cls.IsInterface)
throw new Exception(cls.Name + " should be an interface but is not");
expectedBaseString = string.IsNullOrEmpty(baseClass) ? "" : "multiple_inheritance_interfacesNamespace." + baseClass;
} else {
// expecting a class
if (cls.IsInterface)
throw new Exception(cls.Name + " is an interface but it should not be");
expectedBaseString = string.IsNullOrEmpty(baseClass) ? "Object" : baseClass;
}
string actualBaseString = cls.BaseType == null ? "" : cls.BaseType.Name;
if (expectedBaseString != actualBaseString)
throw new Exception("Expected base for " + cls.Name + ": [" + expectedBaseString + "]" + " Actual base: [" + actualBaseString + "]");
}
public static void Main() {
// Note that we can't get just the immediate interface
// Type.GetInterfaces() returns all interfaces up the inheritance hierarchy
checkBaseAndInterfaces(typeof(IA), true, "", new string[] {});
checkBaseAndInterfaces(typeof(IB), true, "", new string[] {});
checkBaseAndInterfaces(typeof(IC), true, "", new string[] {"IA", "IB"});
checkBaseAndInterfaces(typeof(A), false, "", new string[] {"IA"});
checkBaseAndInterfaces(typeof(B), false, "", new string[] {"IB"});
checkBaseAndInterfaces(typeof(C), false, "", new string[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(typeof(D), false, "", new string[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(typeof(E), false, "D", new string[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(typeof(IJ), true, "", new string[] {});
checkBaseAndInterfaces(typeof(IK), true, "", new string[] {"IJ"});
checkBaseAndInterfaces(typeof(IL), true, "", new string[] {"IJ", "IK"});
checkBaseAndInterfaces(typeof(J), false, "", new string[] {"IJ"});
checkBaseAndInterfaces(typeof(K), false, "", new string[] {"IJ", "IK"});
checkBaseAndInterfaces(typeof(L), false, "", new string[] {"IJ", "IK", "IL"});
checkBaseAndInterfaces(typeof(M), false, "", new string[] {"IJ", "IK", "IL"});
checkBaseAndInterfaces(typeof(P), false, "", new string[] {});
checkBaseAndInterfaces(typeof(IQ), true, "", new string[] {});
checkBaseAndInterfaces(typeof(Q), false, "", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(R), false, "P", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(S), false, "P", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(T), false, "", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(U), false, "R", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(V), false, "S", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(W), false, "T", new string[] {"IQ"});
// overloaded methods check
D d = new D();
d.ia();
d.ia(10);
d.ia("bye");
d.ia("bye", false);
}
}

View file

@ -0,0 +1,246 @@
using System;
using multiple_inheritance_nspaceNamespace;
using multiple_inheritance_nspaceNamespace.Space;
public class multiple_inheritance_nspace_runme {
//Test base class as a parameter in C#
int jcbase1b(CBase1SwigInterface cb1){
return cb1.cbase1y();
}
int jabase1(ABase1SwigInterface ab1){
return ab1.abase1();
}
int jcbase2(CBase2SwigInterface cb2){
return cb2.cbase2();
}
public static void check(bool fail, string msg) {
if (fail)
throw new Exception(msg);
}
public static void Main() {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1SwigInterface cb1=new CBase1();
CBase2SwigInterface cb2=new CBase2();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test nspace class as return value
ABase1SwigInterface ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1SwigInterface cb6=d2.cloneit();
CBase2SwigInterface cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1SwigInterface cb3=new Derived1();
CBase1SwigInterface cb4=new Derived3();
CBase2SwigInterface cb5=new Derived3();
ABase1SwigInterface ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in C#
multiple_inheritance_nspace_runme mhar=new multiple_inheritance_nspace_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_nspace.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_nspace.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_nspace.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_nspace.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_nspace.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_nspace.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_nspace.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_nspace.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_nspace.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_nspace.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_nspace.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_nspace.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_nspace.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_nspace.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_nspace.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_nspace.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_nspace.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_nspace.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_nspace.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_nspace.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_nspace.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_nspace.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_nspace.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_nspace.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_nspace.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_nspace.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_nspace.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_nspace.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_nspace.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_nspace.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_nspace.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,329 @@
using System;
using multiple_inheritance_shared_ptrNamespace;
public class multiple_inheritance_shared_ptr_runme {
//Test base class as a parameter in C#
int jcbase1b(CBase1 cb1){
return cb1.cbase1y();
}
int jabase1(ABase1 ab1){
return ab1.abase1();
}
int jcbase2(CBase2 cb2){
return cb2.cbase2();
}
public static void check(bool fail, string msg) {
if (fail)
throw new Exception(msg);
}
public static void Main() {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1 cb1=new CBase1SwigImpl();
CBase2 cb2=new CBase2SwigImpl();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test abstract class as return value
ABase1 ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1 cb6=d2.cloneit();
CBase2 cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1 cb3=new Derived1();
CBase1 cb4=new Derived3();
CBase2 cb5=new Derived3();
ABase1 ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in C#
multiple_inheritance_shared_ptr_runme mhar=new multiple_inheritance_shared_ptr_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_shared_ptr.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Shared pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d2)!=5, "InputSharedPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d3)!=9, "InputSharedPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b2)!=205, "InputSharedPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b3)!=309, "InputSharedPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d1)!=3, "InputSharedPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d2)!=6, "InputSharedPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d3)!=7, "InputSharedPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d3)!=8, "InputSharedPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d1)!=4, "InputSharedPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(cb1)!=1, "InputSharedPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(cb2)!=2, "InputSharedPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b1)!=103, "InputSharedPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b2)!=206, "InputSharedPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b3)!=307, "InputSharedPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b3)!=308, "InputSharedPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b1)!=104, "InputSharedPtrCBase2(), Bottom1 as a parameter failed");
//Shared pointer reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d2)!=5, "InputSharedPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d3)!=9, "InputSharedPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b2)!=205, "InputSharedPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b3)!=309, "InputSharedPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d1)!=3, "InputSharedPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d2)!=6, "InputSharedPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d3)!=7, "InputSharedPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d3)!=8, "InputSharedPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d1)!=4, "InputSharedPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(cb1)!=1, "InputSharedPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(cb2)!=2, "InputSharedPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b1)!=103, "InputSharedPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b2)!=206, "InputSharedPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b3)!=307, "InputSharedPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b3)!=308, "InputSharedPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b1)!=104, "InputSharedPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_shared_ptr.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_shared_ptr.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_shared_ptr.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(d1)!=3+4, "InputSharedPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(d2)!=6+5, "InputSharedPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(d3)!=7+8+9, "InputSharedPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(d1)!=3+4, "InputSharedPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(d2)!=6+5, "InputSharedPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(d3)!=7+8+9, "InputSharedPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_shared_ptr.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_shared_ptr.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_shared_ptr.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(b1)!=103+104, "InputSharedPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(b2)!=206+205, "InputSharedPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(b3)!=307+308+309, "InputSharedPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(b1)!=103+104, "InputSharedPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(b2)!=206+205, "InputSharedPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(b3)!=307+308+309, "InputSharedPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_shared_ptr.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_shared_ptr.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_shared_ptr.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom1(b1)!=103+104, "InputSharedPtrBottom1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom2(b2)!=206+205, "InputSharedPtrBottom2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom3(b3)!=307+308+309, "InputSharedPtrBottom3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom1(b1)!=103+104, "InputSharedPtrRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom2(b2)!=206+205, "InputSharedPtrRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom3(b3)!=307+308+309, "InputSharedPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
// Return smart pointers
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase2().cbase2()!=4, "MakeSharedPtrDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_ABase1().abase1()!=5, "MakeSharedPtrDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_ABase1().abase1()!=9, "MakeSharedPtrDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase2().cbase2()!=8, "MakeSharedPtrDerived3_CBase2 failed");
// Return smart pointers
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrRefDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase2().cbase2()!=4, "MakeSharedPtrRefDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrRefDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_ABase1().abase1()!=5, "MakeSharedPtrRefDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_ABase1().abase1()!=9, "MakeSharedPtrRefDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrRefDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase2().cbase2()!=8, "MakeSharedPtrRefDerived3_CBase2 failed");
}
}

View file

@ -38,7 +38,7 @@ CPP_TEST_CASES = \
java_prepost \
java_throws \
java_typemaps_proxy \
java_typemaps_typewrapper
java_typemaps_typewrapper \
# li_boost_intrusive_ptr
CPP11_TEST_CASES = \
@ -53,12 +53,13 @@ JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
SWIGOPT += $(JAVA_PACKAGEOPT)
# Custom tests - tests with additional commandline options
java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package
nspace.%: JAVA_PACKAGE = $*Package
nspace_extend.%: JAVA_PACKAGE = $*Package
director_nspace.%: JAVA_PACKAGE = $*Package
director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package
java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
multiple_inheritance_nspace.%: JAVA_PACKAGE = $*Package
nspace.%: JAVA_PACKAGE = $*Package
nspace_extend.%: JAVA_PACKAGE = $*Package
# Rules for the different types of tests
%.cpptest:

View file

@ -0,0 +1,253 @@
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 jcbase1b(CBase1 cb1){
return cb1.cbase1y();
}
int jabase1(ABase1 ab1){
return ab1.abase1();
}
int jcbase2(CBase2 cb2){
return cb2.cbase2();
}
public static void check(boolean fail, String msg) {
if (fail)
throw new RuntimeException(msg);
}
public static void main(String argv[]) {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1 cb1=new CBase1SwigImpl();
CBase2 cb2=new CBase2SwigImpl();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test abstract class as return value
ABase1 ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1 cb6=d2.cloneit();
CBase2 cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1 cb3=new Derived1();
CBase1 cb4=new Derived3();
CBase2 cb5=new Derived3();
ABase1 ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in java
multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_abstract.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_abstract.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_abstract.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_abstract.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_abstract.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_abstract.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_abstract.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_abstract.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_abstract.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_abstract.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_abstract.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_abstract.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_abstract.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_abstract.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_abstract.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_abstract.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_abstract.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_abstract.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_abstract.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_abstract.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_abstract.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_abstract.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_abstract.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_abstract.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_abstract.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_abstract.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_abstract.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_abstract.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_abstract.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_abstract.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_abstract.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,78 @@
import multiple_inheritance_interfaces.*;
import java.util.Arrays;
public class multiple_inheritance_interfaces_runme {
static {
try {
System.loadLibrary("multiple_inheritance_interfaces");
} 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);
}
}
private static void checkBaseAndInterfaces(Class cls, boolean interfaceExpected, String base, String[] interfaces) {
String[] expectedInterfaces = new String[interfaces.length];
for (int i=0; i<interfaces.length; ++i)
expectedInterfaces[i] = "interface multiple_inheritance_interfaces." + interfaces[i];
Class[] actualInterfaces = cls.getInterfaces();
String expectedInterfacesString = Arrays.toString(expectedInterfaces);
String actualInterfacesString = Arrays.toString(actualInterfaces);
if (!expectedInterfacesString.equals(actualInterfacesString))
throw new RuntimeException("Expected interfaces for " + cls.getName() + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
String expectedBaseString = null;
if (interfaceExpected) {
// expecting an interface
if (!cls.isInterface())
throw new RuntimeException(cls.getName() + " should be an interface but is not");
expectedBaseString = base.isEmpty() ? "" : "multiple_inheritance_interfaces." + base;
} else {
// expecting a class
if (cls.isInterface())
throw new RuntimeException(cls.getName() + " is an interface but it should not be");
expectedBaseString = base.isEmpty() ? "java.lang.Object" : "multiple_inheritance_interfaces." + base;
}
String actualBaseString = cls.getSuperclass() == null ? "" : cls.getSuperclass().getName();
if (!expectedBaseString.equals(actualBaseString))
throw new RuntimeException("Expected base for " + cls.getName() + ": [" + expectedBaseString + "]" + " Actual base: [" + actualBaseString + "]");
}
public static void main(String argv[]) {
checkBaseAndInterfaces(IA.class, true, "", new String[] {});
checkBaseAndInterfaces(IB.class, true, "", new String[] {});
checkBaseAndInterfaces(IC.class, true, "", new String[] {"IA", "IB"});
checkBaseAndInterfaces(A.class, false, "", new String[] {"IA"});
checkBaseAndInterfaces(B.class, false, "", new String[] {"IB"});
checkBaseAndInterfaces(C.class, false, "", new String[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(D.class, false, "", new String[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(E.class, false, "D", new String[] {});
checkBaseAndInterfaces(IJ.class, true, "", new String[] {});
checkBaseAndInterfaces(IK.class, true, "", new String[] {"IJ"});
checkBaseAndInterfaces(IL.class, true, "", new String[] {"IK"});
checkBaseAndInterfaces(J.class, false, "", new String[] {"IJ"});
checkBaseAndInterfaces(K.class, false, "", new String[] {"IJ", "IK"});
checkBaseAndInterfaces(L.class, false, "", new String[] {"IJ", "IK", "IL"});
checkBaseAndInterfaces(M.class, false, "", new String[] {"IJ", "IK", "IL"});
checkBaseAndInterfaces(P.class, false, "", new String[] {});
checkBaseAndInterfaces(IQ.class, true, "", new String[] {});
checkBaseAndInterfaces(Q.class, false, "", new String[] {"IQ"});
checkBaseAndInterfaces(R.class, false, "P", new String[] {"IQ"});
checkBaseAndInterfaces(S.class, false, "P", new String[] {"IQ"});
checkBaseAndInterfaces(T.class, false, "", new String[] {"IQ"});
checkBaseAndInterfaces(U.class, false, "R", new String[] {});
checkBaseAndInterfaces(V.class, false, "S", new String[] {});
checkBaseAndInterfaces(W.class, false, "T", new String[] {});
// overloaded methods check
D d = new D();
d.ia();
d.ia(10);
d.ia("bye");
d.ia("bye", false);
}
}

View file

@ -0,0 +1,255 @@
import multiple_inheritance_nspacePackage.multiple_inheritance_nspace;
import multiple_inheritance_nspacePackage.multiple_inheritance_nspaceJNI;
import multiple_inheritance_nspacePackage.Space.*;
public class multiple_inheritance_nspace_runme {
static {
try {
System.loadLibrary("multiple_inheritance_nspace");
} 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 jcbase1b(CBase1SwigInterface cb1){
return cb1.cbase1y();
}
int jabase1(ABase1SwigInterface ab1){
return ab1.abase1();
}
int jcbase2(CBase2SwigInterface cb2){
return cb2.cbase2();
}
public static void check(boolean fail, String msg) {
if (fail)
throw new RuntimeException(msg);
}
public static void main(String argv[]) {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1SwigInterface cb1=new CBase1();
CBase2SwigInterface cb2=new CBase2();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test nspace class as return value
ABase1SwigInterface ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1SwigInterface cb6=d2.cloneit();
CBase2SwigInterface cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1SwigInterface cb3=new Derived1();
CBase1SwigInterface cb4=new Derived3();
CBase2SwigInterface cb5=new Derived3();
ABase1SwigInterface ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in java
multiple_inheritance_nspace_runme mhar=new multiple_inheritance_nspace_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_nspace.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_nspace.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_nspace.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_nspace.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_nspace.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_nspace.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_nspace.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_nspace.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_nspace.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_nspace.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_nspace.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_nspace.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_nspace.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_nspace.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_nspace.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_nspace.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_nspace.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_nspace.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_nspace.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_nspace.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_nspace.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_nspace.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_nspace.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_nspace.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_nspace.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_nspace.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_nspace.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_nspace.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_nspace.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_nspace.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_nspace.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,337 @@
import multiple_inheritance_shared_ptr.*;
public class multiple_inheritance_shared_ptr_runme {
static {
try {
System.loadLibrary("multiple_inheritance_shared_ptr");
} 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 jcbase1b(CBase1 cb1){
return cb1.cbase1y();
}
int jabase1(ABase1 ab1){
return ab1.abase1();
}
int jcbase2(CBase2 cb2){
return cb2.cbase2();
}
public static void check(boolean fail, String msg) {
if (fail)
throw new RuntimeException(msg);
}
public static void main(String argv[]) {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1 cb1=new CBase1SwigImpl();
CBase2 cb2=new CBase2SwigImpl();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test abstract class as return value
ABase1 ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1 cb6=d2.cloneit();
CBase2 cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1 cb3=new Derived1();
CBase1 cb4=new Derived3();
CBase2 cb5=new Derived3();
ABase1 ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in java
multiple_inheritance_shared_ptr_runme mhar=new multiple_inheritance_shared_ptr_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_shared_ptr.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Shared pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d2)!=5, "InputSharedPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d3)!=9, "InputSharedPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b2)!=205, "InputSharedPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b3)!=309, "InputSharedPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d1)!=3, "InputSharedPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d2)!=6, "InputSharedPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d3)!=7, "InputSharedPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d3)!=8, "InputSharedPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d1)!=4, "InputSharedPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(cb1)!=1, "InputSharedPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(cb2)!=2, "InputSharedPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b1)!=103, "InputSharedPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b2)!=206, "InputSharedPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b3)!=307, "InputSharedPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b3)!=308, "InputSharedPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b1)!=104, "InputSharedPtrCBase2(), Bottom1 as a parameter failed");
//Shared pointer reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d2)!=5, "InputSharedPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d3)!=9, "InputSharedPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b2)!=205, "InputSharedPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b3)!=309, "InputSharedPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d1)!=3, "InputSharedPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d2)!=6, "InputSharedPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d3)!=7, "InputSharedPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d3)!=8, "InputSharedPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d1)!=4, "InputSharedPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(cb1)!=1, "InputSharedPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(cb2)!=2, "InputSharedPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b1)!=103, "InputSharedPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b2)!=206, "InputSharedPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b3)!=307, "InputSharedPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b3)!=308, "InputSharedPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b1)!=104, "InputSharedPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_shared_ptr.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_shared_ptr.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_shared_ptr.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(d1)!=3+4, "InputSharedPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(d2)!=6+5, "InputSharedPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(d3)!=7+8+9, "InputSharedPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(d1)!=3+4, "InputSharedPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(d2)!=6+5, "InputSharedPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(d3)!=7+8+9, "InputSharedPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_shared_ptr.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_shared_ptr.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_shared_ptr.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(b1)!=103+104, "InputSharedPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(b2)!=206+205, "InputSharedPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(b3)!=307+308+309, "InputSharedPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(b1)!=103+104, "InputSharedPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(b2)!=206+205, "InputSharedPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(b3)!=307+308+309, "InputSharedPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_shared_ptr.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_shared_ptr.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_shared_ptr.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom1(b1)!=103+104, "InputSharedPtrBottom1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom2(b2)!=206+205, "InputSharedPtrBottom2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom3(b3)!=307+308+309, "InputSharedPtrBottom3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom1(b1)!=103+104, "InputSharedPtrRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom2(b2)!=206+205, "InputSharedPtrRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom3(b3)!=307+308+309, "InputSharedPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
// Return smart pointers
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase2().cbase2()!=4, "MakeSharedPtrDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_ABase1().abase1()!=5, "MakeSharedPtrDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_ABase1().abase1()!=9, "MakeSharedPtrDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase2().cbase2()!=8, "MakeSharedPtrDerived3_CBase2 failed");
// Return smart pointers references
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrRefDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase2().cbase2()!=4, "MakeSharedPtrRefDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrRefDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_ABase1().abase1()!=5, "MakeSharedPtrRefDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_ABase1().abase1()!=9, "MakeSharedPtrRefDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrRefDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase2().cbase2()!=8, "MakeSharedPtrRefDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,328 @@
// This is a copy of the multiple_inheritance_abstract test
%module multiple_inheritance_abstract
%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
%include "swiginterface.i"
%interface_impl(Space::ABase1)
%interface_impl(Space::CBase1)
%interface_impl(Space::CBase2)
#endif
#if defined(SWIGD)
// Missing multiple inheritance support results in incorrect use of override
%ignore CBase1;
%ignore CBase2;
#endif
%inline %{
namespace Space {
struct CBase1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 1;
}
int cbase1z() {
return 10;
}
virtual ~CBase1() {
}
};
struct CBase2 {
virtual int cbase2() {
return 2;
}
virtual ~CBase2() {
}
};
struct ABase1 {
virtual int abase1() = 0;
virtual ~ABase1() {
}
};
struct Derived1 : CBase2, CBase1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 3;
}
virtual int cbase2() {
return 4;
}
virtual CBase2 *cloneit() {
return new Derived1(*this);
}
void derived1() {
}
};
struct Derived2 : CBase1, ABase1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 6;
}
virtual int abase1() {
return 5;
}
virtual CBase1 *cloneit() {
return new Derived2(*this);
}
void derived2() {
}
};
struct Derived3 : ABase1, CBase1, CBase2 {
virtual int cbase1y() {
return 7;
}
virtual int cbase2() {
return 8;
}
virtual int abase1() {
return 9;
}
virtual void cbase1x() {
}
virtual ABase1 *cloneit() {
return new Derived3(*this);
}
void derived3() {
}
};
struct Bottom1 : Derived1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 103;
}
virtual int cbase2() {
return 104;
}
};
struct Bottom2 : Derived2 {
virtual int cbase1y() {
return 206;
}
virtual int abase1() {
return 205;
}
};
struct Bottom3 : Derived3 {
virtual int cbase1y() {
return 307;
}
virtual int cbase2() {
return 308;
}
virtual int abase1() {
return 309;
}
};
// Base classes as input
int InputValCBase1(CBase1 cb1) {
return cb1.cbase1y();
}
int InputValCBase2(CBase2 cb2) {
return cb2.cbase2();
}
int InputPtrABase1(ABase1 *pab1) {
return pab1->abase1();
}
int InputPtrCBase1(CBase1 *pcb1) {
return pcb1->cbase1y();
}
int InputPtrCBase2(CBase2 *pcb2) {
return pcb2->cbase2();
}
int InputRefABase1(ABase1 &rab1) {
return rab1.abase1();
}
int InputRefCBase1(CBase1 &rcb1) {
return rcb1.cbase1y();
}
int InputRefCBase2(CBase2 &rcb2) {
return rcb2.cbase2();
}
int InputCPtrRefABase1(ABase1 *const& pab1) {
return pab1->abase1();
}
int InputCPtrRefCBase1(CBase1 *const& pcb1) {
return pcb1->cbase1y();
}
int InputCPtrRefCBase2(CBase2 *const& pcb2) {
return pcb2->cbase2();
}
// Derived classes as input
int InputValDerived1(Derived1 d) {
return d.cbase1y() + d.cbase2();
}
int InputValDerived2(Derived2 d) {
return d.cbase1y() + d.abase1();
}
int InputValDerived3(Derived3 d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputRefDerived1(Derived1 &d) {
return d.cbase1y() + d.cbase2();
}
int InputRefDerived2(Derived2 &d) {
return d.cbase1y() + d.abase1();
}
int InputRefDerived3(Derived3 &d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputPtrDerived1(Derived1 *d) {
return d->cbase1y() + d->cbase2();
}
int InputPtrDerived2(Derived2 *d) {
return d->cbase1y() + d->abase1();
}
int InputPtrDerived3(Derived3 *d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
int InputCPtrRefDerived1(Derived1 *const& d) {
return d->cbase1y() + d->cbase2();
}
int InputCPtrRefDerived2(Derived2 *const& d) {
return d->cbase1y() + d->abase1();
}
int InputCPtrRefDerived3(Derived3 *const& d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
// Bottom classes as input
int InputValBottom1(Bottom1 d) {
return d.cbase1y() + d.cbase2();
}
int InputValBottom2(Bottom2 d) {
return d.cbase1y() + d.abase1();
}
int InputValBottom3(Bottom3 d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputRefBottom1(Bottom1 &d) {
return d.cbase1y() + d.cbase2();
}
int InputRefBottom2(Bottom2 &d) {
return d.cbase1y() + d.abase1();
}
int InputRefBottom3(Bottom3 &d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputPtrBottom1(Bottom1 *d) {
return d->cbase1y() + d->cbase2();
}
int InputPtrBottom2(Bottom2 *d) {
return d->cbase1y() + d->abase1();
}
int InputPtrBottom3(Bottom3 *d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
int InputCPtrRefBottom1(Bottom1 *const& d) {
return d->cbase1y() + d->cbase2();
}
int InputCPtrRefBottom2(Bottom2 *const& d) {
return d->cbase1y() + d->abase1();
}
int InputCPtrRefBottom3(Bottom3 *const& d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
// Return pointers
CBase1 *MakePtrDerived1_CBase1() {
return new Derived1();
}
CBase2 *MakePtrDerived1_CBase2() {
return new Derived1();
}
CBase1 *MakePtrDerived2_CBase1() {
return new Derived2();
}
ABase1 *MakePtrDerived2_ABase1() {
return new Derived2();
}
ABase1 *MakePtrDerived3_ABase1() {
return new Derived3();
}
CBase1 *MakePtrDerived3_CBase1() {
return new Derived3();
}
CBase2 *MakePtrDerived3_CBase2() {
return new Derived3();
}
// Return references
CBase1 &MakeRefDerived1_CBase1() {
static Derived1 d;
return d;
}
CBase2 &MakeRefDerived1_CBase2() {
static Derived1 d;
return d;
}
CBase1 &MakeRefDerived2_CBase1() {
static Derived2 d;
return d;
}
ABase1 &MakeRefDerived2_ABase1() {
static Derived2 d;
return d;
}
ABase1 &MakeRefDerived3_ABase1() {
static Derived3 d;
return d;
}
CBase1 &MakeRefDerived3_CBase1() {
static Derived3 d;
return d;
}
CBase2 &MakeRefDerived3_CBase2() {
static Derived3 d;
return d;
}
// Return by value (sliced objects)
CBase1 MakeValDerived1_CBase1() {
return Derived1();
}
CBase2 MakeValDerived1_CBase2() {
return Derived1();
}
CBase1 MakeValDerived2_CBase1() {
return Derived2();
}
CBase1 MakeValDerived3_CBase1() {
return Derived3();
}
CBase2 MakeValDerived3_CBase2() {
return Derived3();
}
}
%}

View file

@ -0,0 +1,66 @@
%module multiple_inheritance_interfaces
%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
%include "swiginterface.i"
%interface_custom("A", "IA", IA)
%interface_custom("B", "IB", IB)
%interface_custom("%(strip:[I])s", "I%s", IC) // same as %interface_custom("C", "IC", IC)
#endif
%inline %{
struct IA {
virtual void ia() {};
virtual void ia(const char *s, bool b = true) {}
virtual void ia(int i) {}
virtual ~IA() {}
};
struct IB { virtual ~IB() {} virtual void ib() {} };
struct IC : IA, IB {};
struct D : IC {};
struct E : D {};
%}
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
%interface_custom("J", "IJ", IJ)
%interface_custom("K", "IK", IK)
%interface_custom("L", "IL", IL)
#endif
%inline %{
struct IJ { virtual ~IJ() {}; virtual void ij() {} };
struct IK : IJ {};
struct IL : IK {};
struct M : IL {};
%}
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
%interface_custom("Q", "IQ", IQ)
#endif
%inline %{
struct P { virtual ~P() {} virtual void p() {} };
struct IQ { virtual ~IQ() {} virtual void iq() {} };
struct R : IQ, P {};
struct S : P, IQ {};
struct T : IQ {};
struct U : R {};
struct V : S {};
struct W : T {};
%}
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
%interface_impl(BaseOverloaded);
#endif
%inline %{
struct BaseOverloaded {
typedef P PTypedef;
virtual ~BaseOverloaded() {}
virtual void identical_overload(int i, const PTypedef &pp = PTypedef()) {}
};
struct DerivedOverloaded : public BaseOverloaded {
virtual void identical_overload(int i, const PTypedef &p = PTypedef()) {}
};
%}

View file

@ -0,0 +1,338 @@
// This is a copy of the multiple_inheritance_abstract test
%module multiple_inheritance_nspace
%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */
// nspace feature only supported by these languages
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
%nspace;
#endif
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
%include "swiginterface.i"
%interface(Space::ABase1)
%interface(Space::CBase1)
%interface(Space::CBase2)
#endif
#if defined(SWIGD)
// Missing multiple inheritance support results in incorrect use of override
%ignore CBase1;
%ignore CBase2;
#endif
#if defined(SWIGJAVA)
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
#endif
%inline %{
namespace Space {
struct CBase1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 1;
}
int cbase1z() {
return 10;
}
virtual ~CBase1() {
}
};
struct CBase2 {
virtual int cbase2() {
return 2;
}
virtual ~CBase2() {
}
};
struct ABase1 {
virtual int abase1() = 0;
virtual ~ABase1() {
}
};
struct Derived1 : CBase2, CBase1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 3;
}
virtual int cbase2() {
return 4;
}
virtual CBase2 *cloneit() {
return new Derived1(*this);
}
void derived1() {
}
};
struct Derived2 : CBase1, ABase1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 6;
}
virtual int abase1() {
return 5;
}
virtual CBase1 *cloneit() {
return new Derived2(*this);
}
void derived2() {
}
};
struct Derived3 : ABase1, CBase1, CBase2 {
virtual int cbase1y() {
return 7;
}
virtual int cbase2() {
return 8;
}
virtual int abase1() {
return 9;
}
virtual void cbase1x() {
}
virtual ABase1 *cloneit() {
return new Derived3(*this);
}
void derived3() {
}
};
struct Bottom1 : Derived1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 103;
}
virtual int cbase2() {
return 104;
}
};
struct Bottom2 : Derived2 {
virtual int cbase1y() {
return 206;
}
virtual int abase1() {
return 205;
}
};
struct Bottom3 : Derived3 {
virtual int cbase1y() {
return 307;
}
virtual int cbase2() {
return 308;
}
virtual int abase1() {
return 309;
}
};
// Base classes as input
int InputValCBase1(CBase1 cb1) {
return cb1.cbase1y();
}
int InputValCBase2(CBase2 cb2) {
return cb2.cbase2();
}
int InputPtrABase1(ABase1 *pab1) {
return pab1->abase1();
}
int InputPtrCBase1(CBase1 *pcb1) {
return pcb1->cbase1y();
}
int InputPtrCBase2(CBase2 *pcb2) {
return pcb2->cbase2();
}
int InputRefABase1(ABase1 &rab1) {
return rab1.abase1();
}
int InputRefCBase1(CBase1 &rcb1) {
return rcb1.cbase1y();
}
int InputRefCBase2(CBase2 &rcb2) {
return rcb2.cbase2();
}
int InputCPtrRefABase1(ABase1 *const& pab1) {
return pab1->abase1();
}
int InputCPtrRefCBase1(CBase1 *const& pcb1) {
return pcb1->cbase1y();
}
int InputCPtrRefCBase2(CBase2 *const& pcb2) {
return pcb2->cbase2();
}
// Derived classes as input
int InputValDerived1(Derived1 d) {
return d.cbase1y() + d.cbase2();
}
int InputValDerived2(Derived2 d) {
return d.cbase1y() + d.abase1();
}
int InputValDerived3(Derived3 d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputRefDerived1(Derived1 &d) {
return d.cbase1y() + d.cbase2();
}
int InputRefDerived2(Derived2 &d) {
return d.cbase1y() + d.abase1();
}
int InputRefDerived3(Derived3 &d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputPtrDerived1(Derived1 *d) {
return d->cbase1y() + d->cbase2();
}
int InputPtrDerived2(Derived2 *d) {
return d->cbase1y() + d->abase1();
}
int InputPtrDerived3(Derived3 *d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
int InputCPtrRefDerived1(Derived1 *const& d) {
return d->cbase1y() + d->cbase2();
}
int InputCPtrRefDerived2(Derived2 *const& d) {
return d->cbase1y() + d->abase1();
}
int InputCPtrRefDerived3(Derived3 *const& d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
// Bottom classes as input
int InputValBottom1(Bottom1 d) {
return d.cbase1y() + d.cbase2();
}
int InputValBottom2(Bottom2 d) {
return d.cbase1y() + d.abase1();
}
int InputValBottom3(Bottom3 d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputRefBottom1(Bottom1 &d) {
return d.cbase1y() + d.cbase2();
}
int InputRefBottom2(Bottom2 &d) {
return d.cbase1y() + d.abase1();
}
int InputRefBottom3(Bottom3 &d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputPtrBottom1(Bottom1 *d) {
return d->cbase1y() + d->cbase2();
}
int InputPtrBottom2(Bottom2 *d) {
return d->cbase1y() + d->abase1();
}
int InputPtrBottom3(Bottom3 *d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
int InputCPtrRefBottom1(Bottom1 *const& d) {
return d->cbase1y() + d->cbase2();
}
int InputCPtrRefBottom2(Bottom2 *const& d) {
return d->cbase1y() + d->abase1();
}
int InputCPtrRefBottom3(Bottom3 *const& d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
// Return pointers
CBase1 *MakePtrDerived1_CBase1() {
return new Derived1();
}
CBase2 *MakePtrDerived1_CBase2() {
return new Derived1();
}
CBase1 *MakePtrDerived2_CBase1() {
return new Derived2();
}
ABase1 *MakePtrDerived2_ABase1() {
return new Derived2();
}
ABase1 *MakePtrDerived3_ABase1() {
return new Derived3();
}
CBase1 *MakePtrDerived3_CBase1() {
return new Derived3();
}
CBase2 *MakePtrDerived3_CBase2() {
return new Derived3();
}
// Return references
CBase1 &MakeRefDerived1_CBase1() {
static Derived1 d;
return d;
}
CBase2 &MakeRefDerived1_CBase2() {
static Derived1 d;
return d;
}
CBase1 &MakeRefDerived2_CBase1() {
static Derived2 d;
return d;
}
ABase1 &MakeRefDerived2_ABase1() {
static Derived2 d;
return d;
}
ABase1 &MakeRefDerived3_ABase1() {
static Derived3 d;
return d;
}
CBase1 &MakeRefDerived3_CBase1() {
static Derived3 d;
return d;
}
CBase2 &MakeRefDerived3_CBase2() {
static Derived3 d;
return d;
}
// Return by value (sliced objects)
CBase1 MakeValDerived1_CBase1() {
return Derived1();
}
CBase2 MakeValDerived1_CBase2() {
return Derived1();
}
CBase1 MakeValDerived2_CBase1() {
return Derived2();
}
CBase1 MakeValDerived3_CBase1() {
return Derived3();
}
CBase2 MakeValDerived3_CBase2() {
return Derived3();
}
}
%}

View file

@ -0,0 +1,499 @@
// This is a copy of the multiple_inheritance_abstract test and extended for testing %shared_ptr and %interface_impl
%module multiple_inheritance_shared_ptr
%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */
// Typemap changes required to mix %shared_ptr and %interface_impl
// Note we don't have a way to use $javainterfacename/$csinterfacename (yet),
// so we improvise somewhat by adding the SwigImpl suffix
%define SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(CONST, TYPE...)
#if defined(SWIGJAVA)
%typemap(javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "($javainput == null) ? 0 : $javainput.$typemap(jstype, TYPE)_GetInterfaceCPtr()"
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
long cPtr = $jnicall;
return (cPtr == 0) ? null : ($typemap(jstype, TYPE))new $typemap(jstype, TYPE)SwigImpl(cPtr, true);
}
#elif defined(SWIGCSHARP)
%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$csinput == null ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : $csinput.GetInterfaceCPtr()"
%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
global::System.IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)SwigImpl(cPtr, true);$excode
return ret;
}
#endif
%enddef
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
%include <boost_shared_ptr.i>
%shared_ptr(Space::ABase1)
%shared_ptr(Space::CBase1)
%shared_ptr(Space::CBase2)
%shared_ptr(Space::Derived1)
%shared_ptr(Space::Derived2)
%shared_ptr(Space::Derived3)
%shared_ptr(Space::Bottom1)
%shared_ptr(Space::Bottom2)
%shared_ptr(Space::Bottom3)
%include "swiginterface.i"
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::ABase1)
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::CBase1)
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::CBase2)
%interface_impl(Space::ABase1)
%interface_impl(Space::CBase1)
%interface_impl(Space::CBase2)
#endif
#if defined(SWIGD)
// Missing multiple inheritance support results in incorrect use of override
%ignore CBase1;
%ignore CBase2;
#endif
%inline %{
#include <boost/shared_ptr.hpp>
namespace Space {
struct CBase1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 1;
}
int cbase1z() {
return 10;
}
virtual ~CBase1() {
}
};
struct CBase2 {
virtual int cbase2() {
return 2;
}
virtual ~CBase2() {
}
};
struct ABase1 {
virtual int abase1() = 0;
virtual ~ABase1() {
}
};
struct Derived1 : CBase2, CBase1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 3;
}
virtual int cbase2() {
return 4;
}
virtual CBase2 *cloneit() {
return new Derived1(*this);
}
void derived1() {
}
};
struct Derived2 : CBase1, ABase1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 6;
}
virtual int abase1() {
return 5;
}
virtual CBase1 *cloneit() {
return new Derived2(*this);
}
void derived2() {
}
};
struct Derived3 : ABase1, CBase1, CBase2 {
virtual int cbase1y() {
return 7;
}
virtual int cbase2() {
return 8;
}
virtual int abase1() {
return 9;
}
virtual void cbase1x() {
}
virtual ABase1 *cloneit() {
return new Derived3(*this);
}
void derived3() {
}
};
struct Bottom1 : Derived1 {
virtual void cbase1x() {
return;
}
virtual int cbase1y() {
return 103;
}
virtual int cbase2() {
return 104;
}
};
struct Bottom2 : Derived2 {
virtual int cbase1y() {
return 206;
}
virtual int abase1() {
return 205;
}
};
struct Bottom3 : Derived3 {
virtual int cbase1y() {
return 307;
}
virtual int cbase2() {
return 308;
}
virtual int abase1() {
return 309;
}
};
typedef boost::shared_ptr<ABase1> ABase1_SharedPtr;
typedef boost::shared_ptr<CBase1> CBase1_SharedPtr;
typedef boost::shared_ptr<CBase2> CBase2_SharedPtr;
typedef boost::shared_ptr<Derived1> Derived1_SharedPtr;
typedef boost::shared_ptr<Derived2> Derived2_SharedPtr;
typedef boost::shared_ptr<Derived3> Derived3_SharedPtr;
typedef boost::shared_ptr<Bottom1> Bottom1_SharedPtr;
typedef boost::shared_ptr<Bottom2> Bottom2_SharedPtr;
typedef boost::shared_ptr<Bottom3> Bottom3_SharedPtr;
// Base classes as input
int InputValCBase1(CBase1 cb1) {
return cb1.cbase1y();
}
int InputValCBase2(CBase2 cb2) {
return cb2.cbase2();
}
int InputPtrABase1(ABase1 *pab1) {
return pab1->abase1();
}
int InputPtrCBase1(CBase1 *pcb1) {
return pcb1->cbase1y();
}
int InputPtrCBase2(CBase2 *pcb2) {
return pcb2->cbase2();
}
int InputRefABase1(ABase1 &rab1) {
return rab1.abase1();
}
int InputRefCBase1(CBase1 &rcb1) {
return rcb1.cbase1y();
}
int InputRefCBase2(CBase2 &rcb2) {
return rcb2.cbase2();
}
int InputCPtrRefABase1(ABase1 *const& pab1) {
return pab1->abase1();
}
int InputCPtrRefCBase1(CBase1 *const& pcb1) {
return pcb1->cbase1y();
}
int InputCPtrRefCBase2(CBase2 *const& pcb2) {
return pcb2->cbase2();
}
int InputSharedPtrABase1(ABase1_SharedPtr pab1) {
return pab1->abase1();
}
int InputSharedPtrCBase1(CBase1_SharedPtr pcb1) {
return pcb1->cbase1y();
}
int InputSharedPtrCBase2(CBase2_SharedPtr pcb2) {
return pcb2->cbase2();
}
int InputSharedPtrRefABase1(ABase1_SharedPtr &pab1) {
return pab1->abase1();
}
int InputSharedPtrRefCBase1(CBase1_SharedPtr &pcb1) {
return pcb1->cbase1y();
}
int InputSharedPtrRefCBase2(CBase2_SharedPtr &pcb2) {
return pcb2->cbase2();
}
// Derived classes as input
int InputValDerived1(Derived1 d) {
return d.cbase1y() + d.cbase2();
}
int InputValDerived2(Derived2 d) {
return d.cbase1y() + d.abase1();
}
int InputValDerived3(Derived3 d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputRefDerived1(Derived1 &d) {
return d.cbase1y() + d.cbase2();
}
int InputRefDerived2(Derived2 &d) {
return d.cbase1y() + d.abase1();
}
int InputRefDerived3(Derived3 &d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputPtrDerived1(Derived1 *d) {
return d->cbase1y() + d->cbase2();
}
int InputPtrDerived2(Derived2 *d) {
return d->cbase1y() + d->abase1();
}
int InputPtrDerived3(Derived3 *d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
int InputCPtrRefDerived1(Derived1 *const& d) {
return d->cbase1y() + d->cbase2();
}
int InputCPtrRefDerived2(Derived2 *const& d) {
return d->cbase1y() + d->abase1();
}
int InputCPtrRefDerived3(Derived3 *const& d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
int InputSharedPtrDerived1(Derived1_SharedPtr d) {
return d->cbase1y() + d->cbase2();
}
int InputSharedPtrDerived2(Derived2_SharedPtr d) {
return d->cbase1y() + d->abase1();
}
int InputSharedPtrDerived3(Derived3_SharedPtr d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
int InputSharedPtrRefDerived1(Derived1_SharedPtr &d) {
return d->cbase1y() + d->cbase2();
}
int InputSharedPtrRefDerived2(Derived2_SharedPtr &d) {
return d->cbase1y() + d->abase1();
}
int InputSharedPtrRefDerived3(Derived3_SharedPtr &d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
// Bottom classes as input
int InputValBottom1(Bottom1 d) {
return d.cbase1y() + d.cbase2();
}
int InputValBottom2(Bottom2 d) {
return d.cbase1y() + d.abase1();
}
int InputValBottom3(Bottom3 d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputRefBottom1(Bottom1 &d) {
return d.cbase1y() + d.cbase2();
}
int InputRefBottom2(Bottom2 &d) {
return d.cbase1y() + d.abase1();
}
int InputRefBottom3(Bottom3 &d) {
return d.cbase1y() + d.cbase2() + d.abase1();
}
int InputPtrBottom1(Bottom1 *d) {
return d->cbase1y() + d->cbase2();
}
int InputPtrBottom2(Bottom2 *d) {
return d->cbase1y() + d->abase1();
}
int InputPtrBottom3(Bottom3 *d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
int InputCPtrRefBottom1(Bottom1 *const& d) {
return d->cbase1y() + d->cbase2();
}
int InputCPtrRefBottom2(Bottom2 *const& d) {
return d->cbase1y() + d->abase1();
}
int InputCPtrRefBottom3(Bottom3 *const& d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
int InputSharedPtrBottom1(Bottom1_SharedPtr d) {
return d->cbase1y() + d->cbase2();
}
int InputSharedPtrBottom2(Bottom2_SharedPtr d) {
return d->cbase1y() + d->abase1();
}
int InputSharedPtrBottom3(Bottom3_SharedPtr d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
int InputSharedPtrRefBottom1(Bottom1_SharedPtr &d) {
return d->cbase1y() + d->cbase2();
}
int InputSharedPtrRefBottom2(Bottom2_SharedPtr &d) {
return d->cbase1y() + d->abase1();
}
int InputSharedPtrRefBottom3(Bottom3_SharedPtr &d) {
return d->cbase1y() + d->cbase2() + d->abase1();
}
// Return pointers
CBase1 *MakePtrDerived1_CBase1() {
return new Derived1();
}
CBase2 *MakePtrDerived1_CBase2() {
return new Derived1();
}
CBase1 *MakePtrDerived2_CBase1() {
return new Derived2();
}
ABase1 *MakePtrDerived2_ABase1() {
return new Derived2();
}
ABase1 *MakePtrDerived3_ABase1() {
return new Derived3();
}
CBase1 *MakePtrDerived3_CBase1() {
return new Derived3();
}
CBase2 *MakePtrDerived3_CBase2() {
return new Derived3();
}
// Return references
CBase1 &MakeRefDerived1_CBase1() {
static Derived1 d;
return d;
}
CBase2 &MakeRefDerived1_CBase2() {
static Derived1 d;
return d;
}
CBase1 &MakeRefDerived2_CBase1() {
static Derived2 d;
return d;
}
ABase1 &MakeRefDerived2_ABase1() {
static Derived2 d;
return d;
}
ABase1 &MakeRefDerived3_ABase1() {
static Derived3 d;
return d;
}
CBase1 &MakeRefDerived3_CBase1() {
static Derived3 d;
return d;
}
CBase2 &MakeRefDerived3_CBase2() {
static Derived3 d;
return d;
}
// Return by value (sliced objects)
CBase1 MakeValDerived1_CBase1() {
return Derived1();
}
CBase2 MakeValDerived1_CBase2() {
return Derived1();
}
CBase1 MakeValDerived2_CBase1() {
return Derived2();
}
CBase1 MakeValDerived3_CBase1() {
return Derived3();
}
CBase2 MakeValDerived3_CBase2() {
return Derived3();
}
// Return smart pointers
CBase1_SharedPtr MakeSharedPtrDerived1_CBase1() {
return CBase1_SharedPtr(new Derived1());
}
CBase2_SharedPtr MakeSharedPtrDerived1_CBase2() {
return CBase2_SharedPtr(new Derived1());
}
CBase1_SharedPtr MakeSharedPtrDerived2_CBase1() {
return CBase1_SharedPtr(new Derived2());
}
ABase1_SharedPtr MakeSharedPtrDerived2_ABase1() {
return ABase1_SharedPtr(new Derived2());
}
ABase1_SharedPtr MakeSharedPtrDerived3_ABase1() {
return ABase1_SharedPtr(new Derived3());
}
CBase1_SharedPtr MakeSharedPtrDerived3_CBase1() {
return CBase1_SharedPtr(new Derived3());
}
CBase2_SharedPtr MakeSharedPtrDerived3_CBase2() {
return CBase2_SharedPtr(new Derived3());
}
// Return smart pointer references
CBase1_SharedPtr MakeSharedPtrRefDerived1_CBase1() {
static CBase1_SharedPtr s(new Derived1());
return s;
}
CBase2_SharedPtr MakeSharedPtrRefDerived1_CBase2() {
static CBase2_SharedPtr s(new Derived1());
return s;
}
CBase1_SharedPtr MakeSharedPtrRefDerived2_CBase1() {
static CBase1_SharedPtr s(new Derived2());
return s;
}
ABase1_SharedPtr MakeSharedPtrRefDerived2_ABase1() {
static ABase1_SharedPtr s(new Derived2());
return s;
}
ABase1_SharedPtr MakeSharedPtrRefDerived3_ABase1() {
static ABase1_SharedPtr s(new Derived3());
return s;
}
CBase1_SharedPtr MakeSharedPtrRefDerived3_CBase1() {
static CBase1_SharedPtr s(new Derived3());
return s;
}
CBase2_SharedPtr MakeSharedPtrRefDerived3_CBase2() {
static CBase2_SharedPtr s(new Derived3());
return s;
}
}
%}

View file

@ -0,0 +1,5 @@
from rename_rstrip_encoder import *
s = SomeThing()
a = AnotherThing()
a.DoClsX()

View file

@ -0,0 +1,15 @@
%module rename_rstrip_encoder
// strip the Cls suffix from all identifiers
%rename("%(rstrip:[Cls])s") "";
%inline %{
class SomeThingCls {
};
struct AnotherThingCls {
void DoClsXCls() {}
};
%}

View file

@ -0,0 +1,63 @@
/* -----------------------------------------------------------------------------
* swiginterface.i
*
* SWIG interface feature and typemaps implementation providing:
* %interface
* %interface_impl
* %interface_custom
* ----------------------------------------------------------------------------- */
%define INTERFACE_TYPEMAPS(CTYPE...)
%typemap(cstype) CTYPE "$&csinterfacename"
%typemap(cstype) CTYPE *, CTYPE [], CTYPE & "$csinterfacename"
%typemap(cstype) CTYPE *const& "$*csinterfacename"
%typemap(csin) CTYPE, CTYPE & "$csinput.GetInterfaceCPtr()"
%typemap(csin) CTYPE *, CTYPE *const&, CTYPE [] "$csinput == null ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : $csinput.GetInterfaceCPtr()"
%typemap(csout, excode=SWIGEXCODE) CTYPE {
$&csclassname ret = new $&csclassname($imcall, true);$excode
return ($&csinterfacename)ret;
}
%typemap(csout, excode=SWIGEXCODE) CTYPE & {
$csclassname ret = new $csclassname($imcall, $owner);$excode
return ($csinterfacename)ret;
}
%typemap(csout, excode=SWIGEXCODE) CTYPE *, CTYPE [] {
global::System.IntPtr cPtr = $imcall;
$csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
return ($csinterfacename)ret;
}
%typemap(csout, excode=SWIGEXCODE) CTYPE *const& {
global::System.IntPtr cPtr = $imcall;
$*csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
return ($*csinterfacename)ret;
}
%typemap(csdirectorin) CTYPE "($&csinterfacename)new $&csclassname($iminput, false)"
%typemap(csdirectorin) CTYPE & "($csinterfacename)new $csclassname($iminput, false)"
%typemap(csdirectorin) CTYPE *, CTYPE [] "($iminput == global::System.IntPtr.Zero) ? null : ($csinterfacename)new $csclassname($iminput, false)"
%typemap(csdirectorin) CTYPE *const& "($iminput == global::System.IntPtr.Zero) ? null : ($*csinterfacename)new $*csclassname($iminput, false)"
%typemap(csdirectorout) CTYPE, CTYPE *, CTYPE *const&, CTYPE [], CTYPE & "$cscall.GetInterfaceCPtr()"
%typemap(csinterfacecode, declaration=" [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]\n global::System.Runtime.InteropServices.HandleRef GetInterfaceCPtr();\n", cptrmethod="$interfacename_GetInterfaceCPtr") CTYPE %{
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
global::System.Runtime.InteropServices.HandleRef $interfacename.GetInterfaceCPtr() {
return new global::System.Runtime.InteropServices.HandleRef(this, $imclassname.$csclazzname$interfacename_GetInterfaceCPtr(swigCPtr.Handle));
}
%}
%enddef
%define %interface(CTYPE...)
%feature("interface", name="%sSwigInterface") CTYPE;
INTERFACE_TYPEMAPS(CTYPE)
%enddef
%define %interface_impl(CTYPE...)
%rename("%sSwigImpl") CTYPE;
%feature("interface", name="%(rstrip:[SwigImpl])s") CTYPE;
INTERFACE_TYPEMAPS(CTYPE)
%enddef
%define %interface_custom(PROXY, INTERFACE, CTYPE...)
%rename(PROXY) CTYPE;
%feature("interface", name=INTERFACE) CTYPE;
INTERFACE_TYPEMAPS(CTYPE)
%enddef

74
Lib/java/swiginterface.i Normal file
View file

@ -0,0 +1,74 @@
/* -----------------------------------------------------------------------------
* swiginterface.i
*
* SWIG interface feature and typemaps implementation providing:
* %interface
* %interface_impl
* %interface_custom
* ----------------------------------------------------------------------------- */
%define INTERFACE_TYPEMAPS(CTYPE...)
%typemap(jtype) CTYPE, CTYPE *, CTYPE *const&, CTYPE [], CTYPE & "long"
%typemap(jstype) CTYPE "$&javainterfacename"
%typemap(jstype) CTYPE *, CTYPE [], CTYPE & "$javainterfacename"
%typemap(jstype) CTYPE *const& "$*javainterfacename"
%typemap(javain) CTYPE "$javainput.$&interfacename_GetInterfaceCPtr()"
%typemap(javain) CTYPE & "$javainput.$interfacename_GetInterfaceCPtr()"
%typemap(javain) CTYPE *, CTYPE [] "($javainput == null) ? 0 : $javainput.$interfacename_GetInterfaceCPtr()"
%typemap(javain) CTYPE *const& "($javainput == null) ? 0 : $javainput.$*interfacename_GetInterfaceCPtr()"
%typemap(javaout) CTYPE {
return ($&javainterfacename)new $&javaclassname($jnicall, true);
}
%typemap(javaout) CTYPE & {
return ($javainterfacename)new $javaclassname($jnicall, $owner);
}
%typemap(javaout) CTYPE *, CTYPE [] {
long cPtr = $jnicall;
return (cPtr == 0) ? null : ($javainterfacename)new $javaclassname(cPtr, $owner);
}
%typemap(javaout) CTYPE *const& {
long cPtr = $jnicall;
return (cPtr == 0) ? null : ($javainterfacename)new $javaclassname(cPtr, $owner);
}
%typemap(javadirectorin) CTYPE "($&javainterfacename)new $&javaclassname($jniinput, false)"
%typemap(javadirectorin) CTYPE & "($javainterfacename)new $javaclassname($jniinput, false)"
%typemap(javadirectorin) CTYPE *, CTYPE [] "($jniinput == 0) ? null : ($javainterfacename)new $javaclassname($jniinput, false)"
%typemap(javadirectorin) CTYPE *const& "($jniinput == 0) ? null : ($*javainterfacename)new $*javaclassname($jniinput, false)"
%typemap(javadirectorout) CTYPE "$javacall.$&interfacename_GetInterfaceCPtr()"
%typemap(javadirectorout) CTYPE *, CTYPE [], CTYPE & "$javacall.$interfacename_GetInterfaceCPtr()"
%typemap(javadirectorout) CTYPE *const& "$javacall.$*interfacename_GetInterfaceCPtr()"
%typemap(directorin,descriptor="L$packagepath/$&javainterfacename;") CTYPE
%{ $input = 0;
*(($&1_ltype*)&$input) = &$1; %}
%typemap(directorin,descriptor="L$packagepath/$javainterfacename;") CTYPE *, CTYPE []
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
%typemap(directorin,descriptor="L$packagepath/$javainterfacename;") CTYPE &
%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
%typemap(directorin,descriptor="L$packagepath/$*javainterfacename;") CTYPE *const&
%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
%typemap(javainterfacecode, declaration=" long $interfacename_GetInterfaceCPtr();\n", cptrmethod="$interfacename_GetInterfaceCPtr") CTYPE %{
public long $interfacename_GetInterfaceCPtr() {
return $imclassname.$javaclazzname$interfacename_GetInterfaceCPtr(swigCPtr);
}
%}
%enddef
%define %interface(CTYPE...)
%feature("interface", name="%sSwigInterface") CTYPE;
INTERFACE_TYPEMAPS(CTYPE)
%enddef
%define %interface_impl(CTYPE...)
%rename("%sSwigImpl") CTYPE;
%feature("interface", name="%(rstrip:[SwigImpl])s") CTYPE;
INTERFACE_TYPEMAPS(CTYPE)
%enddef
%define %interface_custom(PROXY, INTERFACE, CTYPE...)
%rename(PROXY) CTYPE;
%feature("interface", name=INTERFACE) CTYPE;
INTERFACE_TYPEMAPS(CTYPE)
%enddef

View file

@ -256,6 +256,7 @@
#define WARN_JAVA_TYPEMAP_JAVAIN_UNDEF 818
#define WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF 819
#define WARN_JAVA_TYPEMAP_JAVADIRECTOROUT_UNDEF 820
#define WARN_JAVA_TYPEMAP_INTERFACECODE_UNDEF 821
#define WARN_JAVA_COVARIANT_RET 822
#define WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF 823
#define WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC 824
@ -275,6 +276,7 @@
#define WARN_CSHARP_TYPEMAP_CSIN_UNDEF 838
#define WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF 839
#define WARN_CSHARP_TYPEMAP_CSDIRECTOROUT_UNDEF 840
#define WARN_CSHARP_TYPEMAP_INTERFACECODE_UNDEF 841
#define WARN_CSHARP_COVARIANT_RET 842
#define WARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF 843
#define WARN_CSHARP_EXCODE 844

View file

@ -47,6 +47,7 @@ eswig_SOURCES = CParse/cscanner.c \
Modules/emit.cxx \
Modules/go.cxx \
Modules/guile.cxx \
Modules/interface.cxx \
Modules/java.cxx \
Modules/javascript.cxx \
Modules/lang.cxx \

View file

@ -729,6 +729,8 @@ Allocate():
}
}
Swig_interface_propagate_methods(n);
/* Only care about default behavior. Remove temporary values */
Setattr(n, "allocate:visit", "1");
Swig_symbol_setscope(symtab);

View file

@ -52,6 +52,7 @@ class CSHARP:public Language {
String *imclass_class_code; // intermediary class code
String *proxy_class_def;
String *proxy_class_code;
String *interface_class_code; // if %feature("interface") was declared for a class, here goes the interface declaration
String *module_class_code;
String *proxy_class_name; // proxy class name
String *full_imclass_name; // fully qualified intermediary class name when using nspace feature, otherwise same as imclass_name
@ -126,6 +127,7 @@ public:
imclass_class_code(NULL),
proxy_class_def(NULL),
proxy_class_code(NULL),
interface_class_code(NULL),
module_class_code(NULL),
proxy_class_name(NULL),
full_imclass_name(NULL),
@ -272,6 +274,7 @@ public:
SWIG_config_file("csharp.swg");
allow_overloading();
Swig_interface_feature_enable();
}
/* ---------------------------------------------------------------------
@ -1643,6 +1646,119 @@ public:
return Language::pragmaDirective(n);
}
/* -----------------------------------------------------------------------------
* getQualifiedInterfaceName()
* ----------------------------------------------------------------------------- */
String *getQualifiedInterfaceName(Node *n) {
String *ret = Getattr(n, "interface:qname");
if (!ret) {
String *nspace = Getattr(n, "sym:nspace");
String *interface_name = Getattr(n, "interface:name");
if (nspace) {
if (namespce)
ret = NewStringf("%s.%s.%s", namespce, nspace, interface_name);
else
ret = NewStringf("%s.%s", nspace, interface_name);
} else {
ret = Copy(interface_name);
}
Setattr(n, "interface:qname", ret);
}
return ret;
}
/* -----------------------------------------------------------------------------
* getInterfaceName()
* ----------------------------------------------------------------------------- */
String *getInterfaceName(SwigType *t, bool qualified) {
String *interface_name = NULL;
if (proxy_flag) {
Node *n = classLookup(t);
if (n && Getattr(n, "interface:name"))
interface_name = qualified ? getQualifiedInterfaceName(n) : Getattr(n, "interface:name");
}
return interface_name;
}
/* -----------------------------------------------------------------------------
* addInterfaceNameAndUpcasts()
* ----------------------------------------------------------------------------- */
void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, String *c_classname) {
List *keys = Keys(base_list);
for (Iterator it = First(keys); it.item; it = Next(it)) {
Node *base = Getattr(base_list, it.item);
String *c_baseclass = SwigType_namestr(Getattr(base, "name"));
String *interface_name = Getattr(base, "interface:name");
if (Len(interface_list))
Append(interface_list, ", ");
Append(interface_list, interface_name);
Node *attributes = NewHash();
String *interface_code = Copy(typemapLookup(base, "csinterfacecode", Getattr(base, "classtypeobj"), WARN_CSHARP_TYPEMAP_INTERFACECODE_UNDEF, attributes));
String *cptr_method_name = 0;
if (interface_code) {
Replaceall(interface_code, "$interfacename", interface_name);
Printv(interface_upcasts, interface_code, NIL);
cptr_method_name = Copy(Getattr(attributes, "tmap:csinterfacecode:cptrmethod"));
}
if (!cptr_method_name)
cptr_method_name = NewStringf("%s_GetInterfaceCPtr", interface_name);
Replaceall(cptr_method_name, ".", "_");
Replaceall(cptr_method_name, "$interfacename", interface_name);
String *upcast_method_name = Swig_name_member(getNSpace(), proxy_class_name, cptr_method_name);
upcastsCode(smart, upcast_method_name, c_classname, c_baseclass);
Delete(upcast_method_name);
Delete(cptr_method_name);
Delete(interface_code);
Delete(c_baseclass);
}
Delete(keys);
}
/* -----------------------------------------------------------------------------
* upcastsCode()
*
* Add code for C++ casting to base class
* ----------------------------------------------------------------------------- */
void upcastsCode(SwigType *smart, String *upcast_method_name, String *c_classname, String *c_baseclass) {
String *wname = Swig_name_wrapper(upcast_method_name);
Printv(imclass_cppcasts_code, "\n [global::System.Runtime.InteropServices.DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
Printf(imclass_cppcasts_code, " public static extern global::System.IntPtr %s(global::System.IntPtr jarg1);\n", upcast_method_name);
Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name);
if (smart) {
SwigType *bsmart = Copy(smart);
SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
Replaceall(bsmart, rclassname, rbaseclass);
Delete(rclassname);
Delete(rbaseclass);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(bsmart);
Printv(upcasts_code,
"SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n",
" return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n"
"}\n", "\n", NIL);
Delete(bsmartnamestr);
Delete(smartnamestr);
Delete(bsmart);
} else {
Printv(upcasts_code,
"SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n",
" return (", c_baseclass, " *)jarg1;\n"
"}\n", "\n", NIL);
}
Delete(wname);
}
/* -----------------------------------------------------------------------------
* emitProxyClassDefAndCPPCasts()
* ----------------------------------------------------------------------------- */
@ -1652,9 +1768,12 @@ public:
String *c_baseclass = NULL;
String *baseclass = NULL;
String *c_baseclassname = NULL;
String *interface_list = NewStringEmpty();
String *interface_upcasts = NewStringEmpty();
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
bool feature_director = Swig_directorclass(n) ? true : false;
bool has_outerclass = Getattr(n, "nested:outer") != 0 && !GetFlag(n, "feature:flatnested");
SwigType *smart = Swig_cparse_smartptr(n);
// Inheritance from pure C# classes
Node *attributes = NewHash();
@ -1667,31 +1786,29 @@ public:
if (!purebase_replace) {
List *baselist = Getattr(n, "bases");
if (baselist) {
Iterator base = First(baselist);
while (base.item && GetFlag(base.item, "feature:ignore")) {
base = Next(base);
}
if (base.item) {
c_baseclassname = Getattr(base.item, "name");
baseclass = Copy(getProxyName(c_baseclassname));
if (baseclass)
c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
base = Next(base);
/* Warn about multiple inheritance for additional base class(es) */
while (base.item) {
if (GetFlag(base.item, "feature:ignore")) {
base = Next(base);
continue;
}
String *proxyclassname = Getattr(n, "classtypeobj");
String *baseclassname = Getattr(base.item, "name");
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
base = Next(base);
}
}
Iterator base = First(baselist);
while (base.item) {
if (!(GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface"))) {
String *baseclassname = Getattr(base.item, "name");
if (!c_baseclassname) {
c_baseclassname = baseclassname;
baseclass = Copy(getProxyName(baseclassname));
if (baseclass)
c_baseclass = SwigType_namestr(baseclassname);
} else {
/* Warn about multiple inheritance for additional base class(es) */
String *proxyclassname = Getattr(n, "classtypeobj");
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s, base %s ignored. Multiple inheritance is not supported in C#.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
}
}
base = Next(base);
}
}
}
Hash *interface_bases = Getattr(n, "interface:bases");
if (interface_bases)
addInterfaceNameAndUpcasts(smart, interface_list, interface_upcasts, interface_bases, c_classname);
bool derived = baseclass && getProxyName(c_baseclassname);
if (derived && purebase_notderived)
@ -1707,12 +1824,15 @@ public:
Swig_error(Getfile(n), Getline(n), "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. "
"Warning for %s, base %s ignored. Multiple inheritance is not supported in C#. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure C# interfaces
const String *pure_interfaces = typemapLookup(n, derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE);
if (*Char(interface_list) && *Char(pure_interfaces))
Append(interface_list, ", ");
Append(interface_list, pure_interfaces);
// Start writing the proxy class
if (!has_outerclass)
Printv(proxy_class_def, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements
@ -1725,8 +1845,8 @@ public:
Printv(proxy_class_def, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $csclassname", // Class name and base class
(*Char(wanted_base) || *Char(pure_interfaces)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(pure_interfaces)) ? // Interfaces
", " : "", pure_interfaces, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class
(*Char(wanted_base) || *Char(interface_list)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(interface_list)) ? // Interfaces
", " : "", interface_list, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class
typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
NIL);
@ -1771,6 +1891,8 @@ public:
Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " ", derived ? "override" : "virtual", " void ", destruct_methodname, "() ", destruct, "\n",
NIL);
}
if (*Char(interface_upcasts))
Printv(proxy_class_def, interface_upcasts, NIL);
if (feature_director) {
// Generate director connect method
@ -1852,6 +1974,8 @@ public:
Delete(director_connect_method_name);
}
Delete(interface_upcasts);
Delete(interface_list);
Delete(attributes);
Delete(destruct);
@ -1859,54 +1983,92 @@ public:
Printv(proxy_class_def, typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code
"\n", NIL);
// Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
if (derived) {
SwigType *smart = Swig_cparse_smartptr(n);
String *upcast_method = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
String *wname = Swig_name_wrapper(upcast_method);
Printv(imclass_cppcasts_code, "\n [global::System.Runtime.InteropServices.DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
Printf(imclass_cppcasts_code, " public static extern global::System.IntPtr %s(global::System.IntPtr jarg1);\n", upcast_method);
Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name);
if (smart) {
SwigType *bsmart = Copy(smart);
SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
Replaceall(bsmart, rclassname, rbaseclass);
Delete(rclassname);
Delete(rbaseclass);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(bsmart);
Printv(upcasts_code,
"SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n",
" return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n"
"}\n", "\n", NIL);
Delete(bsmartnamestr);
Delete(smartnamestr);
Delete(bsmart);
} else {
Printv(upcasts_code,
"SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n",
" return (", c_baseclass, " *)jarg1;\n"
"}\n", "\n", NIL);
}
Delete(wname);
Delete(upcast_method);
Delete(smart);
String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
upcastsCode(smart, upcast_method_name, c_classname, c_baseclass);
Delete(upcast_method_name);
}
Delete(smart);
Delete(baseclass);
}
/* ----------------------------------------------------------------------
* emitInterfaceDeclaration()
* ---------------------------------------------------------------------- */
void emitInterfaceDeclaration(Node *n, String *interface_name, File *f_interface) {
Printv(f_interface, typemapLookup(n, "csimports", Getattr(n, "classtypeobj"), WARN_NONE), "\n", NIL);
Printf(f_interface, "public interface %s", interface_name);
if (List *baselist = Getattr(n, "bases")) {
String *bases = 0;
for (Iterator base = First(baselist); base.item; base = Next(base)) {
if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface"))
continue; // TODO: warn about skipped non-interface bases
String *base_iname = Getattr(base.item, "interface:name");
if (!bases)
bases = NewStringf(" : %s", base_iname);
else {
Append(bases, ", ");
Append(bases, base_iname);
}
}
if (bases) {
Printv(f_interface, bases, NIL);
Delete(bases);
}
}
Printf(f_interface, " {\n");
Node *attributes = NewHash();
String *interface_code = Copy(typemapLookup(n, "csinterfacecode", Getattr(n, "classtypeobj"), WARN_CSHARP_TYPEMAP_INTERFACECODE_UNDEF, attributes));
if (interface_code) {
String *interface_declaration = Copy(Getattr(attributes, "tmap:csinterfacecode:declaration"));
if (interface_declaration) {
Replaceall(interface_declaration, "$interfacename", interface_name);
Printv(f_interface, interface_declaration, NIL);
Delete(interface_declaration);
}
Delete(interface_code);
}
}
/* ----------------------------------------------------------------------
* calculateDirectBase()
* ---------------------------------------------------------------------- */
void calculateDirectBase(Node* n) {
Node* direct_base = 0;
// C++ inheritance
Node *attributes = NewHash();
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false;
bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false;
Delete(attributes);
if (!purebase_replace) {
if (List *baselist = Getattr(n, "bases")) {
Iterator base = First(baselist);
while (base.item && (GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface")))
base = Next(base);
direct_base = base.item;
}
if (!direct_base && purebase_notderived)
direct_base = symbolLookup(const_cast<String*>(pure_baseclass));
} else {
direct_base = symbolLookup(const_cast<String*>(pure_baseclass));
}
Setattr(n, "direct_base", direct_base);
}
/* ----------------------------------------------------------------------
* classHandler()
* ---------------------------------------------------------------------- */
virtual int classHandler(Node *n) {
String *nspace = getNSpace();
File *f_proxy = NULL;
File *f_interface = NULL;
// save class local variables
String *old_proxy_class_name = proxy_class_name;
String *old_full_imclass_name = full_imclass_name;
@ -1915,9 +2077,12 @@ public:
String *old_proxy_class_def = proxy_class_def;
String *old_proxy_class_code = proxy_class_code;
bool has_outerclass = Getattr(n, "nested:outer") && !GetFlag(n, "feature:flatnested");
String *old_interface_class_code = interface_class_code;
interface_class_code = 0;
if (proxy_flag) {
proxy_class_name = NewString(Getattr(n, "sym:name"));
String *interface_name = Getattr(n, "feature:interface") ? Getattr(n, "interface:name") : 0;
if (Node *outer = Getattr(n, "nested:outer")) {
String *outerClassesPrefix = Copy(Getattr(outer, "sym:name"));
for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) {
@ -1927,13 +2092,16 @@ public:
String *fnspace = nspace ? NewStringf("%s.%s", nspace, outerClassesPrefix) : outerClassesPrefix;
if (!addSymbol(proxy_class_name, n, fnspace))
return SWIG_ERROR;
if (interface_name && !addInterfaceSymbol(interface_name, n, fnspace))
return SWIG_ERROR;
if (nspace)
Delete(fnspace);
Delete(outerClassesPrefix);
}
else {
} else {
if (!addSymbol(proxy_class_name, n, nspace))
return SWIG_ERROR;
if (interface_name && !addInterfaceSymbol(interface_name, n, nspace))
return SWIG_ERROR;
}
if (!nspace) {
@ -1960,13 +2128,25 @@ public:
f_proxy = getOutputFile(output_directory, proxy_class_name);
addOpenNamespace(nspace, f_proxy);
Delete(output_directory);
}
else
++nesting_depth;
proxy_class_def = NewString("");
proxy_class_code = NewString("");
destructor_call = NewString("");
proxy_class_constants_code = NewString("");
if (Getattr(n, "feature:interface")) {
interface_class_code = NewString("");
String *output_directory = outputDirectory(nspace);
f_interface = getOutputFile(output_directory, interface_name);
addOpenNamespace(nspace, f_interface);
emitInterfaceDeclaration(n, interface_name, interface_class_code);
Delete(output_directory);
}
calculateDirectBase(n);
}
Language::classHandler(n);
@ -1980,22 +2160,28 @@ public:
Replaceall(proxy_class_def, "$csclassname", proxy_class_name);
Replaceall(proxy_class_code, "$csclassname", proxy_class_name);
Replaceall(proxy_class_constants_code, "$csclassname", proxy_class_name);
Replaceall(interface_class_code, "$csclassname", proxy_class_name);
Replaceall(proxy_class_def, "$csclazzname", csclazzname);
Replaceall(proxy_class_code, "$csclazzname", csclazzname);
Replaceall(proxy_class_constants_code, "$csclazzname", csclazzname);
Replaceall(interface_class_code, "$csclazzname", csclazzname);
Replaceall(proxy_class_def, "$module", module_class_name);
Replaceall(proxy_class_code, "$module", module_class_name);
Replaceall(proxy_class_constants_code, "$module", module_class_name);
Replaceall(interface_class_code, "$module", module_class_name);
Replaceall(proxy_class_def, "$imclassname", full_imclass_name);
Replaceall(proxy_class_code, "$imclassname", full_imclass_name);
Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name);
Replaceall(interface_class_code, "$imclassname", full_imclass_name);
Replaceall(proxy_class_def, "$dllimport", dllimport);
Replaceall(proxy_class_code, "$dllimport", dllimport);
Replaceall(proxy_class_constants_code, "$dllimport", dllimport);
Replaceall(interface_class_code, "$dllimport", dllimport);
if (!has_outerclass)
Printv(f_proxy, proxy_class_def, proxy_class_code, NIL);
else {
@ -2058,8 +2244,18 @@ public:
Delete(downcast_method);
}
if (f_interface) {
Printv(f_interface, interface_class_code, "}\n", NIL);
addCloseNamespace(nspace, f_interface);
if (f_interface != f_single_out)
Delete(f_interface);
f_interface = 0;
}
emitDirectorExtraMethods(n);
Delete(interface_class_code);
interface_class_code = old_interface_class_code;
Delete(csclazzname);
Delete(proxy_class_name);
proxy_class_name = old_proxy_class_name;
@ -2145,6 +2341,8 @@ public:
String *pre_code = NewString("");
String *post_code = NewString("");
String *terminator_code = NewString("");
bool is_interface = Getattr(parentNode(n), "feature:interface") != 0
&& !static_flag && Getattr(n, "interface:owner") == 0;
if (!proxy_flag)
return;
@ -2217,8 +2415,21 @@ public:
Printf(function_code, " %s ", methodmods);
if (!is_smart_pointer()) {
// Smart pointer classes do not mirror the inheritance hierarchy of the underlying pointer type, so no virtual/override/new required.
if (Getattr(n, "override"))
Printf(function_code, "override ");
if (Node *base_ovr = Getattr(n, "override")) {
if (GetFlag(n, "isextendmember"))
Printf(function_code, "override ");
else {
Node* base = parentNode(base_ovr);
bool ovr = false;
for (Node* direct_base = Getattr(parentNode(n), "direct_base"); direct_base; direct_base = Getattr(direct_base, "direct_base")) {
if (direct_base == base) { // "override" only applies if the base was not discarded (e.g. in case of multiple inheritance or via "ignore")
ovr = true;
break;
}
}
Printf(function_code, ovr ? "override " : "virtual ");
}
}
else if (checkAttribute(n, "storage", "virtual"))
Printf(function_code, "virtual ");
if (Getattr(n, "hides"))
@ -2228,6 +2439,9 @@ public:
if (static_flag)
Printf(function_code, "static ");
Printf(function_code, "%s %s(", return_type, proxy_function_name);
if (is_interface)
Printf(interface_class_code, " %s %s(", return_type, proxy_function_name);
Printv(imcall, full_imclass_name, ".$imfuncname(", NIL);
if (!static_flag)
@ -2307,10 +2521,15 @@ public:
}
/* Add parameter to proxy function */
if (gencomma >= 2)
if (gencomma >= 2) {
Printf(function_code, ", ");
if (is_interface)
Printf(interface_class_code, ", ");
}
gencomma = 2;
Printf(function_code, "%s %s", param_type, arg);
if (is_interface)
Printf(interface_class_code, "%s %s", param_type, arg);
Delete(arg);
Delete(param_type);
@ -2320,6 +2539,8 @@ public:
Printf(imcall, ")");
Printf(function_code, ")");
if (is_interface)
Printf(interface_class_code, ");\n");
// Transform return type used in PInvoke function (in intermediary class) to type used in C# wrapper function (in proxy class)
if ((tm = Swig_typemap_lookup("csout", n, "", 0))) {
@ -3188,6 +3409,50 @@ public:
substitution_performed = true;
Delete(classnametype);
}
if (Strstr(tm, "$csinterfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$csinterfacename", true);
substitution_performed = true;
Delete(interfacenametype);
}
if (Strstr(tm, "$*csinterfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
Delete(SwigType_pop(interfacenametype));
if (Len(interfacenametype) > 0) {
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$*csinterfacename", true);
substitution_performed = true;
}
Delete(interfacenametype);
}
if (Strstr(tm, "$&csinterfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
SwigType_add_pointer(interfacenametype);
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$&csinterfacename", true);
substitution_performed = true;
Delete(interfacenametype);
}
if (Strstr(tm, "$interfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$interfacename", false);
substitution_performed = true;
Delete(interfacenametype);
}
if (Strstr(tm, "$*interfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
Delete(SwigType_pop(interfacenametype));
if (Len(interfacenametype) > 0) {
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$*interfacename", false);
substitution_performed = true;
}
Delete(interfacenametype);
}
if (Strstr(tm, "$&interfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
SwigType_add_pointer(interfacenametype);
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$&interfacename", false);
substitution_performed = true;
Delete(interfacenametype);
}
Delete(strippedtype);
Delete(type);
@ -3233,6 +3498,20 @@ public:
Delete(replacementname);
}
/* -----------------------------------------------------------------------------
* substituteInterfacenameSpecialVariable()
* ----------------------------------------------------------------------------- */
void substituteInterfacenameSpecialVariable(SwigType *interfacenametype, String *tm, const char *interfacenamespecialvariable, bool qualified) {
String *interfacename = getInterfaceName(interfacenametype, qualified);
if (interfacename) {
String *replacementname = Copy(interfacename);
Replaceall(tm, interfacenamespecialvariable, replacementname);
Delete(replacementname);
}
}
/* -----------------------------------------------------------------------------
* emitTypeWrapperClass()
* ----------------------------------------------------------------------------- */

View file

@ -3123,28 +3123,23 @@ private:
List *baselist = Getattr(n, "bases");
if (baselist) {
Iterator base = First(baselist);
while (base.item && GetFlag(base.item, "feature:ignore")) {
base = Next(base);
}
if (base.item) {
basenode = base.item;
c_baseclassname = Getattr(base.item, "name");
basename = createProxyName(c_baseclassname);
if (basename)
c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
base = Next(base);
/* Warn about multiple inheritance for additional base class(es) */
while (base.item) {
if (GetFlag(base.item, "feature:ignore")) {
base = Next(base);
continue;
while (base.item) {
if (!GetFlag(base.item, "feature:ignore")) {
String *baseclassname = Getattr(base.item, "name");
if (!c_baseclassname) {
basenode = base.item;
c_baseclassname = baseclassname;
basename = createProxyName(c_baseclassname);
if (basename)
c_baseclass = SwigType_namestr(baseclassname);
} else {
/* Warn about multiple inheritance for additional base class(es) */
String *proxyclassname = Getattr(n, "classtypeobj");
Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Base %s of class %s ignored: multiple inheritance is not supported in D.\n", SwigType_namestr(baseclassname), SwigType_namestr(proxyclassname));
}
String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Base %s of class %s ignored: multiple inheritance is not supported in D.\n", baseclassname, proxyclassname);
base = Next(base);
}
base = Next(base);
}
}
}
@ -3169,7 +3164,7 @@ private:
}
} else if (basename && Len(pure_baseclass) > 0) {
Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base class %s ignored. Multiple inheritance is not supported in D. "
"Warning for %s, base class %s ignored. Multiple inheritance is not supported in D. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the dbase typemap?\n", typemap_lookup_type, pure_baseclass);
}

View file

@ -0,0 +1,183 @@
/* -----------------------------------------------------------------------------
* This file is part of SWIG, which is licensed as a whole under version 3
* (or any later version) of the GNU General Public License. Some additional
* terms also apply to certain portions of SWIG. The full details of the SWIG
* license and copyrights can be found in the LICENSE and COPYRIGHT files
* included with the SWIG source code as distributed by the SWIG developers
* and at http://www.swig.org/legal.html.
*
* interface.cxx
*
* This module contains support for the interface feature.
* This feature is used in language modules where the target language does not
* naturally support C++ style multiple inheritance, but does support inheritance
* from multiple interfaces.
* ----------------------------------------------------------------------------- */
#include "swigmod.h"
static bool interface_feature_enabled = false;
/* -----------------------------------------------------------------------------
* collect_interface_methods()
*
* Create a list of all the methods from the base classes of class n that are
* marked as an interface. The resulting list is thus the list of methods that
* need to be implemented in order for n to be non-abstract.
* ----------------------------------------------------------------------------- */
static List *collect_interface_methods(Node *n) {
List *methods = NewList();
if (Hash *bases = Getattr(n, "interface:bases")) {
List *keys = Keys(bases);
for (Iterator base = First(keys); base.item; base = Next(base)) {
Node *cls = Getattr(bases, base.item);
if (cls == n)
continue;
for (Node *child = firstChild(cls); child; child = nextSibling(child)) {
if (Cmp(nodeType(child), "cdecl") == 0) {
if (GetFlag(child, "feature:ignore") || Getattr(child, "interface:owner"))
continue; // skip methods propagated to bases
Node *m = Copy(child);
set_nextSibling(m, NIL);
set_previousSibling(m, NIL);
Setattr(m, "interface:owner", cls);
Append(methods, m);
}
}
}
Delete(keys);
}
return methods;
}
/* -----------------------------------------------------------------------------
* collect_interface_bases
* ----------------------------------------------------------------------------- */
static void collect_interface_bases(Hash *bases, Node *n) {
if (Getattr(n, "feature:interface")) {
String *name = Getattr(n, "interface:name");
if (!Getattr(bases, name))
Setattr(bases, name, n);
}
if (List *baselist = Getattr(n, "bases")) {
for (Iterator base = First(baselist); base.item; base = Next(base)) {
if (!GetFlag(base.item, "feature:ignore")) {
if (Getattr(base.item, "feature:interface"))
collect_interface_bases(bases, base.item);
}
}
}
}
/* -----------------------------------------------------------------------------
* collect_interface_base_classes()
*
* Create a hash containing all the classes up the inheritance hierarchy
* marked with feature:interface (including this class n).
* Stops going up the inheritance chain as soon as a class is found without
* feature:interface.
* The idea is to find all the base interfaces that a class must implement.
* ----------------------------------------------------------------------------- */
static void collect_interface_base_classes(Node *n) {
if (Getattr(n, "feature:interface")) {
// check all bases are also interfaces
if (List *baselist = Getattr(n, "bases")) {
for (Iterator base = First(baselist); base.item; base = Next(base)) {
if (!GetFlag(base.item, "feature:ignore")) {
if (!Getattr(base.item, "feature:interface")) {
Swig_error(Getfile(n), Getline(n), "Base class '%s' of '%s' is not similarly marked as an interface.\n", SwigType_namestr(Getattr(base.item, "name")), SwigType_namestr(Getattr(n, "name")));
SWIG_exit(EXIT_FAILURE);
}
}
}
}
}
Hash *interface_bases = NewHash();
collect_interface_bases(interface_bases, n);
if (Len(interface_bases) == 0)
Delete(interface_bases);
else
Setattr(n, "interface:bases", interface_bases);
}
/* -----------------------------------------------------------------------------
* process_interface_name()
* ----------------------------------------------------------------------------- */
static void process_interface_name(Node *n) {
if (Getattr(n, "feature:interface")) {
String *interface_name = Getattr(n, "feature:interface:name");
if (!Len(interface_name)) {
Swig_error(Getfile(n), Getline(n), "The interface feature for '%s' is missing the name attribute.\n", SwigType_namestr(Getattr(n, "name")));
SWIG_exit(EXIT_FAILURE);
}
if (Strchr(interface_name, '%')) {
String *name = NewStringf(interface_name, Getattr(n, "sym:name"));
Setattr(n, "interface:name", name);
} else {
Setattr(n, "interface:name", interface_name);
}
}
}
/* -----------------------------------------------------------------------------
* Swig_interface_propagate_methods()
*
* Find all the base classes marked as an interface (with feature:interface) for
* class node n. For each of these, add all of its methods as methods of n so that
* n is not abstract. If class n is also marked as an interface, it will remain
* abstract and not have any methods added.
* ----------------------------------------------------------------------------- */
void Swig_interface_propagate_methods(Node *n) {
if (interface_feature_enabled) {
process_interface_name(n);
collect_interface_base_classes(n);
List *methods = collect_interface_methods(n);
bool is_interface = Getattr(n, "feature:interface") != 0;
for (Iterator mi = First(methods); mi.item; mi = Next(mi)) {
if (!is_interface && GetFlag(mi.item, "abstract"))
continue;
String *this_decl = Getattr(mi.item, "decl");
String *this_decl_resolved = SwigType_typedef_resolve_all(this_decl);
bool identically_overloaded_method = false; // true when a base class' method is implemented in n
if (SwigType_isfunction(this_decl_resolved)) {
String *name = Getattr(mi.item, "name");
for (Node *child = firstChild(n); child; child = nextSibling(child)) {
if (Getattr(child, "interface:owner"))
break; // at the end of the list are newly appended methods
if (checkAttribute(child, "name", name)) {
String *decl = SwigType_typedef_resolve_all(Getattr(child, "decl"));
identically_overloaded_method = Strcmp(decl, this_decl_resolved) == 0;
Delete(decl);
if (identically_overloaded_method)
break;
}
}
}
Delete(this_decl_resolved);
if (!identically_overloaded_method) {
// TODO: Fix if the method is overloaded with different arguments / has default args
appendChild(n, mi.item);
} else {
Delete(mi.item);
}
}
Delete(methods);
}
}
/* -----------------------------------------------------------------------------
* Swig_interface_feature_enable()
*
* Turn on interface feature support
* ----------------------------------------------------------------------------- */
void Swig_interface_feature_enable() {
interface_feature_enabled = true;
}

View file

@ -53,6 +53,7 @@ class JAVA:public Language {
String *imclass_class_code; // intermediary class code
String *proxy_class_def;
String *proxy_class_code;
String *interface_class_code; // if %feature("interface") was declared for a class, here goes the interface declaration
String *module_class_code;
String *proxy_class_name; // proxy class name
String *full_proxy_class_name;// fully qualified proxy class name when using nspace feature, otherwise same as proxy_class_name
@ -125,6 +126,7 @@ public:
imclass_class_code(NULL),
proxy_class_def(NULL),
proxy_class_code(NULL),
interface_class_code(NULL),
module_class_code(NULL),
proxy_class_name(NULL),
full_proxy_class_name(NULL),
@ -303,6 +305,7 @@ public:
SWIG_config_file("java.swg");
allow_overloading();
Swig_interface_feature_enable();
}
/* ---------------------------------------------------------------------
@ -1288,8 +1291,10 @@ public:
// Add extra indentation
Replaceall(enum_code, "\n", "\n ");
Replaceall(enum_code, " \n", "\n");
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
if (GetFlag(getCurrentClass(), "feature:interface"))
Printv(interface_class_code, " ", enum_code, "\n\n", NIL);
else
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
} else {
// Global enums are defined in their own file
String *output_directory = outputDirectory(nspace);
@ -1723,6 +1728,125 @@ public:
return Language::pragmaDirective(n);
}
/* -----------------------------------------------------------------------------
* getQualifiedInterfaceName()
* ----------------------------------------------------------------------------- */
String *getQualifiedInterfaceName(Node *n) {
String *ret = Getattr(n, "interface:qname");
if (!ret) {
String *nspace = Getattr(n, "sym:nspace");
String *symname = Getattr(n, "interface:name");
if (nspace) {
if (package)
ret = NewStringf("%s.%s.%s", package, nspace, symname);
else
ret = NewStringf("%s.%s", nspace, symname);
} else {
ret = Copy(symname);
}
Setattr(n, "interface:qname", ret);
}
return ret;
}
/* -----------------------------------------------------------------------------
* getInterfaceName()
* ----------------------------------------------------------------------------- */
String *getInterfaceName(SwigType *t, bool qualified) {
String *interface_name = NULL;
if (proxy_flag) {
Node *n = classLookup(t);
if (n && Getattr(n, "interface:name"))
interface_name = qualified ? getQualifiedInterfaceName(n) : Getattr(n, "interface:name");
}
return interface_name;
}
/* -----------------------------------------------------------------------------
* addInterfaceNameAndUpcasts()
* ----------------------------------------------------------------------------- */
void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, String *c_classname) {
List *keys = Keys(base_list);
for (Iterator it = First(keys); it.item; it = Next(it)) {
Node *base = Getattr(base_list, it.item);
String *c_baseclass = SwigType_namestr(Getattr(base, "name"));
String *interface_name = Getattr(base, "interface:name");
if (Len(interface_list))
Append(interface_list, ", ");
Append(interface_list, interface_name);
Node *attributes = NewHash();
String *interface_code = Copy(typemapLookup(base, "javainterfacecode", Getattr(base, "classtypeobj"), WARN_JAVA_TYPEMAP_INTERFACECODE_UNDEF, attributes));
String *cptr_method_name = 0;
if (interface_code) {
Replaceall(interface_code, "$interfacename", interface_name);
Printv(interface_upcasts, interface_code, NIL);
cptr_method_name = Copy(Getattr(attributes, "tmap:javainterfacecode:cptrmethod"));
}
if (!cptr_method_name)
cptr_method_name = NewStringf("%s_GetInterfaceCPtr", interface_name);
Replaceall(cptr_method_name, ".", "_");
Replaceall(cptr_method_name, "$interfacename", interface_name);
String *upcast_method_name = Swig_name_member(getNSpace(), proxy_class_name, cptr_method_name);
upcastsCode(smart, upcast_method_name, c_classname, c_baseclass);
Delete(upcast_method_name);
Delete(cptr_method_name);
Delete(interface_code);
Delete(c_baseclass);
}
Delete(keys);
}
/* -----------------------------------------------------------------------------
* upcastsCode()
*
* Add code for C++ casting to base class
* ----------------------------------------------------------------------------- */
void upcastsCode(SwigType *smart, String *upcast_method_name, String *c_classname, String *c_baseclass) {
String *jniname = makeValidJniName(upcast_method_name);
String *wname = Swig_name_wrapper(jniname);
Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method_name);
if (smart) {
SwigType *bsmart = Copy(smart);
SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
Replaceall(bsmart, rclassname, rbaseclass);
Delete(rclassname);
Delete(rbaseclass);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(bsmart);
Printv(upcasts_code,
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
" jlong baseptr = 0;\n"
" ", smartnamestr, " *argp1;\n"
" (void)jenv;\n"
" (void)jcls;\n"
" argp1 = *(", smartnamestr, " **)&jarg1;\n"
" *(", bsmartnamestr, " **)&baseptr = argp1 ? new ", bsmartnamestr, "(*argp1) : 0;\n"
" return baseptr;\n"
"}\n", "\n", NIL);
Delete(bsmartnamestr);
Delete(smartnamestr);
Delete(bsmart);
} else {
Printv(upcasts_code,
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
" jlong baseptr = 0;\n"
" (void)jenv;\n"
" (void)jcls;\n"
" *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n"
" return baseptr;\n"
"}\n", "\n", NIL);
}
Delete(wname);
Delete(jniname);
}
/* -----------------------------------------------------------------------------
* emitProxyClassDefAndCPPCasts()
* ----------------------------------------------------------------------------- */
@ -1732,9 +1856,12 @@ public:
String *c_baseclass = NULL;
String *baseclass = NULL;
String *c_baseclassname = NULL;
String *interface_list = NewStringEmpty();
String *interface_upcasts = NewStringEmpty();
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
bool feature_director = Swig_directorclass(n) ? true : false;
bool has_outerclass = Getattr(n, "nested:outer") != 0 && !GetFlag(n, "feature:flatnested");
SwigType *smart = Swig_cparse_smartptr(n);
// Inheritance from pure Java classes
Node *attributes = NewHash();
@ -1747,32 +1874,31 @@ public:
if (!purebase_replace) {
List *baselist = Getattr(n, "bases");
if (baselist) {
Iterator base = First(baselist);
while (base.item && GetFlag(base.item, "feature:ignore")) {
base = Next(base);
}
if (base.item) {
c_baseclassname = Getattr(base.item, "name");
baseclass = Copy(getProxyName(c_baseclassname));
if (baseclass)
c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
base = Next(base);
/* Warn about multiple inheritance for additional base class(es) */
while (base.item) {
if (GetFlag(base.item, "feature:ignore")) {
base = Next(base);
continue;
}
String *proxyclassname = Getattr(n, "classtypeobj");
String *baseclassname = Getattr(base.item, "name");
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
base = Next(base);
}
}
Iterator base = First(baselist);
while (base.item) {
if (!(GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface"))) {
String *baseclassname = Getattr(base.item, "name");
if (!c_baseclassname) {
c_baseclassname = baseclassname;
baseclass = Copy(getProxyName(baseclassname));
if (baseclass)
c_baseclass = SwigType_namestr(baseclassname);
} else {
/* Warn about multiple inheritance for additional base class(es) */
String *proxyclassname = Getattr(n, "classtypeobj");
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s, base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
}
}
base = Next(base);
}
}
}
Hash *interface_bases = Getattr(n, "interface:bases");
if (interface_bases)
addInterfaceNameAndUpcasts(smart, interface_list, interface_upcasts, interface_bases, c_classname);
bool derived = baseclass && getProxyName(c_baseclassname);
if (derived && purebase_notderived)
pure_baseclass = empty_string;
@ -1787,13 +1913,15 @@ public:
Swig_error(Getfile(n), Getline(n), "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. "
"Warning for %s, base %s ignored. Multiple inheritance is not supported in Java. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the javabase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure Java interfaces
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
if (*Char(interface_list) && *Char(pure_interfaces))
Append(interface_list, ", ");
Append(interface_list, pure_interfaces);
// Start writing the proxy class
if (!has_outerclass) // Import statements
Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE),"\n", NIL);
@ -1801,8 +1929,8 @@ public:
Printv(proxy_class_def, "static ", NIL); // C++ nested classes correspond to static java classes
Printv(proxy_class_def, typemapLookup(n, "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(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class
(*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(interface_list) ? // Pure Java interfaces
" implements " : "", interface_list, " {", derived ? typemapLookup(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class
typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
NIL);
@ -1845,6 +1973,8 @@ public:
if (*Char(destruct))
Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL);
}
if (*Char(interface_upcasts))
Printv(proxy_class_def, interface_upcasts, NIL);
/* Insert directordisconnect typemap, if this class has directors enabled */
/* Also insert the swigTakeOwnership and swigReleaseOwnership methods */
@ -1866,6 +1996,8 @@ public:
Delete(take_jnicall);
}
Delete(interface_upcasts);
Delete(interface_list);
Delete(attributes);
Delete(destruct);
@ -1873,60 +2005,80 @@ public:
Printv(proxy_class_def, typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code
"\n", NIL);
// Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
if (derived) {
SwigType *smart = Swig_cparse_smartptr(n);
String *upcast_method = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
String *jniname = makeValidJniName(upcast_method);
String *wname = Swig_name_wrapper(jniname);
Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method);
if (smart) {
SwigType *bsmart = Copy(smart);
SwigType *rclassname = SwigType_typedef_resolve_all(c_classname);
SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass);
Replaceall(bsmart, rclassname, rbaseclass);
Delete(rclassname);
Delete(rbaseclass);
String *smartnamestr = SwigType_namestr(smart);
String *bsmartnamestr = SwigType_namestr(bsmart);
Printv(upcasts_code,
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
" jlong baseptr = 0;\n"
" ", smartnamestr, " *argp1;\n"
" (void)jenv;\n"
" (void)jcls;\n"
" argp1 = *(", smartnamestr, " **)&jarg1;\n"
" *(", bsmartnamestr, " **)&baseptr = argp1 ? new ", bsmartnamestr, "(*argp1) : 0;\n"
" return baseptr;\n"
"}\n", "\n", NIL);
Delete(bsmartnamestr);
Delete(smartnamestr);
Delete(bsmart);
} else {
Printv(upcasts_code,
"SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n",
" jlong baseptr = 0;\n"
" (void)jenv;\n"
" (void)jcls;\n"
" *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n"
" return baseptr;\n"
"}\n", "\n", NIL);
}
Delete(wname);
Delete(jniname);
Delete(upcast_method);
Delete(smart);
String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast");
upcastsCode(smart, upcast_method_name, c_classname, c_baseclass);
Delete(upcast_method_name);
}
Delete(smart);
Delete(baseclass);
}
/* ----------------------------------------------------------------------
* classHandler()
* emitInterfaceDeclaration()
* ---------------------------------------------------------------------- */
virtual int classHandler(Node *n) {
void emitInterfaceDeclaration(Node *n, String *interface_name, File *f_interface, String *nspace) {
if (package || nspace) {
Printf(f_interface, "package ");
if (package)
Printv(f_interface, package, nspace ? "." : "", NIL);
if (nspace)
Printv(f_interface, nspace, NIL);
Printf(f_interface, ";\n");
}
Printv(f_interface, typemapLookup(n, "javaimports", Getattr(n, "classtypeobj"), WARN_NONE), "\n", NIL);
Printf(f_interface, "public interface %s", interface_name);
if (List *baselist = Getattr(n, "bases")) {
String *bases = 0;
for (Iterator base = First(baselist); base.item; base = Next(base)) {
if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface"))
continue; // TODO: warn about skipped non-interface bases
String *base_iname = Getattr(base.item, "interface:name");
if (!bases)
bases = Copy(base_iname);
else {
Append(bases, ", ");
Append(bases, base_iname);
}
}
if (bases) {
Printv(f_interface, " extends ", bases, NIL);
Delete(bases);
}
}
Printf(f_interface, " {\n");
Node *attributes = NewHash();
String *interface_code = Copy(typemapLookup(n, "javainterfacecode", Getattr(n, "classtypeobj"), WARN_JAVA_TYPEMAP_INTERFACECODE_UNDEF, attributes));
if (interface_code) {
String *interface_declaration = Copy(Getattr(attributes, "tmap:javainterfacecode:declaration"));
if (interface_declaration) {
Replaceall(interface_declaration, "$interfacename", interface_name);
Printv(f_interface, interface_declaration, NIL);
Delete(interface_declaration);
}
Delete(interface_code);
}
}
/* ----------------------------------------------------------------------
* classDeclaration()
* ---------------------------------------------------------------------- */
int classDeclaration(Node *n) {
return Language::classDeclaration(n);
}
/* ----------------------------------------------------------------------
* classHandler()
* ---------------------------------------------------------------------- */
virtual int classHandler(Node *n) {
File *f_proxy = NULL;
File *f_interface = NULL;
String *old_proxy_class_name = proxy_class_name;
String *old_full_proxy_class_name = full_proxy_class_name;
String *old_full_imclass_name = full_imclass_name;
@ -1936,6 +2088,8 @@ public:
String *old_proxy_class_def = proxy_class_def;
String *old_proxy_class_code = proxy_class_code;
bool has_outerclass = Getattr(n, "nested:outer") && !GetFlag(n, "feature:flatnested");
String *old_interface_class_code = interface_class_code;
interface_class_code = 0;
if (proxy_flag) {
proxy_class_name = NewString(Getattr(n, "sym:name"));
@ -1976,17 +2130,21 @@ public:
}
}
String *interface_name = Getattr(n, "feature:interface") ? Getattr(n, "interface:name") : 0;
if (outerClassesPrefix) {
String *fnspace = nspace ? NewStringf("%s.%s", nspace, outerClassesPrefix) : outerClassesPrefix;
if (!addSymbol(proxy_class_name, n, fnspace))
return SWIG_ERROR;
if (interface_name && !addInterfaceSymbol(interface_name, n, fnspace))
return SWIG_ERROR;
if (nspace)
Delete(fnspace);
Delete(outerClassesPrefix);
}
else {
} else {
if (!addSymbol(proxy_class_name, n, nspace))
return SWIG_ERROR;
if (interface_name && !addInterfaceSymbol(interface_name, n, nspace))
return SWIG_ERROR;
}
// Each outer proxy class goes into a separate file
@ -2022,11 +2180,27 @@ public:
destructor_call = NewString("");
destructor_throws_clause = NewString("");
proxy_class_constants_code = NewString("");
if (Getattr(n, "feature:interface")) {
interface_class_code = NewString("");
String *output_directory = outputDirectory(nspace);
String *filen = NewStringf("%s%s.java", output_directory, interface_name);
f_interface = NewFile(filen, "w", SWIG_output_files());
if (!f_interface) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
Append(filenames_list, filen); // file name ownership goes to the list
emitBanner(f_interface);
emitInterfaceDeclaration(n, interface_name, interface_class_code, nspace);
Delete(filen);
Delete(output_directory);
}
}
Language::classHandler(n);
if (proxy_flag) {
emitProxyClassDefAndCPPCasts(n);
String *javaclazzname = Swig_name_member(getNSpace(), getClassPrefix(), ""); // mangled full proxy class name
@ -2034,18 +2208,22 @@ public:
Replaceall(proxy_class_def, "$javaclassname", proxy_class_name);
Replaceall(proxy_class_code, "$javaclassname", proxy_class_name);
Replaceall(proxy_class_constants_code, "$javaclassname", proxy_class_name);
Replaceall(interface_class_code, "$javaclassname", proxy_class_name);
Replaceall(proxy_class_def, "$javaclazzname", javaclazzname);
Replaceall(proxy_class_code, "$javaclazzname", javaclazzname);
Replaceall(proxy_class_constants_code, "$javaclazzname", javaclazzname);
Replaceall(interface_class_code, "$javaclazzname", javaclazzname);
Replaceall(proxy_class_def, "$module", module_class_name);
Replaceall(proxy_class_code, "$module", module_class_name);
Replaceall(proxy_class_constants_code, "$module", module_class_name);
Replaceall(interface_class_code, "$module", module_class_name);
Replaceall(proxy_class_def, "$imclassname", full_imclass_name);
Replaceall(proxy_class_code, "$imclassname", full_imclass_name);
Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name);
Replaceall(interface_class_code, "$imclassname", full_imclass_name);
if (!has_outerclass)
Printv(f_proxy, proxy_class_def, proxy_class_code, NIL);
@ -2110,8 +2288,16 @@ public:
Delete(downcast_method);
}
if (f_interface) {
Printv(f_interface, interface_class_code, "}\n", NIL);
Delete(f_interface);
f_interface = 0;
}
emitDirectorExtraMethods(n);
Delete(interface_class_code);
interface_class_code = old_interface_class_code;
Delete(javaclazzname);
Delete(proxy_class_name);
proxy_class_name = old_proxy_class_name;
@ -2203,6 +2389,8 @@ public:
bool setter_flag = false;
String *pre_code = NewString("");
String *post_code = NewString("");
bool is_interface = Getattr(parentNode(n), "feature:interface") != 0
&& !static_flag && Getattr(n, "interface:owner") == 0;
if (!proxy_flag)
return;
@ -2252,6 +2440,9 @@ public:
if (static_flag)
Printf(function_code, "static ");
Printf(function_code, "%s %s(", return_type, proxy_function_name);
if (is_interface)
Printf(interface_class_code, " %s %s(", return_type, proxy_function_name);
Printv(imcall, full_imclass_name, ".$imfuncname(", NIL);
if (!static_flag) {
@ -2339,10 +2530,15 @@ public:
}
/* Add parameter to proxy function */
if (gencomma >= 2)
if (gencomma >= 2) {
Printf(function_code, ", ");
if (is_interface)
Printf(interface_class_code, ", ");
}
gencomma = 2;
Printf(function_code, "%s %s", param_type, arg);
if (is_interface)
Printf(interface_class_code, "%s %s", param_type, arg);
if (prematureGarbageCollectionPreventionParameter(pt, p)) {
String *pgcppname = Getattr(p, "tmap:javain:pgcppname");
@ -2364,6 +2560,8 @@ public:
Printf(imcall, ")");
Printf(function_code, ")");
if (is_interface)
Printf(interface_class_code, ");\n");
// 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))) {
@ -3068,6 +3266,50 @@ public:
substitution_performed = true;
Delete(classnametype);
}
if (Strstr(tm, "$javainterfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$javainterfacename", jnidescriptor, true);
substitution_performed = true;
Delete(interfacenametype);
}
if (Strstr(tm, "$*javainterfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
Delete(SwigType_pop(interfacenametype));
if (Len(interfacenametype) > 0) {
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$*javainterfacename", jnidescriptor, true);
substitution_performed = true;
}
Delete(interfacenametype);
}
if (Strstr(tm, "$&javainterfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
SwigType_add_pointer(interfacenametype);
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$&javainterfacename", jnidescriptor, true);
substitution_performed = true;
Delete(interfacenametype);
}
if (Strstr(tm, "$interfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$interfacename", jnidescriptor, false);
substitution_performed = true;
Delete(interfacenametype);
}
if (Strstr(tm, "$*interfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
Delete(SwigType_pop(interfacenametype));
if (Len(interfacenametype) > 0) {
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$*interfacename", jnidescriptor, false);
substitution_performed = true;
}
Delete(interfacenametype);
}
if (Strstr(tm, "$&interfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
SwigType_add_pointer(interfacenametype);
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$&interfacename", jnidescriptor, false);
substitution_performed = true;
Delete(interfacenametype);
}
Delete(strippedtype);
Delete(type);
@ -3116,6 +3358,24 @@ public:
Delete(replacementname);
}
/* -----------------------------------------------------------------------------
* substituteInterfacenameSpecialVariable()
* ----------------------------------------------------------------------------- */
void substituteInterfacenameSpecialVariable(SwigType *interfacenametype, String *tm, const char *interfacenamespecialvariable, bool jnidescriptor, bool qualified) {
String *interfacename = getInterfaceName(interfacenametype/*, jnidescriptor*/, qualified);
if (interfacename) {
String *replacementname = Copy(interfacename);
if (jnidescriptor)
Replaceall(replacementname,".","/");
Replaceall(tm, interfacenamespecialvariable, replacementname);
Delete(replacementname);
}
}
/* -----------------------------------------------------------------------------
* emitTypeWrapperClass()
* ----------------------------------------------------------------------------- */
@ -3273,7 +3533,7 @@ public:
* ----------------------------------------------------------------------------- */
String *prematureGarbageCollectionPreventionParameter(SwigType *t, Parm *p) {
String *proxyClassName = 0;
String *pgcpp_java_type = 0;
String *jtype = NewString(Getattr(p, "tmap:jtype"));
// Strip C comments
@ -3290,11 +3550,9 @@ public:
if (Cmp(jtype, "long") == 0) {
if (proxy_flag) {
if (!GetFlag(p, "tmap:jtype:nopgcpp") && !nopgcpp_flag) {
String *proxyname = getProxyName(t);
if (proxyname) {
// Found a struct/class parameter passed by value, reference, pointer, or pointer reference
proxyClassName = proxyname;
} else {
String *interface_name = getInterfaceName(t, true);
pgcpp_java_type = interface_name ? interface_name : getProxyName(t);
if (!pgcpp_java_type) {
// Look for proxy class parameters passed to C++ layer using non-default typemaps, ie not one of above types
String *jstype = NewString(Getattr(p, "tmap:jstype"));
if (jstype) {
@ -3316,7 +3574,7 @@ public:
if (cls && !Getattr(cls, "feature:ignore")) {
String *symname = Getattr(cls, "sym:name");
if (symname && Strcmp(symname, jstype) == 0) {
proxyClassName = symname;
pgcpp_java_type = symname;
}
}
}
@ -3328,7 +3586,7 @@ public:
}
}
Delete(jtype);
return proxyClassName;
return pgcpp_java_type;
}
/* -----------------------------------------------------------------------------

View file

@ -3118,6 +3118,31 @@ int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr
return 1;
}
/* -----------------------------------------------------------------------------
* Language::addInterfaceSymbol()
*
* Adds a symbol entry into the target language symbol tables - for the interface
* feature only.
* Returns 1 if the symbol is added successfully.
* The scope is as per addSymbol.
* ----------------------------------------------------------------------------- */
int Language::addInterfaceSymbol(const String *interface_name, Node *n, const_String_or_char_ptr scope) {
if (interface_name) {
Node *existing_symbol = symbolLookup(interface_name, scope);
if (existing_symbol) {
String *proxy_class_name = Getattr(n, "sym:name");
Swig_error(input_file, line_number, "The interface feature name '%s' for proxy class '%s' is already defined in the generated target language module in scope '%s'.\n",
interface_name, proxy_class_name, scope);
Swig_error(Getfile(existing_symbol), Getline(existing_symbol), "Previous declaration of '%s'\n", interface_name);
return 0;
}
if (!addSymbol(interface_name, n, scope))
return 0;
}
return 1;
}
/* -----------------------------------------------------------------------------
* Language::symbolAddScope()
*
@ -3214,7 +3239,7 @@ void Language::dumpSymbols() {
* Language::symbolLookup()
* ----------------------------------------------------------------------------- */
Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
Node *Language::symbolLookup(const String *s, const_String_or_char_ptr scope) {
Hash *symbols = Getattr(symtabs, scope ? scope : "");
if (!symbols) {
return NULL;
@ -3797,6 +3822,7 @@ String *Language::defaultExternalRuntimeFilename() {
/* -----------------------------------------------------------------------------
* Language::replaceSpecialVariables()
*
* Language modules should implement this if special variables are to be handled
* correctly in the $typemap(...) special variable macro.
* method - typemap method name
@ -3816,3 +3842,4 @@ Language *Language::instance() {
Hash *Language::getClassHash() const {
return classhash;
}

View file

@ -2176,20 +2176,24 @@ MODULA3():
/* Deal with inheritance */
List *baselist = Getattr(n, "bases");
if (baselist != NIL) {
if (baselist) {
Iterator base = First(baselist);
if (base.item) {
c_baseclassname = Getattr(base.item, "name");
baseclass = Copy(getProxyName(c_baseclassname));
if (baseclass) {
c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
while (base.item) {
if (!GetFlag(base.item, "feature:ignore")) {
String *baseclassname = Getattr(base.item, "name");
if (!c_baseclassname) {
c_baseclassname = baseclassname;
baseclass = Copy(getProxyName(baseclassname));
if (baseclass)
c_baseclass = SwigType_namestr(baseclassname);
} else {
/* Warn about multiple inheritance for additional base class(es) */
String *proxyclassname = Getattr(n, "classtypeobj");
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s, base %s ignored. Multiple inheritance is not supported in Modula 3.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
}
}
base = Next(base);
if (base.item != NIL) {
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
name, Getattr(base.item, "name"));
}
}
}
@ -2201,7 +2205,7 @@ MODULA3():
const String *pure_baseclass = typemapLookup(n, "m3base", name, WARN_NONE);
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", name, pure_baseclass);
"Warning for %s, base %s ignored. Multiple inheritance is not supported in Modula 3.\n", name, pure_baseclass);
}
// Pure Modula 3 interfaces
const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces",
@ -2431,7 +2435,7 @@ MODULA3():
base = Next(base);
if (base.item) {
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
"Warning for %s, base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
proxy_class_name, Getattr(base.item, "name"));
}
}

View file

@ -2018,7 +2018,7 @@ done:
String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
Swig_warning(WARN_PHP_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in PHP.\n", proxyclassname, baseclassname);
"Warning for %s, base %s ignored. Multiple inheritance is not supported in PHP.\n", proxyclassname, baseclassname);
base = Next(base);
}
}

View file

@ -2473,7 +2473,7 @@ public:
String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Ruby.\n", proxyclassname, baseclassname);
"Warning for %s, base %s ignored. Multiple inheritance is not supported in Ruby.\n", proxyclassname, baseclassname);
base = Next(base);
}
}

View file

@ -208,8 +208,9 @@ public:
/* Miscellaneous */
virtual int validIdentifier(String *s); /* valid identifier? */
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
virtual int addInterfaceSymbol(const String *interface_name, Node *n, const_String_or_char_ptr scope = "");
virtual void dumpSymbols();
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
virtual Node *symbolLookup(const String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
virtual Hash* symbolAddScope(const_String_or_char_ptr scope);
virtual Hash* symbolScopeLookup(const_String_or_char_ptr scope);
virtual Hash* symbolScopePseudoSymbolLookup(const_String_or_char_ptr scope);
@ -422,19 +423,24 @@ extern "C" {
}
/* Contracts */
void Swig_contracts(Node *n);
void Swig_contract_mode_set(int flag);
int Swig_contract_mode_get();
/* Browser */
void Swig_browser(Node *n, int);
void Swig_default_allocators(Node *n);
void Swig_process_types(Node *n);
/* Nested classes */
void Swig_nested_process_classes(Node *n);
void Swig_nested_name_unnamed_c_structs(Node *n);
/* Interface feature */
void Swig_interface_feature_enable();
void Swig_interface_propagate_methods(Node *n);
/* Miscellaneous */
template <class T> class save_value {
T _value;
T& _value_ptr;

View file

@ -1147,6 +1147,39 @@ String *Swig_string_strip(String *s) {
return ns;
}
/* -----------------------------------------------------------------------------
* Swig_string_rstrip()
*
* Strip given suffix from identifiers
*
* Printf(stderr,"%(rstrip:[Cls])s","HelloCls") -> Hello
* ----------------------------------------------------------------------------- */
String *Swig_string_rstrip(String *s) {
String *ns;
int len = Len(s);
if (!len) {
ns = NewString(s);
} else {
const char *cs = Char(s);
const char *ce = Strchr(cs, ']');
if (*cs != '[' || !ce) {
ns = NewString(s);
} else {
String *fmt = NewStringf("%%.%ds", ce-cs-1);
String *suffix = NewStringf(fmt, cs+1);
int suffix_len = Len(suffix);
if (0 == Strncmp(cs+len-suffix_len, suffix, suffix_len)) {
int copy_len = len-suffix_len-(ce+1-cs);
ns = NewStringWithSize(ce+1, copy_len);
} else {
ns = NewString(ce+1);
}
}
}
return ns;
}
/* -----------------------------------------------------------------------------
* Swig_offset_string()
*
@ -1328,7 +1361,7 @@ String *replace_captures(int num_captures, const char *input, String *subst, int
*
* Executes a regular expression substitution. For example:
*
* Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
* Printf(stderr,"gsl%(regex:/GSL_(.*)_/\\1/)s", "GSL_Hello_") -> gslHello
* ----------------------------------------------------------------------------- */
String *Swig_string_regex(String *s) {
const int pcre_options = 0;
@ -1403,6 +1436,7 @@ void Swig_init() {
DohEncoding("command", Swig_string_command);
DohEncoding("schemify", Swig_string_schemify);
DohEncoding("strip", Swig_string_strip);
DohEncoding("rstrip", Swig_string_rstrip);
DohEncoding("regex", Swig_string_regex);
/* aliases for the case encoders */

View file

@ -466,8 +466,7 @@ static DOH *get_object(Hash *n, String *decl) {
return rn;
}
static
DOH *name_object_get(Hash *namehash, String *tname, SwigType *decl, SwigType *ncdecl) {
static DOH *name_object_get(Hash *namehash, String *tname, SwigType *decl, SwigType *ncdecl) {
DOH *rn = 0;
Hash *n = Getattr(namehash, tname);
if (n) {
@ -646,8 +645,7 @@ static void merge_features(Hash *features, Node *n) {
* the declaration, decl.
* ----------------------------------------------------------------------------- */
static
void features_get(Hash *features, const String *tname, SwigType *decl, SwigType *ncdecl, Node *node) {
static void features_get(Hash *features, const String *tname, SwigType *decl, SwigType *ncdecl, Node *node) {
Node *n = Getattr(features, tname);
#ifdef SWIG_DEBUG
Printf(stdout, " features_get: %s\n", tname);
@ -844,41 +842,41 @@ void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *d
* ----------------------------------------------------------------------------- */
static Hash *namewarn_hash = 0;
Hash *Swig_name_namewarn_hash() {
static Hash *name_namewarn_hash() {
if (!namewarn_hash)
namewarn_hash = NewHash();
return namewarn_hash;
}
static Hash *rename_hash = 0;
Hash *Swig_name_rename_hash() {
static Hash *name_rename_hash() {
if (!rename_hash)
rename_hash = NewHash();
return rename_hash;
}
static List *namewarn_list = 0;
List *Swig_name_namewarn_list() {
static List *name_namewarn_list() {
if (!namewarn_list)
namewarn_list = NewList();
return namewarn_list;
}
static List *rename_list = 0;
List *Swig_name_rename_list() {
static List *name_rename_list() {
if (!rename_list)
rename_list = NewList();
return rename_list;
}
/* -----------------------------------------------------------------------------
* int Swig_need_name_warning(Node *n)
* int need_name_warning(Node *n)
*
* Detects if a node needs name warnings
*
* ----------------------------------------------------------------------------- */
int Swig_need_name_warning(Node *n) {
static int need_name_warning(Node *n) {
int need = 1;
/*
We don't use name warnings for:
@ -1061,13 +1059,13 @@ int Swig_need_protected(Node *n) {
}
/* -----------------------------------------------------------------------------
* void Swig_name_nameobj_add()
* void name_nameobj_add()
*
* Add nameobj (rename/namewarn)
*
* ----------------------------------------------------------------------------- */
static List *Swig_make_attrlist(const char *ckey) {
static List *make_attrlist(const char *ckey) {
List *list = NewList();
const char *cattr = strchr(ckey, '$');
if (cattr) {
@ -1089,7 +1087,7 @@ static List *Swig_make_attrlist(const char *ckey) {
return list;
}
static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
static void name_object_attach_keys(const char *keys[], Hash *nameobj) {
Node *kw = nextSibling(nameobj);
List *matchlist = 0;
while (kw) {
@ -1105,7 +1103,7 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
|| (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0))
|| (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) {
Hash *mi = NewHash();
List *attrlist = Swig_make_attrlist(ckey);
List *attrlist = make_attrlist(ckey);
if (!matchlist)
matchlist = NewList();
Setattr(mi, "value", Getattr(kw, "value"));
@ -1135,7 +1133,7 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
}
}
void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, String *name, SwigType *decl, Hash *nameobj) {
static void name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, String *name, SwigType *decl, Hash *nameobj) {
String *nname = 0;
if (name && Len(name)) {
String *target_fmt = Getattr(nameobj, "targetfmt");
@ -1164,13 +1162,13 @@ void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, Str
}
/* -----------------------------------------------------------------------------
* int Swig_name_match_nameobj()
* int name_match_nameobj()
*
* Apply and check the nameobj's math list to the node
*
* ----------------------------------------------------------------------------- */
static DOH *Swig_get_lattr(Node *n, List *lattr) {
static DOH *get_lattr(Node *n, List *lattr) {
DOH *res = 0;
int ilen = Len(lattr);
int i;
@ -1192,7 +1190,7 @@ static DOH *Swig_get_lattr(Node *n, List *lattr) {
#ifdef HAVE_PCRE
#include <pcre.h>
int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
static int name_regexmatch_value(Node *n, String *pattern, String *s) {
pcre *compiled_pat;
const char *err;
int errpos;
@ -1224,7 +1222,7 @@ int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
#else /* !HAVE_PCRE */
int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
static int name_regexmatch_value(Node *n, String *pattern, String *s) {
(void)pattern;
(void)s;
Swig_error("SWIG", Getline(n),
@ -1234,7 +1232,7 @@ int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
#endif /* HAVE_PCRE/!HAVE_PCRE */
int Swig_name_match_value(String *mvalue, String *value) {
static int name_match_value(String *mvalue, String *value) {
#if defined(SWIG_USE_SIMPLE_MATCHOR)
int match = 0;
char *cvalue = Char(value);
@ -1260,12 +1258,11 @@ int Swig_name_match_value(String *mvalue, String *value) {
#endif
}
int Swig_name_match_nameobj(Hash *rn, Node *n) {
static int name_match_nameobj(Hash *rn, Node *n) {
int match = 1;
List *matchlist = Getattr(rn, "matchlist");
#ifdef SWIG_DEBUG
Printf(stdout, "Swig_name_match_nameobj: %s\n", Getattr(n, "name"));
Printf(stdout, "name_match_nameobj: %s\n", Getattr(n, "name"));
#endif
if (matchlist) {
int ilen = Len(matchlist);
@ -1273,14 +1270,14 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
for (i = 0; match && (i < ilen); ++i) {
Node *mi = Getitem(matchlist, i);
List *lattr = Getattr(mi, "attrlist");
String *nval = Swig_get_lattr(n, lattr);
String *nval = get_lattr(n, lattr);
int notmatch = GetFlag(mi, "notmatch");
int regexmatch = GetFlag(mi, "regexmatch");
match = 0;
if (nval) {
String *kwval = Getattr(mi, "value");
match = regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
: Swig_name_match_value(kwval, nval);
match = regexmatch ? name_regexmatch_value(n, kwval, nval)
: name_match_value(kwval, nval);
#ifdef SWIG_DEBUG
Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen);
#endif
@ -1290,19 +1287,19 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
}
}
#ifdef SWIG_DEBUG
Printf(stdout, "Swig_name_match_nameobj: %d\n", match);
Printf(stdout, "name_match_nameobj: %d\n", match);
#endif
return match;
}
/* -----------------------------------------------------------------------------
* Hash *Swig_name_nameobj_lget()
* Hash *name_nameobj_lget()
*
* Get a nameobj (rename/namewarn) from the list of filters
*
* ----------------------------------------------------------------------------- */
Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *name, String *decl) {
static Hash *name_nameobj_lget(List *namelist, Node *n, String *prefix, String *name, String *decl) {
Hash *res = 0;
if (namelist) {
int len = Len(namelist);
@ -1313,7 +1310,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
String *rdecl = Getattr(rn, "decl");
if (rdecl && (!decl || !Equal(rdecl, decl))) {
continue;
} else if (Swig_name_match_nameobj(rn, n)) {
} else if (name_match_nameobj(rn, n)) {
String *tname = Getattr(rn, "targetname");
if (tname) {
String *sfmt = Getattr(rn, "sourcefmt");
@ -1336,8 +1333,8 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
DohIncref(name);
}
}
match = regextarget ? Swig_name_regexmatch_value(n, tname, sname)
: Swig_name_match_value(tname, sname);
match = regextarget ? name_regexmatch_value(n, tname, sname)
: name_match_value(tname, sname);
Delete(sname);
} else {
/* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */
@ -1367,23 +1364,23 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn) {
const char *namewrn_keys[] = { "rename", "error", "fullname", "sourcefmt", "targetfmt", 0 };
Swig_name_object_attach_keys(namewrn_keys, namewrn);
Swig_name_nameobj_add(Swig_name_namewarn_hash(), Swig_name_namewarn_list(), prefix, name, decl, namewrn);
name_object_attach_keys(namewrn_keys, namewrn);
name_nameobj_add(name_namewarn_hash(), name_namewarn_list(), prefix, name, decl, namewrn);
}
/* -----------------------------------------------------------------------------
* Hash *Swig_name_namewarn_get()
* Hash *name_namewarn_get()
*
* Return the namewarn object, if there is one.
*
* ----------------------------------------------------------------------------- */
Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl) {
static Hash *name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl) {
if (!namewarn_hash && !namewarn_list)
return 0;
if (n) {
/* Return in the obvious cases */
if (!name || !Swig_need_name_warning(n)) {
if (!name || !need_name_warning(n)) {
return 0;
} else {
String *access = Getattr(n, "access");
@ -1395,11 +1392,11 @@ Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *de
}
if (name) {
/* Check to see if the name is in the hash */
Hash *wrn = Swig_name_object_get(Swig_name_namewarn_hash(), prefix, name, decl);
if (wrn && !Swig_name_match_nameobj(wrn, n))
Hash *wrn = Swig_name_object_get(name_namewarn_hash(), prefix, name, decl);
if (wrn && !name_match_nameobj(wrn, n))
wrn = 0;
if (!wrn) {
wrn = Swig_name_nameobj_lget(Swig_name_namewarn_list(), n, prefix, name, decl);
wrn = name_nameobj_lget(name_namewarn_list(), n, prefix, name, decl);
}
if (wrn && Getattr(wrn, "error")) {
if (n) {
@ -1422,7 +1419,7 @@ Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *de
* ----------------------------------------------------------------------------- */
String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl) {
Hash *wrn = Swig_name_namewarn_get(n, prefix, name, decl);
Hash *wrn = name_namewarn_get(n, prefix, name, decl);
return (name && wrn) ? Getattr(wrn, "name") : 0;
}
@ -1434,7 +1431,7 @@ String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl)
* ----------------------------------------------------------------------------- */
static void single_rename_add(String *prefix, String *name, SwigType *decl, Hash *newname) {
Swig_name_nameobj_add(Swig_name_rename_hash(), Swig_name_rename_list(), prefix, name, decl, newname);
name_nameobj_add(name_rename_hash(), name_rename_list(), prefix, name, decl, newname);
}
/* Add a new rename. Works much like new_feature including default argument handling. */
@ -1443,7 +1440,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne
ParmList *declparms = declaratorparms;
const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "regextarget", 0 };
Swig_name_object_attach_keys(rename_keys, newname);
name_object_attach_keys(rename_keys, newname);
/* Add the name */
single_rename_add(prefix, name, decl, newname);
@ -1556,11 +1553,10 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
}
}
if (rename_hash || rename_list || namewarn_hash || namewarn_list) {
Hash *rn = Swig_name_object_get(Swig_name_rename_hash(), prefix, name, decl);
if (!rn || !Swig_name_match_nameobj(rn, n)) {
rn = Swig_name_nameobj_lget(Swig_name_rename_list(), n, prefix, name, decl);
Hash *rn = Swig_name_object_get(name_rename_hash(), prefix, name, decl);
if (!rn || !name_match_nameobj(rn, n)) {
rn = name_nameobj_lget(name_rename_list(), n, prefix, name, decl);
if (rn) {
String *sfmt = Getattr(rn, "sourcefmt");
int fullname = GetFlag(rn, "fullname");
@ -1596,7 +1592,7 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
}
}
nname = result ? result : name;
wrn = Swig_name_namewarn_get(n, prefix, nname, decl);
wrn = name_namewarn_get(n, prefix, nname, decl);
if (wrn) {
String *rename = Getattr(wrn, "rename");
if (rename) {
@ -1641,14 +1637,14 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
/* -----------------------------------------------------------------------------
* void Swig_name_inherit()
*
* Inherit namewarn,rename, and feature objects
* Inherit namewarn, rename, and feature objects
*
* ----------------------------------------------------------------------------- */
void Swig_name_inherit(String *base, String *derived) {
/* Printf(stdout,"base = '%s', derived = '%s'\n", base, derived); */
Swig_name_object_inherit(Swig_name_rename_hash(), base, derived);
Swig_name_object_inherit(Swig_name_namewarn_hash(), base, derived);
Swig_name_object_inherit(name_rename_hash(), base, derived);
Swig_name_object_inherit(name_namewarn_hash(), base, derived);
Swig_name_object_inherit(Swig_cparse_features(), base, derived);
}

View file

@ -283,13 +283,11 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Swig_naming_init(void);
extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
extern Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl);
extern void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *namewrn, ParmList *declaratorparms);
extern void Swig_name_inherit(String *base, String *derived);
extern List *Swig_make_inherit_list(String *clsname, List *names, String *Namespaceprefix);
extern void Swig_inherit_base_symbols(List *bases);
extern int Swig_need_protected(Node *n);
extern int Swig_need_name_warning(Node *n);
extern int Swig_need_redefined_warn(Node *a, Node *b, int InClass);
extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname);