| 4792 | |
| 4793 | |
| 4794 | static void argument_list_to_python( struct arg_list * formal, int formal_count, |
| 4795 | FUNCTION * function, FRAME * frame, PyObject * kw ) |
| 4796 | { |
| 4797 | LOL * all_actual = frame->args; |
| 4798 | int i; |
| 4799 | |
| 4800 | for ( i = 0; i < formal_count; ++i ) |
| 4801 | { |
| 4802 | LIST * actual = lol_get( all_actual, i ); |
| 4803 | LISTITER actual_iter = list_begin( actual ); |
| 4804 | LISTITER const actual_end = list_end( actual ); |
| 4805 | int j; |
| 4806 | for ( j = 0; j < formal[ i ].size; ++j ) |
| 4807 | { |
| 4808 | struct argument * formal_arg = &formal[ i ].args[ j ]; |
| 4809 | PyObject * value; |
| 4810 | LIST * l; |
| 4811 | |
| 4812 | switch ( formal_arg->flags ) |
| 4813 | { |
| 4814 | case ARG_ONE: |
| 4815 | if ( actual_iter == actual_end ) |
| 4816 | argument_error( "missing argument", function, frame, |
| 4817 | formal_arg->arg_name ); |
| 4818 | type_check_range( formal_arg->type_name, actual_iter, list_next( |
| 4819 | actual_iter ), frame, function, formal_arg->arg_name ); |
| 4820 | value = PyString_FromString( object_str( list_item( actual_iter |
| 4821 | ) ) ); |
| 4822 | actual_iter = list_next( actual_iter ); |
| 4823 | break; |
| 4824 | case ARG_OPTIONAL: |
| 4825 | if ( actual_iter == actual_end ) |
| 4826 | value = 0; |
| 4827 | else |
| 4828 | { |
| 4829 | type_check_range( formal_arg->type_name, actual_iter, |
| 4830 | list_next( actual_iter ), frame, function, |
| 4831 | formal_arg->arg_name ); |
| 4832 | value = PyString_FromString( object_str( list_item( |
| 4833 | actual_iter ) ) ); |
| 4834 | actual_iter = list_next( actual_iter ); |
| 4835 | } |
| 4836 | break; |
| 4837 | case ARG_PLUS: |
| 4838 | if ( actual_iter == actual_end ) |
| 4839 | argument_error( "missing argument", function, frame, |
| 4840 | formal_arg->arg_name ); |
| 4841 | /* fallthrough */ |
| 4842 | case ARG_STAR: |
| 4843 | type_check_range( formal_arg->type_name, actual_iter, |
| 4844 | actual_end, frame, function, formal_arg->arg_name ); |
| 4845 | l = list_copy_range( actual, actual_iter, actual_end ); |
| 4846 | value = list_to_python( l ); |
| 4847 | list_free( l ); |
| 4848 | actual_iter = actual_end; |
| 4849 | break; |
| 4850 | case ARG_VARIADIC: |
| 4851 | return; |
no test coverage detected