Cython 3.3.0a1__cp315-cp315-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (335) hide show
  1. Cython/Build/BuildExecutable.py +156 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +349 -0
  4. Cython/Build/Dependencies.py +1276 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +467 -0
  7. Cython/Build/IpythonMagic.py +559 -0
  8. Cython/Build/SharedModule.py +84 -0
  9. Cython/Build/Tests/TestCyCache.py +195 -0
  10. Cython/Build/Tests/TestCythonizeArgsParser.py +480 -0
  11. Cython/Build/Tests/TestDependencies.py +133 -0
  12. Cython/Build/Tests/TestInline.py +177 -0
  13. Cython/Build/Tests/TestIpythonMagic.py +303 -0
  14. Cython/Build/Tests/TestRecythonize.py +212 -0
  15. Cython/Build/Tests/TestStripLiterals.py +155 -0
  16. Cython/Build/Tests/__init__.py +1 -0
  17. Cython/Build/__init__.py +11 -0
  18. Cython/CodeWriter.py +815 -0
  19. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  20. Cython/Compiler/Annotate.py +328 -0
  21. Cython/Compiler/AutoDocTransforms.py +320 -0
  22. Cython/Compiler/Buffer.py +680 -0
  23. Cython/Compiler/Builtin.py +997 -0
  24. Cython/Compiler/CmdLine.py +263 -0
  25. Cython/Compiler/Code.cp315-win_amd64.pyd +0 -0
  26. Cython/Compiler/Code.pxd +152 -0
  27. Cython/Compiler/Code.py +3907 -0
  28. Cython/Compiler/CodeGeneration.py +33 -0
  29. Cython/Compiler/CythonScope.py +194 -0
  30. Cython/Compiler/Dataclass.py +890 -0
  31. Cython/Compiler/DebugFlags.py +24 -0
  32. Cython/Compiler/Errors.py +310 -0
  33. Cython/Compiler/ExprNodes.py +15983 -0
  34. Cython/Compiler/FlowControl.cp315-win_amd64.pyd +0 -0
  35. Cython/Compiler/FlowControl.pxd +99 -0
  36. Cython/Compiler/FlowControl.py +1571 -0
  37. Cython/Compiler/FusedNode.cp315-win_amd64.pyd +0 -0
  38. Cython/Compiler/FusedNode.py +976 -0
  39. Cython/Compiler/Future.py +16 -0
  40. Cython/Compiler/Interpreter.py +57 -0
  41. Cython/Compiler/Lexicon.py +422 -0
  42. Cython/Compiler/LineTable.cp315-win_amd64.pyd +0 -0
  43. Cython/Compiler/LineTable.py +114 -0
  44. Cython/Compiler/Main.py +856 -0
  45. Cython/Compiler/MatchCaseNodes.py +2197 -0
  46. Cython/Compiler/MemoryView.py +930 -0
  47. Cython/Compiler/ModuleNode.py +4517 -0
  48. Cython/Compiler/Naming.py +367 -0
  49. Cython/Compiler/Nodes.py +10941 -0
  50. Cython/Compiler/Optimize.py +5455 -0
  51. Cython/Compiler/Options.py +838 -0
  52. Cython/Compiler/ParseTreeTransforms.pxd +79 -0
  53. Cython/Compiler/ParseTreeTransforms.py +4744 -0
  54. Cython/Compiler/Parsing.cp315-win_amd64.pyd +0 -0
  55. Cython/Compiler/Parsing.pxd +9 -0
  56. Cython/Compiler/Parsing.py +4792 -0
  57. Cython/Compiler/Pipeline.py +439 -0
  58. Cython/Compiler/PyrexTypes.py +6111 -0
  59. Cython/Compiler/Pythran.py +232 -0
  60. Cython/Compiler/Scanning.cp315-win_amd64.pyd +0 -0
  61. Cython/Compiler/Scanning.pxd +70 -0
  62. Cython/Compiler/Scanning.py +720 -0
  63. Cython/Compiler/StringEncoding.py +297 -0
  64. Cython/Compiler/Symtab.py +3092 -0
  65. Cython/Compiler/Tests/TestBuffer.py +105 -0
  66. Cython/Compiler/Tests/TestBuiltin.py +117 -0
  67. Cython/Compiler/Tests/TestCmdLine.py +587 -0
  68. Cython/Compiler/Tests/TestCode.py +145 -0
  69. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  70. Cython/Compiler/Tests/TestGrammar.py +202 -0
  71. Cython/Compiler/Tests/TestMemView.py +71 -0
  72. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  73. Cython/Compiler/Tests/TestScanning.py +132 -0
  74. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  75. Cython/Compiler/Tests/TestStringEncoding.py +20 -0
  76. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  77. Cython/Compiler/Tests/TestTreePath.py +103 -0
  78. Cython/Compiler/Tests/TestTypes.py +118 -0
  79. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  80. Cython/Compiler/Tests/TestVisitor.py +61 -0
  81. Cython/Compiler/Tests/Utils.py +36 -0
  82. Cython/Compiler/Tests/__init__.py +1 -0
  83. Cython/Compiler/TreeFragment.py +278 -0
  84. Cython/Compiler/TreePath.py +303 -0
  85. Cython/Compiler/TypeInference.py +611 -0
  86. Cython/Compiler/TypeSlots.py +1329 -0
  87. Cython/Compiler/UFuncs.py +311 -0
  88. Cython/Compiler/UtilNodes.py +413 -0
  89. Cython/Compiler/UtilityCode.py +348 -0
  90. Cython/Compiler/Version.py +8 -0
  91. Cython/Compiler/Visitor.cp315-win_amd64.pyd +0 -0
  92. Cython/Compiler/Visitor.pxd +53 -0
  93. Cython/Compiler/Visitor.py +864 -0
  94. Cython/Compiler/__init__.py +1 -0
  95. Cython/Coverage.py +448 -0
  96. Cython/Debugger/Cygdb.py +177 -0
  97. Cython/Debugger/DebugWriter.py +82 -0
  98. Cython/Debugger/Tests/TestLibCython.py +280 -0
  99. Cython/Debugger/Tests/__init__.py +1 -0
  100. Cython/Debugger/Tests/cfuncs.c +8 -0
  101. Cython/Debugger/Tests/codefile +49 -0
  102. Cython/Debugger/Tests/test_libcython_in_gdb.py +580 -0
  103. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  104. Cython/Debugger/__init__.py +1 -0
  105. Cython/Debugger/libcython.py +1548 -0
  106. Cython/Debugger/libpython.py +2821 -0
  107. Cython/Debugging.py +20 -0
  108. Cython/Distutils/__init__.py +2 -0
  109. Cython/Distutils/build_ext.py +139 -0
  110. Cython/Distutils/extension.py +96 -0
  111. Cython/Distutils/old_build_ext.py +351 -0
  112. Cython/Includes/cpython/__init__.pxd +173 -0
  113. Cython/Includes/cpython/array.pxd +152 -0
  114. Cython/Includes/cpython/bool.pxd +37 -0
  115. Cython/Includes/cpython/buffer.pxd +112 -0
  116. Cython/Includes/cpython/bytearray.pxd +33 -0
  117. Cython/Includes/cpython/bytes.pxd +200 -0
  118. Cython/Includes/cpython/cellobject.pxd +35 -0
  119. Cython/Includes/cpython/ceval.pxd +8 -0
  120. Cython/Includes/cpython/codecs.pxd +121 -0
  121. Cython/Includes/cpython/complex.pxd +60 -0
  122. Cython/Includes/cpython/contextvars.pxd +145 -0
  123. Cython/Includes/cpython/conversion.pxd +36 -0
  124. Cython/Includes/cpython/datetime.pxd +395 -0
  125. Cython/Includes/cpython/descr.pxd +26 -0
  126. Cython/Includes/cpython/dict.pxd +268 -0
  127. Cython/Includes/cpython/exc.pxd +263 -0
  128. Cython/Includes/cpython/fileobject.pxd +57 -0
  129. Cython/Includes/cpython/float.pxd +56 -0
  130. Cython/Includes/cpython/frozendict.pxd +37 -0
  131. Cython/Includes/cpython/function.pxd +65 -0
  132. Cython/Includes/cpython/genobject.pxd +25 -0
  133. Cython/Includes/cpython/getargs.pxd +12 -0
  134. Cython/Includes/cpython/instance.pxd +25 -0
  135. Cython/Includes/cpython/iterator.pxd +36 -0
  136. Cython/Includes/cpython/iterobject.pxd +24 -0
  137. Cython/Includes/cpython/list.pxd +144 -0
  138. Cython/Includes/cpython/long.pxd +180 -0
  139. Cython/Includes/cpython/longintrepr.pxd +14 -0
  140. Cython/Includes/cpython/mapping.pxd +63 -0
  141. Cython/Includes/cpython/marshal.pxd +66 -0
  142. Cython/Includes/cpython/mem.pxd +120 -0
  143. Cython/Includes/cpython/memoryview.pxd +50 -0
  144. Cython/Includes/cpython/method.pxd +49 -0
  145. Cython/Includes/cpython/module.pxd +208 -0
  146. Cython/Includes/cpython/number.pxd +258 -0
  147. Cython/Includes/cpython/object.pxd +430 -0
  148. Cython/Includes/cpython/pycapsule.pxd +143 -0
  149. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  150. Cython/Includes/cpython/pyport.pxd +8 -0
  151. Cython/Includes/cpython/pystate.pxd +95 -0
  152. Cython/Includes/cpython/pythread.pxd +53 -0
  153. Cython/Includes/cpython/ref.pxd +141 -0
  154. Cython/Includes/cpython/sentinel.pxd +17 -0
  155. Cython/Includes/cpython/sequence.pxd +134 -0
  156. Cython/Includes/cpython/set.pxd +119 -0
  157. Cython/Includes/cpython/slice.pxd +70 -0
  158. Cython/Includes/cpython/time.pxd +129 -0
  159. Cython/Includes/cpython/tuple.pxd +72 -0
  160. Cython/Includes/cpython/type.pxd +146 -0
  161. Cython/Includes/cpython/unicode.pxd +639 -0
  162. Cython/Includes/cpython/version.pxd +32 -0
  163. Cython/Includes/cpython/weakref.pxd +78 -0
  164. Cython/Includes/libc/__init__.pxd +1 -0
  165. Cython/Includes/libc/complex.pxd +35 -0
  166. Cython/Includes/libc/errno.pxd +127 -0
  167. Cython/Includes/libc/float.pxd +43 -0
  168. Cython/Includes/libc/limits.pxd +28 -0
  169. Cython/Includes/libc/locale.pxd +46 -0
  170. Cython/Includes/libc/math.pxd +209 -0
  171. Cython/Includes/libc/setjmp.pxd +10 -0
  172. Cython/Includes/libc/signal.pxd +64 -0
  173. Cython/Includes/libc/stddef.pxd +9 -0
  174. Cython/Includes/libc/stdint.pxd +105 -0
  175. Cython/Includes/libc/stdio.pxd +80 -0
  176. Cython/Includes/libc/stdlib.pxd +72 -0
  177. Cython/Includes/libc/string.pxd +50 -0
  178. Cython/Includes/libc/threads.pxd +234 -0
  179. Cython/Includes/libc/time.pxd +52 -0
  180. Cython/Includes/libcpp/__init__.pxd +4 -0
  181. Cython/Includes/libcpp/algorithm.pxd +320 -0
  182. Cython/Includes/libcpp/any.pxd +16 -0
  183. Cython/Includes/libcpp/atomic.pxd +59 -0
  184. Cython/Includes/libcpp/barrier.pxd +22 -0
  185. Cython/Includes/libcpp/bit.pxd +29 -0
  186. Cython/Includes/libcpp/cast.pxd +12 -0
  187. Cython/Includes/libcpp/cmath.pxd +518 -0
  188. Cython/Includes/libcpp/complex.pxd +106 -0
  189. Cython/Includes/libcpp/condition_variable.pxd +322 -0
  190. Cython/Includes/libcpp/deque.pxd +165 -0
  191. Cython/Includes/libcpp/exception.pxd +216 -0
  192. Cython/Includes/libcpp/execution.pxd +15 -0
  193. Cython/Includes/libcpp/forward_list.pxd +63 -0
  194. Cython/Includes/libcpp/functional.pxd +26 -0
  195. Cython/Includes/libcpp/future.pxd +103 -0
  196. Cython/Includes/libcpp/iterator.pxd +34 -0
  197. Cython/Includes/libcpp/latch.pxd +17 -0
  198. Cython/Includes/libcpp/limits.pxd +61 -0
  199. Cython/Includes/libcpp/list.pxd +117 -0
  200. Cython/Includes/libcpp/map.pxd +252 -0
  201. Cython/Includes/libcpp/memory.pxd +115 -0
  202. Cython/Includes/libcpp/mutex.pxd +387 -0
  203. Cython/Includes/libcpp/numbers.pxd +15 -0
  204. Cython/Includes/libcpp/numeric.pxd +131 -0
  205. Cython/Includes/libcpp/optional.pxd +34 -0
  206. Cython/Includes/libcpp/pair.pxd +1 -0
  207. Cython/Includes/libcpp/queue.pxd +25 -0
  208. Cython/Includes/libcpp/random.pxd +166 -0
  209. Cython/Includes/libcpp/semaphore.pxd +43 -0
  210. Cython/Includes/libcpp/set.pxd +228 -0
  211. Cython/Includes/libcpp/shared_mutex.pxd +96 -0
  212. Cython/Includes/libcpp/span.pxd +87 -0
  213. Cython/Includes/libcpp/stack.pxd +11 -0
  214. Cython/Includes/libcpp/stop_token.pxd +117 -0
  215. Cython/Includes/libcpp/string.pxd +355 -0
  216. Cython/Includes/libcpp/string_view.pxd +183 -0
  217. Cython/Includes/libcpp/typeindex.pxd +15 -0
  218. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  219. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  220. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  221. Cython/Includes/libcpp/utility.pxd +30 -0
  222. Cython/Includes/libcpp/vector.pxd +186 -0
  223. Cython/Includes/numpy/math.pxd +150 -0
  224. Cython/Includes/openmp.pxd +50 -0
  225. Cython/Includes/posix/__init__.pxd +1 -0
  226. Cython/Includes/posix/dlfcn.pxd +14 -0
  227. Cython/Includes/posix/fcntl.pxd +86 -0
  228. Cython/Includes/posix/ioctl.pxd +4 -0
  229. Cython/Includes/posix/mman.pxd +101 -0
  230. Cython/Includes/posix/resource.pxd +57 -0
  231. Cython/Includes/posix/select.pxd +21 -0
  232. Cython/Includes/posix/signal.pxd +73 -0
  233. Cython/Includes/posix/stat.pxd +98 -0
  234. Cython/Includes/posix/stdio.pxd +37 -0
  235. Cython/Includes/posix/stdlib.pxd +29 -0
  236. Cython/Includes/posix/strings.pxd +9 -0
  237. Cython/Includes/posix/time.pxd +71 -0
  238. Cython/Includes/posix/types.pxd +30 -0
  239. Cython/Includes/posix/uio.pxd +26 -0
  240. Cython/Includes/posix/unistd.pxd +271 -0
  241. Cython/Includes/posix/wait.pxd +38 -0
  242. Cython/LZSS.py +170 -0
  243. Cython/Plex/Actions.cp315-win_amd64.pyd +0 -0
  244. Cython/Plex/Actions.pxd +24 -0
  245. Cython/Plex/Actions.py +119 -0
  246. Cython/Plex/DFA.cp315-win_amd64.pyd +0 -0
  247. Cython/Plex/DFA.pxd +14 -0
  248. Cython/Plex/DFA.py +164 -0
  249. Cython/Plex/Errors.py +48 -0
  250. Cython/Plex/Lexicons.py +178 -0
  251. Cython/Plex/Machines.cp315-win_amd64.pyd +0 -0
  252. Cython/Plex/Machines.pxd +36 -0
  253. Cython/Plex/Machines.py +238 -0
  254. Cython/Plex/Regexps.py +535 -0
  255. Cython/Plex/Scanners.cp315-win_amd64.pyd +0 -0
  256. Cython/Plex/Scanners.pxd +45 -0
  257. Cython/Plex/Scanners.py +328 -0
  258. Cython/Plex/Transitions.cp315-win_amd64.pyd +0 -0
  259. Cython/Plex/Transitions.pxd +14 -0
  260. Cython/Plex/Transitions.py +239 -0
  261. Cython/Plex/__init__.py +34 -0
  262. Cython/Runtime/__init__.py +1 -0
  263. Cython/Runtime/refnanny.cp315-win_amd64.pyd +0 -0
  264. Cython/Runtime/refnanny.pyx +237 -0
  265. Cython/Shadow.py +1167 -0
  266. Cython/StringIOTree.cp315-win_amd64.pyd +0 -0
  267. Cython/StringIOTree.py +169 -0
  268. Cython/Tempita/__init__.py +4 -0
  269. Cython/Tempita/_looper.py +154 -0
  270. Cython/Tempita/_tempita.cp315-win_amd64.pyd +0 -0
  271. Cython/Tempita/_tempita.py +1087 -0
  272. Cython/TestUtils.py +464 -0
  273. Cython/Tests/TestCodeWriter.py +128 -0
  274. Cython/Tests/TestCythonUtils.py +202 -0
  275. Cython/Tests/TestJediTyper.py +223 -0
  276. Cython/Tests/TestShadow.py +110 -0
  277. Cython/Tests/TestStringIOTree.py +68 -0
  278. Cython/Tests/TestTestUtils.py +89 -0
  279. Cython/Tests/__init__.py +1 -0
  280. Cython/Tests/xmlrunner.py +390 -0
  281. Cython/Utility/AsyncGen.c +1073 -0
  282. Cython/Utility/Buffer.c +866 -0
  283. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  284. Cython/Utility/Builtins.c +933 -0
  285. Cython/Utility/CConvert.pyx +149 -0
  286. Cython/Utility/CMath.c +104 -0
  287. Cython/Utility/CommonStructures.c +244 -0
  288. Cython/Utility/Complex.c +378 -0
  289. Cython/Utility/Coroutine.c +2337 -0
  290. Cython/Utility/CpdefEnums.pyx +107 -0
  291. Cython/Utility/CppConvert.pyx +282 -0
  292. Cython/Utility/CppSupport.cpp +151 -0
  293. Cython/Utility/CythonFunction.c +2072 -0
  294. Cython/Utility/Dataclasses.c +101 -0
  295. Cython/Utility/Embed.c +129 -0
  296. Cython/Utility/Exceptions.c +1038 -0
  297. Cython/Utility/ExtensionTypes.c +1158 -0
  298. Cython/Utility/FunctionArguments.c +1045 -0
  299. Cython/Utility/FusedFunction.pyx +44 -0
  300. Cython/Utility/ImportExport.c +930 -0
  301. Cython/Utility/MatchCase.c +979 -0
  302. Cython/Utility/MatchCase_Cy.pyx +12 -0
  303. Cython/Utility/MemoryView.pxd +108 -0
  304. Cython/Utility/MemoryView.pyx +1499 -0
  305. Cython/Utility/MemoryView_C.c +1056 -0
  306. Cython/Utility/ModuleSetupCode.c +3352 -0
  307. Cython/Utility/NumpyImportArray.c +46 -0
  308. Cython/Utility/ObjectHandling.c +3372 -0
  309. Cython/Utility/Optimize.c +2563 -0
  310. Cython/Utility/Overflow.c +378 -0
  311. Cython/Utility/Profile.c +736 -0
  312. Cython/Utility/StringTools.c +1414 -0
  313. Cython/Utility/Synchronization.c +438 -0
  314. Cython/Utility/TString.c +369 -0
  315. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  316. Cython/Utility/TestCythonScope.pyx +75 -0
  317. Cython/Utility/TestUtilityLoader.c +12 -0
  318. Cython/Utility/TypeConversion.c +1556 -0
  319. Cython/Utility/UFuncs.pyx +50 -0
  320. Cython/Utility/UFuncs_C.c +89 -0
  321. Cython/Utility/__init__.py +28 -0
  322. Cython/Utility/arrayarray.h +172 -0
  323. Cython/Utils.cp315-win_amd64.pyd +0 -0
  324. Cython/Utils.py +677 -0
  325. Cython/__init__.py +12 -0
  326. Cython/py.typed +0 -0
  327. cython-3.3.0a1.dist-info/METADATA +394 -0
  328. cython-3.3.0a1.dist-info/RECORD +335 -0
  329. cython-3.3.0a1.dist-info/WHEEL +5 -0
  330. cython-3.3.0a1.dist-info/entry_points.txt +4 -0
  331. cython-3.3.0a1.dist-info/top_level.txt +3 -0
  332. cython.py +29 -0
  333. pyximport/__init__.py +4 -0
  334. pyximport/pyxbuild.py +160 -0
  335. pyximport/pyximport.py +482 -0
