diff --git a/include/wx/defs.h b/include/wx/defs.h index 629706b1c8..0a5c6c158e 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -2648,6 +2648,7 @@ typedef int (* LINKAGEMODE wxListIterateFunction)(void *current); #ifdef __DARWIN__ #define DECLARE_WXOSX_OPAQUE_CFREF( name ) typedef struct __##name* name##Ref; #define DECLARE_WXOSX_OPAQUE_CONST_CFREF( name ) typedef const struct __##name* name##Ref; + #endif #ifdef __WXMAC__ @@ -2675,15 +2676,43 @@ typedef void* WXDisplay; * core frameworks */ -typedef const void * CFTypeRef; +#if __has_attribute(objc_bridge) && __has_feature(objc_bridge_id) && __has_feature(objc_bridge_id_on_typedefs) -DECLARE_WXOSX_OPAQUE_CONST_CFREF( CFData ) -DECLARE_WXOSX_OPAQUE_CONST_CFREF( CFString ) -typedef struct __CFString * CFMutableStringRef; -DECLARE_WXOSX_OPAQUE_CONST_CFREF( CFDictionary ) +#ifdef __OBJC__ +@class NSArray; +@class NSString; +@class NSData; +@class NSDictionary; +#endif -DECLARE_WXOSX_OPAQUE_CONST_CFREF( CFArray ) -typedef struct __CFArray * CFMutableArrayRef; +#define WXOSX_BRIDGED_TYPE(T) __attribute__((objc_bridge(T))) +#define WXOSX_BRIDGED_MUTABLE_TYPE(T) __attribute__((objc_bridge_mutable(T))) + +#else + +#define WXOSX_BRIDGED_TYPE(T) +#define WXOSX_BRIDGED_MUTABLE_TYPE(T) + +#endif + +#define DECLARE_WXOSX_BRIDGED_TYPE_AND_CFREF( name ) \ + typedef const struct WXOSX_BRIDGED_TYPE(NS##name) __CF##name* CF##name##Ref; +#define DECLARE_WXOSX_BRIDGED_MUTABLE_TYPE_AND_CFREF( name ) \ + typedef struct WXOSX_BRIDGED_MUTABLE_TYPE(NSMutable##name) __CF##name* CFMutable##name##Ref; + +typedef const WXOSX_BRIDGED_TYPE(id) void * CFTypeRef; + +DECLARE_WXOSX_BRIDGED_TYPE_AND_CFREF( Data ) +DECLARE_WXOSX_BRIDGED_MUTABLE_TYPE_AND_CFREF( Data ) + +DECLARE_WXOSX_BRIDGED_TYPE_AND_CFREF( String ) +DECLARE_WXOSX_BRIDGED_MUTABLE_TYPE_AND_CFREF( String ) + +DECLARE_WXOSX_BRIDGED_TYPE_AND_CFREF( Dictionary ) +DECLARE_WXOSX_BRIDGED_MUTABLE_TYPE_AND_CFREF( Dictionary ) + +DECLARE_WXOSX_BRIDGED_TYPE_AND_CFREF( Array ) +DECLARE_WXOSX_BRIDGED_MUTABLE_TYPE_AND_CFREF( Array ) DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoopSource ) DECLARE_WXOSX_OPAQUE_CONST_CFREF( CTFont )