File: embedsignatures_python.pyx

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (280 lines) | stat: -rw-r--r-- 6,172 bytes parent folder | download
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# cython: embedsignature=True
# cython: embedsignature.format=python
# cython: annotation_typing=False
# cython: c_string_type=bytearray

cpdef object      f00(object a): return a
cpdef long double f01(unsigned int a): return <double>a
cpdef long double f02(unsigned int a: float): return <double>a

__doc__ = ur"""
>>> print(f00.__doc__)
f00(a)

>>> print(f01.__doc__)
f01(a: int) -> float

>>> print(f02.__doc__)
f02(a: float) -> float

"""


cdef class Foo:
    "Foo docstring"

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        "init Foo"
        pass

    def m00(self, a): return a
    def m01(self, unsigned int a): return a
    def m02(self, unsigned int a: int): return a
    def m03(self: Self, unsigned int a: int) -> float: return a
    def m04(self, const char* a): return a
    def m05(self, const char a[]): return a
    def m06(self, const char* a: bytes) -> bytes: return a

    @classmethod
    def c00(cls, a): return a
    @classmethod
    def c01(type cls, unsigned int a): return a
    @classmethod
    def c02(cls: type[Foo], unsigned int a: int): return a
    @classmethod
    def c03(type cls: type[Foo], unsigned int a: int) -> float: return a

    @staticmethod
    def s00(a): return a
    @staticmethod
    def s01(unsigned int a): return a
    @staticmethod
    def s02(unsigned int a: int): return a
    @staticmethod
    def s03(unsigned int a: int) -> float: return a

    cdef public long int p0
    property p1:
        """p1 docstring"""
        def __get__(self):
            return 0
    property p2:
        """p2 docstring"""
        def __get__(self) -> int:
            return 0
    cdef public Foo p3


__doc__ += ur"""
>>> print(Foo.__doc__)
Foo docstring
>>> print(Foo.__init__.__doc__)
__init__(self, *args: Any, **kwargs: Any) -> None
init Foo

"""

__doc__ += ur"""
>>> print(Foo.m00.__doc__)
m00(self, a)

>>> print(Foo.m01.__doc__)
m01(self, a: int)

>>> print(Foo.m02.__doc__)
m02(self, a: int)

>>> print(Foo.m03.__doc__)
m03(self: Self, a: int) -> float

>>> print(Foo.m04.__doc__)
m04(self, a: bytearray)

>>> print(Foo.m05.__doc__)
m05(self, a: bytearray)

>>> print(Foo.m06.__doc__)
m06(self, a: bytes) -> bytes

"""

__doc__ += ur"""
>>> print(Foo.c00.__doc__)
c00(cls, a)

>>> print(Foo.c01.__doc__)
c01(cls, a: int)

>>> print(Foo.c02.__doc__)
c02(cls: type[Foo], a: int)

>>> print(Foo.c03.__doc__)
c03(cls: type[Foo], a: int) -> float

"""

__doc__ += ur"""
>>> print(Foo.s00.__doc__)
s00(a)

>>> print(Foo.s01.__doc__)
s01(a: int)

>>> print(Foo.s02.__doc__)
s02(a: int)

>>> print(Foo.s03.__doc__)
s03(a: int) -> float

"""

__doc__ += ur"""
>>> print(Foo.p0.__doc__)
p0: int

>>> print(Foo.p1.__doc__)
p1 docstring

>>> print(Foo.p2.__doc__)
p2: int
p2 docstring

>>> print(Foo.p3.__doc__)
p3: Foo

"""

ctypedef long     long      LongLong
ctypedef signed   long long LongLongSigned
ctypedef unsigned long long LongLongUnsigned

cdef class Bar:

    cpdef          char       m00(self,          char       a): return a
    cpdef signed   char       m01(self, signed   char       a): return a
    cpdef unsigned char       m02(self, unsigned char       a): return a

    cpdef          short      m10(self,          short      a): return a
    cpdef signed   short      m11(self, signed   short      a): return a
    cpdef unsigned short      m12(self, unsigned short      a): return a

    cpdef          int        m20(self,          int        a): return a
    cpdef signed   int        m21(self, signed   int        a): return a
    cpdef unsigned int        m22(self, unsigned int        a): return a

    cpdef          long       m30(self,          long       a): return a
    cpdef signed   long       m31(self, signed   long       a): return a
    cpdef unsigned long       m32(self, unsigned long       a): return a

    cpdef          long long  m40(self,          long long  a): return a
    cpdef signed   long long  m41(self, signed   long long  a): return a
    cpdef unsigned long long  m42(self, unsigned long long  a): return a

    cpdef LongLong            m43(self, LongLong            a): return a
    cpdef LongLongSigned      m44(self, LongLongSigned      a): return a
    cpdef LongLongUnsigned    m45(self, LongLongUnsigned    a): return a

    cpdef float               m50(self, float               a): return a
    cpdef double              m60(self, double              a): return a
    cpdef long double         m70(self, long double         a): return a

    cpdef float       complex m51(self, float       complex a): return a
    cpdef double      complex m61(self, double      complex a): return a
    cpdef long double complex m71(self, long double complex a): return a


__doc__ += ur"""
>>> print(Bar.m00.__doc__)
m00(self, a: int) -> int

>>> print(Bar.m01.__doc__)
m01(self, a: int) -> int

>>> print(Bar.m02.__doc__)
m02(self, a: int) -> int

"""

__doc__ += ur"""
>>> print(Bar.m10.__doc__)
m10(self, a: int) -> int

>>> print(Bar.m11.__doc__)
m11(self, a: int) -> int

>>> print(Bar.m12.__doc__)
m12(self, a: int) -> int

"""

__doc__ += ur"""
>>> print(Bar.m20.__doc__)
m20(self, a: int) -> int

>>> print(Bar.m21.__doc__)
m21(self, a: int) -> int

>>> print(Bar.m22.__doc__)
m22(self, a: int) -> int

"""

__doc__ += ur"""
>>> print(Bar.m30.__doc__)
m30(self, a: int) -> int

>>> print(Bar.m31.__doc__)
m31(self, a: int) -> int

>>> print(Bar.m32.__doc__)
m32(self, a: int) -> int

"""

__doc__ += ur"""
>>> print(Bar.m40.__doc__)
m40(self, a: int) -> int

>>> print(Bar.m41.__doc__)
m41(self, a: int) -> int

>>> print(Bar.m42.__doc__)
m42(self, a: int) -> int

"""

__doc__ += ur"""
>>> print(Bar.m43.__doc__)
m43(self, a: int) -> int

>>> print(Bar.m44.__doc__)
m44(self, a: int) -> int

>>> print(Bar.m45.__doc__)
m45(self, a: int) -> int

"""

__doc__ += ur"""
>>> print(Bar.m50.__doc__)
m50(self, a: float) -> float

>>> print(Bar.m60.__doc__)
m60(self, a: float) -> float

>>> print(Bar.m70.__doc__)
m70(self, a: float) -> float

"""

__doc__ += ur"""
>>> print(Bar.m51.__doc__)
m51(self, a: complex) -> complex

>>> print(Bar.m61.__doc__)
m61(self, a: complex) -> complex

>>> print(Bar.m71.__doc__)
m71(self, a: complex) -> complex

"""