shoes_code shoes_start(char *path, char *uri) { shoes_code code = SHOES_OK; char bootup[SHOES_BUFSIZE]; int len = shoes_snprintf(bootup, SHOES_BUFSIZE, "begin;" "DIR = File.expand_path(File.dirname(%%q<%s>));" "$:.replace([DIR+'/ruby/lib/'+PLATFORM, DIR+'/ruby/lib', DIR+'/lib']);" "require 'shoes';" "DIR;" "rescue Object => e;" "puts(e.message);" "end", path); if (len < 0 || len >= SHOES_BUFSIZE) { QUIT("Path to script is too long."); } VALUE str = rb_eval_string(bootup); if (NIL_P(str)) return SHOES_QUIT; StringValue(str); strcpy(shoes_world->path, RSTRING(str)->ptr); char *load_uri_str = NULL; VALUE load_uri = rb_rescue2(CASTHOOK(shoes_start_begin), Qnil, CASTHOOK(shoes_start_exception), Qnil, rb_cObject, 0); if (!RTEST(load_uri)) return SHOES_QUIT; if (rb_obj_is_kind_of(load_uri, rb_eException)) { QUIT_ALERT(load_uri); } if (rb_obj_is_kind_of(load_uri, rb_cString)) load_uri_str = RSTRING_PTR(load_uri); code = shoes_load(load_uri_str); if (code != SHOES_OK) goto quit; code = shoes_app_start(shoes_world->apps, uri); quit: return code; }
lumi_code lumi_start(char *path, char *uri) { lumi_code code = LUMI_OK; char bootup[LUMI_BUFSIZE]; int len = lumi_snprintf(bootup, LUMI_BUFSIZE, "begin;" "DIR = File.expand_path(File.dirname(%%q<%s>));" "$:.replace([DIR+'/ruby/lib/'+(ENV['LUMI_RUBY_ARCH'] || RUBY_PLATFORM), DIR+'/ruby/lib', DIR+'/lib', '.']);" "require 'lumi';" "DIR;" "rescue Object => e;" "puts(e.message);" "end", path); if (len < 0 || len >= LUMI_BUFSIZE) { QUIT("Path to script is too long."); } VALUE str = rb_eval_string(bootup); if (NIL_P(str)) return LUMI_QUIT; StringValue(str); strcpy(lumi_world->path, RSTRING_PTR(str)); char *load_uri_str = NULL; VALUE load_uri = rb_rescue2(CASTHOOK(lumi_start_begin), Qnil, CASTHOOK(lumi_start_exception), Qnil, rb_cObject, 0); if (!RTEST(load_uri)) return LUMI_QUIT; if (rb_obj_is_kind_of(load_uri, rb_eException)) { QUIT_ALERT(load_uri); } if (rb_obj_is_kind_of(load_uri, rb_cString)) load_uri_str = RSTRING_PTR(load_uri); code = lumi_load(load_uri_str); if (code != LUMI_OK) goto quit; code = lumi_app_start(lumi_world->apps, uri); quit: return code; }
shoes_code shoes_load(char *path) { shoes_code code = SHOES_QUIT; char bootup[SHOES_BUFSIZE]; if (path) { sprintf(bootup, "Shoes.load(%%q<%s>);", path); VALUE v = rb_rescue2(CASTHOOK(shoes_load_begin), (VALUE)bootup, CASTHOOK(shoes_load_exception), Qnil, rb_cObject, 0); if (rb_obj_is_kind_of(v, rb_eException)) { QUIT_ALERT(v); } } return SHOES_OK; }