diff src/if_ruby.c @ 26788:fccd67ae58c8 v8.2.3922

patch 8.2.3922: cannot build with dynamic Ruby 3.1 Commit: https://github.com/vim/vim/commit/8bb3fe4d4dcd27c02e903f6772fdc8fe2e9eba70 Author: ichizok <gclient.gaap@gmail.com> Date: Tue Dec 28 15:51:45 2021 +0000 patch 8.2.3922: cannot build with dynamic Ruby 3.1 Problem: Cannot build with dynamic Ruby 3.1. Solution: Add "_EXTRA" variables for CI. Add missing functions. (Ozaki Kiichi, closes #9420)
author Bram Moolenaar <Bram@vim.org>
date Tue, 28 Dec 2021 17:00:04 +0100
parents 65ab0b035dd8
children 06a137af96f8
line wrap: on
line diff
--- a/src/if_ruby.c
+++ b/src/if_ruby.c
@@ -73,35 +73,40 @@
 # if RUBY_VERSION >= 19
 // Ruby 1.9 defines a number of static functions which use rb_num2long and
 // rb_int2big
-#  define rb_num2long rb_num2long_stub
-#  define rb_int2big rb_int2big_stub
+#  define rb_num2long	rb_num2long_stub
+#  define rb_int2big	rb_int2big_stub
 
 #  if RUBY_VERSION >= 30 || VIM_SIZEOF_INT < VIM_SIZEOF_LONG
 // Ruby 1.9 defines a number of static functions which use rb_fix2int and
 // rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit)
-#   define rb_fix2int rb_fix2int_stub
-#   define rb_num2int rb_num2int_stub
+#   define rb_fix2int	rb_fix2int_stub
+#   define rb_num2int	rb_num2int_stub
 #  endif
 # endif
 
 # if RUBY_VERSION == 21
 // Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses
 // rb_gc_writebarrier_unprotect_promoted if USE_RGENGC
-#  define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub
+#  define rb_gc_writebarrier_unprotect_promoted	rb_gc_writebarrier_unprotect_promoted_stub
 # endif
 
 # if RUBY_VERSION >= 22
-#  define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub
+#  define rb_gc_writebarrier_unprotect	rb_gc_writebarrier_unprotect_stub
 # endif
 
 # if RUBY_VERSION >= 26
-#  define rb_ary_detransient rb_ary_detransient_stub
+#  define rb_ary_detransient	rb_ary_detransient_stub
 # endif
 
 # if RUBY_VERSION >= 30
-#  define rb_check_type rb_check_type_stub
-#  define rb_num2uint rb_num2uint_stub
-#  define ruby_malloc_size_overflow ruby_malloc_size_overflow_stub
+#  define rb_check_type			rb_check_type_stub
+#  define rb_num2uint			rb_num2uint_stub
+#  define ruby_malloc_size_overflow	ruby_malloc_size_overflow_stub
+# endif
+
+# if RUBY_VERSION >= 31
+#  define rb_debug_rstring_null_ptr	rb_debug_rstring_null_ptr_stub
+#  define rb_unexpected_type		rb_unexpected_type_stub
 # endif
 
 #endif  // ifdef DYNAMIC_RUBY
@@ -173,6 +178,14 @@
 # undef HAVE_DUP
 #endif
 
+// Avoid redefining TRUE/FALSE in vterm.h.
+#ifdef TRUE
+# undef TRUE
+#endif
+#ifdef FALSE
+# undef FALSE
+#endif
+
 #include "vim.h"
 #include "version.h"
 
@@ -411,6 +424,9 @@ static VALUE (*dll_rb_data_typed_object_
 # else
 static VALUE (*dll_rb_data_object_alloc) (VALUE, void*, RUBY_DATA_FUNC, RUBY_DATA_FUNC);
 # endif
+# if RUBY_VERSION >= 31
+static void (*dll_rb_debug_rstring_null_ptr) (const char*);
+# 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);
@@ -485,6 +501,9 @@ static void (*dll_NtInitialize) (int*, c
 static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...);
 #  endif
 # endif
+# if RUBY_VERSION >= 31
+static void (*dll_rb_unexpected_type) (VALUE, int) ATTRIBUTE_NORETURN;
+# endif
 # if RUBY_VERSION >= 18
 static char * (*dll_rb_string_value_ptr) (volatile VALUE*);
 static VALUE (*dll_rb_float_new) (double);
@@ -629,6 +648,18 @@ ruby_malloc_size_overflow_stub(size_t x,
     dll_ruby_malloc_size_overflow(x, y);
 }
 #  endif
+#  if RUBY_VERSION >= 31
+    void
+rb_debug_rstring_null_ptr_stub(const char *func)
+{
+    dll_rb_debug_rstring_null_ptr(func);
+}
+    void
+rb_unexpected_type_stub(VALUE self, int t)
+{
+    dll_rb_unexpected_type(self, t);
+}
+#  endif
 # endif // ifndef PROTO
 
 static HINSTANCE hinstRuby = NULL; // Instance of ruby.dll
@@ -672,6 +703,9 @@ static struct
 # else
     {"rb_data_object_alloc", (RUBY_PROC*)&dll_rb_data_object_alloc},
 # endif
+# if RUBY_VERSION >= 31
+    {"rb_debug_rstring_null_ptr", (RUBY_PROC*)&dll_rb_debug_rstring_null_ptr},
+# 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},
@@ -745,6 +779,9 @@ static struct
     {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf},
 #  endif
 # endif
+# if RUBY_VERSION >= 31
+    {"rb_unexpected_type", (RUBY_PROC*)&dll_rb_unexpected_type},
+# endif
 # if RUBY_VERSION >= 18
     {"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr},
 #  if RUBY_VERSION <= 19