Dag wrote:
> Lisandro wrote:
>> API. And the problem is that different implementations of that
>> standardized API use different calling conventions... Then I want my
>> Cython code to work with any of these implementation, but I only see
>> two solutions:
>>
>> 1) Implement all my callbacks in C and include them with 'cdef
>> extern'. But then I've just lost the power of Cython for implementing
>> C functions, particularly when Python objects are involved and the GIL
>> has to be properly managed.
>>
>> 2) Modify Cython to accept any string literal instead of just
>> __stdcall/__cdecl/__fastcall. Then the contents of that literal could
>> be a macro and I would be able to control its actual contents via the
>> C preprocessor.
>>
>> Can any of you figure out an alternative to (2) to save me (or any
>> other with similar issues) from (1) ??
>
> Yes, as I proposed, some kind of syntax to declare your own calling
> convention; e.g.
>
> cdef callspec __mycall "__mycall"
>
> cdef __mycall int foo(): return 3
Alternatively:
from cython import callconvention
@callconvention("__mycall")
cdef int foo(): ...
though it might be too long? (Shorter name possible on decorator too.)
Similarily one could have
@gccattribute("...")
which I'd prefer to hacking this into a callconvention mechanism.
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev