Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
981ae1c7
Commit
981ae1c7
authored
May 26, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New fix for #303
parent
0f20d105
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
13 deletions
+105
-13
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+47
-0
tests/run/external_defs.h
tests/run/external_defs.h
+22
-1
tests/run/typedfieldbug_T303.pyx
tests/run/typedfieldbug_T303.pyx
+36
-12
No files found.
Cython/Compiler/PyrexTypes.py
View file @
981ae1c7
...
...
@@ -171,6 +171,19 @@ class CTypedefType(BaseType):
self
.
typedef_base_type
=
base_type
self
.
typedef_is_external
=
is_external
# Make typecodes in external typedefs use typesize-neutral macros
if
is_external
:
typecode
=
None
if
base_type
.
is_int
:
if
base_type
.
signed
==
0
:
typecode
=
"__Pyx_T_UNSIGNED_INT"
else
:
typecode
=
"__Pyx_T_SIGNED_INT"
elif
base_type
.
is_float
and
not
rank_to_type_name
[
base_type
.
rank
]
==
"long double"
:
typecode
=
"__Pyx_T_FLOATING"
if
typecode
:
self
.
pymemberdef_typecode
=
"%s(%s)"
%
(
typecode
,
cname
)
def
resolve
(
self
):
return
self
.
typedef_base_type
.
resolve
()
...
...
@@ -1726,6 +1739,40 @@ static INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
#endif
#endif
#if !defined(T_ULONGLONG)
#define __Pyx_T_UNSIGNED_INT(x)
\
\
((sizeof(x) == sizeof(unsigned char)) ? T_UBYTE :
\
\
((sizeof(x) == sizeof(unsigned short)) ? T_USHORT :
\
\
((sizeof(x) == sizeof(unsigned int)) ? T_UINT :
\
\
((sizeof(x) == sizeof(unsigned long)) ? T_ULONG : -1))))
#else
#define __Pyx_T_UNSIGNED_INT(x)
\
\
((sizeof(x) == sizeof(unsigned char)) ? T_UBYTE :
\
\
((sizeof(x) == sizeof(unsigned short)) ? T_USHORT :
\
\
((sizeof(x) == sizeof(unsigned int)) ? T_UINT :
\
\
((sizeof(x) == sizeof(unsigned long)) ? T_ULONG :
\
\
((sizeof(x) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))))
#endif
#if !defined(T_LONGLONG)
#define __Pyx_T_SIGNED_INT(x)
\
\
((sizeof(x) == sizeof(char)) ? T_BYTE :
\
\
((sizeof(x) == sizeof(short)) ? T_SHORT :
\
\
((sizeof(x) == sizeof(int)) ? T_INT :
\
\
((sizeof(x) == sizeof(long)) ? T_LONG : -1))))
#else
#define __Pyx_T_SIGNED_INT(x)
\
\
((sizeof(x) == sizeof(char)) ? T_BYTE :
\
\
((sizeof(x) == sizeof(short)) ? T_SHORT :
\
\
((sizeof(x) == sizeof(int)) ? T_INT :
\
\
((sizeof(x) == sizeof(long)) ? T_LONG :
\
\
((sizeof(x) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))))
#endif
#define __Pyx_T_FLOATING(x)
\
\
((sizeof(x) == sizeof(float)) ? T_FLOAT :
\
\
((sizeof(x) == sizeof(double)) ? T_DOUBLE : -1))
#if !defined(T_SIZET)
#if !defined(T_ULONGLONG)
#define T_SIZET
\
\
...
...
tests/run/external_defs.h
View file @
981ae1c7
typedef
float
FloatTypedef
;
typedef
double
DoubleTypedef
;
typedef
long
double
LongDoubleTypedef
;
typedef
char
CharTypedef
;
typedef
short
ShortTypedef
;
typedef
int
IntTypedef
;
typedef
long
LongTypedef
;
#if defined(T_LONGLONG)
typedef
PY_LONG_LONG
LongLongTypedef
;
#else
typedef
long
LongLongTypedef
;
#endif
typedef
unsigned
char
UCharTypedef
;
typedef
unsigned
short
UShortTypedef
;
typedef
unsigned
int
UIntTypedef
;
typedef
unsigned
long
ULongTypedef
;
#if defined(T_LONGLONG)
typedef
unsigned
PY_LONG_LONG
ULongLongTypedef
;
#else
typedef
unsigned
long
ULongLongTypedef
;
#endif
tests/run/typedfieldbug_T303.pyx
View file @
981ae1c7
"""
>>> f()
42.0 42.0 42.0
42.0
42.0
>>> global_vars(12.0)
12.0 12.0
>>> readonly()
Traceback (most recent call last):
...
AttributeError: attribute 'var_nf' of 'typedfieldbug_T303.MyClass' objects is not writable
TypeError: readonly attribute
>>> longdouble_access()
Traceback (most recent call last):
...
SystemError: bad memberdescr type
"""
cdef
extern
from
"external_defs.h"
:
ctypedef
float
DoubleTypedef
ctypedef
float
LongDoubleTypedef
cdef
public
DoubleTypedef
global_tdef
cdef
public
double
global_double
cdef
class
MyClass
:
cdef
readonly
:
double
var_d
DoubleTypedef
var_nf
cdef
public
:
DoubleTypedef
var_mutable
double
actual_double
DoubleTypedef
float_isreally_double
LongDoubleTypedef
float_isreally_longdouble
def
__init__
(
self
):
self
.
var_d
=
42.0
self
.
var_nf
=
42.0
self
.
var_mutable
=
1
self
.
actual_double
=
42.0
self
.
float_isreally_double
=
42.0
self
.
float_isreally_longdouble
=
42.0
def
global_vars
(
x
):
global
global_tdef
,
global_double
global_tdef
=
x
global_double
=
x
print
global_tdef
,
global_double
def
f
():
c
=
MyClass
()
c
.
var_mutable
=
42.0
print
c
.
var_d
,
c
.
var_nf
,
c
.
var_mutable
print
c
.
actual_double
print
c
.
float_isreally_double
def
longdouble_access
():
c
=
MyClass
()
print
c
.
float_isreally_longdouble
def
readonly
():
c
=
MyClass
()
c
.
var_nf
=
3
c
.
actual_double
=
3
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment