libui/darwin/map.m

30 lines
716 B
Mathematica
Raw Normal View History

// 17 august 2015
#import "uipriv_darwin.h"
2015-11-28 11:16:05 -06:00
// TODO are the NSValues being garbage collected underfoot? open menuless window and check the checkbox
// 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];
}