-
Notifications
You must be signed in to change notification settings - Fork 13
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 PointerHandler #8
Conversation
@@ -86,6 +86,9 @@ def from_param(self, obj): | |||
if isinstance(obj, str): | |||
if issubclass(self.pointer_type, (POINTER(Int16), POINTER(UInt16))): | |||
return obj | |||
elif isinstance(obj, int): | |||
if issubclass(self.pointer_type, (POINTER(Int32), POINTER(UInt32))): | |||
return byref(self.pointer_type._type_(obj)) |
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 suppose it is impossible to pass python's int by reference. obj
can not be changed by function.
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.
when we are passing python class as argument instead of ctypes classes, we don't care about the object reference.
This is creating reference to move the final value correctly to that function. (auto push the integer to type of argument then assign to its reference)
But if you have better idea, I'll be happy to know.
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.
If you aim to pass int value and don't aim to receive result value, I have nothing else to say.
Is this ready to merge? |
Hi @ynkdir , |
I will commit some changes before you complete it. |
c723275 seems reasonable. I didn't test yet but seems works. |
Partially _fixes #4 (comment)