On Fri, 20 Jul 2007 14:52:54 +0200
Armin Rigo <[EMAIL PROTECTED]> wrote:

> 
> Hi Simon,
> 
> On Thu, Jul 19, 2007 at 06:31:17PM -0700, Simon Burton wrote:
> > The lltype's are very strict about types.
> 
> Indeed, it seems worthwhile to loosen this restriction at least for the
> purpose of calling external functions...  Not sure how, but there are
> possible hacks at least.

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

Here is my first attempt. It does no casting, but i already can't get it
to work.


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


where funcptr comes from a call to llexternal.

It seems the tuple construction should not work (each args[i] is a different 
type), but instead i get:
        CallPatternTooComplex': '*' argument must be SomeTuple.

Um.. My only guess now is to malloc a TUPLE_TYPE.. ?!? no idea..
(I am really sick of code generation and hope it doesn't come to that).

Simon.



_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev

Reply via email to