ekg2  GIT master
python.h
Idź do dokumentacji tego pliku.
1 /* $Id$ */
2 
3 /*
4  * (C) Copyright 2004-2005 Leszek Krupiński <leafnode@pld-linux.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License Version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifndef __PYTHON_H_
21 #define __PYTHON_H_
22 
23 #include <sys/types.h> /* on Solaris we need to include it before Python,
24  but I think this shouldn't make problems on others */
25 #include <Python.h>
26 #include <ekg/scripts.h>
27 
28 #if !defined(Py_RETURN_NONE) // New in Python 2.4
29 static inline PyObject* doPy_RETURN_NONE()
30 { Py_INCREF(Py_None); return Py_None; }
31 #define Py_RETURN_NONE return doPy_RETURN_NONE()
32 #endif
33 
34 #if !defined(Py_RETURN_TRUE) // New in Python 2.4
35 static inline PyObject* doPy_RETURN_TRUE()
36 {Py_INCREF(Py_True); return Py_True;}
37 # define Py_RETURN_TRUE return doPy_RETURN_TRUE()
38 #endif
39 
40 #if !defined(Py_RETURN_FALSE) // New in Python 2.4
41 static inline PyObject* doPy_RETURN_FALSE()
42 {Py_INCREF(Py_False); return Py_False;}
43 #define Py_RETURN_FALSE return doPy_RETURN_FALSE()
44 #endif
45 
47 
48 #define python_module(s) ((PyObject *) script_private_get(s)) /* obiekt modułu */
49 
50 #define PYTHON_HANDLE_HEADER(event, arg) \
51 { \
52  PyObject *__py_r; \
53  PyObject *pArgs = arg;\
54  python_handle_result = -1;\
55  \
56  __py_r = PyObject_Call(event, pArgs, NULL);\
57  \
58  if (__py_r && PyInt_Check(__py_r)) { \
59  python_handle_result = PyInt_AsLong(__py_r); \
60  } else if (!__py_r) {\
61  char *err = python_geterror(scr);\
62  print("script_error", err);\
63  xfree(err);\
64  }
65 
66 #define PYTHON_HANDLE_FOOTER() \
67  Py_XDECREF(__py_r); \
68  Py_DECREF(pArgs);\
69  \
70 }
71 
72 int python_run(const char *filename);
73 int python_exec(const char *command);
74 int python_run(const char *filename);
75 int python_autorun();
76 int python_initialize();
77 int python_finalize();
78 int python_plugin_init();
79 script_t *python_find_script(PyObject *module);
80 int python_load(script_t *s);
82 char *python_geterror(script_t *s);
83 PyObject *python_get_func(PyObject *module, const char *name);
84 
85 
86 #endif
87 
88 /*
89  * Local Variables:
90  * mode: c
91  * c-file-style: "k&r"
92  * c-basic-offset: 8
93  * indent-tabs-mode: t
94  * End:
95  * vim: sts=8 sw=8
96  */
static PyObject * doPy_RETURN_TRUE()
Definition: python.h:35
int python_autorun()
script_t * python_find_script(PyObject *module)
Definition: python.c:341
static PyObject * doPy_RETURN_NONE()
Definition: python.h:29
Definition: scripts.h:29
char * python_geterror(script_t *s)
Definition: python.c:358
Definition: commands.h:63
int python_exec(const char *command)
Definition: python.c:279
int python_plugin_init()
PyObject * python_get_func(PyObject *module, const char *name)
Definition: python.c:329
int python_finalize()
Definition: python.c:590
int python_unload(script_t *s)
Definition: python.c:486
Definition: scripts.h:99
int python_run(const char *filename)
Definition: python.c:307
const char * name
Definition: remote.c:88
static PyObject * doPy_RETURN_FALSE()
Definition: python.h:41
int python_load(script_t *s)
Definition: python.c:442
#define s
int python_initialize()
Definition: python.c:528
scriptlang_t python_lang
Definition: python.c:46