annotate src/if_ruby.c @ 8726:4c5c08316979 v7.4.1652

commit https://github.com/vim/vim/commit/610cc1b9b3c8104382f5506606c1f87118c28114 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 25 17:55:42 2016 +0100 patch 7.4.1652 Problem: Old style test for fnamemodify(). Solution: Turn it into a new style test.
author Christian Brabandt <cb@256bit.org>
date Fri, 25 Mar 2016 18:00:04 +0100
parents 24b43dd167eb
children eaf11fa2fec8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
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
2624
bfd69bfb4149 updated for version 7.3.046
Bram Moolenaar <bram@vim.org>
parents: 2621
diff changeset
14 #ifdef HAVE_CONFIG_H
bfd69bfb4149 updated for version 7.3.046
Bram Moolenaar <bram@vim.org>
parents: 2621
diff changeset
15 # include "auto/config.h"
bfd69bfb4149 updated for version 7.3.046
Bram Moolenaar <bram@vim.org>
parents: 2621
diff changeset
16 #endif
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
17
2683
0c7d6d01e058 updated for version 7.3.101
Bram Moolenaar <bram@vim.org>
parents: 2669
diff changeset
18 #include <stdio.h>
0c7d6d01e058 updated for version 7.3.101
Bram Moolenaar <bram@vim.org>
parents: 2669
diff changeset
19 #include <string.h>
0c7d6d01e058 updated for version 7.3.101
Bram Moolenaar <bram@vim.org>
parents: 2669
diff changeset
20
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 #ifdef _WIN32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 # if !defined(DYNAMIC_RUBY_VER) || (DYNAMIC_RUBY_VER < 18)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 # define NT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 # ifndef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 # define IMPORT /* For static dll usage __declspec(dllimport) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 # define RUBYEXTERN __declspec(dllimport)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 #ifndef RUBYEXTERN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 # define RUBYEXTERN extern
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
34 #ifdef DYNAMIC_RUBY
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 * This is tricky. In ruby.h there is (inline) function rb_class_of()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 * definition. This function use these variables. But we want function to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 * use dll_* variables.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 # define rb_cFalseClass (*dll_rb_cFalseClass)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 # define rb_cFixnum (*dll_rb_cFixnum)
4193
e49b80f267dc updated for version 7.3.848
Bram Moolenaar <bram@vim.org>
parents: 4164
diff changeset
42 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
e49b80f267dc updated for version 7.3.848
Bram Moolenaar <bram@vim.org>
parents: 4164
diff changeset
43 # define rb_cFloat (*dll_rb_cFloat)
e49b80f267dc updated for version 7.3.848
Bram Moolenaar <bram@vim.org>
parents: 4164
diff changeset
44 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 # define rb_cNilClass (*dll_rb_cNilClass)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 # define rb_cSymbol (*dll_rb_cSymbol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 # define rb_cTrueClass (*dll_rb_cTrueClass)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 /*
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
50 * 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
51 * in ruby.h. But it causes trouble for these variables, because it is
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 * defined in this file. When defined this RUBY_EXPORT it modified to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 * "extern" and be able to avoid this problem.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 # define RUBY_EXPORT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 # endif
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
57
2624
bfd69bfb4149 updated for version 7.3.046
Bram Moolenaar <bram@vim.org>
parents: 2621
diff changeset
58 #if !(defined(WIN32) || defined(_WIN64))
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
59 # include <dlfcn.h>
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
60 # define HINSTANCE void*
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
61 # define RUBY_PROC void*
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
62 # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
63 # define symbol_from_dll dlsym
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
64 # define close_dll dlclose
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
65 #else
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
66 # define RUBY_PROC FARPROC
2612
fa5dee44df3f updated for version 7.3.034
Bram Moolenaar <bram@vim.org>
parents: 2589
diff changeset
67 # define load_dll vimLoadLib
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
68 # define symbol_from_dll GetProcAddress
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
69 # define close_dll FreeLibrary
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
72 #endif /* ifdef DYNAMIC_RUBY */
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
73
2076
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
74 /* suggested by Ariya Mizutani */
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
75 #if (_MSC_VER == 1200)
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
76 # undef _WIN32_WINNT
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
77 #endif
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
78
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
79 #if (defined(RUBY_VERSION) && RUBY_VERSION >= 19) \
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
80 || (defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19)
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
81 # define RUBY19_OR_LATER 1
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
82 #endif
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
83
7364
fe2f6b92d806 commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents: 7360
diff changeset
84 #if (defined(RUBY_VERSION) && RUBY_VERSION >= 20) \
fe2f6b92d806 commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents: 7360
diff changeset
85 || (defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20)
fe2f6b92d806 commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents: 7360
diff changeset
86 # define RUBY20_OR_LATER 1
fe2f6b92d806 commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents: 7360
diff changeset
87 #endif
fe2f6b92d806 commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents: 7360
diff changeset
88
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
89 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
90 /* Ruby 1.9 defines a number of static functions which use rb_num2long and
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
91 * rb_int2big */
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
92 # define rb_num2long rb_num2long_stub
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
93 # define rb_int2big rb_int2big_stub
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
94 #endif
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
95
5766
b0a9df477096 updated for version 7.4.227
Bram Moolenaar <bram@vim.org>
parents: 5761
diff changeset
96 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 \
b0a9df477096 updated for version 7.4.227
Bram Moolenaar <bram@vim.org>
parents: 5761
diff changeset
97 && VIM_SIZEOF_INT < VIM_SIZEOF_LONG
b0a9df477096 updated for version 7.4.227
Bram Moolenaar <bram@vim.org>
parents: 5761
diff changeset
98 /* Ruby 1.9 defines a number of static functions which use rb_fix2int and
5684
136f05449f29 updated for version 7.4.188
Bram Moolenaar <bram@vim.org>
parents: 5643
diff changeset
99 * rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit) */
4279
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
100 # define rb_fix2int rb_fix2int_stub
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
101 # define rb_num2int rb_num2int_stub
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
102 #endif
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
103
6485
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
104 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21
5643
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
105 /* Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
106 * rb_gc_writebarrier_unprotect_promoted if USE_RGENGC */
6406
ee28ddfc7b7c updated for version 7.4.534
Bram Moolenaar <bram@vim.org>
parents: 6357
diff changeset
107 # define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub
ee28ddfc7b7c updated for version 7.4.534
Bram Moolenaar <bram@vim.org>
parents: 6357
diff changeset
108 #endif
6485
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
109 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
110 # define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
111 #endif
5643
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
112
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 #include <ruby.h>
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
114 #ifdef RUBY19_OR_LATER
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
115 # include <ruby/encoding.h>
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
116 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
2669
ee50cd1a3032 updated for version 7.3.088
Bram Moolenaar <bram@vim.org>
parents: 2656
diff changeset
118 #undef off_t /* ruby defines off_t as _int64, Mingw uses long */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 #undef EXTERN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 #undef _
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 /* T_DATA defined both by Ruby and Mac header files, hack around it... */
1233
57dc6ad793e6 updated for version 7.1
vimboss
parents: 1188
diff changeset
123 #if defined(MACOS_X_UNIX) || defined(macintosh)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 # define __OPENTRANSPORT__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 # define __OPENTRANSPORTPROTOCOL__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 # define __OPENTRANSPORTPROVIDERS__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
129 /*
7364
fe2f6b92d806 commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents: 7360
diff changeset
130 * The TypedData_XXX macro family can be used since Ruby 1.9.2 but
fe2f6b92d806 commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents: 7360
diff changeset
131 * rb_data_type_t changed in 1.9.3, therefore require at least 2.0.
fe2f6b92d806 commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents: 7360
diff changeset
132 * The old Data_XXX macro family was deprecated on Ruby 2.2.
7360
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
133 * Use TypedData_XXX if available.
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
134 */
7364
fe2f6b92d806 commit https://github.com/vim/vim/commit/0d27f64f7188efef99062a3c5694027c12401670
Christian Brabandt <cb@256bit.org>
parents: 7360
diff changeset
135 #if defined(TypedData_Wrap_Struct) && defined(RUBY20_OR_LATER)
7360
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
136 # define USE_TYPEDDATA 1
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
137 #endif
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
138
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
139 /*
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4279
diff changeset
140 * Backward compatibility for Ruby 1.8 and earlier.
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
141 * Ruby 1.9 does not provide STR2CSTR, instead StringValuePtr is provided.
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
142 * Ruby 1.9 does not provide RXXX(s)->len and RXXX(s)->ptr, instead
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
143 * RXXX_LEN(s) and RXXX_PTR(s) are provided.
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
144 */
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
145 #ifndef StringValuePtr
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
146 # define StringValuePtr(s) STR2CSTR(s)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
147 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
148 #ifndef RARRAY_LEN
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
149 # define RARRAY_LEN(s) RARRAY(s)->len
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
150 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
151 #ifndef RARRAY_PTR
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
152 # define RARRAY_PTR(s) RARRAY(s)->ptr
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
153 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
154 #ifndef RSTRING_LEN
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
155 # define RSTRING_LEN(s) RSTRING(s)->len
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
156 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
157 #ifndef RSTRING_PTR
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
158 # define RSTRING_PTR(s) RSTRING(s)->ptr
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
159 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
160
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7823
diff changeset
161 #ifdef HAVE_DUP
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7823
diff changeset
162 # undef HAVE_DUP
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7823
diff changeset
163 #endif
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7823
diff changeset
164
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 #include "version.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 #if defined(PROTO) && !defined(FEAT_RUBY)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 /* Define these to be able to generate the function prototypes. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 # define VALUE int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 # define RUBY_DATA_FUNC int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 static int ruby_initialized = 0;
4369
c9820396afb9 updated for version 7.3.933
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
175 static void *ruby_stack_start;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 static VALUE objtbl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 static VALUE mVIM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 static VALUE cBuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 static VALUE cVimWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 static VALUE eDeletedBufferError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 static VALUE eDeletedWindowError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 static int ensure_ruby_initialized(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 static void error_print(int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 static void ruby_io_init(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 static void ruby_vim_init(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188
4452
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
189 #if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK)
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
190 # if defined(__ia64) && !defined(ruby_init_stack)
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
191 # 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
192 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
193 #endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
194
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 #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
196 # if defined(PROTO) && !defined(HINSTANCE)
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
197 # define HINSTANCE int /* for generating prototypes */
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
198 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 * Wrapper defines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 */
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
203 # define rb_assoc_new dll_rb_assoc_new
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
204 # define rb_cObject (*dll_rb_cObject)
7360
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
205 # define rb_check_type dll_rb_check_type
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
206 # ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
207 # 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
208 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
209 # 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
210 # ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
211 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 23
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
212 # 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
213 # else
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
214 # 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
215 # endif
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
216 # else
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
217 # 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
218 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
219 # 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
220 # define rb_define_const dll_rb_define_const
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
221 # 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
222 # define rb_define_method dll_rb_define_method
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
223 # define rb_define_module dll_rb_define_module
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
224 # 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
225 # 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
226 # 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
227 # define rb_stdout (*dll_rb_stdout)
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
228 # define rb_eArgError (*dll_rb_eArgError)
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
229 # define rb_eIndexError (*dll_rb_eIndexError)
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
230 # define rb_eRuntimeError (*dll_rb_eRuntimeError)
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
231 # define rb_eStandardError (*dll_rb_eStandardError)
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
232 # define rb_eval_string_protect dll_rb_eval_string_protect
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
233 # define rb_global_variable dll_rb_global_variable
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
234 # define rb_hash_aset dll_rb_hash_aset
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
235 # define rb_hash_new dll_rb_hash_new
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
236 # define rb_inspect dll_rb_inspect
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
237 # define rb_int2inum dll_rb_int2inum
5684
136f05449f29 updated for version 7.4.188
Bram Moolenaar <bram@vim.org>
parents: 5643
diff changeset
238 # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */
5766
b0a9df477096 updated for version 7.4.227
Bram Moolenaar <bram@vim.org>
parents: 5761
diff changeset
239 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 18
b0a9df477096 updated for version 7.4.227
Bram Moolenaar <bram@vim.org>
parents: 5761
diff changeset
240 # define rb_fix2int dll_rb_fix2int
b0a9df477096 updated for version 7.4.227
Bram Moolenaar <bram@vim.org>
parents: 5761
diff changeset
241 # define rb_num2int dll_rb_num2int
b0a9df477096 updated for version 7.4.227
Bram Moolenaar <bram@vim.org>
parents: 5761
diff changeset
242 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
243 # define rb_num2uint dll_rb_num2uint
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
244 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
245 # define rb_lastline_get dll_rb_lastline_get
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
246 # define rb_lastline_set dll_rb_lastline_set
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
247 # define rb_load_protect dll_rb_load_protect
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
248 # ifndef RUBY19_OR_LATER
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
249 # define rb_num2long dll_rb_num2long
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
250 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
251 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 19
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
252 # define rb_num2ulong dll_rb_num2ulong
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
253 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
254 # define rb_obj_alloc dll_rb_obj_alloc
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
255 # 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
256 # define rb_obj_id dll_rb_obj_id
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
257 # define rb_raise dll_rb_raise
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
258 # define rb_str_cat dll_rb_str_cat
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
259 # 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
260 # undef rb_str_new
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
261 # define rb_str_new dll_rb_str_new
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
262 # ifdef rb_str_new2
2212
7d3cf4693a8f Some versions of Ruby redefine rb_str_new2 to rb_str_new_cstr.
Bram Moolenaar <bram@vim.org>
parents: 2200
diff changeset
263 /* 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
264 # define need_rb_str_new_cstr 1
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
265 /* Ruby's headers #define rb_str_new_cstr to make use of GCC's
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
266 * __builtin_constant_p extension. */
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
267 # undef rb_str_new_cstr
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
268 # 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
269 # else
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
270 # define rb_str_new2 dll_rb_str_new2
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
271 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
272 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
273 # define rb_string_value dll_rb_string_value
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
274 # 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
275 # define rb_float_new dll_rb_float_new
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
276 # define rb_ary_new dll_rb_ary_new
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
277 # define rb_ary_push dll_rb_ary_push
4452
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
278 # if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK)
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
279 # ifdef __ia64
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
280 # define rb_ia64_bsp dll_rb_ia64_bsp
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
281 # undef ruby_init_stack
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
282 # 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
283 # else
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
284 # define ruby_init_stack dll_ruby_init_stack
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
285 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
286 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
287 # else
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
288 # define rb_str2cstr dll_rb_str2cstr
4373
c42e130ebf36 updated for version 7.3.935
Bram Moolenaar <bram@vim.org>
parents: 4369
diff changeset
289 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
290 # ifdef RUBY19_OR_LATER
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
291 # define rb_errinfo dll_rb_errinfo
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
292 # else
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
293 # define ruby_errinfo (*dll_ruby_errinfo)
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
294 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
295 # define ruby_init dll_ruby_init
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
296 # define ruby_init_loadpath dll_ruby_init_loadpath
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
297 # ifdef WIN3264
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
298 # define NtInitialize dll_NtInitialize
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
299 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
300 # define rb_w32_snprintf dll_rb_w32_snprintf
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
301 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
302 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
304 # ifdef RUBY19_OR_LATER
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
305 # define ruby_script dll_ruby_script
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
306 # 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
307 # 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
308 # undef rb_enc_str_new
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7823
diff changeset
309 # 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
310 # define rb_sprintf dll_rb_sprintf
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
311 # 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
312 # define ruby_options dll_ruby_options
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
313 # endif
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
314
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 * Pointers for dynamic link
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 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
319 VALUE *dll_rb_cFalseClass;
7c31d761ffa9 Fix build problem with Ruby on Windows. (Cesar Romani)
Bram Moolenaar <bram@vim.org>
parents: 2212
diff changeset
320 VALUE *dll_rb_cFixnum;
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
321 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
4193
e49b80f267dc updated for version 7.3.848
Bram Moolenaar <bram@vim.org>
parents: 4164
diff changeset
322 VALUE *dll_rb_cFloat;
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
323 # endif
2274
7c31d761ffa9 Fix build problem with Ruby on Windows. (Cesar Romani)
Bram Moolenaar <bram@vim.org>
parents: 2212
diff changeset
324 VALUE *dll_rb_cNilClass;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 static VALUE *dll_rb_cObject;
2274
7c31d761ffa9 Fix build problem with Ruby on Windows. (Cesar Romani)
Bram Moolenaar <bram@vim.org>
parents: 2212
diff changeset
326 VALUE *dll_rb_cSymbol;
7c31d761ffa9 Fix build problem with Ruby on Windows. (Cesar Romani)
Bram Moolenaar <bram@vim.org>
parents: 2212
diff changeset
327 VALUE *dll_rb_cTrueClass;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 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
329 # ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
330 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
331 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 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
333 # ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
334 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 23
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
335 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
336 # else
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
337 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
338 # endif
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
339 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 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
341 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 static VALUE (*dll_rb_define_class_under) (VALUE, const char*, VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 static void (*dll_rb_define_const) (VALUE,const char*,VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 static void (*dll_rb_define_global_function) (const char*,VALUE(*)(),int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 static void (*dll_rb_define_method) (VALUE,const char*,VALUE(*)(),int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 static VALUE (*dll_rb_define_module) (const char*);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 static void (*dll_rb_define_module_function) (VALUE,const char*,VALUE(*)(),int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 static void (*dll_rb_define_singleton_method) (VALUE,const char*,VALUE(*)(),int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 static void (*dll_rb_define_virtual_variable) (const char*,VALUE(*)(),void(*)());
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 static VALUE *dll_rb_stdout;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 static VALUE *dll_rb_eArgError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 static VALUE *dll_rb_eIndexError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 static VALUE *dll_rb_eRuntimeError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 static VALUE *dll_rb_eStandardError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 static VALUE (*dll_rb_eval_string_protect) (const char*, int*);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 static void (*dll_rb_global_variable) (VALUE*);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 static VALUE (*dll_rb_hash_aset) (VALUE, VALUE, VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 static VALUE (*dll_rb_hash_new) (void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 static VALUE (*dll_rb_inspect) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 static VALUE (*dll_rb_int2inum) (long);
5684
136f05449f29 updated for version 7.4.188
Bram Moolenaar <bram@vim.org>
parents: 5643
diff changeset
361 # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */
3808
87afa95a2992 updated for version 7.3.662
Bram Moolenaar <bram@vim.org>
parents: 3478
diff changeset
362 static long (*dll_rb_fix2int) (VALUE);
87afa95a2992 updated for version 7.3.662
Bram Moolenaar <bram@vim.org>
parents: 3478
diff changeset
363 static long (*dll_rb_num2int) (VALUE);
87afa95a2992 updated for version 7.3.662
Bram Moolenaar <bram@vim.org>
parents: 3478
diff changeset
364 static unsigned long (*dll_rb_num2uint) (VALUE);
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
365 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 static VALUE (*dll_rb_lastline_get) (void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 static void (*dll_rb_lastline_set) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 static void (*dll_rb_load_protect) (VALUE, int, int*);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 static long (*dll_rb_num2long) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 static unsigned long (*dll_rb_num2ulong) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 static VALUE (*dll_rb_obj_alloc) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 static VALUE (*dll_rb_obj_as_string) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 static VALUE (*dll_rb_obj_id) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 static void (*dll_rb_raise) (VALUE, const char*, ...);
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
375 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
376 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
377 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 static char *(*dll_rb_str2cstr) (VALUE,int*);
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
379 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 static VALUE (*dll_rb_str_cat) (VALUE, const char*, long);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 static VALUE (*dll_rb_str_concat) (VALUE, VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 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
383 # 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
384 /* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */
7d3cf4693a8f Some versions of Ruby redefine rb_str_new2 to rb_str_new_cstr.
Bram Moolenaar <bram@vim.org>
parents: 2200
diff changeset
385 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
386 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 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
388 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
389 # ifdef RUBY19_OR_LATER
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
390 static VALUE (*dll_rb_errinfo) (void);
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
391 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 static VALUE *dll_ruby_errinfo;
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
393 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 static void (*dll_ruby_init) (void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 static void (*dll_ruby_init_loadpath) (void);
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
396 # ifdef WIN3264
2076
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
397 static void (*dll_NtInitialize) (int*, char***);
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
398 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
399 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
400 # endif
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
401 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
402 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
403 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
404 static VALUE (*dll_rb_float_new) (double);
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
405 static VALUE (*dll_rb_ary_new) (void);
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
406 static VALUE (*dll_rb_ary_push) (VALUE, VALUE);
4452
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
407 # if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK)
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
408 # ifdef __ia64
4373
c42e130ebf36 updated for version 7.3.935
Bram Moolenaar <bram@vim.org>
parents: 4369
diff changeset
409 static void * (*dll_rb_ia64_bsp) (void);
c42e130ebf36 updated for version 7.3.935
Bram Moolenaar <bram@vim.org>
parents: 4369
diff changeset
410 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
411 # else
4373
c42e130ebf36 updated for version 7.3.935
Bram Moolenaar <bram@vim.org>
parents: 4369
diff changeset
412 static void (*dll_ruby_init_stack)(VALUE*);
4452
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
413 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
414 # endif
4373
c42e130ebf36 updated for version 7.3.935
Bram Moolenaar <bram@vim.org>
parents: 4369
diff changeset
415 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
416 # ifdef RUBY19_OR_LATER
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
417 static VALUE (*dll_rb_int2big)(SIGNED_VALUE);
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
418 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
420 # ifdef RUBY19_OR_LATER
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
421 static void (*dll_ruby_script) (const char*);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
422 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
423 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
424 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
425 static VALUE (*dll_rb_sprintf) (const char*, ...);
2669
ee50cd1a3032 updated for version 7.3.088
Bram Moolenaar <bram@vim.org>
parents: 2656
diff changeset
426 static VALUE (*dll_rb_require) (const char*);
7237
2a95fa0a07b5 commit https://github.com/vim/vim/commit/9b1067e038d371bd6c51e5da025383761f4921b4
Christian Brabandt <cb@256bit.org>
parents: 7196
diff changeset
427 static void* (*ruby_options)(int, char**);
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
428 # endif
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
429
5643
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
430 # if defined(USE_RGENGC) && USE_RGENGC
6485
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
431 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21
5643
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
432 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
433 # else
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
434 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
435 # endif
5643
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
436 # endif
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
437
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
438 # if defined(RUBY19_OR_LATER) && !defined(PROTO)
6767
d118a2c541d5 patch 7.4.705
Bram Moolenaar <bram@vim.org>
parents: 6485
diff changeset
439 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22
d118a2c541d5 patch 7.4.705
Bram Moolenaar <bram@vim.org>
parents: 6485
diff changeset
440 long rb_num2long_stub(VALUE x)
d118a2c541d5 patch 7.4.705
Bram Moolenaar <bram@vim.org>
parents: 6485
diff changeset
441 # else
3947
d08f05285dd1 updated for version 7.3.729
Bram Moolenaar <bram@vim.org>
parents: 3931
diff changeset
442 SIGNED_VALUE rb_num2long_stub(VALUE x)
6767
d118a2c541d5 patch 7.4.705
Bram Moolenaar <bram@vim.org>
parents: 6485
diff changeset
443 # endif
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
444 {
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
445 return dll_rb_num2long(x);
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
446 }
3947
d08f05285dd1 updated for version 7.3.729
Bram Moolenaar <bram@vim.org>
parents: 3931
diff changeset
447 VALUE rb_int2big_stub(SIGNED_VALUE x)
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
448 {
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
449 return dll_rb_int2big(x);
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
450 }
5766
b0a9df477096 updated for version 7.4.227
Bram Moolenaar <bram@vim.org>
parents: 5761
diff changeset
451 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 \
b0a9df477096 updated for version 7.4.227
Bram Moolenaar <bram@vim.org>
parents: 5761
diff changeset
452 && VIM_SIZEOF_INT < VIM_SIZEOF_LONG
4279
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
453 long rb_fix2int_stub(VALUE x)
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
454 {
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
455 return dll_rb_fix2int(x);
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
456 }
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
457 long rb_num2int_stub(VALUE x)
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
458 {
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
459 return dll_rb_num2int(x);
cb0c694517a0 updated for version 7.3.889
Bram Moolenaar <bram@vim.org>
parents: 4193
diff changeset
460 }
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
461 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
462 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
4164
3ac9d7d8274e updated for version 7.3.834
Bram Moolenaar <bram@vim.org>
parents: 4135
diff changeset
463 VALUE
3ac9d7d8274e updated for version 7.3.834
Bram Moolenaar <bram@vim.org>
parents: 4135
diff changeset
464 rb_float_new_in_heap(double d)
3ac9d7d8274e updated for version 7.3.834
Bram Moolenaar <bram@vim.org>
parents: 4135
diff changeset
465 {
3ac9d7d8274e updated for version 7.3.834
Bram Moolenaar <bram@vim.org>
parents: 4135
diff changeset
466 return dll_rb_float_new(d);
3ac9d7d8274e updated for version 7.3.834
Bram Moolenaar <bram@vim.org>
parents: 4135
diff changeset
467 }
6767
d118a2c541d5 patch 7.4.705
Bram Moolenaar <bram@vim.org>
parents: 6485
diff changeset
468 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22
d118a2c541d5 patch 7.4.705
Bram Moolenaar <bram@vim.org>
parents: 6485
diff changeset
469 unsigned long rb_num2ulong(VALUE x)
d118a2c541d5 patch 7.4.705
Bram Moolenaar <bram@vim.org>
parents: 6485
diff changeset
470 # else
4193
e49b80f267dc updated for version 7.3.848
Bram Moolenaar <bram@vim.org>
parents: 4164
diff changeset
471 VALUE rb_num2ulong(VALUE x)
6767
d118a2c541d5 patch 7.4.705
Bram Moolenaar <bram@vim.org>
parents: 6485
diff changeset
472 # endif
4164
3ac9d7d8274e updated for version 7.3.834
Bram Moolenaar <bram@vim.org>
parents: 4135
diff changeset
473 {
3ac9d7d8274e updated for version 7.3.834
Bram Moolenaar <bram@vim.org>
parents: 4135
diff changeset
474 return (long)RSHIFT((SIGNED_VALUE)(x),1);
3ac9d7d8274e updated for version 7.3.834
Bram Moolenaar <bram@vim.org>
parents: 4135
diff changeset
475 }
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
476 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
477 # endif
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
478
6357
7623d953d3bc updated for version 7.4.511
Bram Moolenaar <bram@vim.org>
parents: 5766
diff changeset
479 /* Do not generate a prototype here, VALUE isn't always defined. */
7623d953d3bc updated for version 7.4.511
Bram Moolenaar <bram@vim.org>
parents: 5766
diff changeset
480 # if defined(USE_RGENGC) && USE_RGENGC && !defined(PROTO)
6485
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
481 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21
5643
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
482 void rb_gc_writebarrier_unprotect_promoted_stub(VALUE obj)
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
483 {
6406
ee28ddfc7b7c updated for version 7.4.534
Bram Moolenaar <bram@vim.org>
parents: 6357
diff changeset
484 dll_rb_gc_writebarrier_unprotect_promoted(obj);
5643
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
485 }
6485
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
486 # else
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
487 void rb_gc_writebarrier_unprotect_stub(VALUE obj)
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
488 {
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
489 dll_rb_gc_writebarrier_unprotect(obj);
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
490 }
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
491 # endif
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
492 # endif
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
493
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
494 static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 /*
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
497 * Table of name to function pointer of ruby.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 static struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 char *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 RUBY_PROC *ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 } ruby_funcname_table[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 {"rb_assoc_new", (RUBY_PROC*)&dll_rb_assoc_new},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 {"rb_cFalseClass", (RUBY_PROC*)&dll_rb_cFalseClass},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 {"rb_cFixnum", (RUBY_PROC*)&dll_rb_cFixnum},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
508 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
4193
e49b80f267dc updated for version 7.3.848
Bram Moolenaar <bram@vim.org>
parents: 4164
diff changeset
509 {"rb_cFloat", (RUBY_PROC*)&dll_rb_cFloat},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
510 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 {"rb_cNilClass", (RUBY_PROC*)&dll_rb_cNilClass},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 {"rb_cObject", (RUBY_PROC*)&dll_rb_cObject},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 {"rb_cSymbol", (RUBY_PROC*)&dll_rb_cSymbol},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 {"rb_cTrueClass", (RUBY_PROC*)&dll_rb_cTrueClass},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 {"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
516 # ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
517 {"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
518 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 {"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
520 # ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
521 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 23
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
522 {"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
523 # else
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
524 {"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
525 # endif
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
526 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 {"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
528 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 {"rb_define_class_under", (RUBY_PROC*)&dll_rb_define_class_under},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 {"rb_define_const", (RUBY_PROC*)&dll_rb_define_const},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 {"rb_define_global_function", (RUBY_PROC*)&dll_rb_define_global_function},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 {"rb_define_method", (RUBY_PROC*)&dll_rb_define_method},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 {"rb_define_module", (RUBY_PROC*)&dll_rb_define_module},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 {"rb_define_module_function", (RUBY_PROC*)&dll_rb_define_module_function},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 {"rb_define_singleton_method", (RUBY_PROC*)&dll_rb_define_singleton_method},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 {"rb_define_virtual_variable", (RUBY_PROC*)&dll_rb_define_virtual_variable},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 {"rb_stdout", (RUBY_PROC*)&dll_rb_stdout},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 {"rb_eArgError", (RUBY_PROC*)&dll_rb_eArgError},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 {"rb_eIndexError", (RUBY_PROC*)&dll_rb_eIndexError},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 {"rb_eRuntimeError", (RUBY_PROC*)&dll_rb_eRuntimeError},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 {"rb_eStandardError", (RUBY_PROC*)&dll_rb_eStandardError},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 {"rb_eval_string_protect", (RUBY_PROC*)&dll_rb_eval_string_protect},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 {"rb_global_variable", (RUBY_PROC*)&dll_rb_global_variable},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 {"rb_hash_aset", (RUBY_PROC*)&dll_rb_hash_aset},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 {"rb_hash_new", (RUBY_PROC*)&dll_rb_hash_new},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 {"rb_inspect", (RUBY_PROC*)&dll_rb_inspect},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 {"rb_int2inum", (RUBY_PROC*)&dll_rb_int2inum},
5684
136f05449f29 updated for version 7.4.188
Bram Moolenaar <bram@vim.org>
parents: 5643
diff changeset
548 # if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */
3808
87afa95a2992 updated for version 7.3.662
Bram Moolenaar <bram@vim.org>
parents: 3478
diff changeset
549 {"rb_fix2int", (RUBY_PROC*)&dll_rb_fix2int},
87afa95a2992 updated for version 7.3.662
Bram Moolenaar <bram@vim.org>
parents: 3478
diff changeset
550 {"rb_num2int", (RUBY_PROC*)&dll_rb_num2int},
87afa95a2992 updated for version 7.3.662
Bram Moolenaar <bram@vim.org>
parents: 3478
diff changeset
551 {"rb_num2uint", (RUBY_PROC*)&dll_rb_num2uint},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
552 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 {"rb_lastline_get", (RUBY_PROC*)&dll_rb_lastline_get},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 {"rb_lastline_set", (RUBY_PROC*)&dll_rb_lastline_set},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 {"rb_load_protect", (RUBY_PROC*)&dll_rb_load_protect},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 {"rb_num2long", (RUBY_PROC*)&dll_rb_num2long},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 {"rb_num2ulong", (RUBY_PROC*)&dll_rb_num2ulong},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 {"rb_obj_alloc", (RUBY_PROC*)&dll_rb_obj_alloc},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 {"rb_obj_as_string", (RUBY_PROC*)&dll_rb_obj_as_string},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 {"rb_obj_id", (RUBY_PROC*)&dll_rb_obj_id},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 {"rb_raise", (RUBY_PROC*)&dll_rb_raise},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
562 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
563 {"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
564 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 {"rb_str2cstr", (RUBY_PROC*)&dll_rb_str2cstr},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
566 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 {"rb_str_cat", (RUBY_PROC*)&dll_rb_str_cat},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 {"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
570 # 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
571 {"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
572 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 {"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
574 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
575 # ifdef RUBY19_OR_LATER
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
576 {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
577 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
579 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 {"ruby_init", (RUBY_PROC*)&dll_ruby_init},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
582 # ifdef WIN3264
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
583 {
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
584 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER < 19
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
585 "NtInitialize",
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
586 # else
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
587 "ruby_sysinit",
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
588 # endif
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
589 (RUBY_PROC*)&dll_NtInitialize},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
590 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 {"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
592 # endif
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
593 # endif
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
594 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
595 {"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
596 # if DYNAMIC_RUBY_VER <= 19
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
597 {"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
598 # else
4164
3ac9d7d8274e updated for version 7.3.834
Bram Moolenaar <bram@vim.org>
parents: 4135
diff changeset
599 {"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
600 # endif
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
601 {"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new},
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
602 {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
603 # endif
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
604 # ifdef RUBY19_OR_LATER
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
605 {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big},
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
606 {"ruby_script", (RUBY_PROC*)&dll_ruby_script},
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
607 {"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
608 {"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
609 {"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
610 {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
2669
ee50cd1a3032 updated for version 7.3.088
Bram Moolenaar <bram@vim.org>
parents: 2656
diff changeset
611 {"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
612 {"ruby_options", (RUBY_PROC*)&dll_ruby_options},
4375
e7361b2d8136 updated for version 7.3.936
Bram Moolenaar <bram@vim.org>
parents: 4373
diff changeset
613 # endif
4452
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
614 # if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK)
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
615 # ifdef __ia64
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
616 {"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
617 # endif
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
618 {"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
619 # endif
5643
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
620 # if defined(USE_RGENGC) && USE_RGENGC
6485
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
621 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21
5643
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
622 {"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
623 # else
816c584ff174 updated for version 7.4.570
Bram Moolenaar <bram@vim.org>
parents: 6406
diff changeset
624 {"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
625 # endif
5643
e61a2b709f69 updated for version 7.4.168
Bram Moolenaar <bram@vim.org>
parents: 4452
diff changeset
626 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 {"", NULL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 * Free ruby.dll
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7712
diff changeset
634 end_dynamic_ruby(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 if (hinstRuby)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 {
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
638 close_dll(hinstRuby);
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
639 hinstRuby = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 * Load library and get all pointers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 * Parameter 'libname' provides name of DLL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 * Return OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 ruby_runtime_link_init(char *libname, int verbose)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 if (hinstRuby)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 return OK;
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
655 hinstRuby = load_dll(libname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 if (!hinstRuby)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 if (verbose)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 EMSG2(_(e_loadlib), libname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 for (i = 0; ruby_funcname_table[i].ptr; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 {
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
665 if (!(*ruby_funcname_table[i].ptr = symbol_from_dll(hinstRuby,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 ruby_funcname_table[i].name)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 {
2589
d5681bd2661b updated for version 7.3.013
Bram Moolenaar <bram@vim.org>
parents: 2282
diff changeset
668 close_dll(hinstRuby);
2621
baa5f81197c8 updated for version 7.3.043
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
669 hinstRuby = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 if (verbose)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 EMSG2(_(e_loadfunc), ruby_funcname_table[i].name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 * If ruby is enabled (there is installed ruby on Windows system) return TRUE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 * else FALSE.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7712
diff changeset
683 ruby_enabled(int verbose)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 {
7528
53163e4d9e4f commit https://github.com/vim/vim/commit/25e4fcde767084d1a79e0926bc301c92987c0cce
Christian Brabandt <cb@256bit.org>
parents: 7364
diff changeset
685 return ruby_runtime_link_init((char *)p_rubydll, verbose) == OK;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 #endif /* defined(DYNAMIC_RUBY) || defined(PROTO) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7712
diff changeset
690 ruby_end(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 #ifdef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 end_dynamic_ruby();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 void ex_ruby(exarg_T *eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 int state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 char *script = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701
750
e2f45cbe2b8a updated for version 7.0223
vimboss
parents: 714
diff changeset
702 script = (char *)script_get(eap, eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 if (!eap->skip && ensure_ruby_initialized())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 if (script == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 rb_eval_string_protect((char *)eap->arg, &state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 rb_eval_string_protect(script, &state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 if (state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 error_print(state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 vim_free(script);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
715 /*
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
716 * 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
717 * 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
718 * VIM encoding option.
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
719 */
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
720 static VALUE
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
721 vim_str2rb_enc_str(const char *s)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
722 {
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
723 #ifdef RUBY19_OR_LATER
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
724 int isnum;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
725 long lval;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
726 char_u *sval;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
727 rb_encoding *enc;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
728
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
729 isnum = get_option_value((char_u *)"enc", &lval, &sval, 0);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
730 if (isnum == 0)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
731 {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
732 enc = rb_enc_find((char *)sval);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
733 vim_free(sval);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
734 if (enc) {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
735 return rb_enc_str_new(s, strlen(s), enc);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
736 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
737 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
738 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
739 return rb_str_new2(s);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
740 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
741
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
742 static VALUE
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
743 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
744 {
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
745 #ifdef RUBY19_OR_LATER
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
746 int isnum;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
747 long lval;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
748 char_u *sval;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
749 rb_encoding *enc;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
750 VALUE v;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
751
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
752 isnum = get_option_value((char_u *)"enc", &lval, &sval, 0);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
753 if (isnum == 0)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
754 {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
755 enc = rb_enc_find((char *)sval);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
756 vim_free(sval);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
757 if (enc)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
758 {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
759 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
760 return rb_eval_string_protect(StringValuePtr(v), state);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
761 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
762 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
763 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
764 return rb_eval_string_protect(str, state);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
765 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
766
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 void ex_rubydo(exarg_T *eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 int state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 linenr_T i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 if (ensure_ruby_initialized())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 if (u_save(eap->line1 - 1, eap->line2 + 1) != OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 for (i = eap->line1; i <= eap->line2; i++) {
2656
4549e0e7fbb6 updated for version 7.3.076
Bram Moolenaar <bram@vim.org>
parents: 2647
diff changeset
777 VALUE line;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778
2656
4549e0e7fbb6 updated for version 7.3.076
Bram Moolenaar <bram@vim.org>
parents: 2647
diff changeset
779 line = vim_str2rb_enc_str((char *)ml_get(i));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 rb_lastline_set(line);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
781 eval_enc_string_protect((char *) eap->arg, &state);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 if (state) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 error_print(state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 line = rb_lastline_get();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 if (!NIL_P(line)) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 if (TYPE(line) != T_STRING) {
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
789 EMSG(_("E265: $_ must be an instance of String"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 }
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
792 ml_replace(i, (char_u *) StringValuePtr(line), 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 changed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 #ifdef SYNTAX_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 syn_changed(i); /* recompute syntax hl. for this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 check_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 update_curbuf(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 void ex_rubyfile(exarg_T *eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 int state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 if (ensure_ruby_initialized())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 rb_load_protect(rb_str_new2((char *) eap->arg), 0, &state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 if (state) error_print(state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 }
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 void ruby_buffer_free(buf_T *buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
817 if (buf->b_ruby_ref)
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
818 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
819 rb_hash_aset(objtbl, rb_obj_id((VALUE) buf->b_ruby_ref), Qnil);
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
820 RDATA(buf->b_ruby_ref)->data = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 void ruby_window_free(win_T *win)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
826 if (win->w_ruby_ref)
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
827 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
828 rb_hash_aset(objtbl, rb_obj_id((VALUE) win->w_ruby_ref), Qnil);
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
829 RDATA(win->w_ruby_ref)->data = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 static int ensure_ruby_initialized(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 if (!ruby_initialized)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 #ifdef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 if (ruby_enabled(TRUE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 #endif
2076
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
841 #ifdef _WIN32
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
842 /* suggested by Ariya Mizutani */
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
843 int argc = 1;
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
844 char *argv[] = {"gvim.exe"};
6406
ee28ddfc7b7c updated for version 7.4.534
Bram Moolenaar <bram@vim.org>
parents: 6357
diff changeset
845 char **argvp = argv;
ee28ddfc7b7c updated for version 7.4.534
Bram Moolenaar <bram@vim.org>
parents: 6357
diff changeset
846 NtInitialize(&argc, &argvp);
2076
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
847 #endif
2282
a888ed7ba375 Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents: 2274
diff changeset
848 {
4452
92fec4b83be5 updated for version 7.3.974
Bram Moolenaar <bram@vim.org>
parents: 4375
diff changeset
849 #if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK)
4369
c9820396afb9 updated for version 7.3.933
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
850 ruby_init_stack(ruby_stack_start);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
851 #endif
2282
a888ed7ba375 Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents: 2274
diff changeset
852 ruby_init();
a888ed7ba375 Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents: 2274
diff changeset
853 }
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
854 #ifdef RUBY19_OR_LATER
2669
ee50cd1a3032 updated for version 7.3.088
Bram Moolenaar <bram@vim.org>
parents: 2656
diff changeset
855 {
ee50cd1a3032 updated for version 7.3.088
Bram Moolenaar <bram@vim.org>
parents: 2656
diff changeset
856 int dummy_argc = 2;
ee50cd1a3032 updated for version 7.3.088
Bram Moolenaar <bram@vim.org>
parents: 2656
diff changeset
857 char *dummy_argv[] = {"vim-ruby", "-e0"};
7237
2a95fa0a07b5 commit https://github.com/vim/vim/commit/9b1067e038d371bd6c51e5da025383761f4921b4
Christian Brabandt <cb@256bit.org>
parents: 7196
diff changeset
858 ruby_options(dummy_argc, dummy_argv);
2669
ee50cd1a3032 updated for version 7.3.088
Bram Moolenaar <bram@vim.org>
parents: 2656
diff changeset
859 }
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
860 ruby_script("vim-ruby");
2669
ee50cd1a3032 updated for version 7.3.088
Bram Moolenaar <bram@vim.org>
parents: 2656
diff changeset
861 #else
ee50cd1a3032 updated for version 7.3.088
Bram Moolenaar <bram@vim.org>
parents: 2656
diff changeset
862 ruby_init_loadpath();
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
863 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 ruby_io_init();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 ruby_vim_init();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 ruby_initialized = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 #ifdef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 EMSG(_("E266: Sorry, this command is disabled, the Ruby library could not be loaded."));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 return ruby_initialized;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 static void error_print(int state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 #ifndef DYNAMIC_RUBY
2104
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
882 #if !(defined(RUBY_VERSION) && RUBY_VERSION >= 19) \
09cc86b66653 updated for version 7.2.387
Bram Moolenaar <bram@zimbu.org>
parents: 2090
diff changeset
883 && !(defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 RUBYEXTERN VALUE ruby_errinfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 #endif
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
886 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 VALUE eclass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 VALUE einfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 char buff[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 #define TAG_RETURN 0x1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 #define TAG_BREAK 0x2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 #define TAG_NEXT 0x3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 #define TAG_RETRY 0x4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 #define TAG_REDO 0x5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 #define TAG_RAISE 0x6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 #define TAG_THROW 0x7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 #define TAG_FATAL 0x8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 #define TAG_MASK 0xf
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 switch (state) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 case TAG_RETURN:
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
903 EMSG(_("E267: unexpected return"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 case TAG_NEXT:
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
906 EMSG(_("E268: unexpected next"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 case TAG_BREAK:
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
909 EMSG(_("E269: unexpected break"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 case TAG_REDO:
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
912 EMSG(_("E270: unexpected redo"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 case TAG_RETRY:
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
915 EMSG(_("E271: retry outside of rescue clause"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 case TAG_RAISE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 case TAG_FATAL:
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
919 #ifdef RUBY19_OR_LATER
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
920 eclass = CLASS_OF(rb_errinfo());
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
921 einfo = rb_obj_as_string(rb_errinfo());
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
922 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 eclass = CLASS_OF(ruby_errinfo);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 einfo = rb_obj_as_string(ruby_errinfo);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
925 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
926 if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
927 EMSG(_("E272: unhandled exception"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 VALUE epath;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 epath = rb_class_path(eclass);
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
934 vim_snprintf(buff, BUFSIZ, "%s: %s",
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
935 RSTRING_PTR(epath), RSTRING_PTR(einfo));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 p = strchr(buff, '\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 if (p) *p = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 EMSG(buff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 default:
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
942 vim_snprintf(buff, BUFSIZ, _("E273: unknown longjmp status %d"), state);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 EMSG(buff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
948 static VALUE vim_message(VALUE self UNUSED, VALUE str)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 char *buff, *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 str = rb_obj_as_string(str);
2990
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
953 if (RSTRING_LEN(str) > 0)
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
954 {
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
955 /* Only do this when the string isn't empty, alloc(0) causes trouble. */
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
956 buff = ALLOCA_N(char, RSTRING_LEN(str));
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
957 strcpy(buff, RSTRING_PTR(str));
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
958 p = strchr(buff, '\n');
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
959 if (p) *p = '\0';
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
960 MSG(buff);
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
961 }
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
962 else
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
963 {
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
964 MSG("");
ad404f2a4bfa updated for version 7.3.267
Bram Moolenaar <bram@vim.org>
parents: 2683
diff changeset
965 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
969 static VALUE vim_set_option(VALUE self UNUSED, VALUE str)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
971 do_set((char_u *)StringValuePtr(str), 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 update_screen(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
976 static VALUE vim_command(VALUE self UNUSED, VALUE str)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
978 do_cmdline_cmd((char_u *)StringValuePtr(str));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
982 #ifdef FEAT_EVAL
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
983 static VALUE vim_to_ruby(typval_T *tv)
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
984 {
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
985 VALUE result = Qnil;
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
986
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
987 if (tv->v_type == VAR_STRING)
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
988 {
2121
20d9fc2f13a4 updated for version 7.2.403
Bram Moolenaar <bram@zimbu.org>
parents: 2117
diff changeset
989 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
990 ? "" : (char *)(tv->vval.v_string));
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
991 }
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
992 else if (tv->v_type == VAR_NUMBER)
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
993 {
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
994 result = INT2NUM(tv->vval.v_number);
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
995 }
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
996 # ifdef FEAT_FLOAT
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
997 else if (tv->v_type == VAR_FLOAT)
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
998 {
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
999 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
1000 }
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1001 # endif
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1002 else if (tv->v_type == VAR_LIST)
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1003 {
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1004 list_T *list = tv->vval.v_list;
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1005 listitem_T *curr;
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1006
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1007 result = rb_ary_new();
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1008
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1009 if (list != NULL)
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1010 {
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1011 for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1012 {
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1013 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
1014 }
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1015 }
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1016 }
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1017 else if (tv->v_type == VAR_DICT)
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1018 {
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1019 result = rb_hash_new();
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1020
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1021 if (tv->vval.v_dict != NULL)
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1022 {
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1023 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
1024 long_u todo = ht->ht_used;
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1025 hashitem_T *hi;
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1026 dictitem_T *di;
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1027
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1028 for (hi = ht->ht_array; todo > 0; ++hi)
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1029 {
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1030 if (!HASHITEM_EMPTY(hi))
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1031 {
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1032 --todo;
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1033
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1034 di = dict_lookup(hi);
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1035 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
1036 vim_to_ruby(&di->di_tv));
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1037 }
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1038 }
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1039 }
7712
bce3b5ddb393 commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents: 7668
diff changeset
1040 }
bce3b5ddb393 commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents: 7668
diff changeset
1041 else if (tv->v_type == VAR_SPECIAL)
bce3b5ddb393 commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents: 7668
diff changeset
1042 {
bce3b5ddb393 commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents: 7668
diff changeset
1043 if (tv->vval.v_number <= VVAL_TRUE)
bce3b5ddb393 commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents: 7668
diff changeset
1044 result = INT2NUM(tv->vval.v_number);
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1045 } /* else return Qnil; */
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1046
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1047 return result;
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1048 }
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1049 #endif
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1050
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
1051 static VALUE vim_evaluate(VALUE self UNUSED, VALUE str)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 #ifdef FEAT_EVAL
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1054 typval_T *tv;
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1055 VALUE result;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1057 tv = eval_expr((char_u *)StringValuePtr(str), NULL);
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1058 if (tv == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 {
2117
4be6da0fa3d9 updated for version 7.2.400
Bram Moolenaar <bram@zimbu.org>
parents: 2104
diff changeset
1060 return Qnil;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 }
2090
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1062 result = vim_to_ruby(tv);
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1063
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1064 free_tv(tv);
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1065
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1066 return result;
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1067 #else
53d475dff0e3 updated for version 7.2.374
Bram Moolenaar <bram@zimbu.org>
parents: 2084
diff changeset
1068 return Qnil;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071
7360
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1072 #ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1073 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
1074
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1075 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
1076 "vim_buffer",
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1077 {0, 0, buffer_dsize, {0, 0}},
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1078 0, 0,
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1079 # ifdef RUBY_TYPED_FREE_IMMEDIATELY
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1080 0,
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1081 # endif
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1082 };
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1083
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1084 static size_t buffer_dsize(const void *buf UNUSED)
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1085 {
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1086 return sizeof(buf_T);
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1087 }
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1088 #endif
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1089
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 static VALUE buffer_new(buf_T *buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1092 if (buf->b_ruby_ref)
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1093 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1094 return (VALUE) buf->b_ruby_ref;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 }
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1096 else
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1097 {
7360
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1098 #ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1099 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
1100 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 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
1102 #endif
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1103 buf->b_ruby_ref = (void *) obj;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 rb_hash_aset(objtbl, rb_obj_id(obj), obj);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 return obj;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 static buf_T *get_buf(VALUE obj)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112
7360
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1113 #ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1114 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
1115 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 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
1117 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 rb_raise(eDeletedBufferError, "attempt to refer to deleted buffer");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7712
diff changeset
1123 static VALUE buffer_s_current(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 return buffer_new(curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7712
diff changeset
1128 static VALUE buffer_s_count(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 buf_T *b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 int n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1133 for (b = firstbuf; b != NULL; b = b->b_next)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1134 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1135 /* Deleted buffers should not be counted
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1136 * SegPhault - 01/07/05 */
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1137 if (b->b_p_bl)
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1138 n++;
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1139 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1140
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 return INT2NUM(n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
1144 static VALUE buffer_s_aref(VALUE self UNUSED, VALUE num)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 buf_T *b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 int n = NUM2INT(num);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1149 for (b = firstbuf; b != NULL; b = b->b_next)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1150 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1151 /* Deleted buffers should not be counted
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1152 * SegPhault - 01/07/05 */
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1153 if (!b->b_p_bl)
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1154 continue;
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1155
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1156 if (n == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 return buffer_new(b);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1158
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1159 n--;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 static VALUE buffer_name(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 buf_T *buf = get_buf(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167
750
e2f45cbe2b8a updated for version 7.0223
vimboss
parents: 714
diff changeset
1168 return buf->b_ffname ? rb_str_new2((char *)buf->b_ffname) : Qnil;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 static VALUE buffer_number(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 buf_T *buf = get_buf(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 return INT2NUM(buf->b_fnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 static VALUE buffer_count(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 buf_T *buf = get_buf(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 return INT2NUM(buf->b_ml.ml_line_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1185 static VALUE get_buffer_line(buf_T *buf, linenr_T n)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 {
2637
37d62d968182 updated for version 7.3.058
Bram Moolenaar <bram@vim.org>
parents: 2624
diff changeset
1187 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
1188 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
1189 return vim_str2rb_enc_str((char *)ml_get_buf(buf, n, FALSE));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1192 static VALUE buffer_aref(VALUE self, VALUE num)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 buf_T *buf = get_buf(self);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1195
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1196 if (buf != NULL)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1197 return get_buffer_line(buf, (linenr_T)NUM2LONG(num));
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1198 return Qnil; /* For stop warning */
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1199 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1200
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1201 static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1202 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1203 char *line = StringValuePtr(str);
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1204 aco_save_T aco;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1206 if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL)
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1207 {
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1208 /* set curwin/curbuf for "buf" and save some things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1209 aucmd_prepbuf(&aco, buf);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1210
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 if (u_savesub(n) == OK) {
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1212 ml_replace(n, (char_u *)line, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 changed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 #ifdef SYNTAX_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 syn_changed(n); /* recompute syntax hl. for this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 }
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1218
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1219 /* restore curwin/curbuf and a few other things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1220 aucmd_restbuf(&aco);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1221 /* Careful: autocommands may have made "buf" invalid! */
934
e44efb3af0d5 updated for version 7.0-060
vimboss
parents: 896
diff changeset
1222
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 update_curbuf(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 }
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1225 else
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1226 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1227 rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 return str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1232 static VALUE buffer_aset(VALUE self, VALUE num, VALUE str)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1233 {
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1234 buf_T *buf = get_buf(self);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1235
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1236 if (buf != NULL)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1237 return set_buffer_line(buf, (linenr_T)NUM2LONG(num), str);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1238 return str;
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1239 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1240
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 static VALUE buffer_delete(VALUE self, VALUE num)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 {
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1243 buf_T *buf = get_buf(self);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1244 long n = NUM2LONG(num);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1245 aco_save_T aco;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1247 if (n > 0 && n <= buf->b_ml.ml_line_count)
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1248 {
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1249 /* set curwin/curbuf for "buf" and save some things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1250 aucmd_prepbuf(&aco, buf);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1251
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 if (u_savedel(n, 1) == OK) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 ml_delete(n, 0);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1254
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1255 /* Changes to non-active buffers should properly refresh
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1256 * SegPhault - 01/09/05 */
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1257 deleted_lines_mark(n, 1L);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1258
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 changed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 }
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1261
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1262 /* restore curwin/curbuf and a few other things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1263 aucmd_restbuf(&aco);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1264 /* Careful: autocommands may have made "buf" invalid! */
934
e44efb3af0d5 updated for version 7.0-060
vimboss
parents: 896
diff changeset
1265
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 update_curbuf(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 }
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1268 else
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1269 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1270 rb_raise(rb_eIndexError, "line number %ld out of range", n);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 static VALUE buffer_append(VALUE self, VALUE num, VALUE str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 {
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1277 buf_T *buf = get_buf(self);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1278 char *line = StringValuePtr(str);
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1279 long n = NUM2LONG(num);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1280 aco_save_T aco;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281
2637
37d62d968182 updated for version 7.3.058
Bram Moolenaar <bram@vim.org>
parents: 2624
diff changeset
1282 if (line == NULL)
37d62d968182 updated for version 7.3.058
Bram Moolenaar <bram@vim.org>
parents: 2624
diff changeset
1283 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1284 rb_raise(rb_eIndexError, "NULL line");
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1285 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1286 else if (n >= 0 && n <= buf->b_ml.ml_line_count)
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1287 {
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1288 /* set curwin/curbuf for "buf" and save some things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1289 aucmd_prepbuf(&aco, buf);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1290
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 if (u_inssub(n + 1) == OK) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 ml_append(n, (char_u *) line, (colnr_T) 0, FALSE);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1293
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1294 /* Changes to non-active buffers should properly refresh screen
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1295 * SegPhault - 12/20/04 */
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1296 appended_lines_mark(n, 1L);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1297
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
1298 changed();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 }
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1300
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1301 /* restore curwin/curbuf and a few other things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1302 aucmd_restbuf(&aco);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
1303 /* Careful: autocommands may have made "buf" invalid! */
934
e44efb3af0d5 updated for version 7.0-060
vimboss
parents: 896
diff changeset
1304
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 update_curbuf(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 }
2637
37d62d968182 updated for version 7.3.058
Bram Moolenaar <bram@vim.org>
parents: 2624
diff changeset
1307 else
37d62d968182 updated for version 7.3.058
Bram Moolenaar <bram@vim.org>
parents: 2624
diff changeset
1308 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1309 rb_raise(rb_eIndexError, "line number %ld out of range", n);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 return str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313
7360
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1314 #ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1315 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
1316
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1317 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
1318 "vim_window",
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1319 {0, 0, window_dsize, {0, 0}},
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1320 0, 0,
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1321 # ifdef RUBY_TYPED_FREE_IMMEDIATELY
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1322 0,
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1323 # endif
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1324 };
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1325
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1326 static size_t window_dsize(const void *win UNUSED)
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1327 {
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1328 return sizeof(win_T);
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1329 }
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1330 #endif
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1331
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 static VALUE window_new(win_T *win)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1334 if (win->w_ruby_ref)
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1335 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1336 return (VALUE) win->w_ruby_ref;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 }
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1338 else
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1339 {
7360
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1340 #ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1341 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
1342 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 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
1344 #endif
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
1345 win->w_ruby_ref = (void *) obj;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 rb_hash_aset(objtbl, rb_obj_id(obj), obj);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 return obj;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 static win_T *get_win(VALUE obj)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354
7360
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1355 #ifdef USE_TYPEDDATA
b20095ba6fc2 commit https://github.com/vim/vim/commit/f2f6d297966ec0e357640b71a238e51afcaba6cc
Christian Brabandt <cb@256bit.org>
parents: 7237
diff changeset
1356 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
1357 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 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
1359 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 if (win == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 rb_raise(eDeletedWindowError, "attempt to refer to deleted window");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 return win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7712
diff changeset
1365 static VALUE window_s_current(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 return window_new(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1370 /*
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1371 * Added line manipulation functions
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1372 * SegPhault - 03/07/05
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1373 */
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7712
diff changeset
1374 static VALUE line_s_current(void)
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1375 {
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1376 return get_buffer_line(curbuf, curwin->w_cursor.lnum);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1377 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1378
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
1379 static VALUE set_current_line(VALUE self UNUSED, VALUE str)
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1380 {
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1381 return set_buffer_line(curbuf, curwin->w_cursor.lnum, str);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1382 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1383
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7712
diff changeset
1384 static VALUE current_line_number(void)
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1385 {
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1386 return INT2FIX((int)curwin->w_cursor.lnum);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1387 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1388
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1389
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1390
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7712
diff changeset
1391 static VALUE window_s_count(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 win_T *w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 int n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396
671
83a006f81bac updated for version 7.0199
vimboss
parents: 502
diff changeset
1397 for (w = firstwin; w != NULL; w = w->w_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 return INT2NUM(n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 return INT2NUM(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
1405 static VALUE window_s_aref(VALUE self UNUSED, VALUE num)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 win_T *w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 int n = NUM2INT(num);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 #ifndef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 w = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 for (w = firstwin; w != NULL; w = w->w_next, --n)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 if (n == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 return window_new(w);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 static VALUE window_buffer(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 win_T *win = get_win(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 return buffer_new(win->w_buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 static VALUE window_height(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 win_T *win = get_win(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 return INT2NUM(win->w_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 static VALUE window_set_height(VALUE self, VALUE height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 win_T *win = get_win(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 win_T *savewin = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 curwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 win_setheight(NUM2INT(height));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 curwin = savewin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 return height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444
4135
688da4d486a0 updated for version 7.3.820
Bram Moolenaar <bram@vim.org>
parents: 3947
diff changeset
1445 static VALUE window_width(VALUE self UNUSED)
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1446 {
4135
688da4d486a0 updated for version 7.3.820
Bram Moolenaar <bram@vim.org>
parents: 3947
diff changeset
1447 return INT2NUM(W_WIDTH(get_win(self)));
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1448 }
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1449
4135
688da4d486a0 updated for version 7.3.820
Bram Moolenaar <bram@vim.org>
parents: 3947
diff changeset
1450 static VALUE window_set_width(VALUE self UNUSED, VALUE width)
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1451 {
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8080
diff changeset
1452 #ifdef FEAT_WINDOWS
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1453 win_T *win = get_win(self);
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1454 win_T *savewin = curwin;
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1455
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1456 curwin = win;
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1457 win_setwidth(NUM2INT(width));
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1458 curwin = savewin;
4135
688da4d486a0 updated for version 7.3.820
Bram Moolenaar <bram@vim.org>
parents: 3947
diff changeset
1459 #endif
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1460 return width;
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1461 }
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1462
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 static VALUE window_cursor(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 win_T *win = get_win(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 return rb_assoc_new(INT2NUM(win->w_cursor.lnum), INT2NUM(win->w_cursor.col));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 static VALUE window_set_cursor(VALUE self, VALUE pos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 VALUE lnum, col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 win_T *win = get_win(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 Check_Type(pos, T_ARRAY);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1476 if (RARRAY_LEN(pos) != 2)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 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
1478 lnum = RARRAY_PTR(pos)[0];
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1479 col = RARRAY_PTR(pos)[1];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 win->w_cursor.lnum = NUM2LONG(lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 win->w_cursor.col = NUM2UINT(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 check_cursor(); /* put cursor on an existing line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 update_screen(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486
3478
65d036fd449e updated for version 7.3.503
Bram Moolenaar <bram@vim.org>
parents: 3474
diff changeset
1487 static VALUE f_nop(VALUE self UNUSED)
3474
d7b335626ddc updated for version 7.3.501
Bram Moolenaar <bram@vim.org>
parents: 2990
diff changeset
1488 {
d7b335626ddc updated for version 7.3.501
Bram Moolenaar <bram@vim.org>
parents: 2990
diff changeset
1489 return Qnil;
d7b335626ddc updated for version 7.3.501
Bram Moolenaar <bram@vim.org>
parents: 2990
diff changeset
1490 }
d7b335626ddc updated for version 7.3.501
Bram Moolenaar <bram@vim.org>
parents: 2990
diff changeset
1491
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
1492 static VALUE f_p(int argc, VALUE *argv, VALUE self UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 VALUE str = rb_str_new("", 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 for (i = 0; i < argc; i++) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 if (i > 0) rb_str_cat(str, ", ", 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 rb_str_concat(str, rb_inspect(argv[i]));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 }
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1501 MSG(RSTRING_PTR(str));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 static void ruby_io_init(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 #ifndef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 RUBYEXTERN VALUE rb_stdout;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 rb_stdout = rb_obj_alloc(rb_cObject);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 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
1513 rb_define_singleton_method(rb_stdout, "flush", f_nop, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 rb_define_global_function("p", f_p, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 static void ruby_vim_init(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 objtbl = rb_hash_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 rb_global_variable(&objtbl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521
1188
2a276274c592 updated for version 7.1b
vimboss
parents: 1131
diff changeset
1522 /* The Vim module used to be called "VIM", but "Vim" is better. Make an
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4279
diff changeset
1523 * alias "VIM" for backwards compatibility. */
1188
2a276274c592 updated for version 7.1b
vimboss
parents: 1131
diff changeset
1524 mVIM = rb_define_module("Vim");
2a276274c592 updated for version 7.1b
vimboss
parents: 1131
diff changeset
1525 rb_define_const(rb_cObject, "VIM", mVIM);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 rb_define_const(mVIM, "VERSION_MAJOR", INT2NUM(VIM_VERSION_MAJOR));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 rb_define_const(mVIM, "VERSION_MINOR", INT2NUM(VIM_VERSION_MINOR));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 rb_define_const(mVIM, "VERSION_BUILD", INT2NUM(VIM_VERSION_BUILD));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 rb_define_const(mVIM, "VERSION_PATCHLEVEL", INT2NUM(VIM_VERSION_PATCHLEVEL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 rb_define_const(mVIM, "VERSION_SHORT", rb_str_new2(VIM_VERSION_SHORT));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 rb_define_const(mVIM, "VERSION_MEDIUM", rb_str_new2(VIM_VERSION_MEDIUM));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 rb_define_const(mVIM, "VERSION_LONG", rb_str_new2(VIM_VERSION_LONG));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 rb_define_const(mVIM, "VERSION_LONG_DATE", rb_str_new2(VIM_VERSION_LONG_DATE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 rb_define_module_function(mVIM, "message", vim_message, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 rb_define_module_function(mVIM, "set_option", vim_set_option, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 rb_define_module_function(mVIM, "command", vim_command, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 rb_define_module_function(mVIM, "evaluate", vim_evaluate, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 eDeletedBufferError = rb_define_class_under(mVIM, "DeletedBufferError",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 rb_eStandardError);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 eDeletedWindowError = rb_define_class_under(mVIM, "DeletedWindowError",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 rb_eStandardError);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 cBuffer = rb_define_class_under(mVIM, "Buffer", rb_cObject);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 rb_define_singleton_method(cBuffer, "current", buffer_s_current, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 rb_define_singleton_method(cBuffer, "count", buffer_s_count, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 rb_define_singleton_method(cBuffer, "[]", buffer_s_aref, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548 rb_define_method(cBuffer, "name", buffer_name, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 rb_define_method(cBuffer, "number", buffer_number, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 rb_define_method(cBuffer, "count", buffer_count, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 rb_define_method(cBuffer, "length", buffer_count, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 rb_define_method(cBuffer, "[]", buffer_aref, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 rb_define_method(cBuffer, "[]=", buffer_aset, 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 rb_define_method(cBuffer, "delete", buffer_delete, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 rb_define_method(cBuffer, "append", buffer_append, 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1557 /* Added line manipulation functions
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1558 * SegPhault - 03/07/05 */
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1559 rb_define_method(cBuffer, "line_number", current_line_number, 0);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1560 rb_define_method(cBuffer, "line", line_s_current, 0);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1561 rb_define_method(cBuffer, "line=", set_current_line, 1);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1562
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1563
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564 cVimWindow = rb_define_class_under(mVIM, "Window", rb_cObject);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 rb_define_singleton_method(cVimWindow, "current", window_s_current, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 rb_define_singleton_method(cVimWindow, "count", window_s_count, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 rb_define_singleton_method(cVimWindow, "[]", window_s_aref, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 rb_define_method(cVimWindow, "buffer", window_buffer, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 rb_define_method(cVimWindow, "height", window_height, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 rb_define_method(cVimWindow, "height=", window_set_height, 1);
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1571 rb_define_method(cVimWindow, "width", window_width, 0);
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1572 rb_define_method(cVimWindow, "width=", window_set_width, 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 rb_define_method(cVimWindow, "cursor", window_cursor, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574 rb_define_method(cVimWindow, "cursor=", window_set_cursor, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1575
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 rb_define_virtual_variable("$curbuf", buffer_s_current, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 rb_define_virtual_variable("$curwin", window_s_current, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 }
4369
c9820396afb9 updated for version 7.3.933
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1579
c9820396afb9 updated for version 7.3.933
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1580 void vim_ruby_init(void *stack_start)
c9820396afb9 updated for version 7.3.933
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1581 {
c9820396afb9 updated for version 7.3.933
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1582 /* should get machine stack start address early in main function */
c9820396afb9 updated for version 7.3.933
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1583 ruby_stack_start = stack_start;
c9820396afb9 updated for version 7.3.933
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
1584 }