pytron-kit 0.3.12__py3-none-macosx_11_0_universal2.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 (419) hide show
  1. pytron/__init__.py +112 -0
  2. pytron/application.py +562 -0
  3. pytron/apputils/__init__.py +0 -0
  4. pytron/apputils/chrome_ipc.py +203 -0
  5. pytron/apputils/codegen.py +261 -0
  6. pytron/apputils/config.py +303 -0
  7. pytron/apputils/deadmansswitch.py +47 -0
  8. pytron/apputils/extras.py +76 -0
  9. pytron/apputils/native.py +148 -0
  10. pytron/apputils/shell.py +73 -0
  11. pytron/apputils/windows.py +286 -0
  12. pytron/cli.py +384 -0
  13. pytron/commands/__init__.py +0 -0
  14. pytron/commands/android.py +28 -0
  15. pytron/commands/build.py +26 -0
  16. pytron/commands/doctor.py +221 -0
  17. pytron/commands/engine.py +23 -0
  18. pytron/commands/frontend.py +60 -0
  19. pytron/commands/harvest.py +112 -0
  20. pytron/commands/helpers.py +239 -0
  21. pytron/commands/info.py +50 -0
  22. pytron/commands/init.py +521 -0
  23. pytron/commands/install.py +294 -0
  24. pytron/commands/login.py +130 -0
  25. pytron/commands/package.py +228 -0
  26. pytron/commands/plugin.py +442 -0
  27. pytron/commands/run.py +312 -0
  28. pytron/commands/scan.py +210 -0
  29. pytron/commands/show.py +23 -0
  30. pytron/commands/uninstall.py +150 -0
  31. pytron/commands/utils.py +42 -0
  32. pytron/commands/workflow.py +95 -0
  33. pytron/console.py +133 -0
  34. pytron/core.py +18 -0
  35. pytron/dependencies/WebView2Loader.dll +0 -0
  36. pytron/dependencies/__init__.py +1 -0
  37. pytron/dependencies/pytron_native.so +0 -0
  38. pytron/engines/chrome/adapter.py +445 -0
  39. pytron/engines/chrome/engine.py +576 -0
  40. pytron/engines/chrome/forge.py +147 -0
  41. pytron/engines/chrome/shell/package.json +8 -0
  42. pytron/engines/chrome/shell/preload.js +12 -0
  43. pytron/engines/chrome/shell/shell.js +534 -0
  44. pytron/exceptions.py +36 -0
  45. pytron/inspector.py +201 -0
  46. pytron/inspector_ui.py +512 -0
  47. pytron/installer/Installation.nsi +236 -0
  48. pytron/installer/header.bmp +0 -0
  49. pytron/installer/pytron.ico +0 -0
  50. pytron/installer/sidebar.bmp +0 -0
  51. pytron/llms.md +98 -0
  52. pytron/manifests/README.md +29 -0
  53. pytron/manifests/windows-utf8.manifest +44 -0
  54. pytron/menu.py +128 -0
  55. pytron/nsis-setup.exe +0 -0
  56. pytron/pack/__init__.py +0 -0
  57. pytron/pack/assets.py +131 -0
  58. pytron/pack/compilers.py +289 -0
  59. pytron/pack/crystal.py +297 -0
  60. pytron/pack/graph.py +377 -0
  61. pytron/pack/inference.py +157 -0
  62. pytron/pack/installers.py +402 -0
  63. pytron/pack/introspect.py +357 -0
  64. pytron/pack/metadata.py +213 -0
  65. pytron/pack/modules.py +618 -0
  66. pytron/pack/nuitka.py +108 -0
  67. pytron/pack/pipeline.py +107 -0
  68. pytron/pack/pyinstaller.py +176 -0
  69. pytron/pack/rust_engine.py +273 -0
  70. pytron/pack/secure.py +309 -0
  71. pytron/pack/secure_loader/bin/pytron_rust_bootloader +0 -0
  72. pytron/pack/secure_loader/icon.ico +0 -0
  73. pytron/pack/utils.py +110 -0
  74. pytron/pack/virtual_root.py +124 -0
  75. pytron/platforms/__init__.py +0 -0
  76. pytron/platforms/android/__init__.py +3 -0
  77. pytron/platforms/android/android.py +103 -0
  78. pytron/platforms/android/builder.py +736 -0
  79. pytron/platforms/android/ops/build.py +79 -0
  80. pytron/platforms/android/ops/init.py +63 -0
  81. pytron/platforms/android/ops/run.py +79 -0
  82. pytron/platforms/android/ops/sync.py +770 -0
  83. pytron/platforms/android/ops/utils.py +8 -0
  84. pytron/platforms/android/shell/README.md +30 -0
  85. pytron/platforms/android/shell/app/build.gradle +64 -0
  86. pytron/platforms/android/shell/app/src/main/AndroidManifest.xml +29 -0
  87. pytron/platforms/android/shell/app/src/main/assets/python/main.py +86 -0
  88. pytron/platforms/android/shell/app/src/main/assets/python/python314.zip +0 -0
  89. pytron/platforms/android/shell/app/src/main/cpp/CMakeLists.txt +25 -0
  90. pytron/platforms/android/shell/app/src/main/cpp/include/Python.h +155 -0
  91. pytron/platforms/android/shell/app/src/main/cpp/include/abstract.h +915 -0
  92. pytron/platforms/android/shell/app/src/main/cpp/include/audit.h +30 -0
  93. pytron/platforms/android/shell/app/src/main/cpp/include/bltinmodule.h +14 -0
  94. pytron/platforms/android/shell/app/src/main/cpp/include/boolobject.h +54 -0
  95. pytron/platforms/android/shell/app/src/main/cpp/include/bytearrayobject.h +44 -0
  96. pytron/platforms/android/shell/app/src/main/cpp/include/bytesobject.h +66 -0
  97. pytron/platforms/android/shell/app/src/main/cpp/include/ceval.h +145 -0
  98. pytron/platforms/android/shell/app/src/main/cpp/include/codecs.h +176 -0
  99. pytron/platforms/android/shell/app/src/main/cpp/include/compile.h +22 -0
  100. pytron/platforms/android/shell/app/src/main/cpp/include/complexobject.h +30 -0
  101. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/abstract.h +104 -0
  102. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/audit.h +8 -0
  103. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytearrayobject.h +38 -0
  104. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytesobject.h +42 -0
  105. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/cellobject.h +50 -0
  106. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/ceval.h +43 -0
  107. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/classobject.h +71 -0
  108. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/code.h +340 -0
  109. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/compile.h +50 -0
  110. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/complexobject.h +33 -0
  111. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/context.h +107 -0
  112. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/critical_section.h +154 -0
  113. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/descrobject.h +62 -0
  114. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/dictobject.h +105 -0
  115. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileobject.h +16 -0
  116. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileutils.h +16 -0
  117. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/floatobject.h +27 -0
  118. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/frameobject.h +35 -0
  119. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/funcobject.h +185 -0
  120. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/genobject.h +56 -0
  121. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/import.h +30 -0
  122. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/initconfig.h +334 -0
  123. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/listobject.h +53 -0
  124. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/lock.h +74 -0
  125. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longintrepr.h +184 -0
  126. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longobject.h +89 -0
  127. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/memoryobject.h +50 -0
  128. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/methodobject.h +66 -0
  129. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/modsupport.h +26 -0
  130. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/monitoring.h +269 -0
  131. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/object.h +493 -0
  132. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/objimpl.h +104 -0
  133. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/odictobject.h +43 -0
  134. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/picklebufobject.h +31 -0
  135. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pthread_stubs.h +105 -0
  136. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic.h +614 -0
  137. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_gcc.h +615 -0
  138. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_msc.h +1197 -0
  139. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_std.h +1112 -0
  140. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyctype.h +39 -0
  141. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pydebug.h +38 -0
  142. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyerrors.h +132 -0
  143. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyfpe.h +15 -0
  144. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyframe.h +45 -0
  145. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyhash.h +54 -0
  146. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pylifecycle.h +89 -0
  147. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pymem.h +84 -0
  148. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystate.h +275 -0
  149. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystats.h +194 -0
  150. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythonrun.h +96 -0
  151. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythread.h +43 -0
  152. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pytime.h +27 -0
  153. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/setobject.h +71 -0
  154. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/traceback.h +13 -0
  155. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tracemalloc.h +32 -0
  156. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tupleobject.h +40 -0
  157. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/unicodeobject.h +773 -0
  158. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/warnings.h +20 -0
  159. pytron/platforms/android/shell/app/src/main/cpp/include/cpython/weakrefobject.h +66 -0
  160. pytron/platforms/android/shell/app/src/main/cpp/include/critical_section.h +16 -0
  161. pytron/platforms/android/shell/app/src/main/cpp/include/datetime.h +267 -0
  162. pytron/platforms/android/shell/app/src/main/cpp/include/descrobject.h +100 -0
  163. pytron/platforms/android/shell/app/src/main/cpp/include/dictobject.h +108 -0
  164. pytron/platforms/android/shell/app/src/main/cpp/include/dynamic_annotations.h +499 -0
  165. pytron/platforms/android/shell/app/src/main/cpp/include/enumobject.h +17 -0
  166. pytron/platforms/android/shell/app/src/main/cpp/include/errcode.h +45 -0
  167. pytron/platforms/android/shell/app/src/main/cpp/include/exports.h +105 -0
  168. pytron/platforms/android/shell/app/src/main/cpp/include/fileobject.h +41 -0
  169. pytron/platforms/android/shell/app/src/main/cpp/include/fileutils.h +62 -0
  170. pytron/platforms/android/shell/app/src/main/cpp/include/floatobject.h +54 -0
  171. pytron/platforms/android/shell/app/src/main/cpp/include/frameobject.h +20 -0
  172. pytron/platforms/android/shell/app/src/main/cpp/include/genericaliasobject.h +14 -0
  173. pytron/platforms/android/shell/app/src/main/cpp/include/import.h +103 -0
  174. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/atomic.h +392 -0
  175. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/internal.h +969 -0
  176. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/prim.h +329 -0
  177. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/track.h +147 -0
  178. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/types.h +721 -0
  179. pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc.h +565 -0
  180. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_abstract.h +61 -0
  181. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_asdl.h +112 -0
  182. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast.h +945 -0
  183. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast_state.h +271 -0
  184. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_atexit.h +31 -0
  185. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_audit.h +35 -0
  186. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_backoff.h +133 -0
  187. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bitutils.h +186 -0
  188. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_blocks_output_buffer.h +321 -0
  189. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_brc.h +73 -0
  190. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytes_methods.h +82 -0
  191. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytesobject.h +149 -0
  192. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_c_array.h +39 -0
  193. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_call.h +206 -0
  194. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_capsule.h +17 -0
  195. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_cell.h +75 -0
  196. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval.h +390 -0
  197. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval_state.h +48 -0
  198. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_code.h +671 -0
  199. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_codecs.h +76 -0
  200. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_compile.h +230 -0
  201. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_complexobject.h +34 -0
  202. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_condvar.h +93 -0
  203. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_context.h +59 -0
  204. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_critical_section.h +237 -0
  205. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp.h +406 -0
  206. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp_data_registry.h +41 -0
  207. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_debug_offsets.h +379 -0
  208. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_descrobject.h +28 -0
  209. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict.h +410 -0
  210. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict_state.h +28 -0
  211. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dtoa.h +40 -0
  212. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_signal.h +30 -0
  213. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_trampoline.h +70 -0
  214. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_exceptions.h +40 -0
  215. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_faulthandler.h +100 -0
  216. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils.h +320 -0
  217. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils_windows.h +98 -0
  218. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_floatobject.h +49 -0
  219. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_flowgraph.h +47 -0
  220. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_format.h +27 -0
  221. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_frame.h +61 -0
  222. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist.h +111 -0
  223. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist_state.h +70 -0
  224. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_function.h +53 -0
  225. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gc.h +378 -0
  226. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_genobject.h +43 -0
  227. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_getopt.h +22 -0
  228. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gil.h +66 -0
  229. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects.h +34 -0
  230. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects_fini_generated.h +1592 -0
  231. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_strings.h +854 -0
  232. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hamt.h +113 -0
  233. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hashtable.h +150 -0
  234. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_import.h +141 -0
  235. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_importdl.h +139 -0
  236. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_index_pool.h +36 -0
  237. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_initconfig.h +197 -0
  238. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruction_sequence.h +83 -0
  239. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruments.h +127 -0
  240. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp.h +109 -0
  241. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp_structs.h +977 -0
  242. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe.h +401 -0
  243. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe_structs.h +95 -0
  244. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpolation.h +26 -0
  245. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_intrinsics.h +51 -0
  246. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_jit.h +29 -0
  247. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_list.h +81 -0
  248. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_llist.h +106 -0
  249. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_lock.h +236 -0
  250. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_long.h +319 -0
  251. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_magic_number.h +305 -0
  252. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_memoryobject.h +20 -0
  253. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_mimalloc.h +69 -0
  254. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_modsupport.h +99 -0
  255. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_moduleobject.h +62 -0
  256. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_namespace.h +21 -0
  257. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object.h +1029 -0
  258. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_alloc.h +71 -0
  259. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_deferred.h +32 -0
  260. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_stack.h +95 -0
  261. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_state.h +49 -0
  262. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc.h +702 -0
  263. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc_init.h +66 -0
  264. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_metadata.h +2117 -0
  265. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_utils.h +90 -0
  266. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_optimizer.h +318 -0
  267. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parking_lot.h +97 -0
  268. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parser.h +78 -0
  269. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pathconfig.h +26 -0
  270. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyarena.h +68 -0
  271. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyatomic_ft_wrappers.h +174 -0
  272. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pybuffer.h +21 -0
  273. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyerrors.h +213 -0
  274. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyhash.h +91 -0
  275. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pylifecycle.h +136 -0
  276. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymath.h +205 -0
  277. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem.h +145 -0
  278. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem_init.h +103 -0
  279. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystate.h +339 -0
  280. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystats.h +21 -0
  281. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythonrun.h +68 -0
  282. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythread.h +172 -0
  283. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_qsbr.h +172 -0
  284. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_range.h +21 -0
  285. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime.h +63 -0
  286. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init.h +239 -0
  287. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init_generated.h +1589 -0
  288. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_structs.h +310 -0
  289. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_semaphore.h +67 -0
  290. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_setobject.h +41 -0
  291. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_signal.h +108 -0
  292. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sliceobject.h +20 -0
  293. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stackref.h +791 -0
  294. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stats.h +97 -0
  295. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_strhex.h +39 -0
  296. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structs.h +88 -0
  297. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structseq.h +40 -0
  298. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_symtable.h +201 -0
  299. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sysmodule.h +32 -0
  300. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_template.h +26 -0
  301. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_time.h +334 -0
  302. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_token.h +110 -0
  303. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_traceback.h +111 -0
  304. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tracemalloc.h +164 -0
  305. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tstate.h +88 -0
  306. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tuple.h +75 -0
  307. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typedefs.h +18 -0
  308. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typeobject.h +155 -0
  309. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typevarobject.h +28 -0
  310. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ucnhash.h +36 -0
  311. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject.h +308 -0
  312. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject_generated.h +3132 -0
  313. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unionobject.h +26 -0
  314. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uniqueid.h +57 -0
  315. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_ids.h +335 -0
  316. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_metadata.h +1204 -0
  317. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_warnings.h +21 -0
  318. pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_weakref.h +133 -0
  319. pytron/platforms/android/shell/app/src/main/cpp/include/intrcheck.h +23 -0
  320. pytron/platforms/android/shell/app/src/main/cpp/include/iterobject.h +24 -0
  321. pytron/platforms/android/shell/app/src/main/cpp/include/listobject.h +55 -0
  322. pytron/platforms/android/shell/app/src/main/cpp/include/lock.h +16 -0
  323. pytron/platforms/android/shell/app/src/main/cpp/include/longobject.h +178 -0
  324. pytron/platforms/android/shell/app/src/main/cpp/include/marshal.h +31 -0
  325. pytron/platforms/android/shell/app/src/main/cpp/include/memoryobject.h +34 -0
  326. pytron/platforms/android/shell/app/src/main/cpp/include/methodobject.h +146 -0
  327. pytron/platforms/android/shell/app/src/main/cpp/include/modsupport.h +146 -0
  328. pytron/platforms/android/shell/app/src/main/cpp/include/moduleobject.h +122 -0
  329. pytron/platforms/android/shell/app/src/main/cpp/include/monitoring.h +18 -0
  330. pytron/platforms/android/shell/app/src/main/cpp/include/object.h +828 -0
  331. pytron/platforms/android/shell/app/src/main/cpp/include/objimpl.h +211 -0
  332. pytron/platforms/android/shell/app/src/main/cpp/include/opcode.h +43 -0
  333. pytron/platforms/android/shell/app/src/main/cpp/include/opcode_ids.h +259 -0
  334. pytron/platforms/android/shell/app/src/main/cpp/include/osdefs.h +57 -0
  335. pytron/platforms/android/shell/app/src/main/cpp/include/osmodule.h +17 -0
  336. pytron/platforms/android/shell/app/src/main/cpp/include/patchlevel.h +49 -0
  337. pytron/platforms/android/shell/app/src/main/cpp/include/py_curses.h +117 -0
  338. pytron/platforms/android/shell/app/src/main/cpp/include/pyatomic.h +16 -0
  339. pytron/platforms/android/shell/app/src/main/cpp/include/pybuffer.h +145 -0
  340. pytron/platforms/android/shell/app/src/main/cpp/include/pycapsule.h +58 -0
  341. pytron/platforms/android/shell/app/src/main/cpp/include/pyconfig.h +2088 -0
  342. pytron/platforms/android/shell/app/src/main/cpp/include/pydtrace.h +59 -0
  343. pytron/platforms/android/shell/app/src/main/cpp/include/pyerrors.h +335 -0
  344. pytron/platforms/android/shell/app/src/main/cpp/include/pyexpat.h +62 -0
  345. pytron/platforms/android/shell/app/src/main/cpp/include/pyframe.h +26 -0
  346. pytron/platforms/android/shell/app/src/main/cpp/include/pyhash.h +59 -0
  347. pytron/platforms/android/shell/app/src/main/cpp/include/pylifecycle.h +80 -0
  348. pytron/platforms/android/shell/app/src/main/cpp/include/pymacconfig.h +91 -0
  349. pytron/platforms/android/shell/app/src/main/cpp/include/pymacro.h +243 -0
  350. pytron/platforms/android/shell/app/src/main/cpp/include/pymath.h +65 -0
  351. pytron/platforms/android/shell/app/src/main/cpp/include/pymem.h +110 -0
  352. pytron/platforms/android/shell/app/src/main/cpp/include/pyport.h +710 -0
  353. pytron/platforms/android/shell/app/src/main/cpp/include/pystate.h +132 -0
  354. pytron/platforms/android/shell/app/src/main/cpp/include/pystats.h +28 -0
  355. pytron/platforms/android/shell/app/src/main/cpp/include/pystrcmp.h +23 -0
  356. pytron/platforms/android/shell/app/src/main/cpp/include/pystrtod.h +37 -0
  357. pytron/platforms/android/shell/app/src/main/cpp/include/pythonrun.h +42 -0
  358. pytron/platforms/android/shell/app/src/main/cpp/include/pythread.h +131 -0
  359. pytron/platforms/android/shell/app/src/main/cpp/include/pytypedefs.h +30 -0
  360. pytron/platforms/android/shell/app/src/main/cpp/include/rangeobject.h +27 -0
  361. pytron/platforms/android/shell/app/src/main/cpp/include/refcount.h +555 -0
  362. pytron/platforms/android/shell/app/src/main/cpp/include/setobject.h +49 -0
  363. pytron/platforms/android/shell/app/src/main/cpp/include/sliceobject.h +69 -0
  364. pytron/platforms/android/shell/app/src/main/cpp/include/structmember.h +56 -0
  365. pytron/platforms/android/shell/app/src/main/cpp/include/structseq.h +46 -0
  366. pytron/platforms/android/shell/app/src/main/cpp/include/sysmodule.h +27 -0
  367. pytron/platforms/android/shell/app/src/main/cpp/include/traceback.h +26 -0
  368. pytron/platforms/android/shell/app/src/main/cpp/include/tupleobject.h +46 -0
  369. pytron/platforms/android/shell/app/src/main/cpp/include/typeslots.h +96 -0
  370. pytron/platforms/android/shell/app/src/main/cpp/include/unicodeobject.h +1029 -0
  371. pytron/platforms/android/shell/app/src/main/cpp/include/warnings.h +45 -0
  372. pytron/platforms/android/shell/app/src/main/cpp/include/weakrefobject.h +46 -0
  373. pytron/platforms/android/shell/app/src/main/cpp/pytron_bridge.cpp +224 -0
  374. pytron/platforms/android/shell/app/src/main/java/com/pytron/shell/MainActivity.kt +208 -0
  375. pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  376. pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  377. pytron/platforms/android/shell/build.gradle +11 -0
  378. pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.jar +0 -0
  379. pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.properties +5 -0
  380. pytron/platforms/android/shell/gradle.properties +2 -0
  381. pytron/platforms/android/shell/gradlew.bat +85 -0
  382. pytron/platforms/android/shell/settings.gradle +16 -0
  383. pytron/platforms/darwin.py +82 -0
  384. pytron/platforms/darwin_ops/libs.py +31 -0
  385. pytron/platforms/darwin_ops/system.py +182 -0
  386. pytron/platforms/darwin_ops/utils.py +85 -0
  387. pytron/platforms/darwin_ops/webview.py +5 -0
  388. pytron/platforms/darwin_ops/window.py +102 -0
  389. pytron/platforms/interface.py +152 -0
  390. pytron/platforms/linux.py +82 -0
  391. pytron/platforms/linux_ops/libs.py +49 -0
  392. pytron/platforms/linux_ops/system.py +316 -0
  393. pytron/platforms/linux_ops/utils.py +19 -0
  394. pytron/platforms/linux_ops/webview.py +5 -0
  395. pytron/platforms/linux_ops/window.py +115 -0
  396. pytron/platforms/windows.py +136 -0
  397. pytron/platforms/windows_ops/__init__.py +0 -0
  398. pytron/platforms/windows_ops/constants.py +126 -0
  399. pytron/platforms/windows_ops/system.py +518 -0
  400. pytron/platforms/windows_ops/utils.py +3 -0
  401. pytron/platforms/windows_ops/webview.py +5 -0
  402. pytron/platforms/windows_ops/window.py +361 -0
  403. pytron/plugin.py +467 -0
  404. pytron/rcedit-x64.exe +0 -0
  405. pytron/router.py +146 -0
  406. pytron/serializer.py +240 -0
  407. pytron/shortcuts.py +279 -0
  408. pytron/state.py +76 -0
  409. pytron/tray.py +399 -0
  410. pytron/updater.py +181 -0
  411. pytron/utf8_hook.py +112 -0
  412. pytron/utils.py +44 -0
  413. pytron/webview.py +722 -0
  414. pytron_kit-0.3.12.dist-info/METADATA +131 -0
  415. pytron_kit-0.3.12.dist-info/RECORD +419 -0
  416. pytron_kit-0.3.12.dist-info/WHEEL +5 -0
  417. pytron_kit-0.3.12.dist-info/entry_points.txt +2 -0
  418. pytron_kit-0.3.12.dist-info/licenses/LICENSE +201 -0
  419. pytron_kit-0.3.12.dist-info/top_level.txt +1 -0
@@ -0,0 +1,791 @@
1
+ #ifndef Py_INTERNAL_STACKREF_H
2
+ #define Py_INTERNAL_STACKREF_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ #ifndef Py_BUILD_CORE
8
+ # error "this header requires Py_BUILD_CORE define"
9
+ #endif
10
+
11
+ #include "pycore_object.h" // Py_DECREF_MORTAL
12
+ #include "pycore_object_deferred.h" // _PyObject_HasDeferredRefcount()
13
+
14
+ #include <stdbool.h> // bool
15
+
16
+
17
+ /*
18
+ This file introduces a new API for handling references on the stack, called
19
+ _PyStackRef. This API is inspired by HPy.
20
+
21
+ There are 3 main operations, that convert _PyStackRef to PyObject* and
22
+ vice versa:
23
+
24
+ 1. Borrow (discouraged)
25
+ 2. Steal
26
+ 3. New
27
+
28
+ Borrow means that the reference is converted without any change in ownership.
29
+ This is discouraged because it makes verification much harder. It also makes
30
+ unboxed integers harder in the future.
31
+
32
+ Steal means that ownership is transferred to something else. The total
33
+ number of references to the object stays the same. The old reference is no
34
+ longer valid.
35
+
36
+ New creates a new reference from the old reference. The old reference
37
+ is still valid.
38
+
39
+ All _PyStackRef must be operated on by the new reference operations:
40
+
41
+ 1. DUP
42
+ 2. CLOSE
43
+
44
+ DUP is roughly equivalent to Py_NewRef. It creates a new reference from an old
45
+ reference. The old reference remains unchanged.
46
+
47
+ CLOSE is roughly equivalent to Py_DECREF. It destroys a reference.
48
+
49
+ Note that it is unsafe to borrow a _PyStackRef and then do normal
50
+ CPython refcounting operations on it!
51
+ */
52
+
53
+
54
+ #if !defined(Py_GIL_DISABLED) && defined(Py_STACKREF_DEBUG)
55
+
56
+ #define Py_TAG_BITS 0
57
+
58
+ PyAPI_FUNC(PyObject *) _Py_stackref_get_object(_PyStackRef ref);
59
+ PyAPI_FUNC(PyObject *) _Py_stackref_close(_PyStackRef ref, const char *filename, int linenumber);
60
+ PyAPI_FUNC(_PyStackRef) _Py_stackref_create(PyObject *obj, const char *filename, int linenumber);
61
+ PyAPI_FUNC(void) _Py_stackref_record_borrow(_PyStackRef ref, const char *filename, int linenumber);
62
+ extern void _Py_stackref_associate(PyInterpreterState *interp, PyObject *obj, _PyStackRef ref);
63
+
64
+ static const _PyStackRef PyStackRef_NULL = { .index = 0 };
65
+
66
+ // Use the first 3 even numbers for None, True and False.
67
+ // Odd numbers are reserved for (tagged) integers
68
+ #define PyStackRef_None ((_PyStackRef){ .index = 2 } )
69
+ #define PyStackRef_False ((_PyStackRef){ .index = 4 })
70
+ #define PyStackRef_True ((_PyStackRef){ .index = 6 })
71
+
72
+ #define INITIAL_STACKREF_INDEX 8
73
+
74
+ static inline int
75
+ PyStackRef_IsNull(_PyStackRef ref)
76
+ {
77
+ return ref.index == 0;
78
+ }
79
+
80
+ static inline int
81
+ PyStackRef_IsTrue(_PyStackRef ref)
82
+ {
83
+ return _Py_stackref_get_object(ref) == Py_True;
84
+ }
85
+
86
+ static inline int
87
+ PyStackRef_IsFalse(_PyStackRef ref)
88
+ {
89
+ return _Py_stackref_get_object(ref) == Py_False;
90
+ }
91
+
92
+ static inline int
93
+ PyStackRef_IsNone(_PyStackRef ref)
94
+ {
95
+ return _Py_stackref_get_object(ref) == Py_None;
96
+ }
97
+
98
+ static inline PyObject *
99
+ _PyStackRef_AsPyObjectBorrow(_PyStackRef ref, const char *filename, int linenumber)
100
+ {
101
+ assert((ref.index & 1) == 0);
102
+ _Py_stackref_record_borrow(ref, filename, linenumber);
103
+ return _Py_stackref_get_object(ref);
104
+ }
105
+
106
+ #define PyStackRef_AsPyObjectBorrow(REF) _PyStackRef_AsPyObjectBorrow((REF), __FILE__, __LINE__)
107
+
108
+ static inline PyObject *
109
+ _PyStackRef_AsPyObjectSteal(_PyStackRef ref, const char *filename, int linenumber)
110
+ {
111
+ return _Py_stackref_close(ref, filename, linenumber);
112
+ }
113
+ #define PyStackRef_AsPyObjectSteal(REF) _PyStackRef_AsPyObjectSteal((REF), __FILE__, __LINE__)
114
+
115
+ static inline _PyStackRef
116
+ _PyStackRef_FromPyObjectNew(PyObject *obj, const char *filename, int linenumber)
117
+ {
118
+ Py_INCREF(obj);
119
+ return _Py_stackref_create(obj, filename, linenumber);
120
+ }
121
+ #define PyStackRef_FromPyObjectNew(obj) _PyStackRef_FromPyObjectNew(_PyObject_CAST(obj), __FILE__, __LINE__)
122
+
123
+ static inline _PyStackRef
124
+ _PyStackRef_FromPyObjectSteal(PyObject *obj, const char *filename, int linenumber)
125
+ {
126
+ return _Py_stackref_create(obj, filename, linenumber);
127
+ }
128
+ #define PyStackRef_FromPyObjectSteal(obj) _PyStackRef_FromPyObjectSteal(_PyObject_CAST(obj), __FILE__, __LINE__)
129
+
130
+ static inline _PyStackRef
131
+ _PyStackRef_FromPyObjectImmortal(PyObject *obj, const char *filename, int linenumber)
132
+ {
133
+ assert(_Py_IsImmortal(obj));
134
+ return _Py_stackref_create(obj, filename, linenumber);
135
+ }
136
+ #define PyStackRef_FromPyObjectImmortal(obj) _PyStackRef_FromPyObjectImmortal(_PyObject_CAST(obj), __FILE__, __LINE__)
137
+
138
+ static inline bool
139
+ PyStackRef_IsTaggedInt(_PyStackRef ref)
140
+ {
141
+ return (ref.index & 1) == 1;
142
+ }
143
+
144
+ static inline void
145
+ _PyStackRef_CLOSE(_PyStackRef ref, const char *filename, int linenumber)
146
+ {
147
+ if (PyStackRef_IsTaggedInt(ref)) {
148
+ return;
149
+ }
150
+ PyObject *obj = _Py_stackref_close(ref, filename, linenumber);
151
+ Py_DECREF(obj);
152
+ }
153
+ #define PyStackRef_CLOSE(REF) _PyStackRef_CLOSE((REF), __FILE__, __LINE__)
154
+
155
+
156
+ static inline void
157
+ _PyStackRef_XCLOSE(_PyStackRef ref, const char *filename, int linenumber)
158
+ {
159
+ if (PyStackRef_IsNull(ref)) {
160
+ return;
161
+ }
162
+ _PyStackRef_CLOSE(ref, filename, linenumber);
163
+ }
164
+ #define PyStackRef_XCLOSE(REF) _PyStackRef_XCLOSE((REF), __FILE__, __LINE__)
165
+
166
+ static inline _PyStackRef
167
+ _PyStackRef_DUP(_PyStackRef ref, const char *filename, int linenumber)
168
+ {
169
+ if (PyStackRef_IsTaggedInt(ref)) {
170
+ return ref;
171
+ }
172
+ else {
173
+ PyObject *obj = _Py_stackref_get_object(ref);
174
+ Py_INCREF(obj);
175
+ return _Py_stackref_create(obj, filename, linenumber);
176
+ }
177
+ }
178
+ #define PyStackRef_DUP(REF) _PyStackRef_DUP(REF, __FILE__, __LINE__)
179
+
180
+ extern void _PyStackRef_CLOSE_SPECIALIZED(_PyStackRef ref, destructor destruct, const char *filename, int linenumber);
181
+ #define PyStackRef_CLOSE_SPECIALIZED(REF, DESTRUCT) _PyStackRef_CLOSE_SPECIALIZED(REF, DESTRUCT, __FILE__, __LINE__)
182
+
183
+ static inline _PyStackRef
184
+ PyStackRef_MakeHeapSafe(_PyStackRef ref)
185
+ {
186
+ return ref;
187
+ }
188
+
189
+ static inline _PyStackRef
190
+ PyStackRef_Borrow(_PyStackRef ref)
191
+ {
192
+ return PyStackRef_DUP(ref);
193
+ }
194
+
195
+ #define PyStackRef_CLEAR(REF) \
196
+ do { \
197
+ _PyStackRef *_tmp_op_ptr = &(REF); \
198
+ _PyStackRef _tmp_old_op = (*_tmp_op_ptr); \
199
+ *_tmp_op_ptr = PyStackRef_NULL; \
200
+ PyStackRef_XCLOSE(_tmp_old_op); \
201
+ } while (0)
202
+
203
+ static inline _PyStackRef
204
+ _PyStackRef_FromPyObjectStealMortal(PyObject *obj, const char *filename, int linenumber)
205
+ {
206
+ assert(!_Py_IsImmortal(obj));
207
+ return _Py_stackref_create(obj, filename, linenumber);
208
+ }
209
+ #define PyStackRef_FromPyObjectStealMortal(obj) _PyStackRef_FromPyObjectStealMortal(_PyObject_CAST(obj), __FILE__, __LINE__)
210
+
211
+ static inline bool
212
+ PyStackRef_IsHeapSafe(_PyStackRef ref)
213
+ {
214
+ return true;
215
+ }
216
+
217
+ static inline _PyStackRef
218
+ _PyStackRef_FromPyObjectNewMortal(PyObject *obj, const char *filename, int linenumber)
219
+ {
220
+ assert(!_Py_IsStaticImmortal(obj));
221
+ Py_INCREF(obj);
222
+ return _Py_stackref_create(obj, filename, linenumber);
223
+ }
224
+ #define PyStackRef_FromPyObjectNewMortal(obj) _PyStackRef_FromPyObjectNewMortal(_PyObject_CAST(obj), __FILE__, __LINE__)
225
+
226
+ #define PyStackRef_RefcountOnObject(REF) 1
227
+
228
+ extern int PyStackRef_Is(_PyStackRef a, _PyStackRef b);
229
+
230
+ extern bool PyStackRef_IsTaggedInt(_PyStackRef ref);
231
+
232
+ extern intptr_t PyStackRef_UntagInt(_PyStackRef ref);
233
+
234
+ extern _PyStackRef PyStackRef_TagInt(intptr_t i);
235
+
236
+ extern bool
237
+ PyStackRef_IsNullOrInt(_PyStackRef ref);
238
+
239
+ #else
240
+
241
+ #define Py_INT_TAG 3
242
+ #define Py_TAG_REFCNT 1
243
+
244
+ static inline bool
245
+ PyStackRef_IsTaggedInt(_PyStackRef i)
246
+ {
247
+ return (i.bits & Py_INT_TAG) == Py_INT_TAG;
248
+ }
249
+
250
+ static inline _PyStackRef
251
+ PyStackRef_TagInt(intptr_t i)
252
+ {
253
+ assert(Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, (i << 2), 2) == i);
254
+ return (_PyStackRef){ .bits = ((((uintptr_t)i) << 2) | Py_INT_TAG) };
255
+ }
256
+
257
+ static inline intptr_t
258
+ PyStackRef_UntagInt(_PyStackRef i)
259
+ {
260
+ assert((i.bits & Py_INT_TAG) == Py_INT_TAG);
261
+ intptr_t val = (intptr_t)i.bits;
262
+ return Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, val, 2);
263
+ }
264
+
265
+
266
+ #ifdef Py_GIL_DISABLED
267
+
268
+ #define Py_TAG_DEFERRED Py_TAG_REFCNT
269
+
270
+ #define Py_TAG_PTR ((uintptr_t)0)
271
+ #define Py_TAG_BITS ((uintptr_t)1)
272
+
273
+
274
+ static const _PyStackRef PyStackRef_NULL = { .bits = Py_TAG_DEFERRED};
275
+ #define PyStackRef_IsNull(stackref) ((stackref).bits == PyStackRef_NULL.bits)
276
+ #define PyStackRef_True ((_PyStackRef){.bits = ((uintptr_t)&_Py_TrueStruct) | Py_TAG_DEFERRED })
277
+ #define PyStackRef_False ((_PyStackRef){.bits = ((uintptr_t)&_Py_FalseStruct) | Py_TAG_DEFERRED })
278
+ #define PyStackRef_None ((_PyStackRef){.bits = ((uintptr_t)&_Py_NoneStruct) | Py_TAG_DEFERRED })
279
+
280
+ // Checks that mask out the deferred bit in the free threading build.
281
+ #define PyStackRef_IsNone(ref) (PyStackRef_AsPyObjectBorrow(ref) == Py_None)
282
+ #define PyStackRef_IsTrue(ref) (PyStackRef_AsPyObjectBorrow(ref) == Py_True)
283
+ #define PyStackRef_IsFalse(ref) (PyStackRef_AsPyObjectBorrow(ref) == Py_False)
284
+
285
+ #define PyStackRef_IsNullOrInt(stackref) (PyStackRef_IsNull(stackref) || PyStackRef_IsTaggedInt(stackref))
286
+
287
+ static inline PyObject *
288
+ PyStackRef_AsPyObjectBorrow(_PyStackRef stackref)
289
+ {
290
+ PyObject *cleared = ((PyObject *)((stackref).bits & (~Py_TAG_BITS)));
291
+ return cleared;
292
+ }
293
+
294
+ #define PyStackRef_IsDeferred(ref) (((ref).bits & Py_TAG_BITS) == Py_TAG_DEFERRED)
295
+
296
+ static inline PyObject *
297
+ PyStackRef_NotDeferred_AsPyObject(_PyStackRef stackref)
298
+ {
299
+ assert(!PyStackRef_IsDeferred(stackref));
300
+ return (PyObject *)stackref.bits;
301
+ }
302
+
303
+ static inline PyObject *
304
+ PyStackRef_AsPyObjectSteal(_PyStackRef stackref)
305
+ {
306
+ assert(!PyStackRef_IsNull(stackref));
307
+ if (PyStackRef_IsDeferred(stackref)) {
308
+ return Py_NewRef(PyStackRef_AsPyObjectBorrow(stackref));
309
+ }
310
+ return PyStackRef_AsPyObjectBorrow(stackref);
311
+ }
312
+
313
+ static inline _PyStackRef
314
+ _PyStackRef_FromPyObjectSteal(PyObject *obj)
315
+ {
316
+ assert(obj != NULL);
317
+ // Make sure we don't take an already tagged value.
318
+ assert(((uintptr_t)obj & Py_TAG_BITS) == 0);
319
+ return (_PyStackRef){ .bits = (uintptr_t)obj };
320
+ }
321
+ # define PyStackRef_FromPyObjectSteal(obj) _PyStackRef_FromPyObjectSteal(_PyObject_CAST(obj))
322
+
323
+ static inline bool
324
+ PyStackRef_IsHeapSafe(_PyStackRef stackref)
325
+ {
326
+ if (PyStackRef_IsDeferred(stackref)) {
327
+ PyObject *obj = PyStackRef_AsPyObjectBorrow(stackref);
328
+ return obj == NULL || _Py_IsImmortal(obj) || _PyObject_HasDeferredRefcount(obj);
329
+ }
330
+ return true;
331
+ }
332
+
333
+ static inline _PyStackRef
334
+ PyStackRef_MakeHeapSafe(_PyStackRef stackref)
335
+ {
336
+ if (PyStackRef_IsHeapSafe(stackref)) {
337
+ return stackref;
338
+ }
339
+ PyObject *obj = PyStackRef_AsPyObjectBorrow(stackref);
340
+ return (_PyStackRef){ .bits = (uintptr_t)(Py_NewRef(obj)) | Py_TAG_PTR };
341
+ }
342
+
343
+ static inline _PyStackRef
344
+ PyStackRef_FromPyObjectStealMortal(PyObject *obj)
345
+ {
346
+ assert(obj != NULL);
347
+ assert(!_Py_IsImmortal(obj));
348
+ // Make sure we don't take an already tagged value.
349
+ assert(((uintptr_t)obj & Py_TAG_BITS) == 0);
350
+ return (_PyStackRef){ .bits = (uintptr_t)obj };
351
+ }
352
+
353
+ static inline _PyStackRef
354
+ PyStackRef_FromPyObjectNew(PyObject *obj)
355
+ {
356
+ // Make sure we don't take an already tagged value.
357
+ assert(((uintptr_t)obj & Py_TAG_BITS) == 0);
358
+ assert(obj != NULL);
359
+ if (_PyObject_HasDeferredRefcount(obj)) {
360
+ return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_DEFERRED };
361
+ }
362
+ else {
363
+ return (_PyStackRef){ .bits = (uintptr_t)(Py_NewRef(obj)) | Py_TAG_PTR };
364
+ }
365
+ }
366
+ #define PyStackRef_FromPyObjectNew(obj) PyStackRef_FromPyObjectNew(_PyObject_CAST(obj))
367
+
368
+ static inline _PyStackRef
369
+ PyStackRef_FromPyObjectImmortal(PyObject *obj)
370
+ {
371
+ // Make sure we don't take an already tagged value.
372
+ assert(((uintptr_t)obj & Py_TAG_BITS) == 0);
373
+ assert(obj != NULL);
374
+ assert(_Py_IsImmortal(obj));
375
+ return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_DEFERRED };
376
+ }
377
+ #define PyStackRef_FromPyObjectImmortal(obj) PyStackRef_FromPyObjectImmortal(_PyObject_CAST(obj))
378
+
379
+ #define PyStackRef_CLOSE(REF) \
380
+ do { \
381
+ _PyStackRef _close_tmp = (REF); \
382
+ assert(!PyStackRef_IsNull(_close_tmp)); \
383
+ if (!PyStackRef_IsDeferred(_close_tmp)) { \
384
+ Py_DECREF(PyStackRef_AsPyObjectBorrow(_close_tmp)); \
385
+ } \
386
+ } while (0)
387
+
388
+ static inline void
389
+ PyStackRef_CLOSE_SPECIALIZED(_PyStackRef ref, destructor destruct)
390
+ {
391
+ (void)destruct;
392
+ PyStackRef_CLOSE(ref);
393
+ }
394
+
395
+ static inline _PyStackRef
396
+ PyStackRef_DUP(_PyStackRef stackref)
397
+ {
398
+ assert(!PyStackRef_IsNull(stackref));
399
+ if (PyStackRef_IsDeferred(stackref)) {
400
+ return stackref;
401
+ }
402
+ Py_INCREF(PyStackRef_AsPyObjectBorrow(stackref));
403
+ return stackref;
404
+ }
405
+
406
+ static inline _PyStackRef
407
+ PyStackRef_Borrow(_PyStackRef stackref)
408
+ {
409
+ return (_PyStackRef){ .bits = stackref.bits | Py_TAG_DEFERRED };
410
+ }
411
+
412
+ // Convert a possibly deferred reference to a strong reference.
413
+ static inline _PyStackRef
414
+ PyStackRef_AsStrongReference(_PyStackRef stackref)
415
+ {
416
+ return PyStackRef_FromPyObjectSteal(PyStackRef_AsPyObjectSteal(stackref));
417
+ }
418
+
419
+ #define PyStackRef_XCLOSE(stackref) \
420
+ do { \
421
+ _PyStackRef _tmp = (stackref); \
422
+ if (!PyStackRef_IsNull(_tmp)) { \
423
+ PyStackRef_CLOSE(_tmp); \
424
+ } \
425
+ } while (0);
426
+
427
+ #define PyStackRef_CLEAR(op) \
428
+ do { \
429
+ _PyStackRef *_tmp_op_ptr = &(op); \
430
+ _PyStackRef _tmp_old_op = (*_tmp_op_ptr); \
431
+ if (!PyStackRef_IsNull(_tmp_old_op)) { \
432
+ *_tmp_op_ptr = PyStackRef_NULL; \
433
+ PyStackRef_CLOSE(_tmp_old_op); \
434
+ } \
435
+ } while (0)
436
+
437
+ #define PyStackRef_FromPyObjectNewMortal PyStackRef_FromPyObjectNew
438
+
439
+ #else // Py_GIL_DISABLED
440
+
441
+ // With GIL
442
+
443
+ /* References to immortal objects always have their tag bit set to Py_TAG_REFCNT
444
+ * as they can (must) have their reclamation deferred */
445
+
446
+ #define Py_TAG_BITS 3
447
+ #if _Py_IMMORTAL_FLAGS != Py_TAG_REFCNT
448
+ # error "_Py_IMMORTAL_FLAGS != Py_TAG_REFCNT"
449
+ #endif
450
+
451
+ #define BITS_TO_PTR(REF) ((PyObject *)((REF).bits))
452
+ #define BITS_TO_PTR_MASKED(REF) ((PyObject *)(((REF).bits) & (~Py_TAG_REFCNT)))
453
+
454
+ #define PyStackRef_NULL_BITS Py_TAG_REFCNT
455
+ static const _PyStackRef PyStackRef_NULL = { .bits = PyStackRef_NULL_BITS };
456
+
457
+ #define PyStackRef_IsNull(ref) ((ref).bits == PyStackRef_NULL_BITS)
458
+ #define PyStackRef_True ((_PyStackRef){.bits = ((uintptr_t)&_Py_TrueStruct) | Py_TAG_REFCNT })
459
+ #define PyStackRef_False ((_PyStackRef){.bits = ((uintptr_t)&_Py_FalseStruct) | Py_TAG_REFCNT })
460
+ #define PyStackRef_None ((_PyStackRef){.bits = ((uintptr_t)&_Py_NoneStruct) | Py_TAG_REFCNT })
461
+
462
+ #define PyStackRef_IsTrue(REF) ((REF).bits == (((uintptr_t)&_Py_TrueStruct) | Py_TAG_REFCNT))
463
+ #define PyStackRef_IsFalse(REF) ((REF).bits == (((uintptr_t)&_Py_FalseStruct) | Py_TAG_REFCNT))
464
+ #define PyStackRef_IsNone(REF) ((REF).bits == (((uintptr_t)&_Py_NoneStruct) | Py_TAG_REFCNT))
465
+
466
+ #ifdef Py_DEBUG
467
+
468
+ static inline void PyStackRef_CheckValid(_PyStackRef ref) {
469
+ assert(ref.bits != 0);
470
+ int tag = ref.bits & Py_TAG_BITS;
471
+ PyObject *obj = BITS_TO_PTR_MASKED(ref);
472
+ switch (tag) {
473
+ case 0:
474
+ /* Can be immortal if object was made immortal after reference came into existence */
475
+ assert(!_Py_IsStaticImmortal(obj));
476
+ break;
477
+ case Py_TAG_REFCNT:
478
+ break;
479
+ default:
480
+ assert(0);
481
+ }
482
+ }
483
+
484
+ #else
485
+
486
+ #define PyStackRef_CheckValid(REF) ((void)0)
487
+
488
+ #endif
489
+
490
+ #ifdef _WIN32
491
+ #define PyStackRef_RefcountOnObject(REF) (((REF).bits & Py_TAG_REFCNT) == 0)
492
+ #define PyStackRef_AsPyObjectBorrow BITS_TO_PTR_MASKED
493
+ #define PyStackRef_Borrow(REF) (_PyStackRef){ .bits = ((REF).bits) | Py_TAG_REFCNT};
494
+ #else
495
+ /* Does this ref not have an embedded refcount and thus not refer to a declared immmortal object? */
496
+ static inline int
497
+ PyStackRef_RefcountOnObject(_PyStackRef ref)
498
+ {
499
+ return (ref.bits & Py_TAG_REFCNT) == 0;
500
+ }
501
+
502
+ static inline PyObject *
503
+ PyStackRef_AsPyObjectBorrow(_PyStackRef ref)
504
+ {
505
+ assert(!PyStackRef_IsTaggedInt(ref));
506
+ return BITS_TO_PTR_MASKED(ref);
507
+ }
508
+
509
+ static inline _PyStackRef
510
+ PyStackRef_Borrow(_PyStackRef ref)
511
+ {
512
+ return (_PyStackRef){ .bits = ref.bits | Py_TAG_REFCNT };
513
+ }
514
+ #endif
515
+
516
+ static inline PyObject *
517
+ PyStackRef_AsPyObjectSteal(_PyStackRef ref)
518
+ {
519
+ if (PyStackRef_RefcountOnObject(ref)) {
520
+ return BITS_TO_PTR(ref);
521
+ }
522
+ else {
523
+ return Py_NewRef(BITS_TO_PTR_MASKED(ref));
524
+ }
525
+ }
526
+
527
+ static inline _PyStackRef
528
+ PyStackRef_FromPyObjectSteal(PyObject *obj)
529
+ {
530
+ assert(obj != NULL);
531
+ #if SIZEOF_VOID_P > 4
532
+ unsigned int tag = obj->ob_flags & Py_TAG_REFCNT;
533
+ #else
534
+ unsigned int tag = _Py_IsImmortal(obj) ? Py_TAG_REFCNT : 0;
535
+ #endif
536
+ _PyStackRef ref = ((_PyStackRef){.bits = ((uintptr_t)(obj)) | tag});
537
+ PyStackRef_CheckValid(ref);
538
+ return ref;
539
+ }
540
+
541
+ static inline _PyStackRef
542
+ PyStackRef_FromPyObjectStealMortal(PyObject *obj)
543
+ {
544
+ assert(obj != NULL);
545
+ assert(!_Py_IsImmortal(obj));
546
+ _PyStackRef ref = ((_PyStackRef){.bits = ((uintptr_t)(obj)) });
547
+ PyStackRef_CheckValid(ref);
548
+ return ref;
549
+ }
550
+
551
+ static inline _PyStackRef
552
+ _PyStackRef_FromPyObjectNew(PyObject *obj)
553
+ {
554
+ assert(obj != NULL);
555
+ if (_Py_IsImmortal(obj)) {
556
+ return (_PyStackRef){ .bits = ((uintptr_t)obj) | Py_TAG_REFCNT};
557
+ }
558
+ _Py_INCREF_MORTAL(obj);
559
+ _PyStackRef ref = (_PyStackRef){ .bits = (uintptr_t)obj };
560
+ PyStackRef_CheckValid(ref);
561
+ return ref;
562
+ }
563
+ #define PyStackRef_FromPyObjectNew(obj) _PyStackRef_FromPyObjectNew(_PyObject_CAST(obj))
564
+
565
+ static inline _PyStackRef
566
+ _PyStackRef_FromPyObjectNewMortal(PyObject *obj)
567
+ {
568
+ assert(obj != NULL);
569
+ _Py_INCREF_MORTAL(obj);
570
+ _PyStackRef ref = (_PyStackRef){ .bits = (uintptr_t)obj };
571
+ PyStackRef_CheckValid(ref);
572
+ return ref;
573
+ }
574
+ #define PyStackRef_FromPyObjectNewMortal(obj) _PyStackRef_FromPyObjectNewMortal(_PyObject_CAST(obj))
575
+
576
+ /* Create a new reference from an object with an embedded reference count */
577
+ static inline _PyStackRef
578
+ PyStackRef_FromPyObjectImmortal(PyObject *obj)
579
+ {
580
+ assert(_Py_IsImmortal(obj));
581
+ return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_REFCNT};
582
+ }
583
+
584
+ /* WARNING: This macro evaluates its argument more than once */
585
+ #ifdef _WIN32
586
+ #define PyStackRef_DUP(REF) \
587
+ (PyStackRef_RefcountOnObject(REF) ? (_Py_INCREF_MORTAL(BITS_TO_PTR(REF)), (REF)) : (REF))
588
+ #else
589
+ static inline _PyStackRef
590
+ PyStackRef_DUP(_PyStackRef ref)
591
+ {
592
+ assert(!PyStackRef_IsNull(ref));
593
+ if (PyStackRef_RefcountOnObject(ref)) {
594
+ _Py_INCREF_MORTAL(BITS_TO_PTR(ref));
595
+ }
596
+ return ref;
597
+ }
598
+ #endif
599
+
600
+ static inline bool
601
+ PyStackRef_IsHeapSafe(_PyStackRef ref)
602
+ {
603
+ return (ref.bits & Py_TAG_BITS) != Py_TAG_REFCNT || ref.bits == PyStackRef_NULL_BITS || _Py_IsImmortal(BITS_TO_PTR_MASKED(ref));
604
+ }
605
+
606
+ static inline _PyStackRef
607
+ PyStackRef_MakeHeapSafe(_PyStackRef ref)
608
+ {
609
+ if (PyStackRef_IsHeapSafe(ref)) {
610
+ return ref;
611
+ }
612
+ PyObject *obj = BITS_TO_PTR_MASKED(ref);
613
+ Py_INCREF(obj);
614
+ ref.bits = (uintptr_t)obj;
615
+ PyStackRef_CheckValid(ref);
616
+ return ref;
617
+ }
618
+
619
+ #ifdef _WIN32
620
+ #define PyStackRef_CLOSE(REF) \
621
+ do { \
622
+ _PyStackRef _temp = (REF); \
623
+ if (PyStackRef_RefcountOnObject(_temp)) Py_DECREF_MORTAL(BITS_TO_PTR(_temp)); \
624
+ } while (0)
625
+ #else
626
+ static inline void
627
+ PyStackRef_CLOSE(_PyStackRef ref)
628
+ {
629
+ assert(!PyStackRef_IsNull(ref));
630
+ if (PyStackRef_RefcountOnObject(ref)) {
631
+ Py_DECREF_MORTAL(BITS_TO_PTR(ref));
632
+ }
633
+ }
634
+ #endif
635
+
636
+ static inline bool
637
+ PyStackRef_IsNullOrInt(_PyStackRef ref)
638
+ {
639
+ return PyStackRef_IsNull(ref) || PyStackRef_IsTaggedInt(ref);
640
+ }
641
+
642
+ static inline void
643
+ PyStackRef_CLOSE_SPECIALIZED(_PyStackRef ref, destructor destruct)
644
+ {
645
+ assert(!PyStackRef_IsNull(ref));
646
+ if (PyStackRef_RefcountOnObject(ref)) {
647
+ Py_DECREF_MORTAL_SPECIALIZED(BITS_TO_PTR(ref), destruct);
648
+ }
649
+ }
650
+
651
+ #ifdef _WIN32
652
+ #define PyStackRef_XCLOSE PyStackRef_CLOSE
653
+ #else
654
+ static inline void
655
+ PyStackRef_XCLOSE(_PyStackRef ref)
656
+ {
657
+ assert(ref.bits != 0);
658
+ if (PyStackRef_RefcountOnObject(ref)) {
659
+ assert(!PyStackRef_IsNull(ref));
660
+ Py_DECREF_MORTAL(BITS_TO_PTR(ref));
661
+ }
662
+ }
663
+ #endif
664
+
665
+ #define PyStackRef_CLEAR(REF) \
666
+ do { \
667
+ _PyStackRef *_tmp_op_ptr = &(REF); \
668
+ _PyStackRef _tmp_old_op = (*_tmp_op_ptr); \
669
+ *_tmp_op_ptr = PyStackRef_NULL; \
670
+ PyStackRef_XCLOSE(_tmp_old_op); \
671
+ } while (0)
672
+
673
+
674
+ #endif // Py_GIL_DISABLED
675
+
676
+ // Note: this is a macro because MSVC (Windows) has trouble inlining it.
677
+
678
+ #define PyStackRef_Is(a, b) (((a).bits & (~Py_TAG_REFCNT)) == ((b).bits & (~Py_TAG_REFCNT)))
679
+
680
+
681
+ #endif // !defined(Py_GIL_DISABLED) && defined(Py_STACKREF_DEBUG)
682
+
683
+ #define PyStackRef_TYPE(stackref) Py_TYPE(PyStackRef_AsPyObjectBorrow(stackref))
684
+
685
+ // Converts a PyStackRef back to a PyObject *, converting the
686
+ // stackref to a new reference.
687
+ #define PyStackRef_AsPyObjectNew(stackref) Py_NewRef(PyStackRef_AsPyObjectBorrow(stackref))
688
+
689
+ // StackRef type checks
690
+
691
+ static inline bool
692
+ PyStackRef_GenCheck(_PyStackRef stackref)
693
+ {
694
+ return PyGen_Check(PyStackRef_AsPyObjectBorrow(stackref));
695
+ }
696
+
697
+ static inline bool
698
+ PyStackRef_BoolCheck(_PyStackRef stackref)
699
+ {
700
+ return PyBool_Check(PyStackRef_AsPyObjectBorrow(stackref));
701
+ }
702
+
703
+ static inline bool
704
+ PyStackRef_LongCheck(_PyStackRef stackref)
705
+ {
706
+ return PyLong_Check(PyStackRef_AsPyObjectBorrow(stackref));
707
+ }
708
+
709
+ static inline bool
710
+ PyStackRef_ExceptionInstanceCheck(_PyStackRef stackref)
711
+ {
712
+ return PyExceptionInstance_Check(PyStackRef_AsPyObjectBorrow(stackref));
713
+ }
714
+
715
+ static inline bool
716
+ PyStackRef_CodeCheck(_PyStackRef stackref)
717
+ {
718
+ return PyCode_Check(PyStackRef_AsPyObjectBorrow(stackref));
719
+ }
720
+
721
+ static inline bool
722
+ PyStackRef_FunctionCheck(_PyStackRef stackref)
723
+ {
724
+ return PyFunction_Check(PyStackRef_AsPyObjectBorrow(stackref));
725
+ }
726
+
727
+ static inline void
728
+ _PyThreadState_PushCStackRef(PyThreadState *tstate, _PyCStackRef *ref)
729
+ {
730
+ #ifdef Py_GIL_DISABLED
731
+ _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate;
732
+ ref->next = tstate_impl->c_stack_refs;
733
+ tstate_impl->c_stack_refs = ref;
734
+ #endif
735
+ ref->ref = PyStackRef_NULL;
736
+ }
737
+
738
+ static inline void
739
+ _PyThreadState_PopCStackRef(PyThreadState *tstate, _PyCStackRef *ref)
740
+ {
741
+ #ifdef Py_GIL_DISABLED
742
+ _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate;
743
+ assert(tstate_impl->c_stack_refs == ref);
744
+ tstate_impl->c_stack_refs = ref->next;
745
+ #endif
746
+ PyStackRef_XCLOSE(ref->ref);
747
+ }
748
+
749
+ #ifdef Py_GIL_DISABLED
750
+
751
+ static inline int
752
+ _Py_TryIncrefCompareStackRef(PyObject **src, PyObject *op, _PyStackRef *out)
753
+ {
754
+ if (_PyObject_HasDeferredRefcount(op)) {
755
+ *out = (_PyStackRef){ .bits = (uintptr_t)op | Py_TAG_DEFERRED };
756
+ return 1;
757
+ }
758
+ if (_Py_TryIncrefCompare(src, op)) {
759
+ *out = PyStackRef_FromPyObjectSteal(op);
760
+ return 1;
761
+ }
762
+ return 0;
763
+ }
764
+
765
+ static inline int
766
+ _Py_TryXGetStackRef(PyObject **src, _PyStackRef *out)
767
+ {
768
+ PyObject *op = _PyObject_CAST(_Py_atomic_load_ptr_relaxed(src));
769
+ if (op == NULL) {
770
+ *out = PyStackRef_NULL;
771
+ return 1;
772
+ }
773
+ return _Py_TryIncrefCompareStackRef(src, op, out);
774
+ }
775
+
776
+ #endif
777
+
778
+ // Like Py_VISIT but for _PyStackRef fields
779
+ #define _Py_VISIT_STACKREF(ref) \
780
+ do { \
781
+ if (!PyStackRef_IsNullOrInt(ref)) { \
782
+ int vret = _PyGC_VisitStackRef(&(ref), visit, arg); \
783
+ if (vret) \
784
+ return vret; \
785
+ } \
786
+ } while (0)
787
+
788
+ #ifdef __cplusplus
789
+ }
790
+ #endif
791
+ #endif /* !Py_INTERNAL_STACKREF_H */