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
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"
static NSMutableArray *allocations;
NSMutableArray *delegates;
NSMutableArray *uiprivDelegates;
void initAlloc(void)
void uiprivInitAlloc(void)
{
allocations = [NSMutableArray new];
delegates = [NSMutableArray new];
uiprivDelegates = [NSMutableArray new];
}
#define UINT8(p) ((uint8_t *) (p))
@ -20,12 +20,12 @@ void initAlloc(void)
#define CCHAR(p) ((const char **) (p))
#define TYPE(p) CCHAR(UINT8(p) + sizeof (size_t))
void uninitAlloc(void)
void uiprivUninitAlloc(void)
{
NSMutableString *str;
NSValue *v;
[delegates release];
[uiprivDelegates release];
if ([allocations count] == 0) {
[allocations release];
return;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -82,4 +82,9 @@ extern NSTextField *uiprivNewEditableTextField(void);
@end
extern uiWindow *uiprivWindowFromNSWindow(NSWindow *);
// alloc.m
extern NSMutableArray *uiprivDelegates;
extern void uiprivInitAlloc(void);
extern void uiprivUninitAlloc(void);
#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) {
windowDelegate = [[windowDelegateClass new] autorelease];
[delegates addObject:windowDelegate];
[uiprivDelegates addObject:windowDelegate];
}
[windowDelegate registerWindow:w];
uiWindowOnClosing(w, defaultOnClosing, NULL);