annotate src/if_ruby.c @ 25713:2eddbc3d83b9 v8.2.3392

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