-
Notifications
You must be signed in to change notification settings - Fork 8
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
Feature Request: Enhanche generate_bindings
s niceobject_prefix
with something like niceobject_firstarg
#10
Comments
I'm not sure exactly what you're asking for, so providing a set of example functions might help me understand. I feel like I'm missing something. Did you instead mean to say that you'd like to identify the handle arg by name rather than position? |
It could be that I misunderstood the docstring of // Example header file
typedef void* HANDLE;
int GeneralGetDeviceList(uint* devList, uint listSize);
void GeneralGetErrorString(int errCode, char *recvBuf, uint bufSize);
int GeneralOpenMotor(uint motorID, HANDLE *phMotor);
int MotorClose(HANDLE hMotor);
... But if the prefix of these function would be also // Example header file
typedef void* HANDLE;
int GeneralGetDeviceList(uint* devList, uint listSize);
void GeneralGetErrorString(int errCode, char *recvBuf, uint bufSize);
int GeneralOpenMotor(uint motorID, HANDLE *phMotor);
int GeneralClose(HANDLE hMotor);
... Instead one could look at the name of first argument to determine if it belongs in the NiceObj subclass. |
By the way, it seems the current version of header_paths, predef_path = handle_header_path(header_info) But handle_header_path also requires the basedir. |
As a stop-gap solution I wrote a simpler binding generator based on the argnames dict of the low-level binding. |
I see, I didn't realize you were talking about |
Also related, it there a way to access the original type of a function argument? The types which are accessible via cffi are already in a reduced form (e.g. most basic type and missing consts). The original types can be helpful to automate to generate the mid-level bindings. For example the library I am currently rewriting the binding uses |
If they're not accessible via cffi, then no. I'd be willing to accept a PR that adds this kind of information to the compiled module. Check out the The basic idea would be to use a If you do this, it's probably best to work on the |
Is it possible to just modify the Playing around, I think it is enough to change the following visitor in
to
is enough? But I don't understand why names is a list yet. |
You don't really need to know anything about parsing, you just need to traverse an already-parsed AST from pycparser. You can explore the typical structure of a pycparser AST by playing around with some test strings of your own, e.g.
And yes, it would be natural to modify the |
For the libraries I wrote a binding, the functions taking a handle are not identifiable by its prefix, but are always identifiable by its first arg. Therefore something like
niceobject_firstarg
taking the name of the handle arg would be really nice.The text was updated successfully, but these errors were encountered: