Skip to content
Snippets Groups Projects
Commit 3bcec4b9 authored by Utz-Uwe Haus's avatar Utz-Uwe Haus
Browse files

Implement mstro_cdo argout typemap

parent 0d7dd5a4
Branches
No related tags found
1 merge request!24Draft: Resolve "scripting interface to maestro core"
......@@ -4,12 +4,46 @@
%include "cpointer.i"
%include "exception.i"
/* handling mstro_status return codes: suppress unless an error needs to be indicated. In that case: throw exeption */
/* No identifier conversion here. PEP-8 says
*
* > Function names should be lowercase, with words separated by underscores as
* > necessary to improve readability.
*
* so our C API will be just fine.
*/
/***** typemaps *****/
/* mstro_status codes: suppress unless an error needs to be indicated. In that case: throw exeption */
%typemap(out) mstro_status {
$result = SWIG_Py_Void();
if(MSTRO_OK!=$1) {
SWIG_exception(SWIG_RuntimeError, mstro_status_description($1));
}
}
/* CDO return values: */
%typemap(in, numinputs=0) mstro_cdo *result (mstro_cdo temp) {
$1 = &temp;
}
%typemap(argout) mstro_cdo *result {
/* Create shadow object (do not use SWIG_POINTER_NEW) */
PyObject * temp = SWIG_NewPointerObj(*$1,
$descriptor(mstro_cdo),
SWIG_POINTER_NEW);
/* if multiple results: ensure result is a list */
if(VOID_Object==$result) {
/* we're producing the first result */
$result = temp;
} else {
$result = SWIG_Py_Void();
/* coerce previous result to list and append */
if (!PyList_Check($result)) {
PyObject * tt = $result;
$result = PyList_New(1);
PyList_SetItem($result, 0, tt);
}
PyList_Append($result, temp);
Py_DECREF(temp);
}
}
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment