Sorry for the lag,
* On Thu, 10 Jul 2008, Adam Strzelecki wrote:
Is it really technically impossible to access the
Quartz APIs or write
Mac applications using C?
Well it is possible, for example iTunes is non Objective-C Carbon
(API) app AFAIK. Problem is that Carbon (pure C interface) is
considered as deprecated by Apple and may disappear from future
releases of OSXes at all, most 98% of applications are Objective-C
Cocoa anyway. Moreover most of the functionality introduced in 10.5 or
10.4 went just into Cocoa, and never was backported to Carbon.
So it isn't matter that it isn't possible, but it is IMHO more
reasonable to do it in Objective-C.
Then what about some thunking from carbonic source code to binary
Objective-C code?
Well, I have found some text [1] on the web about bridging D (not C) [2]
with ObjectiveC:
| So basically, since the whole Objective-C runtime is accessible from C
| calls, it’s pretty easy to do whatever we want with it.
If that's true, then some MacOSy hacker should give it a try. The bigger
task here probably would be implementation of some callback stuff in C
with the right calling convention / ABI (as ObjC seems to send some kind
of "messages" back).
Somewhat scary part may be bridging of exception handling, but if Wine did
this for WinAPI, with gobjc/libFoundation present and with Apple docs
given [3] it should be doable also.
I googled a bit more. There are at least two ways of achieving this
mentioned in the docs of libFoundation: by using XML-RPC call and by
wrapping classes in ANSI-C APIs. [4]
And the last -- I found libffi for Unix-like systems which seems to be
used on the MacOS X [5]:
| On Mac OS X libffi is commonly used with BridgeSupport, which provides
| programming language neutral descriptions of framework interfaces, and
| Nu which binds direct Objective-C access from Lisp.
HTH.
[1]
http://michelf.com/weblog/2007/d-objc-bridge/
[2]
http://en.wikipedia.org/wiki/D_(programming_language)
[3]
http://www.google.lt/search?q=+objectivec+abi+site:developer.apple.com
[4]
http://www.opengroupware.org/en/devs/languages/ansic/index.html
[5]
http://en.wikipedia.org/wiki/Libffi