4). In particular considering what I had done more recently in
trying to automatically generate directly from the Framework/API
header files to the jnilib. Eliminating the JNIDirect runtime
dependancy on gcc. Those efforts initially mostly directed at Cocoa
and it's frameworks. This you might remember is how we are told
JDirect used to work more less, based off the universal headers, I
don't claim it as an original idea.
Of course wheels can always be re-invented. It might be interesting
to see what might be created from scratch. I have a little too much
effort tied up in this.
It's always struck me that Java and Objective C are both very dynamic
languages. Java has Reflection and Objective C is all based on a few
C functions for sending messages (not to mention things like
NSInvocation)
It occurred to me that all one might really need to do is generate
(or type in!) Java interfaces for any given Objective C class. Then
one could use reflection and Java's java.lang.reflect.Proxy class...
something like this.
//Java 5 syntax - of course, you'd wrap up all this plumbing in a
nice library
int pointer = Something.createObject(...);
NSWhatever objCinstance = Proxy.newInstance
(NSWhatever.class.getClassLoader(), NSWhatever.class, new
ObjCInvocationHandler(pointer));
objCinstance.init();
...
class ObjectiveCInvocationHandler() implements InvocationHandler {
private final int instancePointer;
public ObjectiveCInvocationHandler(final int instancePointer) {
this.instancePointer = instancePointer;
}
public Object invoke(Object proxy,
Method method,
Object[] args)
throws Throwable {
... what goes here is non trivial, but also not rocket
science...?
you just need a JNI bridge to Objective C's NSInvocation or to
objc_msgSend itself?
}
Of course, there's a thousand other details to worry about -
marshalling parameters, reference counting, garbage collection.
But I always figured doing it this way avoids the tedious generation
of code for every single objective C class... well, you'd want to
generate a Java interface for the class, but you wouldn't need a body.
Just a thought... may or may not work in practice.
AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside
(see you later space cowboy, you can't take the sky from me)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden