@pairling/runtime-darwin-arm64 0.2.0 → 0.2.2
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.
- package/README.md +1 -1
- package/bin/pairling-connectd +0 -0
- package/manifest.json +4 -4
- package/package.json +3 -3
- package/python/bin/python3 +0 -0
- package/python/bin/python3.12 +0 -0
- package/python/lib/libpython3.12.dylib +0 -0
- package/python/lib/python3.12/__pycache__/__future__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/_compression.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/_weakrefset.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/base64.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/bisect.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/bz2.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/calendar.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/contextlib.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/copyreg.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/datetime.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/enum.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/fnmatch.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/functools.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/hashlib.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/hmac.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/ipaddress.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/keyword.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/locale.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/lzma.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/operator.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/plistlib.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/pty.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/quopri.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/random.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/reprlib.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/selectors.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/shutil.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/signal.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/socket.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/ssl.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/string.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/struct.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/subprocess.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/tempfile.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/threading.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/tty.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/types.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/typing.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/warnings.cpython-312.pyc +0 -0
- package/python/lib/python3.12/__pycache__/weakref.cpython-312.pyc +0 -0
- package/python/lib/python3.12/collections/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/collections/__pycache__/abc.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/_encoded_words.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/_parseaddr.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/_policybase.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/base64mime.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/charset.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/encoders.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/errors.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/feedparser.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/header.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/iterators.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/message.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/parser.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/quoprimime.cpython-312.pyc +0 -0
- package/python/lib/python3.12/email/__pycache__/utils.cpython-312.pyc +0 -0
- package/python/lib/python3.12/encodings/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/encodings/__pycache__/aliases.cpython-312.pyc +0 -0
- package/python/lib/python3.12/encodings/__pycache__/utf_8.cpython-312.pyc +0 -0
- package/python/lib/python3.12/http/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/http/__pycache__/client.cpython-312.pyc +0 -0
- package/python/lib/python3.12/json/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/json/__pycache__/decoder.cpython-312.pyc +0 -0
- package/python/lib/python3.12/json/__pycache__/encoder.cpython-312.pyc +0 -0
- package/python/lib/python3.12/json/__pycache__/scanner.cpython-312.pyc +0 -0
- package/python/lib/python3.12/lib-dynload/_crypt.cpython-312-darwin.so +0 -0
- package/python/lib/python3.12/lib-dynload/_dbm.cpython-312-darwin.so +0 -0
- package/python/lib/python3.12/re/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/re/__pycache__/_casefix.cpython-312.pyc +0 -0
- package/python/lib/python3.12/re/__pycache__/_compiler.cpython-312.pyc +0 -0
- package/python/lib/python3.12/re/__pycache__/_constants.cpython-312.pyc +0 -0
- package/python/lib/python3.12/re/__pycache__/_parser.cpython-312.pyc +0 -0
- package/python/lib/python3.12/site-packages/_cffi_backend.cpython-312-darwin.so +0 -0
- package/python/lib/python3.12/site-packages/cffi/__init__.py +14 -0
- package/python/lib/python3.12/site-packages/cffi/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/site-packages/cffi/__pycache__/api.cpython-312.pyc +0 -0
- package/python/lib/python3.12/site-packages/cffi/__pycache__/error.cpython-312.pyc +0 -0
- package/python/lib/python3.12/site-packages/cffi/__pycache__/lock.cpython-312.pyc +0 -0
- package/python/lib/python3.12/site-packages/cffi/__pycache__/model.cpython-312.pyc +0 -0
- package/python/lib/python3.12/site-packages/cffi/_cffi_errors.h +149 -0
- package/python/lib/python3.12/site-packages/cffi/_cffi_include.h +389 -0
- package/python/lib/python3.12/site-packages/cffi/_embedding.h +550 -0
- package/python/lib/python3.12/site-packages/cffi/_imp_emulation.py +83 -0
- package/python/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py +45 -0
- package/python/lib/python3.12/site-packages/cffi/api.py +967 -0
- package/python/lib/python3.12/site-packages/cffi/backend_ctypes.py +1121 -0
- package/python/lib/python3.12/site-packages/cffi/cffi_opcode.py +187 -0
- package/python/lib/python3.12/site-packages/cffi/commontypes.py +82 -0
- package/python/lib/python3.12/site-packages/cffi/cparser.py +1015 -0
- package/python/lib/python3.12/site-packages/cffi/error.py +31 -0
- package/python/lib/python3.12/site-packages/cffi/ffiplatform.py +113 -0
- package/python/lib/python3.12/site-packages/cffi/lock.py +30 -0
- package/python/lib/python3.12/site-packages/cffi/model.py +618 -0
- package/python/lib/python3.12/site-packages/cffi/parse_c_type.h +181 -0
- package/python/lib/python3.12/site-packages/cffi/pkgconfig.py +121 -0
- package/python/lib/python3.12/site-packages/cffi/recompiler.py +1598 -0
- package/python/lib/python3.12/site-packages/cffi/setuptools_ext.py +229 -0
- package/python/lib/python3.12/site-packages/cffi/vengine_cpy.py +1087 -0
- package/python/lib/python3.12/site-packages/cffi/vengine_gen.py +679 -0
- package/python/lib/python3.12/site-packages/cffi/verifier.py +306 -0
- package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/INSTALLER +1 -0
- package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/METADATA +68 -0
- package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/RECORD +31 -0
- package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/WHEEL +6 -0
- package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/entry_points.txt +2 -0
- package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/licenses/AUTHORS +8 -0
- package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/licenses/LICENSE +23 -0
- package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/top_level.txt +2 -0
- package/python/lib/python3.12/site-packages/cryptography/__about__.py +17 -0
- package/python/lib/python3.12/site-packages/cryptography/__init__.py +26 -0
- package/python/lib/python3.12/site-packages/cryptography/__pycache__/__about__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/site-packages/cryptography/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/site-packages/cryptography/__pycache__/utils.cpython-312.pyc +0 -0
- package/python/lib/python3.12/site-packages/cryptography/exceptions.py +52 -0
- package/python/lib/python3.12/site-packages/cryptography/fernet.py +224 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/__init__.py +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/_oid.py +348 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/__init__.py +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/__init__.py +9 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/backend.py +308 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/__init__.py +3 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/__init__.pyi +37 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/_openssl.pyi +8 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/asn1.pyi +7 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/exceptions.pyi +17 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/ocsp.pyi +117 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi +75 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/aead.pyi +107 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ciphers.pyi +38 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/cmac.pyi +18 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/dh.pyi +51 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/dsa.pyi +41 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ec.pyi +52 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed25519.pyi +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed448.pyi +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/hashes.pyi +28 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/hmac.pyi +22 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi +49 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/keys.pyi +34 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/poly1305.pyi +15 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/rsa.pyi +55 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/x25519.pyi +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/x448.pyi +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/pkcs12.pyi +52 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/pkcs7.pyi +50 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/test_support.pyi +23 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +313 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust.abi3.so +0 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/__init__.py +3 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py +191 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/binding.py +122 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/__init__.py +5 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/ciphers/__init__.py +5 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/ciphers/algorithms.py +112 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/__init__.py +3 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_asymmetric.py +19 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_cipheralgorithm.py +60 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_serialization.py +168 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/__init__.py +3 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py +147 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/dsa.py +167 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py +447 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ed25519.py +129 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ed448.py +131 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py +113 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py +277 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/types.py +111 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/utils.py +24 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py +122 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x448.py +125 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py +27 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/aead.py +23 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +183 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/base.py +146 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/modes.py +268 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/cmac.py +10 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/constant_time.py +14 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/hashes.py +246 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/hmac.py +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/__init__.py +23 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/argon2.py +13 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/concatkdf.py +125 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/hkdf.py +101 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/kbkdf.py +305 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/pbkdf2.py +62 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/scrypt.py +19 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/x963kdf.py +61 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/keywrap.py +177 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/padding.py +69 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/poly1305.py +11 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/__init__.py +65 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/base.py +14 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py +176 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs7.py +411 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/ssh.py +1619 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/__init__.py +9 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/hotp.py +101 -0
- package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/totp.py +56 -0
- package/python/lib/python3.12/site-packages/cryptography/py.typed +0 -0
- package/python/lib/python3.12/site-packages/cryptography/utils.py +139 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/__init__.py +270 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/base.py +848 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/certificate_transparency.py +35 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/extensions.py +2528 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/general_name.py +281 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/name.py +477 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/ocsp.py +379 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/oid.py +37 -0
- package/python/lib/python3.12/site-packages/cryptography/x509/verification.py +34 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/INSTALLER +1 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/METADATA +139 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/RECORD +106 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/REQUESTED +0 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/WHEEL +4 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE +3 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE.APACHE +202 -0
- package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE.BSD +27 -0
- package/python/lib/python3.12/site-packages/pycparser/__init__.py +99 -0
- package/python/lib/python3.12/site-packages/pycparser/_ast_gen.py +355 -0
- package/python/lib/python3.12/site-packages/pycparser/_c_ast.cfg +195 -0
- package/python/lib/python3.12/site-packages/pycparser/ast_transforms.py +174 -0
- package/python/lib/python3.12/site-packages/pycparser/c_ast.py +1341 -0
- package/python/lib/python3.12/site-packages/pycparser/c_generator.py +573 -0
- package/python/lib/python3.12/site-packages/pycparser/c_lexer.py +706 -0
- package/python/lib/python3.12/site-packages/pycparser/c_parser.py +2376 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/INSTALLER +1 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/METADATA +244 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/RECORD +14 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/WHEEL +5 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/licenses/LICENSE +27 -0
- package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/top_level.txt +1 -0
- package/python/lib/python3.12/sqlite3/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/sqlite3/__pycache__/dbapi2.cpython-312.pyc +0 -0
- package/python/lib/python3.12/urllib/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/urllib/__pycache__/error.cpython-312.pyc +0 -0
- package/python/lib/python3.12/urllib/__pycache__/parse.cpython-312.pyc +0 -0
- package/python/lib/python3.12/urllib/__pycache__/request.cpython-312.pyc +0 -0
- package/python/lib/python3.12/urllib/__pycache__/response.cpython-312.pyc +0 -0
- package/python/lib/python3.12/xml/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/xml/parsers/__pycache__/__init__.cpython-312.pyc +0 -0
- package/python/lib/python3.12/xml/parsers/__pycache__/expat.cpython-312.pyc +0 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
# ------------------------------------------------------------------------------
|
|
2
|
+
# pycparser: c_generator.py
|
|
3
|
+
#
|
|
4
|
+
# C code generator from pycparser AST nodes.
|
|
5
|
+
#
|
|
6
|
+
# Eli Bendersky [https://eli.thegreenplace.net/]
|
|
7
|
+
# License: BSD
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
from typing import Callable, List, Optional
|
|
10
|
+
|
|
11
|
+
from . import c_ast
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CGenerator:
|
|
15
|
+
"""Uses the same visitor pattern as c_ast.NodeVisitor, but modified to
|
|
16
|
+
return a value from each visit method, using string accumulation in
|
|
17
|
+
generic_visit.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
indent_level: int
|
|
21
|
+
reduce_parentheses: bool
|
|
22
|
+
|
|
23
|
+
def __init__(self, reduce_parentheses: bool = False) -> None:
|
|
24
|
+
"""Constructs C-code generator
|
|
25
|
+
|
|
26
|
+
reduce_parentheses:
|
|
27
|
+
if True, eliminates needless parentheses on binary operators
|
|
28
|
+
"""
|
|
29
|
+
# Statements start with indentation of self.indent_level spaces, using
|
|
30
|
+
# the _make_indent method.
|
|
31
|
+
self.indent_level = 0
|
|
32
|
+
self.reduce_parentheses = reduce_parentheses
|
|
33
|
+
|
|
34
|
+
def _make_indent(self) -> str:
|
|
35
|
+
return " " * self.indent_level
|
|
36
|
+
|
|
37
|
+
def visit(self, node: c_ast.Node) -> str:
|
|
38
|
+
method = "visit_" + node.__class__.__name__
|
|
39
|
+
return getattr(self, method, self.generic_visit)(node)
|
|
40
|
+
|
|
41
|
+
def generic_visit(self, node: Optional[c_ast.Node]) -> str:
|
|
42
|
+
if node is None:
|
|
43
|
+
return ""
|
|
44
|
+
else:
|
|
45
|
+
return "".join(self.visit(c) for c_name, c in node.children())
|
|
46
|
+
|
|
47
|
+
def visit_Constant(self, n: c_ast.Constant) -> str:
|
|
48
|
+
return n.value
|
|
49
|
+
|
|
50
|
+
def visit_ID(self, n: c_ast.ID) -> str:
|
|
51
|
+
return n.name
|
|
52
|
+
|
|
53
|
+
def visit_Pragma(self, n: c_ast.Pragma) -> str:
|
|
54
|
+
ret = "#pragma"
|
|
55
|
+
if n.string:
|
|
56
|
+
ret += " " + n.string
|
|
57
|
+
return ret
|
|
58
|
+
|
|
59
|
+
def visit_ArrayRef(self, n: c_ast.ArrayRef) -> str:
|
|
60
|
+
arrref = self._parenthesize_unless_simple(n.name)
|
|
61
|
+
return arrref + "[" + self.visit(n.subscript) + "]"
|
|
62
|
+
|
|
63
|
+
def visit_StructRef(self, n: c_ast.StructRef) -> str:
|
|
64
|
+
sref = self._parenthesize_unless_simple(n.name)
|
|
65
|
+
return sref + n.type + self.visit(n.field)
|
|
66
|
+
|
|
67
|
+
def visit_FuncCall(self, n: c_ast.FuncCall) -> str:
|
|
68
|
+
fref = self._parenthesize_unless_simple(n.name)
|
|
69
|
+
args = self.visit(n.args) if n.args is not None else ""
|
|
70
|
+
return fref + "(" + args + ")"
|
|
71
|
+
|
|
72
|
+
def visit_UnaryOp(self, n: c_ast.UnaryOp) -> str:
|
|
73
|
+
match n.op:
|
|
74
|
+
case "sizeof":
|
|
75
|
+
# Always parenthesize the argument of sizeof since it can be
|
|
76
|
+
# a name.
|
|
77
|
+
return f"sizeof({self.visit(n.expr)})"
|
|
78
|
+
case "p++":
|
|
79
|
+
operand = self._parenthesize_unless_simple(n.expr)
|
|
80
|
+
return f"{operand}++"
|
|
81
|
+
case "p--":
|
|
82
|
+
operand = self._parenthesize_unless_simple(n.expr)
|
|
83
|
+
return f"{operand}--"
|
|
84
|
+
case _:
|
|
85
|
+
operand = self._parenthesize_unless_simple(n.expr)
|
|
86
|
+
return f"{n.op}{operand}"
|
|
87
|
+
|
|
88
|
+
# Precedence map of binary operators:
|
|
89
|
+
precedence_map = {
|
|
90
|
+
# Should be in sync with c_parser.CParser.precedence
|
|
91
|
+
# Higher numbers are stronger binding
|
|
92
|
+
"||": 0, # weakest binding
|
|
93
|
+
"&&": 1,
|
|
94
|
+
"|": 2,
|
|
95
|
+
"^": 3,
|
|
96
|
+
"&": 4,
|
|
97
|
+
"==": 5,
|
|
98
|
+
"!=": 5,
|
|
99
|
+
">": 6,
|
|
100
|
+
">=": 6,
|
|
101
|
+
"<": 6,
|
|
102
|
+
"<=": 6,
|
|
103
|
+
">>": 7,
|
|
104
|
+
"<<": 7,
|
|
105
|
+
"+": 8,
|
|
106
|
+
"-": 8,
|
|
107
|
+
"*": 9,
|
|
108
|
+
"/": 9,
|
|
109
|
+
"%": 9, # strongest binding
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
def visit_BinaryOp(self, n: c_ast.BinaryOp) -> str:
|
|
113
|
+
# Note: all binary operators are left-to-right associative
|
|
114
|
+
#
|
|
115
|
+
# If `n.left.op` has a stronger or equally binding precedence in
|
|
116
|
+
# comparison to `n.op`, no parenthesis are needed for the left:
|
|
117
|
+
# e.g., `(a*b) + c` is equivalent to `a*b + c`, as well as
|
|
118
|
+
# `(a+b) - c` is equivalent to `a+b - c` (same precedence).
|
|
119
|
+
# If the left operator is weaker binding than the current, then
|
|
120
|
+
# parentheses are necessary:
|
|
121
|
+
# e.g., `(a+b) * c` is NOT equivalent to `a+b * c`.
|
|
122
|
+
lval_str = self._parenthesize_if(
|
|
123
|
+
n.left,
|
|
124
|
+
lambda d: not (
|
|
125
|
+
self._is_simple_node(d)
|
|
126
|
+
or self.reduce_parentheses
|
|
127
|
+
and isinstance(d, c_ast.BinaryOp)
|
|
128
|
+
and self.precedence_map[d.op] >= self.precedence_map[n.op]
|
|
129
|
+
),
|
|
130
|
+
)
|
|
131
|
+
# If `n.right.op` has a stronger -but not equal- binding precedence,
|
|
132
|
+
# parenthesis can be omitted on the right:
|
|
133
|
+
# e.g., `a + (b*c)` is equivalent to `a + b*c`.
|
|
134
|
+
# If the right operator is weaker or equally binding, then parentheses
|
|
135
|
+
# are necessary:
|
|
136
|
+
# e.g., `a * (b+c)` is NOT equivalent to `a * b+c` and
|
|
137
|
+
# `a - (b+c)` is NOT equivalent to `a - b+c` (same precedence).
|
|
138
|
+
rval_str = self._parenthesize_if(
|
|
139
|
+
n.right,
|
|
140
|
+
lambda d: not (
|
|
141
|
+
self._is_simple_node(d)
|
|
142
|
+
or self.reduce_parentheses
|
|
143
|
+
and isinstance(d, c_ast.BinaryOp)
|
|
144
|
+
and self.precedence_map[d.op] > self.precedence_map[n.op]
|
|
145
|
+
),
|
|
146
|
+
)
|
|
147
|
+
return f"{lval_str} {n.op} {rval_str}"
|
|
148
|
+
|
|
149
|
+
def visit_Assignment(self, n: c_ast.Assignment) -> str:
|
|
150
|
+
rval_str = self._parenthesize_if(
|
|
151
|
+
n.rvalue, lambda n: isinstance(n, c_ast.Assignment)
|
|
152
|
+
)
|
|
153
|
+
return f"{self.visit(n.lvalue)} {n.op} {rval_str}"
|
|
154
|
+
|
|
155
|
+
def visit_IdentifierType(self, n: c_ast.IdentifierType) -> str:
|
|
156
|
+
return " ".join(n.names)
|
|
157
|
+
|
|
158
|
+
def _visit_expr(self, n: c_ast.Node) -> str:
|
|
159
|
+
match n:
|
|
160
|
+
case c_ast.InitList():
|
|
161
|
+
return "{" + self.visit(n) + "}"
|
|
162
|
+
case c_ast.ExprList() | c_ast.Compound():
|
|
163
|
+
return "(" + self.visit(n) + ")"
|
|
164
|
+
case _:
|
|
165
|
+
return self.visit(n)
|
|
166
|
+
|
|
167
|
+
def visit_Decl(self, n: c_ast.Decl, no_type: bool = False) -> str:
|
|
168
|
+
# no_type is used when a Decl is part of a DeclList, where the type is
|
|
169
|
+
# explicitly only for the first declaration in a list.
|
|
170
|
+
#
|
|
171
|
+
s = n.name if no_type else self._generate_decl(n)
|
|
172
|
+
if n.bitsize:
|
|
173
|
+
s += " : " + self.visit(n.bitsize)
|
|
174
|
+
if n.init:
|
|
175
|
+
s += " = " + self._visit_expr(n.init)
|
|
176
|
+
return s
|
|
177
|
+
|
|
178
|
+
def visit_DeclList(self, n: c_ast.DeclList) -> str:
|
|
179
|
+
s = self.visit(n.decls[0])
|
|
180
|
+
if len(n.decls) > 1:
|
|
181
|
+
s += ", " + ", ".join(
|
|
182
|
+
self.visit_Decl(decl, no_type=True) for decl in n.decls[1:]
|
|
183
|
+
)
|
|
184
|
+
return s
|
|
185
|
+
|
|
186
|
+
def visit_Typedef(self, n: c_ast.Typedef) -> str:
|
|
187
|
+
s = ""
|
|
188
|
+
if n.storage:
|
|
189
|
+
s += " ".join(n.storage) + " "
|
|
190
|
+
s += self._generate_type(n.type)
|
|
191
|
+
return s
|
|
192
|
+
|
|
193
|
+
def visit_Cast(self, n: c_ast.Cast) -> str:
|
|
194
|
+
s = "(" + self._generate_type(n.to_type, emit_declname=False) + ")"
|
|
195
|
+
return s + " " + self._parenthesize_unless_simple(n.expr)
|
|
196
|
+
|
|
197
|
+
def visit_ExprList(self, n: c_ast.ExprList) -> str:
|
|
198
|
+
visited_subexprs = []
|
|
199
|
+
for expr in n.exprs:
|
|
200
|
+
visited_subexprs.append(self._visit_expr(expr))
|
|
201
|
+
return ", ".join(visited_subexprs)
|
|
202
|
+
|
|
203
|
+
def visit_InitList(self, n: c_ast.InitList) -> str:
|
|
204
|
+
visited_subexprs = []
|
|
205
|
+
for expr in n.exprs:
|
|
206
|
+
visited_subexprs.append(self._visit_expr(expr))
|
|
207
|
+
return ", ".join(visited_subexprs)
|
|
208
|
+
|
|
209
|
+
def visit_Enum(self, n: c_ast.Enum) -> str:
|
|
210
|
+
return self._generate_struct_union_enum(n, name="enum")
|
|
211
|
+
|
|
212
|
+
def visit_Alignas(self, n: c_ast.Alignas) -> str:
|
|
213
|
+
return "_Alignas({})".format(self.visit(n.alignment))
|
|
214
|
+
|
|
215
|
+
def visit_Enumerator(self, n: c_ast.Enumerator) -> str:
|
|
216
|
+
if not n.value:
|
|
217
|
+
return "{indent}{name},\n".format(
|
|
218
|
+
indent=self._make_indent(),
|
|
219
|
+
name=n.name,
|
|
220
|
+
)
|
|
221
|
+
else:
|
|
222
|
+
return "{indent}{name} = {value},\n".format(
|
|
223
|
+
indent=self._make_indent(),
|
|
224
|
+
name=n.name,
|
|
225
|
+
value=self.visit(n.value),
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
def visit_FuncDef(self, n: c_ast.FuncDef) -> str:
|
|
229
|
+
decl = self.visit(n.decl)
|
|
230
|
+
self.indent_level = 0
|
|
231
|
+
body = self.visit(n.body)
|
|
232
|
+
if n.param_decls:
|
|
233
|
+
knrdecls = ";\n".join(self.visit(p) for p in n.param_decls)
|
|
234
|
+
return decl + "\n" + knrdecls + ";\n" + body + "\n"
|
|
235
|
+
else:
|
|
236
|
+
return decl + "\n" + body + "\n"
|
|
237
|
+
|
|
238
|
+
def visit_FileAST(self, n: c_ast.FileAST) -> str:
|
|
239
|
+
s = ""
|
|
240
|
+
for ext in n.ext:
|
|
241
|
+
match ext:
|
|
242
|
+
case c_ast.FuncDef():
|
|
243
|
+
s += self.visit(ext)
|
|
244
|
+
case c_ast.Pragma():
|
|
245
|
+
s += self.visit(ext) + "\n"
|
|
246
|
+
case _:
|
|
247
|
+
s += self.visit(ext) + ";\n"
|
|
248
|
+
return s
|
|
249
|
+
|
|
250
|
+
def visit_Compound(self, n: c_ast.Compound) -> str:
|
|
251
|
+
s = self._make_indent() + "{\n"
|
|
252
|
+
self.indent_level += 2
|
|
253
|
+
if n.block_items:
|
|
254
|
+
s += "".join(self._generate_stmt(stmt) for stmt in n.block_items)
|
|
255
|
+
self.indent_level -= 2
|
|
256
|
+
s += self._make_indent() + "}\n"
|
|
257
|
+
return s
|
|
258
|
+
|
|
259
|
+
def visit_CompoundLiteral(self, n: c_ast.CompoundLiteral) -> str:
|
|
260
|
+
return "(" + self.visit(n.type) + "){" + self.visit(n.init) + "}"
|
|
261
|
+
|
|
262
|
+
def visit_EmptyStatement(self, n: c_ast.EmptyStatement) -> str:
|
|
263
|
+
return ";"
|
|
264
|
+
|
|
265
|
+
def visit_ParamList(self, n: c_ast.ParamList) -> str:
|
|
266
|
+
return ", ".join(self.visit(param) for param in n.params)
|
|
267
|
+
|
|
268
|
+
def visit_Return(self, n: c_ast.Return) -> str:
|
|
269
|
+
s = "return"
|
|
270
|
+
if n.expr:
|
|
271
|
+
s += " " + self.visit(n.expr)
|
|
272
|
+
return s + ";"
|
|
273
|
+
|
|
274
|
+
def visit_Break(self, n: c_ast.Break) -> str:
|
|
275
|
+
return "break;"
|
|
276
|
+
|
|
277
|
+
def visit_Continue(self, n: c_ast.Continue) -> str:
|
|
278
|
+
return "continue;"
|
|
279
|
+
|
|
280
|
+
def visit_TernaryOp(self, n: c_ast.TernaryOp) -> str:
|
|
281
|
+
s = "(" + self._visit_expr(n.cond) + ") ? "
|
|
282
|
+
s += "(" + self._visit_expr(n.iftrue) + ") : "
|
|
283
|
+
s += "(" + self._visit_expr(n.iffalse) + ")"
|
|
284
|
+
return s
|
|
285
|
+
|
|
286
|
+
def visit_If(self, n: c_ast.If) -> str:
|
|
287
|
+
s = "if ("
|
|
288
|
+
if n.cond:
|
|
289
|
+
s += self.visit(n.cond)
|
|
290
|
+
s += ")\n"
|
|
291
|
+
s += self._generate_stmt(n.iftrue, add_indent=True)
|
|
292
|
+
if n.iffalse:
|
|
293
|
+
s += self._make_indent() + "else\n"
|
|
294
|
+
s += self._generate_stmt(n.iffalse, add_indent=True)
|
|
295
|
+
return s
|
|
296
|
+
|
|
297
|
+
def visit_For(self, n: c_ast.For) -> str:
|
|
298
|
+
s = "for ("
|
|
299
|
+
if n.init:
|
|
300
|
+
s += self.visit(n.init)
|
|
301
|
+
s += ";"
|
|
302
|
+
if n.cond:
|
|
303
|
+
s += " " + self.visit(n.cond)
|
|
304
|
+
s += ";"
|
|
305
|
+
if n.next:
|
|
306
|
+
s += " " + self.visit(n.next)
|
|
307
|
+
s += ")\n"
|
|
308
|
+
s += self._generate_stmt(n.stmt, add_indent=True)
|
|
309
|
+
return s
|
|
310
|
+
|
|
311
|
+
def visit_While(self, n: c_ast.While) -> str:
|
|
312
|
+
s = "while ("
|
|
313
|
+
if n.cond:
|
|
314
|
+
s += self.visit(n.cond)
|
|
315
|
+
s += ")\n"
|
|
316
|
+
s += self._generate_stmt(n.stmt, add_indent=True)
|
|
317
|
+
return s
|
|
318
|
+
|
|
319
|
+
def visit_DoWhile(self, n: c_ast.DoWhile) -> str:
|
|
320
|
+
s = "do\n"
|
|
321
|
+
s += self._generate_stmt(n.stmt, add_indent=True)
|
|
322
|
+
s += self._make_indent() + "while ("
|
|
323
|
+
if n.cond:
|
|
324
|
+
s += self.visit(n.cond)
|
|
325
|
+
s += ");"
|
|
326
|
+
return s
|
|
327
|
+
|
|
328
|
+
def visit_StaticAssert(self, n: c_ast.StaticAssert) -> str:
|
|
329
|
+
s = "_Static_assert("
|
|
330
|
+
s += self.visit(n.cond)
|
|
331
|
+
if n.message:
|
|
332
|
+
s += ","
|
|
333
|
+
s += self.visit(n.message)
|
|
334
|
+
s += ")"
|
|
335
|
+
return s
|
|
336
|
+
|
|
337
|
+
def visit_Switch(self, n: c_ast.Switch) -> str:
|
|
338
|
+
s = "switch (" + self.visit(n.cond) + ")\n"
|
|
339
|
+
s += self._generate_stmt(n.stmt, add_indent=True)
|
|
340
|
+
return s
|
|
341
|
+
|
|
342
|
+
def visit_Case(self, n: c_ast.Case) -> str:
|
|
343
|
+
s = "case " + self.visit(n.expr) + ":\n"
|
|
344
|
+
for stmt in n.stmts:
|
|
345
|
+
s += self._generate_stmt(stmt, add_indent=True)
|
|
346
|
+
return s
|
|
347
|
+
|
|
348
|
+
def visit_Default(self, n: c_ast.Default) -> str:
|
|
349
|
+
s = "default:\n"
|
|
350
|
+
for stmt in n.stmts:
|
|
351
|
+
s += self._generate_stmt(stmt, add_indent=True)
|
|
352
|
+
return s
|
|
353
|
+
|
|
354
|
+
def visit_Label(self, n: c_ast.Label) -> str:
|
|
355
|
+
return n.name + ":\n" + self._generate_stmt(n.stmt)
|
|
356
|
+
|
|
357
|
+
def visit_Goto(self, n: c_ast.Goto) -> str:
|
|
358
|
+
return "goto " + n.name + ";"
|
|
359
|
+
|
|
360
|
+
def visit_EllipsisParam(self, n: c_ast.EllipsisParam) -> str:
|
|
361
|
+
return "..."
|
|
362
|
+
|
|
363
|
+
def visit_Struct(self, n: c_ast.Struct) -> str:
|
|
364
|
+
return self._generate_struct_union_enum(n, "struct")
|
|
365
|
+
|
|
366
|
+
def visit_Typename(self, n: c_ast.Typename) -> str:
|
|
367
|
+
return self._generate_type(n.type)
|
|
368
|
+
|
|
369
|
+
def visit_Union(self, n: c_ast.Union) -> str:
|
|
370
|
+
return self._generate_struct_union_enum(n, "union")
|
|
371
|
+
|
|
372
|
+
def visit_NamedInitializer(self, n: c_ast.NamedInitializer) -> str:
|
|
373
|
+
s = ""
|
|
374
|
+
for name in n.name:
|
|
375
|
+
if isinstance(name, c_ast.ID):
|
|
376
|
+
s += "." + name.name
|
|
377
|
+
else:
|
|
378
|
+
s += "[" + self.visit(name) + "]"
|
|
379
|
+
s += " = " + self._visit_expr(n.expr)
|
|
380
|
+
return s
|
|
381
|
+
|
|
382
|
+
def visit_FuncDecl(self, n: c_ast.FuncDecl) -> str:
|
|
383
|
+
return self._generate_type(n)
|
|
384
|
+
|
|
385
|
+
def visit_ArrayDecl(self, n: c_ast.ArrayDecl) -> str:
|
|
386
|
+
return self._generate_type(n, emit_declname=False)
|
|
387
|
+
|
|
388
|
+
def visit_TypeDecl(self, n: c_ast.TypeDecl) -> str:
|
|
389
|
+
return self._generate_type(n, emit_declname=False)
|
|
390
|
+
|
|
391
|
+
def visit_PtrDecl(self, n: c_ast.PtrDecl) -> str:
|
|
392
|
+
return self._generate_type(n, emit_declname=False)
|
|
393
|
+
|
|
394
|
+
def _generate_struct_union_enum(
|
|
395
|
+
self, n: c_ast.Struct | c_ast.Union | c_ast.Enum, name: str
|
|
396
|
+
) -> str:
|
|
397
|
+
"""Generates code for structs, unions, and enums. name should be
|
|
398
|
+
'struct', 'union', or 'enum'.
|
|
399
|
+
"""
|
|
400
|
+
if name in ("struct", "union"):
|
|
401
|
+
assert isinstance(n, (c_ast.Struct, c_ast.Union))
|
|
402
|
+
members = n.decls
|
|
403
|
+
body_function = self._generate_struct_union_body
|
|
404
|
+
else:
|
|
405
|
+
assert name == "enum"
|
|
406
|
+
assert isinstance(n, c_ast.Enum)
|
|
407
|
+
members = None if n.values is None else n.values.enumerators
|
|
408
|
+
body_function = self._generate_enum_body
|
|
409
|
+
s = name + " " + (n.name or "")
|
|
410
|
+
if members is not None:
|
|
411
|
+
# None means no members
|
|
412
|
+
# Empty sequence means an empty list of members
|
|
413
|
+
s += "\n"
|
|
414
|
+
s += self._make_indent()
|
|
415
|
+
self.indent_level += 2
|
|
416
|
+
s += "{\n"
|
|
417
|
+
s += body_function(members)
|
|
418
|
+
self.indent_level -= 2
|
|
419
|
+
s += self._make_indent() + "}"
|
|
420
|
+
return s
|
|
421
|
+
|
|
422
|
+
def _generate_struct_union_body(self, members: List[c_ast.Node]) -> str:
|
|
423
|
+
return "".join(self._generate_stmt(decl) for decl in members)
|
|
424
|
+
|
|
425
|
+
def _generate_enum_body(self, members: List[c_ast.Enumerator]) -> str:
|
|
426
|
+
# `[:-2] + '\n'` removes the final `,` from the enumerator list
|
|
427
|
+
return "".join(self.visit(value) for value in members)[:-2] + "\n"
|
|
428
|
+
|
|
429
|
+
def _generate_stmt(self, n: c_ast.Node, add_indent: bool = False) -> str:
|
|
430
|
+
"""Generation from a statement node. This method exists as a wrapper
|
|
431
|
+
for individual visit_* methods to handle different treatment of
|
|
432
|
+
some statements in this context.
|
|
433
|
+
"""
|
|
434
|
+
if add_indent:
|
|
435
|
+
self.indent_level += 2
|
|
436
|
+
indent = self._make_indent()
|
|
437
|
+
if add_indent:
|
|
438
|
+
self.indent_level -= 2
|
|
439
|
+
|
|
440
|
+
match n:
|
|
441
|
+
case (
|
|
442
|
+
c_ast.Decl()
|
|
443
|
+
| c_ast.Assignment()
|
|
444
|
+
| c_ast.Cast()
|
|
445
|
+
| c_ast.UnaryOp()
|
|
446
|
+
| c_ast.BinaryOp()
|
|
447
|
+
| c_ast.TernaryOp()
|
|
448
|
+
| c_ast.FuncCall()
|
|
449
|
+
| c_ast.ArrayRef()
|
|
450
|
+
| c_ast.StructRef()
|
|
451
|
+
| c_ast.Constant()
|
|
452
|
+
| c_ast.ID()
|
|
453
|
+
| c_ast.Typedef()
|
|
454
|
+
| c_ast.ExprList()
|
|
455
|
+
):
|
|
456
|
+
# These can also appear in an expression context so no semicolon
|
|
457
|
+
# is added to them automatically
|
|
458
|
+
#
|
|
459
|
+
return indent + self.visit(n) + ";\n"
|
|
460
|
+
case c_ast.Compound():
|
|
461
|
+
# No extra indentation required before the opening brace of a
|
|
462
|
+
# compound - because it consists of multiple lines it has to
|
|
463
|
+
# compute its own indentation.
|
|
464
|
+
#
|
|
465
|
+
return self.visit(n)
|
|
466
|
+
case c_ast.If():
|
|
467
|
+
return indent + self.visit(n)
|
|
468
|
+
case _:
|
|
469
|
+
return indent + self.visit(n) + "\n"
|
|
470
|
+
|
|
471
|
+
def _generate_decl(self, n: c_ast.Decl) -> str:
|
|
472
|
+
"""Generation from a Decl node."""
|
|
473
|
+
s = ""
|
|
474
|
+
if n.funcspec:
|
|
475
|
+
s = " ".join(n.funcspec) + " "
|
|
476
|
+
if n.storage:
|
|
477
|
+
s += " ".join(n.storage) + " "
|
|
478
|
+
if n.align:
|
|
479
|
+
s += self.visit(n.align[0]) + " "
|
|
480
|
+
s += self._generate_type(n.type)
|
|
481
|
+
return s
|
|
482
|
+
|
|
483
|
+
def _generate_type(
|
|
484
|
+
self,
|
|
485
|
+
n: c_ast.Node,
|
|
486
|
+
modifiers: List[c_ast.Node] = [],
|
|
487
|
+
emit_declname: bool = True,
|
|
488
|
+
) -> str:
|
|
489
|
+
"""Recursive generation from a type node. n is the type node.
|
|
490
|
+
modifiers collects the PtrDecl, ArrayDecl and FuncDecl modifiers
|
|
491
|
+
encountered on the way down to a TypeDecl, to allow proper
|
|
492
|
+
generation from it.
|
|
493
|
+
"""
|
|
494
|
+
# ~ print(n, modifiers)
|
|
495
|
+
match n:
|
|
496
|
+
case c_ast.TypeDecl():
|
|
497
|
+
s = ""
|
|
498
|
+
if n.quals:
|
|
499
|
+
s += " ".join(n.quals) + " "
|
|
500
|
+
s += self.visit(n.type)
|
|
501
|
+
|
|
502
|
+
nstr = n.declname if n.declname and emit_declname else ""
|
|
503
|
+
# Resolve modifiers.
|
|
504
|
+
# Wrap in parens to distinguish pointer to array and pointer to
|
|
505
|
+
# function syntax.
|
|
506
|
+
#
|
|
507
|
+
for i, modifier in enumerate(modifiers):
|
|
508
|
+
match modifier:
|
|
509
|
+
case c_ast.ArrayDecl():
|
|
510
|
+
if i != 0 and isinstance(modifiers[i - 1], c_ast.PtrDecl):
|
|
511
|
+
nstr = "(" + nstr + ")"
|
|
512
|
+
nstr += "["
|
|
513
|
+
if modifier.dim_quals:
|
|
514
|
+
nstr += " ".join(modifier.dim_quals) + " "
|
|
515
|
+
if modifier.dim is not None:
|
|
516
|
+
nstr += self.visit(modifier.dim)
|
|
517
|
+
nstr += "]"
|
|
518
|
+
case c_ast.FuncDecl():
|
|
519
|
+
if i != 0 and isinstance(modifiers[i - 1], c_ast.PtrDecl):
|
|
520
|
+
nstr = "(" + nstr + ")"
|
|
521
|
+
args = (
|
|
522
|
+
self.visit(modifier.args)
|
|
523
|
+
if modifier.args is not None
|
|
524
|
+
else ""
|
|
525
|
+
)
|
|
526
|
+
nstr += "(" + args + ")"
|
|
527
|
+
case c_ast.PtrDecl():
|
|
528
|
+
if modifier.quals:
|
|
529
|
+
quals = " ".join(modifier.quals)
|
|
530
|
+
suffix = f" {nstr}" if nstr else ""
|
|
531
|
+
nstr = f"* {quals}{suffix}"
|
|
532
|
+
else:
|
|
533
|
+
nstr = "*" + nstr
|
|
534
|
+
if nstr:
|
|
535
|
+
s += " " + nstr
|
|
536
|
+
return s
|
|
537
|
+
case c_ast.Decl():
|
|
538
|
+
return self._generate_decl(n.type)
|
|
539
|
+
case c_ast.Typename():
|
|
540
|
+
return self._generate_type(n.type, emit_declname=emit_declname)
|
|
541
|
+
case c_ast.IdentifierType():
|
|
542
|
+
return " ".join(n.names) + " "
|
|
543
|
+
case c_ast.ArrayDecl() | c_ast.PtrDecl() | c_ast.FuncDecl():
|
|
544
|
+
return self._generate_type(
|
|
545
|
+
n.type, modifiers + [n], emit_declname=emit_declname
|
|
546
|
+
)
|
|
547
|
+
case _:
|
|
548
|
+
return self.visit(n)
|
|
549
|
+
|
|
550
|
+
def _parenthesize_if(
|
|
551
|
+
self, n: c_ast.Node, condition: Callable[[c_ast.Node], bool]
|
|
552
|
+
) -> str:
|
|
553
|
+
"""Visits 'n' and returns its string representation, parenthesized
|
|
554
|
+
if the condition function applied to the node returns True.
|
|
555
|
+
"""
|
|
556
|
+
s = self._visit_expr(n)
|
|
557
|
+
if condition(n):
|
|
558
|
+
return "(" + s + ")"
|
|
559
|
+
else:
|
|
560
|
+
return s
|
|
561
|
+
|
|
562
|
+
def _parenthesize_unless_simple(self, n: c_ast.Node) -> str:
|
|
563
|
+
"""Common use case for _parenthesize_if"""
|
|
564
|
+
return self._parenthesize_if(n, lambda d: not self._is_simple_node(d))
|
|
565
|
+
|
|
566
|
+
def _is_simple_node(self, n: c_ast.Node) -> bool:
|
|
567
|
+
"""Returns True for nodes that are "simple" - i.e. nodes that always
|
|
568
|
+
have higher precedence than operators.
|
|
569
|
+
"""
|
|
570
|
+
return isinstance(
|
|
571
|
+
n,
|
|
572
|
+
(c_ast.Constant, c_ast.ID, c_ast.ArrayRef, c_ast.StructRef, c_ast.FuncCall),
|
|
573
|
+
)
|