MCPcopy Create free account
hub / github.com/boostorg/build / call_python_function

Function call_python_function

v2/engine/function.c:4785–4862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4783
4784
4785static LIST * call_python_function( PYTHON_FUNCTION * function, FRAME * frame )
4786{
4787 LIST * result = 0;
4788 PyObject * arguments = 0;
4789 PyObject * kw = NULL;
4790 int i;
4791 PyObject * py_result;
4792 FRAME * prev_frame_before_python_call;
4793
4794 if ( function->base.formal_arguments )
4795 {
4796 arguments = PyTuple_New( 0 );
4797 kw = PyDict_New();
4798 argument_list_to_python( function->base.formal_arguments,
4799 function->base.num_formal_arguments, &function->base, frame, kw );
4800 }
4801 else
4802 {
4803 arguments = PyTuple_New( frame->args->count );
4804 for ( i = 0; i < frame->args->count; ++i )
4805 PyTuple_SetItem( arguments, i, list_to_python( lol_get( frame->args,
4806 i ) ) );
4807 }
4808
4809 frame->module = python_module();
4810
4811 prev_frame_before_python_call = frame_before_python_call;
4812 frame_before_python_call = frame;
4813 py_result = PyObject_Call( function->python_function, arguments, kw );
4814 frame_before_python_call = prev_frame_before_python_call;
4815 Py_DECREF( arguments );
4816 Py_XDECREF( kw );
4817 if ( py_result != NULL )
4818 {
4819 if ( PyList_Check( py_result ) )
4820 {
4821 int size = PyList_Size( py_result );
4822 int i;
4823 for ( i = 0; i < size; ++i )
4824 {
4825 OBJECT * s = python_to_string( PyList_GetItem( py_result, i ) );
4826 if ( !s )
4827 fprintf( stderr,
4828 "Non-string object returned by Python call.\n" );
4829 else
4830 result = list_push_back( result, s );
4831 }
4832 }
4833 else if ( py_result == Py_None )
4834 {
4835 result = L0;
4836 }
4837 else
4838 {
4839 OBJECT * const s = python_to_string( py_result );
4840 if ( s )
4841 result = list_new( s );
4842 else

Callers 1

ifFunction · 0.85

Calls 7

argument_list_to_pythonFunction · 0.85
list_to_pythonFunction · 0.85
lol_getFunction · 0.85
python_moduleFunction · 0.85
python_to_stringFunction · 0.85
list_push_backFunction · 0.85
list_newFunction · 0.85

Tested by

no test coverage detected