On Fri, Apr 13, 2012 at 2:18 PM, Stefan Behnel <stefan...@behnel.de> wrote:

> wlavrij...@lbl.gov, 13.04.2012 19:03:
> >> Note that a wrapper function may offer more than one native signature,
> e.g.
> >> when wrapping overloaded C++ functions or when using Cython fused
> functions.
> >
> > the big problem I'm finding for unpacking C++ functions (other than that
> > there's no platform-independent way to do so when it comes to methods,
> AFAIK
> > anyway), is handling of C++ exceptions.
>
> At least for Cython code that's not a problem - its functions raise Python
> exceptions. Some C++ exceptions are mapped automatically and others can be
> mapped explicitly.
>
> Other wrapper generators could also generate an intermediate wrapper
> function that does the error mapping and passes on Python exceptions.
> Unpacking a wrapped function doesn't necessarily mean that you get a bare C
> or C++ function. The main intention is to reduce the call overhead, which
> is mainly introduced by packing and unpacking arguments. That's why we want
> to expose the signature.
>
>
> > Integrating unpacked functions pointers with PyPy works rather elegantly
> > through the functionality made available in rlib/libffi.py. The form of
> the
> > specification matters little at that point, as long as it is complete.
>
> Hmm, but that's RPython, isn't it? I thought that was compiled statically?
> How would it adapt to a signature that it finds at runtime then?
>
> I think this is closer to ctypes, except that you don't have to specify the
> signature of the thing you call because PyPy will see it at call time.
>
>
> > For cppyy, the current plan is to wrap python functions in generated C++
> > functions for callbacks.
>
> Yes, that would be the other direction.
>
> Stefan
>
> _______________________________________________
> pypy-dev mailing list
> pypy-dev@python.org
> http://mail.python.org/mailman/listinfo/pypy-dev
>

rlib/libffi.py is for runtime stuff, it's the basis of both ctypes and the
C++ wrapper.  You may be thinking of rffi.py, which is compile time.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to