10 messages in net.java.dev.jna.usersRe: [jna-users] Constants defined in ...
FromSent OnAttachments
Timo HoepfnerNov 20, 2008 5:50 am 
Timothy WallNov 20, 2008 6:22 am 
Timo HoepfnerNov 20, 2008 7:10 am 
Timothy WallNov 20, 2008 7:33 am 
LYou...@gkservices.comNov 20, 2008 7:53 am 
Timo HoepfnerNov 20, 2008 2:58 pm 
Scott PalmerNov 27, 2008 7:10 am 
Stefan EndrullisNov 27, 2008 7:38 am 
Scott PalmerNov 27, 2008 8:22 am 
Daniel KaufmannNov 27, 2008 10:05 am 
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:Re: [jna-users] Constants defined in libraryActions...
From:Timo Hoepfner (th-@onlinehome.de)
Date:Nov 20, 2008 7:10:41 am
List:net.java.dev.jna.users

Hi Timothy,

Use NativeLibrary.getGlobalVariableAddress(String name). This will give you a pointer to the value, so you'll need to use Pointer.getXXX(0) to obtain the actual value of the "constant".

Thanks a lot!

But how I can get from the Pointer to a Structure subclass? Here's what I have by now:

public class CFDictionaryKeyCallBacks extends Structure { public int version; public CFDictionaryRetainCallBack retain; public CFDictionaryReleaseCallBack release; public CFDictionaryCopyDescriptionCallBack copyDescription; public CFDictionaryEqualCallBack equal; public CFDictionaryHashCallBack hash;

public CFDictionaryKeyCallBacks( int version, CFDictionaryRetainCallBack retain, CFDictionaryReleaseCallBack release, CFDictionaryCopyDescriptionCallBack copyDescription, CFDictionaryEqualCallBack equal, CFDictionaryHashCallBack hash) {

super(); this.version = version; this.retain = retain; this.release = release; this.copyDescription = copyDescription; this.equal = equal; this.hash = hash; }

// callbacks public interface CFDictionaryRetainCallBack extends Callback { CFType callback(CFAllocator allocator, CFType value); }

// ...

public static CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks () { NativeLibrary nativeLib = NativeLibrary.getInstance (CoreFoundationLibrary.LIBRARY_NAME); Pointer pointer = nativeLib.getGlobalVariableAddress ("kCFTypeDictionaryKeyCallBacks");

CFDictionaryKeyCallBacks result = ?????

return result; }

// ...

}

Thanks again for your help and for JNA in general... :)

Timo