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.
- pytron/__init__.py +112 -0
- pytron/application.py +562 -0
- pytron/apputils/__init__.py +0 -0
- pytron/apputils/chrome_ipc.py +203 -0
- pytron/apputils/codegen.py +261 -0
- pytron/apputils/config.py +303 -0
- pytron/apputils/deadmansswitch.py +47 -0
- pytron/apputils/extras.py +76 -0
- pytron/apputils/native.py +148 -0
- pytron/apputils/shell.py +73 -0
- pytron/apputils/windows.py +286 -0
- pytron/cli.py +384 -0
- pytron/commands/__init__.py +0 -0
- pytron/commands/android.py +28 -0
- pytron/commands/build.py +26 -0
- pytron/commands/doctor.py +221 -0
- pytron/commands/engine.py +23 -0
- pytron/commands/frontend.py +60 -0
- pytron/commands/harvest.py +112 -0
- pytron/commands/helpers.py +239 -0
- pytron/commands/info.py +50 -0
- pytron/commands/init.py +521 -0
- pytron/commands/install.py +294 -0
- pytron/commands/login.py +130 -0
- pytron/commands/package.py +228 -0
- pytron/commands/plugin.py +442 -0
- pytron/commands/run.py +312 -0
- pytron/commands/scan.py +210 -0
- pytron/commands/show.py +23 -0
- pytron/commands/uninstall.py +150 -0
- pytron/commands/utils.py +42 -0
- pytron/commands/workflow.py +95 -0
- pytron/console.py +133 -0
- pytron/core.py +18 -0
- pytron/dependencies/WebView2Loader.dll +0 -0
- pytron/dependencies/__init__.py +1 -0
- pytron/dependencies/pytron_native.so +0 -0
- pytron/engines/chrome/adapter.py +445 -0
- pytron/engines/chrome/engine.py +576 -0
- pytron/engines/chrome/forge.py +147 -0
- pytron/engines/chrome/shell/package.json +8 -0
- pytron/engines/chrome/shell/preload.js +12 -0
- pytron/engines/chrome/shell/shell.js +534 -0
- pytron/exceptions.py +36 -0
- pytron/inspector.py +201 -0
- pytron/inspector_ui.py +512 -0
- pytron/installer/Installation.nsi +236 -0
- pytron/installer/header.bmp +0 -0
- pytron/installer/pytron.ico +0 -0
- pytron/installer/sidebar.bmp +0 -0
- pytron/llms.md +98 -0
- pytron/manifests/README.md +29 -0
- pytron/manifests/windows-utf8.manifest +44 -0
- pytron/menu.py +128 -0
- pytron/nsis-setup.exe +0 -0
- pytron/pack/__init__.py +0 -0
- pytron/pack/assets.py +131 -0
- pytron/pack/compilers.py +289 -0
- pytron/pack/crystal.py +297 -0
- pytron/pack/graph.py +377 -0
- pytron/pack/inference.py +157 -0
- pytron/pack/installers.py +402 -0
- pytron/pack/introspect.py +357 -0
- pytron/pack/metadata.py +213 -0
- pytron/pack/modules.py +618 -0
- pytron/pack/nuitka.py +108 -0
- pytron/pack/pipeline.py +107 -0
- pytron/pack/pyinstaller.py +176 -0
- pytron/pack/rust_engine.py +273 -0
- pytron/pack/secure.py +309 -0
- pytron/pack/secure_loader/bin/pytron_rust_bootloader +0 -0
- pytron/pack/secure_loader/icon.ico +0 -0
- pytron/pack/utils.py +110 -0
- pytron/pack/virtual_root.py +124 -0
- pytron/platforms/__init__.py +0 -0
- pytron/platforms/android/__init__.py +3 -0
- pytron/platforms/android/android.py +103 -0
- pytron/platforms/android/builder.py +736 -0
- pytron/platforms/android/ops/build.py +79 -0
- pytron/platforms/android/ops/init.py +63 -0
- pytron/platforms/android/ops/run.py +79 -0
- pytron/platforms/android/ops/sync.py +770 -0
- pytron/platforms/android/ops/utils.py +8 -0
- pytron/platforms/android/shell/README.md +30 -0
- pytron/platforms/android/shell/app/build.gradle +64 -0
- pytron/platforms/android/shell/app/src/main/AndroidManifest.xml +29 -0
- pytron/platforms/android/shell/app/src/main/assets/python/main.py +86 -0
- pytron/platforms/android/shell/app/src/main/assets/python/python314.zip +0 -0
- pytron/platforms/android/shell/app/src/main/cpp/CMakeLists.txt +25 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/Python.h +155 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/abstract.h +915 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/audit.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bltinmodule.h +14 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/boolobject.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bytearrayobject.h +44 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/bytesobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/ceval.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/codecs.h +176 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/compile.h +22 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/complexobject.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/abstract.h +104 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/audit.h +8 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytearrayobject.h +38 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/bytesobject.h +42 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/cellobject.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/ceval.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/classobject.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/code.h +340 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/compile.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/complexobject.h +33 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/context.h +107 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/critical_section.h +154 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/descrobject.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/dictobject.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileobject.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/fileutils.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/floatobject.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/frameobject.h +35 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/funcobject.h +185 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/genobject.h +56 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/import.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/initconfig.h +334 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/listobject.h +53 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/lock.h +74 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longintrepr.h +184 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/longobject.h +89 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/memoryobject.h +50 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/methodobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/modsupport.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/monitoring.h +269 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/object.h +493 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/objimpl.h +104 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/odictobject.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/picklebufobject.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pthread_stubs.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic.h +614 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_gcc.h +615 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_msc.h +1197 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyatomic_std.h +1112 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyctype.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pydebug.h +38 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyerrors.h +132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyfpe.h +15 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyframe.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pyhash.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pylifecycle.h +89 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pymem.h +84 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystate.h +275 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pystats.h +194 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythonrun.h +96 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pythread.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/pytime.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/setobject.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/traceback.h +13 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tracemalloc.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/tupleobject.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/unicodeobject.h +773 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/warnings.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/cpython/weakrefobject.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/critical_section.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/datetime.h +267 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/descrobject.h +100 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/dictobject.h +108 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/dynamic_annotations.h +499 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/enumobject.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/errcode.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/exports.h +105 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/fileobject.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/fileutils.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/floatobject.h +54 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/frameobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/genericaliasobject.h +14 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/import.h +103 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/atomic.h +392 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/internal.h +969 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/prim.h +329 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/track.h +147 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc/types.h +721 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/mimalloc/mimalloc.h +565 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_abstract.h +61 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_asdl.h +112 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast.h +945 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ast_state.h +271 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_atexit.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_audit.h +35 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_backoff.h +133 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bitutils.h +186 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_blocks_output_buffer.h +321 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_brc.h +73 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytes_methods.h +82 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_bytesobject.h +149 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_c_array.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_call.h +206 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_capsule.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_cell.h +75 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval.h +390 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ceval_state.h +48 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_code.h +671 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_codecs.h +76 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_compile.h +230 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_complexobject.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_condvar.h +93 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_context.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_critical_section.h +237 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp.h +406 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_crossinterp_data_registry.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_debug_offsets.h +379 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_descrobject.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict.h +410 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dict_state.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_dtoa.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_signal.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_emscripten_trampoline.h +70 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_exceptions.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_faulthandler.h +100 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils.h +320 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_fileutils_windows.h +98 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_floatobject.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_flowgraph.h +47 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_format.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_frame.h +61 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist.h +111 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_freelist_state.h +70 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_function.h +53 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gc.h +378 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_genobject.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_getopt.h +22 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_gil.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_objects_fini_generated.h +1592 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_global_strings.h +854 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hamt.h +113 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_hashtable.h +150 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_import.h +141 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_importdl.h +139 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_index_pool.h +36 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_initconfig.h +197 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruction_sequence.h +83 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_instruments.h +127 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp.h +109 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interp_structs.h +977 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe.h +401 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpframe_structs.h +95 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_interpolation.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_intrinsics.h +51 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_jit.h +29 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_list.h +81 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_llist.h +106 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_lock.h +236 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_long.h +319 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_magic_number.h +305 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_memoryobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_mimalloc.h +69 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_modsupport.h +99 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_moduleobject.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_namespace.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object.h +1029 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_alloc.h +71 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_deferred.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_stack.h +95 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_object_state.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc.h +702 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_obmalloc_init.h +66 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_metadata.h +2117 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_opcode_utils.h +90 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_optimizer.h +318 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parking_lot.h +97 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_parser.h +78 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pathconfig.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyarena.h +68 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyatomic_ft_wrappers.h +174 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pybuffer.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyerrors.h +213 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pyhash.h +91 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pylifecycle.h +136 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymath.h +205 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pymem_init.h +103 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystate.h +339 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pystats.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythonrun.h +68 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_pythread.h +172 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_qsbr.h +172 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_range.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime.h +63 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init.h +239 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_init_generated.h +1589 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_runtime_structs.h +310 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_semaphore.h +67 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_setobject.h +41 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_signal.h +108 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sliceobject.h +20 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stackref.h +791 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_stats.h +97 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_strhex.h +39 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structs.h +88 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_structseq.h +40 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_symtable.h +201 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_sysmodule.h +32 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_template.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_time.h +334 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_token.h +110 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_traceback.h +111 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tracemalloc.h +164 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tstate.h +88 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_tuple.h +75 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typedefs.h +18 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typeobject.h +155 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_typevarobject.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_ucnhash.h +36 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject.h +308 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unicodeobject_generated.h +3132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_unionobject.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uniqueid.h +57 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_ids.h +335 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_uop_metadata.h +1204 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_warnings.h +21 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/internal/pycore_weakref.h +133 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/intrcheck.h +23 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/iterobject.h +24 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/listobject.h +55 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/lock.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/longobject.h +178 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/marshal.h +31 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/memoryobject.h +34 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/methodobject.h +146 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/modsupport.h +146 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/moduleobject.h +122 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/monitoring.h +18 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/object.h +828 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/objimpl.h +211 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/opcode.h +43 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/opcode_ids.h +259 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/osdefs.h +57 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/osmodule.h +17 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/patchlevel.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/py_curses.h +117 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyatomic.h +16 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pybuffer.h +145 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pycapsule.h +58 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyconfig.h +2088 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pydtrace.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyerrors.h +335 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyexpat.h +62 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyframe.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyhash.h +59 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pylifecycle.h +80 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymacconfig.h +91 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymacro.h +243 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymath.h +65 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pymem.h +110 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pyport.h +710 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystate.h +132 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystats.h +28 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystrcmp.h +23 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pystrtod.h +37 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pythonrun.h +42 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pythread.h +131 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/pytypedefs.h +30 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/rangeobject.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/refcount.h +555 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/setobject.h +49 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/sliceobject.h +69 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/structmember.h +56 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/structseq.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/sysmodule.h +27 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/traceback.h +26 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/tupleobject.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/typeslots.h +96 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/unicodeobject.h +1029 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/warnings.h +45 -0
- pytron/platforms/android/shell/app/src/main/cpp/include/weakrefobject.h +46 -0
- pytron/platforms/android/shell/app/src/main/cpp/pytron_bridge.cpp +224 -0
- pytron/platforms/android/shell/app/src/main/java/com/pytron/shell/MainActivity.kt +208 -0
- pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- pytron/platforms/android/shell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- pytron/platforms/android/shell/build.gradle +11 -0
- pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.jar +0 -0
- pytron/platforms/android/shell/gradle/wrapper/gradle-wrapper.properties +5 -0
- pytron/platforms/android/shell/gradle.properties +2 -0
- pytron/platforms/android/shell/gradlew.bat +85 -0
- pytron/platforms/android/shell/settings.gradle +16 -0
- pytron/platforms/darwin.py +82 -0
- pytron/platforms/darwin_ops/libs.py +31 -0
- pytron/platforms/darwin_ops/system.py +182 -0
- pytron/platforms/darwin_ops/utils.py +85 -0
- pytron/platforms/darwin_ops/webview.py +5 -0
- pytron/platforms/darwin_ops/window.py +102 -0
- pytron/platforms/interface.py +152 -0
- pytron/platforms/linux.py +82 -0
- pytron/platforms/linux_ops/libs.py +49 -0
- pytron/platforms/linux_ops/system.py +316 -0
- pytron/platforms/linux_ops/utils.py +19 -0
- pytron/platforms/linux_ops/webview.py +5 -0
- pytron/platforms/linux_ops/window.py +115 -0
- pytron/platforms/windows.py +136 -0
- pytron/platforms/windows_ops/__init__.py +0 -0
- pytron/platforms/windows_ops/constants.py +126 -0
- pytron/platforms/windows_ops/system.py +518 -0
- pytron/platforms/windows_ops/utils.py +3 -0
- pytron/platforms/windows_ops/webview.py +5 -0
- pytron/platforms/windows_ops/window.py +361 -0
- pytron/plugin.py +467 -0
- pytron/rcedit-x64.exe +0 -0
- pytron/router.py +146 -0
- pytron/serializer.py +240 -0
- pytron/shortcuts.py +279 -0
- pytron/state.py +76 -0
- pytron/tray.py +399 -0
- pytron/updater.py +181 -0
- pytron/utf8_hook.py +112 -0
- pytron/utils.py +44 -0
- pytron/webview.py +722 -0
- pytron_kit-0.3.12.dist-info/METADATA +131 -0
- pytron_kit-0.3.12.dist-info/RECORD +419 -0
- pytron_kit-0.3.12.dist-info/WHEEL +5 -0
- pytron_kit-0.3.12.dist-info/entry_points.txt +2 -0
- pytron_kit-0.3.12.dist-info/licenses/LICENSE +201 -0
- pytron_kit-0.3.12.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// A doubly-linked list that can be embedded in a struct.
|
|
2
|
+
//
|
|
3
|
+
// Usage:
|
|
4
|
+
// struct llist_node head = LLIST_INIT(head);
|
|
5
|
+
// typedef struct {
|
|
6
|
+
// ...
|
|
7
|
+
// struct llist_node node;
|
|
8
|
+
// ...
|
|
9
|
+
// } MyObj;
|
|
10
|
+
//
|
|
11
|
+
// llist_insert_tail(&head, &obj->node);
|
|
12
|
+
// llist_remove(&obj->node);
|
|
13
|
+
//
|
|
14
|
+
// struct llist_node *node;
|
|
15
|
+
// llist_for_each(node, &head) {
|
|
16
|
+
// MyObj *obj = llist_data(node, MyObj, node);
|
|
17
|
+
// ...
|
|
18
|
+
// }
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
#ifndef Py_INTERNAL_LLIST_H
|
|
22
|
+
#define Py_INTERNAL_LLIST_H
|
|
23
|
+
|
|
24
|
+
#include <stddef.h>
|
|
25
|
+
|
|
26
|
+
#ifdef __cplusplus
|
|
27
|
+
extern "C" {
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#ifndef Py_BUILD_CORE
|
|
31
|
+
# error "Py_BUILD_CORE must be defined to include this header"
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
struct llist_node {
|
|
35
|
+
struct llist_node *next;
|
|
36
|
+
struct llist_node *prev;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Get the struct containing a node.
|
|
40
|
+
#define llist_data(node, type, member) (_Py_CONTAINER_OF(node, type, member))
|
|
41
|
+
|
|
42
|
+
// Iterate over a list.
|
|
43
|
+
#define llist_for_each(node, head) \
|
|
44
|
+
for (node = (head)->next; node != (head); node = node->next)
|
|
45
|
+
|
|
46
|
+
// Iterate over a list, but allow removal of the current node.
|
|
47
|
+
#define llist_for_each_safe(node, head) \
|
|
48
|
+
for (struct llist_node *_next = (node = (head)->next, node->next); \
|
|
49
|
+
node != (head); node = _next, _next = node->next)
|
|
50
|
+
|
|
51
|
+
#define LLIST_INIT(head) { &head, &head }
|
|
52
|
+
|
|
53
|
+
static inline void
|
|
54
|
+
llist_init(struct llist_node *head)
|
|
55
|
+
{
|
|
56
|
+
head->next = head;
|
|
57
|
+
head->prev = head;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Returns 1 if the list is empty, 0 otherwise.
|
|
61
|
+
static inline int
|
|
62
|
+
llist_empty(struct llist_node *head)
|
|
63
|
+
{
|
|
64
|
+
return head->next == head;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Appends to the tail of the list.
|
|
68
|
+
static inline void
|
|
69
|
+
llist_insert_tail(struct llist_node *head, struct llist_node *node)
|
|
70
|
+
{
|
|
71
|
+
node->prev = head->prev;
|
|
72
|
+
node->next = head;
|
|
73
|
+
head->prev->next = node;
|
|
74
|
+
head->prev = node;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Remove a node from the list.
|
|
78
|
+
static inline void
|
|
79
|
+
llist_remove(struct llist_node *node)
|
|
80
|
+
{
|
|
81
|
+
struct llist_node *prev = node->prev;
|
|
82
|
+
struct llist_node *next = node->next;
|
|
83
|
+
prev->next = next;
|
|
84
|
+
next->prev = prev;
|
|
85
|
+
node->prev = NULL;
|
|
86
|
+
node->next = NULL;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Append all nodes from head2 onto head1. head2 is left empty.
|
|
90
|
+
static inline void
|
|
91
|
+
llist_concat(struct llist_node *head1, struct llist_node *head2)
|
|
92
|
+
{
|
|
93
|
+
if (!llist_empty(head2)) {
|
|
94
|
+
head1->prev->next = head2->next;
|
|
95
|
+
head2->next->prev = head1->prev;
|
|
96
|
+
|
|
97
|
+
head1->prev = head2->prev;
|
|
98
|
+
head2->prev->next = head1;
|
|
99
|
+
llist_init(head2);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
#ifdef __cplusplus
|
|
104
|
+
}
|
|
105
|
+
#endif
|
|
106
|
+
#endif /* !Py_INTERNAL_LLIST_H */
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// Lightweight locks and other synchronization mechanisms.
|
|
2
|
+
//
|
|
3
|
+
// These implementations are based on WebKit's WTF::Lock. See
|
|
4
|
+
// https://webkit.org/blog/6161/locking-in-webkit/ for a description of the
|
|
5
|
+
// design.
|
|
6
|
+
#ifndef Py_INTERNAL_LOCK_H
|
|
7
|
+
#define Py_INTERNAL_LOCK_H
|
|
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
|
+
//_Py_UNLOCKED is defined as 0 and _Py_LOCKED as 1 in Include/cpython/lock.h
|
|
17
|
+
#define _Py_HAS_PARKED 2
|
|
18
|
+
#define _Py_ONCE_INITIALIZED 4
|
|
19
|
+
|
|
20
|
+
static inline int
|
|
21
|
+
PyMutex_LockFast(PyMutex *m)
|
|
22
|
+
{
|
|
23
|
+
uint8_t expected = _Py_UNLOCKED;
|
|
24
|
+
uint8_t *lock_bits = &m->_bits;
|
|
25
|
+
return _Py_atomic_compare_exchange_uint8(lock_bits, &expected, _Py_LOCKED);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Re-initializes the mutex after a fork to the unlocked state.
|
|
29
|
+
static inline void
|
|
30
|
+
_PyMutex_at_fork_reinit(PyMutex *m)
|
|
31
|
+
{
|
|
32
|
+
memset(m, 0, sizeof(*m));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
typedef enum _PyLockFlags {
|
|
36
|
+
// Do not detach/release the GIL when waiting on the lock.
|
|
37
|
+
_Py_LOCK_DONT_DETACH = 0,
|
|
38
|
+
|
|
39
|
+
// Detach/release the GIL while waiting on the lock.
|
|
40
|
+
_PY_LOCK_DETACH = 1,
|
|
41
|
+
|
|
42
|
+
// Handle signals if interrupted while waiting on the lock.
|
|
43
|
+
_PY_LOCK_HANDLE_SIGNALS = 2,
|
|
44
|
+
} _PyLockFlags;
|
|
45
|
+
|
|
46
|
+
// Lock a mutex with an optional timeout and additional options. See
|
|
47
|
+
// _PyLockFlags for details.
|
|
48
|
+
extern PyAPI_FUNC(PyLockStatus)
|
|
49
|
+
_PyMutex_LockTimed(PyMutex *m, PyTime_t timeout_ns, _PyLockFlags flags);
|
|
50
|
+
|
|
51
|
+
// Lock a mutex with additional options. See _PyLockFlags for details.
|
|
52
|
+
static inline void
|
|
53
|
+
PyMutex_LockFlags(PyMutex *m, _PyLockFlags flags)
|
|
54
|
+
{
|
|
55
|
+
uint8_t expected = _Py_UNLOCKED;
|
|
56
|
+
if (!_Py_atomic_compare_exchange_uint8(&m->_bits, &expected, _Py_LOCKED)) {
|
|
57
|
+
_PyMutex_LockTimed(m, -1, flags);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Unlock a mutex, returns -1 if the mutex is not locked (used for improved
|
|
62
|
+
// error messages) otherwise returns 0.
|
|
63
|
+
extern int _PyMutex_TryUnlock(PyMutex *m);
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// PyEvent is a one-time event notification
|
|
67
|
+
typedef struct {
|
|
68
|
+
uint8_t v;
|
|
69
|
+
} PyEvent;
|
|
70
|
+
|
|
71
|
+
// Check if the event is set without blocking. Returns 1 if the event is set or
|
|
72
|
+
// 0 otherwise.
|
|
73
|
+
PyAPI_FUNC(int) _PyEvent_IsSet(PyEvent *evt);
|
|
74
|
+
|
|
75
|
+
// Set the event and notify any waiting threads.
|
|
76
|
+
// Export for '_testinternalcapi' shared extension
|
|
77
|
+
PyAPI_FUNC(void) _PyEvent_Notify(PyEvent *evt);
|
|
78
|
+
|
|
79
|
+
// Wait for the event to be set. If the event is already set, then this returns
|
|
80
|
+
// immediately.
|
|
81
|
+
PyAPI_FUNC(void) PyEvent_Wait(PyEvent *evt);
|
|
82
|
+
|
|
83
|
+
// Wait for the event to be set, or until the timeout expires. If the event is
|
|
84
|
+
// already set, then this returns immediately. Returns 1 if the event was set,
|
|
85
|
+
// and 0 if the timeout expired or thread was interrupted. If `detach` is
|
|
86
|
+
// true, then the thread will detach/release the GIL while waiting.
|
|
87
|
+
PyAPI_FUNC(int)
|
|
88
|
+
PyEvent_WaitTimed(PyEvent *evt, PyTime_t timeout_ns, int detach);
|
|
89
|
+
|
|
90
|
+
// _PyRawMutex implements a word-sized mutex that that does not depend on the
|
|
91
|
+
// parking lot API, and therefore can be used in the parking lot
|
|
92
|
+
// implementation.
|
|
93
|
+
//
|
|
94
|
+
// The mutex uses a packed representation: the least significant bit is used to
|
|
95
|
+
// indicate whether the mutex is locked or not. The remaining bits are either
|
|
96
|
+
// zero or a pointer to a `struct raw_mutex_entry` (see lock.c).
|
|
97
|
+
typedef struct {
|
|
98
|
+
uintptr_t v;
|
|
99
|
+
} _PyRawMutex;
|
|
100
|
+
|
|
101
|
+
// Slow paths for lock/unlock
|
|
102
|
+
extern void _PyRawMutex_LockSlow(_PyRawMutex *m);
|
|
103
|
+
extern void _PyRawMutex_UnlockSlow(_PyRawMutex *m);
|
|
104
|
+
|
|
105
|
+
static inline void
|
|
106
|
+
_PyRawMutex_Lock(_PyRawMutex *m)
|
|
107
|
+
{
|
|
108
|
+
uintptr_t unlocked = _Py_UNLOCKED;
|
|
109
|
+
if (_Py_atomic_compare_exchange_uintptr(&m->v, &unlocked, _Py_LOCKED)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
_PyRawMutex_LockSlow(m);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static inline void
|
|
116
|
+
_PyRawMutex_Unlock(_PyRawMutex *m)
|
|
117
|
+
{
|
|
118
|
+
uintptr_t locked = _Py_LOCKED;
|
|
119
|
+
if (_Py_atomic_compare_exchange_uintptr(&m->v, &locked, _Py_UNLOCKED)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
_PyRawMutex_UnlockSlow(m);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Type signature for one-time initialization functions. The function should
|
|
126
|
+
// return 0 on success and -1 on failure.
|
|
127
|
+
typedef int _Py_once_fn_t(void *arg);
|
|
128
|
+
|
|
129
|
+
// (private) slow path for one time initialization
|
|
130
|
+
PyAPI_FUNC(int)
|
|
131
|
+
_PyOnceFlag_CallOnceSlow(_PyOnceFlag *flag, _Py_once_fn_t *fn, void *arg);
|
|
132
|
+
|
|
133
|
+
// Calls `fn` once using `flag`. The `arg` is passed to the call to `fn`.
|
|
134
|
+
//
|
|
135
|
+
// Returns 0 on success and -1 on failure.
|
|
136
|
+
//
|
|
137
|
+
// If `fn` returns 0 (success), then subsequent calls immediately return 0.
|
|
138
|
+
// If `fn` returns -1 (failure), then subsequent calls will retry the call.
|
|
139
|
+
static inline int
|
|
140
|
+
_PyOnceFlag_CallOnce(_PyOnceFlag *flag, _Py_once_fn_t *fn, void *arg)
|
|
141
|
+
{
|
|
142
|
+
if (_Py_atomic_load_uint8(&flag->v) == _Py_ONCE_INITIALIZED) {
|
|
143
|
+
return 0;
|
|
144
|
+
}
|
|
145
|
+
return _PyOnceFlag_CallOnceSlow(flag, fn, arg);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// A recursive mutex. The mutex should zero-initialized.
|
|
149
|
+
typedef struct {
|
|
150
|
+
PyMutex mutex;
|
|
151
|
+
unsigned long long thread; // i.e., PyThread_get_thread_ident_ex()
|
|
152
|
+
size_t level;
|
|
153
|
+
} _PyRecursiveMutex;
|
|
154
|
+
|
|
155
|
+
PyAPI_FUNC(int) _PyRecursiveMutex_IsLockedByCurrentThread(_PyRecursiveMutex *m);
|
|
156
|
+
PyAPI_FUNC(void) _PyRecursiveMutex_Lock(_PyRecursiveMutex *m);
|
|
157
|
+
extern PyLockStatus _PyRecursiveMutex_LockTimed(_PyRecursiveMutex *m, PyTime_t timeout, _PyLockFlags flags);
|
|
158
|
+
PyAPI_FUNC(void) _PyRecursiveMutex_Unlock(_PyRecursiveMutex *m);
|
|
159
|
+
extern int _PyRecursiveMutex_TryUnlock(_PyRecursiveMutex *m);
|
|
160
|
+
|
|
161
|
+
// A readers-writer (RW) lock. The lock supports multiple concurrent readers or
|
|
162
|
+
// a single writer. The lock is write-preferring: if a writer is waiting while
|
|
163
|
+
// the lock is read-locked then, new readers will be blocked. This avoids
|
|
164
|
+
// starvation of writers.
|
|
165
|
+
//
|
|
166
|
+
// In C++, the equivalent synchronization primitive is std::shared_mutex
|
|
167
|
+
// with shared ("read") and exclusive ("write") locking.
|
|
168
|
+
//
|
|
169
|
+
// The two least significant bits are used to indicate if the lock is
|
|
170
|
+
// write-locked and if there are parked threads (either readers or writers)
|
|
171
|
+
// waiting to acquire the lock. The remaining bits are used to indicate the
|
|
172
|
+
// number of readers holding the lock.
|
|
173
|
+
//
|
|
174
|
+
// 0b000..00000: unlocked
|
|
175
|
+
// 0bnnn..nnn00: nnn..nnn readers holding the lock
|
|
176
|
+
// 0bnnn..nnn10: nnn..nnn readers holding the lock and a writer is waiting
|
|
177
|
+
// 0b00000..010: unlocked with awoken writer about to acquire lock
|
|
178
|
+
// 0b00000..001: write-locked
|
|
179
|
+
// 0b00000..011: write-locked and readers or other writers are waiting
|
|
180
|
+
//
|
|
181
|
+
// Note that reader_count must be zero if the lock is held by a writer, and
|
|
182
|
+
// vice versa. The lock can only be held by readers or a writer, but not both.
|
|
183
|
+
//
|
|
184
|
+
// The design is optimized for simplicity of the implementation. The lock is
|
|
185
|
+
// not fair: if fairness is desired, use an additional PyMutex to serialize
|
|
186
|
+
// writers. The lock is also not reentrant.
|
|
187
|
+
typedef struct {
|
|
188
|
+
uintptr_t bits;
|
|
189
|
+
} _PyRWMutex;
|
|
190
|
+
|
|
191
|
+
// Read lock (i.e., shared lock)
|
|
192
|
+
PyAPI_FUNC(void) _PyRWMutex_RLock(_PyRWMutex *rwmutex);
|
|
193
|
+
PyAPI_FUNC(void) _PyRWMutex_RUnlock(_PyRWMutex *rwmutex);
|
|
194
|
+
|
|
195
|
+
// Write lock (i.e., exclusive lock)
|
|
196
|
+
PyAPI_FUNC(void) _PyRWMutex_Lock(_PyRWMutex *rwmutex);
|
|
197
|
+
PyAPI_FUNC(void) _PyRWMutex_Unlock(_PyRWMutex *rwmutex);
|
|
198
|
+
|
|
199
|
+
// Similar to linux seqlock: https://en.wikipedia.org/wiki/Seqlock
|
|
200
|
+
// We use a sequence number to lock the writer, an even sequence means we're unlocked, an odd
|
|
201
|
+
// sequence means we're locked. Readers will read the sequence before attempting to read the
|
|
202
|
+
// underlying data and then read the sequence number again after reading the data. If the
|
|
203
|
+
// sequence has not changed the data is valid.
|
|
204
|
+
//
|
|
205
|
+
// Differs a little bit in that we use CAS on sequence as the lock, instead of a separate spin lock.
|
|
206
|
+
// The writer can also detect that the undelering data has not changed and abandon the write
|
|
207
|
+
// and restore the previous sequence.
|
|
208
|
+
typedef struct {
|
|
209
|
+
uint32_t sequence;
|
|
210
|
+
} _PySeqLock;
|
|
211
|
+
|
|
212
|
+
// Lock the sequence lock for the writer
|
|
213
|
+
PyAPI_FUNC(void) _PySeqLock_LockWrite(_PySeqLock *seqlock);
|
|
214
|
+
|
|
215
|
+
// Unlock the sequence lock and move to the next sequence number.
|
|
216
|
+
PyAPI_FUNC(void) _PySeqLock_UnlockWrite(_PySeqLock *seqlock);
|
|
217
|
+
|
|
218
|
+
// Abandon the current update indicating that no mutations have occurred
|
|
219
|
+
// and restore the previous sequence value.
|
|
220
|
+
PyAPI_FUNC(void) _PySeqLock_AbandonWrite(_PySeqLock *seqlock);
|
|
221
|
+
|
|
222
|
+
// Begin a read operation and return the current sequence number.
|
|
223
|
+
PyAPI_FUNC(uint32_t) _PySeqLock_BeginRead(_PySeqLock *seqlock);
|
|
224
|
+
|
|
225
|
+
// End the read operation and confirm that the sequence number has not changed.
|
|
226
|
+
// Returns 1 if the read was successful or 0 if the read should be retried.
|
|
227
|
+
PyAPI_FUNC(int) _PySeqLock_EndRead(_PySeqLock *seqlock, uint32_t previous);
|
|
228
|
+
|
|
229
|
+
// Check if the lock was held during a fork and clear the lock. Returns 1
|
|
230
|
+
// if the lock was held and any associated data should be cleared.
|
|
231
|
+
PyAPI_FUNC(int) _PySeqLock_AfterFork(_PySeqLock *seqlock);
|
|
232
|
+
|
|
233
|
+
#ifdef __cplusplus
|
|
234
|
+
}
|
|
235
|
+
#endif
|
|
236
|
+
#endif /* !Py_INTERNAL_LOCK_H */
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
#ifndef Py_INTERNAL_LONG_H
|
|
2
|
+
#define Py_INTERNAL_LONG_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_bytesobject.h" // _PyBytesWriter
|
|
12
|
+
#include "pycore_runtime.h" // _Py_SINGLETON()
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Default int base conversion size limitation: Denial of Service prevention.
|
|
16
|
+
*
|
|
17
|
+
* Chosen such that this isn't wildly slow on modern hardware and so that
|
|
18
|
+
* everyone's existing deployed numpy test suite passes before
|
|
19
|
+
* https://github.com/numpy/numpy/issues/22098 is widely available.
|
|
20
|
+
*
|
|
21
|
+
* $ python -m timeit -s 's = "1"*4300' 'int(s)'
|
|
22
|
+
* 2000 loops, best of 5: 125 usec per loop
|
|
23
|
+
* $ python -m timeit -s 's = "1"*4300; v = int(s)' 'str(v)'
|
|
24
|
+
* 1000 loops, best of 5: 311 usec per loop
|
|
25
|
+
* (zen2 cloud VM)
|
|
26
|
+
*
|
|
27
|
+
* 4300 decimal digits fits a ~14284 bit number.
|
|
28
|
+
*/
|
|
29
|
+
#define _PY_LONG_DEFAULT_MAX_STR_DIGITS 4300
|
|
30
|
+
/*
|
|
31
|
+
* Threshold for max digits check. For performance reasons int() and
|
|
32
|
+
* int.__str__() don't checks values that are smaller than this
|
|
33
|
+
* threshold. Acts as a guaranteed minimum size limit for bignums that
|
|
34
|
+
* applications can expect from CPython.
|
|
35
|
+
*
|
|
36
|
+
* % python -m timeit -s 's = "1"*640; v = int(s)' 'str(int(s))'
|
|
37
|
+
* 20000 loops, best of 5: 12 usec per loop
|
|
38
|
+
*
|
|
39
|
+
* "640 digits should be enough for anyone." - gps
|
|
40
|
+
* fits a ~2126 bit decimal number.
|
|
41
|
+
*/
|
|
42
|
+
#define _PY_LONG_MAX_STR_DIGITS_THRESHOLD 640
|
|
43
|
+
|
|
44
|
+
#if ((_PY_LONG_DEFAULT_MAX_STR_DIGITS != 0) && \
|
|
45
|
+
(_PY_LONG_DEFAULT_MAX_STR_DIGITS < _PY_LONG_MAX_STR_DIGITS_THRESHOLD))
|
|
46
|
+
# error "_PY_LONG_DEFAULT_MAX_STR_DIGITS smaller than threshold."
|
|
47
|
+
#endif
|
|
48
|
+
|
|
49
|
+
/* runtime lifecycle */
|
|
50
|
+
|
|
51
|
+
extern PyStatus _PyLong_InitTypes(PyInterpreterState *);
|
|
52
|
+
extern void _PyLong_FiniTypes(PyInterpreterState *interp);
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
/* other API */
|
|
56
|
+
|
|
57
|
+
PyAPI_FUNC(void) _PyLong_ExactDealloc(PyObject *self);
|
|
58
|
+
|
|
59
|
+
#define _PyLong_SMALL_INTS _Py_SINGLETON(small_ints)
|
|
60
|
+
|
|
61
|
+
// _PyLong_GetZero() and _PyLong_GetOne() must always be available
|
|
62
|
+
// _PyLong_FromUnsignedChar must always be available
|
|
63
|
+
#if _PY_NSMALLPOSINTS < 257
|
|
64
|
+
# error "_PY_NSMALLPOSINTS must be greater than or equal to 257"
|
|
65
|
+
#endif
|
|
66
|
+
|
|
67
|
+
#define _PY_IS_SMALL_INT(val) ((val) >= 0 && (val) < 256 && (val) < _PY_NSMALLPOSINTS)
|
|
68
|
+
|
|
69
|
+
// Return a reference to the immortal zero singleton.
|
|
70
|
+
// The function cannot return NULL.
|
|
71
|
+
static inline PyObject* _PyLong_GetZero(void)
|
|
72
|
+
{ return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS]; }
|
|
73
|
+
|
|
74
|
+
// Return a reference to the immortal one singleton.
|
|
75
|
+
// The function cannot return NULL.
|
|
76
|
+
static inline PyObject* _PyLong_GetOne(void)
|
|
77
|
+
{ return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS+1]; }
|
|
78
|
+
|
|
79
|
+
static inline PyObject* _PyLong_FromUnsignedChar(unsigned char i)
|
|
80
|
+
{
|
|
81
|
+
return (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS+i];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// _PyLong_Frexp returns a double x and an exponent e such that the
|
|
85
|
+
// true value is approximately equal to x * 2**e. x is
|
|
86
|
+
// 0.0 if and only if the input is 0 (in which case, e and x are both
|
|
87
|
+
// zeroes); otherwise, 0.5 <= abs(x) < 1.0.
|
|
88
|
+
// Always successful.
|
|
89
|
+
//
|
|
90
|
+
// Export for 'math' shared extension
|
|
91
|
+
PyAPI_DATA(double) _PyLong_Frexp(PyLongObject *a, int64_t *e);
|
|
92
|
+
|
|
93
|
+
extern PyObject* _PyLong_FromBytes(const char *, Py_ssize_t, int);
|
|
94
|
+
|
|
95
|
+
// _PyLong_DivmodNear. Given integers a and b, compute the nearest
|
|
96
|
+
// integer q to the exact quotient a / b, rounding to the nearest even integer
|
|
97
|
+
// in the case of a tie. Return (q, r), where r = a - q*b. The remainder r
|
|
98
|
+
// will satisfy abs(r) <= abs(b)/2, with equality possible only if q is
|
|
99
|
+
// even.
|
|
100
|
+
//
|
|
101
|
+
// Export for '_datetime' shared extension.
|
|
102
|
+
PyAPI_DATA(PyObject*) _PyLong_DivmodNear(PyObject *, PyObject *);
|
|
103
|
+
|
|
104
|
+
// _PyLong_Format: Convert the long to a string object with given base,
|
|
105
|
+
// appending a base prefix of 0[box] if base is 2, 8 or 16.
|
|
106
|
+
// Export for '_tkinter' shared extension.
|
|
107
|
+
PyAPI_DATA(PyObject*) _PyLong_Format(PyObject *obj, int base);
|
|
108
|
+
|
|
109
|
+
// Export for 'math' shared extension
|
|
110
|
+
PyAPI_DATA(PyObject*) _PyLong_Rshift(PyObject *, int64_t);
|
|
111
|
+
|
|
112
|
+
// Export for 'math' shared extension
|
|
113
|
+
PyAPI_DATA(PyObject*) _PyLong_Lshift(PyObject *, int64_t);
|
|
114
|
+
|
|
115
|
+
PyAPI_FUNC(PyObject*) _PyLong_Add(PyLongObject *left, PyLongObject *right);
|
|
116
|
+
PyAPI_FUNC(PyObject*) _PyLong_Multiply(PyLongObject *left, PyLongObject *right);
|
|
117
|
+
PyAPI_FUNC(PyObject*) _PyLong_Subtract(PyLongObject *left, PyLongObject *right);
|
|
118
|
+
|
|
119
|
+
// Export for 'binascii' shared extension.
|
|
120
|
+
PyAPI_DATA(unsigned char) _PyLong_DigitValue[256];
|
|
121
|
+
|
|
122
|
+
/* Format the object based on the format_spec, as defined in PEP 3101
|
|
123
|
+
(Advanced String Formatting). */
|
|
124
|
+
extern int _PyLong_FormatAdvancedWriter(
|
|
125
|
+
_PyUnicodeWriter *writer,
|
|
126
|
+
PyObject *obj,
|
|
127
|
+
PyObject *format_spec,
|
|
128
|
+
Py_ssize_t start,
|
|
129
|
+
Py_ssize_t end);
|
|
130
|
+
|
|
131
|
+
extern int _PyLong_FormatWriter(
|
|
132
|
+
_PyUnicodeWriter *writer,
|
|
133
|
+
PyObject *obj,
|
|
134
|
+
int base,
|
|
135
|
+
int alternate);
|
|
136
|
+
|
|
137
|
+
extern char* _PyLong_FormatBytesWriter(
|
|
138
|
+
_PyBytesWriter *writer,
|
|
139
|
+
char *str,
|
|
140
|
+
PyObject *obj,
|
|
141
|
+
int base,
|
|
142
|
+
int alternate);
|
|
143
|
+
|
|
144
|
+
// Argument converters used by Argument Clinic
|
|
145
|
+
|
|
146
|
+
// Export for 'select' shared extension (Argument Clinic code)
|
|
147
|
+
PyAPI_FUNC(int) _PyLong_UnsignedShort_Converter(PyObject *, void *);
|
|
148
|
+
|
|
149
|
+
// Export for '_testclinic' shared extension (Argument Clinic code)
|
|
150
|
+
PyAPI_FUNC(int) _PyLong_UnsignedInt_Converter(PyObject *, void *);
|
|
151
|
+
|
|
152
|
+
// Export for '_blake2' shared extension (Argument Clinic code)
|
|
153
|
+
PyAPI_FUNC(int) _PyLong_UnsignedLong_Converter(PyObject *, void *);
|
|
154
|
+
|
|
155
|
+
// Export for '_blake2' shared extension (Argument Clinic code)
|
|
156
|
+
PyAPI_FUNC(int) _PyLong_UnsignedLongLong_Converter(PyObject *, void *);
|
|
157
|
+
|
|
158
|
+
// Export for '_testclinic' shared extension (Argument Clinic code)
|
|
159
|
+
PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *);
|
|
160
|
+
|
|
161
|
+
PyAPI_FUNC(int) _PyLong_UInt8_Converter(PyObject *, void *);
|
|
162
|
+
PyAPI_FUNC(int) _PyLong_UInt16_Converter(PyObject *, void *);
|
|
163
|
+
PyAPI_FUNC(int) _PyLong_UInt32_Converter(PyObject *, void *);
|
|
164
|
+
PyAPI_FUNC(int) _PyLong_UInt64_Converter(PyObject *, void *);
|
|
165
|
+
|
|
166
|
+
/* Long value tag bits:
|
|
167
|
+
* 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
|
|
168
|
+
* 2: Set to 1 for the small ints
|
|
169
|
+
* 3+ Unsigned digit count
|
|
170
|
+
*/
|
|
171
|
+
#define SIGN_MASK 3
|
|
172
|
+
#define SIGN_ZERO 1
|
|
173
|
+
#define SIGN_NEGATIVE 2
|
|
174
|
+
#define NON_SIZE_BITS 3
|
|
175
|
+
#define IMMORTALITY_BIT_MASK (1 << 2)
|
|
176
|
+
|
|
177
|
+
/* The functions _PyLong_IsCompact and _PyLong_CompactValue are defined
|
|
178
|
+
* in Include/cpython/longobject.h, since they need to be inline.
|
|
179
|
+
*
|
|
180
|
+
* "Compact" values have at least one bit to spare,
|
|
181
|
+
* so that addition and subtraction can be performed on the values
|
|
182
|
+
* without risk of overflow.
|
|
183
|
+
*
|
|
184
|
+
* The inline functions need tag bits.
|
|
185
|
+
* For readability, rather than do `#define SIGN_MASK _PyLong_SIGN_MASK`
|
|
186
|
+
* we define them to the numbers in both places and then assert that
|
|
187
|
+
* they're the same.
|
|
188
|
+
*/
|
|
189
|
+
#if SIGN_MASK != _PyLong_SIGN_MASK
|
|
190
|
+
# error "SIGN_MASK does not match _PyLong_SIGN_MASK"
|
|
191
|
+
#endif
|
|
192
|
+
#if NON_SIZE_BITS != _PyLong_NON_SIZE_BITS
|
|
193
|
+
# error "NON_SIZE_BITS does not match _PyLong_NON_SIZE_BITS"
|
|
194
|
+
#endif
|
|
195
|
+
|
|
196
|
+
/* All *compact" values are guaranteed to fit into
|
|
197
|
+
* a Py_ssize_t with at least one bit to spare.
|
|
198
|
+
* In other words, for 64 bit machines, compact
|
|
199
|
+
* will be signed 63 (or fewer) bit values
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
/* Return 1 if the argument is compact int */
|
|
203
|
+
static inline int
|
|
204
|
+
_PyLong_IsNonNegativeCompact(const PyLongObject* op) {
|
|
205
|
+
assert(PyLong_Check(op));
|
|
206
|
+
return ((op->long_value.lv_tag & ~IMMORTALITY_BIT_MASK) <= (1 << NON_SIZE_BITS));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
static inline int
|
|
211
|
+
_PyLong_BothAreCompact(const PyLongObject* a, const PyLongObject* b) {
|
|
212
|
+
assert(PyLong_Check(a));
|
|
213
|
+
assert(PyLong_Check(b));
|
|
214
|
+
return (a->long_value.lv_tag | b->long_value.lv_tag) < (2 << NON_SIZE_BITS);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
static inline bool
|
|
218
|
+
_PyLong_IsZero(const PyLongObject *op)
|
|
219
|
+
{
|
|
220
|
+
return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
static inline bool
|
|
224
|
+
_PyLong_IsNegative(const PyLongObject *op)
|
|
225
|
+
{
|
|
226
|
+
return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
static inline bool
|
|
230
|
+
_PyLong_IsPositive(const PyLongObject *op)
|
|
231
|
+
{
|
|
232
|
+
return (op->long_value.lv_tag & SIGN_MASK) == 0;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
static inline Py_ssize_t
|
|
236
|
+
_PyLong_DigitCount(const PyLongObject *op)
|
|
237
|
+
{
|
|
238
|
+
assert(PyLong_Check(op));
|
|
239
|
+
return (Py_ssize_t)(op->long_value.lv_tag >> NON_SIZE_BITS);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* Equivalent to _PyLong_DigitCount(op) * _PyLong_NonCompactSign(op) */
|
|
243
|
+
static inline Py_ssize_t
|
|
244
|
+
_PyLong_SignedDigitCount(const PyLongObject *op)
|
|
245
|
+
{
|
|
246
|
+
assert(PyLong_Check(op));
|
|
247
|
+
Py_ssize_t sign = 1 - (op->long_value.lv_tag & SIGN_MASK);
|
|
248
|
+
return sign * (Py_ssize_t)(op->long_value.lv_tag >> NON_SIZE_BITS);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
static inline int
|
|
252
|
+
_PyLong_CompactSign(const PyLongObject *op)
|
|
253
|
+
{
|
|
254
|
+
assert(PyLong_Check(op));
|
|
255
|
+
assert(_PyLong_IsCompact((PyLongObject *)op));
|
|
256
|
+
return 1 - (op->long_value.lv_tag & SIGN_MASK);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
static inline int
|
|
260
|
+
_PyLong_NonCompactSign(const PyLongObject *op)
|
|
261
|
+
{
|
|
262
|
+
assert(PyLong_Check(op));
|
|
263
|
+
assert(!_PyLong_IsCompact((PyLongObject *)op));
|
|
264
|
+
return 1 - (op->long_value.lv_tag & SIGN_MASK);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/* Do a and b have the same sign? */
|
|
268
|
+
static inline int
|
|
269
|
+
_PyLong_SameSign(const PyLongObject *a, const PyLongObject *b)
|
|
270
|
+
{
|
|
271
|
+
return (a->long_value.lv_tag & SIGN_MASK) == (b->long_value.lv_tag & SIGN_MASK);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
#define TAG_FROM_SIGN_AND_SIZE(sign, size) \
|
|
275
|
+
((uintptr_t)(1 - (sign)) | ((uintptr_t)(size) << NON_SIZE_BITS))
|
|
276
|
+
|
|
277
|
+
static inline void
|
|
278
|
+
_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
|
|
279
|
+
{
|
|
280
|
+
assert(size >= 0);
|
|
281
|
+
assert(-1 <= sign && sign <= 1);
|
|
282
|
+
assert(sign != 0 || size == 0);
|
|
283
|
+
op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, size);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
static inline void
|
|
287
|
+
_PyLong_SetDigitCount(PyLongObject *op, Py_ssize_t size)
|
|
288
|
+
{
|
|
289
|
+
assert(size >= 0);
|
|
290
|
+
op->long_value.lv_tag = (((size_t)size) << NON_SIZE_BITS) | (op->long_value.lv_tag & SIGN_MASK);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
#define NON_SIZE_MASK ~(uintptr_t)((1 << NON_SIZE_BITS) - 1)
|
|
294
|
+
|
|
295
|
+
static inline void
|
|
296
|
+
_PyLong_FlipSign(PyLongObject *op) {
|
|
297
|
+
unsigned int flipped_sign = 2 - (op->long_value.lv_tag & SIGN_MASK);
|
|
298
|
+
op->long_value.lv_tag &= NON_SIZE_MASK;
|
|
299
|
+
op->long_value.lv_tag |= flipped_sign;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
#define _PyLong_DIGIT_INIT(val) \
|
|
303
|
+
{ \
|
|
304
|
+
.ob_base = _PyObject_HEAD_INIT(&PyLong_Type), \
|
|
305
|
+
.long_value = { \
|
|
306
|
+
.lv_tag = TAG_FROM_SIGN_AND_SIZE( \
|
|
307
|
+
(val) == 0 ? 0 : ((val) < 0 ? -1 : 1), \
|
|
308
|
+
(val) == 0 ? 0 : 1) | IMMORTALITY_BIT_MASK, \
|
|
309
|
+
{ ((val) >= 0 ? (val) : -(val)) }, \
|
|
310
|
+
} \
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
#define _PyLong_FALSE_TAG TAG_FROM_SIGN_AND_SIZE(0, 0)
|
|
314
|
+
#define _PyLong_TRUE_TAG TAG_FROM_SIGN_AND_SIZE(1, 1)
|
|
315
|
+
|
|
316
|
+
#ifdef __cplusplus
|
|
317
|
+
}
|
|
318
|
+
#endif
|
|
319
|
+
#endif /* !Py_INTERNAL_LONG_H */
|