@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.
Files changed (249) hide show
  1. package/README.md +1 -1
  2. package/bin/pairling-connectd +0 -0
  3. package/manifest.json +4 -4
  4. package/package.json +3 -3
  5. package/python/bin/python3 +0 -0
  6. package/python/bin/python3.12 +0 -0
  7. package/python/lib/libpython3.12.dylib +0 -0
  8. package/python/lib/python3.12/__pycache__/__future__.cpython-312.pyc +0 -0
  9. package/python/lib/python3.12/__pycache__/_compression.cpython-312.pyc +0 -0
  10. package/python/lib/python3.12/__pycache__/_weakrefset.cpython-312.pyc +0 -0
  11. package/python/lib/python3.12/__pycache__/base64.cpython-312.pyc +0 -0
  12. package/python/lib/python3.12/__pycache__/bisect.cpython-312.pyc +0 -0
  13. package/python/lib/python3.12/__pycache__/bz2.cpython-312.pyc +0 -0
  14. package/python/lib/python3.12/__pycache__/calendar.cpython-312.pyc +0 -0
  15. package/python/lib/python3.12/__pycache__/contextlib.cpython-312.pyc +0 -0
  16. package/python/lib/python3.12/__pycache__/copyreg.cpython-312.pyc +0 -0
  17. package/python/lib/python3.12/__pycache__/datetime.cpython-312.pyc +0 -0
  18. package/python/lib/python3.12/__pycache__/enum.cpython-312.pyc +0 -0
  19. package/python/lib/python3.12/__pycache__/fnmatch.cpython-312.pyc +0 -0
  20. package/python/lib/python3.12/__pycache__/functools.cpython-312.pyc +0 -0
  21. package/python/lib/python3.12/__pycache__/hashlib.cpython-312.pyc +0 -0
  22. package/python/lib/python3.12/__pycache__/hmac.cpython-312.pyc +0 -0
  23. package/python/lib/python3.12/__pycache__/ipaddress.cpython-312.pyc +0 -0
  24. package/python/lib/python3.12/__pycache__/keyword.cpython-312.pyc +0 -0
  25. package/python/lib/python3.12/__pycache__/locale.cpython-312.pyc +0 -0
  26. package/python/lib/python3.12/__pycache__/lzma.cpython-312.pyc +0 -0
  27. package/python/lib/python3.12/__pycache__/operator.cpython-312.pyc +0 -0
  28. package/python/lib/python3.12/__pycache__/plistlib.cpython-312.pyc +0 -0
  29. package/python/lib/python3.12/__pycache__/pty.cpython-312.pyc +0 -0
  30. package/python/lib/python3.12/__pycache__/quopri.cpython-312.pyc +0 -0
  31. package/python/lib/python3.12/__pycache__/random.cpython-312.pyc +0 -0
  32. package/python/lib/python3.12/__pycache__/reprlib.cpython-312.pyc +0 -0
  33. package/python/lib/python3.12/__pycache__/selectors.cpython-312.pyc +0 -0
  34. package/python/lib/python3.12/__pycache__/shutil.cpython-312.pyc +0 -0
  35. package/python/lib/python3.12/__pycache__/signal.cpython-312.pyc +0 -0
  36. package/python/lib/python3.12/__pycache__/socket.cpython-312.pyc +0 -0
  37. package/python/lib/python3.12/__pycache__/ssl.cpython-312.pyc +0 -0
  38. package/python/lib/python3.12/__pycache__/string.cpython-312.pyc +0 -0
  39. package/python/lib/python3.12/__pycache__/struct.cpython-312.pyc +0 -0
  40. package/python/lib/python3.12/__pycache__/subprocess.cpython-312.pyc +0 -0
  41. package/python/lib/python3.12/__pycache__/tempfile.cpython-312.pyc +0 -0
  42. package/python/lib/python3.12/__pycache__/threading.cpython-312.pyc +0 -0
  43. package/python/lib/python3.12/__pycache__/tty.cpython-312.pyc +0 -0
  44. package/python/lib/python3.12/__pycache__/types.cpython-312.pyc +0 -0
  45. package/python/lib/python3.12/__pycache__/typing.cpython-312.pyc +0 -0
  46. package/python/lib/python3.12/__pycache__/warnings.cpython-312.pyc +0 -0
  47. package/python/lib/python3.12/__pycache__/weakref.cpython-312.pyc +0 -0
  48. package/python/lib/python3.12/collections/__pycache__/__init__.cpython-312.pyc +0 -0
  49. package/python/lib/python3.12/collections/__pycache__/abc.cpython-312.pyc +0 -0
  50. package/python/lib/python3.12/email/__pycache__/__init__.cpython-312.pyc +0 -0
  51. package/python/lib/python3.12/email/__pycache__/_encoded_words.cpython-312.pyc +0 -0
  52. package/python/lib/python3.12/email/__pycache__/_parseaddr.cpython-312.pyc +0 -0
  53. package/python/lib/python3.12/email/__pycache__/_policybase.cpython-312.pyc +0 -0
  54. package/python/lib/python3.12/email/__pycache__/base64mime.cpython-312.pyc +0 -0
  55. package/python/lib/python3.12/email/__pycache__/charset.cpython-312.pyc +0 -0
  56. package/python/lib/python3.12/email/__pycache__/encoders.cpython-312.pyc +0 -0
  57. package/python/lib/python3.12/email/__pycache__/errors.cpython-312.pyc +0 -0
  58. package/python/lib/python3.12/email/__pycache__/feedparser.cpython-312.pyc +0 -0
  59. package/python/lib/python3.12/email/__pycache__/header.cpython-312.pyc +0 -0
  60. package/python/lib/python3.12/email/__pycache__/iterators.cpython-312.pyc +0 -0
  61. package/python/lib/python3.12/email/__pycache__/message.cpython-312.pyc +0 -0
  62. package/python/lib/python3.12/email/__pycache__/parser.cpython-312.pyc +0 -0
  63. package/python/lib/python3.12/email/__pycache__/quoprimime.cpython-312.pyc +0 -0
  64. package/python/lib/python3.12/email/__pycache__/utils.cpython-312.pyc +0 -0
  65. package/python/lib/python3.12/encodings/__pycache__/__init__.cpython-312.pyc +0 -0
  66. package/python/lib/python3.12/encodings/__pycache__/aliases.cpython-312.pyc +0 -0
  67. package/python/lib/python3.12/encodings/__pycache__/utf_8.cpython-312.pyc +0 -0
  68. package/python/lib/python3.12/http/__pycache__/__init__.cpython-312.pyc +0 -0
  69. package/python/lib/python3.12/http/__pycache__/client.cpython-312.pyc +0 -0
  70. package/python/lib/python3.12/json/__pycache__/__init__.cpython-312.pyc +0 -0
  71. package/python/lib/python3.12/json/__pycache__/decoder.cpython-312.pyc +0 -0
  72. package/python/lib/python3.12/json/__pycache__/encoder.cpython-312.pyc +0 -0
  73. package/python/lib/python3.12/json/__pycache__/scanner.cpython-312.pyc +0 -0
  74. package/python/lib/python3.12/lib-dynload/_crypt.cpython-312-darwin.so +0 -0
  75. package/python/lib/python3.12/lib-dynload/_dbm.cpython-312-darwin.so +0 -0
  76. package/python/lib/python3.12/re/__pycache__/__init__.cpython-312.pyc +0 -0
  77. package/python/lib/python3.12/re/__pycache__/_casefix.cpython-312.pyc +0 -0
  78. package/python/lib/python3.12/re/__pycache__/_compiler.cpython-312.pyc +0 -0
  79. package/python/lib/python3.12/re/__pycache__/_constants.cpython-312.pyc +0 -0
  80. package/python/lib/python3.12/re/__pycache__/_parser.cpython-312.pyc +0 -0
  81. package/python/lib/python3.12/site-packages/_cffi_backend.cpython-312-darwin.so +0 -0
  82. package/python/lib/python3.12/site-packages/cffi/__init__.py +14 -0
  83. package/python/lib/python3.12/site-packages/cffi/__pycache__/__init__.cpython-312.pyc +0 -0
  84. package/python/lib/python3.12/site-packages/cffi/__pycache__/api.cpython-312.pyc +0 -0
  85. package/python/lib/python3.12/site-packages/cffi/__pycache__/error.cpython-312.pyc +0 -0
  86. package/python/lib/python3.12/site-packages/cffi/__pycache__/lock.cpython-312.pyc +0 -0
  87. package/python/lib/python3.12/site-packages/cffi/__pycache__/model.cpython-312.pyc +0 -0
  88. package/python/lib/python3.12/site-packages/cffi/_cffi_errors.h +149 -0
  89. package/python/lib/python3.12/site-packages/cffi/_cffi_include.h +389 -0
  90. package/python/lib/python3.12/site-packages/cffi/_embedding.h +550 -0
  91. package/python/lib/python3.12/site-packages/cffi/_imp_emulation.py +83 -0
  92. package/python/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py +45 -0
  93. package/python/lib/python3.12/site-packages/cffi/api.py +967 -0
  94. package/python/lib/python3.12/site-packages/cffi/backend_ctypes.py +1121 -0
  95. package/python/lib/python3.12/site-packages/cffi/cffi_opcode.py +187 -0
  96. package/python/lib/python3.12/site-packages/cffi/commontypes.py +82 -0
  97. package/python/lib/python3.12/site-packages/cffi/cparser.py +1015 -0
  98. package/python/lib/python3.12/site-packages/cffi/error.py +31 -0
  99. package/python/lib/python3.12/site-packages/cffi/ffiplatform.py +113 -0
  100. package/python/lib/python3.12/site-packages/cffi/lock.py +30 -0
  101. package/python/lib/python3.12/site-packages/cffi/model.py +618 -0
  102. package/python/lib/python3.12/site-packages/cffi/parse_c_type.h +181 -0
  103. package/python/lib/python3.12/site-packages/cffi/pkgconfig.py +121 -0
  104. package/python/lib/python3.12/site-packages/cffi/recompiler.py +1598 -0
  105. package/python/lib/python3.12/site-packages/cffi/setuptools_ext.py +229 -0
  106. package/python/lib/python3.12/site-packages/cffi/vengine_cpy.py +1087 -0
  107. package/python/lib/python3.12/site-packages/cffi/vengine_gen.py +679 -0
  108. package/python/lib/python3.12/site-packages/cffi/verifier.py +306 -0
  109. package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/INSTALLER +1 -0
  110. package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/METADATA +68 -0
  111. package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/RECORD +31 -0
  112. package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/WHEEL +6 -0
  113. package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/entry_points.txt +2 -0
  114. package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/licenses/AUTHORS +8 -0
  115. package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/licenses/LICENSE +23 -0
  116. package/python/lib/python3.12/site-packages/cffi-2.0.0.dist-info/top_level.txt +2 -0
  117. package/python/lib/python3.12/site-packages/cryptography/__about__.py +17 -0
  118. package/python/lib/python3.12/site-packages/cryptography/__init__.py +26 -0
  119. package/python/lib/python3.12/site-packages/cryptography/__pycache__/__about__.cpython-312.pyc +0 -0
  120. package/python/lib/python3.12/site-packages/cryptography/__pycache__/__init__.cpython-312.pyc +0 -0
  121. package/python/lib/python3.12/site-packages/cryptography/__pycache__/utils.cpython-312.pyc +0 -0
  122. package/python/lib/python3.12/site-packages/cryptography/exceptions.py +52 -0
  123. package/python/lib/python3.12/site-packages/cryptography/fernet.py +224 -0
  124. package/python/lib/python3.12/site-packages/cryptography/hazmat/__init__.py +13 -0
  125. package/python/lib/python3.12/site-packages/cryptography/hazmat/_oid.py +348 -0
  126. package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/__init__.py +13 -0
  127. package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/__init__.py +9 -0
  128. package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/backend.py +308 -0
  129. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/__init__.py +3 -0
  130. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/__init__.pyi +37 -0
  131. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/_openssl.pyi +8 -0
  132. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/asn1.pyi +7 -0
  133. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/exceptions.pyi +17 -0
  134. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/ocsp.pyi +117 -0
  135. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi +75 -0
  136. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/aead.pyi +107 -0
  137. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ciphers.pyi +38 -0
  138. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/cmac.pyi +18 -0
  139. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/dh.pyi +51 -0
  140. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/dsa.pyi +41 -0
  141. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ec.pyi +52 -0
  142. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed25519.pyi +13 -0
  143. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed448.pyi +13 -0
  144. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/hashes.pyi +28 -0
  145. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/hmac.pyi +22 -0
  146. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi +49 -0
  147. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/keys.pyi +34 -0
  148. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/poly1305.pyi +15 -0
  149. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/rsa.pyi +55 -0
  150. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/x25519.pyi +13 -0
  151. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/x448.pyi +13 -0
  152. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/pkcs12.pyi +52 -0
  153. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/pkcs7.pyi +50 -0
  154. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/test_support.pyi +23 -0
  155. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +313 -0
  156. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust.abi3.so +0 -0
  157. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/__init__.py +3 -0
  158. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py +191 -0
  159. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/binding.py +122 -0
  160. package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/__init__.py +5 -0
  161. package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/ciphers/__init__.py +5 -0
  162. package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/ciphers/algorithms.py +112 -0
  163. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/__init__.py +3 -0
  164. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_asymmetric.py +19 -0
  165. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_cipheralgorithm.py +60 -0
  166. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_serialization.py +168 -0
  167. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/__init__.py +3 -0
  168. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py +147 -0
  169. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/dsa.py +167 -0
  170. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py +447 -0
  171. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ed25519.py +129 -0
  172. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ed448.py +131 -0
  173. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py +113 -0
  174. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py +277 -0
  175. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/types.py +111 -0
  176. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/utils.py +24 -0
  177. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py +122 -0
  178. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x448.py +125 -0
  179. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py +27 -0
  180. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/aead.py +23 -0
  181. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +183 -0
  182. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/base.py +146 -0
  183. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/modes.py +268 -0
  184. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/cmac.py +10 -0
  185. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/constant_time.py +14 -0
  186. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/hashes.py +246 -0
  187. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/hmac.py +13 -0
  188. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/__init__.py +23 -0
  189. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/argon2.py +13 -0
  190. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/concatkdf.py +125 -0
  191. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/hkdf.py +101 -0
  192. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/kbkdf.py +305 -0
  193. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/pbkdf2.py +62 -0
  194. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/scrypt.py +19 -0
  195. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/x963kdf.py +61 -0
  196. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/keywrap.py +177 -0
  197. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/padding.py +69 -0
  198. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/poly1305.py +11 -0
  199. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/__init__.py +65 -0
  200. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/base.py +14 -0
  201. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py +176 -0
  202. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs7.py +411 -0
  203. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/ssh.py +1619 -0
  204. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/__init__.py +9 -0
  205. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/hotp.py +101 -0
  206. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/totp.py +56 -0
  207. package/python/lib/python3.12/site-packages/cryptography/py.typed +0 -0
  208. package/python/lib/python3.12/site-packages/cryptography/utils.py +139 -0
  209. package/python/lib/python3.12/site-packages/cryptography/x509/__init__.py +270 -0
  210. package/python/lib/python3.12/site-packages/cryptography/x509/base.py +848 -0
  211. package/python/lib/python3.12/site-packages/cryptography/x509/certificate_transparency.py +35 -0
  212. package/python/lib/python3.12/site-packages/cryptography/x509/extensions.py +2528 -0
  213. package/python/lib/python3.12/site-packages/cryptography/x509/general_name.py +281 -0
  214. package/python/lib/python3.12/site-packages/cryptography/x509/name.py +477 -0
  215. package/python/lib/python3.12/site-packages/cryptography/x509/ocsp.py +379 -0
  216. package/python/lib/python3.12/site-packages/cryptography/x509/oid.py +37 -0
  217. package/python/lib/python3.12/site-packages/cryptography/x509/verification.py +34 -0
  218. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/INSTALLER +1 -0
  219. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/METADATA +139 -0
  220. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/RECORD +106 -0
  221. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/REQUESTED +0 -0
  222. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/WHEEL +4 -0
  223. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE +3 -0
  224. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE.APACHE +202 -0
  225. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE.BSD +27 -0
  226. package/python/lib/python3.12/site-packages/pycparser/__init__.py +99 -0
  227. package/python/lib/python3.12/site-packages/pycparser/_ast_gen.py +355 -0
  228. package/python/lib/python3.12/site-packages/pycparser/_c_ast.cfg +195 -0
  229. package/python/lib/python3.12/site-packages/pycparser/ast_transforms.py +174 -0
  230. package/python/lib/python3.12/site-packages/pycparser/c_ast.py +1341 -0
  231. package/python/lib/python3.12/site-packages/pycparser/c_generator.py +573 -0
  232. package/python/lib/python3.12/site-packages/pycparser/c_lexer.py +706 -0
  233. package/python/lib/python3.12/site-packages/pycparser/c_parser.py +2376 -0
  234. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/INSTALLER +1 -0
  235. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/METADATA +244 -0
  236. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/RECORD +14 -0
  237. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/WHEEL +5 -0
  238. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/licenses/LICENSE +27 -0
  239. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/top_level.txt +1 -0
  240. package/python/lib/python3.12/sqlite3/__pycache__/__init__.cpython-312.pyc +0 -0
  241. package/python/lib/python3.12/sqlite3/__pycache__/dbapi2.cpython-312.pyc +0 -0
  242. package/python/lib/python3.12/urllib/__pycache__/__init__.cpython-312.pyc +0 -0
  243. package/python/lib/python3.12/urllib/__pycache__/error.cpython-312.pyc +0 -0
  244. package/python/lib/python3.12/urllib/__pycache__/parse.cpython-312.pyc +0 -0
  245. package/python/lib/python3.12/urllib/__pycache__/request.cpython-312.pyc +0 -0
  246. package/python/lib/python3.12/urllib/__pycache__/response.cpython-312.pyc +0 -0
  247. package/python/lib/python3.12/xml/__pycache__/__init__.cpython-312.pyc +0 -0
  248. package/python/lib/python3.12/xml/parsers/__pycache__/__init__.cpython-312.pyc +0 -0
  249. package/python/lib/python3.12/xml/parsers/__pycache__/expat.cpython-312.pyc +0 -0
