Migrated alloc.m functions.

This commit is contained in:
Pietro Gagliardi 2018-05-05 19:46:57 -04:00
parent 090c783147
commit eb28beff1b
11 changed files with 19 additions and 18 deletions

View File

@ -1,7 +1,3 @@
// alloc.m
extern NSMutableArray *delegates;
extern void initAlloc(void);
extern void uninitAlloc(void);
// autolayout.m // autolayout.m
extern NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRelation relation, id view2, NSLayoutAttribute attr2, CGFloat multiplier, CGFloat c, NSString *desc); extern NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRelation relation, id view2, NSLayoutAttribute attr2, CGFloat multiplier, CGFloat c, NSString *desc);

View File

@ -3,12 +3,12 @@
#import "uipriv_darwin.h" #import "uipriv_darwin.h"
static NSMutableArray *allocations; static NSMutableArray *allocations;
NSMutableArray *delegates; NSMutableArray *uiprivDelegates;
void initAlloc(void) void uiprivInitAlloc(void)
{ {
allocations = [NSMutableArray new]; allocations = [NSMutableArray new];
delegates = [NSMutableArray new]; uiprivDelegates = [NSMutableArray new];
} }
#define UINT8(p) ((uint8_t *) (p)) #define UINT8(p) ((uint8_t *) (p))
@ -20,12 +20,12 @@ void initAlloc(void)
#define CCHAR(p) ((const char **) (p)) #define CCHAR(p) ((const char **) (p))
#define TYPE(p) CCHAR(UINT8(p) + sizeof (size_t)) #define TYPE(p) CCHAR(UINT8(p) + sizeof (size_t))
void uninitAlloc(void) void uiprivUninitAlloc(void)
{ {
NSMutableString *str; NSMutableString *str;
NSValue *v; NSValue *v;
[delegates release]; [uiprivDelegates release];
if ([allocations count] == 0) { if ([allocations count] == 0) {
[allocations release]; [allocations release];
return; return;

View File

@ -104,7 +104,7 @@ uiButton *uiNewButton(const char *text)
if (buttonDelegate == nil) { if (buttonDelegate == nil) {
buttonDelegate = [[buttonDelegateClass new] autorelease]; buttonDelegate = [[buttonDelegateClass new] autorelease];
[delegates addObject:buttonDelegate]; [uiprivDelegates addObject:buttonDelegate];
} }
[buttonDelegate registerButton:b]; [buttonDelegate registerButton:b];
uiButtonOnClicked(b, defaultOnClicked, NULL); uiButtonOnClicked(b, defaultOnClicked, NULL);

View File

@ -120,7 +120,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
if (checkboxDelegate == nil) { if (checkboxDelegate == nil) {
checkboxDelegate = [[checkboxDelegateClass new] autorelease]; checkboxDelegate = [[checkboxDelegateClass new] autorelease];
[delegates addObject:checkboxDelegate]; [uiprivDelegates addObject:checkboxDelegate];
} }
[checkboxDelegate registerCheckbox:c]; [checkboxDelegate registerCheckbox:c];
uiCheckboxOnToggled(c, defaultOnToggled, NULL); uiCheckboxOnToggled(c, defaultOnToggled, NULL);

View File

@ -136,7 +136,7 @@ uiCombobox *uiNewCombobox(void)
if (comboboxDelegate == nil) { if (comboboxDelegate == nil) {
comboboxDelegate = [[comboboxDelegateClass new] autorelease]; comboboxDelegate = [[comboboxDelegateClass new] autorelease];
[delegates addObject:comboboxDelegate]; [uiprivDelegates addObject:comboboxDelegate];
} }
[comboboxDelegate registerCombobox:c]; [comboboxDelegate registerCombobox:c];
uiComboboxOnSelected(c, defaultOnSelected, NULL); uiComboboxOnSelected(c, defaultOnSelected, NULL);

View File

@ -177,7 +177,7 @@ uiEditableCombobox *uiNewEditableCombobox(void)
if (comboboxDelegate == nil) { if (comboboxDelegate == nil) {
comboboxDelegate = [[editableComboboxDelegateClass new] autorelease]; comboboxDelegate = [[editableComboboxDelegateClass new] autorelease];
[delegates addObject:comboboxDelegate]; [uiprivDelegates addObject:comboboxDelegate];
} }
[comboboxDelegate registerCombobox:c]; [comboboxDelegate registerCombobox:c];
uiEditableComboboxOnChanged(c, defaultOnChanged, NULL); uiEditableComboboxOnChanged(c, defaultOnChanged, NULL);

View File

@ -216,7 +216,7 @@ static uiEntry *finishNewEntry(Class class)
if (entryDelegate == nil) { if (entryDelegate == nil) {
entryDelegate = [[entryDelegateClass new] autorelease]; entryDelegate = [[entryDelegateClass new] autorelease];
[delegates addObject:entryDelegate]; [uiprivDelegates addObject:entryDelegate];
} }
[entryDelegate registerEntry:e]; [entryDelegate registerEntry:e];
uiEntryOnChanged(e, defaultOnChanged, NULL); uiEntryOnChanged(e, defaultOnChanged, NULL);

View File

@ -119,7 +119,7 @@ const char *uiInit(uiInitOptions *o)
delegate = [uiprivAppDelegate new]; delegate = [uiprivAppDelegate new];
[uiprivNSApp() setDelegate:delegate]; [uiprivNSApp() setDelegate:delegate];
initAlloc(); uiprivInitAlloc();
loadFutures(); loadFutures();
loadUndocumented(); loadUndocumented();
@ -148,7 +148,7 @@ void uiUninit(void)
[delegate release]; [delegate release];
[uiprivNSApp() setDelegate:nil]; [uiprivNSApp() setDelegate:nil];
[app release]; [app release];
uninitAlloc(); uiprivUninitAlloc();
} }
} }

View File

@ -138,7 +138,7 @@ uiSlider *uiNewSlider(int min, int max)
if (sliderDelegate == nil) { if (sliderDelegate == nil) {
sliderDelegate = [[sliderDelegateClass new] autorelease]; sliderDelegate = [[sliderDelegateClass new] autorelease];
[delegates addObject:sliderDelegate]; [uiprivDelegates addObject:sliderDelegate];
} }
[sliderDelegate registerSlider:s]; [sliderDelegate registerSlider:s];
uiSliderOnChanged(s, defaultOnChanged, NULL); uiSliderOnChanged(s, defaultOnChanged, NULL);

View File

@ -82,4 +82,9 @@ extern NSTextField *uiprivNewEditableTextField(void);
@end @end
extern uiWindow *uiprivWindowFromNSWindow(NSWindow *); extern uiWindow *uiprivWindowFromNSWindow(NSWindow *);
// alloc.m
extern NSMutableArray *uiprivDelegates;
extern void uiprivInitAlloc(void);
extern void uiprivUninitAlloc(void);
#import "OLD_uipriv_darwin.h" #import "OLD_uipriv_darwin.h"

View File

@ -387,7 +387,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
if (windowDelegate == nil) { if (windowDelegate == nil) {
windowDelegate = [[windowDelegateClass new] autorelease]; windowDelegate = [[windowDelegateClass new] autorelease];
[delegates addObject:windowDelegate]; [uiprivDelegates addObject:windowDelegate];
} }
[windowDelegate registerWindow:w]; [windowDelegate registerWindow:w];
uiWindowOnClosing(w, defaultOnClosing, NULL); uiWindowOnClosing(w, defaultOnClosing, NULL);