semiwrap 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- semiwrap/__init__.py +0 -0
- semiwrap/__main__.py +4 -0
- semiwrap/autowrap/__init__.py +0 -0
- semiwrap/autowrap/buffer.py +45 -0
- semiwrap/autowrap/context.py +570 -0
- semiwrap/autowrap/cxxparser.py +2067 -0
- semiwrap/autowrap/generator_data.py +386 -0
- semiwrap/autowrap/mangle.py +177 -0
- semiwrap/autowrap/render_cls_prologue.py +41 -0
- semiwrap/autowrap/render_cls_trampoline_hpp.py +442 -0
- semiwrap/autowrap/render_pybind11.py +450 -0
- semiwrap/autowrap/render_tmpl_inst.py +67 -0
- semiwrap/autowrap/render_wrapped.py +196 -0
- semiwrap/casters.py +55 -0
- semiwrap/cmd/__init__.py +0 -0
- semiwrap/cmd/dat2cpp.py +35 -0
- semiwrap/cmd/dat2tmplcpp.py +41 -0
- semiwrap/cmd/dat2tmplhpp.py +33 -0
- semiwrap/cmd/dat2trampoline.py +65 -0
- semiwrap/cmd/gen_libinit.py +53 -0
- semiwrap/cmd/gen_modinit_hpp.py +114 -0
- semiwrap/cmd/gen_pkgconf.py +46 -0
- semiwrap/cmd/header2dat.py +140 -0
- semiwrap/cmd/make_pyi.py +119 -0
- semiwrap/cmd/publish_casters.py +95 -0
- semiwrap/cmd/resolve_casters.py +71 -0
- semiwrap/config/__init__.py +0 -0
- semiwrap/config/autowrap_yml.py +659 -0
- semiwrap/config/pyproject_toml.py +219 -0
- semiwrap/config/util.py +57 -0
- semiwrap/depfile.py +32 -0
- semiwrap/hooks.py +108 -0
- semiwrap/include/gilsafe_object.h +141 -0
- semiwrap/include/pybind11_typing.h +5 -0
- semiwrap/include/semiwrap.h +86 -0
- semiwrap/makeplan.py +660 -0
- semiwrap/mkpc.py +51 -0
- semiwrap/pkgconf_cache.py +116 -0
- semiwrap/pybind11/LICENSE +29 -0
- semiwrap/pybind11/include/pybind11/attr.h +708 -0
- semiwrap/pybind11/include/pybind11/buffer_info.h +208 -0
- semiwrap/pybind11/include/pybind11/cast.h +2194 -0
- semiwrap/pybind11/include/pybind11/chrono.h +225 -0
- semiwrap/pybind11/include/pybind11/common.h +2 -0
- semiwrap/pybind11/include/pybind11/complex.h +74 -0
- semiwrap/pybind11/include/pybind11/conduit/README.txt +15 -0
- semiwrap/pybind11/include/pybind11/conduit/pybind11_conduit_v1.h +111 -0
- semiwrap/pybind11/include/pybind11/conduit/pybind11_platform_abi_id.h +87 -0
- semiwrap/pybind11/include/pybind11/conduit/wrap_include_python_h.h +72 -0
- semiwrap/pybind11/include/pybind11/detail/class.h +826 -0
- semiwrap/pybind11/include/pybind11/detail/common.h +1267 -0
- semiwrap/pybind11/include/pybind11/detail/cpp_conduit.h +77 -0
- semiwrap/pybind11/include/pybind11/detail/descr.h +201 -0
- semiwrap/pybind11/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +39 -0
- semiwrap/pybind11/include/pybind11/detail/exception_translation.h +71 -0
- semiwrap/pybind11/include/pybind11/detail/init.h +505 -0
- semiwrap/pybind11/include/pybind11/detail/internals.h +669 -0
- semiwrap/pybind11/include/pybind11/detail/struct_smart_holder.h +349 -0
- semiwrap/pybind11/include/pybind11/detail/type_caster_base.h +1598 -0
- semiwrap/pybind11/include/pybind11/detail/typeid.h +65 -0
- semiwrap/pybind11/include/pybind11/detail/using_smart_holder.h +22 -0
- semiwrap/pybind11/include/pybind11/detail/value_and_holder.h +78 -0
- semiwrap/pybind11/include/pybind11/eigen/common.h +9 -0
- semiwrap/pybind11/include/pybind11/eigen/matrix.h +723 -0
- semiwrap/pybind11/include/pybind11/eigen/tensor.h +521 -0
- semiwrap/pybind11/include/pybind11/eigen.h +12 -0
- semiwrap/pybind11/include/pybind11/embed.h +303 -0
- semiwrap/pybind11/include/pybind11/eval.h +156 -0
- semiwrap/pybind11/include/pybind11/functional.h +150 -0
- semiwrap/pybind11/include/pybind11/gil.h +215 -0
- semiwrap/pybind11/include/pybind11/gil_safe_call_once.h +102 -0
- semiwrap/pybind11/include/pybind11/iostream.h +265 -0
- semiwrap/pybind11/include/pybind11/numpy.h +2232 -0
- semiwrap/pybind11/include/pybind11/operators.h +202 -0
- semiwrap/pybind11/include/pybind11/options.h +92 -0
- semiwrap/pybind11/include/pybind11/pybind11.h +3442 -0
- semiwrap/pybind11/include/pybind11/pytypes.h +2655 -0
- semiwrap/pybind11/include/pybind11/stl/filesystem.h +124 -0
- semiwrap/pybind11/include/pybind11/stl.h +648 -0
- semiwrap/pybind11/include/pybind11/stl_bind.h +858 -0
- semiwrap/pybind11/include/pybind11/trampoline_self_life_support.h +60 -0
- semiwrap/pybind11/include/pybind11/type_caster_pyobject_ptr.h +61 -0
- semiwrap/pybind11/include/pybind11/typing.h +295 -0
- semiwrap/pybind11/include/pybind11/warnings.h +75 -0
- semiwrap/pyproject.py +96 -0
- semiwrap/render_meson.py +454 -0
- semiwrap/semiwrap-pybind11.pc +8 -0
- semiwrap/semiwrap.pc +9 -0
- semiwrap/semiwrap.pybind11.json +66 -0
- semiwrap/tool/__init__.py +1 -0
- semiwrap/tool/__main__.py +42 -0
- semiwrap/tool/build_dep.py +49 -0
- semiwrap/tool/create_imports.py +143 -0
- semiwrap/tool/create_yaml.py +103 -0
- semiwrap/tool/scan_headers.py +148 -0
- semiwrap/util.py +27 -0
- semiwrap/version.py +21 -0
- semiwrap-0.1.0.dist-info/METADATA +57 -0
- semiwrap-0.1.0.dist-info/RECORD +102 -0
- semiwrap-0.1.0.dist-info/WHEEL +4 -0
- semiwrap-0.1.0.dist-info/entry_points.txt +8 -0
- semiwrap-0.1.0.dist-info/licenses/LICENSE.txt +26 -0
semiwrap/__init__.py
ADDED
|
File without changes
|
semiwrap/__main__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import contextlib
|
|
3
|
+
import inspect
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class RenderBuffer:
|
|
7
|
+
def __init__(self) -> None:
|
|
8
|
+
self._buffer = io.StringIO()
|
|
9
|
+
|
|
10
|
+
self._indent = ""
|
|
11
|
+
self._indentlen = 0
|
|
12
|
+
|
|
13
|
+
def getvalue(self) -> str:
|
|
14
|
+
return self._buffer.getvalue()
|
|
15
|
+
|
|
16
|
+
def rel_indent(self, spaces: int):
|
|
17
|
+
self._indentlen += spaces
|
|
18
|
+
self._indent = " " * self._indentlen
|
|
19
|
+
|
|
20
|
+
@contextlib.contextmanager
|
|
21
|
+
def indent(self, spaces: int = 2):
|
|
22
|
+
self._indentlen += spaces
|
|
23
|
+
self._indent = " " * self._indentlen
|
|
24
|
+
try:
|
|
25
|
+
yield
|
|
26
|
+
finally:
|
|
27
|
+
self._indentlen -= spaces
|
|
28
|
+
self._indent = " " * self._indentlen
|
|
29
|
+
|
|
30
|
+
def writeln(self, s: str = ""):
|
|
31
|
+
if not s:
|
|
32
|
+
self._buffer.write("\n")
|
|
33
|
+
else:
|
|
34
|
+
for line in s.splitlines(False):
|
|
35
|
+
if line:
|
|
36
|
+
self._buffer.write(f"{self._indent}{line}\n")
|
|
37
|
+
else:
|
|
38
|
+
self._buffer.write("\n")
|
|
39
|
+
|
|
40
|
+
def write_trim(self, s: str):
|
|
41
|
+
for line in inspect.cleandoc(s).splitlines(False):
|
|
42
|
+
if line:
|
|
43
|
+
self._buffer.write(f"{self._indent}{line}\n")
|
|
44
|
+
else:
|
|
45
|
+
self._buffer.write("\n")
|
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
#
|
|
2
|
+
# These dataclasses hold data to be rendered
|
|
3
|
+
#
|
|
4
|
+
# To make the rendering functions easier to understand, where possible we try
|
|
5
|
+
# to do logic in the code that produces this data instead of in the rendering
|
|
6
|
+
# functions.
|
|
7
|
+
#
|
|
8
|
+
# We also prefer to copy over data from the autowrap YAML file instead of using
|
|
9
|
+
# those data structures directly. While there's some slight overhead added,
|
|
10
|
+
# this should help to keep the logic outside of the templates.
|
|
11
|
+
#
|
|
12
|
+
|
|
13
|
+
from dataclasses import dataclass, field
|
|
14
|
+
import enum
|
|
15
|
+
import pathlib
|
|
16
|
+
import typing
|
|
17
|
+
|
|
18
|
+
from cxxheaderparser.types import Function, PQName
|
|
19
|
+
|
|
20
|
+
from ..config.autowrap_yml import ReturnValuePolicy
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Documentation = typing.Optional[typing.List[str]]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class OverloadTracker:
|
|
27
|
+
"""Evaluates to true if overloaded"""
|
|
28
|
+
|
|
29
|
+
def __init__(self) -> None:
|
|
30
|
+
self.overloads = 0
|
|
31
|
+
|
|
32
|
+
def add_overload(self):
|
|
33
|
+
# This only needs to count new overloads, because if there are
|
|
34
|
+
# multiple instances of a function it *has* to be different or
|
|
35
|
+
# the compiler would complain
|
|
36
|
+
self.overloads += 1
|
|
37
|
+
|
|
38
|
+
def __bool__(self) -> bool:
|
|
39
|
+
return self.overloads > 1
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass
|
|
43
|
+
class EnumeratorContext:
|
|
44
|
+
"""Render data for each enumerator"""
|
|
45
|
+
|
|
46
|
+
#: C++ name, including namespace/classname
|
|
47
|
+
full_cpp_name: str
|
|
48
|
+
|
|
49
|
+
#: Name in python
|
|
50
|
+
py_name: str
|
|
51
|
+
|
|
52
|
+
#: Documentation
|
|
53
|
+
doc: Documentation
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@dataclass
|
|
57
|
+
class EnumContext:
|
|
58
|
+
"""Render data for enum"""
|
|
59
|
+
|
|
60
|
+
#: Name of parent variable in initializer
|
|
61
|
+
scope_var: str
|
|
62
|
+
|
|
63
|
+
#: Name of variable in initializer
|
|
64
|
+
var_name: str
|
|
65
|
+
|
|
66
|
+
#: C++ name without namespace
|
|
67
|
+
cpp_name: str
|
|
68
|
+
|
|
69
|
+
#: C++ name, including namespace/classname
|
|
70
|
+
full_cpp_name: str
|
|
71
|
+
|
|
72
|
+
#: Python name
|
|
73
|
+
py_name: str
|
|
74
|
+
|
|
75
|
+
#: Enum values
|
|
76
|
+
values: typing.List[EnumeratorContext]
|
|
77
|
+
|
|
78
|
+
#: Documentation
|
|
79
|
+
doc: Documentation
|
|
80
|
+
|
|
81
|
+
#
|
|
82
|
+
# Copied from user's EnumData
|
|
83
|
+
#
|
|
84
|
+
|
|
85
|
+
arithmetic: bool
|
|
86
|
+
inline_code: typing.Optional[str]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class ParamCategory(enum.Enum):
|
|
90
|
+
IGNORE = 0
|
|
91
|
+
OUT = 1
|
|
92
|
+
IN = 2
|
|
93
|
+
TMP = 3
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@dataclass
|
|
97
|
+
class ParamContext:
|
|
98
|
+
"""Render data for each parameter"""
|
|
99
|
+
|
|
100
|
+
# Original argument name
|
|
101
|
+
arg_name: str
|
|
102
|
+
|
|
103
|
+
# name of type with const but no *, &
|
|
104
|
+
# .. why does this have const
|
|
105
|
+
cpp_type: str
|
|
106
|
+
|
|
107
|
+
# contains 'const', &, etc
|
|
108
|
+
full_cpp_type: str
|
|
109
|
+
|
|
110
|
+
#: py::arg() for pybind11, includes default value
|
|
111
|
+
py_arg: str
|
|
112
|
+
|
|
113
|
+
#: passed to lambda
|
|
114
|
+
default: typing.Optional[str]
|
|
115
|
+
|
|
116
|
+
#: Name to pass to function when calling the original
|
|
117
|
+
#: .. only used by lambda
|
|
118
|
+
call_name: str
|
|
119
|
+
|
|
120
|
+
#: Name to pass to function when generating a virtual function
|
|
121
|
+
virtual_call_name: str
|
|
122
|
+
|
|
123
|
+
#: Not used in renderer, but is used to determine variable
|
|
124
|
+
#: name when used as an out parameter
|
|
125
|
+
cpp_retname: str
|
|
126
|
+
|
|
127
|
+
#: Not used in renderer, used for filtering
|
|
128
|
+
category: ParamCategory
|
|
129
|
+
|
|
130
|
+
# type + name, rarely used
|
|
131
|
+
@property
|
|
132
|
+
def decl(self) -> str:
|
|
133
|
+
return f"{self.full_cpp_type} {self.arg_name}"
|
|
134
|
+
|
|
135
|
+
# only used for operator generation, rarely used
|
|
136
|
+
@property
|
|
137
|
+
def cpp_type_no_const(self) -> str:
|
|
138
|
+
ct = self.cpp_type
|
|
139
|
+
if ct.startswith("const "):
|
|
140
|
+
return ct[6:]
|
|
141
|
+
return ct
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@dataclass
|
|
145
|
+
class GeneratedLambda:
|
|
146
|
+
"""
|
|
147
|
+
Data for generating a lambda to change the behavior of the function
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
pre: str
|
|
151
|
+
call_start: str
|
|
152
|
+
ret: str
|
|
153
|
+
|
|
154
|
+
#: input parameters
|
|
155
|
+
in_params: typing.List[ParamContext]
|
|
156
|
+
#: output parameters
|
|
157
|
+
out_params: typing.List[ParamContext]
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
@dataclass
|
|
161
|
+
class FunctionContext:
|
|
162
|
+
"""Render data for a C++ function or method"""
|
|
163
|
+
|
|
164
|
+
#: C++ name of function
|
|
165
|
+
cpp_name: str
|
|
166
|
+
|
|
167
|
+
#: Documentation
|
|
168
|
+
doc: Documentation
|
|
169
|
+
|
|
170
|
+
#: parent variable to attach to
|
|
171
|
+
scope_var: str
|
|
172
|
+
|
|
173
|
+
#: Name in python
|
|
174
|
+
py_name: str
|
|
175
|
+
|
|
176
|
+
#: Return value as fully qualified C++ type with const/*
|
|
177
|
+
cpp_return_type: typing.Optional[str]
|
|
178
|
+
|
|
179
|
+
#: All original C++ parameters for the function
|
|
180
|
+
#: -> used by trampoline signature, and trampolines
|
|
181
|
+
all_params: typing.List[ParamContext]
|
|
182
|
+
|
|
183
|
+
#: every parameter except ignored
|
|
184
|
+
filtered_params: typing.List[ParamContext]
|
|
185
|
+
|
|
186
|
+
#: Has vararg parameters
|
|
187
|
+
#: -> used by trampoline signature
|
|
188
|
+
# vararg: bool
|
|
189
|
+
|
|
190
|
+
#
|
|
191
|
+
# Mixed
|
|
192
|
+
#
|
|
193
|
+
|
|
194
|
+
has_buffers: bool
|
|
195
|
+
|
|
196
|
+
keepalives: typing.List[typing.Tuple[int, int]]
|
|
197
|
+
|
|
198
|
+
return_value_policy: str
|
|
199
|
+
|
|
200
|
+
#
|
|
201
|
+
# User settings from autowrap_yml.FunctionData
|
|
202
|
+
#
|
|
203
|
+
|
|
204
|
+
#: If True, don't wrap this, but provide a pure virtual implementation
|
|
205
|
+
ignore_pure: bool
|
|
206
|
+
|
|
207
|
+
#: If True, don't expose this function to python
|
|
208
|
+
ignore_py: bool
|
|
209
|
+
|
|
210
|
+
#: Use this code instead of the generated code
|
|
211
|
+
cpp_code: typing.Optional[str]
|
|
212
|
+
#: Use this code instead of the generated code in a trampoline
|
|
213
|
+
trampoline_cpp_code: typing.Optional[str]
|
|
214
|
+
|
|
215
|
+
#: Generate this in an `#ifdef`
|
|
216
|
+
ifdef: typing.Optional[str]
|
|
217
|
+
#: Generate this in an `#ifndef`
|
|
218
|
+
ifndef: typing.Optional[str]
|
|
219
|
+
|
|
220
|
+
release_gil: bool
|
|
221
|
+
|
|
222
|
+
# List of template instantiations
|
|
223
|
+
template_impls: typing.Optional[typing.List[typing.List[str]]]
|
|
224
|
+
|
|
225
|
+
virtual_xform: typing.Optional[str]
|
|
226
|
+
|
|
227
|
+
# OverloadTracker evaluates to True if there are overloads
|
|
228
|
+
is_overloaded: OverloadTracker
|
|
229
|
+
|
|
230
|
+
# Used to compute the trampoline signature
|
|
231
|
+
_fn: Function
|
|
232
|
+
|
|
233
|
+
#
|
|
234
|
+
# Cached/conditionally set properties
|
|
235
|
+
#
|
|
236
|
+
|
|
237
|
+
genlambda: typing.Optional[GeneratedLambda] = None
|
|
238
|
+
|
|
239
|
+
#: Is this a constructor?
|
|
240
|
+
is_constructor: bool = False
|
|
241
|
+
|
|
242
|
+
#: & or && qualifiers for function
|
|
243
|
+
ref_qualifiers: str = ""
|
|
244
|
+
|
|
245
|
+
#: Marked const
|
|
246
|
+
const: bool = False
|
|
247
|
+
|
|
248
|
+
is_pure_virtual: bool = False
|
|
249
|
+
|
|
250
|
+
#: If there is a namespace associated with this function, this is it,
|
|
251
|
+
#: and this ends with ::
|
|
252
|
+
namespace: str = ""
|
|
253
|
+
|
|
254
|
+
#: The operator for this method
|
|
255
|
+
#: - if set, cpp_type will be filled out by the parser
|
|
256
|
+
operator: typing.Optional[str] = None
|
|
257
|
+
|
|
258
|
+
#: True if this is a static method
|
|
259
|
+
is_static_method: bool = False
|
|
260
|
+
|
|
261
|
+
# Only compute the trampoline signature once, used as cache by
|
|
262
|
+
# trampoline_signature function
|
|
263
|
+
_trampoline_signature: typing.Optional[str] = None
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
@dataclass
|
|
267
|
+
class PropContext:
|
|
268
|
+
"""
|
|
269
|
+
Render data for each class property
|
|
270
|
+
"""
|
|
271
|
+
|
|
272
|
+
py_name: str
|
|
273
|
+
cpp_name: str
|
|
274
|
+
cpp_type: str
|
|
275
|
+
readonly: bool
|
|
276
|
+
doc: Documentation
|
|
277
|
+
|
|
278
|
+
array_size: typing.Optional[int]
|
|
279
|
+
array: bool # cannot sensibly autowrap an array of incomplete size
|
|
280
|
+
reference: bool
|
|
281
|
+
static: bool
|
|
282
|
+
bitfield: bool
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
@dataclass
|
|
286
|
+
class BaseClassData:
|
|
287
|
+
"""
|
|
288
|
+
Render data for each base that a class inherits
|
|
289
|
+
"""
|
|
290
|
+
|
|
291
|
+
#: Just the class name
|
|
292
|
+
cls_name: str
|
|
293
|
+
|
|
294
|
+
#: This ends with ::
|
|
295
|
+
namespace_: str
|
|
296
|
+
|
|
297
|
+
#: C++ name, including all known components
|
|
298
|
+
full_cpp_name: str # was x_qualname
|
|
299
|
+
|
|
300
|
+
full_cpp_name_w_templates: str # was x_class
|
|
301
|
+
|
|
302
|
+
#: Translated C++ name suitable for use as an identifier. :<>= are
|
|
303
|
+
#: turned into underscores.
|
|
304
|
+
full_cpp_name_identifier: str # was x_qualname_
|
|
305
|
+
|
|
306
|
+
#: C++ name + components, no template parameters
|
|
307
|
+
dep_cpp_name: str
|
|
308
|
+
|
|
309
|
+
#: comma separated list of template parameters for this base, or empty string
|
|
310
|
+
template_params: str
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
@dataclass
|
|
314
|
+
class TrampolineData:
|
|
315
|
+
"""
|
|
316
|
+
Trampolines are classes that have the original class as a base class,
|
|
317
|
+
which allows us to add additional features from python:
|
|
318
|
+
|
|
319
|
+
* Protected method/variable access
|
|
320
|
+
* Implement virtual functions from python
|
|
321
|
+
"""
|
|
322
|
+
|
|
323
|
+
full_cpp_name: str
|
|
324
|
+
var: str
|
|
325
|
+
inline_code: typing.Optional[str]
|
|
326
|
+
|
|
327
|
+
#: trampoline base class template types
|
|
328
|
+
tmpl_args: str
|
|
329
|
+
|
|
330
|
+
#: trampoline base class template names
|
|
331
|
+
tmpl_params: str
|
|
332
|
+
|
|
333
|
+
#
|
|
334
|
+
# Lists used by trampolines so that the logic in the template is less
|
|
335
|
+
# complicated
|
|
336
|
+
#
|
|
337
|
+
|
|
338
|
+
# pub + protected + final (ignore doesn't matter)
|
|
339
|
+
# private + final or override (ignore doesn't matter)
|
|
340
|
+
# -> to delete, only needs signature
|
|
341
|
+
methods_to_disable: typing.List[FunctionContext]
|
|
342
|
+
|
|
343
|
+
# public + protected + private
|
|
344
|
+
# - if not ignore and virtual and not final and not buffers)
|
|
345
|
+
virtual_methods: typing.List[FunctionContext]
|
|
346
|
+
|
|
347
|
+
# protected + not ignore + constructor
|
|
348
|
+
protected_constructors: typing.List[FunctionContext]
|
|
349
|
+
|
|
350
|
+
# protected + not (ignore or virtual or constructor)
|
|
351
|
+
non_virtual_protected_methods: typing.List[FunctionContext]
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
@dataclass
|
|
355
|
+
class ClassTemplateData:
|
|
356
|
+
#: N, ..
|
|
357
|
+
argument_list: str
|
|
358
|
+
#: <typename N, .. >
|
|
359
|
+
parameter_list: str
|
|
360
|
+
|
|
361
|
+
#: the specified C++ code is inserted into the template definition
|
|
362
|
+
inline_code: str
|
|
363
|
+
|
|
364
|
+
#: Instances of this class
|
|
365
|
+
instances: typing.List["TemplateInstanceContext"] = field(default_factory=list)
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
@dataclass
|
|
369
|
+
class ClassContext:
|
|
370
|
+
"""
|
|
371
|
+
Render data for each class encountered in a header
|
|
372
|
+
"""
|
|
373
|
+
|
|
374
|
+
parent: typing.Optional["ClassContext"]
|
|
375
|
+
|
|
376
|
+
#: lookup key for dat2trampoline
|
|
377
|
+
yml_id: str
|
|
378
|
+
|
|
379
|
+
#: Namespace that this class lives in
|
|
380
|
+
namespace: str
|
|
381
|
+
|
|
382
|
+
#: C++ name (only the class)
|
|
383
|
+
cpp_name: str
|
|
384
|
+
|
|
385
|
+
#: C++ name, including namespace/classname: was: x_qualname
|
|
386
|
+
full_cpp_name: str
|
|
387
|
+
|
|
388
|
+
#: Translated C++ name suitable for use as an identifier. :<>= are
|
|
389
|
+
#: turned into underscores. was: x_qualname_
|
|
390
|
+
full_cpp_name_identifier: str
|
|
391
|
+
|
|
392
|
+
#: C++ name + components, no template parameters
|
|
393
|
+
dep_cpp_name: str
|
|
394
|
+
|
|
395
|
+
#: Python name
|
|
396
|
+
py_name: str
|
|
397
|
+
|
|
398
|
+
#: Name of parent variable in initializer
|
|
399
|
+
scope_var: str
|
|
400
|
+
|
|
401
|
+
#: Name of variable in initializer. was: x_varname
|
|
402
|
+
var_name: str
|
|
403
|
+
|
|
404
|
+
#: If the object shouldn't be deleted by pybind11, use this. Disables
|
|
405
|
+
#: implicit constructors.
|
|
406
|
+
nodelete: bool
|
|
407
|
+
|
|
408
|
+
#: class is final
|
|
409
|
+
final: bool
|
|
410
|
+
|
|
411
|
+
#: Documentation
|
|
412
|
+
doc: Documentation
|
|
413
|
+
|
|
414
|
+
bases: typing.List[BaseClassData]
|
|
415
|
+
|
|
416
|
+
template: typing.Optional[ClassTemplateData]
|
|
417
|
+
|
|
418
|
+
#
|
|
419
|
+
# User specified settings copied from ClassData
|
|
420
|
+
#
|
|
421
|
+
|
|
422
|
+
#: Extra 'using' directives to insert into the trampoline and the
|
|
423
|
+
#: wrapping scope
|
|
424
|
+
user_typealias: typing.List[str]
|
|
425
|
+
|
|
426
|
+
#: Extra constexpr to insert into the trampoline and wrapping scopes
|
|
427
|
+
#: (name, value)
|
|
428
|
+
constants: typing.List[typing.Tuple[str, str]]
|
|
429
|
+
|
|
430
|
+
#: Extra code to insert into the class scope
|
|
431
|
+
inline_code: str
|
|
432
|
+
|
|
433
|
+
#: User specified settings
|
|
434
|
+
force_multiple_inheritance: bool
|
|
435
|
+
|
|
436
|
+
#
|
|
437
|
+
# Everything else
|
|
438
|
+
#
|
|
439
|
+
|
|
440
|
+
# Not used in rendering functions but used elsewhere
|
|
441
|
+
has_constructor: bool = False
|
|
442
|
+
is_polymorphic: bool = False
|
|
443
|
+
|
|
444
|
+
#: was x_has_trampoline
|
|
445
|
+
trampoline: typing.Optional[TrampolineData] = None
|
|
446
|
+
|
|
447
|
+
#
|
|
448
|
+
# Properties (member variables)
|
|
449
|
+
#
|
|
450
|
+
|
|
451
|
+
public_properties: typing.List[PropContext] = field(default_factory=list)
|
|
452
|
+
protected_properties: typing.List[PropContext] = field(default_factory=list)
|
|
453
|
+
|
|
454
|
+
#
|
|
455
|
+
# Methods: the idea here is have a bunch of descriptive lists here so that
|
|
456
|
+
# the j2 templates don't need logic to emit each method
|
|
457
|
+
#
|
|
458
|
+
|
|
459
|
+
#
|
|
460
|
+
# Method lists for wrapping
|
|
461
|
+
#
|
|
462
|
+
|
|
463
|
+
add_default_constructor: bool = False
|
|
464
|
+
|
|
465
|
+
# public + not (ignore_pure + ignore_py)
|
|
466
|
+
wrapped_public_methods: typing.List[FunctionContext] = field(default_factory=list)
|
|
467
|
+
|
|
468
|
+
# only if trampoline:
|
|
469
|
+
# - protected + not (ignore_pure + ignore_py)
|
|
470
|
+
wrapped_protected_methods: typing.List[FunctionContext] = field(
|
|
471
|
+
default_factory=list
|
|
472
|
+
)
|
|
473
|
+
|
|
474
|
+
#: Public enums + unnamed enums
|
|
475
|
+
enums: typing.List[EnumContext] = field(default_factory=list)
|
|
476
|
+
unnamed_enums: typing.List[EnumContext] = field(default_factory=list)
|
|
477
|
+
|
|
478
|
+
#: Extra autodetected 'using' directives
|
|
479
|
+
auto_typealias: typing.List[str] = field(default_factory=list)
|
|
480
|
+
|
|
481
|
+
#: vcheck are various static asserts that check things about the
|
|
482
|
+
#: inline functions
|
|
483
|
+
vcheck_fns: typing.List[FunctionContext] = field(default_factory=list)
|
|
484
|
+
|
|
485
|
+
child_classes: typing.List["ClassContext"] = field(default_factory=list)
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
@dataclass
|
|
489
|
+
class TemplateInstanceContext:
|
|
490
|
+
#: Name of parent variable in initializer
|
|
491
|
+
scope_var: str
|
|
492
|
+
|
|
493
|
+
#: Name of variable in initializer
|
|
494
|
+
var_name: str
|
|
495
|
+
|
|
496
|
+
py_name: str
|
|
497
|
+
|
|
498
|
+
full_cpp_name_identifier: str
|
|
499
|
+
binder_typename: str
|
|
500
|
+
|
|
501
|
+
params: typing.List[typing.Union[int, str]]
|
|
502
|
+
|
|
503
|
+
header_name: str
|
|
504
|
+
|
|
505
|
+
doc_set: Documentation
|
|
506
|
+
doc_add: Documentation
|
|
507
|
+
|
|
508
|
+
#: If true, instantiated in class order
|
|
509
|
+
matched: bool = False
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
@dataclass
|
|
513
|
+
class HeaderContext:
|
|
514
|
+
"""
|
|
515
|
+
Data derived from parsing a single header
|
|
516
|
+
"""
|
|
517
|
+
|
|
518
|
+
# Name in toml
|
|
519
|
+
hname: str
|
|
520
|
+
|
|
521
|
+
# config file for this
|
|
522
|
+
orig_yaml: pathlib.Path
|
|
523
|
+
|
|
524
|
+
extra_includes_first: typing.List[str]
|
|
525
|
+
extra_includes: typing.List[str]
|
|
526
|
+
inline_code: typing.Optional[str]
|
|
527
|
+
|
|
528
|
+
#: Path to the parsed header relative to some root
|
|
529
|
+
rel_fname: str
|
|
530
|
+
|
|
531
|
+
#: True if <pybind11/operators.h> is needed
|
|
532
|
+
need_operators_h: bool = False
|
|
533
|
+
|
|
534
|
+
using_declarations: typing.List[PQName] = field(default_factory=list)
|
|
535
|
+
|
|
536
|
+
# TODO: anon enums?
|
|
537
|
+
enums: typing.List[EnumContext] = field(default_factory=list)
|
|
538
|
+
|
|
539
|
+
# classes that are not contained in other classes
|
|
540
|
+
classes: typing.List[ClassContext] = field(default_factory=list)
|
|
541
|
+
|
|
542
|
+
# same as classes, but only those that have trampolines
|
|
543
|
+
classes_with_trampolines: typing.List[ClassContext] = field(default_factory=list)
|
|
544
|
+
|
|
545
|
+
# for diagnostic purposes
|
|
546
|
+
ignored_classes: typing.List[str] = field(default_factory=list)
|
|
547
|
+
|
|
548
|
+
functions: typing.List[FunctionContext] = field(default_factory=list)
|
|
549
|
+
|
|
550
|
+
# trampolines
|
|
551
|
+
|
|
552
|
+
# template_classes
|
|
553
|
+
template_instances: typing.List[TemplateInstanceContext] = field(
|
|
554
|
+
default_factory=list
|
|
555
|
+
)
|
|
556
|
+
|
|
557
|
+
type_caster_includes: typing.List[str] = field(default_factory=list)
|
|
558
|
+
user_typealias: typing.List[str] = field(default_factory=list)
|
|
559
|
+
|
|
560
|
+
using_ns: typing.List[str] = field(default_factory=list)
|
|
561
|
+
|
|
562
|
+
# All namespaces that occur in the file
|
|
563
|
+
namespaces: typing.List[str] = field(default_factory=list)
|
|
564
|
+
|
|
565
|
+
subpackages: typing.Dict[str, str] = field(default_factory=dict)
|
|
566
|
+
|
|
567
|
+
# key: class name, value: list of classes this class depends on
|
|
568
|
+
class_hierarchy: typing.Dict[str, typing.List[str]] = field(default_factory=dict)
|
|
569
|
+
|
|
570
|
+
has_vcheck: bool = False
|