comparison src/if_ruby.c @ 2076:1c7a66d820e4 v7.2.360

updated for version 7.2.360 Problem: Ruby on MS-Windows: can't use sockets. Solution: Call NtInitialize() during initialization. (Ariya Mizutani)
author Bram Moolenaar <bram@zimbu.org>
date Wed, 17 Feb 2010 15:11:50 +0100
parents ae2251be41f9
children d8983769c9dd
comparison
equal deleted inserted replaced
2075:903fcd726d90 2076:1c7a66d820e4
44 * defined in this file. When defined this RUBY_EXPORT it modified to 44 * defined in this file. When defined this RUBY_EXPORT it modified to
45 * "extern" and be able to avoid this problem. 45 * "extern" and be able to avoid this problem.
46 */ 46 */
47 # define RUBY_EXPORT 47 # define RUBY_EXPORT
48 # endif 48 # endif
49 #endif
50
51 /* suggested by Ariya Mizutani */
52 #if (_MSC_VER == 1200)
53 # undef _WIN32_WINNT
49 #endif 54 #endif
50 55
51 #include <ruby.h> 56 #include <ruby.h>
52 57
53 #undef EXTERN 58 #undef EXTERN
130 #define rb_str_new dll_rb_str_new 135 #define rb_str_new dll_rb_str_new
131 #define rb_str_new2 dll_rb_str_new2 136 #define rb_str_new2 dll_rb_str_new2
132 #define ruby_errinfo (*dll_ruby_errinfo) 137 #define ruby_errinfo (*dll_ruby_errinfo)
133 #define ruby_init dll_ruby_init 138 #define ruby_init dll_ruby_init
134 #define ruby_init_loadpath dll_ruby_init_loadpath 139 #define ruby_init_loadpath dll_ruby_init_loadpath
140 #define NtInitialize dll_NtInitialize
135 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 141 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
136 # define rb_w32_snprintf dll_rb_w32_snprintf 142 # define rb_w32_snprintf dll_rb_w32_snprintf
137 #endif 143 #endif
138 144
139 /* 145 /*
184 static VALUE (*dll_rb_str_new) (const char*, long); 190 static VALUE (*dll_rb_str_new) (const char*, long);
185 static VALUE (*dll_rb_str_new2) (const char*); 191 static VALUE (*dll_rb_str_new2) (const char*);
186 static VALUE *dll_ruby_errinfo; 192 static VALUE *dll_ruby_errinfo;
187 static void (*dll_ruby_init) (void); 193 static void (*dll_ruby_init) (void);
188 static void (*dll_ruby_init_loadpath) (void); 194 static void (*dll_ruby_init_loadpath) (void);
195 static void (*dll_NtInitialize) (int*, char***);
189 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 196 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
190 static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...); 197 static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...);
191 #endif 198 #endif
192 199
193 static HINSTANCE hinstRuby = 0; /* Instance of ruby.dll */ 200 static HINSTANCE hinstRuby = 0; /* Instance of ruby.dll */
246 {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new}, 253 {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new},
247 {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2}, 254 {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2},
248 {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo}, 255 {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
249 {"ruby_init", (RUBY_PROC*)&dll_ruby_init}, 256 {"ruby_init", (RUBY_PROC*)&dll_ruby_init},
250 {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath}, 257 {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath},
258 {"NtInitialize", (RUBY_PROC*)&dll_NtInitialize},
251 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 259 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
252 {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf}, 260 {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf},
253 #endif 261 #endif
254 {"", NULL}, 262 {"", NULL},
255 }; 263 };
411 if (!ruby_initialized) 419 if (!ruby_initialized)
412 { 420 {
413 #ifdef DYNAMIC_RUBY 421 #ifdef DYNAMIC_RUBY
414 if (ruby_enabled(TRUE)) 422 if (ruby_enabled(TRUE))
415 { 423 {
424 #endif
425 #ifdef _WIN32
426 /* suggested by Ariya Mizutani */
427 int argc = 1;
428 char *argv[] = {"gvim.exe"};
429 NtInitialize(&argc, &argv);
416 #endif 430 #endif
417 ruby_init(); 431 ruby_init();
418 ruby_init_loadpath(); 432 ruby_init_loadpath();
419 ruby_io_init(); 433 ruby_io_init();
420 ruby_vim_init(); 434 ruby_vim_init();