| 2035 | */ |
| 2036 | |
| 2037 | PyObject * bjam_call( PyObject * self, PyObject * args ) |
| 2038 | { |
| 2039 | FRAME inner[ 1 ]; |
| 2040 | LIST * result; |
| 2041 | PARSE * p; |
| 2042 | OBJECT * rulename; |
| 2043 | |
| 2044 | /* Build up the list of arg lists. */ |
| 2045 | frame_init( inner ); |
| 2046 | inner->prev = 0; |
| 2047 | inner->prev_user = 0; |
| 2048 | inner->module = bindmodule( constant_python_interface ); |
| 2049 | |
| 2050 | /* Extract the rule name and arguments from 'args'. */ |
| 2051 | |
| 2052 | /* PyTuple_GetItem returns borrowed reference. */ |
| 2053 | rulename = object_new( PyString_AsString( PyTuple_GetItem( args, 0 ) ) ); |
| 2054 | { |
| 2055 | int i = 1; |
| 2056 | int size = PyTuple_Size( args ); |
| 2057 | for ( ; i < size; ++i ) |
| 2058 | { |
| 2059 | PyObject * a = PyTuple_GetItem( args, i ); |
| 2060 | if ( PyString_Check( a ) ) |
| 2061 | { |
| 2062 | lol_add( inner->args, list_new( object_new( |
| 2063 | PyString_AsString( a ) ) ) ); |
| 2064 | } |
| 2065 | else if ( PySequence_Check( a ) ) |
| 2066 | { |
| 2067 | LIST * l = 0; |
| 2068 | int s = PySequence_Size( a ); |
| 2069 | int i = 0; |
| 2070 | for ( ; i < s; ++i ) |
| 2071 | { |
| 2072 | /* PySequence_GetItem returns new reference. */ |
| 2073 | PyObject * e = PySequence_GetItem( a, i ); |
| 2074 | char * s = PyString_AsString( e ); |
| 2075 | if ( !s ) |
| 2076 | { |
| 2077 | printf( "Invalid parameter type passed from Python\n" ); |
| 2078 | exit( 1 ); |
| 2079 | } |
| 2080 | l = list_push_back( l, object_new( s ) ); |
| 2081 | Py_DECREF( e ); |
| 2082 | } |
| 2083 | lol_add( inner->args, l ); |
| 2084 | } |
| 2085 | } |
| 2086 | } |
| 2087 | |
| 2088 | result = evaluate_rule( bindrule( rulename, inner->module), rulename, inner ); |
| 2089 | object_free( rulename ); |
| 2090 | |
| 2091 | frame_free( inner ); |
| 2092 | |
| 2093 | /* Convert the bjam list into a Python list result. */ |
| 2094 | { |
nothing calls this directly
no test coverage detected