Lisandro Dalcin wrote:
> On Tue, May 12, 2009 at 1:04 PM, Dag Sverre Seljebotn
> <[email protected]> wrote:
>> A)
>>
>> Ticket #303 manifests itself like this:
>>
>> cdef extern:
>>     ctypedef float footype # really double!
>>
>> cdef class A:
>>     cdef public footype myproperty
>>
>> My suggestion for a fix here is to replace all T_INT, T_UINT etc. with
>> simply three types: __Pyx_T_SIGNED, __Pyx_T_UNSIGNED, __Pyx_T_FLOAT.
>> These would use sizeof to determine the right type to flag the extension
>> type property as (like Lisandro did with T_SIZET already does).
>>
> 
> I'm -1 on this...
> 
> For (A), we need to enhance Cython to generate a couple of converter
> functions to_py/from_py for externally defined integral or floating
> types. For the integral ones, the only requisite is to specify sign
> part. I've already have some preliminary work on this, but I'm not
> sure how to go on because of the delegation-based implementation in
> CTypedefNode.

Sounds like a plan.

I just added a "typedef_is_external" to CTypedefType which could be useful.

If one renamed this to simply "is_external" (or "lacks_size"?) and 
defaulted it to 0 on all types, then the result would be that one could 
simply always query on a conversion whether the type "lacked size", and 
if so use custom converter functions.

Does that solve it?

> For (B), I believe that if the type is an external typedef, a
> transform should change the "cdef publid footype value" to this:
> 
> cdef class A:
>    property value:
>       def __get__(self): return self.value
>       def __set__(self, footype x) : self.value = x
> 
> In short, I already have implemented the utility code for (A), but I'm
> in doubt about how to reimplement CTypedefNode. Additionally, I
> believe my appoach for (B) could be easily implemented (likely Dag can
> implement this part far better than me).

Splendid! This was basically already implemented (by Robert I think) to 
support "cdef public MyCdefClass foo", so the patch was really easy.

http://hg.cython.org/cython-devel/rev/dcc78ab6a498

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to