blob: 4298a1cce2d9c06456213a3b66eb266d34976df2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# mode: run
# ticket: 303
__doc__ = """
>>> try: readonly()
... except (TypeError, AttributeError): pass
"""
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 actual_double
DoubleTypedef float_isreally_double
LongDoubleTypedef float_isreally_longdouble
def __init__(self):
self.actual_double = 42.0
self.float_isreally_double = 42.0
self.float_isreally_longdouble = 42.0
def global_vars(x):
"""
>>> global_vars(12.0)
12.0 12.0
"""
global global_tdef, global_double
global_tdef = x
global_double = x
print global_tdef, global_double
def f():
"""
>>> f()
42.0
42.0
"""
cdef object c = MyClass()
print c.actual_double
print c.float_isreally_double
def longdouble_access():
"""
>>> longdouble_access()
42.0
"""
cdef object c = MyClass()
print c.float_isreally_longdouble
def readonly():
cdef object c = MyClass()
c.actual_double = 3
|