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