@@ -0,0 +1,1087 @@
1
+ #
2
+ # DEPRECATED: implementation for ffi.verify()
3
+ #
4
+ import sys
5
+ from . import model
6
+ from .error import VerificationError
7
+ from . import _imp_emulation as imp
8
+
9
+
10
+ class VCPythonEngine(object):
11
+ _class_key = 'x'
12
+ _gen_python_module = True
13
+
14
+ def __init__(self, verifier):
15
+ self.verifier = verifier
16
+ self.ffi = verifier.ffi
17
+ self._struct_pending_verification = {}
18
+ self._types_of_builtin_functions = {}
19
+
20
+ def patch_extension_kwds(self, kwds):
21
+ pass
22
+
23
+ def find_module(self, module_name, path, so_suffixes):
24
+ try:
25
+ f, filename, descr = imp.find_module(module_name, path)
26
+ except ImportError:
27
+ return None
28
+ if f is not None:
29
+ f.close()
30
+ # Note that after a setuptools installation, there are both .py
31
+ # and .so files with the same basename. The code here relies on
32
+ # imp.find_module() locating the .so in priority.
33
+ if descr[0] not in so_suffixes:
34
+ return None
35
+ return filename
36
+
37
+ def collect_types(self):
38
+ self._typesdict = {}
39
+ self._generate("collecttype")
40
+
41
+ def _prnt(self, what=''):
42
+ self._f.write(what + '\n')
43
+
44
+ def _gettypenum(self, type):
45
+ # a KeyError here is a bug. please report it! :-)
46
+ return self._typesdict[type]
47
+
48
+ def _do_collect_type(self, tp):
49
+ if ((not isinstance(tp, model.PrimitiveType)
50
+ or tp.name == 'long double')
51
+ and tp not in self._typesdict):
52
+ num = len(self._typesdict)
53
+ self._typesdict[tp] = num
54
+
55
+ def write_source_to_f(self):
56
+ self.collect_types()
57
+ #
58
+ # The new module will have a _cffi_setup() function that receives
59
+ # objects from the ffi world, and that calls some setup code in
60
+ # the module. This setup code is split in several independent
61
+ # functions, e.g. one per constant. The functions are "chained"
62
+ # by ending in a tail call to each other.
63
+ #
64
+ # This is further split in two chained lists, depending on if we
65
+ # can do it at import-time or if we must wait for _cffi_setup() to
66
+ # provide us with the <ctype> objects. This is needed because we
67
+ # need the values of the enum constants in order to build the
68
+ # <ctype 'enum'> that we may have to pass to _cffi_setup().
69
+ #
70
+ # The following two 'chained_list_constants' items contains
71
+ # the head of these two chained lists, as a string that gives the
72
+ # call to do, if any.
73
+ self._chained_list_constants = ['((void)lib,0)', '((void)lib,0)']
74
+ #
75
+ prnt = self._prnt
76
+ # first paste some standard set of lines that are mostly '#define'
77
+ prnt(cffimod_header)
78
+ prnt()
79
+ # then paste the C source given by the user, verbatim.
80
+ prnt(self.verifier.preamble)
81
+ prnt()
82
+ #
83
+ # call generate_cpy_xxx_decl(), for every xxx found from
84
+ # ffi._parser._declarations. This generates all the functions.
85
+ self._generate("decl")
86
+ #
87
+ # implement the function _cffi_setup_custom() as calling the
88
+ # head of the chained list.
89
+ self._generate_setup_custom()
90
+ prnt()
91
+ #
92
+ # produce the method table, including the entries for the
93
+ # generated Python->C function wrappers, which are done
94
+ # by generate_cpy_function_method().
95
+ prnt('static PyMethodDef _cffi_methods[] = {')
96
+ self._generate("method")
97
+ prnt(' {"_cffi_setup", _cffi_setup, METH_VARARGS, NULL},')
98
+ prnt(' {NULL, NULL, 0, NULL} /* Sentinel */')
99
+ prnt('};')
100
+ prnt()
101
+ #
102
+ # standard init.
103
+ modname = self.verifier.get_module_name()
104
+ constants = self._chained_list_constants[False]
105
+ prnt('#if PY_MAJOR_VERSION >= 3')
106
+ prnt()
107
+ prnt('static struct PyModuleDef _cffi_module_def = {')
108
+ prnt(' PyModuleDef_HEAD_INIT,')
109
+ prnt(' "%s",' % modname)
110
+ prnt(' NULL,')
111
+ prnt(' -1,')
112
+ prnt(' _cffi_methods,')
113
+ prnt(' NULL, NULL, NULL, NULL')
114
+ prnt('};')
115
+ prnt()
116
+ prnt('PyMODINIT_FUNC')
117
+ prnt('PyInit_%s(void)' % modname)
118
+ prnt('{')
119
+ prnt(' PyObject *lib;')
120
+ prnt(' lib = PyModule_Create(&_cffi_module_def);')
121
+ prnt(' if (lib == NULL)')
122
+ prnt(' return NULL;')
123
+ prnt(' if (%s < 0 || _cffi_init() < 0) {' % (constants,))
124
+ prnt(' Py_DECREF(lib);')
125
+ prnt(' return NULL;')
126
+ prnt(' }')
127
+ prnt('#if Py_GIL_DISABLED')
128
+ prnt(' PyUnstable_Module_SetGIL(lib, Py_MOD_GIL_NOT_USED);')
129
+ prnt('#endif')
130
+ prnt(' return lib;')
131
+ prnt('}')
132
+ prnt()
133
+ prnt('#else')
134
+ prnt()
135
+ prnt('PyMODINIT_FUNC')
136
+ prnt('init%s(void)' % modname)
137
+ prnt('{')
138
+ prnt(' PyObject *lib;')
139
+ prnt(' lib = Py_InitModule("%s", _cffi_methods);' % modname)
140
+ prnt(' if (lib == NULL)')
141
+ prnt(' return;')
142
+ prnt(' if (%s < 0 || _cffi_init() < 0)' % (constants,))
143
+ prnt(' return;')
144
+ prnt(' return;')
145
+ prnt('}')
146
+ prnt()
147
+ prnt('#endif')
148
+
149
+ def load_library(self, flags=None):
150
+ # XXX review all usages of 'self' here!
151
+ # import it as a new extension module
152
+ imp.acquire_lock()
153
+ try:
154
+ if hasattr(sys, "getdlopenflags"):
155
+ previous_flags = sys.getdlopenflags()
156
+ try:
157
+ if hasattr(sys, "setdlopenflags") and flags is not None:
158
+ sys.setdlopenflags(flags)
159
+ module = imp.load_dynamic(self.verifier.get_module_name(),
160
+ self.verifier.modulefilename)
161
+ except ImportError as e:
162
+ error = "importing %r: %s" % (self.verifier.modulefilename, e)
163
+ raise VerificationError(error)
164
+ finally:
165
+ if hasattr(sys, "setdlopenflags"):
166
+ sys.setdlopenflags(previous_flags)
167
+ finally:
168
+ imp.release_lock()
169
+ #
170
+ # call loading_cpy_struct() to get the struct layout inferred by
171
+ # the C compiler
172
+ self._load(module, 'loading')
173
+ #
174
+ # the C code will need the <ctype> objects. Collect them in
175
+ # order in a list.
176
+ revmapping = dict([(value, key)
177
+ for (key, value) in self._typesdict.items()])
178
+ lst = [revmapping[i] for i in range(len(revmapping))]
179
+ lst = list(map(self.ffi._get_cached_btype, lst))
180
+ #
181
+ # build the FFILibrary class and instance and call _cffi_setup().
182
+ # this will set up some fields like '_cffi_types', and only then
183
+ # it will invoke the chained list of functions that will really
184
+ # build (notably) the constant objects, as <cdata> if they are
185
+ # pointers, and store them as attributes on the 'library' object.
186
+ class FFILibrary(object):
187
+ _cffi_python_module = module
188
+ _cffi_ffi = self.ffi
189
+ _cffi_dir = []
190
+ def __dir__(self):
191
+ return FFILibrary._cffi_dir + list(self.__dict__)
192
+ library = FFILibrary()
193
+ if module._cffi_setup(lst, VerificationError, library):
194
+ import warnings
195
+ warnings.warn("reimporting %r might overwrite older definitions"
196
+ % (self.verifier.get_module_name()))
197
+ #
198
+ # finally, call the loaded_cpy_xxx() functions. This will perform
199
+ # the final adjustments, like copying the Python->C wrapper
200
+ # functions from the module to the 'library' object, and setting
201
+ # up the FFILibrary class with properties for the global C variables.
202
+ self._load(module, 'loaded', library=library)
203
+ module._cffi_original_ffi = self.ffi
204
+ module._cffi_types_of_builtin_funcs = self._types_of_builtin_functions
205
+ return library
206
+
207
+ def _get_declarations(self):
208
+ lst = [(key, tp) for (key, (tp, qual)) in
209
+ self.ffi._parser._declarations.items()]
210
+ lst.sort()
211
+ return lst
212
+
213
+ def _generate(self, step_name):
214
+ for name, tp in self._get_declarations():
215
+ kind, realname = name.split(' ', 1)
216
+ try:
217
+ method = getattr(self, '_generate_cpy_%s_%s' % (kind,
218
+ step_name))
219
+ except AttributeError:
220
+ raise VerificationError(
221
+ "not implemented in verify(): %r" % name)
222
+ try:
223
+ method(tp, realname)
224
+ except Exception as e:
225
+ model.attach_exception_info(e, name)
226
+ raise
227
+
228
+ def _load(self, module, step_name, **kwds):
229
+ for name, tp in self._get_declarations():
230
+ kind, realname = name.split(' ', 1)
231
+ method = getattr(self, '_%s_cpy_%s' % (step_name, kind))
232
+ try:
233
+ method(tp, realname, module, **kwds)
234
+ except Exception as e:
235
+ model.attach_exception_info(e, name)
236
+ raise
237
+
238
+ def _generate_nothing(self, tp, name):
239
+ pass
240
+
241
+ def _loaded_noop(self, tp, name, module, **kwds):
242
+ pass
243
+
244
+ # ----------
245
+
246
+ def _convert_funcarg_to_c(self, tp, fromvar, tovar, errcode):
247
+ extraarg = ''
248
+ if isinstance(tp, model.PrimitiveType):
249
+ if tp.is_integer_type() and tp.name != '_Bool':
250
+ converter = '_cffi_to_c_int'
251
+ extraarg = ', %s' % tp.name
252
+ elif tp.is_complex_type():
253
+ raise VerificationError(
254
+ "not implemented in verify(): complex types")
255
+ else:
256
+ converter = '(%s)_cffi_to_c_%s' % (tp.get_c_name(''),
257
+ tp.name.replace(' ', '_'))
258
+ errvalue = '-1'
259
+ #
260
+ elif isinstance(tp, model.PointerType):
261
+ self._convert_funcarg_to_c_ptr_or_array(tp, fromvar,
262
+ tovar, errcode)
263
+ return
264
+ #
265
+ elif isinstance(tp, (model.StructOrUnion, model.EnumType)):
266
+ # a struct (not a struct pointer) as a function argument
267
+ self._prnt(' if (_cffi_to_c((char *)&%s, _cffi_type(%d), %s) < 0)'
268
+ % (tovar, self._gettypenum(tp), fromvar))
269
+ self._prnt(' %s;' % errcode)
270
+ return
271
+ #
272
+ elif isinstance(tp, model.FunctionPtrType):
273
+ converter = '(%s)_cffi_to_c_pointer' % tp.get_c_name('')
274
+ extraarg = ', _cffi_type(%d)' % self._gettypenum(tp)
275
+ errvalue = 'NULL'
276
+ #
277
+ else:
278
+ raise NotImplementedError(tp)
279
+ #
280
+ self._prnt(' %s = %s(%s%s);' % (tovar, converter, fromvar, extraarg))
281
+ self._prnt(' if (%s == (%s)%s && PyErr_Occurred())' % (
282
+ tovar, tp.get_c_name(''), errvalue))
283
+ self._prnt(' %s;' % errcode)
284
+
285
+ def _extra_local_variables(self, tp, localvars, freelines):
286
+ if isinstance(tp, model.PointerType):
287
+ localvars.add('Py_ssize_t datasize')
288
+ localvars.add('struct _cffi_freeme_s *large_args_free = NULL')
289
+ freelines.add('if (large_args_free != NULL)'
290
+ ' _cffi_free_array_arguments(large_args_free);')
291
+
292
+ def _convert_funcarg_to_c_ptr_or_array(self, tp, fromvar, tovar, errcode):
293
+ self._prnt(' datasize = _cffi_prepare_pointer_call_argument(')
294
+ self._prnt(' _cffi_type(%d), %s, (char **)&%s);' % (
295
+ self._gettypenum(tp), fromvar, tovar))
296
+ self._prnt(' if (datasize != 0) {')
297
+ self._prnt(' %s = ((size_t)datasize) <= 640 ? '
298
+ 'alloca((size_t)datasize) : NULL;' % (tovar,))
299
+ self._prnt(' if (_cffi_convert_array_argument(_cffi_type(%d), %s, '
300
+ '(char **)&%s,' % (self._gettypenum(tp), fromvar, tovar))
301
+ self._prnt(' datasize, &large_args_free) < 0)')
302
+ self._prnt(' %s;' % errcode)
303
+ self._prnt(' }')
304
+
305
+ def _convert_expr_from_c(self, tp, var, context):
306
+ if isinstance(tp, model.PrimitiveType):
307
+ if tp.is_integer_type() and tp.name != '_Bool':
308
+ return '_cffi_from_c_int(%s, %s)' % (var, tp.name)
309
+ elif tp.name != 'long double':
310
+ return '_cffi_from_c_%s(%s)' % (tp.name.replace(' ', '_'), var)
311
+ else:
312
+ return '_cffi_from_c_deref((char *)&%s, _cffi_type(%d))' % (
313
+ var, self._gettypenum(tp))
314
+ elif isinstance(tp, (model.PointerType, model.FunctionPtrType)):
315
+ return '_cffi_from_c_pointer((char *)%s, _cffi_type(%d))' % (
316
+ var, self._gettypenum(tp))
317
+ elif isinstance(tp, model.ArrayType):
318
+ return '_cffi_from_c_pointer((char *)%s, _cffi_type(%d))' % (
319
+ var, self._gettypenum(model.PointerType(tp.item)))
320
+ elif isinstance(tp, model.StructOrUnion):
321
+ if tp.fldnames is None:
322
+ raise TypeError("'%s' is used as %s, but is opaque" % (
323
+ tp._get_c_name(), context))
324
+ return '_cffi_from_c_struct((char *)&%s, _cffi_type(%d))' % (
325
+ var, self._gettypenum(tp))
326
+ elif isinstance(tp, model.EnumType):
327
+ return '_cffi_from_c_deref((char *)&%s, _cffi_type(%d))' % (
328
+ var, self._gettypenum(tp))
329
+ else:
330
+ raise NotImplementedError(tp)
331
+
332
+ # ----------
333
+ # typedefs: generates no code so far
334
+
335
+ _generate_cpy_typedef_collecttype = _generate_nothing
336
+ _generate_cpy_typedef_decl = _generate_nothing
337
+ _generate_cpy_typedef_method = _generate_nothing
338
+ _loading_cpy_typedef = _loaded_noop
339
+ _loaded_cpy_typedef = _loaded_noop
340
+
341
+ # ----------
342
+ # function declarations
343
+
344
+ def _generate_cpy_function_collecttype(self, tp, name):
345
+ assert isinstance(tp, model.FunctionPtrType)
346
+ if tp.ellipsis:
347
+ self._do_collect_type(tp)
348
+ else:
349
+ # don't call _do_collect_type(tp) in this common case,
350
+ # otherwise test_autofilled_struct_as_argument fails
351
+ for type in tp.args:
352
+ self._do_collect_type(type)
353
+ self._do_collect_type(tp.result)
354
+
355
+ def _generate_cpy_function_decl(self, tp, name):
356
+ assert isinstance(tp, model.FunctionPtrType)
357
+ if tp.ellipsis:
358
+ # cannot support vararg functions better than this: check for its
359
+ # exact type (including the fixed arguments), and build it as a
360
+ # constant function pointer (no CPython wrapper)
361
+ self._generate_cpy_const(False, name, tp)
362
+ return
363
+ prnt = self._prnt
364
+ numargs = len(tp.args)
365
+ if numargs == 0:
366
+ argname = 'noarg'
367
+ elif numargs == 1:
368
+ argname = 'arg0'
369
+ else:
370
+ argname = 'args'
371
+ prnt('static PyObject *')
372
+ prnt('_cffi_f_%s(PyObject *self, PyObject *%s)' % (name, argname))
373
+ prnt('{')
374
+ #
375
+ context = 'argument of %s' % name
376
+ for i, type in enumerate(tp.args):
377
+ prnt(' %s;' % type.get_c_name(' x%d' % i, context))
378
+ #
379
+ localvars = set()
380
+ freelines = set()
381
+ for type in tp.args:
382
+ self._extra_local_variables(type, localvars, freelines)
383
+ for decl in sorted(localvars):
384
+ prnt(' %s;' % (decl,))
385
+ #
386
+ if not isinstance(tp.result, model.VoidType):
387
+ result_code = 'result = '
388
+ context = 'result of %s' % name
389
+ prnt(' %s;' % tp.result.get_c_name(' result', context))
390
+ prnt(' PyObject *pyresult;')
391
+ else:
392
+ result_code = ''
393
+ #
394
+ if len(tp.args) > 1:
395
+ rng = range(len(tp.args))
396
+ for i in rng:
397
+ prnt(' PyObject *arg%d;' % i)
398
+ prnt()
399
+ prnt(' if (!PyArg_ParseTuple(args, "%s:%s", %s))' % (
400
+ 'O' * numargs, name, ', '.join(['&arg%d' % i for i in rng])))
401
+ prnt(' return NULL;')
402
+ prnt()
403
+ #
404
+ for i, type in enumerate(tp.args):
405
+ self._convert_funcarg_to_c(type, 'arg%d' % i, 'x%d' % i,
406
+ 'return NULL')
407
+ prnt()
408
+ #
409
+ prnt(' Py_BEGIN_ALLOW_THREADS')
410
+ prnt(' _cffi_restore_errno();')
411
+ prnt(' { %s%s(%s); }' % (
412
+ result_code, name,
413
+ ', '.join(['x%d' % i for i in range(len(tp.args))])))
414
+ prnt(' _cffi_save_errno();')
415
+ prnt(' Py_END_ALLOW_THREADS')
416
+ prnt()
417
+ #
418
+ prnt(' (void)self; /* unused */')
419
+ if numargs == 0:
420
+ prnt(' (void)noarg; /* unused */')
421
+ if result_code:
422
+ prnt(' pyresult = %s;' %
423
+ self._convert_expr_from_c(tp.result, 'result', 'result type'))
424
+ for freeline in freelines:
425
+ prnt(' ' + freeline)
426
+ prnt(' return pyresult;')
427
+ else:
428
+ for freeline in freelines:
429
+ prnt(' ' + freeline)
430
+ prnt(' Py_INCREF(Py_None);')
431
+ prnt(' return Py_None;')
432
+ prnt('}')
433
+ prnt()
434
+
435
+ def _generate_cpy_function_method(self, tp, name):
436
+ if tp.ellipsis:
437
+ return
438
+ numargs = len(tp.args)
439
+ if numargs == 0:
440
+ meth = 'METH_NOARGS'
441
+ elif numargs == 1:
442
+ meth = 'METH_O'
443
+ else:
444
+ meth = 'METH_VARARGS'
445
+ self._prnt(' {"%s", _cffi_f_%s, %s, NULL},' % (name, name, meth))
446
+
447
+ _loading_cpy_function = _loaded_noop
448
+
449
+ def _loaded_cpy_function(self, tp, name, module, library):
450
+ if tp.ellipsis:
451
+ return
452
+ func = getattr(module, name)
453
+ setattr(library, name, func)
454
+ self._types_of_builtin_functions[func] = tp
455
+
456
+ # ----------
457
+ # named structs
458
+
459
+ _generate_cpy_struct_collecttype = _generate_nothing
460
+ def _generate_cpy_struct_decl(self, tp, name):
461
+ assert name == tp.name
462
+ self._generate_struct_or_union_decl(tp, 'struct', name)
463
+ def _generate_cpy_struct_method(self, tp, name):
464
+ self._generate_struct_or_union_method(tp, 'struct', name)
465
+ def _loading_cpy_struct(self, tp, name, module):
466
+ self._loading_struct_or_union(tp, 'struct', name, module)
467
+ def _loaded_cpy_struct(self, tp, name, module, **kwds):
468
+ self._loaded_struct_or_union(tp)
469
+
470
+ _generate_cpy_union_collecttype = _generate_nothing
471
+ def _generate_cpy_union_decl(self, tp, name):
472
+ assert name == tp.name
473
+ self._generate_struct_or_union_decl(tp, 'union', name)
474
+ def _generate_cpy_union_method(self, tp, name):
475
+ self._generate_struct_or_union_method(tp, 'union', name)
476
+ def _loading_cpy_union(self, tp, name, module):
477
+ self._loading_struct_or_union(tp, 'union', name, module)
478
+ def _loaded_cpy_union(self, tp, name, module, **kwds):
479
+ self._loaded_struct_or_union(tp)
480
+
481
+ def _generate_struct_or_union_decl(self, tp, prefix, name):
482
+ if tp.fldnames is None:
483
+ return # nothing to do with opaque structs
484
+ checkfuncname = '_cffi_check_%s_%s' % (prefix, name)
485
+ layoutfuncname = '_cffi_layout_%s_%s' % (prefix, name)
486
+ cname = ('%s %s' % (prefix, name)).strip()
487
+ #
488
+ prnt = self._prnt
489
+ prnt('static void %s(%s *p)' % (checkfuncname, cname))
490
+ prnt('{')
491
+ prnt(' /* only to generate compile-time warnings or errors */')
492
+ prnt(' (void)p;')
493
+ for fname, ftype, fbitsize, fqual in tp.enumfields():
494
+ if (isinstance(ftype, model.PrimitiveType)
495
+ and ftype.is_integer_type()) or fbitsize >= 0:
496
+ # accept all integers, but complain on float or double
497
+ prnt(' (void)((p->%s) << 1);' % fname)
498
+ else:
499
+ # only accept exactly the type declared.
500
+ try:
501
+ prnt(' { %s = &p->%s; (void)tmp; }' % (
502
+ ftype.get_c_name('*tmp', 'field %r'%fname, quals=fqual),
503
+ fname))
504
+ except VerificationError as e:
505
+ prnt(' /* %s */' % str(e)) # cannot verify it, ignore
506
+ prnt('}')
507
+ prnt('static PyObject *')
508
+ prnt('%s(PyObject *self, PyObject *noarg)' % (layoutfuncname,))
509
+ prnt('{')
510
+ prnt(' struct _cffi_aligncheck { char x; %s y; };' % cname)
511
+ prnt(' static Py_ssize_t nums[] = {')
512
+ prnt(' sizeof(%s),' % cname)
513
+ prnt(' offsetof(struct _cffi_aligncheck, y),')
514
+ for fname, ftype, fbitsize, fqual in tp.enumfields():
515
+ if fbitsize >= 0:
516
+ continue # xxx ignore fbitsize for now
517
+ prnt(' offsetof(%s, %s),' % (cname, fname))
518
+ if isinstance(ftype, model.ArrayType) and ftype.length is None:
519
+ prnt(' 0, /* %s */' % ftype._get_c_name())
520
+ else:
521
+ prnt(' sizeof(((%s *)0)->%s),' % (cname, fname))
522
+ prnt(' -1')
523
+ prnt(' };')
524
+ prnt(' (void)self; /* unused */')
525
+ prnt(' (void)noarg; /* unused */')
526
+ prnt(' return _cffi_get_struct_layout(nums);')
527
+ prnt(' /* the next line is not executed, but compiled */')
528
+ prnt(' %s(0);' % (checkfuncname,))
529
+ prnt('}')
530
+ prnt()
531
+
532
+ def _generate_struct_or_union_method(self, tp, prefix, name):
533
+ if tp.fldnames is None:
534
+ return # nothing to do with opaque structs
535
+ layoutfuncname = '_cffi_layout_%s_%s' % (prefix, name)
536
+ self._prnt(' {"%s", %s, METH_NOARGS, NULL},' % (layoutfuncname,
537
+ layoutfuncname))
538
+
539
+ def _loading_struct_or_union(self, tp, prefix, name, module):
540
+ if tp.fldnames is None:
541
+ return # nothing to do with opaque structs
542
+ layoutfuncname = '_cffi_layout_%s_%s' % (prefix, name)
543
+ #
544
+ function = getattr(module, layoutfuncname)
545
+ layout = function()
546
+ if isinstance(tp, model.StructOrUnion) and tp.partial:
547
+ # use the function()'s sizes and offsets to guide the
548
+ # layout of the struct
549
+ totalsize = layout[0]
550
+ totalalignment = layout[1]
551
+ fieldofs = layout[2::2]
552
+ fieldsize = layout[3::2]
553
+ tp.force_flatten()
554
+ assert len(fieldofs) == len(fieldsize) == len(tp.fldnames)
555
+ tp.fixedlayout = fieldofs, fieldsize, totalsize, totalalignment
556
+ else:
557
+ cname = ('%s %s' % (prefix, name)).strip()
558
+ self._struct_pending_verification[tp] = layout, cname
559
+
560
+ def _loaded_struct_or_union(self, tp):
561
+ if tp.fldnames is None:
562
+ return # nothing to do with opaque structs
563
+ self.ffi._get_cached_btype(tp) # force 'fixedlayout' to be considered
564
+
565
+ if tp in self._struct_pending_verification:
566
+ # check that the layout sizes and offsets match the real ones
567
+ def check(realvalue, expectedvalue, msg):
568
+ if realvalue != expectedvalue:
569
+ raise VerificationError(
570
+ "%s (we have %d, but C compiler says %d)"
571
+ % (msg, expectedvalue, realvalue))
572
+ ffi = self.ffi
573
+ BStruct = ffi._get_cached_btype(tp)
574
+ layout, cname = self._struct_pending_verification.pop(tp)
575
+ check(layout[0], ffi.sizeof(BStruct), "wrong total size")
576
+ check(layout[1], ffi.alignof(BStruct), "wrong total alignment")
577
+ i = 2
578
+ for fname, ftype, fbitsize, fqual in tp.enumfields():
579
+ if fbitsize >= 0:
580
+ continue # xxx ignore fbitsize for now
581
+ check(layout[i], ffi.offsetof(BStruct, fname),
582
+ "wrong offset for field %r" % (fname,))
583
+ if layout[i+1] != 0:
584
+ BField = ffi._get_cached_btype(ftype)
585
+ check(layout[i+1], ffi.sizeof(BField),
586
+ "wrong size for field %r" % (fname,))
587
+ i += 2
588
+ assert i == len(layout)
589
+
590
+ # ----------
591
+ # 'anonymous' declarations. These are produced for anonymous structs
592
+ # or unions; the 'name' is obtained by a typedef.
593
+
594
+ _generate_cpy_anonymous_collecttype = _generate_nothing
595
+
596
+ def _generate_cpy_anonymous_decl(self, tp, name):
597
+ if isinstance(tp, model.EnumType):
598
+ self._generate_cpy_enum_decl(tp, name, '')
599
+ else:
600
+ self._generate_struct_or_union_decl(tp, '', name)
601
+
602
+ def _generate_cpy_anonymous_method(self, tp, name):
603
+ if not isinstance(tp, model.EnumType):
604
+ self._generate_struct_or_union_method(tp, '', name)
605
+
606
+ def _loading_cpy_anonymous(self, tp, name, module):
607
+ if isinstance(tp, model.EnumType):
608
+ self._loading_cpy_enum(tp, name, module)
609
+ else:
610
+ self._loading_struct_or_union(tp, '', name, module)
611
+
612
+ def _loaded_cpy_anonymous(self, tp, name, module, **kwds):
613
+ if isinstance(tp, model.EnumType):
614
+ self._loaded_cpy_enum(tp, name, module, **kwds)
615
+ else:
616
+ self._loaded_struct_or_union(tp)
617
+
618
+ # ----------
619
+ # constants, likely declared with '#define'
620
+
621
+ def _generate_cpy_const(self, is_int, name, tp=None, category='const',
622
+ vartp=None, delayed=True, size_too=False,
623
+ check_value=None):
624
+ prnt = self._prnt
625
+ funcname = '_cffi_%s_%s' % (category, name)
626
+ prnt('static int %s(PyObject *lib)' % funcname)
627
+ prnt('{')
628
+ prnt(' PyObject *o;')
629
+ prnt(' int res;')
630
+ if not is_int:
631
+ prnt(' %s;' % (vartp or tp).get_c_name(' i', name))
632
+ else:
633
+ assert category == 'const'
634
+ #
635
+ if check_value is not None:
636
+ self._check_int_constant_value(name, check_value)
637
+ #
638
+ if not is_int:
639
+ if category == 'var':
640
+ realexpr = '&' + name
641
+ else:
642
+ realexpr = name
643
+ prnt(' i = (%s);' % (realexpr,))
644
+ prnt(' o = %s;' % (self._convert_expr_from_c(tp, 'i',
645
+ 'variable type'),))
646
+ assert delayed
647
+ else:
648
+ prnt(' o = _cffi_from_c_int_const(%s);' % name)
649
+ prnt(' if (o == NULL)')
650
+ prnt(' return -1;')
651
+ if size_too:
652
+ prnt(' {')
653
+ prnt(' PyObject *o1 = o;')
654
+ prnt(' o = Py_BuildValue("On", o1, (Py_ssize_t)sizeof(%s));'
655
+ % (name,))
656
+ prnt(' Py_DECREF(o1);')
657
+ prnt(' if (o == NULL)')
658
+ prnt(' return -1;')
659
+ prnt(' }')
660
+ prnt(' res = PyObject_SetAttrString(lib, "%s", o);' % name)
661
+ prnt(' Py_DECREF(o);')
662
+ prnt(' if (res < 0)')
663
+ prnt(' return -1;')
664
+ prnt(' return %s;' % self._chained_list_constants[delayed])
665
+ self._chained_list_constants[delayed] = funcname + '(lib)'
666
+ prnt('}')
667
+ prnt()
668
+
669
+ def _generate_cpy_constant_collecttype(self, tp, name):
670
+ is_int = isinstance(tp, model.PrimitiveType) and tp.is_integer_type()
671
+ if not is_int:
672
+ self._do_collect_type(tp)
673
+
674
+ def _generate_cpy_constant_decl(self, tp, name):
675
+ is_int = isinstance(tp, model.PrimitiveType) and tp.is_integer_type()
676
+ self._generate_cpy_const(is_int, name, tp)
677
+
678
+ _generate_cpy_constant_method = _generate_nothing
679
+ _loading_cpy_constant = _loaded_noop
680
+ _loaded_cpy_constant = _loaded_noop
681
+
682
+ # ----------
683
+ # enums
684
+
685
+ def _check_int_constant_value(self, name, value, err_prefix=''):
686
+ prnt = self._prnt
687
+ if value <= 0:
688
+ prnt(' if ((%s) > 0 || (long)(%s) != %dL) {' % (
689
+ name, name, value))
690
+ else:
691
+ prnt(' if ((%s) <= 0 || (unsigned long)(%s) != %dUL) {' % (
692
+ name, name, value))
693
+ prnt(' char buf[64];')
694
+ prnt(' if ((%s) <= 0)' % name)
695
+ prnt(' snprintf(buf, 63, "%%ld", (long)(%s));' % name)
696
+ prnt(' else')
697
+ prnt(' snprintf(buf, 63, "%%lu", (unsigned long)(%s));' %
698
+ name)
699
+ prnt(' PyErr_Format(_cffi_VerificationError,')
700
+ prnt(' "%s%s has the real value %s, not %s",')
701
+ prnt(' "%s", "%s", buf, "%d");' % (
702
+ err_prefix, name, value))
703
+ prnt(' return -1;')
704
+ prnt(' }')
705
+
706
+ def _enum_funcname(self, prefix, name):
707
+ # "$enum_$1" => "___D_enum____D_1"
708
+ name = name.replace('$', '___D_')
709
+ return '_cffi_e_%s_%s' % (prefix, name)
710
+
711
+ def _generate_cpy_enum_decl(self, tp, name, prefix='enum'):
712
+ if tp.partial:
713
+ for enumerator in tp.enumerators:
714
+ self._generate_cpy_const(True, enumerator, delayed=False)
715
+ return
716
+ #
717
+ funcname = self._enum_funcname(prefix, name)
718
+ prnt = self._prnt
719
+ prnt('static int %s(PyObject *lib)' % funcname)
720
+ prnt('{')
721
+ for enumerator, enumvalue in zip(tp.enumerators, tp.enumvalues):
722
+ self._check_int_constant_value(enumerator, enumvalue,
723
+ "enum %s: " % name)
724
+ prnt(' return %s;' % self._chained_list_constants[True])
725
+ self._chained_list_constants[True] = funcname + '(lib)'
726
+ prnt('}')
727
+ prnt()
728
+
729
+ _generate_cpy_enum_collecttype = _generate_nothing
730
+ _generate_cpy_enum_method = _generate_nothing
731
+
732
+ def _loading_cpy_enum(self, tp, name, module):
733
+ if tp.partial:
734
+ enumvalues = [getattr(module, enumerator)
735
+ for enumerator in tp.enumerators]
736
+ tp.enumvalues = tuple(enumvalues)
737
+ tp.partial_resolved = True
738
+
739
+ def _loaded_cpy_enum(self, tp, name, module, library):
740
+ for enumerator, enumvalue in zip(tp.enumerators, tp.enumvalues):
741
+ setattr(library, enumerator, enumvalue)
742
+
743
+ # ----------
744
+ # macros: for now only for integers
745
+
746
+ def _generate_cpy_macro_decl(self, tp, name):
747
+ if tp == '...':
748
+ check_value = None
749
+ else:
750
+ check_value = tp # an integer
751
+ self._generate_cpy_const(True, name, check_value=check_value)
752
+
753
+ _generate_cpy_macro_collecttype = _generate_nothing
754
+ _generate_cpy_macro_method = _generate_nothing
755
+ _loading_cpy_macro = _loaded_noop
756
+ _loaded_cpy_macro = _loaded_noop
757
+
758
+ # ----------
759
+ # global variables
760
+
761
+ def _generate_cpy_variable_collecttype(self, tp, name):
762
+ if isinstance(tp, model.ArrayType):
763
+ tp_ptr = model.PointerType(tp.item)
764
+ else:
765
+ tp_ptr = model.PointerType(tp)
766
+ self._do_collect_type(tp_ptr)
767
+
768
+ def _generate_cpy_variable_decl(self, tp, name):
769
+ if isinstance(tp, model.ArrayType):
770
+ tp_ptr = model.PointerType(tp.item)
771
+ self._generate_cpy_const(False, name, tp, vartp=tp_ptr,
772
+ size_too = tp.length_is_unknown())
773
+ else:
774
+ tp_ptr = model.PointerType(tp)
775
+ self._generate_cpy_const(False, name, tp_ptr, category='var')
776
+
777
+ _generate_cpy_variable_method = _generate_nothing
778
+ _loading_cpy_variable = _loaded_noop
779
+
780
+ def _loaded_cpy_variable(self, tp, name, module, library):
781
+ value = getattr(library, name)
782
+ if isinstance(tp, model.ArrayType): # int a[5] is "constant" in the
783
+ # sense that "a=..." is forbidden
784
+ if tp.length_is_unknown():
785
+ assert isinstance(value, tuple)
786
+ (value, size) = value
787
+ BItemType = self.ffi._get_cached_btype(tp.item)
788
+ length, rest = divmod(size, self.ffi.sizeof(BItemType))
789
+ if rest != 0:
790
+ raise VerificationError(
791
+ "bad size: %r does not seem to be an array of %s" %
792
+ (name, tp.item))
793
+ tp = tp.resolve_length(length)
794
+ # 'value' is a <cdata 'type *'> which we have to replace with
795
+ # a <cdata 'type[N]'> if the N is actually known
796
+ if tp.length is not None:
797
+ BArray = self.ffi._get_cached_btype(tp)
798
+ value = self.ffi.cast(BArray, value)
799
+ setattr(library, name, value)
800
+ return
801
+ # remove ptr=<cdata 'int *'> from the library instance, and replace
802
+ # it by a property on the class, which reads/writes into ptr[0].
803
+ ptr = value
804
+ delattr(library, name)
805
+ def getter(library):
806
+ return ptr[0]
807
+ def setter(library, value):
808
+ ptr[0] = value
809
+ setattr(type(library), name, property(getter, setter))
810
+ type(library)._cffi_dir.append(name)
811
+
812
+ # ----------
813
+
814
+ def _generate_setup_custom(self):
815
+ prnt = self._prnt
816
+ prnt('static int _cffi_setup_custom(PyObject *lib)')
817
+ prnt('{')
818
+ prnt(' return %s;' % self._chained_list_constants[True])
819
+ prnt('}')
820
+
821
+ cffimod_header = r'''
822
+ #include <Python.h>
823
+ #include <stddef.h>
824
+
825
+ /* this block of #ifs should be kept exactly identical between
826
+ c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py
827
+ and cffi/_cffi_include.h */
828
+ #if defined(_MSC_VER)
829
+ # include <malloc.h> /* for alloca() */
830
+ # if _MSC_VER < 1600 /* MSVC < 2010 */
831
+ typedef __int8 int8_t;
832
+ typedef __int16 int16_t;
833
+ typedef __int32 int32_t;
834
+ typedef __int64 int64_t;
835
+ typedef unsigned __int8 uint8_t;
836
+ typedef unsigned __int16 uint16_t;
837
+ typedef unsigned __int32 uint32_t;
838
+ typedef unsigned __int64 uint64_t;
839
+ typedef __int8 int_least8_t;
840
+ typedef __int16 int_least16_t;
841
+ typedef __int32 int_least32_t;
842
+ typedef __int64 int_least64_t;
843
+ typedef unsigned __int8 uint_least8_t;
844
+ typedef unsigned __int16 uint_least16_t;
845
+ typedef unsigned __int32 uint_least32_t;
846
+ typedef unsigned __int64 uint_least64_t;
847
+ typedef __int8 int_fast8_t;
848
+ typedef __int16 int_fast16_t;
849
+ typedef __int32 int_fast32_t;
850
+ typedef __int64 int_fast64_t;
851
+ typedef unsigned __int8 uint_fast8_t;
852
+ typedef unsigned __int16 uint_fast16_t;
853
+ typedef unsigned __int32 uint_fast32_t;
854
+ typedef unsigned __int64 uint_fast64_t;
855
+ typedef __int64 intmax_t;
856
+ typedef unsigned __int64 uintmax_t;
857
+ # else
858
+ # include <stdint.h>
859
+ # endif
860
+ # if _MSC_VER < 1800 /* MSVC < 2013 */
861
+ # ifndef __cplusplus
862
+ typedef unsigned char _Bool;
863
+ # endif
864
+ # endif
865
+ # define _cffi_float_complex_t _Fcomplex /* include <complex.h> for it */
866
+ # define _cffi_double_complex_t _Dcomplex /* include <complex.h> for it */
867
+ #else
868
+ # include <stdint.h>
869
+ # if (defined (__SVR4) && defined (__sun)) || defined(_AIX) || defined(__hpux)
870
+ # include <alloca.h>
871
+ # endif
872
+ # define _cffi_float_complex_t float _Complex
873
+ # define _cffi_double_complex_t double _Complex
874
+ #endif
875
+
876
+ #if PY_MAJOR_VERSION < 3
877
+ # undef PyCapsule_CheckExact
878
+ # undef PyCapsule_GetPointer
879
+ # define PyCapsule_CheckExact(capsule) (PyCObject_Check(capsule))
880
+ # define PyCapsule_GetPointer(capsule, name) \
881
+ (PyCObject_AsVoidPtr(capsule))
882
+ #endif
883
+
884
+ #if PY_MAJOR_VERSION >= 3
885
+ # define PyInt_FromLong PyLong_FromLong
886
+ #endif
887
+
888
+ #define _cffi_from_c_double PyFloat_FromDouble
889
+ #define _cffi_from_c_float PyFloat_FromDouble
890
+ #define _cffi_from_c_long PyInt_FromLong
891
+ #define _cffi_from_c_ulong PyLong_FromUnsignedLong
892
+ #define _cffi_from_c_longlong PyLong_FromLongLong
893
+ #define _cffi_from_c_ulonglong PyLong_FromUnsignedLongLong
894
+ #define _cffi_from_c__Bool PyBool_FromLong
895
+
896
+ #define _cffi_to_c_double PyFloat_AsDouble
897
+ #define _cffi_to_c_float PyFloat_AsDouble
898
+
899
+ #define _cffi_from_c_int_const(x) \
900
+ (((x) > 0) ? \
901
+ ((unsigned long long)(x) <= (unsigned long long)LONG_MAX) ? \
902
+ PyInt_FromLong((long)(x)) : \
903
+ PyLong_FromUnsignedLongLong((unsigned long long)(x)) : \
904
+ ((long long)(x) >= (long long)LONG_MIN) ? \
905
+ PyInt_FromLong((long)(x)) : \
906
+ PyLong_FromLongLong((long long)(x)))
907
+
908
+ #define _cffi_from_c_int(x, type) \
909
+ (((type)-1) > 0 ? /* unsigned */ \
910
+ (sizeof(type) < sizeof(long) ? \
911
+ PyInt_FromLong((long)x) : \
912
+ sizeof(type) == sizeof(long) ? \
913
+ PyLong_FromUnsignedLong((unsigned long)x) : \
914
+ PyLong_FromUnsignedLongLong((unsigned long long)x)) : \
915
+ (sizeof(type) <= sizeof(long) ? \
916
+ PyInt_FromLong((long)x) : \
917
+ PyLong_FromLongLong((long long)x)))
918
+
919
+ #define _cffi_to_c_int(o, type) \
920
+ ((type)( \
921
+ sizeof(type) == 1 ? (((type)-1) > 0 ? (type)_cffi_to_c_u8(o) \
922
+ : (type)_cffi_to_c_i8(o)) : \
923
+ sizeof(type) == 2 ? (((type)-1) > 0 ? (type)_cffi_to_c_u16(o) \
924
+ : (type)_cffi_to_c_i16(o)) : \
925
+ sizeof(type) == 4 ? (((type)-1) > 0 ? (type)_cffi_to_c_u32(o) \
926
+ : (type)_cffi_to_c_i32(o)) : \
927
+ sizeof(type) == 8 ? (((type)-1) > 0 ? (type)_cffi_to_c_u64(o) \
928
+ : (type)_cffi_to_c_i64(o)) : \
929
+ (Py_FatalError("unsupported size for type " #type), (type)0)))
930
+
931
+ #define _cffi_to_c_i8 \
932
+ ((int(*)(PyObject *))_cffi_exports[1])
933
+ #define _cffi_to_c_u8 \
934
+ ((int(*)(PyObject *))_cffi_exports[2])
935
+ #define _cffi_to_c_i16 \
936
+ ((int(*)(PyObject *))_cffi_exports[3])
937
+ #define _cffi_to_c_u16 \
938
+ ((int(*)(PyObject *))_cffi_exports[4])
939
+ #define _cffi_to_c_i32 \
940
+ ((int(*)(PyObject *))_cffi_exports[5])
941
+ #define _cffi_to_c_u32 \
942
+ ((unsigned int(*)(PyObject *))_cffi_exports[6])
943
+ #define _cffi_to_c_i64 \
944
+ ((long long(*)(PyObject *))_cffi_exports[7])
945
+ #define _cffi_to_c_u64 \
946
+ ((unsigned long long(*)(PyObject *))_cffi_exports[8])
947
+ #define _cffi_to_c_char \
948
+ ((int(*)(PyObject *))_cffi_exports[9])
949
+ #define _cffi_from_c_pointer \
950
+ ((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[10])
951
+ #define _cffi_to_c_pointer \
952
+ ((char *(*)(PyObject *, CTypeDescrObject *))_cffi_exports[11])
953
+ #define _cffi_get_struct_layout \
954
+ ((PyObject *(*)(Py_ssize_t[]))_cffi_exports[12])
955
+ #define _cffi_restore_errno \
956
+ ((void(*)(void))_cffi_exports[13])
957
+ #define _cffi_save_errno \
958
+ ((void(*)(void))_cffi_exports[14])
959
+ #define _cffi_from_c_char \
960
+ ((PyObject *(*)(char))_cffi_exports[15])
961
+ #define _cffi_from_c_deref \
962
+ ((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[16])
963
+ #define _cffi_to_c \
964
+ ((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[17])
965
+ #define _cffi_from_c_struct \
966
+ ((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[18])
967
+ #define _cffi_to_c_wchar_t \
968
+ ((wchar_t(*)(PyObject *))_cffi_exports[19])
969
+ #define _cffi_from_c_wchar_t \
970
+ ((PyObject *(*)(wchar_t))_cffi_exports[20])
971
+ #define _cffi_to_c_long_double \
972
+ ((long double(*)(PyObject *))_cffi_exports[21])
973
+ #define _cffi_to_c__Bool \
974
+ ((_Bool(*)(PyObject *))_cffi_exports[22])
975
+ #define _cffi_prepare_pointer_call_argument \
976
+ ((Py_ssize_t(*)(CTypeDescrObject *, PyObject *, char **))_cffi_exports[23])
977
+ #define _cffi_convert_array_from_object \
978
+ ((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[24])
979
+ #define _CFFI_NUM_EXPORTS 25
980
+
981
+ typedef struct _ctypedescr CTypeDescrObject;
982
+
983
+ static void *_cffi_exports[_CFFI_NUM_EXPORTS];
984
+ static PyObject *_cffi_types, *_cffi_VerificationError;
985
+
986
+ static int _cffi_setup_custom(PyObject *lib); /* forward */
987
+
988
+ static PyObject *_cffi_setup(PyObject *self, PyObject *args)
989
+ {
990
+ PyObject *library;
991
+ int was_alive = (_cffi_types != NULL);
992
+ (void)self; /* unused */
993
+ if (!PyArg_ParseTuple(args, "OOO", &_cffi_types, &_cffi_VerificationError,
994
+ &library))
995
+ return NULL;
996
+ Py_INCREF(_cffi_types);
997
+ Py_INCREF(_cffi_VerificationError);
998
+ if (_cffi_setup_custom(library) < 0)
999
+ return NULL;
1000
+ return PyBool_FromLong(was_alive);
1001
+ }
1002
+
1003
+ union _cffi_union_alignment_u {
1004
+ unsigned char m_char;
1005
+ unsigned short m_short;
1006
+ unsigned int m_int;
1007
+ unsigned long m_long;
1008
+ unsigned long long m_longlong;
1009
+ float m_float;
1010
+ double m_double;
1011
+ long double m_longdouble;
1012
+ };
1013
+
1014
+ struct _cffi_freeme_s {
1015
+ struct _cffi_freeme_s *next;
1016
+ union _cffi_union_alignment_u alignment;
1017
+ };
1018
+
1019
+ #ifdef __GNUC__
1020
+ __attribute__((unused))
1021
+ #endif
1022
+ static int _cffi_convert_array_argument(CTypeDescrObject *ctptr, PyObject *arg,
1023
+ char **output_data, Py_ssize_t datasize,
1024
+ struct _cffi_freeme_s **freeme)
1025
+ {
1026
+ char *p;
1027
+ if (datasize < 0)
1028
+ return -1;
1029
+
1030
+ p = *output_data;
1031
+ if (p == NULL) {
1032
+ struct _cffi_freeme_s *fp = (struct _cffi_freeme_s *)PyObject_Malloc(
1033
+ offsetof(struct _cffi_freeme_s, alignment) + (size_t)datasize);
1034
+ if (fp == NULL)
1035
+ return -1;
1036
+ fp->next = *freeme;
1037
+ *freeme = fp;
1038
+ p = *output_data = (char *)&fp->alignment;
1039
+ }
1040
+ memset((void *)p, 0, (size_t)datasize);
1041
+ return _cffi_convert_array_from_object(p, ctptr, arg);
1042
+ }
1043
+
1044
+ #ifdef __GNUC__
1045
+ __attribute__((unused))
1046
+ #endif
1047
+ static void _cffi_free_array_arguments(struct _cffi_freeme_s *freeme)
1048
+ {
1049
+ do {
1050
+ void *p = (void *)freeme;
1051
+ freeme = freeme->next;
1052
+ PyObject_Free(p);
1053
+ } while (freeme != NULL);
1054
+ }
1055
+
1056
+ static int _cffi_init(void)
1057
+ {
1058
+ PyObject *module, *c_api_object = NULL;
1059
+
1060
+ module = PyImport_ImportModule("_cffi_backend");
1061
+ if (module == NULL)
1062
+ goto failure;
1063
+
1064
+ c_api_object = PyObject_GetAttrString(module, "_C_API");
1065
+ if (c_api_object == NULL)
1066
+ goto failure;
1067
+ if (!PyCapsule_CheckExact(c_api_object)) {
1068
+ PyErr_SetNone(PyExc_ImportError);
1069
+ goto failure;
1070
+ }
1071
+ memcpy(_cffi_exports, PyCapsule_GetPointer(c_api_object, "cffi"),
1072
+ _CFFI_NUM_EXPORTS * sizeof(void *));
1073
+
1074
+ Py_DECREF(module);
1075
+ Py_DECREF(c_api_object);
1076
+ return 0;
1077
+
1078
+ failure:
1079
+ Py_XDECREF(module);
1080
+ Py_XDECREF(c_api_object);
1081
+ return -1;
1082
+ }
1083
+
1084
+ #define _cffi_type(num) ((CTypeDescrObject *)PyList_GET_ITEM(_cffi_types, num))
1085
+
1086
+ /**********/
1087
+ '''