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