Support building with Ruby 1.9

This commit is contained in:
Struma 2020-11-15 18:47:21 -05:00 committed by zzoro
parent 21f24b67d1
commit bd549a65ad
5 changed files with 43 additions and 10 deletions

View file

@ -681,11 +681,21 @@ static void showExc(VALUE exc, const BacktraceData &btData) {
VALUE bt0 = rb_ary_entry(bt, 0);
VALUE name = rb_class_path(rb_obj_class(exc));
VALUE ds = rb_sprintf("%" PRIsVALUE ": %" PRIsVALUE " (%" PRIsVALUE ")", bt0,
exc, name);
VALUE ds = rb_sprintf("%" PRIsVALUE ": %" PRIsVALUE " (%" PRIsVALUE ")",
#if RAPI_MAJOR >= 2
bt0, exc, name);
#else
// Ruby 1.9's version of this function needs char*
RSTRING_PTR(bt0), RSTRING_PTR(exc), RSTRING_PTR(name));
#endif
/* omit "useless" last entry (from ruby:1:in `eval') */
for (long i = 1, btlen = RARRAY_LEN(bt) - 1; i < btlen; ++i)
rb_str_catf(ds, "\n\tfrom %" PRIsVALUE, rb_ary_entry(bt, i));
rb_str_catf(ds, "\n\tfrom %" PRIsVALUE,
#if RAPI_MAJOR >= 2
rb_ary_entry(bt, i));
#else
RSTRING_PTR(rb_ary_entry(bt, i)));
#endif
Debug() << StringValueCStr(ds);
char *s = RSTRING_PTR(bt0);

View file

@ -87,7 +87,7 @@ void raiseRbExc(const Exception &exc);
#endif
#endif
#if RAPI_MAJOR > 1
#if RAPI_MAJOR > 1 || RAPI_MINOR <= 9
#if RAPI_FULL < 270
#define DEF_TYPE_CUSTOMNAME_AND_FREE(Klass, Name, Free) \
rb_data_type_t Klass##Type = { \
@ -107,8 +107,9 @@ void raiseRbExc(const Exception &exc);
#endif
// Ruby 1.8 helper stuff
#if RAPI_FULL <= 187
#if RAPI_MAJOR < 2
#if RAPI_MINOR < 9
#define RUBY_T_FIXNUM T_FIXNUM
#define RUBY_T_TRUE T_TRUE
#define RUBY_T_FALSE T_FALSE
@ -118,12 +119,26 @@ void raiseRbExc(const Exception &exc);
#define RUBY_T_FLOAT T_FLOAT
#define RUBY_T_STRING T_STRING
#define RUBY_T_ARRAY T_ARRAY
#else
#define T_FIXNUM RUBY_T_FIXNUM
#define T_TRUE RUBY_T_TRUE
#define T_FALSE RUBY_T_FALSE
#define T_NIL RUBY_T_NIL
#define T_UNDEF RUBY_T_UNDEF
#define T_SYMBOL RUBY_T_SYMBOL
#define T_FLOAT RUBY_T_FLOAT
#define T_STRING RUBY_T_STRING
#define T_ARRAY RUBY_T_ARRAY
#endif
#if RAPI_MINOR < 9
#define RUBY_Qtrue Qtrue
#define RUBY_Qfalse Qfalse
#define RUBY_Qnil Qnil
#define RUBY_Qundef Qundef
#endif
#if RAPI_MINOR < 9
#define RB_FIXNUM_P(obj) FIXNUM_P(obj)
#define RB_SYMBOL_P(obj) SYMBOL_P(obj)
@ -142,6 +157,7 @@ void raiseRbExc(const Exception &exc);
? RB_SYMBOL_P(obj) \
: (!SPECIAL_CONST_P(obj) && \
BUILTIN_TYPE(obj) == (type)))
#endif
#define OBJ_INIT_COPY(a, b) rb_obj_init_copy(a, b)
@ -152,7 +168,10 @@ void raiseRbExc(const Exception &exc);
#define DEF_ALLOCFUNC(type) DEF_ALLOCFUNC_CUSTOMFREE(type, freeInstance<type>)
#if RAPI_MINOR < 9
#define rb_str_new_cstr rb_str_new2
#endif
#define PRIsVALUE "s"
#endif
@ -363,12 +382,13 @@ inline void rb_check_argc(int actual, int expected) {
expected);
}
#if RAPI_FULL <= 187
#if RAPI_MAJOR < 2
static inline void rb_error_arity(int argc, int min, int max) {
if (argc > max || argc < min)
rb_raise(rb_eArgError, "Finish me! rb_error_arity()"); // TODO
}
#if RAPI_MINOR < 9
static inline VALUE rb_sprintf(const char *fmt, ...) {
return rb_str_new2("Finish me! rb_sprintf()"); // TODO
}
@ -382,6 +402,7 @@ static inline VALUE rb_file_open_str(VALUE filename, const char *mode) {
rb_str_new2(mode));
}
#endif
#endif
#define RB_METHOD(name) static VALUE name(int argc, VALUE *argv, VALUE self)

View file

@ -1,7 +1,7 @@
if get_option('mri_includes') == ''
ver = get_option('mri_version')
if ver.version_compare('<=1.9')
if ver.version_compare('<=1.8')
global_args += '-DLEGACY_RUBY'
endif
global_dependencies += dependency('ruby-' + ver)

View file

@ -15,9 +15,9 @@
#define _T_BOOL 4
#ifndef __WIN32__
#define MINIFFI_MAX_ARGS 8
#define MINIFFI_MAX_ARGS 8l
#else
#define MINIFFI_MAX_ARGS 32
#define MINIFFI_MAX_ARGS 32l
#endif
#define INTEL_ASM ".intel_syntax noprefix\n"

View file

@ -77,12 +77,14 @@ global_include_dirs += include_directories('boost-unordered')
# ====================
# Suppress warnings
global_args += ['-Wno-non-virtual-dtor', '-Wno-reorder', '-Wno-uninitialized', '-Wno-unknown-pragmas', '-Wno-unknown-warning-option']
global_args += ['-Wno-non-virtual-dtor', '-Wno-reorder', '-Wno-uninitialized', '-Wno-unknown-pragmas', '-Wno-unknown-warning-option', '-Wno-deprecated-register']
if compilers['objc'].get_id() == 'clang'
global_args += ['-Wno-undefined-var-template', '-Wno-delete-non-abstract-non-virtual-dtor']
endif
if host_system == 'windows'
global_args += '-Wno-unknown-attributes'
elif host_system == 'darwin'
global_args += '-Wno-deprecated-declarations'
endif
# Decide whether or not to use MiniFFI