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:Timothy Wall (twal@dev.java.net)
Date:Nov 20, 2008 6:22:20 am
List:net.java.dev.jna.users

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".

NativeLibrary is the object that sits behind a given Library interface mapping and does name lookups within the library.

On Nov 20, 2008, at 8:50 AM, Timo Hoepfner wrote:

Hi,

I'm trying to make some of Apple's C Libraries usable from java using JNA. So far it's going quite well, but there's one thing I can't find a solution for.

There are "constants" described in the header files, that I don't know how to get access to, as their value is defined in the library itself. E.g. I understand how I can define the following struct and callbacks with JNA, but I don't know how to get access to the value of "kCFTypeDictionaryKeyCallBacks" and "kCFCopyStringDictionaryKeyCallBacks":

typedef const void * (*CFDictionaryRetainCallBack)(CFAllocatorRef allocator, const void *value); typedef void (*CFDictionaryReleaseCallBack)(CFAllocatorRef allocator, const void *value); typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack)(const void *value); typedef Boolean (*CFDictionaryEqualCallBack)(const void *value1, const void *value2); typedef CFHashCode (*CFDictionaryHashCallBack)(const void *value); typedef struct { CFIndex version; CFDictionaryRetainCallBack retain; CFDictionaryReleaseCallBack release; CFDictionaryCopyDescriptionCallBack copyDescription; CFDictionaryEqualCallBack equal; CFDictionaryHashCallBack hash; } CFDictionaryKeyCallBacks;

/*! @constant kCFTypeDictionaryKeyCallBacks Predefined CFDictionaryKeyCallBacks structure containing a set of callbacks appropriate for use when the keys of a CFDictionary are all CFTypes. */ CF_EXPORT const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;

/*! @constant kCFCopyStringDictionaryKeyCallBacks Predefined CFDictionaryKeyCallBacks structure containing a set of callbacks appropriate for use when the keys of a CFDictionary are all CFStrings, which may be mutable and need to be copied in order to serve as constant keys for the values in the dictionary. */ CF_EXPORT const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks;

I'm not a big C expert, so please forgive me, if I miss something obvious...

Thanks for your help,