gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I think I figured out how Apple did their toll-free bridging.


From: Chan Maxthon
Subject: Re: I think I figured out how Apple did their toll-free bridging.
Date: Sat, 18 May 2013 05:48:42 +0800

And about memory management. All CoreFoundation objects places the field for 
retain count at the same offset as Cocoa objects do. Since all CoreFoundation 
objects have their respective isa field pointing to their corresponding Cocoa 
class, no matter public or private, the standard Objective-C destructor dealloc 
is used for CoreFoundation objects as well. Modern CFRetain and CFRelease 
functions are mere wrappers around objc_retain and objc_release functions from 
libobjc2. 

发自我的 iPhone

在 2013-5-18,5:35,Chan Maxthon <address@hidden> 写道:

> I discovered this from stack traces of toll-free bridged calls.
> 
> All CoreFoundation objects have an Objective-C isa pointer. For toll-free 
> bridged objects, this pointer points to an Objective-C class which is a 
> subclass of the corresponding class cluster public class, like for CFArray 
> the subclass is called __NSCFArray. This Objective-C class maps calls from 
> Objective-C public API to corresponding CoreFoundation calls.
> 
> All CoreFoundation functions that take toll-free-bridge-able objects detects 
> if the argument passed in is CoreFoundation object. If Cocoa objects are 
> used, base on the situation, either the object will be copied into its 
> CoreFoundation counterpart, or the call will be mapped back to Cocoa.
> 
> This entangled nature guaranteed that at least all toll-free bridging private 
> Cocoa classes, their public base classes and NSObject are inside 
> CoreFoundation binary, or the linker will be seriously confused.
> 
> 发自我的 iPhone
> _______________________________________________
> Gnustep-dev mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/gnustep-dev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]