Hi Tom,
On 2 January 2017 at 16:29, Tom Krauss <
t...@kraussfamily.org> wrote:
> What's involved in giving it a try? :-) I'd like to try to help add support
> for this.
Great :-) The best would be to join #pypy on
irc.freenode.net for
more interactive discussion.
In two words, check out
https://bitbucket.org/cffi/cffi and look at
how the "float/double/long double" types are implemented:
c/_cffi_backend.c, grep for PRIMITIVE_FLOAT. I guess a good first
step would be to support only "float _Complex " and "double _Complex",
with a new CT_PRIMITIVE_COMPLEX. There is already a skipped test in
c/test_c.py: test_complex_types(), that I wrote long ago (needs
checking, maybe some details changed; compare with test_float_types).
All in all it's not a whole lot of work, but we need to make sure
about the interaction between <cdata 'double _Complex'> and regular
Python complex objects.
The next step is the mapping to libffi types, which should occur in
new_primitive_type(). You need to add a test in test_c.py to check
calling functions with complex arguments or return types, something
similar to the various test_call_function_NUMBER.
Note that the C type name is e.g. "double _Complex", I think. This is
similar to "_Bool", which is the primitive name, and which usually is
typedef'ed to "bool" in C. This and other details need to be added to
the Python logic in the cffi/ package. Grep around for "_Bool" to see
an example. Maybe grepping around for "long double" is also a good
idea: "long double" is a type that needs a few special cases here and
there.
A bientôt,
Armin.