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: Luboš Doležel
Subject: Re: I think I figured out how Apple did their toll-free bridging.
Date: Sat, 18 May 2013 21:51:14 +0200
User-agent: Roundcube Webmail/0.5

On Sat, 18 May 2013 05:35:50 +0800, Chan Maxthon wrote:
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.

Well, CoreBase is written around the same idea. In my fork on GitHub, toll-free bridging already works for most common types/classes - but the infrastructure was supplied by Stefan Bidi who modelled it after Apple.

--
Luboš Doležel



reply via email to

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