ekg2

plugins/python/python.h

Idź do dokumentacji tego pliku.
00001 /* $Id$ */
00002 
00003 /*
00004  *  (C) Copyright 2004-2005 Leszek Krupiński <leafnode@pld-linux.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License Version 2 as
00008  *  published by the Free Software Foundation.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  */
00019 
00020 #ifndef __PYTHON_H_
00021 #define __PYTHON_H_
00022 
00023 #include <sys/types.h>          /* on Solaris we need to include it before Python,
00024                                    but I think this shouldn't make problems on others */
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)) /* obiekt modułu */
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  * Local Variables:
00090  * mode: c
00091  * c-file-style: "k&r"
00092  * c-basic-offset: 8
00093  * indent-tabs-mode: t
00094  * End:
00095  * vim: sts=8 sw=8
00096  */
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje