comp.lang.ada
 help / color / mirror / Atom feed
From: Ivan Levashew <octagram@bluebottle.com>
Subject: Re: Interfacing with Objective-C or Python
Date: Mon, 26 May 2008 15:25:15 +0700
Date: 2008-05-26T15:25:15+07:00	[thread overview]
Message-ID: <g1drq0$3g5$1@registered.motzarella.org> (raw)
In-Reply-To: 

Adrian Hoe пишет:
> Is there any way to interface Ada with Objective-C (or Python) without
> having a wrapper? Has anyone done this before?

Objective-C from Apple and from FSF have different way of dispatching calls.

Apple's one has objc_sendMsg varargs function. The best way is to have a 
C wrapper for every kind of varargs invokation since one can't be sure 
if passing some kind of argument is equivalent to passing it as a 
varargs argument. But if one is sure, one can completely eliminate ObjC 
wrapper. objc_sendMsg must be imported several times for every 
combination of arguments one is going to use it with. One will also need 
to map selectors' string representation to their integer representation 
with NSSelectorFromString. Frozen constant will do.

Then one just calls objc_sendMsg (objc-class-or-object, selector, arg1, 
arg2, ...). And also reference counting: Controlled's Adjust/Finalize 
must be mapped to NeXTSTEP's retain/release. I don't know much about 
exception handling.

> without having a wrapper?

ObjectiveC is like C++. There are at least 3 incompatible 
implementations: Apple, FSF, POC*. One either make a wrapper or go into 
details and make implementation-dependent binding. Cocoa APIs are 
partially duplicated in GNUStep and Cocotron, and Apple is rumored to 
release Cocoa for Windows [1] currently being tested on Safari for 
Windows. So it's usually better to make portable bindings. Since Skype 
API on Mac OS X is likely to remain tied to Apple ObjC, Skype is an 
exception.

What's the point in not having a wrapper?

*) Portable Object Compiler
[1]http://www.roughlydrafted.com/RD/RDM.Tech.Q2.07/A35C23B9-BD22-4478-BC30-4111CFC360B5.html

-- 
If you want to get to the top, you have to start at the bottom



  reply	other threads:[~2008-05-26  8:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-26  6:47 Interfacing with Objective-C or Python Adrian Hoe
2008-05-26  8:25 ` Ivan Levashew [this message]
2008-05-26  8:48   ` Adrian Hoe
2008-05-26  9:18     ` Ivan Levashew
2008-06-01  1:28       ` Adrian Hoe
2008-05-26  9:02 ` Sébastien
2008-06-01 19:40 ` [OT] Skype is dangerous (was 'Re: Interfacing with Objective-C or Python') Ivan Levashew
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox