Hi Ryan,
On 19 May 2015 at 20:09, Ryan Gonzalez <[email protected]> wrote:
> Why not return a pointer to a double? Like (UNTESTED!):
>
> d = ffi.new('double*')
> d[0] = 9.0
> return d
This doesn't work! You can't return a ffi.new() pointer, because the
'd' variable is not kept alive.
>>> The document Embedding PyPy shows good examples, but did not tell how to
>>> deal with None value.
I'm still unsure I understand the question. You need to know at least
a bit of C in order to use cffi. In C you can't write a function that
returns either a double or NULL. First start by thinking about a
valid C interface, and then use cffi to implement it. Maybe you want
something like
int foo(int argument, double *result);
which returns a status code as an integer (e.g. 0=ok, -1=error), and
in the ok case, fills in "*result".
A bientôt,
Armin.
_______________________________________________
pypy-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-dev