1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
From: Stephane Glondu <steph@glondu.net>
Date: Fri, 5 Jun 2009 17:11:04 +0200
Subject: Wrap Py_* calls
This patch wraps calls to Python API macros that used to be functions.
History:
* first provided by Christopher L. Conway (Closes: #477010)
* adapted for Python 2.6 by Stephane Glondu (Closes: #531806)
---
pycaml_ml.c | 48 ++++++++++++++++++++++++++++++++++++------------
1 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/pycaml_ml.c b/pycaml_ml.c
index 0edb262..f9ea0e4 100644
--- a/pycaml_ml.c
+++ b/pycaml_ml.c
@@ -897,6 +897,30 @@ value pyunwrapvalue( value cb ) {
CAMLreturn(*v);
}
+int wrap_PyRun_SimpleString(const char *s) { return PyRun_SimpleString(s); }
+int wrap_PyRun_AnyFile(FILE *f, const char * p) { return PyRun_AnyFile(f,p); }
+int wrap_PyRun_AnyFileEx(FILE *f, const char * p, int c) { return PyRun_AnyFileEx(f,p,c); }
+int wrap_PyRun_SimpleFile(FILE *f, const char * p) { return PyRun_SimpleFile(f,p); }
+int wrap_PyRun_SimpleFileEx(FILE *f, const char * p, int c) { return PyRun_SimpleFileEx(f,p,c); }
+int wrap_PyRun_InteractiveOne(FILE *f, const char * p) { return PyRun_InteractiveOne(f,p); }
+int wrap_PyRun_InteractiveLoop(FILE *f, const char * p) { return PyRun_InteractiveLoop(f,p); }
+PyObject * wrap_PyRun_String(const char *str, int s, PyObject * g, PyObject * l) {
+ return PyRun_String(str,s,g,l);
+}
+PyObject * wrap_PyRun_File(FILE *f, const char *p, int s, PyObject * g, PyObject * l) {
+ return PyRun_File(f,p,s,g,l);
+}
+PyObject *wrap_PyRun_FileEx(FILE *f, const char *p, int s, PyObject * g, PyObject * l,int c) {
+ return PyRun_FileEx(f,p,s,g,l,c);
+}
+PyObject * wrap_Py_CompileString(const char *str, const char *p, int s) {
+ return Py_CompileString(str,p,s);
+}
+PyObject *wrap_PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist) {
+ return PyImport_ImportModuleEx(name, globals, locals, fromlist);
+}
+
+
/* Create the function table */
typedef struct _python_func_table {
@@ -919,16 +943,16 @@ python_func_table the_python_func_table[] = {
/* 4 */
{ (void *)Py_IsInitialized, 4, "Py_IsInitialized" },
/* 5 */
- { (void *)PyRun_SimpleString, 5, "PyRun_SimpleString" },
+ { (void *)wrap_PyRun_SimpleString, 5, "PyRun_SimpleString" },
/* 6 */
- { (void *)PyRun_AnyFile, 6, "PyRun_AnyFile" },
- { (void *)PyRun_SimpleFile, 6, "PyRun_SimpleFile" },
- { (void *)PyRun_InteractiveOne, 6, "PyRun_InteractiveOne" },
- { (void *)PyRun_InteractiveLoop, 6, "PyRun_InteractiveLoop" },
+ { (void *)wrap_PyRun_AnyFile, 6, "PyRun_AnyFile" },
+ { (void *)wrap_PyRun_SimpleFile, 6, "PyRun_SimpleFile" },
+ { (void *)wrap_PyRun_InteractiveOne, 6, "PyRun_InteractiveOne" },
+ { (void *)wrap_PyRun_InteractiveLoop, 6, "PyRun_InteractiveLoop" },
{ (void *)Py_FdIsInteractive, 6, "Py_FdIsInteractive" },
/* 7 */
- { (void *)PyRun_AnyFileEx, 7, "PyRun_AnyFileEx" },
- { (void *)PyRun_SimpleFileEx, 7, "PyRun_SimpleFileEx" },
+ { (void *)wrap_PyRun_AnyFileEx, 7, "PyRun_AnyFileEx" },
+ { (void *)wrap_PyRun_SimpleFileEx, 7, "PyRun_SimpleFileEx" },
/* 8 */
{ (void *)Py_GetProgramName, 8, "Py_GetProgramName" },
{ (void *)Py_GetPythonHome, 8, "Py_GetPythonHome" },
@@ -942,13 +966,13 @@ python_func_table the_python_func_table[] = {
{ (void *)Py_GetCompiler, 8, "Py_GetCompiler" },
{ (void *)Py_GetBuildInfo, 8, "Py_GetBuildInfo" },
/* 9 */
- { (void *)PyRun_String, 9, "PyRun_String" },
+ { (void *)wrap_PyRun_String, 9, "PyRun_String" },
/* 10 */
- { (void *)PyRun_File, 10, "PyRun_File" },
+ { (void *)wrap_PyRun_File, 10, "PyRun_File" },
/* 11 */
- { (void *)PyRun_FileEx, 11, "PyRun_FileEx" },
+ { (void *)wrap_PyRun_FileEx, 11, "PyRun_FileEx" },
/* 12 */
- { (void *)Py_CompileString, 12, "Py_CompileString" },
+ { (void *)wrap_Py_CompileString, 12, "Py_CompileString" },
/* Object */
/* 13 */
@@ -1125,7 +1149,7 @@ python_func_table the_python_func_table[] = {
{ (void *)PyImport_AddModule, 28, "PyImport_AddModule" },
{ (void *)PyImport_ImportModule, 28, "PyImport_ImportModule" },
/* 51 */
-{ (void *)PyImport_ImportModuleEx, 51, "PyImport_ImportModuleEx" },
+{ (void *)wrap_PyImport_ImportModuleEx, 51, "PyImport_ImportModuleEx" },
/* 28 */
{ (void *)PyImport_Import, 28, "PyImport_Import" },
/* 14 */
--
|