int eruta_ruby_init() { VALUE options = Qnil, sublet = Qnil; void Init_prelude(void); RUBY_INIT_STACK; ruby_init(); ruby_init_loadpath(); ruby_script("eruta"); #ifdef HAVE_RB_ENC_SET_DEFAULT_INTERNAL { VALUE encoding = Qnil; /* FIXME: Fix for ruby 1.9.2p429 borrowed from ruby? */ (void)rb_filesystem_encoding(); /* Set encoding */ encoding = rb_enc_from_encoding(rb_locale_encoding()); rb_enc_set_default_external(encoding); } #endif /* HAVE_RB_ENC_SET_DEFAULT_INTERNAL */ /* FIXME: Fake ruby_init_gems(Qtrue) */ rb_define_module("Gem"); Init_prelude(); /* Bypassing garbage collection. Why? */ /* shelter = rb_ary_new(); rb_gc_register_address(&shelter); */ }
/* * call-seq: * Encoding.default_external = enc * * Sets default external encoding. */ static VALUE set_default_external(VALUE klass, VALUE encoding) { rb_warning("setting Encoding.default_external"); rb_enc_set_default_external(encoding); return encoding; }
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(); }
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; }