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