Changed all the things that used NSMutableDictionary to store views as keys to not do so. Will test next.

This commit is contained in:
Pietro Gagliardi 2015-08-17 01:29:34 -04:00
parent 22551413aa
commit eb0b1d1ab7
4 changed files with 15 additions and 25 deletions

View File

@ -9,7 +9,7 @@ struct uiButton {
};
@interface buttonDelegateClass : NSObject {
NSMutableDictionary *buttons;
NSMapTable *buttons;
}
- (IBAction)onClicked:(id)sender;
- (void)registerButton:(uiButton *)b;
@ -22,7 +22,7 @@ struct uiButton {
{
self = [super init];
if (self)
self->buttons = [NSMutableDictionary new];
self->buttons = newMap();
return self;
}
@ -37,18 +37,15 @@ struct uiButton {
- (IBAction)onClicked:(id)sender
{
NSValue *v;
uiButton *b;
v = (NSValue *) [self->buttons objectForKey:sender];
b = (uiButton *) [v pointerValue];
b = (uiButton *) mapGet(self->buttons, sender);
(*(b->onClicked))(b, b->onClickedData);
}
- (void)registerButton:(uiButton *)b
{
[self->buttons setObject:[NSValue valueWithPointer:b]
forKey:b->button];
mapSet(self->buttons, b->button, b);
[b->button setTarget:self];
[b->button setAction:@selector(onClicked:)];
}

View File

@ -9,7 +9,7 @@ struct uiCheckbox {
};
@interface checkboxDelegateClass : NSObject {
NSMutableDictionary *buttons; // TODO rename to checkboxes?
NSMapTable *buttons; // TODO rename to checkboxes?
}
- (IBAction)onToggled:(id)sender;
- (void)registerCheckbox:(uiCheckbox *)c;
@ -22,7 +22,7 @@ struct uiCheckbox {
{
self = [super init];
if (self)
self->buttons = [NSMutableDictionary new];
self->buttons = newMap();
return self;
}
@ -37,18 +37,15 @@ struct uiCheckbox {
- (IBAction)onToggled:(id)sender
{
NSValue *v;
uiCheckbox *c;
v = (NSValue *) [self->buttons objectForKey:sender];
c = (uiCheckbox *) [v pointerValue];
c = (uiCheckbox *) mapGet(self->buttons, sender);
(*(c->onToggled))(c, c->onToggledData);
}
- (void)registerCheckbox:(uiCheckbox *)c
{
[self->buttons setObject:[NSValue valueWithPointer:c]
forKey:c->button];
mapSet(self->buttons, c->button, c);
[c->button setTarget:self];
[c->button setAction:@selector(onToggled:)];
}

View File

@ -11,7 +11,7 @@ struct uiEntry {
};
@interface entryDelegateClass : NSObject<NSTextFieldDelegate> {
NSMutableDictionary *entries;
NSMapTable *entries;
}
- (void)controlTextDidChange:(NSNotification *)note;
- (void)registerEntry:(uiEntry *)e;
@ -24,7 +24,7 @@ struct uiEntry {
{
self = [super init];
if (self)
self->entries = [NSMutableDictionary new];
self->entries = newMap();
return self;
}
@ -39,18 +39,15 @@ struct uiEntry {
- (void)controlTextDidChange:(NSNotification *)note
{
NSValue *v;
uiEntry *e;
v = (NSValue *) [self->entries objectForKey:[note object]];
e = (uiEntry *) [v pointerValue];
e = (uiEntry *) mapGet(self->entries, [note object]);
(*(e->onChanged))(e, e->onChangedData);
}
- (void)registerEntry:(uiEntry *)e
{
[self->entries setObject:[NSValue valueWithPointer:e]
forKey:e->textfield];
mapSet(self->entries, e->textfield, e);
[e->textfield setDelegate:self];
}

View File

@ -11,7 +11,7 @@ struct uiWindow {
};
@interface windowDelegateClass : NSObject<NSWindowDelegate> {
NSMutableDictionary *windows;
NSMapTable *windows;
}
- (BOOL)windowShouldClose:(id)sender;
- (void)registerWindow:(uiWindow *)w;
@ -25,7 +25,7 @@ struct uiWindow {
{
self = [super init];
if (self)
self->windows = [NSMutableDictionary new];
self->windows = newMap();
return self;
}
@ -51,8 +51,7 @@ struct uiWindow {
- (void)registerWindow:(uiWindow *)w
{
[self->windows setObject:[NSValue valueWithPointer:w]
forKey:w->window];
mapSet(self->windows w->window, w);
[w->window setDelegate:self];
}