Sha256: 10c71632b606c0782630657f25655181b78444c0d35928e6bbae9ce9837fa9fb

Contents?: true

Size: 1.88 KB

Versions: 37

Compression:

Stored size: 1.88 KB

Contents

// -*- mode: objc -*-
#import <CRuby.h>
#import "RubySketch.h"
#include "../reflex/src/ios/view_controller.h"


extern "C"
{
	void Init_beeps_native ();
	void Init_rays_native ();
	void Init_reflex_native ();
}


static ReflexViewController* active_reflex_view_controller = nil;

static ReflexViewController*
ReflexViewController_create()
{
	return active_reflex_view_controller;
}

static void
ReflexViewController_show (UIViewController*, ReflexViewController*)
{
}


@implementation RubySketch

	+ (void) setup
	{
		static BOOL done = NO;
		if (done) return;
		done = YES;

		[CRuby addExtension:@"beeps/native"  init:^{Init_beeps_native();}];
		[CRuby addExtension:@"rays/native"   init:^{Init_rays_native();}];
		[CRuby addExtension:@"reflex/native" init:^{Init_reflex_native();}];

		for (NSString *ext in @[
			@"Xot",
			@"Rucy",
			@"Beeps",
			@"Rays",
			@"Reflex",
			@"Processing",
			@"RubySketch"
		]) [CRuby addLibrary:ext bundle:[NSBundle bundleForClass:RubySketch.class]];

		ReflexViewController_set_create_fun(ReflexViewController_create);
		ReflexViewController_set_show_fun(ReflexViewController_show);
	}

	+ (BOOL) start
	{
		return [self start:@"main.rb" rescue:nil];
	}

	+ (BOOL) startWithRescue: (RescueBlock) rescue
	{
		return [self start:@"main.rb" rescue:rescue];
	}

	+ (BOOL) start: (NSString*) path
	{
		return [self start:path rescue:nil];
	}

	+ (BOOL) start: (NSString*) path rescue: (RescueBlock) rescue
	{
		CRBValue* ret = [CRuby evaluate:[NSString stringWithFormat:@
			"raise 'already started' unless require 'rubysketch'\n"
			"load '%@'\n"
			"RubySketch::WINDOW.__send__ :end_draw\n"
			"RubySketch::WINDOW.show",
			path
		]];
		return ret && ret.toBOOL;
	}

	+ (void) setActiveReflexViewController: (id) reflexViewController
	{
		active_reflex_view_controller = reflexViewController;
	}

	+ (void) resetActiveReflexViewController
	{
		active_reflex_view_controller = nil;
	}

@end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
rubysketch-0.7 src/RubySketch.mm
rubysketch-0.6.3 src/RubySketch.mm
rubysketch-0.6.2 src/RubySketch.mm
rubysketch-0.5.38 src/RubySketch.mm
rubysketch-0.5.37 src/RubySketch.mm
rubysketch-0.5.36 src/RubySketch.mm
rubysketch-0.5.35 src/RubySketch.mm
rubysketch-0.5.34 src/RubySketch.mm
rubysketch-0.5.33 src/RubySketch.mm
rubysketch-0.5.32 src/RubySketch.mm
rubysketch-0.5.31 src/RubySketch.mm
rubysketch-0.5.30 src/RubySketch.mm
rubysketch-0.5.28 src/RubySketch.mm
rubysketch-0.5.27 src/RubySketch.mm
rubysketch-0.5.26 src/RubySketch.mm
rubysketch-0.5.25 src/RubySketch.mm
rubysketch-0.5.24 src/RubySketch.mm
rubysketch-0.5.23 src/RubySketch.mm
rubysketch-0.5.22 src/RubySketch.mm
rubysketch-0.5.21 src/RubySketch.mm