-
Notifications
You must be signed in to change notification settings - Fork 50
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
Some suggestions regarding objc2-foundation and block2 #615
Comments
Thanks for the review!
This would indeed be very nice, it's tracked in #518.
Hmm, the issue is that the let s: CFString = ...;
let ptr: CFStringRef = s.as_concrete_TypeRef();
let ptr: *const NSString = s.cast();
// SAFETY: CFString is toll-free bridged with NSString
let s: &NSString = unsafe { ptr.as_ref().unwrap() };
The problem here is that in the future, I'd like to use these encodings to emit block encodings properly, which is used by some methods, see #442 (and #434 for a workaround). Specifically for #[repr(transparent)]
struct CustomCFStringRef(CFStringRef);
// SAFETY: `CustomCFStringRef` is `#[repr(transparent)]` over `CFStringRef`
unsafe impl Encode for CustomCFStringRef {
const ENCODING: Encoding = Encoding::Pointer(&Encoding::Struct("__CFString", &[]));
} And pass |
I've added more detailed documentation on interop with |
When using NSArray or NSDictionary, their values are usually generic types, so they need to be defined using AnyObject, such as
NSMutableDictionary::<NSString, AnyObject>
. However, for types like NSNumber, multiple calls tointo_super
or unsafe methods such asId::cast
are required to convert them to AnyObject. Considering the frequency of this operation, could a safe method be provided to complete the conversion from NSNumber to AnyObject in one step?When using many Apple frameworks, it is necessary to pass the static CFString exported from the framework to NSString. Could a method be added for NSString, create NString from a raw pointer?
When using block2, all parameter and return value types must implement Encode trait, but many Apple frameworks do not use Objective-C interfaces and types. Could a feature be added to block2 to allow it to be used in C interface framework wrappers, replace block?
The text was updated successfully, but these errors were encountered: