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,321 @@
1
+ /*
2
+ _BlocksOutputBuffer is used to maintain an output buffer
3
+ that has unpredictable size. Suitable for compression/decompression
4
+ API (bz2/lzma/zlib) that has stream->next_out and stream->avail_out:
5
+
6
+ stream->next_out: point to the next output position.
7
+ stream->avail_out: the number of available bytes left in the buffer.
8
+
9
+ It maintains a list of bytes object, so there is no overhead of resizing
10
+ the buffer.
11
+
12
+ Usage:
13
+
14
+ 1, Initialize the struct instance like this:
15
+ _BlocksOutputBuffer buffer = {.list = NULL};
16
+ Set .list to NULL for _BlocksOutputBuffer_OnError()
17
+
18
+ 2, Initialize the buffer use one of these functions:
19
+ _BlocksOutputBuffer_InitAndGrow()
20
+ _BlocksOutputBuffer_InitWithSize()
21
+
22
+ 3, If (avail_out == 0), grow the buffer:
23
+ _BlocksOutputBuffer_Grow()
24
+
25
+ 4, Get the current outputted data size:
26
+ _BlocksOutputBuffer_GetDataSize()
27
+
28
+ 5, Finish the buffer, and return a bytes object:
29
+ _BlocksOutputBuffer_Finish()
30
+
31
+ 6, Clean up the buffer when an error occurred:
32
+ _BlocksOutputBuffer_OnError()
33
+ */
34
+
35
+ #ifndef Py_INTERNAL_BLOCKS_OUTPUT_BUFFER_H
36
+ #define Py_INTERNAL_BLOCKS_OUTPUT_BUFFER_H
37
+ #ifdef __cplusplus
38
+ extern "C" {
39
+ #endif
40
+
41
+ #include "Python.h"
42
+
43
+ #ifndef Py_BUILD_CORE
44
+ # error "this header requires Py_BUILD_CORE define"
45
+ #endif
46
+
47
+ typedef struct {
48
+ // List of bytes objects
49
+ PyObject *list;
50
+ // Number of whole allocated size
51
+ Py_ssize_t allocated;
52
+ // Max length of the buffer, negative number means unlimited length.
53
+ Py_ssize_t max_length;
54
+ } _BlocksOutputBuffer;
55
+
56
+ static const char unable_allocate_msg[] = "Unable to allocate output buffer.";
57
+
58
+ /* In 32-bit build, the max block size should <= INT32_MAX. */
59
+ #define OUTPUT_BUFFER_MAX_BLOCK_SIZE (256*1024*1024)
60
+
61
+ /* Block size sequence */
62
+ #define KB (1024)
63
+ #define MB (1024*1024)
64
+ static const Py_ssize_t BUFFER_BLOCK_SIZE[] =
65
+ { 32*KB, 64*KB, 256*KB, 1*MB, 4*MB, 8*MB, 16*MB, 16*MB,
66
+ 32*MB, 32*MB, 32*MB, 32*MB, 64*MB, 64*MB, 128*MB, 128*MB,
67
+ OUTPUT_BUFFER_MAX_BLOCK_SIZE };
68
+ #undef KB
69
+ #undef MB
70
+
71
+ /* According to the block sizes defined by BUFFER_BLOCK_SIZE, the whole
72
+ allocated size growth step is:
73
+ 1 32 KB +32 KB
74
+ 2 96 KB +64 KB
75
+ 3 352 KB +256 KB
76
+ 4 1.34 MB +1 MB
77
+ 5 5.34 MB +4 MB
78
+ 6 13.34 MB +8 MB
79
+ 7 29.34 MB +16 MB
80
+ 8 45.34 MB +16 MB
81
+ 9 77.34 MB +32 MB
82
+ 10 109.34 MB +32 MB
83
+ 11 141.34 MB +32 MB
84
+ 12 173.34 MB +32 MB
85
+ 13 237.34 MB +64 MB
86
+ 14 301.34 MB +64 MB
87
+ 15 429.34 MB +128 MB
88
+ 16 557.34 MB +128 MB
89
+ 17 813.34 MB +256 MB
90
+ 18 1069.34 MB +256 MB
91
+ 19 1325.34 MB +256 MB
92
+ 20 1581.34 MB +256 MB
93
+ 21 1837.34 MB +256 MB
94
+ 22 2093.34 MB +256 MB
95
+ ...
96
+ */
97
+
98
+ /* Initialize the buffer, and grow the buffer.
99
+
100
+ max_length: Max length of the buffer, -1 for unlimited length.
101
+
102
+ On success, return allocated size (>=0)
103
+ On failure, return -1
104
+ */
105
+ static inline Py_ssize_t
106
+ _BlocksOutputBuffer_InitAndGrow(_BlocksOutputBuffer *buffer,
107
+ const Py_ssize_t max_length,
108
+ void **next_out)
109
+ {
110
+ PyObject *b;
111
+ Py_ssize_t block_size;
112
+
113
+ // ensure .list was set to NULL
114
+ assert(buffer->list == NULL);
115
+
116
+ // get block size
117
+ if (0 <= max_length && max_length < BUFFER_BLOCK_SIZE[0]) {
118
+ block_size = max_length;
119
+ } else {
120
+ block_size = BUFFER_BLOCK_SIZE[0];
121
+ }
122
+
123
+ // the first block
124
+ b = PyBytes_FromStringAndSize(NULL, block_size);
125
+ if (b == NULL) {
126
+ return -1;
127
+ }
128
+
129
+ // create the list
130
+ buffer->list = PyList_New(1);
131
+ if (buffer->list == NULL) {
132
+ Py_DECREF(b);
133
+ return -1;
134
+ }
135
+ PyList_SET_ITEM(buffer->list, 0, b);
136
+
137
+ // set variables
138
+ buffer->allocated = block_size;
139
+ buffer->max_length = max_length;
140
+
141
+ *next_out = PyBytes_AS_STRING(b);
142
+ return block_size;
143
+ }
144
+
145
+ /* Initialize the buffer, with an initial size.
146
+
147
+ Check block size limit in the outer wrapper function. For example, some libs
148
+ accept UINT32_MAX as the maximum block size, then init_size should <= it.
149
+
150
+ On success, return allocated size (>=0)
151
+ On failure, return -1
152
+ */
153
+ static inline Py_ssize_t
154
+ _BlocksOutputBuffer_InitWithSize(_BlocksOutputBuffer *buffer,
155
+ const Py_ssize_t init_size,
156
+ void **next_out)
157
+ {
158
+ PyObject *b;
159
+
160
+ // ensure .list was set to NULL
161
+ assert(buffer->list == NULL);
162
+
163
+ // the first block
164
+ b = PyBytes_FromStringAndSize(NULL, init_size);
165
+ if (b == NULL) {
166
+ PyErr_SetString(PyExc_MemoryError, unable_allocate_msg);
167
+ return -1;
168
+ }
169
+
170
+ // create the list
171
+ buffer->list = PyList_New(1);
172
+ if (buffer->list == NULL) {
173
+ Py_DECREF(b);
174
+ return -1;
175
+ }
176
+ PyList_SET_ITEM(buffer->list, 0, b);
177
+
178
+ // set variables
179
+ buffer->allocated = init_size;
180
+ buffer->max_length = -1;
181
+
182
+ *next_out = PyBytes_AS_STRING(b);
183
+ return init_size;
184
+ }
185
+
186
+ /* Grow the buffer. The avail_out must be 0, please check it before calling.
187
+
188
+ On success, return allocated size (>=0)
189
+ On failure, return -1
190
+ */
191
+ static inline Py_ssize_t
192
+ _BlocksOutputBuffer_Grow(_BlocksOutputBuffer *buffer,
193
+ void **next_out,
194
+ const Py_ssize_t avail_out)
195
+ {
196
+ PyObject *b;
197
+ const Py_ssize_t list_len = Py_SIZE(buffer->list);
198
+ Py_ssize_t block_size;
199
+
200
+ // ensure no gaps in the data
201
+ if (avail_out != 0) {
202
+ PyErr_SetString(PyExc_SystemError,
203
+ "avail_out is non-zero in _BlocksOutputBuffer_Grow().");
204
+ return -1;
205
+ }
206
+
207
+ // get block size
208
+ if (list_len < (Py_ssize_t) Py_ARRAY_LENGTH(BUFFER_BLOCK_SIZE)) {
209
+ block_size = BUFFER_BLOCK_SIZE[list_len];
210
+ } else {
211
+ block_size = BUFFER_BLOCK_SIZE[Py_ARRAY_LENGTH(BUFFER_BLOCK_SIZE) - 1];
212
+ }
213
+
214
+ // check max_length
215
+ if (buffer->max_length >= 0) {
216
+ // if (rest == 0), should not grow the buffer.
217
+ Py_ssize_t rest = buffer->max_length - buffer->allocated;
218
+ assert(rest > 0);
219
+
220
+ // block_size of the last block
221
+ if (block_size > rest) {
222
+ block_size = rest;
223
+ }
224
+ }
225
+
226
+ // check buffer->allocated overflow
227
+ if (block_size > PY_SSIZE_T_MAX - buffer->allocated) {
228
+ PyErr_SetString(PyExc_MemoryError, unable_allocate_msg);
229
+ return -1;
230
+ }
231
+
232
+ // create the block
233
+ b = PyBytes_FromStringAndSize(NULL, block_size);
234
+ if (b == NULL) {
235
+ PyErr_SetString(PyExc_MemoryError, unable_allocate_msg);
236
+ return -1;
237
+ }
238
+ if (PyList_Append(buffer->list, b) < 0) {
239
+ Py_DECREF(b);
240
+ return -1;
241
+ }
242
+ Py_DECREF(b);
243
+
244
+ // set variables
245
+ buffer->allocated += block_size;
246
+
247
+ *next_out = PyBytes_AS_STRING(b);
248
+ return block_size;
249
+ }
250
+
251
+ /* Return the current outputted data size. */
252
+ static inline Py_ssize_t
253
+ _BlocksOutputBuffer_GetDataSize(_BlocksOutputBuffer *buffer,
254
+ const Py_ssize_t avail_out)
255
+ {
256
+ return buffer->allocated - avail_out;
257
+ }
258
+
259
+ /* Finish the buffer.
260
+
261
+ Return a bytes object on success
262
+ Return NULL on failure
263
+ */
264
+ static inline PyObject *
265
+ _BlocksOutputBuffer_Finish(_BlocksOutputBuffer *buffer,
266
+ const Py_ssize_t avail_out)
267
+ {
268
+ PyObject *result, *block;
269
+ const Py_ssize_t list_len = Py_SIZE(buffer->list);
270
+
271
+ // fast path for single block
272
+ if ((list_len == 1 && avail_out == 0) ||
273
+ (list_len == 2 && Py_SIZE(PyList_GET_ITEM(buffer->list, 1)) == avail_out))
274
+ {
275
+ block = PyList_GET_ITEM(buffer->list, 0);
276
+ Py_INCREF(block);
277
+
278
+ Py_CLEAR(buffer->list);
279
+ return block;
280
+ }
281
+
282
+ // final bytes object
283
+ result = PyBytes_FromStringAndSize(NULL, buffer->allocated - avail_out);
284
+ if (result == NULL) {
285
+ PyErr_SetString(PyExc_MemoryError, unable_allocate_msg);
286
+ return NULL;
287
+ }
288
+
289
+ // memory copy
290
+ if (list_len > 0) {
291
+ char *posi = PyBytes_AS_STRING(result);
292
+
293
+ // blocks except the last one
294
+ Py_ssize_t i = 0;
295
+ for (; i < list_len-1; i++) {
296
+ block = PyList_GET_ITEM(buffer->list, i);
297
+ memcpy(posi, PyBytes_AS_STRING(block), Py_SIZE(block));
298
+ posi += Py_SIZE(block);
299
+ }
300
+ // the last block
301
+ block = PyList_GET_ITEM(buffer->list, i);
302
+ memcpy(posi, PyBytes_AS_STRING(block), Py_SIZE(block) - avail_out);
303
+ } else {
304
+ assert(Py_SIZE(result) == 0);
305
+ }
306
+
307
+ Py_CLEAR(buffer->list);
308
+ return result;
309
+ }
310
+
311
+ /* Clean up the buffer when an error occurred. */
312
+ static inline void
313
+ _BlocksOutputBuffer_OnError(_BlocksOutputBuffer *buffer)
314
+ {
315
+ Py_CLEAR(buffer->list);
316
+ }
317
+
318
+ #ifdef __cplusplus
319
+ }
320
+ #endif
321
+ #endif /* Py_INTERNAL_BLOCKS_OUTPUT_BUFFER_H */
@@ -0,0 +1,73 @@
1
+ #ifndef Py_INTERNAL_BRC_H
2
+ #define Py_INTERNAL_BRC_H
3
+
4
+ #include <stdint.h>
5
+ #include "pycore_llist.h" // struct llist_node
6
+ #include "pycore_object_stack.h" // _PyObjectStack
7
+
8
+ #ifdef __cplusplus
9
+ extern "C" {
10
+ #endif
11
+
12
+ #ifndef Py_BUILD_CORE
13
+ # error "this header requires Py_BUILD_CORE define"
14
+ #endif
15
+
16
+ #ifdef Py_GIL_DISABLED
17
+
18
+ // Prime number to avoid correlations with memory addresses.
19
+ #define _Py_BRC_NUM_BUCKETS 257
20
+
21
+ // Hash table bucket
22
+ struct _brc_bucket {
23
+ // Mutex protects both the bucket and thread state queues in this bucket.
24
+ PyMutex mutex;
25
+
26
+ // Linked list of _PyThreadStateImpl objects hashed to this bucket.
27
+ struct llist_node root;
28
+ };
29
+
30
+ // Per-interpreter biased reference counting state
31
+ struct _brc_state {
32
+ // Hash table of thread states by thread-id. Thread states within a bucket
33
+ // are chained using a doubly-linked list.
34
+ struct _brc_bucket table[_Py_BRC_NUM_BUCKETS];
35
+ };
36
+
37
+ // Per-thread biased reference counting state
38
+ struct _brc_thread_state {
39
+ // Linked-list of thread states per hash bucket
40
+ struct llist_node bucket_node;
41
+
42
+ // Thread-id as determined by _PyThread_Id()
43
+ uintptr_t tid;
44
+
45
+ // Objects with refcounts to be merged (protected by bucket mutex)
46
+ _PyObjectStack objects_to_merge;
47
+
48
+ // Local stack of objects to be merged (not accessed by other threads)
49
+ _PyObjectStack local_objects_to_merge;
50
+ };
51
+
52
+ // Initialize/finalize the per-thread biased reference counting state
53
+ void _Py_brc_init_thread(PyThreadState *tstate);
54
+ void _Py_brc_remove_thread(PyThreadState *tstate);
55
+
56
+ // Initialize per-interpreter state
57
+ void _Py_brc_init_state(PyInterpreterState *interp);
58
+
59
+ void _Py_brc_after_fork(PyInterpreterState *interp);
60
+
61
+ // Enqueues an object to be merged by it's owning thread (tid). This
62
+ // steals a reference to the object.
63
+ void _Py_brc_queue_object(PyObject *ob);
64
+
65
+ // Merge the refcounts of queued objects for the current thread.
66
+ void _Py_brc_merge_refcounts(PyThreadState *tstate);
67
+
68
+ #endif /* Py_GIL_DISABLED */
69
+
70
+ #ifdef __cplusplus
71
+ }
72
+ #endif
73
+ #endif /* !Py_INTERNAL_BRC_H */
@@ -0,0 +1,82 @@
1
+ #ifndef Py_LIMITED_API
2
+ #ifndef Py_BYTES_CTYPE_H
3
+ #define Py_BYTES_CTYPE_H
4
+
5
+ #ifndef Py_BUILD_CORE
6
+ # error "this header requires Py_BUILD_CORE define"
7
+ #endif
8
+
9
+ /*
10
+ * The internal implementation behind PyBytes (bytes) and PyByteArray (bytearray)
11
+ * methods of the given names, they operate on ASCII byte strings.
12
+ */
13
+ extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len);
14
+ extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len);
15
+ extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len);
16
+ extern PyObject* _Py_bytes_isascii(const char *cptr, Py_ssize_t len);
17
+ extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len);
18
+ extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len);
19
+ extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len);
20
+ extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len);
21
+
22
+ /* These store their len sized answer in the given preallocated *result arg. */
23
+ extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len);
24
+ extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len);
25
+ extern void _Py_bytes_title(char *result, const char *s, Py_ssize_t len);
26
+ extern void _Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len);
27
+ extern void _Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len);
28
+
29
+ extern PyObject *_Py_bytes_find(const char *str, Py_ssize_t len, PyObject *sub,
30
+ Py_ssize_t start, Py_ssize_t end);
31
+ extern PyObject *_Py_bytes_index(const char *str, Py_ssize_t len, PyObject *sub,
32
+ Py_ssize_t start, Py_ssize_t end);
33
+ extern PyObject *_Py_bytes_rfind(const char *str, Py_ssize_t len, PyObject *sub,
34
+ Py_ssize_t start, Py_ssize_t end);
35
+ extern PyObject *_Py_bytes_rindex(const char *str, Py_ssize_t len, PyObject *sub,
36
+ Py_ssize_t start, Py_ssize_t end);
37
+ extern PyObject *_Py_bytes_count(const char *str, Py_ssize_t len, PyObject *sub,
38
+ Py_ssize_t start, Py_ssize_t end);
39
+ extern int _Py_bytes_contains(const char *str, Py_ssize_t len, PyObject *arg);
40
+ extern PyObject *_Py_bytes_startswith(const char *str, Py_ssize_t len,
41
+ PyObject *subobj, Py_ssize_t start,
42
+ Py_ssize_t end);
43
+ extern PyObject *_Py_bytes_endswith(const char *str, Py_ssize_t len,
44
+ PyObject *subobj, Py_ssize_t start,
45
+ Py_ssize_t end);
46
+
47
+ /* The maketrans() static method. */
48
+ extern PyObject* _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to);
49
+
50
+ /* Shared __doc__ strings. */
51
+ extern const char _Py_isspace__doc__[];
52
+ extern const char _Py_isalpha__doc__[];
53
+ extern const char _Py_isalnum__doc__[];
54
+ extern const char _Py_isascii__doc__[];
55
+ extern const char _Py_isdigit__doc__[];
56
+ extern const char _Py_islower__doc__[];
57
+ extern const char _Py_isupper__doc__[];
58
+ extern const char _Py_istitle__doc__[];
59
+ extern const char _Py_lower__doc__[];
60
+ extern const char _Py_upper__doc__[];
61
+ extern const char _Py_title__doc__[];
62
+ extern const char _Py_capitalize__doc__[];
63
+ extern const char _Py_swapcase__doc__[];
64
+ extern const char _Py_count__doc__[];
65
+ extern const char _Py_find__doc__[];
66
+ extern const char _Py_index__doc__[];
67
+ extern const char _Py_rfind__doc__[];
68
+ extern const char _Py_rindex__doc__[];
69
+ extern const char _Py_startswith__doc__[];
70
+ extern const char _Py_endswith__doc__[];
71
+ extern const char _Py_maketrans__doc__[];
72
+ extern const char _Py_expandtabs__doc__[];
73
+ extern const char _Py_ljust__doc__[];
74
+ extern const char _Py_rjust__doc__[];
75
+ extern const char _Py_center__doc__[];
76
+ extern const char _Py_zfill__doc__[];
77
+
78
+ /* this is needed because some docs are shared from the .o, not static */
79
+ #define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
80
+
81
+ #endif /* !Py_BYTES_CTYPE_H */
82
+ #endif /* !Py_LIMITED_API */
@@ -0,0 +1,149 @@
1
+ #ifndef Py_INTERNAL_BYTESOBJECT_H
2
+ #define Py_INTERNAL_BYTESOBJECT_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
+ extern PyObject* _PyBytes_FormatEx(
12
+ const char *format,
13
+ Py_ssize_t format_len,
14
+ PyObject *args,
15
+ int use_bytearray);
16
+
17
+ extern PyObject* _PyBytes_FromHex(
18
+ PyObject *string,
19
+ int use_bytearray);
20
+
21
+ // Helper for PyBytes_DecodeEscape that detects invalid escape chars.
22
+ // Export for test_peg_generator.
23
+ PyAPI_FUNC(PyObject*) _PyBytes_DecodeEscape2(const char *, Py_ssize_t,
24
+ const char *,
25
+ int *, const char **);
26
+
27
+
28
+ // Substring Search.
29
+ //
30
+ // Returns the index of the first occurrence of
31
+ // a substring ("needle") in a larger text ("haystack").
32
+ // If the needle is not found, return -1.
33
+ // If the needle is found, add offset to the index.
34
+ //
35
+ // Export for 'mmap' shared extension.
36
+ PyAPI_FUNC(Py_ssize_t)
37
+ _PyBytes_Find(const char *haystack, Py_ssize_t len_haystack,
38
+ const char *needle, Py_ssize_t len_needle,
39
+ Py_ssize_t offset);
40
+
41
+ // Same as above, but search right-to-left.
42
+ // Export for 'mmap' shared extension.
43
+ PyAPI_FUNC(Py_ssize_t)
44
+ _PyBytes_ReverseFind(const char *haystack, Py_ssize_t len_haystack,
45
+ const char *needle, Py_ssize_t len_needle,
46
+ Py_ssize_t offset);
47
+
48
+
49
+ // Helper function to implement the repeat and inplace repeat methods on a
50
+ // buffer.
51
+ //
52
+ // len_dest is assumed to be an integer multiple of len_src.
53
+ // If src equals dest, then assume the operation is inplace.
54
+ //
55
+ // This method repeately doubles the number of bytes copied to reduce
56
+ // the number of invocations of memcpy.
57
+ //
58
+ // Export for 'array' shared extension.
59
+ PyAPI_FUNC(void)
60
+ _PyBytes_Repeat(char* dest, Py_ssize_t len_dest,
61
+ const char* src, Py_ssize_t len_src);
62
+
63
+ /* --- _PyBytesWriter ----------------------------------------------------- */
64
+
65
+ /* The _PyBytesWriter structure is big: it contains an embedded "stack buffer".
66
+ A _PyBytesWriter variable must be declared at the end of variables in a
67
+ function to optimize the memory allocation on the stack. */
68
+ typedef struct {
69
+ /* bytes, bytearray or NULL (when the small buffer is used) */
70
+ PyObject *buffer;
71
+
72
+ /* Number of allocated size. */
73
+ Py_ssize_t allocated;
74
+
75
+ /* Minimum number of allocated bytes,
76
+ incremented by _PyBytesWriter_Prepare() */
77
+ Py_ssize_t min_size;
78
+
79
+ /* If non-zero, use a bytearray instead of a bytes object for buffer. */
80
+ int use_bytearray;
81
+
82
+ /* If non-zero, overallocate the buffer (default: 0).
83
+ This flag must be zero if use_bytearray is non-zero. */
84
+ int overallocate;
85
+
86
+ /* Stack buffer */
87
+ int use_small_buffer;
88
+ char small_buffer[512];
89
+ } _PyBytesWriter;
90
+
91
+ /* Initialize a bytes writer
92
+
93
+ By default, the overallocation is disabled. Set the overallocate attribute
94
+ to control the allocation of the buffer.
95
+
96
+ Export _PyBytesWriter API for '_pickle' shared extension. */
97
+ PyAPI_FUNC(void) _PyBytesWriter_Init(_PyBytesWriter *writer);
98
+
99
+ /* Get the buffer content and reset the writer.
100
+ Return a bytes object, or a bytearray object if use_bytearray is non-zero.
101
+ Raise an exception and return NULL on error. */
102
+ PyAPI_FUNC(PyObject *) _PyBytesWriter_Finish(_PyBytesWriter *writer,
103
+ void *str);
104
+
105
+ /* Deallocate memory of a writer (clear its internal buffer). */
106
+ PyAPI_FUNC(void) _PyBytesWriter_Dealloc(_PyBytesWriter *writer);
107
+
108
+ /* Allocate the buffer to write size bytes.
109
+ Return the pointer to the beginning of buffer data.
110
+ Raise an exception and return NULL on error. */
111
+ PyAPI_FUNC(void*) _PyBytesWriter_Alloc(_PyBytesWriter *writer,
112
+ Py_ssize_t size);
113
+
114
+ /* Ensure that the buffer is large enough to write *size* bytes.
115
+ Add size to the writer minimum size (min_size attribute).
116
+
117
+ str is the current pointer inside the buffer.
118
+ Return the updated current pointer inside the buffer.
119
+ Raise an exception and return NULL on error. */
120
+ PyAPI_FUNC(void*) _PyBytesWriter_Prepare(_PyBytesWriter *writer,
121
+ void *str,
122
+ Py_ssize_t size);
123
+
124
+ /* Resize the buffer to make it larger.
125
+ The new buffer may be larger than size bytes because of overallocation.
126
+ Return the updated current pointer inside the buffer.
127
+ Raise an exception and return NULL on error.
128
+
129
+ Note: size must be greater than the number of allocated bytes in the writer.
130
+
131
+ This function doesn't use the writer minimum size (min_size attribute).
132
+
133
+ See also _PyBytesWriter_Prepare().
134
+ */
135
+ PyAPI_FUNC(void*) _PyBytesWriter_Resize(_PyBytesWriter *writer,
136
+ void *str,
137
+ Py_ssize_t size);
138
+
139
+ /* Write bytes.
140
+ Raise an exception and return NULL on error. */
141
+ PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer,
142
+ void *str,
143
+ const void *bytes,
144
+ Py_ssize_t size);
145
+
146
+ #ifdef __cplusplus
147
+ }
148
+ #endif
149
+ #endif /* !Py_INTERNAL_BYTESOBJECT_H */
@@ -0,0 +1,39 @@
1
+ #ifndef Py_INTERNAL_C_ARRAY_H
2
+ #define Py_INTERNAL_C_ARRAY_H
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #ifndef Py_BUILD_CORE
9
+ # error "this header requires Py_BUILD_CORE define"
10
+ #endif
11
+
12
+
13
+ /* Utility for a number of growing arrays */
14
+
15
+ typedef struct {
16
+ void *array; /* pointer to the array */
17
+ int allocated_entries; /* pointer to the capacity of the array */
18
+ size_t item_size; /* size of each element */
19
+ int initial_num_entries; /* initial allocation size */
20
+ } _Py_c_array_t;
21
+
22
+
23
+ int _Py_CArray_Init(_Py_c_array_t* array, int item_size, int initial_num_entries);
24
+ void _Py_CArray_Fini(_Py_c_array_t* array);
25
+
26
+ /* If idx is out of bounds:
27
+ * If arr->array is NULL, allocate arr->initial_num_entries slots.
28
+ * Otherwise, double its size.
29
+ *
30
+ * Return 0 if successful and -1 (with exception set) otherwise.
31
+ */
32
+ int _Py_CArray_EnsureCapacity(_Py_c_array_t *c_array, int idx);
33
+
34
+
35
+ #ifdef __cplusplus
36
+ }
37
+ #endif
38
+
39
+ #endif /* !Py_INTERNAL_C_ARRAY_H */