Skip to content

Commit

Permalink
more cpython abi support
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroIntensity committed Dec 22, 2022
1 parent bd1a5c6 commit 4df716c
Show file tree
Hide file tree
Showing 8 changed files with 1,949 additions and 5,483 deletions.
14 changes: 13 additions & 1 deletion docs/cpython_bindings.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CPython ABI Bindings

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

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

Expand Down Expand Up @@ -44,3 +44,15 @@ from pointers import PyEval, struct_cast
frame = struct_cast(PyEval.get_frame())
# frame is now a valid frame object!
```

## Limitations

I did say above that there is support for _most_ of the ABI, so what isn't available right now?

- Any function using a format string
- Any function defined in the header file without parameter names
- Anything using a macro (such as `_Py_NO_RETURN`) in its signature

However, there are a few other functions that are unsupported due to arbitrary reasons.

**These will all be supported in the future.**
4 changes: 3 additions & 1 deletion gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,11 @@ async def _gen_ct_bindings() -> dict[str, list[str]]:
if line[index + 1] != " ":
patched_line += " "


patched_line = patched_line.replace(" *", "* ").replace("* *", "** ").replace(" ", " ").replace(" )", ")").replace(" ,", ",")
result = await _gen_str(
None,
patched_line.replace(" *", "* ").replace("* *", "** "),
patched_line,
params,
None,
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
dependencies = [
"typing_extensions",
]
version = "2.4.0"
version = "2.5.0"

[project.urls]
Documentation = "https://pointers.zintensity.dev"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if __name__ == "__main__":
setup(
name="pointers.py",
version="2.4.0",
version="2.5.0",
packages=["pointers"],
license="MIT",
project_urls={
Expand Down
2 changes: 1 addition & 1 deletion src/pointers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
from .structure import Struct, StructPointer
from .util import NULL, Nullable, handle, raw_type, struct_cast

__version__ = "2.2.0"
__version__ = "2.5.0"
__license__ = "MIT"
Loading

0 comments on commit 4df716c

Please sign in to comment.