Added allocation logging to Objective-C objects. Fixed some Mac OS X build issues.

This commit is contained in:
Pietro Gagliardi 2015-04-08 00:26:49 -04:00
parent 33c67baa99
commit d6bf5d6d48
5 changed files with 27 additions and 1 deletions

View File

@ -9,6 +9,8 @@
@implementation button @implementation button
uiLogObjCClassAllocations
- (IBAction)buttonClicked:(id)sender - (IBAction)buttonClicked:(id)sender
{ {
(*(self.onClicked))(self.c, self.onClickedData); (*(self.onClicked))(self.c, self.onClickedData);

View File

@ -10,6 +10,8 @@
// thanks to mikeash and JtRip in irc.freenode.net/#macdev // thanks to mikeash and JtRip in irc.freenode.net/#macdev
@implementation uiContainer @implementation uiContainer
uiLogObjCClassAllocations
- (void)setFrameSize:(NSSize)s - (void)setFrameSize:(NSSize)s
{ {
uiSizing d; uiSizing d;

View File

@ -6,6 +6,8 @@
@implementation uiApplication @implementation uiApplication
uiLogObjCClassAllocations
// hey look! we're overriding terminate:! // hey look! we're overriding terminate:!
// we're going to make sure we can go back to main() whether Cocoa likes it or not! // we're going to make sure we can go back to main() whether Cocoa likes it or not!
// and just how are we going to do that, hm? // and just how are we going to do that, hm?

View File

@ -11,6 +11,24 @@
struct uiSizing { struct uiSizing {
}; };
#ifdef uiLogAllocations
#import <stdio.h>
#define uiLogObjCClassAllocations \
- (id)init \
{ \
self = [super init]; \
fprintf(stderr, "%p alloc %s\n", self, [[self className] UTF8String]); \
return self; \
} \
- (void)dealloc \
{ \
[super dealloc]; \
fprintf(stderr, "%p free\n", self); \
}
#else
#define uiLogObjCClassAllocations
#endif
// util_darwin.m // util_darwin.m
extern void setStandardControlFont(NSControl *); extern void setStandardControlFont(NSControl *);

View File

@ -12,6 +12,8 @@
@implementation uiWindowDelegate @implementation uiWindowDelegate
uiLogObjCClassAllocations
// TODO will this *destroy* the window? // TODO will this *destroy* the window?
- (BOOL)windowShouldClose:(id)win - (BOOL)windowShouldClose:(id)win
{ {
@ -39,7 +41,7 @@ uiWindow *uiNewWindow(char *title, int width, int height)
{ {
uiWindow *w; uiWindow *w;
w = (uiWindow *) uiAlloc(sizeof (uiWindow)); w = uiNew(uiWindow);
w->w = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height) w->w = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height)
styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask) styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)