Mercurial > vim
annotate src/if_ruby.c @ 24873:e66659584572
Added tag v8.2.2974 for changeset 59cfa23bd9eb2d4115d3a0e27944e1fdcf522c66
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 11 Jun 2021 19:15:05 +0200 |
parents | 51a5c5f08bdd |
children | c4298ed56ffa |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
779 | 4 * |
5 * Ruby interface by Shugo Maeda | |
6 * with improvements by SegPhault (Ryan Paul) | |
2589 | 7 * with improvements by Jon Maken |
7 | 8 * |
9 * Do ":help uganda" in Vim to read copying and usage conditions. | |
10 * Do ":help credits" in Vim to see a list of people who contributed. | |
11 * See README.txt for an overview of the Vim source code. | |
12 */ | |
13 | |
14736
3e9b24eac417
patch 8.1.0380: "make proto" doesn't work well
Christian Brabandt <cb@256bit.org>
parents:
14511
diff
changeset
|
14 #include "protodef.h" |
2624 | 15 #ifdef HAVE_CONFIG_H |
16 # include "auto/config.h" | |
17 #endif | |
2621 | 18 |
2683 | 19 #include <stdio.h> |
20 #include <string.h> | |
21 | |
7 | 22 #ifdef _WIN32 |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
23 # if !defined(DYNAMIC_RUBY) || (RUBY_VERSION < 18) |
19376
1cae476a7c82
patch 8.2.0246: MSVC: deprecation warnings with Ruby
Bram Moolenaar <Bram@vim.org>
parents:
19102
diff
changeset
|
24 # define NT |
7 | 25 # endif |
26 # ifndef DYNAMIC_RUBY | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
27 # define IMPORT // For static dll usage __declspec(dllimport) |
7 | 28 # define RUBYEXTERN __declspec(dllimport) |
29 # endif | |
30 #endif | |
31 #ifndef RUBYEXTERN | |
32 # define RUBYEXTERN extern | |
33 #endif | |
34 | |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
35 // suggested by Ariya Mizutani |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
36 #if (_MSC_VER == 1200) |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
37 # undef _WIN32_WINNT |
9278
97b0b568f820
commit https://github.com/vim/vim/commit/06469e979fe524ac6cb8f705ed4221aa267de11d
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
38 #endif |
97b0b568f820
commit https://github.com/vim/vim/commit/06469e979fe524ac6cb8f705ed4221aa267de11d
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
39 |
2589 | 40 #ifdef DYNAMIC_RUBY |
7 | 41 /* |
42 * This is tricky. In ruby.h there is (inline) function rb_class_of() | |
43 * definition. This function use these variables. But we want function to | |
44 * use dll_* variables. | |
45 */ | |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
46 # if RUBY_VERSION >= 24 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
47 # define USE_RUBY_INTEGER |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
48 # endif |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
49 |
7 | 50 # define rb_cFalseClass (*dll_rb_cFalseClass) |
51 # define rb_cFixnum (*dll_rb_cFixnum) | |
9293
946b62bbd871
commit https://github.com/vim/vim/commit/2016ae586b12513d973aabc30ed758b543114cbe
Christian Brabandt <cb@256bit.org>
parents:
9278
diff
changeset
|
52 # if defined(USE_RUBY_INTEGER) |
946b62bbd871
commit https://github.com/vim/vim/commit/2016ae586b12513d973aabc30ed758b543114cbe
Christian Brabandt <cb@256bit.org>
parents:
9278
diff
changeset
|
53 # define rb_cInteger (*dll_rb_cInteger) |
9278
97b0b568f820
commit https://github.com/vim/vim/commit/06469e979fe524ac6cb8f705ed4221aa267de11d
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
54 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
55 # if RUBY_VERSION >= 20 |
4193 | 56 # define rb_cFloat (*dll_rb_cFloat) |
57 # endif | |
7 | 58 # define rb_cNilClass (*dll_rb_cNilClass) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
59 # define rb_cString (*dll_rb_cString) |
7 | 60 # define rb_cSymbol (*dll_rb_cSymbol) |
61 # define rb_cTrueClass (*dll_rb_cTrueClass) | |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
62 |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
63 # if RUBY_VERSION >= 18 |
7 | 64 /* |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
65 * On ver 1.8, all Ruby functions are exported with "__declspec(dllimport)" |
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
66 * in ruby.h. But it causes trouble for these variables, because it is |
7 | 67 * defined in this file. When defined this RUBY_EXPORT it modified to |
68 * "extern" and be able to avoid this problem. | |
69 */ | |
70 # define RUBY_EXPORT | |
71 # endif | |
2589 | 72 |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
73 # if RUBY_VERSION >= 19 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
74 // Ruby 1.9 defines a number of static functions which use rb_num2long and |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
75 // rb_int2big |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
76 # define rb_num2long rb_num2long_stub |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
77 # define rb_int2big rb_int2big_stub |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
78 |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
79 # if RUBY_VERSION >= 30 || VIM_SIZEOF_INT < VIM_SIZEOF_LONG |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
80 // Ruby 1.9 defines a number of static functions which use rb_fix2int and |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
81 // rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit) |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
82 # define rb_fix2int rb_fix2int_stub |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
83 # define rb_num2int rb_num2int_stub |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
84 # endif |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
85 # endif |
4279 | 86 |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
87 # if RUBY_VERSION == 21 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
88 // Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
89 // rb_gc_writebarrier_unprotect_promoted if USE_RGENGC |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
90 # define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
91 # endif |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
92 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
93 # if RUBY_VERSION >= 22 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
94 # define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
95 # endif |
5643 | 96 |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
97 # if RUBY_VERSION >= 26 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
98 # define rb_ary_detransient rb_ary_detransient_stub |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
99 # endif |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
100 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
101 # if RUBY_VERSION >= 30 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
102 # define rb_check_type rb_check_type_stub |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
103 # define rb_num2uint rb_num2uint_stub |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
104 # define ruby_malloc_size_overflow ruby_malloc_size_overflow_stub |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
105 # endif |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
106 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
107 #endif // ifdef DYNAMIC_RUBY |
15275
b408509d8292
patch 8.1.0646: cannot build with Ruby 2.6.0
Bram Moolenaar <Bram@vim.org>
parents:
15199
diff
changeset
|
108 |
19971
a042d2a3b13d
patch 8.2.0541: Travis CI does not give compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
109 // On macOS pre-installed Ruby defines "SIZEOF_TIME_T" as "SIZEOF_LONG" so it |
20548
6564dafe5005
patch 8.2.0828: Travis: regexp patttern doesn't work everywhere
Bram Moolenaar <Bram@vim.org>
parents:
19971
diff
changeset
|
110 // conflicts with the definition in config.h then causes a macro-redefined |
6564dafe5005
patch 8.2.0828: Travis: regexp patttern doesn't work everywhere
Bram Moolenaar <Bram@vim.org>
parents:
19971
diff
changeset
|
111 // warning. |
19971
a042d2a3b13d
patch 8.2.0541: Travis CI does not give compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
112 #ifdef SIZEOF_TIME_T |
a042d2a3b13d
patch 8.2.0541: Travis CI does not give compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
113 # undef SIZEOF_TIME_T |
a042d2a3b13d
patch 8.2.0541: Travis CI does not give compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
114 #endif |
a042d2a3b13d
patch 8.2.0541: Travis CI does not give compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
115 |
7 | 116 #include <ruby.h> |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
117 #if RUBY_VERSION >= 19 |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
118 # include <ruby/encoding.h> |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
119 #endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
120 #if RUBY_VERSION <= 18 |
16338
366978ec2c03
patch 8.1.1174: cannot build with Ruby 1.8
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
121 # include <st.h> // for ST_STOP and ST_CONTINUE |
366978ec2c03
patch 8.1.1174: cannot build with Ruby 1.8
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
122 #endif |
7 | 123 |
20548
6564dafe5005
patch 8.2.0828: Travis: regexp patttern doesn't work everywhere
Bram Moolenaar <Bram@vim.org>
parents:
19971
diff
changeset
|
124 // See above. |
6564dafe5005
patch 8.2.0828: Travis: regexp patttern doesn't work everywhere
Bram Moolenaar <Bram@vim.org>
parents:
19971
diff
changeset
|
125 #ifdef SIZEOF_TIME_T |
6564dafe5005
patch 8.2.0828: Travis: regexp patttern doesn't work everywhere
Bram Moolenaar <Bram@vim.org>
parents:
19971
diff
changeset
|
126 # undef SIZEOF_TIME_T |
6564dafe5005
patch 8.2.0828: Travis: regexp patttern doesn't work everywhere
Bram Moolenaar <Bram@vim.org>
parents:
19971
diff
changeset
|
127 #endif |
6564dafe5005
patch 8.2.0828: Travis: regexp patttern doesn't work everywhere
Bram Moolenaar <Bram@vim.org>
parents:
19971
diff
changeset
|
128 |
16338
366978ec2c03
patch 8.1.1174: cannot build with Ruby 1.8
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
129 #undef off_t // ruby defines off_t as _int64, Mingw uses long |
7 | 130 #undef EXTERN |
131 #undef _ | |
132 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
133 // T_DATA defined both by Ruby and Mac header files, hack around it... |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12553
diff
changeset
|
134 #if defined(MACOS_X) |
7 | 135 # define __OPENTRANSPORT__ |
136 # define __OPENTRANSPORTPROTOCOL__ | |
137 # define __OPENTRANSPORTPROVIDERS__ | |
138 #endif | |
139 | |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
140 /* |
7364
fe2f6b92d806
commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents:
7360
diff
changeset
|
141 * The TypedData_XXX macro family can be used since Ruby 1.9.2 but |
fe2f6b92d806
commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents:
7360
diff
changeset
|
142 * rb_data_type_t changed in 1.9.3, therefore require at least 2.0. |
fe2f6b92d806
commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents:
7360
diff
changeset
|
143 * The old Data_XXX macro family was deprecated on Ruby 2.2. |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
144 * Use TypedData_XXX if available. |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
145 */ |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
146 #if defined(TypedData_Wrap_Struct) && (RUBY_VERSION >= 20) |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
147 # define USE_TYPEDDATA 1 |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
148 #endif |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
149 |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
150 /* |
4352 | 151 * Backward compatibility for Ruby 1.8 and earlier. |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
152 * Ruby 1.9 does not provide STR2CSTR, instead StringValuePtr is provided. |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
153 * Ruby 1.9 does not provide RXXX(s)->len and RXXX(s)->ptr, instead |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
154 * RXXX_LEN(s) and RXXX_PTR(s) are provided. |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
155 */ |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
156 #ifndef StringValuePtr |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
157 # define StringValuePtr(s) STR2CSTR(s) |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
158 #endif |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
159 #ifndef RARRAY_LEN |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
160 # define RARRAY_LEN(s) RARRAY(s)->len |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
161 #endif |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
162 #ifndef RARRAY_PTR |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
163 # define RARRAY_PTR(s) RARRAY(s)->ptr |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
164 #endif |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
165 #ifndef RSTRING_LEN |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
166 # define RSTRING_LEN(s) RSTRING(s)->len |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
167 #endif |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
168 #ifndef RSTRING_PTR |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
169 # define RSTRING_PTR(s) RSTRING(s)->ptr |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
170 #endif |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
171 |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
172 #ifdef HAVE_DUP |
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
173 # undef HAVE_DUP |
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
174 #endif |
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
175 |
7 | 176 #include "vim.h" |
177 #include "version.h" | |
178 | |
15882
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
179 #ifdef DYNAMIC_RUBY |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
180 # if !defined(MSWIN) // must come after including vim.h, where it is defined |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
181 # include <dlfcn.h> |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
182 # define HINSTANCE void* |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
183 # define RUBY_PROC void* |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
184 # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
185 # define symbol_from_dll dlsym |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
186 # define close_dll dlclose |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
187 # else |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
188 # define RUBY_PROC FARPROC |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
189 # define load_dll vimLoadLib |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
190 # define symbol_from_dll GetProcAddress |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
191 # define close_dll FreeLibrary |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
192 # endif |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
193 #endif |
8fb7dd311ca7
patch 8.1.0947: using MSWIN before it is defined
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
194 |
7 | 195 #if defined(PROTO) && !defined(FEAT_RUBY) |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
196 // Define these to be able to generate the function prototypes. |
7 | 197 # define VALUE int |
198 # define RUBY_DATA_FUNC int | |
199 #endif | |
200 | |
201 static int ruby_initialized = 0; | |
4369 | 202 static void *ruby_stack_start; |
7 | 203 static VALUE objtbl; |
204 | |
205 static VALUE mVIM; | |
206 static VALUE cBuffer; | |
207 static VALUE cVimWindow; | |
208 static VALUE eDeletedBufferError; | |
209 static VALUE eDeletedWindowError; | |
210 | |
211 static int ensure_ruby_initialized(void); | |
212 static void error_print(int); | |
213 static void ruby_io_init(void); | |
214 static void ruby_vim_init(void); | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
215 static int ruby_convert_to_vim_value(VALUE val, typval_T *rettv); |
7 | 216 |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
217 #if (RUBY_VERSION >= 19) || defined(RUBY_INIT_STACK) |
4452 | 218 # if defined(__ia64) && !defined(ruby_init_stack) |
219 # define ruby_init_stack(addr) ruby_init_stack((addr), rb_ia64_bsp()) | |
220 # endif | |
4375 | 221 #endif |
222 | |
7 | 223 #if defined(DYNAMIC_RUBY) || defined(PROTO) |
7668
21b0a39d13ed
commit https://github.com/vim/vim/commit/ef26954a35207c3f17d6ed35d9a40c918d974892
Christian Brabandt <cb@256bit.org>
parents:
7528
diff
changeset
|
224 # if defined(PROTO) && !defined(HINSTANCE) |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
225 # define HINSTANCE int // for generating prototypes |
4375 | 226 # endif |
7 | 227 |
228 /* | |
229 * Wrapper defines | |
230 */ | |
19479
bc6c7be92527
patch 8.2.0297: compiler warnings for the Ruby interface
Bram Moolenaar <Bram@vim.org>
parents:
19376
diff
changeset
|
231 // Ruby 2.7 actually expands the following symbols as macro. |
bc6c7be92527
patch 8.2.0297: compiler warnings for the Ruby interface
Bram Moolenaar <Bram@vim.org>
parents:
19376
diff
changeset
|
232 # if RUBY_VERSION >= 27 |
bc6c7be92527
patch 8.2.0297: compiler warnings for the Ruby interface
Bram Moolenaar <Bram@vim.org>
parents:
19376
diff
changeset
|
233 # undef rb_define_global_function |
bc6c7be92527
patch 8.2.0297: compiler warnings for the Ruby interface
Bram Moolenaar <Bram@vim.org>
parents:
19376
diff
changeset
|
234 # undef rb_define_method |
bc6c7be92527
patch 8.2.0297: compiler warnings for the Ruby interface
Bram Moolenaar <Bram@vim.org>
parents:
19376
diff
changeset
|
235 # undef rb_define_module_function |
bc6c7be92527
patch 8.2.0297: compiler warnings for the Ruby interface
Bram Moolenaar <Bram@vim.org>
parents:
19376
diff
changeset
|
236 # undef rb_define_singleton_method |
bc6c7be92527
patch 8.2.0297: compiler warnings for the Ruby interface
Bram Moolenaar <Bram@vim.org>
parents:
19376
diff
changeset
|
237 # endif |
bc6c7be92527
patch 8.2.0297: compiler warnings for the Ruby interface
Bram Moolenaar <Bram@vim.org>
parents:
19376
diff
changeset
|
238 |
4375 | 239 # define rb_assoc_new dll_rb_assoc_new |
240 # define rb_cObject (*dll_rb_cObject) | |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
241 # define rb_class_new_instance dll_rb_class_new_instance |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
242 # if RUBY_VERSION < 30 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
243 # define rb_check_type dll_rb_check_type |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
244 # endif |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
245 # ifdef USE_TYPEDDATA |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
246 # define rb_check_typeddata dll_rb_check_typeddata |
6485 | 247 # endif |
4375 | 248 # define rb_class_path dll_rb_class_path |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
249 # ifdef USE_TYPEDDATA |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
250 # if RUBY_VERSION >= 23 |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
251 # define rb_data_typed_object_wrap dll_rb_data_typed_object_wrap |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
252 # else |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
253 # define rb_data_typed_object_alloc dll_rb_data_typed_object_alloc |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
254 # endif |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
255 # else |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
256 # define rb_data_object_alloc dll_rb_data_object_alloc |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
257 # endif |
4375 | 258 # define rb_define_class_under dll_rb_define_class_under |
259 # define rb_define_const dll_rb_define_const | |
260 # define rb_define_global_function dll_rb_define_global_function | |
261 # define rb_define_method dll_rb_define_method | |
262 # define rb_define_module dll_rb_define_module | |
263 # define rb_define_module_function dll_rb_define_module_function | |
264 # define rb_define_singleton_method dll_rb_define_singleton_method | |
265 # define rb_define_virtual_variable dll_rb_define_virtual_variable | |
266 # define rb_stdout (*dll_rb_stdout) | |
14389
424ccd85d5c6
patch 8.1.0209: stderr output from Ruby messes up display
Christian Brabandt <cb@256bit.org>
parents:
13958
diff
changeset
|
267 # define rb_stderr (*dll_rb_stderr) |
4375 | 268 # define rb_eArgError (*dll_rb_eArgError) |
269 # define rb_eIndexError (*dll_rb_eIndexError) | |
270 # define rb_eRuntimeError (*dll_rb_eRuntimeError) | |
271 # define rb_eStandardError (*dll_rb_eStandardError) | |
272 # define rb_eval_string_protect dll_rb_eval_string_protect | |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
273 # if RUBY_VERSION >= 21 |
14437
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
274 # define rb_funcallv dll_rb_funcallv |
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
275 # else |
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
276 # define rb_funcall2 dll_rb_funcall2 |
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
277 # endif |
4375 | 278 # define rb_global_variable dll_rb_global_variable |
279 # define rb_hash_aset dll_rb_hash_aset | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
280 # define rb_hash_foreach dll_rb_hash_foreach |
4375 | 281 # define rb_hash_new dll_rb_hash_new |
282 # define rb_inspect dll_rb_inspect | |
283 # define rb_int2inum dll_rb_int2inum | |
14451
9992af1ec9d3
patch 8.1.0239: now Ruby build fails on other systems
Christian Brabandt <cb@256bit.org>
parents:
14445
diff
changeset
|
284 |
9992af1ec9d3
patch 8.1.0239: now Ruby build fails on other systems
Christian Brabandt <cb@256bit.org>
parents:
14445
diff
changeset
|
285 // ruby.h may redefine rb_intern to use RUBY_CONST_ID_CACHE(), but that won't |
9992af1ec9d3
patch 8.1.0239: now Ruby build fails on other systems
Christian Brabandt <cb@256bit.org>
parents:
14445
diff
changeset
|
286 // work. Not using the cache appears to be the best solution. |
9992af1ec9d3
patch 8.1.0239: now Ruby build fails on other systems
Christian Brabandt <cb@256bit.org>
parents:
14445
diff
changeset
|
287 # undef rb_intern |
9992af1ec9d3
patch 8.1.0239: now Ruby build fails on other systems
Christian Brabandt <cb@256bit.org>
parents:
14445
diff
changeset
|
288 # define rb_intern dll_rb_intern |
9992af1ec9d3
patch 8.1.0239: now Ruby build fails on other systems
Christian Brabandt <cb@256bit.org>
parents:
14445
diff
changeset
|
289 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
290 # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG // 64 bits only |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
291 # if RUBY_VERSION <= 18 |
5766 | 292 # define rb_fix2int dll_rb_fix2int |
293 # define rb_num2int dll_rb_num2int | |
294 # endif | |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
295 # if RUBY_VERSION < 30 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
296 # define rb_num2uint dll_rb_num2uint |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
297 # endif |
4375 | 298 # endif |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
299 # define rb_num2dbl dll_rb_num2dbl |
4375 | 300 # define rb_lastline_get dll_rb_lastline_get |
301 # define rb_lastline_set dll_rb_lastline_set | |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12553
diff
changeset
|
302 # define rb_protect dll_rb_protect |
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12553
diff
changeset
|
303 # define rb_load dll_rb_load |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
304 # if RUBY_VERSION <= 18 |
4375 | 305 # define rb_num2long dll_rb_num2long |
306 # endif | |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
307 # if RUBY_VERSION <= 19 |
4375 | 308 # define rb_num2ulong dll_rb_num2ulong |
309 # endif | |
310 # define rb_obj_alloc dll_rb_obj_alloc | |
311 # define rb_obj_as_string dll_rb_obj_as_string | |
312 # define rb_obj_id dll_rb_obj_id | |
313 # define rb_raise dll_rb_raise | |
314 # define rb_str_cat dll_rb_str_cat | |
315 # define rb_str_concat dll_rb_str_concat | |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
316 # undef rb_str_new |
4375 | 317 # define rb_str_new dll_rb_str_new |
318 # ifdef rb_str_new2 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
319 // Ruby may #define rb_str_new2 to use rb_str_new_cstr. |
4375 | 320 # define need_rb_str_new_cstr 1 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
321 // Ruby's headers #define rb_str_new_cstr to make use of GCC's |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
322 // __builtin_constant_p extension. |
4375 | 323 # undef rb_str_new_cstr |
324 # define rb_str_new_cstr dll_rb_str_new_cstr | |
4373 | 325 # else |
4375 | 326 # define rb_str_new2 dll_rb_str_new2 |
327 # endif | |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
328 # if RUBY_VERSION >= 18 |
4375 | 329 # define rb_string_value dll_rb_string_value |
330 # define rb_string_value_ptr dll_rb_string_value_ptr | |
331 # define rb_float_new dll_rb_float_new | |
332 # define rb_ary_new dll_rb_ary_new | |
14511
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
333 # ifdef rb_ary_new4 |
19376
1cae476a7c82
patch 8.2.0246: MSVC: deprecation warnings with Ruby
Bram Moolenaar <Bram@vim.org>
parents:
19102
diff
changeset
|
334 # define RB_ARY_NEW4_MACRO 1 |
1cae476a7c82
patch 8.2.0246: MSVC: deprecation warnings with Ruby
Bram Moolenaar <Bram@vim.org>
parents:
19102
diff
changeset
|
335 # undef rb_ary_new4 |
14511
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
336 # endif |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
337 # define rb_ary_new4 dll_rb_ary_new4 |
4375 | 338 # define rb_ary_push dll_rb_ary_push |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
339 # if (RUBY_VERSION >= 19) || defined(RUBY_INIT_STACK) |
4452 | 340 # ifdef __ia64 |
341 # define rb_ia64_bsp dll_rb_ia64_bsp | |
342 # undef ruby_init_stack | |
343 # define ruby_init_stack(addr) dll_ruby_init_stack((addr), rb_ia64_bsp()) | |
344 # else | |
345 # define ruby_init_stack dll_ruby_init_stack | |
346 # endif | |
4375 | 347 # endif |
348 # else | |
349 # define rb_str2cstr dll_rb_str2cstr | |
4373 | 350 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
351 # if RUBY_VERSION >= 19 |
4375 | 352 # define rb_errinfo dll_rb_errinfo |
353 # else | |
354 # define ruby_errinfo (*dll_ruby_errinfo) | |
2621 | 355 # endif |
4375 | 356 # define ruby_init dll_ruby_init |
357 # define ruby_init_loadpath dll_ruby_init_loadpath | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15727
diff
changeset
|
358 # ifdef MSWIN |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
359 # if RUBY_VERSION >= 19 |
15199
1e98b81ff9ee
patch 8.1.0609: MS-Windows: unused variable, depending on the Ruby version
Bram Moolenaar <Bram@vim.org>
parents:
14736
diff
changeset
|
360 # define ruby_sysinit dll_ruby_sysinit |
1e98b81ff9ee
patch 8.1.0609: MS-Windows: unused variable, depending on the Ruby version
Bram Moolenaar <Bram@vim.org>
parents:
14736
diff
changeset
|
361 # else |
1e98b81ff9ee
patch 8.1.0609: MS-Windows: unused variable, depending on the Ruby version
Bram Moolenaar <Bram@vim.org>
parents:
14736
diff
changeset
|
362 # define NtInitialize dll_NtInitialize |
1e98b81ff9ee
patch 8.1.0609: MS-Windows: unused variable, depending on the Ruby version
Bram Moolenaar <Bram@vim.org>
parents:
14736
diff
changeset
|
363 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
364 # if RUBY_VERSION >= 18 |
4375 | 365 # define rb_w32_snprintf dll_rb_w32_snprintf |
366 # endif | |
367 # endif | |
7 | 368 |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
369 # if RUBY_VERSION >= 19 |
4375 | 370 # define ruby_script dll_ruby_script |
371 # define rb_enc_find_index dll_rb_enc_find_index | |
372 # define rb_enc_find dll_rb_enc_find | |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
373 # undef rb_enc_str_new |
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
374 # define rb_enc_str_new dll_rb_enc_str_new |
4375 | 375 # define rb_sprintf dll_rb_sprintf |
376 # define rb_require dll_rb_require | |
7237
2a95fa0a07b5
commit https://github.com/vim/vim/commit/9b1067e038d371bd6c51e5da025383761f4921b4
Christian Brabandt <cb@256bit.org>
parents:
7196
diff
changeset
|
377 # define ruby_options dll_ruby_options |
4375 | 378 # endif |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
379 |
7 | 380 /* |
381 * Pointers for dynamic link | |
382 */ | |
383 static VALUE (*dll_rb_assoc_new) (VALUE, VALUE); | |
2274
7c31d761ffa9
Fix build problem with Ruby on Windows. (Cesar Romani)
Bram Moolenaar <bram@vim.org>
parents:
2212
diff
changeset
|
384 VALUE *dll_rb_cFalseClass; |
7c31d761ffa9
Fix build problem with Ruby on Windows. (Cesar Romani)
Bram Moolenaar <bram@vim.org>
parents:
2212
diff
changeset
|
385 VALUE *dll_rb_cFixnum; |
9293
946b62bbd871
commit https://github.com/vim/vim/commit/2016ae586b12513d973aabc30ed758b543114cbe
Christian Brabandt <cb@256bit.org>
parents:
9278
diff
changeset
|
386 # if defined(USE_RUBY_INTEGER) |
9278
97b0b568f820
commit https://github.com/vim/vim/commit/06469e979fe524ac6cb8f705ed4221aa267de11d
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
387 VALUE *dll_rb_cInteger; |
97b0b568f820
commit https://github.com/vim/vim/commit/06469e979fe524ac6cb8f705ed4221aa267de11d
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
388 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
389 # if RUBY_VERSION >= 20 |
4193 | 390 VALUE *dll_rb_cFloat; |
4375 | 391 # endif |
2274
7c31d761ffa9
Fix build problem with Ruby on Windows. (Cesar Romani)
Bram Moolenaar <bram@vim.org>
parents:
2212
diff
changeset
|
392 VALUE *dll_rb_cNilClass; |
7 | 393 static VALUE *dll_rb_cObject; |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
394 VALUE *dll_rb_cString; |
2274
7c31d761ffa9
Fix build problem with Ruby on Windows. (Cesar Romani)
Bram Moolenaar <bram@vim.org>
parents:
2212
diff
changeset
|
395 VALUE *dll_rb_cSymbol; |
7c31d761ffa9
Fix build problem with Ruby on Windows. (Cesar Romani)
Bram Moolenaar <bram@vim.org>
parents:
2212
diff
changeset
|
396 VALUE *dll_rb_cTrueClass; |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
397 static VALUE (*dll_rb_class_new_instance) (int,VALUE*,VALUE); |
7 | 398 static void (*dll_rb_check_type) (VALUE,int); |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
399 # ifdef USE_TYPEDDATA |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
400 static void *(*dll_rb_check_typeddata) (VALUE,const rb_data_type_t *); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
401 # endif |
7 | 402 static VALUE (*dll_rb_class_path) (VALUE); |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
403 # ifdef USE_TYPEDDATA |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
404 # if RUBY_VERSION >= 23 |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
405 static VALUE (*dll_rb_data_typed_object_wrap) (VALUE, void*, const rb_data_type_t *); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
406 # else |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
407 static VALUE (*dll_rb_data_typed_object_alloc) (VALUE, void*, const rb_data_type_t *); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
408 # endif |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
409 # else |
7 | 410 static VALUE (*dll_rb_data_object_alloc) (VALUE, void*, RUBY_DATA_FUNC, RUBY_DATA_FUNC); |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
411 # endif |
7 | 412 static VALUE (*dll_rb_define_class_under) (VALUE, const char*, VALUE); |
413 static void (*dll_rb_define_const) (VALUE,const char*,VALUE); | |
414 static void (*dll_rb_define_global_function) (const char*,VALUE(*)(),int); | |
415 static void (*dll_rb_define_method) (VALUE,const char*,VALUE(*)(),int); | |
416 static VALUE (*dll_rb_define_module) (const char*); | |
417 static void (*dll_rb_define_module_function) (VALUE,const char*,VALUE(*)(),int); | |
418 static void (*dll_rb_define_singleton_method) (VALUE,const char*,VALUE(*)(),int); | |
419 static void (*dll_rb_define_virtual_variable) (const char*,VALUE(*)(),void(*)()); | |
420 static VALUE *dll_rb_stdout; | |
14389
424ccd85d5c6
patch 8.1.0209: stderr output from Ruby messes up display
Christian Brabandt <cb@256bit.org>
parents:
13958
diff
changeset
|
421 static VALUE *dll_rb_stderr; |
7 | 422 static VALUE *dll_rb_eArgError; |
423 static VALUE *dll_rb_eIndexError; | |
424 static VALUE *dll_rb_eRuntimeError; | |
425 static VALUE *dll_rb_eStandardError; | |
426 static VALUE (*dll_rb_eval_string_protect) (const char*, int*); | |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
427 # if RUBY_VERSION >= 21 |
14437
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
428 static VALUE (*dll_rb_funcallv) (VALUE, ID, int, const VALUE*); |
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
429 # else |
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
430 static VALUE (*dll_rb_funcall2) (VALUE, ID, int, const VALUE*); |
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
431 # endif |
7 | 432 static void (*dll_rb_global_variable) (VALUE*); |
433 static VALUE (*dll_rb_hash_aset) (VALUE, VALUE, VALUE); | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
434 static VALUE (*dll_rb_hash_foreach) (VALUE, int (*)(VALUE, VALUE, VALUE), VALUE); |
7 | 435 static VALUE (*dll_rb_hash_new) (void); |
436 static VALUE (*dll_rb_inspect) (VALUE); | |
437 static VALUE (*dll_rb_int2inum) (long); | |
14445
dda317774511
patch 8.1.0236: Ruby build fails when ruby_intern is missing
Christian Brabandt <cb@256bit.org>
parents:
14437
diff
changeset
|
438 static ID (*dll_rb_intern) (const char*); |
23814
51a5c5f08bdd
patch 8.2.2448: compilation error with Ruby 3.0
Bram Moolenaar <Bram@vim.org>
parents:
23539
diff
changeset
|
439 # if RUBY_VERSION >= 30 || VIM_SIZEOF_INT < VIM_SIZEOF_LONG |
3808 | 440 static long (*dll_rb_fix2int) (VALUE); |
441 static long (*dll_rb_num2int) (VALUE); | |
442 static unsigned long (*dll_rb_num2uint) (VALUE); | |
4375 | 443 # endif |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
444 static double (*dll_rb_num2dbl) (VALUE); |
7 | 445 static VALUE (*dll_rb_lastline_get) (void); |
446 static void (*dll_rb_lastline_set) (VALUE); | |
13148
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
447 static VALUE (*dll_rb_protect) (VALUE (*)(VALUE), VALUE, int*); |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12553
diff
changeset
|
448 static void (*dll_rb_load) (VALUE, int); |
7 | 449 static long (*dll_rb_num2long) (VALUE); |
450 static unsigned long (*dll_rb_num2ulong) (VALUE); | |
451 static VALUE (*dll_rb_obj_alloc) (VALUE); | |
452 static VALUE (*dll_rb_obj_as_string) (VALUE); | |
453 static VALUE (*dll_rb_obj_id) (VALUE); | |
454 static void (*dll_rb_raise) (VALUE, const char*, ...); | |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
455 # if RUBY_VERSION >= 18 |
2589 | 456 static VALUE (*dll_rb_string_value) (volatile VALUE*); |
4375 | 457 # else |
7 | 458 static char *(*dll_rb_str2cstr) (VALUE,int*); |
4375 | 459 # endif |
7 | 460 static VALUE (*dll_rb_str_cat) (VALUE, const char*, long); |
461 static VALUE (*dll_rb_str_concat) (VALUE, VALUE); | |
462 static VALUE (*dll_rb_str_new) (const char*, long); | |
4375 | 463 # ifdef need_rb_str_new_cstr |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
464 // Ruby may #define rb_str_new2 to use rb_str_new_cstr. |
2212
7d3cf4693a8f
Some versions of Ruby redefine rb_str_new2 to rb_str_new_cstr.
Bram Moolenaar <bram@vim.org>
parents:
2200
diff
changeset
|
465 static VALUE (*dll_rb_str_new_cstr) (const char*); |
4375 | 466 # else |
7 | 467 static VALUE (*dll_rb_str_new2) (const char*); |
4375 | 468 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
469 # if RUBY_VERSION >= 19 |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
470 static VALUE (*dll_rb_errinfo) (void); |
4375 | 471 # else |
7 | 472 static VALUE *dll_ruby_errinfo; |
4375 | 473 # endif |
7 | 474 static void (*dll_ruby_init) (void); |
475 static void (*dll_ruby_init_loadpath) (void); | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15727
diff
changeset
|
476 # ifdef MSWIN |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
477 # if RUBY_VERSION >= 19 |
15199
1e98b81ff9ee
patch 8.1.0609: MS-Windows: unused variable, depending on the Ruby version
Bram Moolenaar <Bram@vim.org>
parents:
14736
diff
changeset
|
478 static void (*dll_ruby_sysinit) (int*, char***); |
1e98b81ff9ee
patch 8.1.0609: MS-Windows: unused variable, depending on the Ruby version
Bram Moolenaar <Bram@vim.org>
parents:
14736
diff
changeset
|
479 # else |
2076
1c7a66d820e4
updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents:
1888
diff
changeset
|
480 static void (*dll_NtInitialize) (int*, char***); |
15199
1e98b81ff9ee
patch 8.1.0609: MS-Windows: unused variable, depending on the Ruby version
Bram Moolenaar <Bram@vim.org>
parents:
14736
diff
changeset
|
481 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
482 # if RUBY_VERSION >= 18 |
2621 | 483 static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...); |
4375 | 484 # endif |
2621 | 485 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
486 # if RUBY_VERSION >= 18 |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
487 static char * (*dll_rb_string_value_ptr) (volatile VALUE*); |
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
488 static VALUE (*dll_rb_float_new) (double); |
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
489 static VALUE (*dll_rb_ary_new) (void); |
14511
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
490 static VALUE (*dll_rb_ary_new4) (long n, const VALUE *elts); |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
491 static VALUE (*dll_rb_ary_push) (VALUE, VALUE); |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
492 # if RUBY_VERSION >= 26 |
15275
b408509d8292
patch 8.1.0646: cannot build with Ruby 2.6.0
Bram Moolenaar <Bram@vim.org>
parents:
15199
diff
changeset
|
493 static void (*dll_rb_ary_detransient) (VALUE); |
b408509d8292
patch 8.1.0646: cannot build with Ruby 2.6.0
Bram Moolenaar <Bram@vim.org>
parents:
15199
diff
changeset
|
494 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
495 # if (RUBY_VERSION >= 19) || defined(RUBY_INIT_STACK) |
4452 | 496 # ifdef __ia64 |
4373 | 497 static void * (*dll_rb_ia64_bsp) (void); |
498 static void (*dll_ruby_init_stack)(VALUE*, void*); | |
4452 | 499 # else |
4373 | 500 static void (*dll_ruby_init_stack)(VALUE*); |
4452 | 501 # endif |
4375 | 502 # endif |
4373 | 503 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
504 # if RUBY_VERSION >= 19 |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
505 static VALUE (*dll_rb_int2big)(SIGNED_VALUE); |
4375 | 506 # endif |
7 | 507 |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
508 # if RUBY_VERSION >= 19 |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
509 static void (*dll_ruby_script) (const char*); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
510 static int (*dll_rb_enc_find_index) (const char*); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
511 static rb_encoding* (*dll_rb_enc_find) (const char*); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
512 static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
513 static VALUE (*dll_rb_sprintf) (const char*, ...); |
2669 | 514 static VALUE (*dll_rb_require) (const char*); |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
515 static void* (*dll_ruby_options)(int, char**); |
4375 | 516 # endif |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
517 |
5643 | 518 # if defined(USE_RGENGC) && USE_RGENGC |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
519 # if RUBY_VERSION == 21 |
5643 | 520 static void (*dll_rb_gc_writebarrier_unprotect_promoted)(VALUE); |
6485 | 521 # else |
522 static void (*dll_rb_gc_writebarrier_unprotect)(VALUE obj); | |
523 # endif | |
5643 | 524 # endif |
525 | |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
526 # if RUBY_VERSION >= 30 |
23814
51a5c5f08bdd
patch 8.2.2448: compilation error with Ruby 3.0
Bram Moolenaar <Bram@vim.org>
parents:
23539
diff
changeset
|
527 # ifdef _MSC_VER |
51a5c5f08bdd
patch 8.2.2448: compilation error with Ruby 3.0
Bram Moolenaar <Bram@vim.org>
parents:
23539
diff
changeset
|
528 static void (*dll_ruby_malloc_size_overflow)(size_t, size_t); |
51a5c5f08bdd
patch 8.2.2448: compilation error with Ruby 3.0
Bram Moolenaar <Bram@vim.org>
parents:
23539
diff
changeset
|
529 # else |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
530 NORETURN(static void (*dll_ruby_malloc_size_overflow)(size_t, size_t)); |
23814
51a5c5f08bdd
patch 8.2.2448: compilation error with Ruby 3.0
Bram Moolenaar <Bram@vim.org>
parents:
23539
diff
changeset
|
531 # endif |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
532 # endif |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
533 |
23160
19575087e859
patch 8.2.2126: Ruby: missing function prototype
Bram Moolenaar <Bram@vim.org>
parents:
23116
diff
changeset
|
534 # if RUBY_VERSION >= 26 |
19575087e859
patch 8.2.2126: Ruby: missing function prototype
Bram Moolenaar <Bram@vim.org>
parents:
23116
diff
changeset
|
535 void rb_ary_detransient_stub(VALUE x); |
19575087e859
patch 8.2.2126: Ruby: missing function prototype
Bram Moolenaar <Bram@vim.org>
parents:
23116
diff
changeset
|
536 # endif |
19575087e859
patch 8.2.2126: Ruby: missing function prototype
Bram Moolenaar <Bram@vim.org>
parents:
23116
diff
changeset
|
537 |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
538 // Do not generate a prototype here, VALUE isn't always defined. |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
539 # ifndef PROTO |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
540 # if RUBY_VERSION >= 19 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
541 # if RUBY_VERSION >= 22 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
542 long |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
543 rb_num2long_stub(VALUE x) |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
544 # else |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
545 SIGNED_VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
546 rb_num2long_stub(VALUE x) |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
547 # endif |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
548 { |
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
549 return dll_rb_num2long(x); |
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
550 } |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
551 # if RUBY_VERSION >= 26 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
552 VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
553 rb_int2big_stub(intptr_t x) |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
554 # else |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
555 VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
556 rb_int2big_stub(SIGNED_VALUE x) |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
557 # endif |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
558 { |
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
559 return dll_rb_int2big(x); |
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
560 } |
23814
51a5c5f08bdd
patch 8.2.2448: compilation error with Ruby 3.0
Bram Moolenaar <Bram@vim.org>
parents:
23539
diff
changeset
|
561 # if RUBY_VERSION >= 30 || VIM_SIZEOF_INT < VIM_SIZEOF_LONG |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
562 long |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
563 rb_fix2int_stub(VALUE x) |
4279 | 564 { |
565 return dll_rb_fix2int(x); | |
566 } | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
567 long |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
568 rb_num2int_stub(VALUE x) |
4279 | 569 { |
570 return dll_rb_num2int(x); | |
571 } | |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
572 # endif |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
573 # if RUBY_VERSION >= 20 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
574 VALUE |
4164 | 575 rb_float_new_in_heap(double d) |
576 { | |
577 return dll_rb_float_new(d); | |
578 } | |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
579 # if RUBY_VERSION >= 22 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
580 unsigned long |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
581 rb_num2ulong(VALUE x) |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
582 # else |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
583 VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
584 rb_num2ulong(VALUE x) |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
585 # endif |
4164 | 586 { |
587 return (long)RSHIFT((SIGNED_VALUE)(x),1); | |
588 } | |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
589 # endif |
4375 | 590 # endif |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
591 # if defined(USE_RGENGC) && USE_RGENGC |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
592 # if RUBY_VERSION == 21 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
593 void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
594 rb_gc_writebarrier_unprotect_promoted_stub(VALUE obj) |
5643 | 595 { |
6406 | 596 dll_rb_gc_writebarrier_unprotect_promoted(obj); |
5643 | 597 } |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
598 # else |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
599 void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
600 rb_gc_writebarrier_unprotect_stub(VALUE obj) |
6485 | 601 { |
602 dll_rb_gc_writebarrier_unprotect(obj); | |
603 } | |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
604 # endif |
6485 | 605 # endif |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
606 # if RUBY_VERSION >= 26 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
607 void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
608 rb_ary_detransient_stub(VALUE x) |
15392
0807e2dbbab6
patch 8.1.0704: building with Ruby 2.6 gives compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
15275
diff
changeset
|
609 { |
0807e2dbbab6
patch 8.1.0704: building with Ruby 2.6 gives compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
15275
diff
changeset
|
610 dll_rb_ary_detransient(x); |
0807e2dbbab6
patch 8.1.0704: building with Ruby 2.6 gives compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
15275
diff
changeset
|
611 } |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
612 # endif |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
613 # if RUBY_VERSION >= 30 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
614 void |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
615 rb_check_type_stub(VALUE obj, int t) |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
616 { |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
617 dll_rb_check_type(obj, t); |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
618 } |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
619 unsigned long |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
620 rb_num2uint_stub(VALUE x) |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
621 { |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
622 return dll_rb_num2uint(x); |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
623 } |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
624 void |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
625 ruby_malloc_size_overflow_stub(size_t x, size_t y) |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
626 { |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
627 dll_ruby_malloc_size_overflow(x, y); |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
628 } |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
629 # endif |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
630 # endif // ifndef PROTO |
15392
0807e2dbbab6
patch 8.1.0704: building with Ruby 2.6 gives compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
15275
diff
changeset
|
631 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
632 static HINSTANCE hinstRuby = NULL; // Instance of ruby.dll |
7 | 633 |
634 /* | |
501 | 635 * Table of name to function pointer of ruby. |
7 | 636 */ |
637 static struct | |
638 { | |
639 char *name; | |
640 RUBY_PROC *ptr; | |
641 } ruby_funcname_table[] = | |
642 { | |
643 {"rb_assoc_new", (RUBY_PROC*)&dll_rb_assoc_new}, | |
644 {"rb_cFalseClass", (RUBY_PROC*)&dll_rb_cFalseClass}, | |
9293
946b62bbd871
commit https://github.com/vim/vim/commit/2016ae586b12513d973aabc30ed758b543114cbe
Christian Brabandt <cb@256bit.org>
parents:
9278
diff
changeset
|
645 # if defined(USE_RUBY_INTEGER) |
9278
97b0b568f820
commit https://github.com/vim/vim/commit/06469e979fe524ac6cb8f705ed4221aa267de11d
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
646 {"rb_cInteger", (RUBY_PROC*)&dll_rb_cInteger}, |
10546
7babc70a7b98
patch 8.0.0163: cannot build with Ruby 2.4
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
647 # else |
7babc70a7b98
patch 8.0.0163: cannot build with Ruby 2.4
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
648 {"rb_cFixnum", (RUBY_PROC*)&dll_rb_cFixnum}, |
9278
97b0b568f820
commit https://github.com/vim/vim/commit/06469e979fe524ac6cb8f705ed4221aa267de11d
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
649 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
650 # if RUBY_VERSION >= 20 |
4193 | 651 {"rb_cFloat", (RUBY_PROC*)&dll_rb_cFloat}, |
4375 | 652 # endif |
7 | 653 {"rb_cNilClass", (RUBY_PROC*)&dll_rb_cNilClass}, |
654 {"rb_cObject", (RUBY_PROC*)&dll_rb_cObject}, | |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
655 {"rb_cString", (RUBY_PROC*)&dll_rb_cString}, |
7 | 656 {"rb_cSymbol", (RUBY_PROC*)&dll_rb_cSymbol}, |
657 {"rb_cTrueClass", (RUBY_PROC*)&dll_rb_cTrueClass}, | |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
658 {"rb_class_new_instance", (RUBY_PROC*)&dll_rb_class_new_instance}, |
7 | 659 {"rb_check_type", (RUBY_PROC*)&dll_rb_check_type}, |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
660 # ifdef USE_TYPEDDATA |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
661 {"rb_check_typeddata", (RUBY_PROC*)&dll_rb_check_typeddata}, |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
662 # endif |
7 | 663 {"rb_class_path", (RUBY_PROC*)&dll_rb_class_path}, |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
664 # ifdef USE_TYPEDDATA |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
665 # if RUBY_VERSION >= 23 |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
666 {"rb_data_typed_object_wrap", (RUBY_PROC*)&dll_rb_data_typed_object_wrap}, |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
667 # else |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
668 {"rb_data_typed_object_alloc", (RUBY_PROC*)&dll_rb_data_typed_object_alloc}, |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
669 # endif |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
670 # else |
7 | 671 {"rb_data_object_alloc", (RUBY_PROC*)&dll_rb_data_object_alloc}, |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
672 # endif |
7 | 673 {"rb_define_class_under", (RUBY_PROC*)&dll_rb_define_class_under}, |
674 {"rb_define_const", (RUBY_PROC*)&dll_rb_define_const}, | |
675 {"rb_define_global_function", (RUBY_PROC*)&dll_rb_define_global_function}, | |
676 {"rb_define_method", (RUBY_PROC*)&dll_rb_define_method}, | |
677 {"rb_define_module", (RUBY_PROC*)&dll_rb_define_module}, | |
678 {"rb_define_module_function", (RUBY_PROC*)&dll_rb_define_module_function}, | |
679 {"rb_define_singleton_method", (RUBY_PROC*)&dll_rb_define_singleton_method}, | |
680 {"rb_define_virtual_variable", (RUBY_PROC*)&dll_rb_define_virtual_variable}, | |
681 {"rb_stdout", (RUBY_PROC*)&dll_rb_stdout}, | |
14389
424ccd85d5c6
patch 8.1.0209: stderr output from Ruby messes up display
Christian Brabandt <cb@256bit.org>
parents:
13958
diff
changeset
|
682 {"rb_stderr", (RUBY_PROC*)&dll_rb_stderr}, |
7 | 683 {"rb_eArgError", (RUBY_PROC*)&dll_rb_eArgError}, |
684 {"rb_eIndexError", (RUBY_PROC*)&dll_rb_eIndexError}, | |
685 {"rb_eRuntimeError", (RUBY_PROC*)&dll_rb_eRuntimeError}, | |
686 {"rb_eStandardError", (RUBY_PROC*)&dll_rb_eStandardError}, | |
687 {"rb_eval_string_protect", (RUBY_PROC*)&dll_rb_eval_string_protect}, | |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
688 # if RUBY_VERSION >= 21 |
14437
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
689 {"rb_funcallv", (RUBY_PROC*)&dll_rb_funcallv}, |
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
690 # else |
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
691 {"rb_funcall2", (RUBY_PROC*)&dll_rb_funcall2}, |
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
692 # endif |
7 | 693 {"rb_global_variable", (RUBY_PROC*)&dll_rb_global_variable}, |
694 {"rb_hash_aset", (RUBY_PROC*)&dll_rb_hash_aset}, | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
695 {"rb_hash_foreach", (RUBY_PROC*)&dll_rb_hash_foreach}, |
7 | 696 {"rb_hash_new", (RUBY_PROC*)&dll_rb_hash_new}, |
697 {"rb_inspect", (RUBY_PROC*)&dll_rb_inspect}, | |
698 {"rb_int2inum", (RUBY_PROC*)&dll_rb_int2inum}, | |
14445
dda317774511
patch 8.1.0236: Ruby build fails when ruby_intern is missing
Christian Brabandt <cb@256bit.org>
parents:
14437
diff
changeset
|
699 {"rb_intern", (RUBY_PROC*)&dll_rb_intern}, |
23814
51a5c5f08bdd
patch 8.2.2448: compilation error with Ruby 3.0
Bram Moolenaar <Bram@vim.org>
parents:
23539
diff
changeset
|
700 # if RUBY_VERSION >= 30 || VIM_SIZEOF_INT < VIM_SIZEOF_LONG |
3808 | 701 {"rb_fix2int", (RUBY_PROC*)&dll_rb_fix2int}, |
702 {"rb_num2int", (RUBY_PROC*)&dll_rb_num2int}, | |
703 {"rb_num2uint", (RUBY_PROC*)&dll_rb_num2uint}, | |
4375 | 704 # endif |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
705 {"rb_num2dbl", (RUBY_PROC*)&dll_rb_num2dbl}, |
7 | 706 {"rb_lastline_get", (RUBY_PROC*)&dll_rb_lastline_get}, |
707 {"rb_lastline_set", (RUBY_PROC*)&dll_rb_lastline_set}, | |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12553
diff
changeset
|
708 {"rb_protect", (RUBY_PROC*)&dll_rb_protect}, |
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
12553
diff
changeset
|
709 {"rb_load", (RUBY_PROC*)&dll_rb_load}, |
7 | 710 {"rb_num2long", (RUBY_PROC*)&dll_rb_num2long}, |
711 {"rb_num2ulong", (RUBY_PROC*)&dll_rb_num2ulong}, | |
712 {"rb_obj_alloc", (RUBY_PROC*)&dll_rb_obj_alloc}, | |
713 {"rb_obj_as_string", (RUBY_PROC*)&dll_rb_obj_as_string}, | |
714 {"rb_obj_id", (RUBY_PROC*)&dll_rb_obj_id}, | |
715 {"rb_raise", (RUBY_PROC*)&dll_rb_raise}, | |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
716 # if RUBY_VERSION >= 18 |
2589 | 717 {"rb_string_value", (RUBY_PROC*)&dll_rb_string_value}, |
4375 | 718 # else |
7 | 719 {"rb_str2cstr", (RUBY_PROC*)&dll_rb_str2cstr}, |
4375 | 720 # endif |
7 | 721 {"rb_str_cat", (RUBY_PROC*)&dll_rb_str_cat}, |
722 {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat}, | |
723 {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new}, | |
4375 | 724 # ifdef need_rb_str_new_cstr |
2212
7d3cf4693a8f
Some versions of Ruby redefine rb_str_new2 to rb_str_new_cstr.
Bram Moolenaar <bram@vim.org>
parents:
2200
diff
changeset
|
725 {"rb_str_new_cstr", (RUBY_PROC*)&dll_rb_str_new_cstr}, |
4375 | 726 # else |
7 | 727 {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2}, |
4375 | 728 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
729 # if RUBY_VERSION >= 19 |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
730 {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo}, |
4375 | 731 # else |
7 | 732 {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo}, |
4375 | 733 # endif |
7 | 734 {"ruby_init", (RUBY_PROC*)&dll_ruby_init}, |
735 {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath}, | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15727
diff
changeset
|
736 # ifdef MSWIN |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
737 # if RUBY_VERSION >= 19 |
15199
1e98b81ff9ee
patch 8.1.0609: MS-Windows: unused variable, depending on the Ruby version
Bram Moolenaar <Bram@vim.org>
parents:
14736
diff
changeset
|
738 {"ruby_sysinit", (RUBY_PROC*)&dll_ruby_sysinit}, |
1e98b81ff9ee
patch 8.1.0609: MS-Windows: unused variable, depending on the Ruby version
Bram Moolenaar <Bram@vim.org>
parents:
14736
diff
changeset
|
739 # else |
10603
df1abc85b169
patch 8.0.0191: can't build with Ruby on some systems
Christian Brabandt <cb@256bit.org>
parents:
10595
diff
changeset
|
740 {"NtInitialize", (RUBY_PROC*)&dll_NtInitialize}, |
4375 | 741 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
742 # if RUBY_VERSION >= 18 |
7 | 743 {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf}, |
4375 | 744 # endif |
2621 | 745 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
746 # if RUBY_VERSION >= 18 |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
747 {"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr}, |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
748 # if RUBY_VERSION <= 19 |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
749 {"rb_float_new", (RUBY_PROC*)&dll_rb_float_new}, |
4375 | 750 # else |
4164 | 751 {"rb_float_new_in_heap", (RUBY_PROC*)&dll_rb_float_new}, |
4375 | 752 # endif |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
753 {"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new}, |
14511
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
754 # ifdef RB_ARY_NEW4_MACRO |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
755 {"rb_ary_new_from_values", (RUBY_PROC*)&dll_rb_ary_new4}, |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
756 # else |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
757 {"rb_ary_new4", (RUBY_PROC*)&dll_rb_ary_new4}, |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
758 # endif |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
759 {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push}, |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
760 # if RUBY_VERSION >= 26 |
15275
b408509d8292
patch 8.1.0646: cannot build with Ruby 2.6.0
Bram Moolenaar <Bram@vim.org>
parents:
15199
diff
changeset
|
761 {"rb_ary_detransient", (RUBY_PROC*)&dll_rb_ary_detransient}, |
b408509d8292
patch 8.1.0646: cannot build with Ruby 2.6.0
Bram Moolenaar <Bram@vim.org>
parents:
15199
diff
changeset
|
762 # endif |
4375 | 763 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
764 # if RUBY_VERSION >= 19 |
2104
09cc86b66653
updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents:
2090
diff
changeset
|
765 {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big}, |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
766 {"ruby_script", (RUBY_PROC*)&dll_ruby_script}, |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
767 {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index}, |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
768 {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find}, |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
769 {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new}, |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
770 {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf}, |
2669 | 771 {"rb_require", (RUBY_PROC*)&dll_rb_require}, |
7237
2a95fa0a07b5
commit https://github.com/vim/vim/commit/9b1067e038d371bd6c51e5da025383761f4921b4
Christian Brabandt <cb@256bit.org>
parents:
7196
diff
changeset
|
772 {"ruby_options", (RUBY_PROC*)&dll_ruby_options}, |
4375 | 773 # endif |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
774 # if (RUBY_VERSION >= 19) || defined(RUBY_INIT_STACK) |
4452 | 775 # ifdef __ia64 |
776 {"rb_ia64_bsp", (RUBY_PROC*)&dll_rb_ia64_bsp}, | |
777 # endif | |
778 {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack}, | |
779 # endif | |
5643 | 780 # if defined(USE_RGENGC) && USE_RGENGC |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
781 # if RUBY_VERSION == 21 |
5643 | 782 {"rb_gc_writebarrier_unprotect_promoted", (RUBY_PROC*)&dll_rb_gc_writebarrier_unprotect_promoted}, |
6485 | 783 # else |
784 {"rb_gc_writebarrier_unprotect", (RUBY_PROC*)&dll_rb_gc_writebarrier_unprotect}, | |
785 # endif | |
5643 | 786 # endif |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
787 # if RUBY_VERSION >= 30 |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
788 {"ruby_malloc_size_overflow", (RUBY_PROC*)&dll_ruby_malloc_size_overflow}, |
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
789 # endif |
7 | 790 {"", NULL}, |
791 }; | |
792 | |
793 /* | |
794 * Load library and get all pointers. | |
795 * Parameter 'libname' provides name of DLL. | |
796 * Return OK or FAIL. | |
797 */ | |
798 static int | |
799 ruby_runtime_link_init(char *libname, int verbose) | |
800 { | |
801 int i; | |
802 | |
803 if (hinstRuby) | |
804 return OK; | |
2589 | 805 hinstRuby = load_dll(libname); |
7 | 806 if (!hinstRuby) |
807 { | |
808 if (verbose) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
809 semsg(_(e_loadlib), libname); |
7 | 810 return FAIL; |
811 } | |
812 | |
813 for (i = 0; ruby_funcname_table[i].ptr; ++i) | |
814 { | |
2589 | 815 if (!(*ruby_funcname_table[i].ptr = symbol_from_dll(hinstRuby, |
7 | 816 ruby_funcname_table[i].name))) |
817 { | |
2589 | 818 close_dll(hinstRuby); |
2621 | 819 hinstRuby = NULL; |
7 | 820 if (verbose) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
821 semsg(_(e_loadfunc), ruby_funcname_table[i].name); |
7 | 822 return FAIL; |
823 } | |
824 } | |
825 return OK; | |
826 } | |
827 | |
828 /* | |
829 * If ruby is enabled (there is installed ruby on Windows system) return TRUE, | |
830 * else FALSE. | |
831 */ | |
832 int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7712
diff
changeset
|
833 ruby_enabled(int verbose) |
7 | 834 { |
7528
53163e4d9e4f
commit https://github.com/vim/vim/commit/25e4fcde767084d1a79e0926bc301c92987c0cce
Christian Brabandt <cb@256bit.org>
parents:
7364
diff
changeset
|
835 return ruby_runtime_link_init((char *)p_rubydll, verbose) == OK; |
7 | 836 } |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
837 #endif // defined(DYNAMIC_RUBY) || defined(PROTO) |
7 | 838 |
839 void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7712
diff
changeset
|
840 ruby_end(void) |
7 | 841 { |
842 } | |
843 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
844 void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
845 ex_ruby(exarg_T *eap) |
7 | 846 { |
847 int state; | |
848 char *script = NULL; | |
849 | |
750 | 850 script = (char *)script_get(eap, eap->arg); |
7 | 851 if (!eap->skip && ensure_ruby_initialized()) |
852 { | |
853 if (script == NULL) | |
854 rb_eval_string_protect((char *)eap->arg, &state); | |
855 else | |
856 rb_eval_string_protect(script, &state); | |
857 if (state) | |
858 error_print(state); | |
859 } | |
860 vim_free(script); | |
861 } | |
862 | |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
863 /* |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
864 * In Ruby 1.9 or later, ruby String object has encoding. |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
865 * conversion buffer string of vim to ruby String object using |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
866 * VIM encoding option. |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
867 */ |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
868 static VALUE |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
869 vim_str2rb_enc_str(const char *s) |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
870 { |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
871 #if RUBY_VERSION >= 19 |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
872 long lval; |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
873 char_u *sval; |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
874 rb_encoding *enc; |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
875 |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23384
diff
changeset
|
876 if (get_option_value((char_u *)"enc", &lval, &sval, 0) == gov_string) |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
877 { |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
878 enc = rb_enc_find((char *)sval); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
879 vim_free(sval); |
8802
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
880 if (enc) |
9159
6b003ff07234
commit https://github.com/vim/vim/commit/9b0ac229bcfc91acabd35fc576055a94c1687c32
Christian Brabandt <cb@256bit.org>
parents:
8802
diff
changeset
|
881 return rb_enc_str_new(s, (long)strlen(s), enc); |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
882 } |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
883 #endif |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
884 return rb_str_new2(s); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
885 } |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
886 |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
887 static VALUE |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
888 eval_enc_string_protect(const char *str, int *state) |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
889 { |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
890 #if RUBY_VERSION >= 19 |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
891 long lval; |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
892 char_u *sval; |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
893 rb_encoding *enc; |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
894 VALUE v; |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
895 |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23384
diff
changeset
|
896 if (get_option_value((char_u *)"enc", &lval, &sval, 0) == gov_string) |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
897 { |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
898 enc = rb_enc_find((char *)sval); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
899 vim_free(sval); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
900 if (enc) |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
901 { |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
902 v = rb_sprintf("#-*- coding:%s -*-\n%s", rb_enc_name(enc), str); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
903 return rb_eval_string_protect(StringValuePtr(v), state); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
904 } |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
905 } |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
906 #endif |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
907 return rb_eval_string_protect(str, state); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
908 } |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
909 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
910 void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
911 ex_rubydo(exarg_T *eap) |
7 | 912 { |
913 int state; | |
914 linenr_T i; | |
10761
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
10603
diff
changeset
|
915 buf_T *was_curbuf = curbuf; |
7 | 916 |
917 if (ensure_ruby_initialized()) | |
918 { | |
919 if (u_save(eap->line1 - 1, eap->line2 + 1) != OK) | |
920 return; | |
8802
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
921 for (i = eap->line1; i <= eap->line2; i++) |
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
922 { |
2656 | 923 VALUE line; |
7 | 924 |
10761
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
10603
diff
changeset
|
925 if (i > curbuf->b_ml.ml_line_count) |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
10603
diff
changeset
|
926 break; |
2656 | 927 line = vim_str2rb_enc_str((char *)ml_get(i)); |
7 | 928 rb_lastline_set(line); |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
929 eval_enc_string_protect((char *) eap->arg, &state); |
8802
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
930 if (state) |
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
931 { |
7 | 932 error_print(state); |
933 break; | |
934 } | |
10761
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
10603
diff
changeset
|
935 if (was_curbuf != curbuf) |
721af7a9b4b4
patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
10603
diff
changeset
|
936 break; |
7 | 937 line = rb_lastline_get(); |
8802
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
938 if (!NIL_P(line)) |
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
939 { |
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
940 if (TYPE(line) != T_STRING) |
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
941 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
942 emsg(_("E265: $_ must be an instance of String")); |
7 | 943 return; |
944 } | |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
945 ml_replace(i, (char_u *) StringValuePtr(line), 1); |
7 | 946 changed(); |
947 #ifdef SYNTAX_HL | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
948 syn_changed(i); // recompute syntax hl. for this line |
7 | 949 #endif |
950 } | |
951 } | |
952 check_cursor(); | |
953 update_curbuf(NOT_VALID); | |
954 } | |
955 } | |
956 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
957 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
958 rb_load_wrap(VALUE file_to_load) |
13148
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
959 { |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
960 rb_load(file_to_load, 0); |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
961 return Qnil; |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
962 } |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
963 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
964 void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
965 ex_rubyfile(exarg_T *eap) |
7 | 966 { |
967 int state; | |
968 | |
969 if (ensure_ruby_initialized()) | |
970 { | |
13148
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
971 VALUE file_to_load = rb_str_new2((const char *)eap->arg); |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
972 rb_protect(rb_load_wrap, file_to_load, &state); |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
973 if (state) |
f06a0a75d5b1
patch 8.0.1448: segfault with exception inside :rubyfile command
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
974 error_print(state); |
7 | 975 } |
976 } | |
977 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
978 void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
979 ruby_buffer_free(buf_T *buf) |
7 | 980 { |
502 | 981 if (buf->b_ruby_ref) |
982 { | |
983 rb_hash_aset(objtbl, rb_obj_id((VALUE) buf->b_ruby_ref), Qnil); | |
984 RDATA(buf->b_ruby_ref)->data = NULL; | |
7 | 985 } |
986 } | |
987 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
988 void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
989 ruby_window_free(win_T *win) |
7 | 990 { |
502 | 991 if (win->w_ruby_ref) |
992 { | |
993 rb_hash_aset(objtbl, rb_obj_id((VALUE) win->w_ruby_ref), Qnil); | |
994 RDATA(win->w_ruby_ref)->data = NULL; | |
7 | 995 } |
996 } | |
997 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
998 static int |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
999 ensure_ruby_initialized(void) |
7 | 1000 { |
1001 if (!ruby_initialized) | |
1002 { | |
1003 #ifdef DYNAMIC_RUBY | |
1004 if (ruby_enabled(TRUE)) | |
1005 { | |
1006 #endif | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15727
diff
changeset
|
1007 #ifdef MSWIN |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1008 // suggested by Ariya Mizutani |
2076
1c7a66d820e4
updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents:
1888
diff
changeset
|
1009 int argc = 1; |
1c7a66d820e4
updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents:
1888
diff
changeset
|
1010 char *argv[] = {"gvim.exe"}; |
6406 | 1011 char **argvp = argv; |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1012 # if RUBY_VERSION >= 19 |
10595
dbaad101b1e1
patch 8.0.0187: cant build with new Ruby version
Christian Brabandt <cb@256bit.org>
parents:
10546
diff
changeset
|
1013 ruby_sysinit(&argc, &argvp); |
dbaad101b1e1
patch 8.0.0187: cant build with new Ruby version
Christian Brabandt <cb@256bit.org>
parents:
10546
diff
changeset
|
1014 # else |
6406 | 1015 NtInitialize(&argc, &argvp); |
10595
dbaad101b1e1
patch 8.0.0187: cant build with new Ruby version
Christian Brabandt <cb@256bit.org>
parents:
10546
diff
changeset
|
1016 # endif |
2076
1c7a66d820e4
updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents:
1888
diff
changeset
|
1017 #endif |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2274
diff
changeset
|
1018 { |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1019 #if (RUBY_VERSION >= 19) || defined(RUBY_INIT_STACK) |
4369 | 1020 ruby_init_stack(ruby_stack_start); |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1021 #endif |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2274
diff
changeset
|
1022 ruby_init(); |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2274
diff
changeset
|
1023 } |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1024 #if RUBY_VERSION >= 19 |
2669 | 1025 { |
1026 int dummy_argc = 2; | |
12553
270aec277c81
patch 8.0.1155: Ruby command triggers a warning
Christian Brabandt <cb@256bit.org>
parents:
12517
diff
changeset
|
1027 char *dummy_argv[] = {"vim-ruby", "-e_=0"}; |
7237
2a95fa0a07b5
commit https://github.com/vim/vim/commit/9b1067e038d371bd6c51e5da025383761f4921b4
Christian Brabandt <cb@256bit.org>
parents:
7196
diff
changeset
|
1028 ruby_options(dummy_argc, dummy_argv); |
2669 | 1029 } |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1030 ruby_script("vim-ruby"); |
2669 | 1031 #else |
1032 ruby_init_loadpath(); | |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1033 #endif |
7 | 1034 ruby_io_init(); |
1035 ruby_vim_init(); | |
1036 ruby_initialized = 1; | |
1037 #ifdef DYNAMIC_RUBY | |
1038 } | |
1039 else | |
1040 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
1041 emsg(_("E266: Sorry, this command is disabled, the Ruby library could not be loaded.")); |
7 | 1042 return 0; |
1043 } | |
1044 #endif | |
1045 } | |
1046 return ruby_initialized; | |
1047 } | |
1048 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1049 static void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1050 error_print(int state) |
7 | 1051 { |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1052 #if !defined(DYNAMIC_RUBY) && (RUBY_VERSION <= 18) |
7 | 1053 RUBYEXTERN VALUE ruby_errinfo; |
1054 #endif | |
14437
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
1055 VALUE error; |
7 | 1056 VALUE eclass; |
1057 VALUE einfo; | |
14437
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
1058 VALUE bt; |
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
1059 int attr; |
7 | 1060 char buff[BUFSIZ]; |
14437
ceb9b6bf0f4a
patch 8.1.0232: Ruby error does not include backtrace
Christian Brabandt <cb@256bit.org>
parents:
14411
diff
changeset
|
1061 long i; |
7 | 1062 |
1063 #define TAG_RETURN 0x1 | |
1064 #define TAG_BREAK 0x2 | |
1065 #define TAG_NEXT 0x3 | |
1066 #define TAG_RETRY 0x4 | |
1067 #define TAG_REDO 0x5 | |
1068 #define TAG_RAISE 0x6 | |
1069 #define TAG_THROW 0x7 | |
1070 #define TAG_FATAL 0x8 | |
1071 #define TAG_MASK 0xf | |
1072 | |
8802
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1073 switch (state) |
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1074 { |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1075 case TAG_RETURN: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1076 emsg(_("E267: unexpected return")); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1077 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1078 case TAG_NEXT: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1079 emsg(_("E268: unexpected next")); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1080 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1081 case TAG_BREAK: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1082 emsg(_("E269: unexpected break")); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1083 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1084 case TAG_REDO: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1085 emsg(_("E270: unexpected redo")); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1086 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1087 case TAG_RETRY: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1088 emsg(_("E271: retry outside of rescue clause")); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1089 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1090 case TAG_RAISE: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1091 case TAG_FATAL: |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1092 #if RUBY_VERSION >= 19 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1093 error = rb_errinfo(); |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1094 #else |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1095 error = ruby_errinfo; |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1096 #endif |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1097 eclass = CLASS_OF(error); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1098 einfo = rb_obj_as_string(error); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1099 if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1100 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1101 emsg(_("E272: unhandled exception")); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1102 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1103 else |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1104 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1105 VALUE epath; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1106 char *p; |
7 | 1107 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1108 epath = rb_class_path(eclass); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1109 vim_snprintf(buff, BUFSIZ, "%s: %s", |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1110 RSTRING_PTR(epath), RSTRING_PTR(einfo)); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1111 p = strchr(buff, '\n'); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1112 if (p) *p = '\0'; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1113 emsg(buff); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1114 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1115 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1116 attr = syn_name2attr((char_u *)"Error"); |
19376
1cae476a7c82
patch 8.2.0246: MSVC: deprecation warnings with Ruby
Bram Moolenaar <Bram@vim.org>
parents:
19102
diff
changeset
|
1117 #if RUBY_VERSION >= 21 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1118 bt = rb_funcallv(error, rb_intern("backtrace"), 0, 0); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1119 for (i = 0; i < RARRAY_LEN(bt); i++) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1120 msg_attr(RSTRING_PTR(RARRAY_AREF(bt, i)), attr); |
19376
1cae476a7c82
patch 8.2.0246: MSVC: deprecation warnings with Ruby
Bram Moolenaar <Bram@vim.org>
parents:
19102
diff
changeset
|
1121 #else |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1122 bt = rb_funcall2(error, rb_intern("backtrace"), 0, 0); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1123 for (i = 0; i < RARRAY_LEN(bt); i++) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1124 msg_attr(RSTRING_PTR(RARRAY_PTR(bt)[i]), attr); |
19376
1cae476a7c82
patch 8.2.0246: MSVC: deprecation warnings with Ruby
Bram Moolenaar <Bram@vim.org>
parents:
19102
diff
changeset
|
1125 #endif |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1126 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1127 default: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1128 vim_snprintf(buff, BUFSIZ, _("E273: unknown longjmp status %d"), state); |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
1129 emsg(buff); |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1130 break; |
7 | 1131 } |
1132 } | |
1133 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1134 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1135 vim_message(VALUE self UNUSED, VALUE str) |
7 | 1136 { |
1137 char *buff, *p; | |
1138 | |
1139 str = rb_obj_as_string(str); | |
2990 | 1140 if (RSTRING_LEN(str) > 0) |
1141 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1142 // Only do this when the string isn't empty, alloc(0) causes trouble. |
12335
df498e3e34fc
patch 8.0.1047: buffer overflow in Ruby
Christian Brabandt <cb@256bit.org>
parents:
10761
diff
changeset
|
1143 buff = ALLOCA_N(char, RSTRING_LEN(str) + 1); |
2990 | 1144 strcpy(buff, RSTRING_PTR(str)); |
1145 p = strchr(buff, '\n'); | |
1146 if (p) *p = '\0'; | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1147 msg(buff); |
2990 | 1148 } |
1149 else | |
1150 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1151 msg(""); |
2990 | 1152 } |
7 | 1153 return Qnil; |
1154 } | |
1155 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1156 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1157 vim_set_option(VALUE self UNUSED, VALUE str) |
7 | 1158 { |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1159 do_set((char_u *)StringValuePtr(str), 0); |
7 | 1160 update_screen(NOT_VALID); |
1161 return Qnil; | |
1162 } | |
1163 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1164 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1165 vim_command(VALUE self UNUSED, VALUE str) |
7 | 1166 { |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1167 do_cmdline_cmd((char_u *)StringValuePtr(str)); |
7 | 1168 return Qnil; |
1169 } | |
1170 | |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1171 #ifdef FEAT_EVAL |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1172 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1173 vim_to_ruby(typval_T *tv) |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1174 { |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1175 VALUE result = Qnil; |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1176 |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1177 if (tv->v_type == VAR_STRING) |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1178 { |
2121
20d9fc2f13a4
updated for version 7.2.403
Bram Moolenaar <bram@zimbu.org>
parents:
2117
diff
changeset
|
1179 result = rb_str_new2(tv->vval.v_string == NULL |
20d9fc2f13a4
updated for version 7.2.403
Bram Moolenaar <bram@zimbu.org>
parents:
2117
diff
changeset
|
1180 ? "" : (char *)(tv->vval.v_string)); |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1181 } |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1182 else if (tv->v_type == VAR_NUMBER) |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1183 { |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1184 result = INT2NUM(tv->vval.v_number); |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1185 } |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1186 # ifdef FEAT_FLOAT |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1187 else if (tv->v_type == VAR_FLOAT) |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1188 { |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1189 result = rb_float_new(tv->vval.v_float); |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1190 } |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1191 # endif |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1192 else if (tv->v_type == VAR_LIST) |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1193 { |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1194 list_T *list = tv->vval.v_list; |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1195 listitem_T *curr; |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1196 |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1197 result = rb_ary_new(); |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1198 |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1199 if (list != NULL) |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1200 { |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19846
diff
changeset
|
1201 FOR_ALL_LIST_ITEMS(list, curr) |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1202 rb_ary_push(result, vim_to_ruby(&curr->li_tv)); |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1203 } |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1204 } |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1205 else if (tv->v_type == VAR_DICT) |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1206 { |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1207 result = rb_hash_new(); |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1208 |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1209 if (tv->vval.v_dict != NULL) |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1210 { |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1211 hashtab_T *ht = &tv->vval.v_dict->dv_hashtab; |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1212 long_u todo = ht->ht_used; |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1213 hashitem_T *hi; |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1214 dictitem_T *di; |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1215 |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1216 for (hi = ht->ht_array; todo > 0; ++hi) |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1217 { |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1218 if (!HASHITEM_EMPTY(hi)) |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1219 { |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1220 --todo; |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1221 |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1222 di = dict_lookup(hi); |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1223 rb_hash_aset(result, rb_str_new2((char *)hi->hi_key), |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1224 vim_to_ruby(&di->di_tv)); |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1225 } |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1226 } |
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1227 } |
7712
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7668
diff
changeset
|
1228 } |
19102
ba9f50bfda83
patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents:
19079
diff
changeset
|
1229 else if (tv->v_type == VAR_BOOL || tv->v_type == VAR_SPECIAL) |
7712
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7668
diff
changeset
|
1230 { |
14411
504091aca571
patch 8.1.0220: Ruby converts v:true and v:false to a number
Christian Brabandt <cb@256bit.org>
parents:
14395
diff
changeset
|
1231 if (tv->vval.v_number == VVAL_TRUE) |
504091aca571
patch 8.1.0220: Ruby converts v:true and v:false to a number
Christian Brabandt <cb@256bit.org>
parents:
14395
diff
changeset
|
1232 result = Qtrue; |
504091aca571
patch 8.1.0220: Ruby converts v:true and v:false to a number
Christian Brabandt <cb@256bit.org>
parents:
14395
diff
changeset
|
1233 else if (tv->vval.v_number == VVAL_FALSE) |
504091aca571
patch 8.1.0220: Ruby converts v:true and v:false to a number
Christian Brabandt <cb@256bit.org>
parents:
14395
diff
changeset
|
1234 result = Qfalse; |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1235 } |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1236 else if (tv->v_type == VAR_BLOB) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1237 { |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1238 result = rb_str_new(tv->vval.v_blob->bv_ga.ga_data, |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1239 tv->vval.v_blob->bv_ga.ga_len); |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1240 } |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1241 // else return Qnil; |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1242 |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1243 return result; |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1244 } |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1245 #endif |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1246 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1247 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1248 vim_evaluate(VALUE self UNUSED, VALUE str) |
7 | 1249 { |
1250 #ifdef FEAT_EVAL | |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1251 typval_T *tv; |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1252 VALUE result; |
7 | 1253 |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1254 tv = eval_expr((char_u *)StringValuePtr(str), NULL); |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1255 if (tv == NULL) |
2117
4be6da0fa3d9
updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents:
2104
diff
changeset
|
1256 return Qnil; |
2090
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1257 result = vim_to_ruby(tv); |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1258 |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1259 free_tv(tv); |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1260 |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1261 return result; |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1262 #else |
53d475dff0e3
updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents:
2084
diff
changeset
|
1263 return Qnil; |
7 | 1264 #endif |
1265 } | |
1266 | |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1267 #ifdef USE_TYPEDDATA |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1268 static size_t buffer_dsize(const void *buf); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1269 |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1270 static const rb_data_type_t buffer_type = { |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1271 "vim_buffer", |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1272 {0, 0, buffer_dsize, |
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1273 # if RUBY_VERSION >= 27 |
19479
bc6c7be92527
patch 8.2.0297: compiler warnings for the Ruby interface
Bram Moolenaar <Bram@vim.org>
parents:
19376
diff
changeset
|
1274 0, {0} |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1275 # else |
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1276 {0, 0} |
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1277 # endif |
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1278 }, |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1279 0, 0, |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1280 # ifdef RUBY_TYPED_FREE_IMMEDIATELY |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1281 0, |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1282 # endif |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1283 }; |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1284 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1285 static size_t |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1286 buffer_dsize(const void *buf UNUSED) |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1287 { |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1288 return sizeof(buf_T); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1289 } |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1290 #endif |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1291 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1292 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1293 buffer_new(buf_T *buf) |
7 | 1294 { |
502 | 1295 if (buf->b_ruby_ref) |
1296 { | |
1297 return (VALUE) buf->b_ruby_ref; | |
7 | 1298 } |
502 | 1299 else |
1300 { | |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1301 #ifdef USE_TYPEDDATA |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1302 VALUE obj = TypedData_Wrap_Struct(cBuffer, &buffer_type, buf); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1303 #else |
7 | 1304 VALUE obj = Data_Wrap_Struct(cBuffer, 0, 0, buf); |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1305 #endif |
502 | 1306 buf->b_ruby_ref = (void *) obj; |
7 | 1307 rb_hash_aset(objtbl, rb_obj_id(obj), obj); |
1308 return obj; | |
1309 } | |
1310 } | |
1311 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1312 static buf_T * |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1313 get_buf(VALUE obj) |
7 | 1314 { |
1315 buf_T *buf; | |
1316 | |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1317 #ifdef USE_TYPEDDATA |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1318 TypedData_Get_Struct(obj, buf_T, &buffer_type, buf); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1319 #else |
7 | 1320 Data_Get_Struct(obj, buf_T, buf); |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1321 #endif |
7 | 1322 if (buf == NULL) |
1323 rb_raise(eDeletedBufferError, "attempt to refer to deleted buffer"); | |
1324 return buf; | |
1325 } | |
1326 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1327 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1328 vim_blob(VALUE self UNUSED, VALUE str) |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1329 { |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1330 VALUE result = rb_str_new("0z", 2); |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1331 char buf[4]; |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1332 int i; |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1333 for (i = 0; i < RSTRING_LEN(str); i++) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1334 { |
15943
e5f82e8b3c06
patch 8.1.0977: blob not tested with Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15882
diff
changeset
|
1335 sprintf(buf, "%02X", (unsigned char)(RSTRING_PTR(str)[i])); |
15681
ef9c89680e7f
patch 8.1.0848: cannot build with Ruby 1.8
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1336 rb_str_concat(result, rb_str_new2(buf)); |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1337 } |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1338 return result; |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1339 } |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1340 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1341 static VALUE |
23116
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1342 buffer_s_current(VALUE self UNUSED) |
7 | 1343 { |
1344 return buffer_new(curbuf); | |
1345 } | |
1346 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1347 static VALUE |
23116
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1348 buffer_s_current_getter(ID id UNUSED, VALUE *x UNUSED) |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1349 { |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1350 return buffer_new(curbuf); |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1351 } |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1352 |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1353 static VALUE |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1354 buffer_s_count(VALUE self UNUSED) |
7 | 1355 { |
1356 buf_T *b; | |
1357 int n = 0; | |
1358 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9293
diff
changeset
|
1359 FOR_ALL_BUFFERS(b) |
779 | 1360 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1361 // Deleted buffers should not be counted |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1362 // SegPhault - 01/07/05 |
856 | 1363 if (b->b_p_bl) |
779 | 1364 n++; |
1365 } | |
1366 | |
7 | 1367 return INT2NUM(n); |
1368 } | |
1369 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1370 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1371 buffer_s_aref(VALUE self UNUSED, VALUE num) |
7 | 1372 { |
1373 buf_T *b; | |
1374 int n = NUM2INT(num); | |
1375 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9293
diff
changeset
|
1376 FOR_ALL_BUFFERS(b) |
779 | 1377 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1378 // Deleted buffers should not be counted |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1379 // SegPhault - 01/07/05 |
856 | 1380 if (!b->b_p_bl) |
779 | 1381 continue; |
1382 | |
856 | 1383 if (n == 0) |
7 | 1384 return buffer_new(b); |
779 | 1385 |
856 | 1386 n--; |
7 | 1387 } |
1388 return Qnil; | |
1389 } | |
1390 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1391 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1392 buffer_name(VALUE self) |
7 | 1393 { |
1394 buf_T *buf = get_buf(self); | |
1395 | |
750 | 1396 return buf->b_ffname ? rb_str_new2((char *)buf->b_ffname) : Qnil; |
7 | 1397 } |
1398 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1399 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1400 buffer_number(VALUE self) |
7 | 1401 { |
1402 buf_T *buf = get_buf(self); | |
1403 | |
1404 return INT2NUM(buf->b_fnum); | |
1405 } | |
1406 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1407 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1408 buffer_count(VALUE self) |
7 | 1409 { |
1410 buf_T *buf = get_buf(self); | |
1411 | |
1412 return INT2NUM(buf->b_ml.ml_line_count); | |
1413 } | |
1414 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1415 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1416 get_buffer_line(buf_T *buf, linenr_T n) |
7 | 1417 { |
2637 | 1418 if (n <= 0 || n > buf->b_ml.ml_line_count) |
1419 rb_raise(rb_eIndexError, "line number %ld out of range", (long)n); | |
1420 return vim_str2rb_enc_str((char *)ml_get_buf(buf, n, FALSE)); | |
7 | 1421 } |
1422 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1423 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1424 buffer_aref(VALUE self, VALUE num) |
7 | 1425 { |
1426 buf_T *buf = get_buf(self); | |
779 | 1427 |
1428 if (buf != NULL) | |
1429 return get_buffer_line(buf, (linenr_T)NUM2LONG(num)); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1430 return Qnil; // For stop warning |
779 | 1431 } |
1432 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1433 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1434 set_buffer_line(buf_T *buf, linenr_T n, VALUE str) |
779 | 1435 { |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1436 char *line = StringValuePtr(str); |
896 | 1437 aco_save_T aco; |
7 | 1438 |
896 | 1439 if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL) |
1440 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1441 // set curwin/curbuf for "buf" and save some things |
896 | 1442 aucmd_prepbuf(&aco, buf); |
1443 | |
8802
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1444 if (u_savesub(n) == OK) |
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1445 { |
779 | 1446 ml_replace(n, (char_u *)line, TRUE); |
7 | 1447 changed(); |
1448 #ifdef SYNTAX_HL | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1449 syn_changed(n); // recompute syntax hl. for this line |
7 | 1450 #endif |
1451 } | |
896 | 1452 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1453 // restore curwin/curbuf and a few other things |
896 | 1454 aucmd_restbuf(&aco); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1455 // Careful: autocommands may have made "buf" invalid! |
934 | 1456 |
7 | 1457 update_curbuf(NOT_VALID); |
1458 } | |
896 | 1459 else |
1460 { | |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1461 rb_raise(rb_eIndexError, "line number %ld out of range", (long)n); |
7 | 1462 } |
1463 return str; | |
1464 } | |
1465 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1466 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1467 buffer_aset(VALUE self, VALUE num, VALUE str) |
779 | 1468 { |
1469 buf_T *buf = get_buf(self); | |
1470 | |
1471 if (buf != NULL) | |
1472 return set_buffer_line(buf, (linenr_T)NUM2LONG(num), str); | |
1473 return str; | |
1474 } | |
1475 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1476 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1477 buffer_delete(VALUE self, VALUE num) |
7 | 1478 { |
896 | 1479 buf_T *buf = get_buf(self); |
1480 long n = NUM2LONG(num); | |
1481 aco_save_T aco; | |
7 | 1482 |
896 | 1483 if (n > 0 && n <= buf->b_ml.ml_line_count) |
1484 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1485 // set curwin/curbuf for "buf" and save some things |
896 | 1486 aucmd_prepbuf(&aco, buf); |
1487 | |
8802
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1488 if (u_savedel(n, 1) == OK) |
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1489 { |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20548
diff
changeset
|
1490 ml_delete(n); |
779 | 1491 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1492 // Changes to non-active buffers should properly refresh |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1493 // SegPhault - 01/09/05 |
856 | 1494 deleted_lines_mark(n, 1L); |
779 | 1495 |
7 | 1496 changed(); |
1497 } | |
896 | 1498 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1499 // restore curwin/curbuf and a few other things |
896 | 1500 aucmd_restbuf(&aco); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1501 // Careful: autocommands may have made "buf" invalid! |
934 | 1502 |
7 | 1503 update_curbuf(NOT_VALID); |
1504 } | |
896 | 1505 else |
1506 { | |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1507 rb_raise(rb_eIndexError, "line number %ld out of range", n); |
7 | 1508 } |
1509 return Qnil; | |
1510 } | |
1511 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1512 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1513 buffer_append(VALUE self, VALUE num, VALUE str) |
7 | 1514 { |
896 | 1515 buf_T *buf = get_buf(self); |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1516 char *line = StringValuePtr(str); |
896 | 1517 long n = NUM2LONG(num); |
1518 aco_save_T aco; | |
7 | 1519 |
2637 | 1520 if (line == NULL) |
1521 { | |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1522 rb_raise(rb_eIndexError, "NULL line"); |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1523 } |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1524 else if (n >= 0 && n <= buf->b_ml.ml_line_count) |
896 | 1525 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1526 // set curwin/curbuf for "buf" and save some things |
896 | 1527 aucmd_prepbuf(&aco, buf); |
1528 | |
8802
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1529 if (u_inssub(n + 1) == OK) |
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1530 { |
7 | 1531 ml_append(n, (char_u *) line, (colnr_T) 0, FALSE); |
779 | 1532 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1533 // Changes to non-active buffers should properly refresh screen |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1534 // SegPhault - 12/20/04 |
856 | 1535 appended_lines_mark(n, 1L); |
779 | 1536 |
856 | 1537 changed(); |
7 | 1538 } |
896 | 1539 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1540 // restore curwin/curbuf and a few other things |
896 | 1541 aucmd_restbuf(&aco); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1542 // Careful: autocommands may have made "buf" invalid! |
934 | 1543 |
7 | 1544 update_curbuf(NOT_VALID); |
1545 } | |
2637 | 1546 else |
1547 { | |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1548 rb_raise(rb_eIndexError, "line number %ld out of range", n); |
7 | 1549 } |
1550 return str; | |
1551 } | |
1552 | |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1553 #ifdef USE_TYPEDDATA |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1554 static size_t window_dsize(const void *buf); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1555 |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1556 static const rb_data_type_t window_type = { |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1557 "vim_window", |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1558 {0, 0, window_dsize, |
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1559 # if RUBY_VERSION >= 27 |
19479
bc6c7be92527
patch 8.2.0297: compiler warnings for the Ruby interface
Bram Moolenaar <Bram@vim.org>
parents:
19376
diff
changeset
|
1560 0, {0} |
19079
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1561 # else |
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1562 {0, 0} |
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1563 # endif |
23df4b83fd31
patch 8.2.0100: macros for Ruby are too complicated
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
1564 }, |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1565 0, 0, |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1566 # ifdef RUBY_TYPED_FREE_IMMEDIATELY |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1567 0, |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1568 # endif |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1569 }; |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1570 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1571 static size_t |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1572 window_dsize(const void *win UNUSED) |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1573 { |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1574 return sizeof(win_T); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1575 } |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1576 #endif |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1577 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1578 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1579 window_new(win_T *win) |
7 | 1580 { |
502 | 1581 if (win->w_ruby_ref) |
1582 { | |
1583 return (VALUE) win->w_ruby_ref; | |
7 | 1584 } |
502 | 1585 else |
1586 { | |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1587 #ifdef USE_TYPEDDATA |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1588 VALUE obj = TypedData_Wrap_Struct(cVimWindow, &window_type, win); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1589 #else |
7 | 1590 VALUE obj = Data_Wrap_Struct(cVimWindow, 0, 0, win); |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1591 #endif |
502 | 1592 win->w_ruby_ref = (void *) obj; |
7 | 1593 rb_hash_aset(objtbl, rb_obj_id(obj), obj); |
1594 return obj; | |
1595 } | |
1596 } | |
1597 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1598 static win_T * |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1599 get_win(VALUE obj) |
7 | 1600 { |
1601 win_T *win; | |
1602 | |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1603 #ifdef USE_TYPEDDATA |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1604 TypedData_Get_Struct(obj, win_T, &window_type, win); |
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1605 #else |
7 | 1606 Data_Get_Struct(obj, win_T, win); |
7360
b20095ba6fc2
commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents:
7237
diff
changeset
|
1607 #endif |
7 | 1608 if (win == NULL) |
1609 rb_raise(eDeletedWindowError, "attempt to refer to deleted window"); | |
1610 return win; | |
1611 } | |
1612 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1613 static VALUE |
23116
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1614 window_s_current(VALUE self UNUSED) |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1615 { |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1616 return window_new(curwin); |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1617 } |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1618 |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1619 static VALUE |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1620 window_s_current_getter(ID id UNUSED, VALUE *x UNUSED) |
7 | 1621 { |
1622 return window_new(curwin); | |
1623 } | |
1624 | |
779 | 1625 /* |
1626 * Added line manipulation functions | |
1627 * SegPhault - 03/07/05 | |
1628 */ | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1629 static VALUE |
23116
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1630 line_s_current(VALUE self UNUSED) |
779 | 1631 { |
1632 return get_buffer_line(curbuf, curwin->w_cursor.lnum); | |
1633 } | |
1634 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1635 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1636 set_current_line(VALUE self UNUSED, VALUE str) |
779 | 1637 { |
1638 return set_buffer_line(curbuf, curwin->w_cursor.lnum, str); | |
1639 } | |
1640 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1641 static VALUE |
23116
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1642 current_line_number(VALUE self UNUSED) |
779 | 1643 { |
1644 return INT2FIX((int)curwin->w_cursor.lnum); | |
1645 } | |
1646 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1647 static VALUE |
23116
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1648 window_s_count(VALUE self UNUSED) |
7 | 1649 { |
1650 win_T *w; | |
1651 int n = 0; | |
1652 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9293
diff
changeset
|
1653 FOR_ALL_WINDOWS(w) |
7 | 1654 n++; |
1655 return INT2NUM(n); | |
1656 } | |
1657 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1658 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1659 window_s_aref(VALUE self UNUSED, VALUE num) |
7 | 1660 { |
1661 win_T *w; | |
1662 int n = NUM2INT(num); | |
1663 | |
1664 for (w = firstwin; w != NULL; w = w->w_next, --n) | |
1665 if (n == 0) | |
1666 return window_new(w); | |
1667 return Qnil; | |
1668 } | |
1669 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1670 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1671 window_buffer(VALUE self) |
7 | 1672 { |
1673 win_T *win = get_win(self); | |
1674 | |
1675 return buffer_new(win->w_buffer); | |
1676 } | |
1677 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1678 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1679 window_height(VALUE self) |
7 | 1680 { |
1681 win_T *win = get_win(self); | |
1682 | |
1683 return INT2NUM(win->w_height); | |
1684 } | |
1685 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1686 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1687 window_set_height(VALUE self, VALUE height) |
7 | 1688 { |
1689 win_T *win = get_win(self); | |
1690 win_T *savewin = curwin; | |
1691 | |
1692 curwin = win; | |
1693 win_setheight(NUM2INT(height)); | |
1694 curwin = savewin; | |
1695 return height; | |
1696 } | |
1697 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1698 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1699 window_width(VALUE self UNUSED) |
501 | 1700 { |
12517
1b65cbe1578d
patch 8.0.1137: cannot build with Ruby
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
1701 return INT2NUM(get_win(self)->w_width); |
501 | 1702 } |
1703 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1704 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1705 window_set_width(VALUE self UNUSED, VALUE width) |
501 | 1706 { |
1707 win_T *win = get_win(self); | |
1708 win_T *savewin = curwin; | |
1709 | |
1710 curwin = win; | |
1711 win_setwidth(NUM2INT(width)); | |
1712 curwin = savewin; | |
1713 return width; | |
1714 } | |
1715 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1716 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1717 window_cursor(VALUE self) |
7 | 1718 { |
1719 win_T *win = get_win(self); | |
1720 | |
1721 return rb_assoc_new(INT2NUM(win->w_cursor.lnum), INT2NUM(win->w_cursor.col)); | |
1722 } | |
1723 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1724 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1725 window_set_cursor(VALUE self, VALUE pos) |
7 | 1726 { |
1727 VALUE lnum, col; | |
1728 win_T *win = get_win(self); | |
1729 | |
1730 Check_Type(pos, T_ARRAY); | |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1731 if (RARRAY_LEN(pos) != 2) |
7 | 1732 rb_raise(rb_eArgError, "array length must be 2"); |
2077
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1733 lnum = RARRAY_PTR(pos)[0]; |
d8983769c9dd
updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents:
2076
diff
changeset
|
1734 col = RARRAY_PTR(pos)[1]; |
7 | 1735 win->w_cursor.lnum = NUM2LONG(lnum); |
1736 win->w_cursor.col = NUM2UINT(col); | |
14395
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
14389
diff
changeset
|
1737 win->w_set_curswant = TRUE; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1738 check_cursor(); // put cursor on an existing line |
7 | 1739 update_screen(NOT_VALID); |
1740 return Qnil; | |
1741 } | |
1742 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1743 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1744 f_nop(VALUE self UNUSED) |
3474 | 1745 { |
1746 return Qnil; | |
1747 } | |
1748 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1749 static VALUE |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1750 f_p(int argc, VALUE *argv, VALUE self UNUSED) |
7 | 1751 { |
1752 int i; | |
1753 VALUE str = rb_str_new("", 0); | |
14511
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
1754 VALUE ret = Qnil; |
7 | 1755 |
8802
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1756 for (i = 0; i < argc; i++) |
eaf11fa2fec8
commit https://github.com/vim/vim/commit/758535a1df4c5e86b45dddf12db2a54dea28ca40
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1757 { |
7 | 1758 if (i > 0) rb_str_cat(str, ", ", 2); |
1759 rb_str_concat(str, rb_inspect(argv[i])); | |
1760 } | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1761 msg(RSTRING_PTR(str)); |
14511
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
1762 |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
1763 if (argc == 1) |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
1764 ret = argv[0]; |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
1765 else if (argc > 1) |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
1766 ret = rb_ary_new4(argc, argv); |
e6ad77cf13e0
patch 8.1.0269: Ruby Kernel.#p method always returns nil
Christian Brabandt <cb@256bit.org>
parents:
14451
diff
changeset
|
1767 return ret; |
7 | 1768 } |
1769 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1770 static void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1771 ruby_io_init(void) |
7 | 1772 { |
1773 #ifndef DYNAMIC_RUBY | |
1774 RUBYEXTERN VALUE rb_stdout; | |
14389
424ccd85d5c6
patch 8.1.0209: stderr output from Ruby messes up display
Christian Brabandt <cb@256bit.org>
parents:
13958
diff
changeset
|
1775 RUBYEXTERN VALUE rb_stderr; |
7 | 1776 #endif |
1777 | |
1778 rb_stdout = rb_obj_alloc(rb_cObject); | |
14389
424ccd85d5c6
patch 8.1.0209: stderr output from Ruby messes up display
Christian Brabandt <cb@256bit.org>
parents:
13958
diff
changeset
|
1779 rb_stderr = rb_obj_alloc(rb_cObject); |
7 | 1780 rb_define_singleton_method(rb_stdout, "write", vim_message, 1); |
3474 | 1781 rb_define_singleton_method(rb_stdout, "flush", f_nop, 0); |
14389
424ccd85d5c6
patch 8.1.0209: stderr output from Ruby messes up display
Christian Brabandt <cb@256bit.org>
parents:
13958
diff
changeset
|
1782 rb_define_singleton_method(rb_stderr, "write", vim_message, 1); |
424ccd85d5c6
patch 8.1.0209: stderr output from Ruby messes up display
Christian Brabandt <cb@256bit.org>
parents:
13958
diff
changeset
|
1783 rb_define_singleton_method(rb_stderr, "flush", f_nop, 0); |
7 | 1784 rb_define_global_function("p", f_p, -1); |
1785 } | |
1786 | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1787 static void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1788 ruby_vim_init(void) |
7 | 1789 { |
1790 objtbl = rb_hash_new(); | |
1791 rb_global_variable(&objtbl); | |
1792 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1793 // The Vim module used to be called "VIM", but "Vim" is better. Make an |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1794 // alias "VIM" for backwards compatibility. |
1188 | 1795 mVIM = rb_define_module("Vim"); |
1796 rb_define_const(rb_cObject, "VIM", mVIM); | |
7 | 1797 rb_define_const(mVIM, "VERSION_MAJOR", INT2NUM(VIM_VERSION_MAJOR)); |
1798 rb_define_const(mVIM, "VERSION_MINOR", INT2NUM(VIM_VERSION_MINOR)); | |
1799 rb_define_const(mVIM, "VERSION_BUILD", INT2NUM(VIM_VERSION_BUILD)); | |
1800 rb_define_const(mVIM, "VERSION_PATCHLEVEL", INT2NUM(VIM_VERSION_PATCHLEVEL)); | |
1801 rb_define_const(mVIM, "VERSION_SHORT", rb_str_new2(VIM_VERSION_SHORT)); | |
1802 rb_define_const(mVIM, "VERSION_MEDIUM", rb_str_new2(VIM_VERSION_MEDIUM)); | |
1803 rb_define_const(mVIM, "VERSION_LONG", rb_str_new2(VIM_VERSION_LONG)); | |
1804 rb_define_const(mVIM, "VERSION_LONG_DATE", rb_str_new2(VIM_VERSION_LONG_DATE)); | |
1805 rb_define_module_function(mVIM, "message", vim_message, 1); | |
1806 rb_define_module_function(mVIM, "set_option", vim_set_option, 1); | |
1807 rb_define_module_function(mVIM, "command", vim_command, 1); | |
1808 rb_define_module_function(mVIM, "evaluate", vim_evaluate, 1); | |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15392
diff
changeset
|
1809 rb_define_module_function(mVIM, "blob", vim_blob, 1); |
7 | 1810 |
1811 eDeletedBufferError = rb_define_class_under(mVIM, "DeletedBufferError", | |
1812 rb_eStandardError); | |
1813 eDeletedWindowError = rb_define_class_under(mVIM, "DeletedWindowError", | |
1814 rb_eStandardError); | |
1815 | |
1816 cBuffer = rb_define_class_under(mVIM, "Buffer", rb_cObject); | |
1817 rb_define_singleton_method(cBuffer, "current", buffer_s_current, 0); | |
1818 rb_define_singleton_method(cBuffer, "count", buffer_s_count, 0); | |
1819 rb_define_singleton_method(cBuffer, "[]", buffer_s_aref, 1); | |
1820 rb_define_method(cBuffer, "name", buffer_name, 0); | |
1821 rb_define_method(cBuffer, "number", buffer_number, 0); | |
1822 rb_define_method(cBuffer, "count", buffer_count, 0); | |
1823 rb_define_method(cBuffer, "length", buffer_count, 0); | |
1824 rb_define_method(cBuffer, "[]", buffer_aref, 1); | |
1825 rb_define_method(cBuffer, "[]=", buffer_aset, 2); | |
1826 rb_define_method(cBuffer, "delete", buffer_delete, 1); | |
1827 rb_define_method(cBuffer, "append", buffer_append, 2); | |
1828 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1829 // Added line manipulation functions |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1830 // SegPhault - 03/07/05 |
779 | 1831 rb_define_method(cBuffer, "line_number", current_line_number, 0); |
1832 rb_define_method(cBuffer, "line", line_s_current, 0); | |
1833 rb_define_method(cBuffer, "line=", set_current_line, 1); | |
1834 | |
1835 | |
7 | 1836 cVimWindow = rb_define_class_under(mVIM, "Window", rb_cObject); |
1837 rb_define_singleton_method(cVimWindow, "current", window_s_current, 0); | |
1838 rb_define_singleton_method(cVimWindow, "count", window_s_count, 0); | |
1839 rb_define_singleton_method(cVimWindow, "[]", window_s_aref, 1); | |
1840 rb_define_method(cVimWindow, "buffer", window_buffer, 0); | |
1841 rb_define_method(cVimWindow, "height", window_height, 0); | |
1842 rb_define_method(cVimWindow, "height=", window_set_height, 1); | |
501 | 1843 rb_define_method(cVimWindow, "width", window_width, 0); |
1844 rb_define_method(cVimWindow, "width=", window_set_width, 1); | |
7 | 1845 rb_define_method(cVimWindow, "cursor", window_cursor, 0); |
1846 rb_define_method(cVimWindow, "cursor=", window_set_cursor, 1); | |
1847 | |
23116
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1848 rb_define_virtual_variable("$curbuf", buffer_s_current_getter, 0); |
55f8b7da27f3
patch 8.2.2104: build problem with Ruby 2.7
Bram Moolenaar <Bram@vim.org>
parents:
20830
diff
changeset
|
1849 rb_define_virtual_variable("$curwin", window_s_current_getter, 0); |
7 | 1850 } |
4369 | 1851 |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1852 void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1853 vim_ruby_init(void *stack_start) |
4369 | 1854 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16338
diff
changeset
|
1855 // should get machine stack start address early in main function |
4369 | 1856 ruby_stack_start = stack_start; |
1857 } | |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1858 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1859 static int |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1860 convert_hash2dict(VALUE key, VALUE val, VALUE arg) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1861 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1862 dict_T *d = (dict_T *)arg; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1863 dictitem_T *di; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1864 |
23384
f719577ddae6
patch 8.2.2235: build failure with some Ruby versions
Bram Moolenaar <Bram@vim.org>
parents:
23160
diff
changeset
|
1865 di = dictitem_alloc((char_u *)RSTRING_PTR(rb_obj_as_string(key))); |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1866 if (di == NULL || ruby_convert_to_vim_value(val, &di->di_tv) != OK |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1867 || dict_add(d, di) != OK) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1868 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1869 d->dv_hashtab.ht_error = TRUE; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1870 return ST_STOP; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1871 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1872 return ST_CONTINUE; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1873 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1874 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1875 static int |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1876 ruby_convert_to_vim_value(VALUE val, typval_T *rettv) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1877 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1878 switch (TYPE(val)) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1879 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1880 case T_NIL: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1881 rettv->v_type = VAR_SPECIAL; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1882 rettv->vval.v_number = VVAL_NULL; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1883 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1884 case T_TRUE: |
19102
ba9f50bfda83
patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents:
19079
diff
changeset
|
1885 rettv->v_type = VAR_BOOL; |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1886 rettv->vval.v_number = VVAL_TRUE; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1887 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1888 case T_FALSE: |
19102
ba9f50bfda83
patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents:
19079
diff
changeset
|
1889 rettv->v_type = VAR_BOOL; |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1890 rettv->vval.v_number = VVAL_FALSE; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1891 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1892 case T_BIGNUM: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1893 case T_FIXNUM: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1894 rettv->v_type = VAR_NUMBER; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1895 rettv->vval.v_number = (varnumber_T)NUM2LONG(val); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1896 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1897 #ifdef FEAT_FLOAT |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1898 case T_FLOAT: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1899 rettv->v_type = VAR_FLOAT; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1900 rettv->vval.v_float = (float_T)NUM2DBL(val); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1901 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1902 #endif |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1903 default: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1904 val = rb_obj_as_string(val); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1905 // FALLTHROUGH |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1906 case T_STRING: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1907 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1908 VALUE str = (VALUE)RSTRING(val); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1909 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1910 rettv->v_type = VAR_STRING; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1911 rettv->vval.v_string = vim_strnsave((char_u *)RSTRING_PTR(str), |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
1912 RSTRING_LEN(str)); |
16103
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1913 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1914 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1915 case T_ARRAY: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1916 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1917 list_T *l; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1918 long i; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1919 typval_T v; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1920 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1921 l = list_alloc(); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1922 if (l == NULL) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1923 return FAIL; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1924 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1925 for (i = 0; i < RARRAY_LEN(val); ++i) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1926 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1927 if (ruby_convert_to_vim_value((VALUE)RARRAY_PTR(val)[i], |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1928 &v) != OK) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1929 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1930 list_unref(l); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1931 return FAIL; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1932 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1933 list_append_tv(l, &v); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1934 clear_tv(&v); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1935 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1936 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1937 rettv->v_type = VAR_LIST; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1938 rettv->vval.v_list = l; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1939 ++l->lv_refcount; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1940 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1941 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1942 case T_HASH: |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1943 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1944 dict_T *d; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1945 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1946 d = dict_alloc(); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1947 if (d == NULL) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1948 return FAIL; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1949 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1950 rb_hash_foreach(val, convert_hash2dict, (VALUE)d); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1951 if (d->dv_hashtab.ht_error) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1952 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1953 dict_unref(d); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1954 return FAIL; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1955 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1956 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1957 rettv->v_type = VAR_DICT; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1958 rettv->vval.v_dict = d; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1959 ++d->dv_refcount; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1960 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1961 break; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1962 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1963 return OK; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1964 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1965 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1966 void |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1967 do_rubyeval(char_u *str, typval_T *rettv) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1968 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1969 int retval = FAIL; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1970 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1971 if (ensure_ruby_initialized()) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1972 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1973 int state; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1974 VALUE obj; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1975 |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1976 obj = rb_eval_string_protect((const char *)str, &state); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1977 if (state) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1978 error_print(state); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1979 else |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1980 retval = ruby_convert_to_vim_value(obj, rettv); |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1981 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1982 if (retval == FAIL) |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1983 { |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1984 rettv->v_type = VAR_NUMBER; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1985 rettv->vval.v_number = 0; |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1986 } |
518f44125207
patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents:
15943
diff
changeset
|
1987 } |