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