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
Patch to support xNVMe #38
Conversation
autopxd/__init__.py
Outdated
if hasattr(decl, "type") and hasattr(decl.type, "name") and decl.type.name in additional_ignore_declarations: | ||
continue | ||
|
||
if hasattr(decl, "decl") and hasattr(decl.decl, "name") and decl.decl.name in additional_ignore_declarations: | ||
continue | ||
|
||
if not hasattr(decl, "name") or decl.name not in (IGNORE_DECLARATIONS | additional_ignore_declarations): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love to hear, if there's a better way to do this.
@Baekalfen this is great! Can you get tests passing? |
Yes, I'll get it fixed. I realize the thing with anon nested structs (like below) isn't totally correct. I'll investigate further if it needs to be narrowed down or removed. int nested__d
int nested__e |
They should be fixed now to get the best of both worlds. The confusing came from trying to print the structs. This will work for any struct as long as it only has named nested structs inside it. cdef test_struct A = ...
A.nested.x = 2
print(A) But the same setup with a struct that contains a nested anon struct will result in a compile error along the lines of:
But dropping the cdef test_struct A = ...
A.nested.x = 2
print(A.a)
print(A.b)
print(A.c)
print(A.nested.x) |
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
…ered by autopxd Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
f6dab57
to
66ce9b8
Compare
@elijahr The tests and the formatting should all be done now, but there's something with the linting step in GHA. |
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
I removed the additional ignore thing. Using the |
This is great! Thanks so much for the contribution! |
@Baekalfen this has been released in https://pypi.org/project/autopxd2/2.1.1/ |
Fantastic! Thank you! |
Hi, I used autopxd over at xNVMe, and needed to patch a few things to make it work, and I thought it could be of use to others.
The commits should be self-contained and have each the functionality they describe.
An overview:
--regex
on command-line to allow arbitrary conversions. Some datatypes or syntax just doesn't get parsed correctly by autopxd. As a quick solution, I can hotfix something easily without making full and proper support in autopxd -- for example an opaque pointer in a function I don't need. (--regex 's/FILE \*/void */g'
).at least in some manner. See example below.cpdef
to make them accessible from Python as well as Cython for free.Possible to ignore known/defined declarations. Maybe there's a better way to do this, but I needed this to support multipleThere is a better way. The.h
files. This way, I can provide the declarations from other headers, so they are not repeated.whitelist
kwarg.wget
in favor ofurllib
. Not all distros haswget
(norcURL
) installed, so I opted for a native Python implementation. This works across all distros I have tried (xNVMe test run).I would love to get feedback from you, especially on the part I will highlight.