Sha256: 4395b64e0e942d49271b0cfdd6ceaa0dda217c239f6abeea2d28dd0b457384d0

Contents?: true

Size: 1.85 KB

Versions: 26

Compression:

Stored size: 1.85 KB

Contents

// -*- objc -*-
#include "application.h"


#include <assert.h>
#include "reflex/exception.h"
#import "app_delegate.h"


extern "C" {
	char*** _NSGetArgv ();
	int*    _NSGetArgc ();
}


@interface ReflexAppDelegate (Bind)
	- (void) bind: (Reflex::Application*) application;
	- (BOOL) callOnStart;
@end


namespace Reflex
{


	namespace global
	{

		static Application* instance = NULL;

	}// global


	Application*
	app ()
	{
		return global::instance;
	}


	Application::Application ()
	{
		if (global::instance)
			reflex_error(__FILE__, __LINE__, "multiple application instances.");

		global::instance = this;
	}

	Application::~Application ()
	{
		global::instance = NULL;
	}

	void
	Application::start ()
	{
		UIApplication* app                 = UIApplication.sharedApplication;
		id<UIApplicationDelegate> delegate = app.delegate;
		if (!delegate)
		{
			UIApplicationMain(*_NSGetArgc(), *_NSGetArgv(), nil, @"ReflexAppDelegate");
			return;
		}

		if ([delegate isKindOfClass: ReflexAppDelegate.class])
		{
			ReflexAppDelegate* reflex_delegate = (ReflexAppDelegate*) delegate;
			[reflex_delegate bind: this];
			[reflex_delegate callOnStart];
		}
	}

	void
	Application::quit ()
	{
		not_implemented_error(__FILE__, __LINE__);
	}

	void
	Application::set_name (const char* name)
	{
		if (!name)
			argument_error(__FILE__, __LINE__);

		self->name = name;
	}

	const char*
	Application::name () const
	{
		return self->name.c_str();
	}

	void
	Application::on_start (Event* e)
	{
	}

	void
	Application::on_quit (Event* e)
	{
	}

	void
	Application::on_motion (MotionEvent* e)
	{
	}

	void
	Application::on_preference (Event* e)
	{
	}

	void
	Application::on_about (Event* e)
	{
	}

	Application::operator bool () const
	{
		return true;
	}

	bool
	Application::operator ! () const
	{
		return !operator bool();
	}


	Application::Data::Data ()
	:	delegate(nil)
	{
	}


}// Reflex

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
reflexion-0.1.51 src/ios/application.mm
reflexion-0.1.50 src/ios/application.mm
reflexion-0.1.49 src/ios/application.mm
reflexion-0.1.48 src/ios/application.mm
reflexion-0.1.47 src/ios/application.mm
reflexion-0.1.46 src/ios/application.mm
reflexion-0.1.45 src/ios/application.mm
reflexion-0.1.44 src/ios/application.mm
reflexion-0.1.43 src/ios/application.mm
reflexion-0.1.42 src/ios/application.mm
reflexion-0.1.41 src/ios/application.mm
reflexion-0.1.40 src/ios/application.mm
reflexion-0.1.39 src/ios/application.mm
reflexion-0.1.38 src/ios/application.mm
reflexion-0.1.37 src/ios/application.mm
reflexion-0.1.36 src/ios/application.mm
reflexion-0.1.35 src/ios/application.mm
reflexion-0.1.34 src/ios/application.mm
reflexion-0.1.33 src/ios/application.mm
reflexion-0.1.32 src/ios/application.mm