Thank you Timothy, Greg and Mike.
I had found the C interface to Objective-C (There's a tentative
wrapper at the end of this mail).
My problem was that in order to call Objective-C methods I need to
call NSSelectorFromString (a C function). This takes an NSString. In
order to get an NSString from a char* (and hence easy JNA
marshalling) I wanted to call the static method
NSString::stringWithUTF8String:(const char *), the problem being that
in order to call this static method I needed a selector, which meant
calling NSSelectorFromString, which needs an NSString... So I was
kind of hoping there was some short-cut to calling a static method,
maybe in the way that you can call C++ functions from C if you can
predict the name mangling.
Our real Cocoa hackers pointed out that CFString is compatible with
NSString and can be built with the plain C function
CFStringCreateWithCString, breaking the cycle and letting me get
selectors for other purposes.
I hope to have a reasonably general purpose Cocoa wrapper to
contribute soon.
Duncan
public interface FoundationLibrary extends Library {
public static FoundationLibrary library = (FoundationLibrary)
Native.loadLibrary("Foundation", FoundationLibrary.class);
void NSLog(Pointer pString, Pointer thing);
Pointer CFStringCreateWithCString(Pointer allocator, String
string, int encoding);
String CFStringGetCStringPtr(Pointer string, int encoding);
Pointer objc_getClass(String className);
Pointer class_createInstance(Pointer pClass, int extraBytes);
Pointer NSSelectorFromString(Pointer nssSelectorName);
Pointer objc_msgSend(Pointer receiver, Pointer selector,
Pointer... args);
}