29 PyObject *data::globals;
30 PyObject *python::module;
33 PyObject *get_py_obj (
void *instance,
const char* class_name);
64 sprintf ( buf,
"import sys ; sys.path.insert(0, \"%s\")", name );
65 PyRun_SimpleString ( buf );
77 PyRun_SimpleString(s);
89 cerr <<
"exec_file: " << filename <<
" load failed: " << endl;
105 if ( PyErr_Occurred() )
115 PyObject *result = PyImport_ImportModule ((
char *) filename.c_str ());
126 string class_ptr = string(class_name) +
"*";
127 return get_py_obj (instance, class_ptr.c_str());
136 tuple = PyTuple_New (l);
138 for (
u_int32 i = 0; i < l; i++)
150 PyTuple_SetItem (tuple, i, PyString_FromString (ms.c_str ()));
156 PyTuple_SetItem (tuple, i, PyInt_FromLong (j));
165 u_int32 l = PyTuple_Size (tuple);
167 for (
u_int32 i = 0; i < l; i++)
170 PyObject * item = PyTuple_GetItem (tuple, i);
174 if (PyString_Check (item))
177 char * s = PyString_AsString (item);
182 else if (PyInt_Check (item))
185 u_int32 li = PyInt_AsLong (item);
Class to write data from a Gzip compressed file.
static bool exec_file(string filename)
Executes a Python script.
Class to read data from a Gzip compressed file.
static void put_tuple(PyObject *tuple, ogzstream &file)
Save a Python tuple into a file.
#define u_int32
32 bits long unsigned integer
static void show_traceback(void)
Dumps any error information to stderr.
static PyObject * get_tuple(igzstream &file)
Loads a Python tuple previously saved with put_tuple ().
static PyObject * import_module(string filename)
Imports a Python module.
static PyObject * pass_instance(void *instance, const char *class_name)
Magic function that makes any C object available to Python!
Defines the python class. This file is named this way so it doesn't conflicts with Python...
static void exec_string(char *s)
Execute Python statements contained in a string.
static void insert_path(char *name)
Adds a directory to Python's include path.
static void cleanup()
Cleanup Python.
static void init()
Initialise Python and insert the Adonthell include paths.