[pypy-dev] rffi strict typing

Simon Burton simon at arrowtheory.com
Thu Aug 23 19:07:37 CEST 2007


On Wed, 22 Aug 2007 15:23:40 -0700
Simon Burton <simon at arrowtheory.com> wrote:

> 
> Following some hints from Samuele, I am trying to wrap such functions in
> another function that does some casting. 

Here is the latest:


def softwrapper(funcptr, arg_tps):
    unrolling_arg_tps = unrolling_iterable(enumerate(arg_tps))
    def softfunc(*args):
        real_args = ()
        for i, tp in unrolling_arg_tps:
            real_args = real_args + (args[i],)
        result = funcptr(*real_args)
        return result
    return softfunc

When applied to llexternal's that have pointer-to-struct args
the generated c code breaks; it decides to declare&use anonymous
structs:

long pypy_g_softfunc_star2_1(struct pypy__cairo_surface0 *l_stararg0_7, struct pypy_array3 *l_stararg1_7) {
	long l_v492;

    block0:
	l_v492 = cairo_surface_write_to_png(l_stararg0_7, l_stararg1_7);
	goto block1;

    block1:
	RPY_DEBUG_RETURN();
	return l_v492;
}

where cairo_surface_write_to_png is declared:

cairo_surface_write_to_png (cairo_surface_t	*surface,
			    const char		*filename);


I wonder if the annotator is getting confused by the real_args tuple growing...



More information about the Pypy-dev mailing list