embed a Ruby; load runtime/main.rb

This commit is contained in:
josh committed 2014-07-12 10:09:24 -04:00
1 parent a717ed4a38
commit f0db52e3d7
3 files changed
+38 -7

No files matched your search

+36 -7
View File
@@ -1,15 +1,44 @@
#include <iostream>
#include "GUI.h"
#include "Core.h"
#include "ruby.h"
using namespace std;
RUBY_GLOBAL_SETUP
static int bootstrap()
{
int rv = 0;
int err_state = 0;
rb_eval_string_protect(
"load File.expand_path('../../runtime/main.rb', $0)",
&err_state);
if (err_state != 0)
{
VALUE e = rb_errinfo();
VALUE s = rb_funcall(e, rb_intern("message"), 0);
fprintf(stderr, "%s\n", StringValueCStr(s));
rb_set_errinfo(Qnil);
rv = 1;
}
return rv;
}
int main(int argc, char *argv[])
{
jes::Core::instance.init(argv[0]);
jes::GUIRef gui = new jes::GUI();
if (!gui->load())
return 2;
return gui->run();
int rv = 0;
int ruby_argc = 1;
char prog_name[] = "main";
char * ruby_argv[] = {&prog_name[0]};
char ** ruby_argv_p = &ruby_argv[0];
ruby_sysinit(&ruby_argc, &ruby_argv_p);
{
RUBY_INIT_STACK;
ruby_init();
ruby_init_loadpath();
ruby_script(argv[0]);
rv = bootstrap();
ruby_finalize();
}
return rv;
}