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
use void* in function signature? #380
Comments
The best way to accomplish this is through the metadata system, there is a decorator that can be used to change the default method signature but that interface is not rich enough in this case. The crash your getting is because the bridge by default assumes that all arguments are Objective-C objects ( With decorator:
The problem with this approach is that the To fix that, drop the decorator and register some metadata before defining the class:
Note: I wrote the code fragments above directly in the browser, there may be typos. BTW. I might implement full bindings for the. IOBluetooth framework in the future, although that depends on how much work that ends up being. |
wow, thats responsive! and did the job :) thanks a lot! now, another quick question: i need to call writeSync func writeSync(_ data: UnsafeMutableRawPointer!,
length: UInt16) -> IOReturn i thought i need to make a pointer with objc.context, is that correct? def synchronouslyWriteData_toRFCOMMChannel_(self, data, channel):
# return [channel writeSync:(void *)[data bytes] length:[data length]];
pointer = objc.context.register(data)
result = channel.writeSync_length_(pointer, len(data))
objc.context.unregister(pointer)
return result here, data is a bytes object and the call is unfortionately not writing the right data. |
You don't want to use In this case you want to do something similar to the registration for the protocol method, but with slightly less information because PyObjC can extract the basic type information from the ObjC runtime.
You can also use |
ok thanks! still i seem to not have it right. I am cleaning up my fork of pybluez to get rid of objc-libraries included in the package: https://github.com/hiaselhans/pybluez2/blob/master/bluetooth/macos/btsocket/delegate.py i figured length: UInt16 being a half argument i had to use _C_USHT but that didn't help either. |
and actually data is of type |
got it! thanks a lot for all the help |
Hello, thanks for the good library!
i want to make a delegate for an rfcomm connection. When i implement the corresponding function i end up with segfaults even when i'm doing nothing in the function call:
https://developer.apple.com/documentation/iobluetooth/iobluetoothrfcommchanneldelegate/1431822-rfcommchanneldata?language=objc
is there a decorator to transform a data-pointer with length to a buffer type? or similar?
thanks!
The text was updated successfully, but these errors were encountered: