Re: [pypy-dev] Could PyPy callback C code with C function pointer?

2015-05-20 Thread Yicong Huang
Great. It did work. :) On Thu, May 21, 2015 at 11:12 AM, Yicong Huang wrote: > With PyPy "pypy_execute_source_ptr()", we could pass a C function pointer > to python code. > The funtion pointer was initilized in C code. > Could PyPy use this function pointer callback to C code? >

[pypy-dev] Could PyPy callback C code with C function pointer?

2015-05-20 Thread Yicong Huang
With PyPy "pypy_execute_source_ptr()", we could pass a C function pointer to python code. The funtion pointer was initilized in C code. Could PyPy use this function pointer callback to C code? ___ pypy-dev mailing list pypy-dev@python.org https://mail.pyt

Re: [pypy-dev] For embedding pypy, how to deal with None value

2015-05-20 Thread Ryan Gonzalez
On May 20, 2015 1:39:57 AM CDT, Armin Rigo wrote: >Hi Ryan, > >On 19 May 2015 at 20:09, Ryan Gonzalez 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

Re: [pypy-dev] Cannot instantiate ctype 'struct *' of unknown size

2015-05-20 Thread Armin Rigo
Hi Yicong, hi Amaury, On 20 May 2015 at 12:27, Amaury Forgeot d'Arc wrote: > Haha, but there is a bug in cffi I think. Thanks for the bug report. Fixed in 2dfaf4b4f0aa. Armin ___ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailm

Re: [pypy-dev] Cannot instantiate ctype 'struct *' of unknown size

2015-05-20 Thread Amaury Forgeot d'Arc
Haha, but there is a bug in cffi I think. I just filed https://bitbucket.org/cffi/cffi/issue/193/forward-declaration-of-struct-does-not with a simpler test case. 2015-05-20 12:03 GMT+02:00 Yicong Huang : > Oh, great thanks for you help! > Finally, I found out the real issue. > The whold code is

Re: [pypy-dev] Cannot instantiate ctype 'struct *' of unknown size

2015-05-20 Thread Yicong Huang
Oh, great thanks for you help! Finally, I found out the real issue. The whold code is this: @ffi.callback("struct api_ret*(char *)") def udf_api(arg0): return None ffi.cdef(''' struct API { struct api_ret* (*pyudf)(char* str); }; ''') ffi.cdef(''' struct api_ret { char *ret1;

Re: [pypy-dev] Cannot instantiate ctype 'struct *' of unknown size

2015-05-20 Thread Amaury Forgeot d'Arc
2015-05-20 11:44 GMT+02:00 Yicong Huang : > Hi, > > The below is the code we met troubles; > > ffi.cdef(''' > struct API { > struct api_ret* (*pyudf)(char* str); > }; > ''') > > ffi.cdef(''' > struct api_ret { > char *ret1; > char *ret2; > char *ret3; > }; > ''') > > re

[pypy-dev] Cannot instantiate ctype 'struct *' of unknown size

2015-05-20 Thread Yicong Huang
Hi, The below is the code we met troubles; ffi.cdef(''' struct API { struct api_ret* (*pyudf)(char* str); }; ''') ffi.cdef(''' struct api_ret { char *ret1; char *ret2; char *ret3; }; ''') result = ffi.new('struct api_ret*') At first, we defined struct API with a fun

Re: [pypy-dev] For embedding pypy, how to deal with None value

2015-05-20 Thread Amaury Forgeot d'Arc
2015-05-20 9:54 GMT+02:00 Yicong Huang : > Yes, C could *not* have a function that returns either a double or NULL. > But python could. > In addition, python could have a function paramter that is either int or > None. > > The problem is we might get a python function, and we would like to call >

Re: [pypy-dev] For embedding pypy, how to deal with None value

2015-05-20 Thread Yicong Huang
Yes, C could *not* have a function that returns either a double or NULL. But python could. In addition, python could have a function paramter that is either int or None. The problem is we might get a python function, and we would like to call this python function in C. We're not sure whether this