On May 20, 2015 1:39:57 AM CDT, Armin Rigo <[email protected]> wrote: >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.
*slaps self* Right. I feel smart... > >>>> 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. -- Sent from my Android device with K-9 Mail. Please excuse my brevity. _______________________________________________ pypy-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-dev
