Hi,
Ruby 2.3.0 was released few days ago, but Vim cannot compile with it when
using +ruby/dyn. I wrote patches for this.
* if_ruby-use_typeddata.patch:
(Actually, this is a patch for Ruby 2.2.)
Currently we use Data_XXX macro family, but it was deprecated on Ruby 2.2.
When compiling with Ruby 2.2 or later, warnings occurs because of this.
This patch uses the new TypedData_XXX macro family which can be used since
Ruby 1.9.2.
* if_ruby23-use_typeddata.patch:
Patch for Ruby 2.3 using TypedData.
Regards,
Ken Takata
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
# HG changeset patch
# Parent 2c4ffcc9fdc7488c8e55b9f2828c68b2b4fdafa0
diff --git a/src/if_ruby.c b/src/if_ruby.c
--- a/src/if_ruby.c
+++ b/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>
@@ -123,6 +122,15 @@
#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.
* Ruby 1.9 does not provide RXXX(s)->len and RXXX(s)->ptr, instead
@@ -184,11 +192,16 @@ 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
+# define rb_data_typed_object_alloc dll_rb_data_typed_object_alloc
+# 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 +310,15 @@ 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
+static VALUE (*dll_rb_data_typed_object_alloc) (VALUE, void*, const rb_data_type_t *);
+# 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 +471,6 @@ void rb_gc_writebarrier_unprotect_stub(V
# 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 +493,15 @@ 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
+ {"rb_data_typed_object_alloc", (RUBY_PROC*)&dll_rb_data_typed_object_alloc},
+# 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},
@@ -1021,6 +1041,24 @@ static VALUE vim_evaluate(VALUE self UNU
#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,
+# ifdef RUBY_TYPED_FREE_IMMEDIATELY
+ 0,
+# endif
+};
+
+static size_t buffer_dsize(const void *buf)
+{
+ return sizeof(buf_T);
+}
+#endif
+
static VALUE buffer_new(buf_T *buf)
{
if (buf->b_ruby_ref)
@@ -1029,7 +1067,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;
@@ -1040,7 +1082,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;
@@ -1237,6 +1283,24 @@ static VALUE buffer_append(VALUE self, V
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,
+# ifdef RUBY_TYPED_FREE_IMMEDIATELY
+ 0,
+# endif
+};
+
+static size_t window_dsize(const void *win)
+{
+ return sizeof(win_T);
+}
+#endif
+
static VALUE window_new(win_T *win)
{
if (win->w_ruby_ref)
@@ -1245,7 +1309,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;
@@ -1256,7 +1324,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;
# HG changeset patch
# Parent 07d5e69edf72857568c5464d9730932563dff0d1
diff --git a/src/if_ruby.c b/src/if_ruby.c
--- a/src/if_ruby.c
+++ b/src/if_ruby.c
@@ -198,7 +198,11 @@ static void ruby_vim_init(void);
# endif
# define rb_class_path dll_rb_class_path
# ifdef USE_TYPEDDATA
-# define rb_data_typed_object_alloc dll_rb_data_typed_object_alloc
+# 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
@@ -315,7 +319,11 @@ static void *(*dll_rb_check_typeddata) (
# 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
@@ -498,7 +506,11 @@ static struct
# 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