Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctypeslib: possible alternative to ctypesgen? #213

Open
mara004 opened this issue Feb 21, 2024 · 1 comment
Open

ctypeslib: possible alternative to ctypesgen? #213

mara004 opened this issue Feb 21, 2024 · 1 comment

Comments

@mara004
Copy link
Contributor

mara004 commented Feb 21, 2024

It happens that I just came across trolldbois/ctypeslib.

At the first glance it seems like this might be a considerably cleaner, more modern alternative to ctypesgen.
To my understanding, it delegates parsing / AST creation to a clang binding, which should be more future proof given newer C standards, and there's no need for any custom lex/yacc.

Disclaimer: I haven't tested ctypeslib yet, but plan to do so eventually.

@mara004 mara004 changed the title ctypeslib: possible alternative to ctypesgen ctypeslib: possible alternative to ctypesgen? Feb 21, 2024
@mara004
Copy link
Contributor Author

mara004 commented Feb 21, 2024

FWIW, I was able to invoke ctypeslib on pdfium headers via

clang2py headers/*.h -d -l ../linux_x64/libpdfium.so -o out.py --clang-args "-I/usr/lib/gcc/x86_64-redhat-linux/12/include -I/usr/local/include/ -I/usr/include"

While it's definitely interesting, I'm not entirely happy with the output -- IMHO pypdfium2-ctypesgen's is better, at least for our use case.

I believe some features might be missing, like precise symbol control or proper dependency handling.
Not to mention that we have to specify system include dirs manually, there are some strange templates, and no __slots__ on structs.

However, it also offers some cute things ctypesgen doesn't, like taking over the C declaration as docstring, or doxygen comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant