-
Notifications
You must be signed in to change notification settings - Fork 111
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
Improve parameters parsing and fix callbacks #125
Conversation
For the moment I worked to be able to reproduce (more or less) the same generated wrappers. Here it is a diff between what I generated with master 943e80a and this branch 1579c1579
< MediaReadCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_ssize_t), ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.c_size_t)
---
> MediaReadCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_ssize_t), ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t)
5876c5876
< ctypes.c_int, Media, MediaSlaveType, ctypes.c_uint, ctypes.c_char_p)
---
> ctypes.c_int, Media, MediaSlaveType, ctypes.c_int, ctypes.c_char_p)
5902c5902
< ctypes.c_uint, Media, ctypes.POINTER(ctypes.POINTER(MediaSlave)))
---
> ctypes.c_int, Media, ctypes.POINTER(ctypes.POINTER(MediaSlave)))
5913c5913
< None, ctypes.POINTER(MediaSlave), ctypes.c_uint)
---
> None, ctypes.POINTER(MediaSlave), ctypes.c_int)
7250c7250
< None, MediaPlayer, Position, ctypes.c_uint)
---
> None, MediaPlayer, Position, ctypes.c_int)
7659c7659
< ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint)
---
> ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.c_char_p, ctypes.c_int, ctypes.c_int)
Some highlights:
|
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.
Great work @albestro , thanks. It all looks good to me, apart from the small remark in the review. Could you fix this, so that I can simply merge the pull request as-is? The cherry on the cake would be to add a test in the tests/test.py
file if it you can figure out one, but this is more optional.
remove superflous try..except block
- improvement for function pointer regex - improvements for Par parse_param - refactored parse_param as Par classmethod
I've refactored the Moreover, I implemented some very basic tests for There is also a minor fix in another test. |
Awesome contribution, many thanks. I just merged it. |
Close #117
As per discussion in the issue, I tried to improve a bit the parser for parameters. It is far from being perfect.
The new method should is not regex based, it should be able to detect all types and pointers with related constness. The constness information is stored inside
Par
as a list of bools, intrinsically giving two information:len==0
), a pointer (len==1
) or a pointer to pointer (len==2
)e.g.
const int *
->[True, False]
const int * const
->[True, True]
int * const
->[False, True]