annotate src/if_ruby.c @ 6954:a958ac497a81 v7.4.795

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