]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wxSWIG/swig_lib/python/embed.i
Since I have made several changes to SWIG over the years to accomodate
[wxWidgets.git] / wxPython / wxSWIG / swig_lib / python / embed.i
1 //
2 // embed15.i
3 // SWIG file embedding the Python interpreter in something else.
4 // This file is based on Python-1.5. It will not work with
5 // earlier versions.
6 //
7 // This file makes it possible to extend Python and all of its
8 // built-in functions without having to hack it's setup script.
9 //
10
11
12 #ifdef AUTODOC
13 %subsection "embed.i"
14 %text %{
15 This module provides support for building a new version of the
16 Python executable. This will be necessary on systems that do
17 not support shared libraries and may be necessary with C++
18 extensions. This file contains everything you need to build
19 a new version of Python from include files and libraries normally
20 installed with the Python language.
21
22 This module will automatically grab all of the Python modules
23 present in your current Python executable (including any special
24 purpose modules you have enabled such as Tkinter). Thus, you
25 may need to provide additional link libraries when compiling.
26
27 This library file only works with Python 1.5. A version
28 compatible with Python 1.4 is available as embed14.i and
29 a Python1.3 version is available as embed13.i. As far as
30 I know, this module is C++ safe.
31 %}
32 #else
33 %echo "embed.i : Using Python 1.5"
34 #endif
35
36 %wrapper %{
37
38 #include <Python.h>
39
40 #ifdef __cplusplus
41 extern "C"
42 #endif
43 void SWIG_init(); /* Forward reference */
44
45 #define _PyImport_Inittab swig_inittab
46
47 /* Grab Python's inittab[] structure */
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 #include <config.c>
53
54 #undef _PyImport_Inittab
55
56 /* Now define our own version of it.
57 Hopefully someone does not have more than 1000 built-in modules */
58
59 struct _inittab _SwigImport_Inittab[1000];
60
61 static int swig_num_modules = 0;
62
63 /* Function for adding modules to Python */
64
65 static void swig_add_module(char *name, void (*initfunc)()) {
66 _SwigImport_Inittab[swig_num_modules].name = name;
67 _SwigImport_Inittab[swig_num_modules].initfunc = initfunc;
68 swig_num_modules++;
69 _SwigImport_Inittab[swig_num_modules].name = (char *) 0;
70 _SwigImport_Inittab[swig_num_modules].initfunc = 0;
71 }
72
73 /* Function to add all of Python's build in modules to our interpreter */
74
75 static void swig_add_builtin() {
76 int i = 0;
77 while (swig_inittab[i].name) {
78 swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc);
79 i++;
80 }
81 #ifdef SWIGMODINIT
82 SWIGMODINIT
83 #endif
84 /* Add SWIG builtin function */
85 swig_add_module(SWIG_name, SWIG_init);
86 }
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #ifdef __cplusplus
93 extern "C" {
94 #endif
95
96 extern int Py_Main(int, char **);
97
98 #ifdef __cplusplus
99 }
100 #endif
101
102 extern struct _inittab *PyImport_Inittab;
103
104 int
105 main(int argc, char **argv) {
106 swig_add_builtin();
107 PyImport_Inittab = _SwigImport_Inittab;
108 return Py_Main(argc,argv);
109 }
110
111 %}
112
113
114
115