Idź do dokumentacji tego pliku.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PYTHON_H_
00021 #define __PYTHON_H_
00022
00023 #include <sys/types.h>
00024
00025 #include <Python.h>
00026 #include <ekg/scripts.h>
00027
00028 #if !defined(Py_RETURN_NONE) // New in Python 2.4
00029 static inline PyObject* doPy_RETURN_NONE()
00030 { Py_INCREF(Py_None); return Py_None; }
00031 #define Py_RETURN_NONE return doPy_RETURN_NONE()
00032 #endif
00033
00034 #if !defined(Py_RETURN_TRUE) // New in Python 2.4
00035 static inline PyObject* doPy_RETURN_TRUE()
00036 {Py_INCREF(Py_True); return Py_True;}
00037 # define Py_RETURN_TRUE return doPy_RETURN_TRUE()
00038 #endif
00039
00040 #if !defined(Py_RETURN_FALSE) // New in Python 2.4
00041 static inline PyObject* doPy_RETURN_FALSE()
00042 {Py_INCREF(Py_False); return Py_False;}
00043 #define Py_RETURN_FALSE return doPy_RETURN_FALSE()
00044 #endif
00045
00046 extern scriptlang_t python_lang;
00047
00048 #define python_module(s) ((PyObject *) script_private_get(s))
00049
00050 #define PYTHON_HANDLE_HEADER(event, arg) \
00051 { \
00052 PyObject *__py_r; \
00053 PyObject *pArgs = arg;\
00054 python_handle_result = -1;\
00055 \
00056 __py_r = PyObject_Call(event, pArgs, NULL);\
00057 \
00058 if (__py_r && PyInt_Check(__py_r)) { \
00059 python_handle_result = PyInt_AsLong(__py_r); \
00060 } else if (!__py_r) {\
00061 char *err = python_geterror(scr);\
00062 print("script_error", err);\
00063 xfree(err);\
00064 }
00065
00066 #define PYTHON_HANDLE_FOOTER() \
00067 Py_XDECREF(__py_r); \
00068 Py_DECREF(pArgs);\
00069 \
00070 }
00071
00072 int python_run(const char *filename);
00073 int python_exec(const char *command);
00074 int python_run(const char *filename);
00075 int python_autorun();
00076 int python_initialize();
00077 int python_finalize();
00078 int python_plugin_init();
00079 script_t *python_find_script(PyObject *module);
00080 int python_load(script_t *s);
00081 int python_unload(script_t *s);
00082 char *python_geterror(script_t *s);
00083 PyObject *python_get_func(PyObject *module, const char *name);
00084
00085
00086 #endif
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096