forked from aniani/vim
patch 7.4.985
Problem: Can't build with Ruby 2.3.0. Solution: Use the new TypedData_XXX macro family instead of Data_XXX. Use TypedData. (Ken Takata)
This commit is contained in:
parent
ad4d8a192a
commit
f2f6d29796
106
src/if_ruby.c
106
src/if_ruby.c
@ -103,7 +103,6 @@
|
||||
#endif
|
||||
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22
|
||||
# define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub
|
||||
# define rb_check_type rb_check_type_stub
|
||||
#endif
|
||||
|
||||
#include <ruby.h>
|
||||
@ -122,6 +121,15 @@
|
||||
# define __OPENTRANSPORTPROVIDERS__
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The TypedData_XXX macro family can be used since Ruby 1.9.2, and
|
||||
* the old Data_XXX macro family was deprecated on Ruby 2.2.
|
||||
* Use TypedData_XXX if available.
|
||||
*/
|
||||
#ifdef TypedData_Wrap_Struct
|
||||
# define USE_TYPEDDATA 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Backward compatibility for Ruby 1.8 and earlier.
|
||||
* Ruby 1.9 does not provide STR2CSTR, instead StringValuePtr is provided.
|
||||
@ -184,11 +192,20 @@ static void ruby_vim_init(void);
|
||||
*/
|
||||
# define rb_assoc_new dll_rb_assoc_new
|
||||
# define rb_cObject (*dll_rb_cObject)
|
||||
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER < 22
|
||||
# define rb_check_type dll_rb_check_type
|
||||
# define rb_check_type dll_rb_check_type
|
||||
# ifdef USE_TYPEDDATA
|
||||
# define rb_check_typeddata dll_rb_check_typeddata
|
||||
# endif
|
||||
# define rb_class_path dll_rb_class_path
|
||||
# define rb_data_object_alloc dll_rb_data_object_alloc
|
||||
# ifdef USE_TYPEDDATA
|
||||
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 23
|
||||
# define rb_data_typed_object_wrap dll_rb_data_typed_object_wrap
|
||||
# else
|
||||
# define rb_data_typed_object_alloc dll_rb_data_typed_object_alloc
|
||||
# endif
|
||||
# else
|
||||
# define rb_data_object_alloc dll_rb_data_object_alloc
|
||||
# endif
|
||||
# define rb_define_class_under dll_rb_define_class_under
|
||||
# define rb_define_const dll_rb_define_const
|
||||
# define rb_define_global_function dll_rb_define_global_function
|
||||
@ -297,8 +314,19 @@ static VALUE *dll_rb_cObject;
|
||||
VALUE *dll_rb_cSymbol;
|
||||
VALUE *dll_rb_cTrueClass;
|
||||
static void (*dll_rb_check_type) (VALUE,int);
|
||||
# ifdef USE_TYPEDDATA
|
||||
static void *(*dll_rb_check_typeddata) (VALUE,const rb_data_type_t *);
|
||||
# endif
|
||||
static VALUE (*dll_rb_class_path) (VALUE);
|
||||
# ifdef USE_TYPEDDATA
|
||||
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 23
|
||||
static VALUE (*dll_rb_data_typed_object_wrap) (VALUE, void*, const rb_data_type_t *);
|
||||
# else
|
||||
static VALUE (*dll_rb_data_typed_object_alloc) (VALUE, void*, const rb_data_type_t *);
|
||||
# endif
|
||||
# else
|
||||
static VALUE (*dll_rb_data_object_alloc) (VALUE, void*, RUBY_DATA_FUNC, RUBY_DATA_FUNC);
|
||||
# endif
|
||||
static VALUE (*dll_rb_define_class_under) (VALUE, const char*, VALUE);
|
||||
static void (*dll_rb_define_const) (VALUE,const char*,VALUE);
|
||||
static void (*dll_rb_define_global_function) (const char*,VALUE(*)(),int);
|
||||
@ -451,13 +479,6 @@ void rb_gc_writebarrier_unprotect_stub(VALUE obj)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22
|
||||
void rb_check_type_stub(VALUE v, int i)
|
||||
{
|
||||
dll_rb_check_type(v, i);
|
||||
}
|
||||
# endif
|
||||
|
||||
static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */
|
||||
|
||||
/*
|
||||
@ -480,8 +501,19 @@ static struct
|
||||
{"rb_cSymbol", (RUBY_PROC*)&dll_rb_cSymbol},
|
||||
{"rb_cTrueClass", (RUBY_PROC*)&dll_rb_cTrueClass},
|
||||
{"rb_check_type", (RUBY_PROC*)&dll_rb_check_type},
|
||||
# ifdef USE_TYPEDDATA
|
||||
{"rb_check_typeddata", (RUBY_PROC*)&dll_rb_check_typeddata},
|
||||
# endif
|
||||
{"rb_class_path", (RUBY_PROC*)&dll_rb_class_path},
|
||||
# ifdef USE_TYPEDDATA
|
||||
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 23
|
||||
{"rb_data_typed_object_wrap", (RUBY_PROC*)&dll_rb_data_typed_object_wrap},
|
||||
# else
|
||||
{"rb_data_typed_object_alloc", (RUBY_PROC*)&dll_rb_data_typed_object_alloc},
|
||||
# endif
|
||||
# else
|
||||
{"rb_data_object_alloc", (RUBY_PROC*)&dll_rb_data_object_alloc},
|
||||
# endif
|
||||
{"rb_define_class_under", (RUBY_PROC*)&dll_rb_define_class_under},
|
||||
{"rb_define_const", (RUBY_PROC*)&dll_rb_define_const},
|
||||
{"rb_define_global_function", (RUBY_PROC*)&dll_rb_define_global_function},
|
||||
@ -1026,6 +1058,24 @@ static VALUE vim_evaluate(VALUE self UNUSED, VALUE str)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_TYPEDDATA
|
||||
static size_t buffer_dsize(const void *buf);
|
||||
|
||||
static const rb_data_type_t buffer_type = {
|
||||
"vim_buffer",
|
||||
{0, 0, buffer_dsize, {0, 0}},
|
||||
0, 0,
|
||||
# ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
||||
0,
|
||||
# endif
|
||||
};
|
||||
|
||||
static size_t buffer_dsize(const void *buf UNUSED)
|
||||
{
|
||||
return sizeof(buf_T);
|
||||
}
|
||||
#endif
|
||||
|
||||
static VALUE buffer_new(buf_T *buf)
|
||||
{
|
||||
if (buf->b_ruby_ref)
|
||||
@ -1034,7 +1084,11 @@ static VALUE buffer_new(buf_T *buf)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_TYPEDDATA
|
||||
VALUE obj = TypedData_Wrap_Struct(cBuffer, &buffer_type, buf);
|
||||
#else
|
||||
VALUE obj = Data_Wrap_Struct(cBuffer, 0, 0, buf);
|
||||
#endif
|
||||
buf->b_ruby_ref = (void *) obj;
|
||||
rb_hash_aset(objtbl, rb_obj_id(obj), obj);
|
||||
return obj;
|
||||
@ -1045,7 +1099,11 @@ static buf_T *get_buf(VALUE obj)
|
||||
{
|
||||
buf_T *buf;
|
||||
|
||||
#ifdef USE_TYPEDDATA
|
||||
TypedData_Get_Struct(obj, buf_T, &buffer_type, buf);
|
||||
#else
|
||||
Data_Get_Struct(obj, buf_T, buf);
|
||||
#endif
|
||||
if (buf == NULL)
|
||||
rb_raise(eDeletedBufferError, "attempt to refer to deleted buffer");
|
||||
return buf;
|
||||
@ -1242,6 +1300,24 @@ static VALUE buffer_append(VALUE self, VALUE num, VALUE str)
|
||||
return str;
|
||||
}
|
||||
|
||||
#ifdef USE_TYPEDDATA
|
||||
static size_t window_dsize(const void *buf);
|
||||
|
||||
static const rb_data_type_t window_type = {
|
||||
"vim_window",
|
||||
{0, 0, window_dsize, {0, 0}},
|
||||
0, 0,
|
||||
# ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
||||
0,
|
||||
# endif
|
||||
};
|
||||
|
||||
static size_t window_dsize(const void *win UNUSED)
|
||||
{
|
||||
return sizeof(win_T);
|
||||
}
|
||||
#endif
|
||||
|
||||
static VALUE window_new(win_T *win)
|
||||
{
|
||||
if (win->w_ruby_ref)
|
||||
@ -1250,7 +1326,11 @@ static VALUE window_new(win_T *win)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_TYPEDDATA
|
||||
VALUE obj = TypedData_Wrap_Struct(cVimWindow, &window_type, win);
|
||||
#else
|
||||
VALUE obj = Data_Wrap_Struct(cVimWindow, 0, 0, win);
|
||||
#endif
|
||||
win->w_ruby_ref = (void *) obj;
|
||||
rb_hash_aset(objtbl, rb_obj_id(obj), obj);
|
||||
return obj;
|
||||
@ -1261,7 +1341,11 @@ static win_T *get_win(VALUE obj)
|
||||
{
|
||||
win_T *win;
|
||||
|
||||
#ifdef USE_TYPEDDATA
|
||||
TypedData_Get_Struct(obj, win_T, &window_type, win);
|
||||
#else
|
||||
Data_Get_Struct(obj, win_T, win);
|
||||
#endif
|
||||
if (win == NULL)
|
||||
rb_raise(eDeletedWindowError, "attempt to refer to deleted window");
|
||||
return win;
|
||||
|
@ -741,6 +741,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
985,
|
||||
/**/
|
||||
984,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user