mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
P
This commit is contained in:
parent
14e27593d1
commit
8bb2415f7b
1 changed files with 5 additions and 29 deletions
|
|
@ -8,26 +8,6 @@ static VALUE string_clone(VALUE self){
|
|||
return rb_obj_clone(self);
|
||||
}
|
||||
|
||||
static VALUE ruby_eval(VALUE self, VALUE code){
|
||||
if (!RB_TYPE_P(code, T_STRING)) {
|
||||
rb_raise(rb_eTypeError, "wrong argument type (expected String)");
|
||||
}
|
||||
|
||||
#ifdef HAVE_RB_EVAL_STRING_PROTECT
|
||||
int error = 0;
|
||||
VALUE result = rb_eval_string_protect(RSTRING_PTR(code), &error);
|
||||
|
||||
if (error) {
|
||||
rb_clear_exception();
|
||||
return Qnil;
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
// Fallback
|
||||
return rb_eval_string(RSTRING_PTR(code));
|
||||
#endif
|
||||
}
|
||||
|
||||
void SunshineBindingInit(){
|
||||
printf("[SunshineBindingInit] Initializing Sunshine binding\n");
|
||||
VALUE module = rb_define_module("Sunshine");
|
||||
|
|
@ -35,15 +15,11 @@ void SunshineBindingInit(){
|
|||
rb_const_set(module, rb_intern("SDLVersion_minor"), INT2NUM(SDL_MINOR_VERSION));
|
||||
rb_const_set(module, rb_intern("SDLVersion_micro"), INT2NUM(SDL_MICRO_VERSION));
|
||||
printf("[SunshineBindingInit] SDL version: %i.%i.%i\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
|
||||
|
||||
printf("[SunshineBindingInit] Initializing helpers\n");
|
||||
rb_define_method(rb_cObject, "class", rb_obj_class, 0);
|
||||
rb_define_method(rb_cString, "clone", RUBY_METHOD_FUNC(string_clone), 0);
|
||||
|
||||
if (!rb_respond_to(rb_mKernel, rb_intern("eval"))) {
|
||||
printf("[SunshineBindingInit] Well, the standard eval is not available, let's try a custom one...\n");
|
||||
rb_define_method(rb_mKernel, "eval", RUBY_METHOD_FUNC(ruby_eval), 1);
|
||||
if (!rb_respond_to(rb_cObject, rb_intern("class"))) {
|
||||
rb_define_method(rb_cObject, "class", rb_obj_class, 0);
|
||||
}
|
||||
|
||||
if (!rb_respond_to(rb_cString, rb_intern("clone"))) {
|
||||
rb_define_method(rb_cString, "clone", RUBY_METHOD_FUNC(string_clone), 0);
|
||||
}
|
||||
printf("[SunshineBindingInit] Done\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue