3232# define RUBYEXTERN extern
3333#endif
3434
35- #if defined(DYNAMIC_RUBY ) && RUBY_VERSION >= 24
36- # define USE_RUBY_INTEGER
35+ // suggested by Ariya Mizutani
36+ #if (_MSC_VER == 1200 )
37+ # undef _WIN32_WINNT
3738#endif
3839
3940#ifdef DYNAMIC_RUBY
4243 * definition. This function use these variables. But we want function to
4344 * use dll_* variables.
4445 */
46+ # if RUBY_VERSION >= 24
47+ # define USE_RUBY_INTEGER
48+ # endif
49+
4550# define rb_cFalseClass (*dll_rb_cFalseClass)
4651# define rb_cFixnum (*dll_rb_cFixnum)
4752# if defined(USE_RUBY_INTEGER )
5459# define rb_cString (*dll_rb_cString)
5560# define rb_cSymbol (*dll_rb_cSymbol)
5661# define rb_cTrueClass (*dll_rb_cTrueClass)
62+
5763# if RUBY_VERSION >= 18
5864/*
5965 * On ver 1.8, all Ruby functions are exported with "__declspec(dllimport)"
6470# define RUBY_EXPORT
6571# endif
6672
67- #endif // ifdef DYNAMIC_RUBY
68-
69- // suggested by Ariya Mizutani
70- #if (_MSC_VER == 1200 )
71- # undef _WIN32_WINNT
72- #endif
73-
74- #if defined(DYNAMIC_RUBY ) && RUBY_VERSION >= 19
73+ # if RUBY_VERSION >= 19
7574// Ruby 1.9 defines a number of static functions which use rb_num2long and
7675// rb_int2big
77- # define rb_num2long rb_num2long_stub
78- # define rb_int2big rb_int2big_stub
79- #endif
76+ # define rb_num2long rb_num2long_stub
77+ # define rb_int2big rb_int2big_stub
8078
81- #if defined(DYNAMIC_RUBY ) && RUBY_VERSION >= 19 \
82- && VIM_SIZEOF_INT < VIM_SIZEOF_LONG
79+ # if RUBY_VERSION >= 30 || VIM_SIZEOF_INT < VIM_SIZEOF_LONG
8380// Ruby 1.9 defines a number of static functions which use rb_fix2int and
8481// rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit)
85- # define rb_fix2int rb_fix2int_stub
86- # define rb_num2int rb_num2int_stub
87- #endif
82+ # define rb_fix2int rb_fix2int_stub
83+ # define rb_num2int rb_num2int_stub
84+ # endif
85+ # endif
8886
89- #if defined( DYNAMIC_RUBY ) && RUBY_VERSION == 21
87+ # if RUBY_VERSION == 21
9088// Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses
9189// rb_gc_writebarrier_unprotect_promoted if USE_RGENGC
92- # define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub
93- #endif
94- #if defined(DYNAMIC_RUBY ) && RUBY_VERSION >= 22
95- # define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub
96- #endif
90+ # define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub
91+ # endif
9792
98- #if defined(DYNAMIC_RUBY ) && RUBY_VERSION >= 26
99- # define rb_ary_detransient rb_ary_detransient_stub
100- #endif
93+ # if RUBY_VERSION >= 22
94+ # define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub
95+ # endif
96+
97+ # if RUBY_VERSION >= 26
98+ # define rb_ary_detransient rb_ary_detransient_stub
99+ # endif
100+
101+ # if RUBY_VERSION >= 30
102+ # define rb_check_type rb_check_type_stub
103+ # define rb_num2uint rb_num2uint_stub
104+ # define ruby_malloc_size_overflow ruby_malloc_size_overflow_stub
105+ # endif
106+
107+ #endif // ifdef DYNAMIC_RUBY
101108
102109// On macOS pre-installed Ruby defines "SIZEOF_TIME_T" as "SIZEOF_LONG" so it
103110// conflicts with the definition in config.h then causes a macro-redefined
@@ -232,7 +239,9 @@ static int ruby_convert_to_vim_value(VALUE val, typval_T *rettv);
232239# define rb_assoc_new dll_rb_assoc_new
233240# define rb_cObject (*dll_rb_cObject)
234241# define rb_class_new_instance dll_rb_class_new_instance
235- # define rb_check_type dll_rb_check_type
242+ # if RUBY_VERSION < 30
243+ # define rb_check_type dll_rb_check_type
244+ # endif
236245# ifdef USE_TYPEDDATA
237246# define rb_check_typeddata dll_rb_check_typeddata
238247# endif
@@ -283,7 +292,9 @@ static int ruby_convert_to_vim_value(VALUE val, typval_T *rettv);
283292# define rb_fix2int dll_rb_fix2int
284293# define rb_num2int dll_rb_num2int
285294# endif
286- # define rb_num2uint dll_rb_num2uint
295+ # if RUBY_VERSION < 30
296+ # define rb_num2uint dll_rb_num2uint
297+ # endif
287298# endif
288299# define rb_num2dbl dll_rb_num2dbl
289300# define rb_lastline_get dll_rb_lastline_get
@@ -501,7 +512,7 @@ static rb_encoding* (*dll_rb_enc_find) (const char*);
501512static VALUE (* dll_rb_enc_str_new ) (const char * , long , rb_encoding * );
502513static VALUE (* dll_rb_sprintf ) (const char * , ...);
503514static VALUE (* dll_rb_require ) (const char * );
504- static void * (* ruby_options )(int , char * * );
515+ static void * (* dll_ruby_options )(int , char * * );
505516# endif
506517
507518# if defined(USE_RGENGC ) && USE_RGENGC
@@ -512,32 +523,38 @@ static void (*dll_rb_gc_writebarrier_unprotect)(VALUE obj);
512523# endif
513524# endif
514525
526+ # if RUBY_VERSION >= 30
527+ NORETURN (static void (* dll_ruby_malloc_size_overflow )(size_t , size_t ));
528+ # endif
529+
515530# if RUBY_VERSION >= 26
516531void rb_ary_detransient_stub (VALUE x );
517532# endif
518533
519- # if (RUBY_VERSION >= 19 ) && !defined(PROTO )
520- # if RUBY_VERSION >= 22
534+ // Do not generate a prototype here, VALUE isn't always defined.
535+ # ifndef PROTO
536+ # if RUBY_VERSION >= 19
537+ # if RUBY_VERSION >= 22
521538 long
522539rb_num2long_stub (VALUE x )
523- # else
540+ # else
524541 SIGNED_VALUE
525542rb_num2long_stub (VALUE x )
526- # endif
543+ # endif
527544{
528545 return dll_rb_num2long (x );
529546}
530- # if RUBY_VERSION >= 26
547+ # if RUBY_VERSION >= 26
531548 VALUE
532549rb_int2big_stub (intptr_t x )
533- # else
550+ # else
534551 VALUE
535552rb_int2big_stub (SIGNED_VALUE x )
536- # endif
553+ # endif
537554{
538555 return dll_rb_int2big (x );
539556}
540- # if ( RUBY_VERSION >= 19 ) && ( VIM_SIZEOF_INT < VIM_SIZEOF_LONG )
557+ # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG
541558 long
542559rb_fix2int_stub (VALUE x )
543560{
@@ -548,50 +565,65 @@ rb_num2int_stub(VALUE x)
548565{
549566 return dll_rb_num2int (x );
550567}
551- # endif
552- # if RUBY_VERSION >= 20
568+ # endif
569+ # if RUBY_VERSION >= 20
553570 VALUE
554571rb_float_new_in_heap (double d )
555572{
556573 return dll_rb_float_new (d );
557574}
558- # if RUBY_VERSION >= 22
575+ # if RUBY_VERSION >= 22
559576 unsigned long
560577rb_num2ulong (VALUE x )
561- # else
578+ # else
562579 VALUE
563580rb_num2ulong (VALUE x )
564- # endif
581+ # endif
565582{
566583 return (long )RSHIFT ((SIGNED_VALUE )(x ),1 );
567584}
585+ # endif
568586# endif
569- # endif
570-
571- // Do not generate a prototype here, VALUE isn't always defined.
572- # if defined(USE_RGENGC ) && USE_RGENGC && !defined(PROTO )
573- # if RUBY_VERSION == 21
587+ # if defined(USE_RGENGC ) && USE_RGENGC
588+ # if RUBY_VERSION == 21
574589 void
575590rb_gc_writebarrier_unprotect_promoted_stub (VALUE obj )
576591{
577592 dll_rb_gc_writebarrier_unprotect_promoted (obj );
578593}
579- # else
594+ # else
580595 void
581596rb_gc_writebarrier_unprotect_stub (VALUE obj )
582597{
583598 dll_rb_gc_writebarrier_unprotect (obj );
584599}
600+ # endif
585601# endif
586- # endif
587-
588- # if RUBY_VERSION >= 26
602+ # if RUBY_VERSION >= 26
589603 void
590604rb_ary_detransient_stub (VALUE x )
591605{
592606 dll_rb_ary_detransient (x );
593607}
594- # endif
608+ # endif
609+ # if RUBY_VERSION >= 30
610+ void
611+ rb_check_type_stub (VALUE obj , int t )
612+ {
613+ dll_rb_check_type (obj , t );
614+ }
615+ unsigned long
616+ rb_num2uint_stub (VALUE x )
617+ {
618+ return dll_rb_num2uint (x );
619+ }
620+ void
621+ ruby_malloc_size_overflow_stub (size_t x , size_t y )
622+ {
623+ dll_ruby_malloc_size_overflow (x , y );
624+ }
625+ # endif
626+ # endif // ifndef PROTO
595627
596628static HINSTANCE hinstRuby = NULL ; // Instance of ruby.dll
597629
@@ -747,6 +779,9 @@ static struct
747779# else
748780 {"rb_gc_writebarrier_unprotect" , (RUBY_PROC * )& dll_rb_gc_writebarrier_unprotect },
749781# endif
782+ # endif
783+ # if RUBY_VERSION >= 30
784+ {"ruby_malloc_size_overflow" , (RUBY_PROC * )& dll_ruby_malloc_size_overflow },
750785# endif
751786 {"" , NULL },
752787};
@@ -1827,7 +1862,7 @@ convert_hash2dict(VALUE key, VALUE val, VALUE arg)
18271862 dict_T * d = (dict_T * )arg ;
18281863 dictitem_T * di ;
18291864
1830- di = dictitem_alloc ((char_u * )RSTRING_PTR (RSTRING ( rb_obj_as_string (key ) )));
1865+ di = dictitem_alloc ((char_u * )RSTRING_PTR (rb_obj_as_string (key )));
18311866 if (di == NULL || ruby_convert_to_vim_value (val , & di -> di_tv ) != OK
18321867 || dict_add (d , di ) != OK )
18331868 {
0 commit comments