]>
Commit | Line | Data |
---|---|---|
17e7d110 SS |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.3.013 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.013 | |
11 | Problem: Dynamic loading with Ruby doesn't work for 1.9.2. | |
12 | Solution: Handle rb_str2cstr differently. Also support dynamic loading on | |
13 | Unix. (Jon Maken) | |
14 | Files: src/if_ruby.c | |
15 | ||
16 | ||
17 | *** ../vim-7.3.012/src/if_ruby.c 2010-08-15 21:57:25.000000000 +0200 | |
18 | --- src/if_ruby.c 2010-09-29 12:49:50.000000000 +0200 | |
19 | *************** | |
20 | *** 4,9 **** | |
21 | --- 4,10 ---- | |
22 | * | |
23 | * Ruby interface by Shugo Maeda | |
24 | * with improvements by SegPhault (Ryan Paul) | |
25 | + * with improvements by Jon Maken | |
26 | * | |
27 | * Do ":help uganda" in Vim to read copying and usage conditions. | |
28 | * Do ":help credits" in Vim to see a list of people who contributed. | |
29 | *************** | |
30 | *** 26,37 **** | |
31 | # define RUBYEXTERN extern | |
32 | #endif | |
33 | ||
34 | /* | |
35 | * This is tricky. In ruby.h there is (inline) function rb_class_of() | |
36 | * definition. This function use these variables. But we want function to | |
37 | * use dll_* variables. | |
38 | */ | |
39 | - #ifdef DYNAMIC_RUBY | |
40 | # define rb_cFalseClass (*dll_rb_cFalseClass) | |
41 | # define rb_cFixnum (*dll_rb_cFixnum) | |
42 | # define rb_cNilClass (*dll_rb_cNilClass) | |
43 | --- 27,38 ---- | |
44 | # define RUBYEXTERN extern | |
45 | #endif | |
46 | ||
47 | + #ifdef DYNAMIC_RUBY | |
48 | /* | |
49 | * This is tricky. In ruby.h there is (inline) function rb_class_of() | |
50 | * definition. This function use these variables. But we want function to | |
51 | * use dll_* variables. | |
52 | */ | |
53 | # define rb_cFalseClass (*dll_rb_cFalseClass) | |
54 | # define rb_cFixnum (*dll_rb_cFixnum) | |
55 | # define rb_cNilClass (*dll_rb_cNilClass) | |
56 | *************** | |
57 | *** 46,53 **** | |
58 | --- 47,67 ---- | |
59 | */ | |
60 | # define RUBY_EXPORT | |
61 | # endif | |
62 | + | |
63 | + #if !(defined(WIN32) || defined(_WIN64)) | |
64 | + # include <dlfcn.h> | |
65 | + # define HANDLE void* | |
66 | + # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) | |
67 | + # define symbol_from_dll dlsym | |
68 | + # define close_dll dlclose | |
69 | + #else | |
70 | + # define load_dll LoadLibrary | |
71 | + # define symbol_from_dll GetProcAddress | |
72 | + # define close_dll FreeLibrary | |
73 | #endif | |
74 | ||
75 | + #endif /* ifdef DYNAMIC_RUBY */ | |
76 | + | |
77 | /* suggested by Ariya Mizutani */ | |
78 | #if (_MSC_VER == 1200) | |
79 | # undef _WIN32_WINNT | |
80 | *************** | |
81 | *** 166,172 **** | |
82 | #define rb_obj_as_string dll_rb_obj_as_string | |
83 | #define rb_obj_id dll_rb_obj_id | |
84 | #define rb_raise dll_rb_raise | |
85 | - #define rb_str2cstr dll_rb_str2cstr | |
86 | #define rb_str_cat dll_rb_str_cat | |
87 | #define rb_str_concat dll_rb_str_concat | |
88 | #define rb_str_new dll_rb_str_new | |
89 | --- 180,185 ---- | |
90 | *************** | |
91 | *** 178,187 **** | |
92 | --- 191,203 ---- | |
93 | # define rb_str_new2 dll_rb_str_new2 | |
94 | #endif | |
95 | #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 | |
96 | + # define rb_string_value dll_rb_string_value | |
97 | # define rb_string_value_ptr dll_rb_string_value_ptr | |
98 | # define rb_float_new dll_rb_float_new | |
99 | # define rb_ary_new dll_rb_ary_new | |
100 | # define rb_ary_push dll_rb_ary_push | |
101 | + #else | |
102 | + # define rb_str2cstr dll_rb_str2cstr | |
103 | #endif | |
104 | #ifdef RUBY19_OR_LATER | |
105 | # define rb_errinfo dll_rb_errinfo | |
106 | *************** | |
107 | *** 246,252 **** | |
108 | --- 262,272 ---- | |
109 | static VALUE (*dll_rb_obj_as_string) (VALUE); | |
110 | static VALUE (*dll_rb_obj_id) (VALUE); | |
111 | static void (*dll_rb_raise) (VALUE, const char*, ...); | |
112 | + #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 | |
113 | + static VALUE (*dll_rb_string_value) (volatile VALUE*); | |
114 | + #else | |
115 | static char *(*dll_rb_str2cstr) (VALUE,int*); | |
116 | + #endif | |
117 | static VALUE (*dll_rb_str_cat) (VALUE, const char*, long); | |
118 | static VALUE (*dll_rb_str_concat) (VALUE, VALUE); | |
119 | static VALUE (*dll_rb_str_new) (const char*, long); | |
120 | *************** | |
121 | *** 347,353 **** | |
122 | --- 367,377 ---- | |
123 | {"rb_obj_as_string", (RUBY_PROC*)&dll_rb_obj_as_string}, | |
124 | {"rb_obj_id", (RUBY_PROC*)&dll_rb_obj_id}, | |
125 | {"rb_raise", (RUBY_PROC*)&dll_rb_raise}, | |
126 | + #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 | |
127 | + {"rb_string_value", (RUBY_PROC*)&dll_rb_string_value}, | |
128 | + #else | |
129 | {"rb_str2cstr", (RUBY_PROC*)&dll_rb_str2cstr}, | |
130 | + #endif | |
131 | {"rb_str_cat", (RUBY_PROC*)&dll_rb_str_cat}, | |
132 | {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat}, | |
133 | {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new}, | |
134 | *************** | |
135 | *** 399,405 **** | |
136 | { | |
137 | if (hinstRuby) | |
138 | { | |
139 | ! FreeLibrary(hinstRuby); | |
140 | hinstRuby = 0; | |
141 | } | |
142 | } | |
143 | --- 423,429 ---- | |
144 | { | |
145 | if (hinstRuby) | |
146 | { | |
147 | ! close_dll(hinstRuby); | |
148 | hinstRuby = 0; | |
149 | } | |
150 | } | |
151 | *************** | |
152 | *** 416,422 **** | |
153 | ||
154 | if (hinstRuby) | |
155 | return OK; | |
156 | ! hinstRuby = LoadLibrary(libname); | |
157 | if (!hinstRuby) | |
158 | { | |
159 | if (verbose) | |
160 | --- 440,446 ---- | |
161 | ||
162 | if (hinstRuby) | |
163 | return OK; | |
164 | ! hinstRuby = load_dll(libname); | |
165 | if (!hinstRuby) | |
166 | { | |
167 | if (verbose) | |
168 | *************** | |
169 | *** 426,435 **** | |
170 | ||
171 | for (i = 0; ruby_funcname_table[i].ptr; ++i) | |
172 | { | |
173 | ! if (!(*ruby_funcname_table[i].ptr = GetProcAddress(hinstRuby, | |
174 | ruby_funcname_table[i].name))) | |
175 | { | |
176 | ! FreeLibrary(hinstRuby); | |
177 | hinstRuby = 0; | |
178 | if (verbose) | |
179 | EMSG2(_(e_loadfunc), ruby_funcname_table[i].name); | |
180 | --- 450,459 ---- | |
181 | ||
182 | for (i = 0; ruby_funcname_table[i].ptr; ++i) | |
183 | { | |
184 | ! if (!(*ruby_funcname_table[i].ptr = symbol_from_dll(hinstRuby, | |
185 | ruby_funcname_table[i].name))) | |
186 | { | |
187 | ! close_dll(hinstRuby); | |
188 | hinstRuby = 0; | |
189 | if (verbose) | |
190 | EMSG2(_(e_loadfunc), ruby_funcname_table[i].name); | |
191 | *** ../vim-7.3.012/src/version.c 2010-09-29 12:37:53.000000000 +0200 | |
192 | --- src/version.c 2010-09-29 13:00:42.000000000 +0200 | |
193 | *************** | |
194 | *** 716,717 **** | |
195 | --- 716,719 ---- | |
196 | { /* Add new patch number below this line */ | |
197 | + /**/ | |
198 | + 13, | |
199 | /**/ | |
200 | ||
201 | -- | |
202 | hundred-and-one symptoms of being an internet addict: | |
203 | 223. You set up a web-cam as your home's security system. | |
204 | ||
205 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
206 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
207 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
208 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |