Add MRI 1.9 Support.
Unfortunately crashes on startup with "[BUG] object allocation during garbage collection phase"
This commit is contained in:
parent
107e30cc87
commit
775fe36fd0
|
@ -32,7 +32,7 @@
|
||||||
#include "boost-hash.h"
|
#include "boost-hash.h"
|
||||||
|
|
||||||
#include <ruby.h>
|
#include <ruby.h>
|
||||||
#if RUBY_API_VERSION_MAJOR > 1
|
#ifndef RUBY_LEGACY_VERSION
|
||||||
#include <ruby/encoding.h>
|
#include <ruby/encoding.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ void raiseRbExc(const Exception &exc)
|
||||||
void
|
void
|
||||||
raiseDisposedAccess(VALUE self)
|
raiseDisposedAccess(VALUE self)
|
||||||
{
|
{
|
||||||
#if RUBY_API_VERSION_MAJOR == 1
|
#ifdef RUBY_LEGACY_VERSION
|
||||||
// FIXME: raiseDisposedAccess not implemented
|
// FIXME: raiseDisposedAccess not implemented
|
||||||
#else
|
#else
|
||||||
const char *klassName = RTYPEDDATA_TYPE(self)->wrap_struct_name;
|
const char *klassName = RTYPEDDATA_TYPE(self)->wrap_struct_name;
|
||||||
|
@ -325,6 +325,10 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if RUBY_API_VERSION_MAJOR == 1
|
#if RUBY_API_VERSION_MAJOR == 1
|
||||||
|
NORETURN(void rb_error_arity(int, int, int)) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
#if RUBY_API_VERSION_MINOR == 8
|
||||||
// Functions providing Ruby 1.8 compatibililty
|
// Functions providing Ruby 1.8 compatibililty
|
||||||
VALUE rb_sprintf(const char* fmt, ...) {
|
VALUE rb_sprintf(const char* fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -345,10 +349,6 @@ void *rb_check_typeddata(VALUE v, const rb_data_type_t *) {
|
||||||
return RTYPEDDATA_DATA(v);
|
return RTYPEDDATA_DATA(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
NORETURN(void rb_error_arity(int, int, int)) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
VALUE rb_enc_str_new(const char* ch, long len, rb_encoding*) {
|
VALUE rb_enc_str_new(const char* ch, long len, rb_encoding*) {
|
||||||
return rb_str_new(ch, len);
|
return rb_str_new(ch, len);
|
||||||
}
|
}
|
||||||
|
@ -392,4 +392,5 @@ int rb_utf8_encindex(void) {
|
||||||
VALUE rb_hash_lookup2(VALUE, VALUE, VALUE) {
|
VALUE rb_hash_lookup2(VALUE, VALUE, VALUE) {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // RUBY_API_VERSION_MINOR == 8
|
||||||
|
#endif // RUBY_API_VERSION_MAJOR == 1
|
|
@ -27,12 +27,27 @@
|
||||||
|
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
|
|
||||||
// Ruby 1.8 and Ruby 2.x use different version macros
|
// Ruby 1.8 and Ruby 1.9+ use different version macros
|
||||||
#ifndef RUBY_API_VERSION_MAJOR
|
#ifndef RUBY_API_VERSION_MAJOR
|
||||||
#define RUBY_API_VERSION_MAJOR RUBY_VERSION_MAJOR
|
#define RUBY_API_VERSION_MAJOR RUBY_VERSION_MAJOR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef RUBY_API_VERSION_MINOR
|
||||||
|
#define RUBY_API_VERSION_MINOR RUBY_VERSION_MINOR
|
||||||
|
#endif
|
||||||
|
|
||||||
#if RUBY_API_VERSION_MAJOR == 1
|
#if RUBY_API_VERSION_MAJOR == 1
|
||||||
|
#define PRIsVALUE "s"
|
||||||
|
#define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
|
||||||
|
#define RB_OBJ_STRING(obj) StringValueCStr(obj)
|
||||||
|
|
||||||
|
NORETURN(void rb_error_arity(int, int, int));
|
||||||
|
|
||||||
|
#define OBJ_INIT_COPY(obj, orig) \
|
||||||
|
((obj) != (orig) && (rb_obj_init_copy((obj), (orig)), 1))
|
||||||
|
#if RUBY_API_VERSION_MINOR == 8
|
||||||
|
// Makes version checks easier
|
||||||
|
#define RUBY_LEGACY_VERSION
|
||||||
// Functions and macros providing Ruby 1.8 compatibililty
|
// Functions and macros providing Ruby 1.8 compatibililty
|
||||||
#define FLONUM_P(x) 0
|
#define FLONUM_P(x) 0
|
||||||
|
|
||||||
|
@ -56,9 +71,6 @@
|
||||||
#define RUBY_T_FALSE T_FALSE
|
#define RUBY_T_FALSE T_FALSE
|
||||||
#define RUBY_T_NIL T_NIL
|
#define RUBY_T_NIL T_NIL
|
||||||
|
|
||||||
#define OBJ_INIT_COPY(obj, orig) \
|
|
||||||
((obj) != (orig) && (rb_obj_init_copy((obj), (orig)), 1))
|
|
||||||
|
|
||||||
#define rb_str_new_cstr rb_str_new2
|
#define rb_str_new_cstr rb_str_new2
|
||||||
|
|
||||||
#define RUBY_DEFAULT_FREE ((RUBY_DATA_FUNC)-1)
|
#define RUBY_DEFAULT_FREE ((RUBY_DATA_FUNC)-1)
|
||||||
|
@ -66,10 +78,6 @@
|
||||||
#define RUBY_TYPED_DEFAULT_FREE RUBY_DEFAULT_FREE
|
#define RUBY_TYPED_DEFAULT_FREE RUBY_DEFAULT_FREE
|
||||||
#define RUBY_TYPED_NEVER_FREE RUBY_NEVER_FREE
|
#define RUBY_TYPED_NEVER_FREE RUBY_NEVER_FREE
|
||||||
|
|
||||||
#define PRIsVALUE "s"
|
|
||||||
#define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
|
|
||||||
#define RB_OBJ_STRING(obj) StringValueCStr(obj)
|
|
||||||
|
|
||||||
#define RTYPEDDATA_DATA DATA_PTR
|
#define RTYPEDDATA_DATA DATA_PTR
|
||||||
|
|
||||||
#define RFLOAT_VALUE(d) RFLOAT(d)->value
|
#define RFLOAT_VALUE(d) RFLOAT(d)->value
|
||||||
|
@ -113,8 +121,6 @@ void *rb_check_typeddata(VALUE, const rb_data_type_t *);
|
||||||
|
|
||||||
#define Check_TypedStruct(v,t) rb_check_typeddata((VALUE)(v),(t))
|
#define Check_TypedStruct(v,t) rb_check_typeddata((VALUE)(v),(t))
|
||||||
|
|
||||||
NORETURN(void rb_error_arity(int, int, int));
|
|
||||||
|
|
||||||
typedef void rb_encoding;
|
typedef void rb_encoding;
|
||||||
|
|
||||||
VALUE rb_enc_str_new(const char*, long, rb_encoding*);
|
VALUE rb_enc_str_new(const char*, long, rb_encoding*);
|
||||||
|
@ -139,7 +145,8 @@ int rb_utf8_encindex(void);
|
||||||
|
|
||||||
VALUE rb_hash_lookup2(VALUE, VALUE, VALUE);
|
VALUE rb_hash_lookup2(VALUE, VALUE, VALUE);
|
||||||
|
|
||||||
#endif
|
#endif // RUBY_API_VERSION_MINOR == 8
|
||||||
|
#endif // RUBY_API_VERSION_MAJOR == 1
|
||||||
|
|
||||||
enum RbException
|
enum RbException
|
||||||
{
|
{
|
||||||
|
@ -181,7 +188,7 @@ raiseRbExc(const Exception &exc);
|
||||||
extern rb_data_type_t Klass##Type
|
extern rb_data_type_t Klass##Type
|
||||||
|
|
||||||
/* 2.1 has added a new field (flags) to rb_data_type_t */
|
/* 2.1 has added a new field (flags) to rb_data_type_t */
|
||||||
#if RUBY_API_VERSION_MINOR > 0
|
#if RUBY_API_VERSION_MAJOR > 1 && RUBY_API_VERSION_MINOR > 0
|
||||||
/* TODO: can mkxp use RUBY_TYPED_FREE_IMMEDIATELY here? */
|
/* TODO: can mkxp use RUBY_TYPED_FREE_IMMEDIATELY here? */
|
||||||
#define DEF_TYPE_FLAGS 0
|
#define DEF_TYPE_FLAGS 0
|
||||||
#else
|
#else
|
||||||
|
@ -492,5 +499,4 @@ rb_check_argc(int actual, int expected)
|
||||||
_rb_define_method(klass, prop_name_s "=", Klass##Set##PropName); \
|
_rb_define_method(klass, prop_name_s "=", Klass##Set##PropName); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // BINDING_UTIL_H
|
#endif // BINDING_UTIL_H
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#if RUBY_API_VERSION_MAJOR > 1
|
#ifndef RUBY_LEGACY_VERSION
|
||||||
#include "ruby/encoding.h"
|
#include "ruby/encoding.h"
|
||||||
#endif
|
#endif
|
||||||
#include "ruby/intern.h"
|
#include "ruby/intern.h"
|
||||||
|
@ -197,7 +197,7 @@ RB_METHOD(_marshalLoad)
|
||||||
|
|
||||||
VALUE utf8Proc;
|
VALUE utf8Proc;
|
||||||
// FIXME: Not implemented for Ruby 1.8
|
// FIXME: Not implemented for Ruby 1.8
|
||||||
#if RUBY_API_VERSION_MAJOR > 1
|
#ifndef RUBY_LEGACY_VERSION
|
||||||
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
|
||||||
|
@ -206,7 +206,7 @@ RB_METHOD(_marshalLoad)
|
||||||
|
|
||||||
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
||||||
|
|
||||||
#if RUBY_API_VERSION_MAJOR > 1
|
#ifndef RUBY_LEGACY_VERSION
|
||||||
VALUE v[] = { port, utf8Proc };
|
VALUE v[] = { port, utf8Proc };
|
||||||
#else
|
#else
|
||||||
VALUE v[] = { port, proc };
|
VALUE v[] = { port, proc };
|
||||||
|
|
Loading…
Reference in New Issue