Set up the infrastructure for replacing NSMutableDictionary with a proper non-copying map.
This commit is contained in:
parent
9d3ba0cfd7
commit
22551413aa
|
@ -13,6 +13,7 @@ osMFILES = \
|
||||||
darwin/group.m \
|
darwin/group.m \
|
||||||
darwin/label.m \
|
darwin/label.m \
|
||||||
darwin/main.m \
|
darwin/main.m \
|
||||||
|
darwin/map.m \
|
||||||
darwin/menu.m \
|
darwin/menu.m \
|
||||||
darwin/progressbar.m \
|
darwin/progressbar.m \
|
||||||
darwin/radiobuttons.m \
|
darwin/radiobuttons.m \
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
// TODO NSPointerFunctionsOpaquePersonality?
|
||||||
|
return [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsOpaqueMemory
|
||||||
|
valueOptions:NSPointerFunctionsOpaqueMemory];
|
||||||
|
}
|
||||||
|
|
||||||
|
void *mapGet(NSMapTable *map, id key)
|
||||||
|
{
|
||||||
|
NSValue *v;
|
||||||
|
|
||||||
|
v = (NSValue *) [self->items objectForKey:sender];
|
||||||
|
return [v pointerValue];
|
||||||
|
}
|
||||||
|
|
||||||
|
void mapSet(NSMapTable *map, id key, void *value)
|
||||||
|
{
|
||||||
|
NSValue *v;
|
||||||
|
|
||||||
|
v = [NSValue valueWithPointer:value];
|
||||||
|
[map setObject:v forKey:key];
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
// 28 april 2015
|
// 28 april 2015
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
|
// TODO migrate to map.m functions
|
||||||
|
|
||||||
static NSMutableArray *menus = nil;
|
static NSMutableArray *menus = nil;
|
||||||
static BOOL menusFinalized = NO;
|
static BOOL menusFinalized = NO;
|
||||||
|
|
||||||
|
@ -35,9 +37,7 @@ enum {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
// TODO NSPointerFunctionsOpaquePersonality?
|
self->items = newMap();
|
||||||
self->items = [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsOpaqueMemory
|
|
||||||
valueOptions:NSPointerFunctionsOpaqueMemory];
|
|
||||||
self->hasQuit = NO;
|
self->hasQuit = NO;
|
||||||
self->hasPreferences = NO;
|
self->hasPreferences = NO;
|
||||||
self->hasAbout = NO;
|
self->hasAbout = NO;
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
// menu.m
|
// menu.m
|
||||||
@interface menuManager : NSObject {
|
@interface menuManager : NSObject {
|
||||||
// unfortunately NSMutableDictionary copies its keys, meaning we can't use it for pointers
|
|
||||||
NSMapTable *items;
|
NSMapTable *items;
|
||||||
BOOL hasQuit;
|
BOOL hasQuit;
|
||||||
BOOL hasPreferences;
|
BOOL hasPreferences;
|
||||||
|
@ -58,5 +57,10 @@ extern void setHuggingPri(NSView *, NSLayoutPriority, NSLayoutConstraintOrientat
|
||||||
extern void layoutSingleView(NSView *, NSView *, int);
|
extern void layoutSingleView(NSView *, NSView *, int);
|
||||||
extern NSSize fittingAlignmentSize(NSView *);
|
extern NSSize fittingAlignmentSize(NSView *);
|
||||||
|
|
||||||
|
// map.m
|
||||||
|
extern NSMapTable *newMap(void);
|
||||||
|
extern void *mapGet(NSMapTable *map, id key);
|
||||||
|
extern void mapSet(NSMapTable *map, id key, void *value);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
#define PUT_CODE_HERE 0
|
#define PUT_CODE_HERE 0
|
||||||
|
|
Loading…
Reference in New Issue