Exemplo n.º 1
0
static void mriBindingExecute()
{
	/* Normally only a ruby executable would do a sysinit,
	 * but not doing it will lead to crashes due to closed
	 * stdio streams on some platforms (eg. Windows) */
	int argc = 0;
	char **argv = 0;
	ruby_sysinit(&argc, &argv);

	ruby_setup();
	rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));

	Config &conf = shState->rtData().config;

	if (!conf.rubyLoadpaths.empty())
	{
		/* Setup custom load paths */
		VALUE lpaths = rb_gv_get(":");

		for (size_t i = 0; i < conf.rubyLoadpaths.size(); ++i)
		{
			std::string &path = conf.rubyLoadpaths[i];

			VALUE pathv = rb_str_new(path.c_str(), path.size());
			rb_ary_push(lpaths, pathv);
		}
	}

	RbData rbData;
	shState->setBindingData(&rbData);
	BacktraceData btData;

	mriBindingInit();


	STEAMSHIM_init();
	_rb_define_module_function(rb_mKernel, "_steam_achievement_unlock",
	                           _steamAchievementUnlock);


	std::string &customScript = conf.customScript;
	if (!customScript.empty())
		runCustomScript(customScript);
	else
		runRMXPScripts(btData);

	VALUE exc = rb_errinfo();
	if (!NIL_P(exc) && !rb_obj_is_kind_of(exc, rb_eSystemExit))
		showExc(exc, btData);

	ruby_cleanup(0);


	STEAMSHIM_deinit();


	shState->rtData().rqTermAck.set();
}
Exemplo n.º 2
0
/* Calls ruby_setup() and check error.
 *
 * Prints errors and calls exit(3) if an error occurred.
 */
void
ruby_init(void)
{
    int state = ruby_setup();
    if (state) {
	error_print();
	exit(EXIT_FAILURE);
    }
}
Exemplo n.º 3
0
/* Calls ruby_setup() and check error.
 *
 * Prints errors and calls exit(3) if an error occurred.
 */
void
ruby_init(void)
{
    int state = ruby_setup();
    if (state) {
        if (RTEST(ruby_debug))
            error_print();
	exit(EXIT_FAILURE);
    }
}
Exemplo n.º 4
0
void hello_from_ruby() 
{
	/* construct the VM */
if (ruby_setup())
	{
		fprintf(stderr, "Failed to init Ruby VM\n");
	}

  rb_require("./test");
  rb_funcall(rb_mKernel, rb_intern("some_ruby_method"), 0, NULL);


	/* destruct the VM */
	ruby_cleanup(0);
}
Exemplo n.º 5
0
static int mod_init(lua_State *l)
{
  int ret = ruby_setup();
  if (ret != 0)
  {
    return luaL_error(l, "ruby_setup: %d", ret);
  }
  ruby_init_loadpath();
  
  rb_define_global_function("rwrite", api_rwrite, 2);
  
  // VALUE api = rb_define_module("Api");
  // rb_define_module_function(api, "rwrite", api_rwrite, 0);
  // rb_define_const(mRUBBER, "TestConst", INT2NUM(38));
  
  return 0;
}
Exemplo n.º 6
0
static void mriBindingExecute()
{
	ruby_setup();
	rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));

	RbData rbData;
	shState->setBindingData(&rbData);

	mriBindingInit();

	std::string &customScript = shState->rtData().config.customScript;
	if (!customScript.empty())
		runCustomScript(customScript);
	else
		runRMXPScripts();

	VALUE exc = rb_errinfo();
	if (!NIL_P(exc) && !rb_obj_is_kind_of(exc, rb_eSystemExit))
		showExc(exc);

	ruby_cleanup(0);

	shState->rtData().rqTermAck = true;
}