summaryrefslogtreecommitdiff
path: root/Examples/python/import
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/python/import')
-rw-r--r--Examples/python/import/Makefile22
-rw-r--r--Examples/python/import/README39
-rw-r--r--Examples/python/import/bar.dsp144
-rw-r--r--Examples/python/import/bar.h22
-rw-r--r--Examples/python/import/bar.i9
-rw-r--r--Examples/python/import/base.dsp144
-rw-r--r--Examples/python/import/base.h18
-rw-r--r--Examples/python/import/base.i6
-rw-r--r--Examples/python/import/example.dsw65
-rw-r--r--Examples/python/import/foo.dsp144
-rw-r--r--Examples/python/import/foo.h21
-rw-r--r--Examples/python/import/foo.i8
-rw-r--r--Examples/python/import/runme.py111
-rw-r--r--Examples/python/import/spam.dsp144
-rw-r--r--Examples/python/import/spam.h24
-rw-r--r--Examples/python/import/spam.i9
16 files changed, 930 insertions, 0 deletions
diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile
new file mode 100644
index 0000000..74d4f88
--- /dev/null
+++ b/Examples/python/import/Makefile
@@ -0,0 +1,22 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT =
+LIBS =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
+ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+ LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp
+
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ @rm -f foo.py bar.py spam.py base.py
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/import/README b/Examples/python/import/README
new file mode 100644
index 0000000..5679dbb
--- /dev/null
+++ b/Examples/python/import/README
@@ -0,0 +1,39 @@
+This example tests the %import directive and working with multiple modules.
+
+Use 'python runme.py' to run a test.
+
+Overview:
+---------
+
+The example defines 4 different extension modules--each wrapping
+a separate C++ class.
+
+ base.i - Base class
+ foo.i - Foo class derived from Base
+ bar.i - Bar class derived from Base
+ spam.i - Spam class derived from Bar
+
+Each module uses %import to refer to another module. For
+example, the 'foo.i' module uses '%import base.i' to get
+definitions for its base class.
+
+If everything is okay, all of the modules will load properly and
+type checking will work correctly. Caveat: Some compilers, for example
+gcc-3.2.x, generate broken vtables with the inline methods in this test.
+This is not a SWIG problem and can usually be solved with non-inlined
+destructors compiled into separate shared objects/DLLs.
+
+Unix:
+-----
+- Run make
+- Run the test as described above
+
+Windows:
+--------
+- Use the Visual C++ 6 workspace file (example.dsw). Build the runtime
+ project DLL first followed by the other 4 DLLs as they all have a
+ dependency on the runtime DLL. The Batch build option in the Build menu
+ is usually the easiest way to do this. Only use the Release builds not
+ the Debug builds.
+- Run the test as described above
+
diff --git a/Examples/python/import/bar.dsp b/Examples/python/import/bar.dsp
new file mode 100644
index 0000000..17b05cc
--- /dev/null
+++ b/Examples/python/import/bar.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="bar" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=bar - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "bar.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "bar.mak" CFG="bar - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "bar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "bar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "bar - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_bar.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "bar - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_bar.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "bar - Win32 Debug"
+# Name "bar - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\bar_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\bar.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\bar.i
+
+!IF "$(CFG)" == "bar - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\bar.i
+InputName=bar
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "bar - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\bar.i
+InputName=bar
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/python/import/bar.h b/Examples/python/import/bar.h
new file mode 100644
index 0000000..fa4185f
--- /dev/null
+++ b/Examples/python/import/bar.h
@@ -0,0 +1,22 @@
+#include "base.h"
+
+class Bar : public Base {
+ public:
+ Bar() { }
+ ~Bar() { }
+ virtual void A() {
+ printf("I'm Bar::A\n");
+ }
+ void B() {
+ printf("I'm Bar::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ static Bar *fromBase(Base *b) {
+ return dynamic_cast<Bar *>(b);
+ }
+
+};
+
+
diff --git a/Examples/python/import/bar.i b/Examples/python/import/bar.i
new file mode 100644
index 0000000..5816cbe
--- /dev/null
+++ b/Examples/python/import/bar.i
@@ -0,0 +1,9 @@
+%module bar
+%{
+#include "bar.h"
+%}
+
+%import base.i
+%include "bar.h"
+
+
diff --git a/Examples/python/import/base.dsp b/Examples/python/import/base.dsp
new file mode 100644
index 0000000..2bc9736
--- /dev/null
+++ b/Examples/python/import/base.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="base" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=base - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "base.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "base.mak" CFG="base - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "base - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "base - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "base - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_base.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "base - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_base.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "base - Win32 Debug"
+# Name "base - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\base_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\base.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\base.i
+
+!IF "$(CFG)" == "base - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\base.i
+InputName=base
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "base - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\base.i
+InputName=base
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/python/import/base.h b/Examples/python/import/base.h
new file mode 100644
index 0000000..5a266f6
--- /dev/null
+++ b/Examples/python/import/base.h
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+class Base {
+ public:
+ Base() { };
+ virtual ~Base() { };
+ virtual void A() {
+ printf("I'm Base::A\n");
+ }
+ void B() {
+ printf("I'm Base::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+};
+
+
diff --git a/Examples/python/import/base.i b/Examples/python/import/base.i
new file mode 100644
index 0000000..f6e19ef
--- /dev/null
+++ b/Examples/python/import/base.i
@@ -0,0 +1,6 @@
+%module base
+%{
+#include "base.h"
+%}
+
+%include base.h
diff --git a/Examples/python/import/example.dsw b/Examples/python/import/example.dsw
new file mode 100644
index 0000000..d395d46
--- /dev/null
+++ b/Examples/python/import/example.dsw
@@ -0,0 +1,65 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "bar"=.\bar.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "base"=.\base.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "foo"=.\foo.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "spam"=.\spam.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/Examples/python/import/foo.dsp b/Examples/python/import/foo.dsp
new file mode 100644
index 0000000..9a92c4b
--- /dev/null
+++ b/Examples/python/import/foo.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="foo" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=foo - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "foo.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "foo.mak" CFG="foo - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "foo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "foo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "foo - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_foo.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "foo - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_foo.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "foo - Win32 Debug"
+# Name "foo - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\foo_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\foo.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\foo.i
+
+!IF "$(CFG)" == "foo - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\foo.i
+InputName=foo
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "foo - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\foo.i
+InputName=foo
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/python/import/foo.h b/Examples/python/import/foo.h
new file mode 100644
index 0000000..dd51840
--- /dev/null
+++ b/Examples/python/import/foo.h
@@ -0,0 +1,21 @@
+#include "base.h"
+
+class Foo : public Base {
+ public:
+ Foo() { }
+ ~Foo() { }
+ virtual void A() {
+ printf("I'm Foo::A\n");
+ }
+ void B() {
+ printf("I'm Foo::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ static Foo *fromBase(Base *b) {
+ return dynamic_cast<Foo *>(b);
+ }
+};
+
+
diff --git a/Examples/python/import/foo.i b/Examples/python/import/foo.i
new file mode 100644
index 0000000..27feb2e
--- /dev/null
+++ b/Examples/python/import/foo.i
@@ -0,0 +1,8 @@
+%module foo
+%{
+#include "foo.h"
+%}
+
+%import base.i
+%include "foo.h"
+
diff --git a/Examples/python/import/runme.py b/Examples/python/import/runme.py
new file mode 100644
index 0000000..6b800ec
--- /dev/null
+++ b/Examples/python/import/runme.py
@@ -0,0 +1,111 @@
+# file: runme.py
+# Test various properties of classes defined in separate modules
+
+print "Testing the %import directive"
+import base
+import foo
+import bar
+import spam
+
+# Create some objects
+
+print "Creating some objects"
+
+a = base.Base()
+b = foo.Foo()
+c = bar.Bar()
+d = spam.Spam()
+
+# Try calling some methods
+print "Testing some methods"
+print "",
+print "Should see 'Base::A' ---> ",
+a.A()
+print "Should see 'Base::B' ---> ",
+a.B()
+
+print "Should see 'Foo::A' ---> ",
+b.A()
+print "Should see 'Foo::B' ---> ",
+b.B()
+
+print "Should see 'Bar::A' ---> ",
+c.A()
+print "Should see 'Bar::B' ---> ",
+c.B()
+
+print "Should see 'Spam::A' ---> ",
+d.A()
+print "Should see 'Spam::B' ---> ",
+d.B()
+
+# Try some casts
+
+print "\nTesting some casts\n"
+print "",
+
+x = a.toBase()
+print "Should see 'Base::A' ---> ",
+x.A()
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = b.toBase()
+print "Should see 'Foo::A' ---> ",
+x.A()
+
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = c.toBase()
+print "Should see 'Bar::A' ---> ",
+x.A()
+
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = d.toBase()
+print "Should see 'Spam::A' ---> ",
+x.A()
+
+print "Should see 'Base::B' ---> ",
+x.B()
+
+x = d.toBar()
+print "Should see 'Bar::B' ---> ",
+x.B()
+
+print "\nTesting some dynamic casts\n"
+x = d.toBase()
+
+print " Spam -> Base -> Foo : ",
+y = foo.Foo_fromBase(x)
+if y:
+ print "bad swig"
+else:
+ print "good swig"
+
+print " Spam -> Base -> Bar : ",
+y = bar.Bar_fromBase(x)
+if y:
+ print "good swig"
+else:
+ print "bad swig"
+
+print " Spam -> Base -> Spam : ",
+y = spam.Spam_fromBase(x)
+if y:
+ print "good swig"
+else:
+ print "bad swig"
+
+print " Foo -> Spam : ",
+y = spam.Spam_fromBase(b)
+if y:
+ print "bad swig"
+else:
+ print "good swig"
+
+
+
+
diff --git a/Examples/python/import/spam.dsp b/Examples/python/import/spam.dsp
new file mode 100644
index 0000000..0a6595b
--- /dev/null
+++ b/Examples/python/import/spam.dsp
@@ -0,0 +1,144 @@
+# Microsoft Developer Studio Project File - Name="spam" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=spam - Win32 Release
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "spam.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "spam.mak" CFG="spam - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "spam - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "spam - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "spam - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_spam.pyd" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "spam - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_spam.pyd"
+
+!ENDIF
+
+# Begin Target
+
+# Name "spam - Win32 Debug"
+# Name "spam - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\spam_wrap.cxx
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\spam.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\spam.i
+
+!IF "$(CFG)" == "spam - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\spam.i
+InputName=spam
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "spam - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\spam.i
+InputName=spam
+
+"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ echo In order to function correctly, please ensure the following environment variables are correctly set:
+ echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
+ echo PYTHON_LIB: %PYTHON_LIB%
+ echo on
+ ..\..\..\swig.exe -c++ -python $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
diff --git a/Examples/python/import/spam.h b/Examples/python/import/spam.h
new file mode 100644
index 0000000..b4e7a26
--- /dev/null
+++ b/Examples/python/import/spam.h
@@ -0,0 +1,24 @@
+#include "bar.h"
+
+class Spam : public Bar {
+ public:
+ Spam() { }
+ ~Spam() { }
+ virtual void A() {
+ printf("I'm Spam::A\n");
+ }
+ void B() {
+ printf("I'm Spam::B\n");
+ }
+ virtual Base *toBase() {
+ return static_cast<Base *>(this);
+ }
+ virtual Bar *toBar() {
+ return static_cast<Bar *>(this);
+ }
+ static Spam *fromBase(Base *b) {
+ return dynamic_cast<Spam *>(b);
+ }
+};
+
+
diff --git a/Examples/python/import/spam.i b/Examples/python/import/spam.i
new file mode 100644
index 0000000..d3d9121
--- /dev/null
+++ b/Examples/python/import/spam.i
@@ -0,0 +1,9 @@
+%module spam
+%{
+#include "spam.h"
+%}
+
+%import bar.i
+%include "spam.h"
+
+