Cython/CodeWriter.py ADDED
@@ -0,0 +1,815 @@
1
+ """
2
+ Serializes a Cython code tree to Cython code. This is primarily useful for
3
+ debugging and testing purposes.
4
+ The output is in a strict format, no whitespace or comments from the input
5
+ is preserved (and it could not be as it is not present in the code tree).
6
+ """
7
+
8
+
9
+ from .Compiler.Visitor import TreeVisitor
10
+ from .Compiler.ExprNodes import *
11
+ from .Compiler.Nodes import CSimpleBaseTypeNode
12
+
13
+
14
+ class LinesResult:
15
+ def __init__(self):
16
+ self.lines = []
17
+ self.s = ""
18
+
19
+ def put(self, s):
20
+ self.s += s
21
+
22
+ def newline(self):
23
+ self.lines.append(self.s)
24
+ self.s = ""
25
+
26
+ def putline(self, s):
27
+ self.put(s)
28
+ self.newline()
29
+
30
+
31
+ class DeclarationWriter(TreeVisitor):
32
+ """
33
+ A Cython code writer that is limited to declarations nodes.
34
+ """
35
+
36
+ indent_string = " "
37
+
38
+ def __init__(self, result=None):
39
+ super().__init__()
40
+ if result is None:
41
+ result = LinesResult()
42
+ self.result = result
43
+ self.numindents = 0
44
+ self.tempnames = {}
45
+ self.tempblockindex = 0
46
+
47
+ def write(self, tree):
48
+ self.visit(tree)
49
+ return self.result
50
+
51
+ def indent(self):
52
+ self.numindents += 1
53
+
54
+ def dedent(self):
55
+ self.numindents -= 1
56
+
57
+ def startline(self, s=""):
58
+ self.result.put(self.indent_string * self.numindents + s)
59
+
60
+ def put(self, s):
61
+ self.result.put(s)
62
+
63
+ def putline(self, s):
64
+ self.result.putline(self.indent_string * self.numindents + s)
65
+
66
+ def endline(self, s=""):
67
+ self.result.putline(s)
68
+
69
+ def line(self, s):
70
+ self.startline(s)
71
+ self.endline()
72
+
73
+ def comma_separated_list(self, items, output_rhs=False):
74
+ if len(items) > 0:
75
+ for item in items[:-1]:
76
+ self.visit(item)
77
+ if output_rhs and item.default is not None:
78
+ self.put(" = ")
79
+ self.visit(item.default)
80
+ self.put(", ")
81
+ self.visit(items[-1])
82
+ if output_rhs and items[-1].default is not None:
83
+ self.put(" = ")
84
+ self.visit(items[-1].default)
85
+
86
+ def _visit_indented(self, node):
87
+ self.indent()
88
+ self.visit(node)
89
+ self.dedent()
90
+
91
+ def visit_Node(self, node):
92
+ raise AssertionError("Node not handled by serializer: %r" % node)
93
+
94
+ def visit_ModuleNode(self, node):
95
+ self.visitchildren(node)
96
+
97
+ def visit_StatListNode(self, node):
98
+ self.visitchildren(node)
99
+
100
+ def visit_CDefExternNode(self, node):
101
+ if node.include_file is None:
102
+ file = '*'
103
+ else:
104
+ file = '"%s"' % node.include_file
105
+ self.putline("cdef extern from %s:" % file)
106
+ self._visit_indented(node.body)
107
+
108
+ def visit_CPtrDeclaratorNode(self, node):
109
+ self.put('*')
110
+ self.visit(node.base)
111
+
112
+ def visit_CReferenceDeclaratorNode(self, node):
113
+ self.put('&')
114
+ self.visit(node.base)
115
+
116
+ def visit_CArrayDeclaratorNode(self, node):
117
+ self.visit(node.base)
118
+ self.put('[')
119
+ if node.dimension is not None:
120
+ self.visit(node.dimension)
121
+ self.put(']')
122
+
123
+ def visit_CFuncDeclaratorNode(self, node):
124
+ # TODO: except, gil, etc.
125
+ self.visit(node.base)
126
+ self.put('(')
127
+ self.comma_separated_list(node.args)
128
+ self.endline(')')
129
+
130
+ def visit_CNameDeclaratorNode(self, node):
131
+ self.put(node.name)
132
+
133
+ def visit_CSimpleBaseTypeNode(self, node):
134
+ # See Parsing.p_sign_and_longness
135
+ if node.is_basic_c_type:
136
+ self.put(("unsigned ", "", "signed ")[node.signed])
137
+ if node.longness < 0:
138
+ self.put("short " * -node.longness)
139
+ elif node.longness > 0:
140
+ self.put("long " * node.longness)
141
+ if node.name is not None:
142
+ self.put(node.name)
143
+
144
+ def visit_CComplexBaseTypeNode(self, node):
145
+ self.visit(node.base_type)
146
+ self.visit(node.declarator)
147
+
148
+ def visit_CNestedBaseTypeNode(self, node):
149
+ self.visit(node.base_type)
150
+ self.put('.')
151
+ self.put(node.name)
152
+
153
+ def visit_TemplatedTypeNode(self, node):
154
+ self.visit(node.base_type_node)
155
+ self.put('[')
156
+ self.comma_separated_list(node.positional_args + node.keyword_args.key_value_pairs)
157
+ self.put(']')
158
+
159
+ def visit_CVarDefNode(self, node):
160
+ self.startline("cdef ")
161
+ self.visit(node.base_type)
162
+ self.put(" ")
163
+ self.comma_separated_list(node.declarators, output_rhs=True)
164
+ self.endline()
165
+
166
+ def _visit_container_node(self, node, decl, extras, attributes):
167
+ # TODO: visibility
168
+ self.startline(decl)
169
+ if node.name:
170
+ self.put(' ')
171
+ self.put(node.name)
172
+ if node.cname is not None:
173
+ self.put(' "%s"' % node.cname)
174
+ if extras:
175
+ self.put(extras)
176
+ self.endline(':')
177
+ self.indent()
178
+ if not attributes:
179
+ self.putline('pass')
180
+ else:
181
+ for attribute in attributes:
182
+ self.visit(attribute)
183
+ self.dedent()
184
+
185
+ def visit_CStructOrUnionDefNode(self, node):
186
+ if node.typedef_flag:
187
+ decl = 'ctypedef '
188
+ else:
189
+ decl = 'cdef '
190
+ if node.visibility == 'public':
191
+ decl += 'public '
192
+ if node.packed:
193
+ decl += 'packed '
194
+ decl += node.kind
195
+ self._visit_container_node(node, decl, None, node.attributes)
196
+
197
+ def visit_CppClassNode(self, node):
198
+ extras = ""
199
+ if node.templates:
200
+ extras = "[%s]" % ", ".join(node.templates)
201
+ if node.base_classes:
202
+ extras += "(%s)" % ", ".join(node.base_classes)
203
+ self._visit_container_node(node, "cdef cppclass", extras, node.attributes)
204
+
205
+ def visit_CEnumDefNode(self, node):
206
+ self._visit_container_node(node, "cdef enum", None, node.items)
207
+
208
+ def visit_CEnumDefItemNode(self, node):
209
+ self.startline(node.name)
210
+ if node.cname:
211
+ self.put(' "%s"' % node.cname)
212
+ if node.value:
213
+ self.put(" = ")
214
+ self.visit(node.value)
215
+ self.endline()
216
+
217
+ def visit_CClassDefNode(self, node):
218
+ assert not node.module_name
219
+ if node.decorators:
220
+ for decorator in node.decorators:
221
+ self.visit(decorator)
222
+ self.startline("cdef class ")
223
+ self.put(node.class_name)
224
+ if node.base_class_name:
225
+ self.put("(")
226
+ if node.base_class_module:
227
+ self.put(node.base_class_module)
228
+ self.put(".")
229
+ self.put(node.base_class_name)
230
+ self.put(")")
231
+ self.endline(":")
232
+ self._visit_indented(node.body)
233
+
234
+ def visit_CTypeDefNode(self, node):
235
+ self.startline("ctypedef ")
236
+ self.visit(node.base_type)
237
+ self.put(" ")
238
+ self.visit(node.declarator)
239
+ self.endline()
240
+
241
+ def visit_FuncDefNode(self, node):
242
+ # TODO: support cdef + cpdef functions
243
+ self.startline("def %s(" % node.name)
244
+ self.comma_separated_list(node.args)
245
+ self.endline("):")
246
+ self._visit_indented(node.body)
247
+
248
+ def visit_CFuncDefNode(self, node):
249
+ self.startline('cpdef ' if node.overridable else 'cdef ')
250
+ if node.modifiers:
251
+ self.put(' '.join(node.modifiers))
252
+ self.put(' ')
253
+ if node.visibility != 'private':
254
+ self.put(node.visibility)
255
+ self.put(' ')
256
+ if node.api:
257
+ self.put('api ')
258
+
259
+ if node.base_type:
260
+ self.visit(node.base_type)
261
+ if node.base_type.name is not None:
262
+ self.put(' ')
263
+
264
+ # visit the CFuncDeclaratorNode, but put a `:` at the end of line
265
+ self.visit(node.declarator.base)
266
+ self.put('(')
267
+ self.comma_separated_list(node.declarator.args)
268
+ self.endline('):')
269
+
270
+ self._visit_indented(node.body)
271
+
272
+ def visit_CArgDeclNode(self, node):
273
+ # For "CSimpleBaseTypeNode", the variable type may have been parsed as type.
274
+ # For other node types, the "name" is always None.
275
+ if not isinstance(node.base_type, CSimpleBaseTypeNode) or \
276
+ node.base_type.name is not None:
277
+ self.visit(node.base_type)
278
+
279
+ # If we printed something for "node.base_type", we may need to print an extra ' '.
280
+ #
281
+ # Special case: if "node.declarator" is a "CNameDeclaratorNode",
282
+ # its "name" might be an empty string, for example, for "cdef f(x)".
283
+ if node.declarator.declared_name():
284
+ self.put(" ")
285
+ self.visit(node.declarator)
286
+ if node.default is not None:
287
+ self.put(" = ")
288
+ self.visit(node.default)
289
+
290
+ def visit_CImportStatNode(self, node):
291
+ self.startline("cimport ")
292
+ self.put(node.module_name)
293
+ if node.as_name:
294
+ self.put(" as ")
295
+ self.put(node.as_name)
296
+ self.endline()
297
+
298
+ def visit_FromCImportStatNode(self, node):
299
+ self.startline("from ")
300
+ self.put(node.module_name)
301
+ self.put(" cimport ")
302
+ first = True
303
+ for pos, name, as_name, kind in node.imported_names:
304
+ assert kind is None
305
+ if first:
306
+ first = False
307
+ else:
308
+ self.put(", ")
309
+ self.put(name)
310
+ if as_name:
311
+ self.put(" as ")
312
+ self.put(as_name)
313
+ self.endline()
314
+
315
+ def visit_NameNode(self, node):
316
+ self.put(node.name)
317
+
318
+ def visit_DecoratorNode(self, node):
319
+ self.startline("@")
320
+ self.visit(node.decorator)
321
+ self.endline()
322
+
323
+ def visit_PassStatNode(self, node):
324
+ self.startline("pass")
325
+ self.endline()
326
+
327
+
328
+ class StatementWriter(DeclarationWriter):
329
+ """
330
+ A Cython code writer for most language statement features.
331
+ """
332
+
333
+ def visit_SingleAssignmentNode(self, node):
334
+ self.startline()
335
+ self.visit(node.lhs)
336
+ self.put(" = ")
337
+ self.visit(node.rhs)
338
+ self.endline()
339
+
340
+ def visit_CascadedAssignmentNode(self, node):
341
+ self.startline()
342
+ for lhs in node.lhs_list:
343
+ self.visit(lhs)
344
+ self.put(" = ")
345
+ self.visit(node.rhs)
346
+ self.endline()
347
+
348
+ def visit_PrintStatNode(self, node):
349
+ self.startline("print ")
350
+ self.comma_separated_list(node.arg_tuple.args)
351
+ if not node.append_newline:
352
+ self.put(",")
353
+ self.endline()
354
+
355
+ def visit_ForInStatNode(self, node):
356
+ self.startline("for ")
357
+ if node.target.is_sequence_constructor:
358
+ self.comma_separated_list(node.target.args)
359
+ else:
360
+ self.visit(node.target)
361
+ self.put(" in ")
362
+ self.visit(node.iterator.sequence)
363
+ self.endline(":")
364
+ self._visit_indented(node.body)
365
+ if node.else_clause is not None:
366
+ self.line("else:")
367
+ self._visit_indented(node.else_clause)
368
+
369
+ def visit_IfStatNode(self, node):
370
+ # The IfClauseNode is handled directly without a separate match
371
+ # for clariy.
372
+ self.startline("if ")
373
+ self.visit(node.if_clauses[0].condition)
374
+ self.endline(":")
375
+ self._visit_indented(node.if_clauses[0].body)
376
+ for clause in node.if_clauses[1:]:
377
+ self.startline("elif ")
378
+ self.visit(clause.condition)
379
+ self.endline(":")
380
+ self._visit_indented(clause.body)
381
+ if node.else_clause is not None:
382
+ self.line("else:")
383
+ self._visit_indented(node.else_clause)
384
+
385
+ def visit_WhileStatNode(self, node):
386
+ self.startline("while ")
387
+ self.visit(node.condition)
388
+ self.endline(":")
389
+ self._visit_indented(node.body)
390
+ if node.else_clause is not None:
391
+ self.line("else:")
392
+ self._visit_indented(node.else_clause)
393
+
394
+ def visit_ContinueStatNode(self, node):
395
+ self.line("continue")
396
+
397
+ def visit_BreakStatNode(self, node):
398
+ self.line("break")
399
+
400
+ def visit_SequenceNode(self, node):
401
+ self.comma_separated_list(node.args) # Might need to discover whether we need () around tuples...hmm...
402
+
403
+ def visit_ExprStatNode(self, node):
404
+ self.startline()
405
+ self.visit(node.expr)
406
+ self.endline()
407
+
408
+ def visit_InPlaceAssignmentNode(self, node):
409
+ self.startline()
410
+ self.visit(node.lhs)
411
+ self.put(" %s= " % node.operator)
412
+ self.visit(node.rhs)
413
+ self.endline()
414
+
415
+ def visit_WithStatNode(self, node):
416
+ self.startline()
417
+ self.put("with ")
418
+ self.visit(node.manager)
419
+ if node.target is not None:
420
+ self.put(" as ")
421
+ self.visit(node.target)
422
+ self.endline(":")
423
+ self._visit_indented(node.body)
424
+
425
+ def visit_TryFinallyStatNode(self, node):
426
+ self.line("try:")
427
+ self._visit_indented(node.body)
428
+ self.line("finally:")
429
+ self._visit_indented(node.finally_clause)
430
+
431
+ def visit_TryExceptStatNode(self, node):
432
+ self.line("try:")
433
+ self._visit_indented(node.body)
434
+ for x in node.except_clauses:
435
+ self.visit(x)
436
+ if node.else_clause is not None:
437
+ self.visit(node.else_clause)
438
+
439
+ def visit_ExceptClauseNode(self, node):
440
+ self.startline("except")
441
+ if node.pattern is not None:
442
+ self.put(" ")
443
+ self.visit(node.pattern)
444
+ if node.target is not None:
445
+ self.put(", ")
446
+ self.visit(node.target)
447
+ self.endline(":")
448
+ self._visit_indented(node.body)
449
+
450
+ def visit_ReturnStatNode(self, node):
451
+ self.startline("return")
452
+ if node.value is not None:
453
+ self.put(" ")
454
+ self.visit(node.value)
455
+ self.endline()
456
+
457
+ def visit_ReraiseStatNode(self, node):
458
+ self.line("raise")
459
+
460
+ def visit_ImportNode(self, node):
461
+ self.put("(import %s)" % node.module_name.value)
462
+
463
+ def visit_TempsBlockNode(self, node):
464
+ """
465
+ Temporaries are output like $1_1', where the first number is
466
+ an index of the TempsBlockNode and the second number is an index
467
+ of the temporary which that block allocates.
468
+ """
469
+ idx = 0
470
+ for handle in node.temps:
471
+ self.tempnames[handle] = "$%d_%d" % (self.tempblockindex, idx)
472
+ idx += 1
473
+ self.tempblockindex += 1
474
+ self.visit(node.body)
475
+
476
+ def visit_TempRefNode(self, node):
477
+ self.put(self.tempnames[node.handle])
478
+
479
+
480
+ class ExpressionWriter(TreeVisitor):
481
+ """
482
+ A Cython code writer that is intentionally limited to expressions.
483
+ """
484
+
485
+ def __init__(self, result=None, allow_unknown_nodes=False):
486
+ super().__init__()
487
+ if result is None:
488
+ result = ""
489
+ self.result = result
490
+ self.allow_unknown_nodes = allow_unknown_nodes
491
+ self.precedence = [0]
492
+
493
+ def write(self, tree):
494
+ self.visit(tree)
495
+ return self.result
496
+
497
+ def put(self, s):
498
+ self.result += s
499
+
500
+ def remove(self, s):
501
+ if self.result.endswith(s):
502
+ self.result = self.result[:-len(s)]
503
+
504
+ def comma_separated_list(self, items):
505
+ if len(items) > 0:
506
+ for item in items[:-1]:
507
+ self.visit(item)
508
+ self.put(", ")
509
+ self.visit(items[-1])
510
+
511
+ def visit_Node(self, node):
512
+ if self.allow_unknown_nodes:
513
+ self.put("...")
514
+ else:
515
+ raise AssertionError("Node not handled by serializer: %r" % node)
516
+
517
+ # TODO: Remove redundancy below. Most constants serialise fine as just "repr(node.value)".
518
+
519
+ def visit_IntNode(self, node):
520
+ self.put(node.value)
521
+
522
+ def visit_FloatNode(self, node):
523
+ self.put(node.value)
524
+
525
+ def visit_NoneNode(self, node):
526
+ self.put("None")
527
+
528
+ def visit_NameNode(self, node):
529
+ self.put(node.name)
530
+
531
+ def visit_EllipsisNode(self, node):
532
+ self.put("...")
533
+
534
+ def visit_BoolNode(self, node):
535
+ self.put(str(node.value))
536
+
537
+ def visit_ConstNode(self, node):
538
+ self.put(str(node.value))
539
+
540
+ def visit_ImagNode(self, node):
541
+ self.put(f"{node.value}j")
542
+
543
+ def visit_BytesNode(self, node):
544
+ self.put(repr(node.value))
545
+
546
+ def visit_UnicodeNode(self, node):
547
+ self.put(repr(node.value))
548
+
549
+ def emit_sequence(self, node, parens=("", "")):
550
+ open_paren, close_paren = parens
551
+ items = node.subexpr_nodes()
552
+ self.put(open_paren)
553
+ self.comma_separated_list(items)
554
+ self.put(close_paren)
555
+
556
+ def visit_ListNode(self, node):
557
+ self.emit_sequence(node, "[]")
558
+
559
+ def visit_TupleNode(self, node):
560
+ self.emit_sequence(node, "()")
561
+
562
+ def visit_SetNode(self, node):
563
+ if len(node.subexpr_nodes()) > 0:
564
+ self.emit_sequence(node, "{}")
565
+ else:
566
+ self.put("set()")
567
+
568
+ def visit_DictNode(self, node):
569
+ self.emit_sequence(node, "{}")
570
+
571
+ def visit_DictItemNode(self, node):
572
+ self.visit(node.key)
573
+ self.put(": ")
574
+ self.visit(node.value)
575
+
576
+ unop_precedence = {
577
+ 'not': 3, '!': 3,
578
+ '+': 11, '-': 11, '~': 11,
579
+ }
580
+ binop_precedence = {
581
+ 'or': 1,
582
+ 'and': 2,
583
+ # unary: 'not': 3, '!': 3,
584
+ 'in': 4, 'not_in': 4, 'is': 4, 'is_not': 4, '<': 4, '<=': 4, '>': 4, '>=': 4, '!=': 4, '==': 4,
585
+ '|': 5,
586
+ '^': 6,
587
+ '&': 7,
588
+ '<<': 8, '>>': 8,
589
+ '+': 9, '-': 9,
590
+ '*': 10, '@': 10, '/': 10, '//': 10, '%': 10,
591
+ # unary: '+': 11, '-': 11, '~': 11
592
+ '**': 12,
593
+ }
594
+
595
+ def operator_enter(self, new_prec):
596
+ old_prec = self.precedence[-1]
597
+ if old_prec > new_prec:
598
+ self.put("(")
599
+ self.precedence.append(new_prec)
600
+
601
+ def operator_exit(self):
602
+ old_prec, new_prec = self.precedence[-2:]
603
+ if old_prec > new_prec:
604
+ self.put(")")
605
+ self.precedence.pop()
606
+
607
+ def visit_NotNode(self, node):
608
+ op = 'not'
609
+ prec = self.unop_precedence[op]
610
+ self.operator_enter(prec)
611
+ self.put("not ")
612
+ self.visit(node.operand)
613
+ self.operator_exit()
614
+
615
+ def visit_UnopNode(self, node):
616
+ op = node.operator
617
+ prec = self.unop_precedence[op]
618
+ self.operator_enter(prec)
619
+ self.put("%s" % node.operator)
620
+ self.visit(node.operand)
621
+ self.operator_exit()
622
+
623
+ def visit_BinopNode(self, node):
624
+ op = node.operator
625
+ prec = self.binop_precedence.get(op, 0)
626
+ self.operator_enter(prec)
627
+ self.visit(node.operand1)
628
+ self.put(" %s " % op.replace('_', ' '))
629
+ self.visit(node.operand2)
630
+ self.operator_exit()
631
+
632
+ def visit_BoolBinopNode(self, node):
633
+ self.visit_BinopNode(node)
634
+
635
+ def visit_PrimaryCmpNode(self, node):
636
+ self.visit_BinopNode(node)
637
+
638
+ def visit_IndexNode(self, node):
639
+ self.visit(node.base)
640
+ self.put("[")
641
+ if isinstance(node.index, TupleNode):
642
+ if node.index.subexpr_nodes():
643
+ self.emit_sequence(node.index)
644
+ else:
645
+ self.put("()")
646
+ else:
647
+ self.visit(node.index)
648
+ self.put("]")
649
+
650
+ def visit_SliceIndexNode(self, node):
651
+ self.visit(node.base)
652
+ self.put("[")
653
+ if node.start:
654
+ self.visit(node.start)
655
+ self.put(":")
656
+ if node.stop:
657
+ self.visit(node.stop)
658
+ if node.slice:
659
+ self.put(":")
660
+ self.visit(node.slice)
661
+ self.put("]")
662
+
663
+ def visit_SliceNode(self, node):
664
+ if not node.start.is_none:
665
+ self.visit(node.start)
666
+ self.put(":")
667
+ if not node.stop.is_none:
668
+ self.visit(node.stop)
669
+ if not node.step.is_none:
670
+ self.put(":")
671
+ self.visit(node.step)
672
+
673
+ def visit_CondExprNode(self, node):
674
+ self.visit(node.true_val)
675
+ self.put(" if ")
676
+ self.visit(node.test)
677
+ self.put(" else ")
678
+ self.visit(node.false_val)
679
+
680
+ def visit_AttributeNode(self, node):
681
+ self.visit(node.obj)
682
+ self.put(".%s" % node.attribute)
683
+
684
+ def visit_SimpleCallNode(self, node):
685
+ self.visit(node.function)
686
+ self.put("(")
687
+ self.comma_separated_list(node.args)
688
+ self.put(")")
689
+
690
+ def emit_pos_args(self, node):
691
+ if node is None:
692
+ return
693
+ if isinstance(node, AddNode):
694
+ self.emit_pos_args(node.operand1)
695
+ self.emit_pos_args(node.operand2)
696
+ elif isinstance(node, TupleNode):
697
+ for expr in node.subexpr_nodes():
698
+ self.visit(expr)
699
+ self.put(", ")
700
+ elif isinstance(node, AsTupleNode):
701
+ self.put("*")
702
+ self.visit(node.arg)
703
+ self.put(", ")
704
+ else:
705
+ self.visit(node)
706
+ self.put(", ")
707
+
708
+ def emit_kwd_args(self, node):
709
+ if node is None:
710
+ return
711
+ if isinstance(node, MergedDictNode):
712
+ for expr in node.subexpr_nodes():
713
+ self.emit_kwd_args(expr)
714
+ elif isinstance(node, DictNode):
715
+ for expr in node.subexpr_nodes():
716
+ self.put("%s=" % expr.key.value)
717
+ self.visit(expr.value)
718
+ self.put(", ")
719
+ else:
720
+ self.put("**")
721
+ self.visit(node)
722
+ self.put(", ")
723
+
724
+ def visit_GeneralCallNode(self, node):
725
+ self.visit(node.function)
726
+ self.put("(")
727
+ self.emit_pos_args(node.positional_args)
728
+ self.emit_kwd_args(node.keyword_args)
729
+ self.remove(", ")
730
+ self.put(")")
731
+
732
+ def emit_comprehension(self, body, target,
733
+ sequence, condition,
734
+ parens=("", "")):
735
+ open_paren, close_paren = parens
736
+ self.put(open_paren)
737
+ self.visit(body)
738
+ self.put(" for ")
739
+ self.visit(target)
740
+ self.put(" in ")
741
+ self.visit(sequence)
742
+ if condition:
743
+ self.put(" if ")
744
+ self.visit(condition)
745
+ self.put(close_paren)
746
+
747
+ def visit_ComprehensionAppendNode(self, node):
748
+ self.visit(node.expr)
749
+
750
+ def visit_DictComprehensionAppendNode(self, node):
751
+ self.visit(node.key_expr)
752
+ self.put(": ")
753
+ self.visit(node.value_expr)
754
+
755
+ def visit_ComprehensionNode(self, node):
756
+ tpmap = {'list': "[]", 'dict': "{}", 'set': "{}"}
757
+ parens = tpmap[node.type.py_type_name()]
758
+ body = node.loop.body
759
+ target = node.loop.target
760
+ sequence = node.loop.iterator.sequence
761
+ condition = None
762
+ if hasattr(body, 'if_clauses'):
763
+ # type(body) is Nodes.IfStatNode
764
+ condition = body.if_clauses[0].condition
765
+ body = body.if_clauses[0].body
766
+ self.emit_comprehension(body, target, sequence, condition, parens)
767
+
768
+ def visit_GeneratorExpressionNode(self, node):
769
+ body = node.loop.body
770
+ target = node.loop.target
771
+ sequence = node.loop.iterator.sequence
772
+ condition = None
773
+ if hasattr(body, 'if_clauses'):
774
+ # type(body) is Nodes.IfStatNode
775
+ condition = body.if_clauses[0].condition
776
+ body = body.if_clauses[0].body.expr.arg
777
+ elif hasattr(body, 'expr'):
778
+ # type(body) is Nodes.ExprStatNode
779
+ body = body.expr.arg
780
+ self.emit_comprehension(body, target, sequence, condition, "()")
781
+
782
+
783
+ class PxdWriter(DeclarationWriter, ExpressionWriter):
784
+ """
785
+ A Cython code writer for everything supported in pxd files.
786
+ (currently unused)
787
+ """
788
+
789
+ def __call__(self, node):
790
+ print('\n'.join(self.write(node).lines))
791
+ return node
792
+
793
+ def visit_CFuncDefNode(self, node):
794
+ if node.overridable:
795
+ self.startline('cpdef ')
796
+ else:
797
+ self.startline('cdef ')
798
+ if node.modifiers:
799
+ self.put(' '.join(node.modifiers))
800
+ self.put(' ')
801
+ if node.visibility != 'private':
802
+ self.put(node.visibility)
803
+ self.put(' ')
804
+ if node.api:
805
+ self.put('api ')
806
+ self.visit(node.declarator)
807
+
808
+ def visit_StatNode(self, node):
809
+ pass
810
+
811
+
812
+ class CodeWriter(StatementWriter, ExpressionWriter):
813
+ """
814
+ A complete Cython code writer.
815
+ """