@pairling/runtime-darwin-x64 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 (159) 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/lib-dynload/_crypt.cpython-312-darwin.so +0 -0
  9. package/python/lib/python3.12/lib-dynload/_dbm.cpython-312-darwin.so +0 -0
  10. package/python/lib/python3.12/site-packages/_cffi_backend.cpython-312-darwin.so +0 -0
  11. package/python/lib/python3.12/site-packages/cffi/__init__.py +14 -0
  12. package/python/lib/python3.12/site-packages/cffi/_cffi_errors.h +149 -0
  13. package/python/lib/python3.12/site-packages/cffi/_cffi_include.h +389 -0
  14. package/python/lib/python3.12/site-packages/cffi/_embedding.h +550 -0
  15. package/python/lib/python3.12/site-packages/cffi/_imp_emulation.py +83 -0
  16. package/python/lib/python3.12/site-packages/cffi/_shimmed_dist_utils.py +45 -0
  17. package/python/lib/python3.12/site-packages/cffi/api.py +967 -0
  18. package/python/lib/python3.12/site-packages/cffi/backend_ctypes.py +1121 -0
  19. package/python/lib/python3.12/site-packages/cffi/cffi_opcode.py +187 -0
  20. package/python/lib/python3.12/site-packages/cffi/commontypes.py +82 -0
  21. package/python/lib/python3.12/site-packages/cffi/cparser.py +1015 -0
  22. package/python/lib/python3.12/site-packages/cffi/error.py +31 -0
  23. package/python/lib/python3.12/site-packages/cffi/ffiplatform.py +113 -0
  24. package/python/lib/python3.12/site-packages/cffi/lock.py +30 -0
  25. package/python/lib/python3.12/site-packages/cffi/model.py +618 -0
  26. package/python/lib/python3.12/site-packages/cffi/parse_c_type.h +181 -0
  27. package/python/lib/python3.12/site-packages/cffi/pkgconfig.py +121 -0
  28. package/python/lib/python3.12/site-packages/cffi/recompiler.py +1598 -0
  29. package/python/lib/python3.12/site-packages/cffi/setuptools_ext.py +216 -0
  30. package/python/lib/python3.12/site-packages/cffi/vengine_cpy.py +1084 -0
  31. package/python/lib/python3.12/site-packages/cffi/vengine_gen.py +679 -0
  32. package/python/lib/python3.12/site-packages/cffi/verifier.py +306 -0
  33. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/INSTALLER +1 -0
  34. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/LICENSE +26 -0
  35. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/METADATA +40 -0
  36. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/RECORD +30 -0
  37. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/WHEEL +5 -0
  38. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/entry_points.txt +2 -0
  39. package/python/lib/python3.12/site-packages/cffi-1.17.1.dist-info/top_level.txt +2 -0
  40. package/python/lib/python3.12/site-packages/cryptography/__about__.py +17 -0
  41. package/python/lib/python3.12/site-packages/cryptography/__init__.py +26 -0
  42. package/python/lib/python3.12/site-packages/cryptography/exceptions.py +52 -0
  43. package/python/lib/python3.12/site-packages/cryptography/fernet.py +224 -0
  44. package/python/lib/python3.12/site-packages/cryptography/hazmat/__init__.py +13 -0
  45. package/python/lib/python3.12/site-packages/cryptography/hazmat/_oid.py +348 -0
  46. package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/__init__.py +13 -0
  47. package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/__init__.py +9 -0
  48. package/python/lib/python3.12/site-packages/cryptography/hazmat/backends/openssl/backend.py +308 -0
  49. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/__init__.py +3 -0
  50. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/__init__.pyi +37 -0
  51. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/_openssl.pyi +8 -0
  52. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/asn1.pyi +7 -0
  53. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/exceptions.pyi +17 -0
  54. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/ocsp.pyi +117 -0
  55. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi +75 -0
  56. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/aead.pyi +107 -0
  57. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ciphers.pyi +38 -0
  58. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/cmac.pyi +18 -0
  59. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/dh.pyi +51 -0
  60. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/dsa.pyi +41 -0
  61. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ec.pyi +52 -0
  62. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed25519.pyi +13 -0
  63. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/ed448.pyi +13 -0
  64. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/hashes.pyi +28 -0
  65. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/hmac.pyi +22 -0
  66. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi +49 -0
  67. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/keys.pyi +34 -0
  68. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/poly1305.pyi +15 -0
  69. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/rsa.pyi +55 -0
  70. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/x25519.pyi +13 -0
  71. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/openssl/x448.pyi +13 -0
  72. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/pkcs12.pyi +52 -0
  73. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/pkcs7.pyi +50 -0
  74. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/test_support.pyi +23 -0
  75. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +313 -0
  76. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/_rust.abi3.so +0 -0
  77. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/__init__.py +3 -0
  78. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py +191 -0
  79. package/python/lib/python3.12/site-packages/cryptography/hazmat/bindings/openssl/binding.py +122 -0
  80. package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/__init__.py +5 -0
  81. package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/ciphers/__init__.py +5 -0
  82. package/python/lib/python3.12/site-packages/cryptography/hazmat/decrepit/ciphers/algorithms.py +112 -0
  83. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/__init__.py +3 -0
  84. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_asymmetric.py +19 -0
  85. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_cipheralgorithm.py +60 -0
  86. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/_serialization.py +168 -0
  87. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/__init__.py +3 -0
  88. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py +147 -0
  89. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/dsa.py +167 -0
  90. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py +447 -0
  91. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ed25519.py +129 -0
  92. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/ed448.py +131 -0
  93. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py +113 -0
  94. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py +277 -0
  95. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/types.py +111 -0
  96. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/utils.py +24 -0
  97. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py +122 -0
  98. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/asymmetric/x448.py +125 -0
  99. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py +27 -0
  100. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/aead.py +23 -0
  101. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +183 -0
  102. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/base.py +146 -0
  103. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/modes.py +268 -0
  104. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/cmac.py +10 -0
  105. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/constant_time.py +14 -0
  106. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/hashes.py +246 -0
  107. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/hmac.py +13 -0
  108. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/__init__.py +23 -0
  109. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/argon2.py +13 -0
  110. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/concatkdf.py +125 -0
  111. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/hkdf.py +101 -0
  112. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/kbkdf.py +305 -0
  113. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/pbkdf2.py +62 -0
  114. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/scrypt.py +19 -0
  115. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/kdf/x963kdf.py +61 -0
  116. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/keywrap.py +177 -0
  117. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/padding.py +69 -0
  118. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/poly1305.py +11 -0
  119. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/__init__.py +65 -0
  120. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/base.py +14 -0
  121. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py +176 -0
  122. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/pkcs7.py +411 -0
  123. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/serialization/ssh.py +1619 -0
  124. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/__init__.py +9 -0
  125. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/hotp.py +101 -0
  126. package/python/lib/python3.12/site-packages/cryptography/hazmat/primitives/twofactor/totp.py +56 -0
  127. package/python/lib/python3.12/site-packages/cryptography/py.typed +0 -0
  128. package/python/lib/python3.12/site-packages/cryptography/utils.py +139 -0
  129. package/python/lib/python3.12/site-packages/cryptography/x509/__init__.py +270 -0
  130. package/python/lib/python3.12/site-packages/cryptography/x509/base.py +848 -0
  131. package/python/lib/python3.12/site-packages/cryptography/x509/certificate_transparency.py +35 -0
  132. package/python/lib/python3.12/site-packages/cryptography/x509/extensions.py +2528 -0
  133. package/python/lib/python3.12/site-packages/cryptography/x509/general_name.py +281 -0
  134. package/python/lib/python3.12/site-packages/cryptography/x509/name.py +477 -0
  135. package/python/lib/python3.12/site-packages/cryptography/x509/ocsp.py +379 -0
  136. package/python/lib/python3.12/site-packages/cryptography/x509/oid.py +37 -0
  137. package/python/lib/python3.12/site-packages/cryptography/x509/verification.py +34 -0
  138. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/INSTALLER +1 -0
  139. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/METADATA +139 -0
  140. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/RECORD +106 -0
  141. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/REQUESTED +0 -0
  142. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/WHEEL +4 -0
  143. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE +3 -0
  144. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE.APACHE +202 -0
  145. package/python/lib/python3.12/site-packages/cryptography-45.0.7.dist-info/licenses/LICENSE.BSD +27 -0
  146. package/python/lib/python3.12/site-packages/pycparser/__init__.py +99 -0
  147. package/python/lib/python3.12/site-packages/pycparser/_ast_gen.py +355 -0
  148. package/python/lib/python3.12/site-packages/pycparser/_c_ast.cfg +195 -0
  149. package/python/lib/python3.12/site-packages/pycparser/ast_transforms.py +174 -0
  150. package/python/lib/python3.12/site-packages/pycparser/c_ast.py +1341 -0
  151. package/python/lib/python3.12/site-packages/pycparser/c_generator.py +573 -0
  152. package/python/lib/python3.12/site-packages/pycparser/c_lexer.py +706 -0
  153. package/python/lib/python3.12/site-packages/pycparser/c_parser.py +2376 -0
  154. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/INSTALLER +1 -0
  155. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/METADATA +244 -0
  156. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/RECORD +14 -0
  157. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/WHEEL +5 -0
  158. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/licenses/LICENSE +27 -0
  159. package/python/lib/python3.12/site-packages/pycparser-3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,355 @@
1
+ # -----------------------------------------------------------------
2
+ # _ast_gen.py
3
+ #
4
+ # Generates the AST Node classes from a specification given in
5
+ # a configuration file. This module can also be run as a script to
6
+ # regenerate c_ast.py from _c_ast.cfg (from the repo root or the
7
+ # pycparser/ directory). Use 'make check' to reformat the generated
8
+ # file after running this script.
9
+ #
10
+ # The design of this module was inspired by astgen.py from the
11
+ # Python 2.5 code-base.
12
+ #
13
+ # Eli Bendersky [https://eli.thegreenplace.net/]
14
+ # License: BSD
15
+ # -----------------------------------------------------------------
16
+ from string import Template
17
+ import os
18
+ from typing import IO
19
+
20
+
21
+ class ASTCodeGenerator:
22
+ def __init__(self, cfg_filename="_c_ast.cfg"):
23
+ """Initialize the code generator from a configuration
24
+ file.
25
+ """
26
+ self.cfg_filename = cfg_filename
27
+ self.node_cfg = [
28
+ NodeCfg(name, contents)
29
+ for (name, contents) in self.parse_cfgfile(cfg_filename)
30
+ ]
31
+
32
+ def generate(self, file: IO[str]) -> None:
33
+ """Generates the code into file, an open file buffer."""
34
+ src = Template(_PROLOGUE_COMMENT).substitute(cfg_filename=self.cfg_filename)
35
+
36
+ src += _PROLOGUE_CODE
37
+ for node_cfg in self.node_cfg:
38
+ src += node_cfg.generate_source() + "\n\n"
39
+
40
+ file.write(src)
41
+
42
+ def parse_cfgfile(self, filename):
43
+ """Parse the configuration file and yield pairs of
44
+ (name, contents) for each node.
45
+ """
46
+ with open(filename, "r") as f:
47
+ for line in f:
48
+ line = line.strip()
49
+ if not line or line.startswith("#"):
50
+ continue
51
+ colon_i = line.find(":")
52
+ lbracket_i = line.find("[")
53
+ rbracket_i = line.find("]")
54
+ if colon_i < 1 or lbracket_i <= colon_i or rbracket_i <= lbracket_i:
55
+ raise RuntimeError(f"Invalid line in {filename}:\n{line}\n")
56
+
57
+ name = line[:colon_i]
58
+ val = line[lbracket_i + 1 : rbracket_i]
59
+ vallist = [v.strip() for v in val.split(",")] if val else []
60
+ yield name, vallist
61
+
62
+
63
+ class NodeCfg:
64
+ """Node configuration.
65
+
66
+ name: node name
67
+ contents: a list of contents - attributes and child nodes
68
+ See comment at the top of the configuration file for details.
69
+ """
70
+
71
+ def __init__(self, name, contents):
72
+ self.name = name
73
+ self.all_entries = []
74
+ self.attr = []
75
+ self.child = []
76
+ self.seq_child = []
77
+
78
+ for entry in contents:
79
+ clean_entry = entry.rstrip("*")
80
+ self.all_entries.append(clean_entry)
81
+
82
+ if entry.endswith("**"):
83
+ self.seq_child.append(clean_entry)
84
+ elif entry.endswith("*"):
85
+ self.child.append(clean_entry)
86
+ else:
87
+ self.attr.append(entry)
88
+
89
+ def generate_source(self):
90
+ src = self._gen_init()
91
+ src += "\n" + self._gen_children()
92
+ src += "\n" + self._gen_iter()
93
+ src += "\n" + self._gen_attr_names()
94
+ return src
95
+
96
+ def _gen_init(self):
97
+ src = f"class {self.name}(Node):\n"
98
+
99
+ if self.all_entries:
100
+ args = ", ".join(self.all_entries)
101
+ slots = ", ".join(f"'{e}'" for e in self.all_entries)
102
+ slots += ", 'coord', '__weakref__'"
103
+ arglist = f"(self, {args}, coord=None)"
104
+ else:
105
+ slots = "'coord', '__weakref__'"
106
+ arglist = "(self, coord=None)"
107
+
108
+ src += f" __slots__ = ({slots})\n"
109
+ src += f" def __init__{arglist}:\n"
110
+
111
+ for name in self.all_entries + ["coord"]:
112
+ src += f" self.{name} = {name}\n"
113
+
114
+ return src
115
+
116
+ def _gen_children(self):
117
+ src = " def children(self):\n"
118
+
119
+ if self.all_entries:
120
+ src += " nodelist = []\n"
121
+
122
+ for child in self.child:
123
+ src += f" if self.{child} is not None:\n"
124
+ src += f' nodelist.append(("{child}", self.{child}))\n'
125
+
126
+ for seq_child in self.seq_child:
127
+ src += f" for i, child in enumerate(self.{seq_child} or []):\n"
128
+ src += f' nodelist.append((f"{seq_child}[{{i}}]", child))\n'
129
+
130
+ src += " return tuple(nodelist)\n"
131
+ else:
132
+ src += " return ()\n"
133
+
134
+ return src
135
+
136
+ def _gen_iter(self):
137
+ src = " def __iter__(self):\n"
138
+
139
+ if self.all_entries:
140
+ for child in self.child:
141
+ src += f" if self.{child} is not None:\n"
142
+ src += f" yield self.{child}\n"
143
+
144
+ for seq_child in self.seq_child:
145
+ src += f" for child in (self.{seq_child} or []):\n"
146
+ src += " yield child\n"
147
+
148
+ if not (self.child or self.seq_child):
149
+ # Empty generator
150
+ src += " return\n" + " yield\n"
151
+ else:
152
+ # Empty generator
153
+ src += " return\n" + " yield\n"
154
+
155
+ return src
156
+
157
+ def _gen_attr_names(self):
158
+ src = " attr_names = (" + "".join(f"{nm!r}, " for nm in self.attr) + ")"
159
+ return src
160
+
161
+
162
+ _PROLOGUE_COMMENT = r"""#-----------------------------------------------------------------
163
+ # ** ATTENTION **
164
+ # This code was automatically generated from _c_ast.cfg
165
+ #
166
+ # Do not modify it directly. Modify the configuration file and
167
+ # run the generator again.
168
+ # ** ** *** ** **
169
+ #
170
+ # pycparser: c_ast.py
171
+ #
172
+ # AST Node classes.
173
+ #
174
+ # Eli Bendersky [https://eli.thegreenplace.net/]
175
+ # License: BSD
176
+ #-----------------------------------------------------------------
177
+
178
+ """
179
+ _PROLOGUE_CODE = r'''
180
+ import sys
181
+ from typing import Any, ClassVar, IO, Optional
182
+
183
+ def _repr(obj):
184
+ """
185
+ Get the representation of an object, with dedicated pprint-like format for lists.
186
+ """
187
+ if isinstance(obj, list):
188
+ return '[' + (',\n '.join((_repr(e).replace('\n', '\n ') for e in obj))) + '\n]'
189
+ else:
190
+ return repr(obj)
191
+
192
+ class Node:
193
+ __slots__ = ()
194
+ """ Abstract base class for AST nodes.
195
+ """
196
+ attr_names: ClassVar[tuple[str, ...]] = ()
197
+ coord: Optional[Any]
198
+ def __repr__(self):
199
+ """ Generates a python representation of the current node
200
+ """
201
+ result = self.__class__.__name__ + '('
202
+
203
+ indent = ''
204
+ separator = ''
205
+ for name in self.__slots__[:-2]:
206
+ result += separator
207
+ result += indent
208
+ result += name + '=' + (_repr(getattr(self, name)).replace('\n', '\n ' + (' ' * (len(name) + len(self.__class__.__name__)))))
209
+
210
+ separator = ','
211
+ indent = '\n ' + (' ' * len(self.__class__.__name__))
212
+
213
+ result += indent + ')'
214
+
215
+ return result
216
+
217
+ def children(self):
218
+ """ A sequence of all children that are Nodes
219
+ """
220
+ pass
221
+
222
+ def show(
223
+ self,
224
+ buf: IO[str] = sys.stdout,
225
+ offset: int = 0,
226
+ attrnames: bool = False,
227
+ showemptyattrs: bool = True,
228
+ nodenames: bool = False,
229
+ showcoord: bool = False,
230
+ _my_node_name: Optional[str] = None,
231
+ ):
232
+ """ Pretty print the Node and all its attributes and
233
+ children (recursively) to a buffer.
234
+
235
+ buf:
236
+ Open IO buffer into which the Node is printed.
237
+
238
+ offset:
239
+ Initial offset (amount of leading spaces)
240
+
241
+ attrnames:
242
+ True if you want to see the attribute names in
243
+ name=value pairs. False to only see the values.
244
+
245
+ showemptyattrs:
246
+ False if you want to suppress printing empty attributes.
247
+
248
+ nodenames:
249
+ True if you want to see the actual node names
250
+ within their parents.
251
+
252
+ showcoord:
253
+ Do you want the coordinates of each Node to be
254
+ displayed.
255
+ """
256
+ lead = ' ' * offset
257
+ if nodenames and _my_node_name is not None:
258
+ buf.write(lead + self.__class__.__name__+ ' <' + _my_node_name + '>: ')
259
+ else:
260
+ buf.write(lead + self.__class__.__name__+ ': ')
261
+
262
+ if self.attr_names:
263
+ def is_empty(v):
264
+ v is None or (hasattr(v, '__len__') and len(v) == 0)
265
+ nvlist = [(n, getattr(self,n)) for n in self.attr_names \
266
+ if showemptyattrs or not is_empty(getattr(self,n))]
267
+ if attrnames:
268
+ attrstr = ', '.join(f'{name}={value}' for name, value in nvlist)
269
+ else:
270
+ attrstr = ', '.join(f'{value}' for _, value in nvlist)
271
+ buf.write(attrstr)
272
+
273
+ if showcoord:
274
+ buf.write(f' (at {self.coord})')
275
+ buf.write('\n')
276
+
277
+ for (child_name, child) in self.children():
278
+ child.show(
279
+ buf,
280
+ offset=offset + 2,
281
+ attrnames=attrnames,
282
+ showemptyattrs=showemptyattrs,
283
+ nodenames=nodenames,
284
+ showcoord=showcoord,
285
+ _my_node_name=child_name)
286
+
287
+
288
+ class NodeVisitor:
289
+ """ A base NodeVisitor class for visiting c_ast nodes.
290
+ Subclass it and define your own visit_XXX methods, where
291
+ XXX is the class name you want to visit with these
292
+ methods.
293
+
294
+ For example:
295
+
296
+ class ConstantVisitor(NodeVisitor):
297
+ def __init__(self):
298
+ self.values = []
299
+
300
+ def visit_Constant(self, node):
301
+ self.values.append(node.value)
302
+
303
+ Creates a list of values of all the constant nodes
304
+ encountered below the given node. To use it:
305
+
306
+ cv = ConstantVisitor()
307
+ cv.visit(node)
308
+
309
+ Notes:
310
+
311
+ * generic_visit() will be called for AST nodes for which
312
+ no visit_XXX method was defined.
313
+ * The children of nodes for which a visit_XXX was
314
+ defined will not be visited - if you need this, call
315
+ generic_visit() on the node.
316
+ You can use:
317
+ NodeVisitor.generic_visit(self, node)
318
+ * Modeled after Python's own AST visiting facilities
319
+ (the ast module of Python 3.0)
320
+ """
321
+
322
+ _method_cache = None
323
+
324
+ def visit(self, node: Node):
325
+ """ Visit a node.
326
+ """
327
+
328
+ if self._method_cache is None:
329
+ self._method_cache = {}
330
+
331
+ visitor = self._method_cache.get(node.__class__.__name__, None)
332
+ if visitor is None:
333
+ method = 'visit_' + node.__class__.__name__
334
+ visitor = getattr(self, method, self.generic_visit)
335
+ self._method_cache[node.__class__.__name__] = visitor
336
+
337
+ return visitor(node)
338
+
339
+ def generic_visit(self, node: Node):
340
+ """ Called if no explicit visitor function exists for a
341
+ node. Implements preorder visiting of the node.
342
+ """
343
+ for _, c in node.children():
344
+ self.visit(c)
345
+
346
+ '''
347
+
348
+
349
+ if __name__ == "__main__":
350
+ base_dir = os.path.dirname(os.path.abspath(__file__))
351
+ cfg_path = os.path.join(base_dir, "_c_ast.cfg")
352
+ out_path = os.path.join(base_dir, "c_ast.py")
353
+ ast_gen = ASTCodeGenerator(cfg_path)
354
+ with open(out_path, "w") as out:
355
+ ast_gen.generate(out)
@@ -0,0 +1,195 @@
1
+ #-----------------------------------------------------------------
2
+ # pycparser: _c_ast.cfg
3
+ #
4
+ # Defines the AST Node classes used in pycparser.
5
+ #
6
+ # Each entry is a Node sub-class name, listing the attributes
7
+ # and child nodes of the class:
8
+ # <name>* - a child node
9
+ # <name>** - a sequence of child nodes
10
+ # <name> - an attribute
11
+ #
12
+ # Eli Bendersky [https://eli.thegreenplace.net/]
13
+ # License: BSD
14
+ #-----------------------------------------------------------------
15
+
16
+ # ArrayDecl is a nested declaration of an array with the given type.
17
+ # dim: the dimension (for example, constant 42)
18
+ # dim_quals: list of dimension qualifiers, to support C99's allowing 'const'
19
+ # and 'static' within the array dimension in function declarations.
20
+ ArrayDecl: [type*, dim*, dim_quals]
21
+
22
+ ArrayRef: [name*, subscript*]
23
+
24
+ # op: =, +=, /= etc.
25
+ #
26
+ Assignment: [op, lvalue*, rvalue*]
27
+
28
+ Alignas: [alignment*]
29
+
30
+ BinaryOp: [op, left*, right*]
31
+
32
+ Break: []
33
+
34
+ Case: [expr*, stmts**]
35
+
36
+ Cast: [to_type*, expr*]
37
+
38
+ # Compound statement in C99 is a list of block items (declarations or
39
+ # statements).
40
+ #
41
+ Compound: [block_items**]
42
+
43
+ # Compound literal (anonymous aggregate) for C99.
44
+ # (type-name) {initializer_list}
45
+ # type: the typename
46
+ # init: InitList for the initializer list
47
+ #
48
+ CompoundLiteral: [type*, init*]
49
+
50
+ # type: int, char, float, string, etc.
51
+ #
52
+ Constant: [type, value]
53
+
54
+ Continue: []
55
+
56
+ # name: the variable being declared
57
+ # quals: list of qualifiers (const, volatile)
58
+ # funcspec: list function specifiers (i.e. inline in C99)
59
+ # storage: list of storage specifiers (extern, register, etc.)
60
+ # type: declaration type (probably nested with all the modifiers)
61
+ # init: initialization value, or None
62
+ # bitsize: bit field size, or None
63
+ #
64
+ Decl: [name, quals, align, storage, funcspec, type*, init*, bitsize*]
65
+
66
+ DeclList: [decls**]
67
+
68
+ Default: [stmts**]
69
+
70
+ DoWhile: [cond*, stmt*]
71
+
72
+ # Represents the ellipsis (...) parameter in a function
73
+ # declaration
74
+ #
75
+ EllipsisParam: []
76
+
77
+ # An empty statement (a semicolon ';' on its own)
78
+ #
79
+ EmptyStatement: []
80
+
81
+ # Enumeration type specifier
82
+ # name: an optional ID
83
+ # values: an EnumeratorList
84
+ #
85
+ Enum: [name, values*]
86
+
87
+ # A name/value pair for enumeration values
88
+ #
89
+ Enumerator: [name, value*]
90
+
91
+ # A list of enumerators
92
+ #
93
+ EnumeratorList: [enumerators**]
94
+
95
+ # A list of expressions separated by the comma operator.
96
+ #
97
+ ExprList: [exprs**]
98
+
99
+ # This is the top of the AST, representing a single C file (a
100
+ # translation unit in K&R jargon). It contains a list of
101
+ # "external-declaration"s, which is either declarations (Decl),
102
+ # Typedef or function definitions (FuncDef).
103
+ #
104
+ FileAST: [ext**]
105
+
106
+ # for (init; cond; next) stmt
107
+ #
108
+ For: [init*, cond*, next*, stmt*]
109
+
110
+ # name: Id
111
+ # args: ExprList
112
+ #
113
+ FuncCall: [name*, args*]
114
+
115
+ # type <decl>(args)
116
+ #
117
+ FuncDecl: [args*, type*]
118
+
119
+ # Function definition: a declarator for the function name and
120
+ # a body, which is a compound statement.
121
+ # There's an optional list of parameter declarations for old
122
+ # K&R-style definitions
123
+ #
124
+ FuncDef: [decl*, param_decls**, body*]
125
+
126
+ Goto: [name]
127
+
128
+ ID: [name]
129
+
130
+ # Holder for types that are a simple identifier (e.g. the built
131
+ # ins void, char etc. and typedef-defined types)
132
+ #
133
+ IdentifierType: [names]
134
+
135
+ If: [cond*, iftrue*, iffalse*]
136
+
137
+ # An initialization list used for compound literals.
138
+ #
139
+ InitList: [exprs**]
140
+
141
+ Label: [name, stmt*]
142
+
143
+ # A named initializer for C99.
144
+ # The name of a NamedInitializer is a sequence of Nodes, because
145
+ # names can be hierarchical and contain constant expressions.
146
+ #
147
+ NamedInitializer: [name**, expr*]
148
+
149
+ # a list of comma separated function parameter declarations
150
+ #
151
+ ParamList: [params**]
152
+
153
+ PtrDecl: [quals, type*]
154
+
155
+ Return: [expr*]
156
+
157
+ StaticAssert: [cond*, message*]
158
+
159
+ # name: struct tag name
160
+ # decls: declaration of members
161
+ #
162
+ Struct: [name, decls**]
163
+
164
+ # type: . or ->
165
+ # name.field or name->field
166
+ #
167
+ StructRef: [name*, type, field*]
168
+
169
+ Switch: [cond*, stmt*]
170
+
171
+ # cond ? iftrue : iffalse
172
+ #
173
+ TernaryOp: [cond*, iftrue*, iffalse*]
174
+
175
+ # A base type declaration
176
+ #
177
+ TypeDecl: [declname, quals, align, type*]
178
+
179
+ # A typedef declaration.
180
+ # Very similar to Decl, but without some attributes
181
+ #
182
+ Typedef: [name, quals, storage, type*]
183
+
184
+ Typename: [name, quals, align, type*]
185
+
186
+ UnaryOp: [op, expr*]
187
+
188
+ # name: union tag name
189
+ # decls: declaration of members
190
+ #
191
+ Union: [name, decls**]
192
+
193
+ While: [cond*, stmt*]
194
+
195
+ Pragma: [string]