Re: C++ framework <-> Cocoa
Re: C++ framework <-> Cocoa
- Subject: Re: C++ framework <-> Cocoa
- From: Andreas Monitzer <email@hidden>
- Date: Tue, 5 Jun 2001 20:24:50 +0200
On Tuesday, June 5, 2001, at 04:52 , Dennis C. De Mars wrote:
In theory, it should be possible to do this, although it would be a big
pain. You'd have to write some Objective C code that passed the selectors
back to the C++ code, then call the Objective C runtime method dispatcher
to
actually execute it. You'd have to link to the right libraries to get the
Objective C runtime in there. And you'd have to understand how Objective
C
works to get this to work.
It's not that complicated:
[objCInstance setIntValue:4711];
translates to
#ifdef __cplusplus
extern "C" {
#include <objc/objc.h>
#endif
id objc_msgSend (id self, SEL _cmd, ...);
#ifdef __cplusplus
}
#endif
void main() {
id objCInstance=...;
SEL setIntValue = sel_getUid("setIntValue:");
objc_msgSend(objCInstance,setIntValue,4711);
}
At least that's how it worked in PB, I haven't tried to compile it since
then.
andy
--
Description forthcoming.