src/cocoa/application.mm in reflexion-0.1.3 vs src/cocoa/application.mm in reflexion-0.1.4

- old
+ new

@@ -1,9 +1,10 @@ // -*- objc -*- #include "reflex/application.h" +#include <assert.h> #import <Cocoa/Cocoa.h> #include <reflex/exception.h> #include "applicationdata.h" #import "cocoaapplication.h" @@ -22,45 +23,36 @@ } Application::Application () { - if (instance) error("multiple application instance."); - + if (instance) reflex_error("multiple application instance."); instance = this; - self->this_ = this; - self->self_ = NSApp ? [NSApp retain] : nil; - if (self->self_) - [self->self_ setApplicationData: self]; + if (NSApp) [NSApp bind: this]; } Application::~Application () { - if (self->self_) - { - [self->self_ release]; - self->self_ = nil; - } - self->this_ = NULL; - instance = NULL; } bool Application::run () { if (!*this) return false; - [self->self_ run]; + + [self->cocoa run]; return true; } bool Application::quit () { if (!*this) return false; - [self->self_ terminate: nil]; + + [self->cocoa terminate: nil]; return true; } bool Application::preference () @@ -70,27 +62,29 @@ bool Application::about () { if (!*this) return false; - [self->self_ orderFrontStandardAboutPanel: nil]; - return true; - } - bool - Application::get_name (String* name) const - { - if (!*this || !name) return false; - *name = self->name; + [self->cocoa orderFrontStandardAboutPanel: nil]; return true; } bool Application::set_name (const char* name) { if (!*this || !name) return false; + self->name = name; return true; + } + + const char* + Application::name () const + { + if (!*this) return NULL; + + return self->name.c_str(); } Application::operator bool () const { return self && *self;