10 messages in net.java.dev.jna.usersAccessing static Objective-C from JNA
FromSent OnAttachments
James WayNov 6, 2007 8:00 am 
Timothy WallNov 13, 2007 1:00 pm 
Wayne MeissnerNov 13, 2007 3:48 pm 
Duncan McGregorNov 13, 2007 4:10 pm 
Timothy WallNov 14, 2007 5:34 am 
Timothy WallNov 14, 2007 5:58 am 
Timothy WallNov 14, 2007 11:23 am 
Duncan McGregorNov 14, 2007 12:49 pm 
Shawn EricksonNov 14, 2007 1:13 pm 
Wayne MeissnerNov 26, 2007 8:15 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Accessing static Objective-C from JNAActions...
From:Duncan McGregor (dun@oneeyedmen.com)
Date:Nov 13, 2007 4:10:11 pm
List:net.java.dev.jna.users

Hi, I'm hoping that some Mac guru can help out.

I'd like to wrap some Cocoa on the Mac. In order to do this I need to create NSString objects, passing them as id (int or long I guess) through JNA.

The function to create an NSString from a C string is NSString::stringWithUTF8String:(const char *). This is a static method on NSString, defined in NSString.h and hence linked from Foundation.Framework

I'd like to persuade the following to work

public interface Foundation extends Library { Foundation instance = (Foundation) Native.loadLibrary ("Foundation", Foundation.class);

int stringWithUTF8String(String string); }

While I can call plain C functions in Foundation, attempting to call stringWithUTF8String gives java.lang.UnsatisfiedLinkError: Cannot locate function 'stringWithUTF8String' at com.sun.jna.NativeLibrary.getFunctionAddress(NativeLibrary.java:228)

Am I being optimistic in hoping that, as stringWithUTF8String is static in NSString, that some naming convention will allow me to access it without dropping down into the JNI code that we're all here to avoid?

Thanks in anticipation