2 * Trampoline functions for the ItemKeyFun callbacks.
5 #include <ItemKeyFun.h>
8 * \brief Trampoline function for the ItemKeyFun.hashcode callback.
10 * The default is to use the pointer itself.
12 unsigned long ItemKeyFun_hashcode(void *this,void *key) {
13 ItemKeyFun *type = (ItemKeyFun*) this;
14 return (type && type->hashcode)? type->hashcode( type, key )
15 : (unsigned long) key;
19 * \brief Trampoline function for the ItemKeyFun.itemkey callback.
21 void *ItemKeyFun_itemkey(void *this,void *item) {
22 ItemKeyFun *type = (ItemKeyFun*) this;
23 return ( type && type->itemkey )? type->itemkey( type, item ) : item;
27 * \brief Trampoline function for the ItemKeyFun.haskey callback.
29 int ItemKeyFun_haskey(void *this,void *item,void *key) {
30 ItemKeyFun *type = (ItemKeyFun*) this;
31 if ( type && type->haskey ) {
32 return type->haskey( this, item, key );
34 void *ikey = ItemKeyFun_itemkey( this, item );
36 ItemKeyFun_releasekey( this, ikey );
41 * \brief Trampoline function for the ItemKeyFun.releasekey callback.
43 void ItemKeyFun_releasekey(void *this,void *key) {
44 ItemKeyFun *type = (ItemKeyFun*) this;
45 if( type && type->releasekey ) {
46 type->releasekey( type, key );
51 * Write a value in hexadecimal form, with "0x" followed by digits, if
52 * it fits within the given limit. Returns characters written, which
55 static int ItemKeyFun_puthexlong(char *p,unsigned long x,int limit) {
60 for ( ; y; y >>= 4, q++ );
67 for ( q++; x; x >>= 4, q-- ) {
84 * \brief Trampoline function for the ItemKeyFun.tostring callback.
86 int ItemKeyFun_tostring(void *this,void *item,char *buffer,int limit) {
87 ItemKeyFun *type = (ItemKeyFun*) this;
88 if( type && type->tostring ) {
89 return type->tostring( type, item, buffer, limit );
94 void *key = ItemKeyFun_itemkey( this, item );
96 void *code[] = { type, key, item };
97 ItemKeyFun_releasekey( this, key );
105 for ( k = 0; k < 3; k++ ) {
106 i = ItemKeyFun_puthexlong( p, (unsigned long) code[ k ], limit - n );
108 if ( i == 0 || n >= limit ) {