libui/redo/darwin/map.m

28 lines
611 B
Mathematica
Raw Normal View History

// 17 august 2015
#import "uipriv_darwin.h"
// unfortunately NSMutableDictionary copies its keys, meaning we can't use it for pointers
// hence, this file
NSMapTable *newMap(void)
{
2015-08-21 23:30:36 -05:00
return [NSMapTable mapTableWithKeyOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
valueOptions:NSPointerFunctionsOpaqueMemory];
}
void *mapGet(NSMapTable *map, id key)
{
NSValue *v;
2015-08-17 00:41:04 -05:00
v = (NSValue *) [map objectForKey:key];
return [v pointerValue];
}
void mapSet(NSMapTable *map, id key, void *value)
{
NSValue *v;
v = [NSValue valueWithPointer:value];
[map setObject:v forKey:key];
}