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