mirror of https://github.com/swig/swig
avoid cast list elements, add more debug info, add Rubin's multi-module 'mod'example
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8493 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
24542ed0cd
commit
a6e348b846
|
@ -382,7 +382,8 @@ C_TEST_CASES += \
|
|||
MULTI_CPP_TEST_CASES += \
|
||||
clientdata_prop \
|
||||
imports \
|
||||
template_typedef_import
|
||||
template_typedef_import \
|
||||
mod
|
||||
|
||||
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
|
||||
$(C_TEST_CASES:=.ctest) \
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
|
||||
class C;
|
||||
|
||||
class A
|
||||
{
|
||||
public:
|
||||
A() {}
|
||||
C* GetC() { return NULL; }
|
||||
|
||||
void DoSomething(A* a) {}
|
||||
};
|
||||
|
||||
|
||||
class B : public A
|
||||
{
|
||||
public:
|
||||
B() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class C : public B
|
||||
{
|
||||
public:
|
||||
C() {}
|
||||
};
|
||||
|
||||
|
||||
class D : public C
|
||||
{
|
||||
public:
|
||||
D() {}
|
||||
};
|
|
@ -0,0 +1,2 @@
|
|||
mod_a
|
||||
mod_b
|
|
@ -0,0 +1,24 @@
|
|||
%module mod_a
|
||||
|
||||
%{
|
||||
#include "mod.h"
|
||||
%}
|
||||
|
||||
|
||||
class C;
|
||||
|
||||
class A
|
||||
{
|
||||
public:
|
||||
A() {}
|
||||
C* GetC() { return NULL; }
|
||||
|
||||
void DoSomething(A* a) {}
|
||||
};
|
||||
|
||||
|
||||
class B : public A
|
||||
{
|
||||
public:
|
||||
B();
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
%module mod_b
|
||||
|
||||
%{
|
||||
#include "mod.h"
|
||||
%}
|
||||
|
||||
|
||||
%import mod_a.i
|
||||
|
||||
|
||||
class C : public B
|
||||
{
|
||||
public:
|
||||
C() {}
|
||||
};
|
||||
|
||||
|
||||
class D : public C
|
||||
{
|
||||
public:
|
||||
D() {}
|
||||
};
|
|
@ -0,0 +1,6 @@
|
|||
import mod_a
|
||||
import mod_b
|
||||
|
||||
c = mod_b.C()
|
||||
d = mod_b.D()
|
||||
d.DoSomething(c)
|
|
@ -123,17 +123,23 @@ SWIG_InitializeModule(void *clientdata) {
|
|||
if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
|
||||
#endif
|
||||
}
|
||||
if (ret && type == swig_module.type_initial[i]) {
|
||||
if (ret) {
|
||||
if (type == swig_module.type_initial[i]) {
|
||||
#ifdef SWIGRUNTIME_DEBUG
|
||||
if (ret) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
|
||||
printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
|
||||
#endif
|
||||
cast->type = ret;
|
||||
ret = 0;
|
||||
} else {
|
||||
/* Fix PyICU and many others */
|
||||
ret = 0;
|
||||
cast->type = ret;
|
||||
ret = 0;
|
||||
} else {
|
||||
/* Check for casting already in the list */
|
||||
swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
|
||||
#ifdef SWIGRUNTIME_DEBUG
|
||||
if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
|
||||
#endif
|
||||
if (!ocast) ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!ret) {
|
||||
#ifdef SWIGRUNTIME_DEBUG
|
||||
printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
|
||||
|
@ -146,11 +152,26 @@ SWIG_InitializeModule(void *clientdata) {
|
|||
}
|
||||
cast++;
|
||||
}
|
||||
|
||||
/* Set entry in modules->types array equal to the type */
|
||||
swig_module.types[i] = type;
|
||||
}
|
||||
swig_module.types[i] = 0;
|
||||
|
||||
#ifdef SWIGRUNTIME_DEBUG
|
||||
printf("**** SWIG_InitializeModule: Cast List ******\n");
|
||||
for (i = 0; i < swig_module.size; ++i) {
|
||||
int j = 0;
|
||||
swig_cast_info *cast = swig_module.cast_initial[i];
|
||||
printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
|
||||
while (cast->type) {
|
||||
printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
|
||||
cast++;
|
||||
++j;
|
||||
}
|
||||
printf("---- Total casts: %d\n",j);
|
||||
}
|
||||
printf("**** SWIG_InitializeModule: Cast List ******\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This function will propagate the clientdata field of type to
|
||||
|
|
Loading…
Reference in New Issue