Fix deprecation warning on build with MRI>2.3

Fixes #158.

The old alias is deprecated since: ruby/ruby@fdb957925f.
This commit is contained in:
Carsten Teibes 2017-08-18 19:45:57 +02:00 committed by Jonas Kulla
parent 01e17ed5c6
commit fde6a92197
1 changed files with 6 additions and 1 deletions

View File

@ -67,7 +67,7 @@ raiseRbExc(const Exception &exc);
/* 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 */
#include <ruby/version.h> #include <ruby/version.h>
#if RUBY_API_VERSION_MINOR > 0 #if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 1
/* 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
@ -90,7 +90,12 @@ raiseRbExc(const Exception &exc);
template<rb_data_type_t *rbType> template<rb_data_type_t *rbType>
static VALUE classAllocate(VALUE klass) static VALUE classAllocate(VALUE klass)
{ {
/* 2.3 has changed the name of this function */
#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 3
return rb_data_typed_object_wrap(klass, 0, rbType);
#else
return rb_data_typed_object_alloc(klass, 0, rbType); return rb_data_typed_object_alloc(klass, 0, rbType);
#endif
} }
template<class C> template<class C>