This commit is contained in:
parent
dc0c4ab781
commit
aace283683
|
|
@ -17,3 +17,10 @@ cmake -S . -B build
|
||||||
cd build
|
cd build
|
||||||
make -jn
|
make -jn
|
||||||
n - count of threads for compilation
|
n - count of threads for compilation
|
||||||
|
|
||||||
|
#TODOs:
|
||||||
|
*Port to SDL3,Modern ruby and other
|
||||||
|
*Extend API with usefull thinks idk...
|
||||||
|
*Fix bugs
|
||||||
|
*Upgrade linux support
|
||||||
|
*MAKE THIS WORK
|
||||||
|
|
|
||||||
|
|
@ -290,13 +290,11 @@ int rb_get_args(int argc, VALUE *argv, const char *format, ...);
|
||||||
|
|
||||||
typedef VALUE (*RubyMethod)(int argc, VALUE *argv, VALUE self);
|
typedef VALUE (*RubyMethod)(int argc, VALUE *argv, VALUE self);
|
||||||
|
|
||||||
static inline void
|
static inline void _rb_define_method(VALUE klass, const char *name, RubyMethod func){
|
||||||
_rb_define_method(VALUE klass, const char *name, RubyMethod func){
|
|
||||||
rb_define_method(klass, name, RUBY_METHOD_FUNC(func), -1);
|
rb_define_method(klass, name, RUBY_METHOD_FUNC(func), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void rb_define_class_method(VALUE klass, const char *name, RubyMethod func){
|
||||||
rb_define_class_method(VALUE klass, const char *name, RubyMethod func){
|
|
||||||
rb_define_singleton_method(klass, name, RUBY_METHOD_FUNC(func), -1);
|
rb_define_singleton_method(klass, name, RUBY_METHOD_FUNC(func), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,7 @@
|
||||||
#include "ruby/encoding.h"
|
#include "ruby/encoding.h"
|
||||||
#include "ruby/intern.h"
|
#include "ruby/intern.h"
|
||||||
|
|
||||||
static void
|
static void fileIntFreeInstance(void *inst){
|
||||||
fileIntFreeInstance(void *inst){
|
|
||||||
SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst);
|
SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst);
|
||||||
|
|
||||||
SDL_CloseIO(ops);
|
SDL_CloseIO(ops);
|
||||||
|
|
@ -184,23 +183,26 @@ static VALUE customProc(VALUE arg, VALUE proc)
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_METHOD(_marshalLoad)
|
RB_METHOD(_marshalLoad){
|
||||||
{
|
printf("test\n");
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
printf("test2\n");
|
||||||
VALUE port, proc = Qnil;
|
VALUE port, proc = Qnil;
|
||||||
|
printf("test3\n");
|
||||||
rb_get_args(argc, argv, "o|o", &port, &proc RB_ARG_END);
|
rb_scan_args(argc, argv, "01", &port, &proc);
|
||||||
|
//rb_get_args(argc, argv, "o|o", &port, &proc RB_ARG_END);
|
||||||
|
printf("test4\n");
|
||||||
VALUE utf8Proc;
|
VALUE utf8Proc;
|
||||||
if (NIL_P(proc))
|
if (NIL_P(proc))
|
||||||
utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(stringForceUTF8), Qnil);
|
utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(stringForceUTF8), Qnil);
|
||||||
else
|
else
|
||||||
utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(customProc), proc);
|
utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(customProc), proc);
|
||||||
|
printf("test5\n");
|
||||||
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
||||||
|
//if (!rb_obj_is_kind_of(marsh, rb_cModule)) rb_raise(rb_eRuntimeError, "Marshal not found");
|
||||||
|
printf("test6\n");
|
||||||
VALUE v[] = { port, utf8Proc };
|
VALUE v[] = { port, utf8Proc };
|
||||||
|
printf("test7\n");
|
||||||
return rb_funcall2(marsh, rb_intern("_mkxp_load_alias"), ARRAY_SIZE(v), v);
|
return rb_funcall2(marsh, rb_intern("_mkxp_load_alias"), ARRAY_SIZE(v), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -221,7 +223,11 @@ fileIntBindingInit()
|
||||||
/* We overload the built-in 'Marshal::load()' function to silently
|
/* We overload the built-in 'Marshal::load()' function to silently
|
||||||
* insert our utf8proc that ensures all read strings will be
|
* insert our utf8proc that ensures all read strings will be
|
||||||
* UTF-8 encoded */
|
* UTF-8 encoded */
|
||||||
|
printf("test8\n");
|
||||||
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
||||||
|
printf("test9\n");
|
||||||
rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load");
|
rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load");
|
||||||
|
printf("test10\n");
|
||||||
_rb_define_module_function(marsh, "load", _marshalLoad);
|
_rb_define_module_function(marsh, "load", _marshalLoad);
|
||||||
|
printf("test11\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue