41 fprintf ( stdout ,
"HPI: loading module %s\n" , name ) ;
43 PyObject* pModule = PyImport_ImportModule ( name );
47 fprintf ( stderr ,
"HPI ERROR: Failed to load module %s\n" , name );
58 fprintf ( stdout ,
"HPI: finalizing Python\n" ) ;
74 fprintf ( stdout ,
"HPI: initializing Python\n" ) ;
104 fprintf ( stdout ,
"HPI: calling %s\n" , hpi_func ) ;
107 PyObject* pFunc = PyObject_GetAttrString (
hpi_module , hpi_func ) ;
109 if ( pFunc && PyCallable_Check ( pFunc ) )
111 PyObject* pValue = PyObject_CallObject ( pFunc , pArgs ) ;
112 if ( pValue != NULL )
115 result = PyInt_AsLong ( pValue ) ;
119 Py_XDECREF ( pFunc ) ;
122 fprintf ( stdout ,
"HPI: call returns: %d\n" , result );
130 swig_type_info* swigtype = SWIG_Python_TypeQuery ( hsi_type );
133 "HPI: making a %s from %p\n" ,
140 "HPI ERROR: can't find SWIG type for %s\n" ,
147 return SWIG_NewPointerObj ( hugin_value , swigtype , 0 );
157 Py_DECREF (
pArgs ) ;
162 if ( ( ! python_arg ) || (
have >=
argc ) )
166 PyTuple_SetItem (
pArgs ,
have++ , python_arg ) ;
173 fprintf ( stdout ,
"HPI: making a PyString from '%s'\n" , str ) ;
176 #if PY_MAJOR_VERSION>=3
177 return add ( PyUnicode_FromString(str));
179 return add ( PyString_FromString(str));
bool activated
flag, true if activated
core classes of the hpi interface, not for user code
PyObject * hsi_module
pointer to loaded hsi module
python_arglist(int _argc)
the constructor is called with the number of arguments the argument list is meant to contain...
PyObject * make_hsi_object(const char *hsi_type, void *hugin_value)
general function to make a Python object from a hugin object.
bool activate()
: loads the necessary modules hsi and hpi.
PyObject * yield()
returns the generated PyObject Note that this will only succeed if the argument count is correct...
~python_arglist()
destructor, does cleanup
PyObject * load_module(const char *name)
general module-loading function
PyObject * hpi_module
pointer to loaded hpi module
bool add(PyObject *python_arg)
add a python object to the argument list.
int call_hpi(const char *hpi_func, PyObject *pArgs)
call a routine in the hsi module with a bunch of parameters.