MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / PP_Run_Function

Function PP_Run_Function

src/Base/PyTools.c:106–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104 *****************************************************************************/
105
106int
107PP_Run_Function(const char *modname, const char *funcname, /* load from module */
108 const char *resfmt, void *cresult, /* convert to c/c++ */
109 const char *argfmt, ... /* arg, arg... */ ) /* convert to python */
110{
111 /* call a function or class in a module */
112 PyObject *func = NULL, *args = NULL, *presult = NULL;
113 va_list argslist;
114 va_start(argslist, argfmt); /* "modname.funcname(args)" */
115
116 func = PP_Load_Attribute(modname, funcname); /* may reload; incref'd */
117 if (func == NULL) { /* func or class or C type */
118 va_end(argslist);
119 return -1;
120 }
121 args = Py_VaBuildValue(argfmt, argslist); /* convert args to python */
122 va_end(argslist);
123 if (args == NULL) { /* args incref'd */
124 Py_DECREF(func);
125 return -1;
126 }
127 if (PP_DEBUG && strcmp(modname, "pdb") != 0) /* debug this call? */
128 presult = PP_Debug_Function(func, args); /* run in pdb; incref'd */
129 else
130 presult = PyObject_CallObject(func, args); /* run function; incref'd */
131
132 Py_DECREF(func);
133 Py_DECREF(args); /* result may be None */
134 return PP_Convert_Result(presult, resfmt, cresult); /* convert result to C*/
135}
136
137
138PyObject *

Callers 4

PP_Debug_FunctionFunction · 0.85
PP_Fetch_Error_TextFunction · 0.85
PP_Debug_CodestrFunction · 0.85
PP_Debug_BytecodeFunction · 0.85

Calls 3

PP_Load_AttributeFunction · 0.85
PP_Debug_FunctionFunction · 0.85
PP_Convert_ResultFunction · 0.85

Tested by

no test coverage detected