PageRenderTime 50ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1.3.35/Lib/python/embed.i

#
Swig | 115 lines | 80 code | 29 blank | 6 comment | 0 complexity | 9f2db7808dcc6653507e154d638fcae2 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  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. #ifdef AUTODOC
  11. %subsection "embed.i"
  12. %text %{
  13. This module provides support for building a new version of the
  14. Python executable. This will be necessary on systems that do
  15. not support shared libraries and may be necessary with C++
  16. extensions. This file contains everything you need to build
  17. a new version of Python from include files and libraries normally
  18. installed with the Python language.
  19. This module will automatically grab all of the Python modules
  20. present in your current Python executable (including any special
  21. purpose modules you have enabled such as Tkinter). Thus, you
  22. may need to provide additional link libraries when compiling.
  23. This library file only works with Python 1.5. A version
  24. compatible with Python 1.4 is available as embed14.i and
  25. a Python1.3 version is available as embed13.i. As far as
  26. I know, this module is C++ safe.
  27. %}
  28. #else
  29. %echo "embed.i : Using Python 1.5"
  30. #endif
  31. %wrapper %{
  32. #include <Python.h>
  33. #ifdef __cplusplus
  34. extern "C"
  35. #endif
  36. void SWIG_init(); /* Forward reference */
  37. #define _PyImport_Inittab swig_inittab
  38. /* Grab Python's inittab[] structure */
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. #include <config.c>
  43. #undef _PyImport_Inittab
  44. /* Now define our own version of it.
  45. Hopefully someone does not have more than 1000 built-in modules */
  46. struct _inittab SWIG_Import_Inittab[1000];
  47. static int swig_num_modules = 0;
  48. /* Function for adding modules to Python */
  49. static void swig_add_module(char *name, void (*initfunc)()) {
  50. SWIG_Import_Inittab[swig_num_modules].name = name;
  51. SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc;
  52. swig_num_modules++;
  53. SWIG_Import_Inittab[swig_num_modules].name = (char *) 0;
  54. SWIG_Import_Inittab[swig_num_modules].initfunc = 0;
  55. }
  56. /* Function to add all of Python's build in modules to our interpreter */
  57. static void swig_add_builtin() {
  58. int i = 0;
  59. while (swig_inittab[i].name) {
  60. swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc);
  61. i++;
  62. }
  63. #ifdef SWIGMODINIT
  64. SWIGMODINIT
  65. #endif
  66. /* Add SWIG builtin function */
  67. swig_add_module(SWIG_name, SWIG_init);
  68. }
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #ifdef __cplusplus
  73. extern "C" {
  74. #endif
  75. extern int Py_Main(int, char **);
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. extern struct _inittab *PyImport_Inittab;
  80. int
  81. main(int argc, char **argv) {
  82. swig_add_builtin();
  83. PyImport_Inittab = SWIG_Import_Inittab;
  84. return Py_Main(argc,argv);
  85. }
  86. %}