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@8493 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c42b44bf58
commit
c8e5a99ecb
7 changed files with 120 additions and 10 deletions
|
|
@ -382,7 +382,8 @@ C_TEST_CASES += \
|
||||||
MULTI_CPP_TEST_CASES += \
|
MULTI_CPP_TEST_CASES += \
|
||||||
clientdata_prop \
|
clientdata_prop \
|
||||||
imports \
|
imports \
|
||||||
template_typedef_import
|
template_typedef_import \
|
||||||
|
mod
|
||||||
|
|
||||||
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
|
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
|
||||||
$(C_TEST_CASES:=.ctest) \
|
$(C_TEST_CASES:=.ctest) \
|
||||||
|
|
|
||||||
34
SWIG/Examples/test-suite/mod.h
Normal file
34
SWIG/Examples/test-suite/mod.h
Normal file
|
|
@ -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() {}
|
||||||
|
};
|
||||||
2
SWIG/Examples/test-suite/mod.list
Normal file
2
SWIG/Examples/test-suite/mod.list
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
mod_a
|
||||||
|
mod_b
|
||||||
24
SWIG/Examples/test-suite/mod_a.i
Normal file
24
SWIG/Examples/test-suite/mod_a.i
Normal file
|
|
@ -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();
|
||||||
|
};
|
||||||
22
SWIG/Examples/test-suite/mod_b.i
Normal file
22
SWIG/Examples/test-suite/mod_b.i
Normal file
|
|
@ -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() {}
|
||||||
|
};
|
||||||
6
SWIG/Examples/test-suite/python/mod_runme.py
Normal file
6
SWIG/Examples/test-suite/python/mod_runme.py
Normal file
|
|
@ -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);
|
if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (ret && type == swig_module.type_initial[i]) {
|
if (ret) {
|
||||||
|
if (type == swig_module.type_initial[i]) {
|
||||||
#ifdef SWIGRUNTIME_DEBUG
|
#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
|
#endif
|
||||||
cast->type = ret;
|
cast->type = ret;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
/* Fix PyICU and many others */
|
/* Check for casting already in the list */
|
||||||
ret = 0;
|
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) {
|
if (!ret) {
|
||||||
#ifdef SWIGRUNTIME_DEBUG
|
#ifdef SWIGRUNTIME_DEBUG
|
||||||
printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
|
printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
|
||||||
|
|
@ -146,11 +152,26 @@ SWIG_InitializeModule(void *clientdata) {
|
||||||
}
|
}
|
||||||
cast++;
|
cast++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set entry in modules->types array equal to the type */
|
/* Set entry in modules->types array equal to the type */
|
||||||
swig_module.types[i] = type;
|
swig_module.types[i] = type;
|
||||||
}
|
}
|
||||||
swig_module.types[i] = 0;
|
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
|
/* This function will propagate the clientdata field of type to
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue