Skip to content

Commit 4df716c

Browse files
committed
more cpython abi support
1 parent bd1a5c6 commit 4df716c

File tree

8 files changed

+1949
-5483
lines changed

8 files changed

+1949
-5483
lines changed

docs/cpython_bindings.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CPython ABI Bindings
22

3-
There is currently limited support for most of the CPython ABI.
3+
Pointers.py provides bindings out of the box for most of the CPython ABI.
44

55
The ABI follows the naming convention of `Py<namespace>_<method>`, so you may use one by importing the namespace from pointers.py:
66

@@ -44,3 +44,15 @@ from pointers import PyEval, struct_cast
4444
frame = struct_cast(PyEval.get_frame())
4545
# frame is now a valid frame object!
4646
```
47+
48+
## Limitations
49+
50+
I did say above that there is support for _most_ of the ABI, so what isn't available right now?
51+
52+
- Any function using a format string
53+
- Any function defined in the header file without parameter names
54+
- Anything using a macro (such as `_Py_NO_RETURN`) in its signature
55+
56+
However, there are a few other functions that are unsupported due to arbitrary reasons.
57+
58+
**These will all be supported in the future.**

gen.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,11 @@ async def _gen_ct_bindings() -> dict[str, list[str]]:
348348
if line[index + 1] != " ":
349349
patched_line += " "
350350

351+
352+
patched_line = patched_line.replace(" *", "* ").replace("* *", "** ").replace(" ", " ").replace(" )", ")").replace(" ,", ",")
351353
result = await _gen_str(
352354
None,
353-
patched_line.replace(" *", "* ").replace("* *", "** "),
355+
patched_line,
354356
params,
355357
None,
356358
)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ classifiers = [
2323
dependencies = [
2424
"typing_extensions",
2525
]
26-
version = "2.4.0"
26+
version = "2.5.0"
2727

2828
[project.urls]
2929
Documentation = "https://pointers.zintensity.dev"

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
if __name__ == "__main__":
77
setup(
88
name="pointers.py",
9-
version="2.4.0",
9+
version="2.5.0",
1010
packages=["pointers"],
1111
license="MIT",
1212
project_urls={

src/pointers/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
from .structure import Struct, StructPointer
3434
from .util import NULL, Nullable, handle, raw_type, struct_cast
3535

36-
__version__ = "2.2.0"
36+
__version__ = "2.5.0"
3737
__license__ = "MIT"

0 commit comments

Comments
 (0)