annotate src/if_ruby.c @ 44:8f4b4c298247

Conected to SessionManager
author Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
date Sun, 19 Dec 2010 23:52:03 +0900
parents c16898406ff2
children 67300faee616
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
2 *
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
4 *
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
5 * Ruby interface by Shugo Maeda
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
6 * with improvements by SegPhault (Ryan Paul)
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
7 * with improvements by Jon Maken
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
8 *
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
9 * Do ":help uganda" in Vim to read copying and usage conditions.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
10 * Do ":help credits" in Vim to see a list of people who contributed.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
11 * See README.txt for an overview of the Vim source code.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
12 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
13
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
14 #include <stdio.h>
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
15 #include <string.h>
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
16
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
17 #ifdef HAVE_CONFIG_H
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
18 # include "auto/config.h"
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
19 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
20
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
21 #ifdef _WIN32
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
22 # if !defined(DYNAMIC_RUBY_VER) || (DYNAMIC_RUBY_VER < 18)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
23 # define NT
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
24 # endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
25 # ifndef DYNAMIC_RUBY
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
26 # define IMPORT /* For static dll usage __declspec(dllimport) */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
27 # define RUBYEXTERN __declspec(dllimport)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
28 # endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
29 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
30 #ifndef RUBYEXTERN
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
31 # define RUBYEXTERN extern
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
32 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
33
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
34 #ifdef DYNAMIC_RUBY
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
35 /*
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
36 * This is tricky. In ruby.h there is (inline) function rb_class_of()
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
37 * definition. This function use these variables. But we want function to
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
38 * use dll_* variables.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
39 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
40 # define rb_cFalseClass (*dll_rb_cFalseClass)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
41 # define rb_cFixnum (*dll_rb_cFixnum)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
42 # define rb_cNilClass (*dll_rb_cNilClass)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
43 # define rb_cSymbol (*dll_rb_cSymbol)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
44 # define rb_cTrueClass (*dll_rb_cTrueClass)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
45 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
46 /*
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
47 * On ver 1.8, all Ruby functions are exported with "__declspec(dllimport)"
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
48 * in ruby.h. But it causes trouble for these variables, because it is
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
49 * defined in this file. When defined this RUBY_EXPORT it modified to
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
50 * "extern" and be able to avoid this problem.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
51 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
52 # define RUBY_EXPORT
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
53 # endif
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
54
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
55 #if !(defined(WIN32) || defined(_WIN64))
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
56 # include <dlfcn.h>
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
57 # define HINSTANCE void*
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
58 # define RUBY_PROC void*
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
59 # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
60 # define symbol_from_dll dlsym
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
61 # define close_dll dlclose
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
62 #else
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
63 # define RUBY_PROC FARPROC
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
64 # define load_dll vimLoadLib
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
65 # define symbol_from_dll GetProcAddress
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
66 # define close_dll FreeLibrary
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
67 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
68
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
69 #endif /* ifdef DYNAMIC_RUBY */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
70
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
71 /* suggested by Ariya Mizutani */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
72 #if (_MSC_VER == 1200)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
73 # undef _WIN32_WINNT
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
74 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
75
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
76 #if (defined(RUBY_VERSION) && RUBY_VERSION >= 19) \
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
77 || (defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
78 # define RUBY19_OR_LATER 1
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
79 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
80
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
81 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
82 /* Ruby 1.9 defines a number of static functions which use rb_num2long and
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
83 * rb_int2big */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
84 # define rb_num2long rb_num2long_stub
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
85 # define rb_int2big rb_int2big_stub
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
86 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
87
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
88 #include <ruby.h>
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
89 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
90 # include <ruby/encoding.h>
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
91 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
92
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
93 #undef EXTERN
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
94 #undef _
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
95
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
96 /* T_DATA defined both by Ruby and Mac header files, hack around it... */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
97 #if defined(MACOS_X_UNIX) || defined(macintosh)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
98 # define __OPENTRANSPORT__
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
99 # define __OPENTRANSPORTPROTOCOL__
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
100 # define __OPENTRANSPORTPROVIDERS__
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
101 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
102
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
103 /*
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
104 * Backward compatiblity for Ruby 1.8 and earlier.
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
105 * Ruby 1.9 does not provide STR2CSTR, instead StringValuePtr is provided.
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
106 * Ruby 1.9 does not provide RXXX(s)->len and RXXX(s)->ptr, instead
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
107 * RXXX_LEN(s) and RXXX_PTR(s) are provided.
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
108 */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
109 #ifndef StringValuePtr
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
110 # define StringValuePtr(s) STR2CSTR(s)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
111 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
112 #ifndef RARRAY_LEN
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
113 # define RARRAY_LEN(s) RARRAY(s)->len
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
114 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
115 #ifndef RARRAY_PTR
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
116 # define RARRAY_PTR(s) RARRAY(s)->ptr
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
117 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
118 #ifndef RSTRING_LEN
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
119 # define RSTRING_LEN(s) RSTRING(s)->len
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
120 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
121 #ifndef RSTRING_PTR
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
122 # define RSTRING_PTR(s) RSTRING(s)->ptr
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
123 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
124
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
125 #include "vim.h"
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
126 #include "version.h"
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
127
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
128 #if defined(PROTO) && !defined(FEAT_RUBY)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
129 /* Define these to be able to generate the function prototypes. */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
130 # define VALUE int
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
131 # define RUBY_DATA_FUNC int
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
132 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
133
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
134 static int ruby_initialized = 0;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
135 static VALUE objtbl;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
136
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
137 static VALUE mVIM;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
138 static VALUE cBuffer;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
139 static VALUE cVimWindow;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
140 static VALUE eDeletedBufferError;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
141 static VALUE eDeletedWindowError;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
142
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
143 static int ensure_ruby_initialized(void);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
144 static void error_print(int);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
145 static void ruby_io_init(void);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
146 static void ruby_vim_init(void);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
147
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
148 #if defined(DYNAMIC_RUBY) || defined(PROTO)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
149 #ifdef PROTO
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
150 # define HINSTANCE int /* for generating prototypes */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
151 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
152
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
153 /*
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
154 * Wrapper defines
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
155 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
156 #define rb_assoc_new dll_rb_assoc_new
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
157 #define rb_cObject (*dll_rb_cObject)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
158 #define rb_check_type dll_rb_check_type
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
159 #define rb_class_path dll_rb_class_path
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
160 #define rb_data_object_alloc dll_rb_data_object_alloc
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
161 #define rb_define_class_under dll_rb_define_class_under
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
162 #define rb_define_const dll_rb_define_const
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
163 #define rb_define_global_function dll_rb_define_global_function
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
164 #define rb_define_method dll_rb_define_method
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
165 #define rb_define_module dll_rb_define_module
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
166 #define rb_define_module_function dll_rb_define_module_function
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
167 #define rb_define_singleton_method dll_rb_define_singleton_method
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
168 #define rb_define_virtual_variable dll_rb_define_virtual_variable
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
169 #define rb_stdout (*dll_rb_stdout)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
170 #define rb_eArgError (*dll_rb_eArgError)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
171 #define rb_eIndexError (*dll_rb_eIndexError)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
172 #define rb_eRuntimeError (*dll_rb_eRuntimeError)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
173 #define rb_eStandardError (*dll_rb_eStandardError)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
174 #define rb_eval_string_protect dll_rb_eval_string_protect
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
175 #define rb_global_variable dll_rb_global_variable
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
176 #define rb_hash_aset dll_rb_hash_aset
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
177 #define rb_hash_new dll_rb_hash_new
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
178 #define rb_inspect dll_rb_inspect
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
179 #define rb_int2inum dll_rb_int2inum
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
180 #define rb_lastline_get dll_rb_lastline_get
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
181 #define rb_lastline_set dll_rb_lastline_set
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
182 #define rb_load_protect dll_rb_load_protect
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
183 #ifndef RUBY19_OR_LATER
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
184 #define rb_num2long dll_rb_num2long
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
185 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
186 #define rb_num2ulong dll_rb_num2ulong
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
187 #define rb_obj_alloc dll_rb_obj_alloc
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
188 #define rb_obj_as_string dll_rb_obj_as_string
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
189 #define rb_obj_id dll_rb_obj_id
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
190 #define rb_raise dll_rb_raise
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
191 #define rb_str_cat dll_rb_str_cat
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
192 #define rb_str_concat dll_rb_str_concat
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
193 #define rb_str_new dll_rb_str_new
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
194 #ifdef rb_str_new2
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
195 /* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
196 # define need_rb_str_new_cstr 1
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
197 /* Ruby's headers #define rb_str_new_cstr to make use of GCC's
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
198 * __builtin_constant_p extension. */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
199 # undef rb_str_new_cstr
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
200 # define rb_str_new_cstr dll_rb_str_new_cstr
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
201 #else
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
202 # define rb_str_new2 dll_rb_str_new2
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
203 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
204 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
205 # define rb_string_value dll_rb_string_value
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
206 # define rb_string_value_ptr dll_rb_string_value_ptr
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
207 # define rb_float_new dll_rb_float_new
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
208 # define rb_ary_new dll_rb_ary_new
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
209 # define rb_ary_push dll_rb_ary_push
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
210 #else
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
211 # define rb_str2cstr dll_rb_str2cstr
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
212 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
213 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
214 # define rb_errinfo dll_rb_errinfo
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
215 #else
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
216 # define ruby_errinfo (*dll_ruby_errinfo)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
217 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
218 #define ruby_init dll_ruby_init
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
219 #define ruby_init_loadpath dll_ruby_init_loadpath
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
220 #ifdef WIN3264
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
221 # define NtInitialize dll_NtInitialize
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
222 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
223 # define rb_w32_snprintf dll_rb_w32_snprintf
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
224 # endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
225 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
226
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
227 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
228 # define ruby_script dll_ruby_script
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
229 # define rb_enc_find_index dll_rb_enc_find_index
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
230 # define rb_enc_find dll_rb_enc_find
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
231 # define rb_enc_str_new dll_rb_enc_str_new
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
232 # define rb_intern2 dll_rb_intern2
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
233 # define rb_const_remove dll_rb_const_remove
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
234 # define rb_sprintf dll_rb_sprintf
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
235 # define ruby_init_stack dll_ruby_init_stack
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
236 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
237
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
238 /*
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
239 * Pointers for dynamic link
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
240 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
241 static VALUE (*dll_rb_assoc_new) (VALUE, VALUE);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
242 VALUE *dll_rb_cFalseClass;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
243 VALUE *dll_rb_cFixnum;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
244 VALUE *dll_rb_cNilClass;
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
245 static VALUE *dll_rb_cObject;
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
246 VALUE *dll_rb_cSymbol;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
247 VALUE *dll_rb_cTrueClass;
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
248 static void (*dll_rb_check_type) (VALUE,int);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
249 static VALUE (*dll_rb_class_path) (VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
250 static VALUE (*dll_rb_data_object_alloc) (VALUE, void*, RUBY_DATA_FUNC, RUBY_DATA_FUNC);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
251 static VALUE (*dll_rb_define_class_under) (VALUE, const char*, VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
252 static void (*dll_rb_define_const) (VALUE,const char*,VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
253 static void (*dll_rb_define_global_function) (const char*,VALUE(*)(),int);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
254 static void (*dll_rb_define_method) (VALUE,const char*,VALUE(*)(),int);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
255 static VALUE (*dll_rb_define_module) (const char*);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
256 static void (*dll_rb_define_module_function) (VALUE,const char*,VALUE(*)(),int);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
257 static void (*dll_rb_define_singleton_method) (VALUE,const char*,VALUE(*)(),int);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
258 static void (*dll_rb_define_virtual_variable) (const char*,VALUE(*)(),void(*)());
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
259 static VALUE *dll_rb_stdout;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
260 static VALUE *dll_rb_eArgError;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
261 static VALUE *dll_rb_eIndexError;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
262 static VALUE *dll_rb_eRuntimeError;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
263 static VALUE *dll_rb_eStandardError;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
264 static VALUE (*dll_rb_eval_string_protect) (const char*, int*);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
265 static void (*dll_rb_global_variable) (VALUE*);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
266 static VALUE (*dll_rb_hash_aset) (VALUE, VALUE, VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
267 static VALUE (*dll_rb_hash_new) (void);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
268 static VALUE (*dll_rb_inspect) (VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
269 static VALUE (*dll_rb_int2inum) (long);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
270 static VALUE (*dll_rb_int2inum) (long);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
271 static VALUE (*dll_rb_lastline_get) (void);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
272 static void (*dll_rb_lastline_set) (VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
273 static void (*dll_rb_load_protect) (VALUE, int, int*);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
274 static long (*dll_rb_num2long) (VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
275 static unsigned long (*dll_rb_num2ulong) (VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
276 static VALUE (*dll_rb_obj_alloc) (VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
277 static VALUE (*dll_rb_obj_as_string) (VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
278 static VALUE (*dll_rb_obj_id) (VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
279 static void (*dll_rb_raise) (VALUE, const char*, ...);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
280 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
281 static VALUE (*dll_rb_string_value) (volatile VALUE*);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
282 #else
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
283 static char *(*dll_rb_str2cstr) (VALUE,int*);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
284 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
285 static VALUE (*dll_rb_str_cat) (VALUE, const char*, long);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
286 static VALUE (*dll_rb_str_concat) (VALUE, VALUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
287 static VALUE (*dll_rb_str_new) (const char*, long);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
288 #ifdef need_rb_str_new_cstr
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
289 /* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
290 static VALUE (*dll_rb_str_new_cstr) (const char*);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
291 #else
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
292 static VALUE (*dll_rb_str_new2) (const char*);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
293 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
294 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
295 static VALUE (*dll_rb_errinfo) (void);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
296 #else
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
297 static VALUE *dll_ruby_errinfo;
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
298 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
299 static void (*dll_ruby_init) (void);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
300 static void (*dll_ruby_init_loadpath) (void);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
301 #ifdef WIN3264
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
302 static void (*dll_NtInitialize) (int*, char***);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
303 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
304 static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
305 # endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
306 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
307 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
308 static char * (*dll_rb_string_value_ptr) (volatile VALUE*);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
309 static VALUE (*dll_rb_float_new) (double);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
310 static VALUE (*dll_rb_ary_new) (void);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
311 static VALUE (*dll_rb_ary_push) (VALUE, VALUE);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
312 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
313 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
314 static VALUE (*dll_rb_int2big)(SIGNED_VALUE);
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
315 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
316
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
317 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
318 static void (*dll_ruby_script) (const char*);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
319 static int (*dll_rb_enc_find_index) (const char*);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
320 static rb_encoding* (*dll_rb_enc_find) (const char*);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
321 static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
322 static ID (*dll_rb_intern2) (const char*, long);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
323 static void (*dll_Init_prelude) (void);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
324 static VALUE (*dll_rb_const_remove) (VALUE, ID);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
325 static VALUE (*dll_rb_sprintf) (const char*, ...);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
326 static void (*ruby_init_stack)(VALUE*);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
327 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
328
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
329 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
330 SIGNED_VALUE rb_num2long_stub(VALUE x)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
331 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
332 return dll_rb_num2long(x);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
333 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
334 VALUE rb_int2big_stub(SIGNED_VALUE x)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
335 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
336 return dll_rb_int2big(x);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
337 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
338 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
339
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
340 static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
341
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
342 /*
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
343 * Table of name to function pointer of ruby.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
344 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
345 static struct
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
346 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
347 char *name;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
348 RUBY_PROC *ptr;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
349 } ruby_funcname_table[] =
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
350 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
351 {"rb_assoc_new", (RUBY_PROC*)&dll_rb_assoc_new},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
352 {"rb_cFalseClass", (RUBY_PROC*)&dll_rb_cFalseClass},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
353 {"rb_cFixnum", (RUBY_PROC*)&dll_rb_cFixnum},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
354 {"rb_cNilClass", (RUBY_PROC*)&dll_rb_cNilClass},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
355 {"rb_cObject", (RUBY_PROC*)&dll_rb_cObject},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
356 {"rb_cSymbol", (RUBY_PROC*)&dll_rb_cSymbol},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
357 {"rb_cTrueClass", (RUBY_PROC*)&dll_rb_cTrueClass},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
358 {"rb_check_type", (RUBY_PROC*)&dll_rb_check_type},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
359 {"rb_class_path", (RUBY_PROC*)&dll_rb_class_path},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
360 {"rb_data_object_alloc", (RUBY_PROC*)&dll_rb_data_object_alloc},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
361 {"rb_define_class_under", (RUBY_PROC*)&dll_rb_define_class_under},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
362 {"rb_define_const", (RUBY_PROC*)&dll_rb_define_const},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
363 {"rb_define_global_function", (RUBY_PROC*)&dll_rb_define_global_function},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
364 {"rb_define_method", (RUBY_PROC*)&dll_rb_define_method},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
365 {"rb_define_module", (RUBY_PROC*)&dll_rb_define_module},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
366 {"rb_define_module_function", (RUBY_PROC*)&dll_rb_define_module_function},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
367 {"rb_define_singleton_method", (RUBY_PROC*)&dll_rb_define_singleton_method},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
368 {"rb_define_virtual_variable", (RUBY_PROC*)&dll_rb_define_virtual_variable},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
369 {"rb_stdout", (RUBY_PROC*)&dll_rb_stdout},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
370 {"rb_eArgError", (RUBY_PROC*)&dll_rb_eArgError},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
371 {"rb_eIndexError", (RUBY_PROC*)&dll_rb_eIndexError},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
372 {"rb_eRuntimeError", (RUBY_PROC*)&dll_rb_eRuntimeError},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
373 {"rb_eStandardError", (RUBY_PROC*)&dll_rb_eStandardError},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
374 {"rb_eval_string_protect", (RUBY_PROC*)&dll_rb_eval_string_protect},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
375 {"rb_global_variable", (RUBY_PROC*)&dll_rb_global_variable},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
376 {"rb_hash_aset", (RUBY_PROC*)&dll_rb_hash_aset},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
377 {"rb_hash_new", (RUBY_PROC*)&dll_rb_hash_new},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
378 {"rb_inspect", (RUBY_PROC*)&dll_rb_inspect},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
379 {"rb_int2inum", (RUBY_PROC*)&dll_rb_int2inum},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
380 {"rb_lastline_get", (RUBY_PROC*)&dll_rb_lastline_get},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
381 {"rb_lastline_set", (RUBY_PROC*)&dll_rb_lastline_set},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
382 {"rb_load_protect", (RUBY_PROC*)&dll_rb_load_protect},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
383 {"rb_num2long", (RUBY_PROC*)&dll_rb_num2long},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
384 {"rb_num2ulong", (RUBY_PROC*)&dll_rb_num2ulong},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
385 {"rb_obj_alloc", (RUBY_PROC*)&dll_rb_obj_alloc},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
386 {"rb_obj_as_string", (RUBY_PROC*)&dll_rb_obj_as_string},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
387 {"rb_obj_id", (RUBY_PROC*)&dll_rb_obj_id},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
388 {"rb_raise", (RUBY_PROC*)&dll_rb_raise},
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
389 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
390 {"rb_string_value", (RUBY_PROC*)&dll_rb_string_value},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
391 #else
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
392 {"rb_str2cstr", (RUBY_PROC*)&dll_rb_str2cstr},
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
393 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
394 {"rb_str_cat", (RUBY_PROC*)&dll_rb_str_cat},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
395 {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
396 {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new},
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
397 #ifdef need_rb_str_new_cstr
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
398 {"rb_str_new_cstr", (RUBY_PROC*)&dll_rb_str_new_cstr},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
399 #else
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
400 {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2},
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
401 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
402 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
403 {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
404 #else
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
405 {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
406 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
407 {"ruby_init", (RUBY_PROC*)&dll_ruby_init},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
408 {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath},
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
409 #ifdef WIN3264
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
410 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
411 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER < 19
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
412 "NtInitialize",
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
413 # else
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
414 "ruby_sysinit",
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
415 # endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
416 (RUBY_PROC*)&dll_NtInitialize},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
417 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
418 {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
419 # endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
420 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
421 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
422 {"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
423 {"rb_float_new", (RUBY_PROC*)&dll_rb_float_new},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
424 {"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
425 {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
426 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
427 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
428 {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
429 {"ruby_script", (RUBY_PROC*)&dll_ruby_script},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
430 {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
431 {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
432 {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
433 {"rb_intern2", (RUBY_PROC*)&dll_rb_intern2},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
434 {"rb_const_remove", (RUBY_PROC*)&dll_rb_const_remove},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
435 {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
436 {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack},
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
437 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
438 {"", NULL},
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
439 };
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
440
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
441 /*
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
442 * Free ruby.dll
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
443 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
444 static void
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
445 end_dynamic_ruby()
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
446 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
447 if (hinstRuby)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
448 {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
449 close_dll(hinstRuby);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
450 hinstRuby = NULL;
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
451 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
452 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
453
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
454 /*
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
455 * Load library and get all pointers.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
456 * Parameter 'libname' provides name of DLL.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
457 * Return OK or FAIL.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
458 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
459 static int
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
460 ruby_runtime_link_init(char *libname, int verbose)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
461 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
462 int i;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
463
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
464 if (hinstRuby)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
465 return OK;
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
466 hinstRuby = load_dll(libname);
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
467 if (!hinstRuby)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
468 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
469 if (verbose)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
470 EMSG2(_(e_loadlib), libname);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
471 return FAIL;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
472 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
473
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
474 for (i = 0; ruby_funcname_table[i].ptr; ++i)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
475 {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
476 if (!(*ruby_funcname_table[i].ptr = symbol_from_dll(hinstRuby,
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
477 ruby_funcname_table[i].name)))
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
478 {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
479 close_dll(hinstRuby);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
480 hinstRuby = NULL;
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
481 if (verbose)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
482 EMSG2(_(e_loadfunc), ruby_funcname_table[i].name);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
483 return FAIL;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
484 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
485 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
486 return OK;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
487 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
488
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
489 /*
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
490 * If ruby is enabled (there is installed ruby on Windows system) return TRUE,
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
491 * else FALSE.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
492 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
493 int
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
494 ruby_enabled(verbose)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
495 int verbose;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
496 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
497 return ruby_runtime_link_init(DYNAMIC_RUBY_DLL, verbose) == OK;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
498 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
499 #endif /* defined(DYNAMIC_RUBY) || defined(PROTO) */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
500
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
501 void
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
502 ruby_end()
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
503 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
504 #ifdef DYNAMIC_RUBY
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
505 end_dynamic_ruby();
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
506 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
507 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
508
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
509 void ex_ruby(exarg_T *eap)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
510 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
511 int state;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
512 char *script = NULL;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
513
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
514 script = (char *)script_get(eap, eap->arg);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
515 if (!eap->skip && ensure_ruby_initialized())
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
516 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
517 if (script == NULL)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
518 rb_eval_string_protect((char *)eap->arg, &state);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
519 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
520 rb_eval_string_protect(script, &state);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
521 if (state)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
522 error_print(state);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
523 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
524 vim_free(script);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
525 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
526
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
527 /*
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
528 * In Ruby 1.9 or later, ruby String object has encoding.
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
529 * conversion buffer string of vim to ruby String object using
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
530 * VIM encoding option.
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
531 */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
532 static VALUE
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
533 vim_str2rb_enc_str(const char *s)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
534 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
535 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
536 int isnum;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
537 long lval;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
538 char_u *sval;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
539 rb_encoding *enc;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
540
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
541 isnum = get_option_value((char_u *)"enc", &lval, &sval, 0);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
542 if (isnum == 0)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
543 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
544 enc = rb_enc_find((char *)sval);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
545 vim_free(sval);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
546 if (enc) {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
547 return rb_enc_str_new(s, strlen(s), enc);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
548 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
549 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
550 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
551 return rb_str_new2(s);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
552 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
553
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
554 static VALUE
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
555 eval_enc_string_protect(const char *str, int *state)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
556 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
557 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
558 int isnum;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
559 long lval;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
560 char_u *sval;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
561 rb_encoding *enc;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
562 VALUE v;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
563
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
564 isnum = get_option_value((char_u *)"enc", &lval, &sval, 0);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
565 if (isnum == 0)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
566 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
567 enc = rb_enc_find((char *)sval);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
568 vim_free(sval);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
569 if (enc)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
570 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
571 v = rb_sprintf("#-*- coding:%s -*-\n%s", rb_enc_name(enc), str);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
572 return rb_eval_string_protect(StringValuePtr(v), state);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
573 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
574 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
575 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
576 return rb_eval_string_protect(str, state);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
577 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
578
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
579 void ex_rubydo(exarg_T *eap)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
580 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
581 int state;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
582 linenr_T i;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
583
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
584 if (ensure_ruby_initialized())
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
585 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
586 if (u_save(eap->line1 - 1, eap->line2 + 1) != OK)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
587 return;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
588 for (i = eap->line1; i <= eap->line2; i++) {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
589 VALUE line;
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
590
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
591 line = vim_str2rb_enc_str((char *)ml_get(i));
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
592 rb_lastline_set(line);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
593 eval_enc_string_protect((char *) eap->arg, &state);
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
594 if (state) {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
595 error_print(state);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
596 break;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
597 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
598 line = rb_lastline_get();
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
599 if (!NIL_P(line)) {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
600 if (TYPE(line) != T_STRING) {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
601 EMSG(_("E265: $_ must be an instance of String"));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
602 return;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
603 }
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
604 ml_replace(i, (char_u *) StringValuePtr(line), 1);
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
605 changed();
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
606 #ifdef SYNTAX_HL
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
607 syn_changed(i); /* recompute syntax hl. for this line */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
608 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
609 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
610 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
611 check_cursor();
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
612 update_curbuf(NOT_VALID);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
613 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
614 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
615
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
616 void ex_rubyfile(exarg_T *eap)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
617 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
618 int state;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
619
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
620 if (ensure_ruby_initialized())
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
621 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
622 rb_load_protect(rb_str_new2((char *) eap->arg), 0, &state);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
623 if (state) error_print(state);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
624 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
625 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
626
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
627 void ruby_buffer_free(buf_T *buf)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
628 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
629 if (buf->b_ruby_ref)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
630 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
631 rb_hash_aset(objtbl, rb_obj_id((VALUE) buf->b_ruby_ref), Qnil);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
632 RDATA(buf->b_ruby_ref)->data = NULL;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
633 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
634 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
635
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
636 void ruby_window_free(win_T *win)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
637 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
638 if (win->w_ruby_ref)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
639 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
640 rb_hash_aset(objtbl, rb_obj_id((VALUE) win->w_ruby_ref), Qnil);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
641 RDATA(win->w_ruby_ref)->data = NULL;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
642 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
643 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
644
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
645 static int ensure_ruby_initialized(void)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
646 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
647 if (!ruby_initialized)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
648 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
649 #ifdef DYNAMIC_RUBY
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
650 if (ruby_enabled(TRUE))
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
651 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
652 #endif
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
653 #ifdef _WIN32
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
654 /* suggested by Ariya Mizutani */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
655 int argc = 1;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
656 char *argv[] = {"gvim.exe"};
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
657 NtInitialize(&argc, &argv);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
658 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
659 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
660 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
661 RUBY_INIT_STACK;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
662 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
663 ruby_init();
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
664 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
665 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
666 ruby_script("vim-ruby");
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
667 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
668 ruby_init_loadpath();
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
669 ruby_io_init();
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
670 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
671 rb_enc_find_index("encdb");
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
672
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
673 /* This avoids the error "Encoding::ConverterNotFoundError: code
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
674 * converter not found (UTF-16LE to ASCII-8BIT)". */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
675 rb_define_module("Gem");
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
676 rb_const_remove(rb_cObject, rb_intern2("TMP_RUBY_PREFIX", 15));
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
677 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
678 ruby_vim_init();
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
679 ruby_initialized = 1;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
680 #ifdef DYNAMIC_RUBY
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
681 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
682 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
683 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
684 EMSG(_("E266: Sorry, this command is disabled, the Ruby library could not be loaded."));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
685 return 0;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
686 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
687 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
688 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
689 return ruby_initialized;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
690 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
691
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
692 static void error_print(int state)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
693 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
694 #ifndef DYNAMIC_RUBY
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
695 #if !(defined(RUBY_VERSION) && RUBY_VERSION >= 19) \
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
696 && !(defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
697 RUBYEXTERN VALUE ruby_errinfo;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
698 #endif
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
699 #endif
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
700 VALUE eclass;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
701 VALUE einfo;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
702 char buff[BUFSIZ];
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
703
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
704 #define TAG_RETURN 0x1
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
705 #define TAG_BREAK 0x2
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
706 #define TAG_NEXT 0x3
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
707 #define TAG_RETRY 0x4
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
708 #define TAG_REDO 0x5
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
709 #define TAG_RAISE 0x6
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
710 #define TAG_THROW 0x7
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
711 #define TAG_FATAL 0x8
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
712 #define TAG_MASK 0xf
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
713
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
714 switch (state) {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
715 case TAG_RETURN:
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
716 EMSG(_("E267: unexpected return"));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
717 break;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
718 case TAG_NEXT:
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
719 EMSG(_("E268: unexpected next"));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
720 break;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
721 case TAG_BREAK:
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
722 EMSG(_("E269: unexpected break"));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
723 break;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
724 case TAG_REDO:
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
725 EMSG(_("E270: unexpected redo"));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
726 break;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
727 case TAG_RETRY:
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
728 EMSG(_("E271: retry outside of rescue clause"));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
729 break;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
730 case TAG_RAISE:
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
731 case TAG_FATAL:
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
732 #ifdef RUBY19_OR_LATER
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
733 eclass = CLASS_OF(rb_errinfo());
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
734 einfo = rb_obj_as_string(rb_errinfo());
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
735 #else
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
736 eclass = CLASS_OF(ruby_errinfo);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
737 einfo = rb_obj_as_string(ruby_errinfo);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
738 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
739 if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
740 EMSG(_("E272: unhandled exception"));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
741 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
742 else {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
743 VALUE epath;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
744 char *p;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
745
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
746 epath = rb_class_path(eclass);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
747 vim_snprintf(buff, BUFSIZ, "%s: %s",
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
748 RSTRING_PTR(epath), RSTRING_PTR(einfo));
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
749 p = strchr(buff, '\n');
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
750 if (p) *p = '\0';
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
751 EMSG(buff);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
752 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
753 break;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
754 default:
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
755 vim_snprintf(buff, BUFSIZ, _("E273: unknown longjmp status %d"), state);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
756 EMSG(buff);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
757 break;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
758 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
759 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
760
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
761 static VALUE vim_message(VALUE self UNUSED, VALUE str)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
762 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
763 char *buff, *p;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
764
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
765 str = rb_obj_as_string(str);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
766 buff = ALLOCA_N(char, RSTRING_LEN(str));
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
767 strcpy(buff, RSTRING_PTR(str));
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
768 p = strchr(buff, '\n');
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
769 if (p) *p = '\0';
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
770 MSG(buff);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
771 return Qnil;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
772 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
773
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
774 static VALUE vim_set_option(VALUE self UNUSED, VALUE str)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
775 {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
776 do_set((char_u *)StringValuePtr(str), 0);
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
777 update_screen(NOT_VALID);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
778 return Qnil;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
779 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
780
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
781 static VALUE vim_command(VALUE self UNUSED, VALUE str)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
782 {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
783 do_cmdline_cmd((char_u *)StringValuePtr(str));
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
784 return Qnil;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
785 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
786
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
787 #ifdef FEAT_EVAL
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
788 static VALUE vim_to_ruby(typval_T *tv)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
789 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
790 VALUE result = Qnil;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
791
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
792 if (tv->v_type == VAR_STRING)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
793 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
794 result = rb_str_new2(tv->vval.v_string == NULL
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
795 ? "" : (char *)(tv->vval.v_string));
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
796 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
797 else if (tv->v_type == VAR_NUMBER)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
798 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
799 result = INT2NUM(tv->vval.v_number);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
800 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
801 # ifdef FEAT_FLOAT
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
802 else if (tv->v_type == VAR_FLOAT)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
803 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
804 result = rb_float_new(tv->vval.v_float);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
805 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
806 # endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
807 else if (tv->v_type == VAR_LIST)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
808 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
809 list_T *list = tv->vval.v_list;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
810 listitem_T *curr;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
811
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
812 result = rb_ary_new();
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
813
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
814 if (list != NULL)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
815 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
816 for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
817 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
818 rb_ary_push(result, vim_to_ruby(&curr->li_tv));
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
819 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
820 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
821 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
822 else if (tv->v_type == VAR_DICT)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
823 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
824 result = rb_hash_new();
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
825
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
826 if (tv->vval.v_dict != NULL)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
827 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
828 hashtab_T *ht = &tv->vval.v_dict->dv_hashtab;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
829 long_u todo = ht->ht_used;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
830 hashitem_T *hi;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
831 dictitem_T *di;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
832
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
833 for (hi = ht->ht_array; todo > 0; ++hi)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
834 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
835 if (!HASHITEM_EMPTY(hi))
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
836 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
837 --todo;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
838
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
839 di = dict_lookup(hi);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
840 rb_hash_aset(result, rb_str_new2((char *)hi->hi_key),
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
841 vim_to_ruby(&di->di_tv));
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
842 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
843 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
844 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
845 } /* else return Qnil; */
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
846
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
847 return result;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
848 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
849 #endif
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
850
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
851 static VALUE vim_evaluate(VALUE self UNUSED, VALUE str)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
852 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
853 #ifdef FEAT_EVAL
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
854 typval_T *tv;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
855 VALUE result;
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
856
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
857 tv = eval_expr((char_u *)StringValuePtr(str), NULL);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
858 if (tv == NULL)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
859 {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
860 return Qnil;
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
861 }
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
862 result = vim_to_ruby(tv);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
863
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
864 free_tv(tv);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
865
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
866 return result;
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
867 #else
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
868 return Qnil;
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
869 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
870 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
871
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
872 static VALUE buffer_new(buf_T *buf)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
873 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
874 if (buf->b_ruby_ref)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
875 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
876 return (VALUE) buf->b_ruby_ref;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
877 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
878 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
879 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
880 VALUE obj = Data_Wrap_Struct(cBuffer, 0, 0, buf);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
881 buf->b_ruby_ref = (void *) obj;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
882 rb_hash_aset(objtbl, rb_obj_id(obj), obj);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
883 return obj;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
884 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
885 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
886
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
887 static buf_T *get_buf(VALUE obj)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
888 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
889 buf_T *buf;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
890
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
891 Data_Get_Struct(obj, buf_T, buf);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
892 if (buf == NULL)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
893 rb_raise(eDeletedBufferError, "attempt to refer to deleted buffer");
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
894 return buf;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
895 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
896
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
897 static VALUE buffer_s_current()
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
898 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
899 return buffer_new(curbuf);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
900 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
901
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
902 static VALUE buffer_s_count()
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
903 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
904 buf_T *b;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
905 int n = 0;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
906
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
907 for (b = firstbuf; b != NULL; b = b->b_next)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
908 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
909 /* Deleted buffers should not be counted
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
910 * SegPhault - 01/07/05 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
911 if (b->b_p_bl)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
912 n++;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
913 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
914
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
915 return INT2NUM(n);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
916 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
917
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
918 static VALUE buffer_s_aref(VALUE self UNUSED, VALUE num)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
919 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
920 buf_T *b;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
921 int n = NUM2INT(num);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
922
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
923 for (b = firstbuf; b != NULL; b = b->b_next)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
924 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
925 /* Deleted buffers should not be counted
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
926 * SegPhault - 01/07/05 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
927 if (!b->b_p_bl)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
928 continue;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
929
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
930 if (n == 0)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
931 return buffer_new(b);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
932
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
933 n--;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
934 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
935 return Qnil;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
936 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
937
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
938 static VALUE buffer_name(VALUE self)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
939 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
940 buf_T *buf = get_buf(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
941
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
942 return buf->b_ffname ? rb_str_new2((char *)buf->b_ffname) : Qnil;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
943 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
944
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
945 static VALUE buffer_number(VALUE self)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
946 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
947 buf_T *buf = get_buf(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
948
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
949 return INT2NUM(buf->b_fnum);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
950 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
951
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
952 static VALUE buffer_count(VALUE self)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
953 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
954 buf_T *buf = get_buf(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
955
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
956 return INT2NUM(buf->b_ml.ml_line_count);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
957 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
958
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
959 static VALUE get_buffer_line(buf_T *buf, linenr_T n)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
960 {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
961 if (n <= 0 || n > buf->b_ml.ml_line_count)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
962 rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
963 return vim_str2rb_enc_str((char *)ml_get_buf(buf, n, FALSE));
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
964 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
965
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
966 static VALUE buffer_aref(VALUE self, VALUE num)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
967 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
968 buf_T *buf = get_buf(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
969
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
970 if (buf != NULL)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
971 return get_buffer_line(buf, (linenr_T)NUM2LONG(num));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
972 return Qnil; /* For stop warning */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
973 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
974
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
975 static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
976 {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
977 char *line = StringValuePtr(str);
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
978 aco_save_T aco;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
979
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
980 if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
981 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
982 /* set curwin/curbuf for "buf" and save some things */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
983 aucmd_prepbuf(&aco, buf);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
984
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
985 if (u_savesub(n) == OK) {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
986 ml_replace(n, (char_u *)line, TRUE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
987 changed();
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
988 #ifdef SYNTAX_HL
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
989 syn_changed(n); /* recompute syntax hl. for this line */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
990 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
991 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
992
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
993 /* restore curwin/curbuf and a few other things */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
994 aucmd_restbuf(&aco);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
995 /* Careful: autocommands may have made "buf" invalid! */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
996
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
997 update_curbuf(NOT_VALID);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
998 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
999 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1000 {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1001 rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1002 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1003 return str;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1004 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1005
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1006 static VALUE buffer_aset(VALUE self, VALUE num, VALUE str)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1007 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1008 buf_T *buf = get_buf(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1009
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1010 if (buf != NULL)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1011 return set_buffer_line(buf, (linenr_T)NUM2LONG(num), str);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1012 return str;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1013 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1014
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1015 static VALUE buffer_delete(VALUE self, VALUE num)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1016 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1017 buf_T *buf = get_buf(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1018 long n = NUM2LONG(num);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1019 aco_save_T aco;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1020
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1021 if (n > 0 && n <= buf->b_ml.ml_line_count)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1022 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1023 /* set curwin/curbuf for "buf" and save some things */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1024 aucmd_prepbuf(&aco, buf);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1025
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1026 if (u_savedel(n, 1) == OK) {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1027 ml_delete(n, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1028
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1029 /* Changes to non-active buffers should properly refresh
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1030 * SegPhault - 01/09/05 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1031 deleted_lines_mark(n, 1L);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1032
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1033 changed();
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1034 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1035
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1036 /* restore curwin/curbuf and a few other things */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1037 aucmd_restbuf(&aco);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1038 /* Careful: autocommands may have made "buf" invalid! */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1039
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1040 update_curbuf(NOT_VALID);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1041 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1042 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1043 {
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1044 rb_raise(rb_eIndexError, "line number %ld out of range", n);
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1045 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1046 return Qnil;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1047 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1048
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1049 static VALUE buffer_append(VALUE self, VALUE num, VALUE str)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1050 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1051 buf_T *buf = get_buf(self);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1052 char *line = StringValuePtr(str);
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1053 long n = NUM2LONG(num);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1054 aco_save_T aco;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1055
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1056 if (line == NULL)
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1057 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1058 rb_raise(rb_eIndexError, "NULL line");
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1059 }
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1060 else if (n >= 0 && n <= buf->b_ml.ml_line_count)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1061 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1062 /* set curwin/curbuf for "buf" and save some things */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1063 aucmd_prepbuf(&aco, buf);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1064
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1065 if (u_inssub(n + 1) == OK) {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1066 ml_append(n, (char_u *) line, (colnr_T) 0, FALSE);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1067
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1068 /* Changes to non-active buffers should properly refresh screen
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1069 * SegPhault - 12/20/04 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1070 appended_lines_mark(n, 1L);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1071
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1072 changed();
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1073 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1074
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1075 /* restore curwin/curbuf and a few other things */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1076 aucmd_restbuf(&aco);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1077 /* Careful: autocommands may have made "buf" invalid! */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1078
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1079 update_curbuf(NOT_VALID);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1080 }
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1081 else
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1082 {
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1083 rb_raise(rb_eIndexError, "line number %ld out of range", n);
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1084 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1085 return str;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1086 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1087
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1088 static VALUE window_new(win_T *win)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1089 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1090 if (win->w_ruby_ref)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1091 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1092 return (VALUE) win->w_ruby_ref;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1093 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1094 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1095 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1096 VALUE obj = Data_Wrap_Struct(cVimWindow, 0, 0, win);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1097 win->w_ruby_ref = (void *) obj;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1098 rb_hash_aset(objtbl, rb_obj_id(obj), obj);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1099 return obj;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1100 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1101 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1102
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1103 static win_T *get_win(VALUE obj)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1104 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1105 win_T *win;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1106
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1107 Data_Get_Struct(obj, win_T, win);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1108 if (win == NULL)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1109 rb_raise(eDeletedWindowError, "attempt to refer to deleted window");
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1110 return win;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1111 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1112
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1113 static VALUE window_s_current()
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1114 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1115 return window_new(curwin);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1116 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1117
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1118 /*
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1119 * Added line manipulation functions
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1120 * SegPhault - 03/07/05
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1121 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1122 static VALUE line_s_current()
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1123 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1124 return get_buffer_line(curbuf, curwin->w_cursor.lnum);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1125 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1126
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1127 static VALUE set_current_line(VALUE self UNUSED, VALUE str)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1128 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1129 return set_buffer_line(curbuf, curwin->w_cursor.lnum, str);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1130 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1131
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1132 static VALUE current_line_number()
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1133 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1134 return INT2FIX((int)curwin->w_cursor.lnum);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1135 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1136
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1137
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1138
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1139 static VALUE window_s_count()
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1140 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1141 #ifdef FEAT_WINDOWS
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1142 win_T *w;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1143 int n = 0;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1144
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1145 for (w = firstwin; w != NULL; w = w->w_next)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1146 n++;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1147 return INT2NUM(n);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1148 #else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1149 return INT2NUM(1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1150 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1151 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1152
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1153 static VALUE window_s_aref(VALUE self UNUSED, VALUE num)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1154 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1155 win_T *w;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1156 int n = NUM2INT(num);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1157
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1158 #ifndef FEAT_WINDOWS
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1159 w = curwin;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1160 #else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1161 for (w = firstwin; w != NULL; w = w->w_next, --n)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1162 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1163 if (n == 0)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1164 return window_new(w);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1165 return Qnil;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1166 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1167
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1168 static VALUE window_buffer(VALUE self)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1169 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1170 win_T *win = get_win(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1171
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1172 return buffer_new(win->w_buffer);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1173 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1174
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1175 static VALUE window_height(VALUE self)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1176 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1177 win_T *win = get_win(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1178
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1179 return INT2NUM(win->w_height);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1180 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1181
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1182 static VALUE window_set_height(VALUE self, VALUE height)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1183 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1184 win_T *win = get_win(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1185 win_T *savewin = curwin;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1186
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1187 curwin = win;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1188 win_setheight(NUM2INT(height));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1189 curwin = savewin;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1190 return height;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1191 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1192
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1193 static VALUE window_width(VALUE self)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1194 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1195 win_T *win = get_win(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1196
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1197 return INT2NUM(win->w_width);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1198 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1199
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1200 static VALUE window_set_width(VALUE self, VALUE width)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1201 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1202 win_T *win = get_win(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1203 win_T *savewin = curwin;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1204
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1205 curwin = win;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1206 win_setwidth(NUM2INT(width));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1207 curwin = savewin;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1208 return width;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1209 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1210
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1211 static VALUE window_cursor(VALUE self)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1212 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1213 win_T *win = get_win(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1214
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1215 return rb_assoc_new(INT2NUM(win->w_cursor.lnum), INT2NUM(win->w_cursor.col));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1216 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1217
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1218 static VALUE window_set_cursor(VALUE self, VALUE pos)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1219 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1220 VALUE lnum, col;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1221 win_T *win = get_win(self);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1222
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1223 Check_Type(pos, T_ARRAY);
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1224 if (RARRAY_LEN(pos) != 2)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1225 rb_raise(rb_eArgError, "array length must be 2");
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1226 lnum = RARRAY_PTR(pos)[0];
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1227 col = RARRAY_PTR(pos)[1];
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1228 win->w_cursor.lnum = NUM2LONG(lnum);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1229 win->w_cursor.col = NUM2UINT(col);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1230 check_cursor(); /* put cursor on an existing line */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1231 update_screen(NOT_VALID);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1232 return Qnil;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1233 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1234
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1235 static VALUE f_p(int argc, VALUE *argv, VALUE self UNUSED)
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1236 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1237 int i;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1238 VALUE str = rb_str_new("", 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1239
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1240 for (i = 0; i < argc; i++) {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1241 if (i > 0) rb_str_cat(str, ", ", 2);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1242 rb_str_concat(str, rb_inspect(argv[i]));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1243 }
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1244 MSG(RSTRING_PTR(str));
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1245 return Qnil;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1246 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1247
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1248 static void ruby_io_init(void)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1249 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1250 #ifndef DYNAMIC_RUBY
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1251 RUBYEXTERN VALUE rb_stdout;
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1252 #endif
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1253
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1254 rb_stdout = rb_obj_alloc(rb_cObject);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1255 rb_define_singleton_method(rb_stdout, "write", vim_message, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1256 rb_define_global_function("p", f_p, -1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1257 }
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1258
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1259 static void ruby_vim_init(void)
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1260 {
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1261 objtbl = rb_hash_new();
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1262 rb_global_variable(&objtbl);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1263
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1264 /* The Vim module used to be called "VIM", but "Vim" is better. Make an
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1265 * alias "VIM" for backwards compatiblity. */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1266 mVIM = rb_define_module("Vim");
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1267 rb_define_const(rb_cObject, "VIM", mVIM);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1268 rb_define_const(mVIM, "VERSION_MAJOR", INT2NUM(VIM_VERSION_MAJOR));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1269 rb_define_const(mVIM, "VERSION_MINOR", INT2NUM(VIM_VERSION_MINOR));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1270 rb_define_const(mVIM, "VERSION_BUILD", INT2NUM(VIM_VERSION_BUILD));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1271 rb_define_const(mVIM, "VERSION_PATCHLEVEL", INT2NUM(VIM_VERSION_PATCHLEVEL));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1272 rb_define_const(mVIM, "VERSION_SHORT", rb_str_new2(VIM_VERSION_SHORT));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1273 rb_define_const(mVIM, "VERSION_MEDIUM", rb_str_new2(VIM_VERSION_MEDIUM));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1274 rb_define_const(mVIM, "VERSION_LONG", rb_str_new2(VIM_VERSION_LONG));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1275 rb_define_const(mVIM, "VERSION_LONG_DATE", rb_str_new2(VIM_VERSION_LONG_DATE));
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1276 rb_define_module_function(mVIM, "message", vim_message, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1277 rb_define_module_function(mVIM, "set_option", vim_set_option, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1278 rb_define_module_function(mVIM, "command", vim_command, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1279 rb_define_module_function(mVIM, "evaluate", vim_evaluate, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1280
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1281 eDeletedBufferError = rb_define_class_under(mVIM, "DeletedBufferError",
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1282 rb_eStandardError);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1283 eDeletedWindowError = rb_define_class_under(mVIM, "DeletedWindowError",
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1284 rb_eStandardError);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1285
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1286 cBuffer = rb_define_class_under(mVIM, "Buffer", rb_cObject);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1287 rb_define_singleton_method(cBuffer, "current", buffer_s_current, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1288 rb_define_singleton_method(cBuffer, "count", buffer_s_count, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1289 rb_define_singleton_method(cBuffer, "[]", buffer_s_aref, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1290 rb_define_method(cBuffer, "name", buffer_name, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1291 rb_define_method(cBuffer, "number", buffer_number, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1292 rb_define_method(cBuffer, "count", buffer_count, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1293 rb_define_method(cBuffer, "length", buffer_count, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1294 rb_define_method(cBuffer, "[]", buffer_aref, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1295 rb_define_method(cBuffer, "[]=", buffer_aset, 2);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1296 rb_define_method(cBuffer, "delete", buffer_delete, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1297 rb_define_method(cBuffer, "append", buffer_append, 2);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1298
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1299 /* Added line manipulation functions
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1300 * SegPhault - 03/07/05 */
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1301 rb_define_method(cBuffer, "line_number", current_line_number, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1302 rb_define_method(cBuffer, "line", line_s_current, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1303 rb_define_method(cBuffer, "line=", set_current_line, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1304
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1305
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1306 cVimWindow = rb_define_class_under(mVIM, "Window", rb_cObject);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1307 rb_define_singleton_method(cVimWindow, "current", window_s_current, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1308 rb_define_singleton_method(cVimWindow, "count", window_s_count, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1309 rb_define_singleton_method(cVimWindow, "[]", window_s_aref, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1310 rb_define_method(cVimWindow, "buffer", window_buffer, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1311 rb_define_method(cVimWindow, "height", window_height, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1312 rb_define_method(cVimWindow, "height=", window_set_height, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1313 rb_define_method(cVimWindow, "width", window_width, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1314 rb_define_method(cVimWindow, "width=", window_set_width, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1315 rb_define_method(cVimWindow, "cursor", window_cursor, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1316 rb_define_method(cVimWindow, "cursor=", window_set_cursor, 1);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1317
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1318 rb_define_virtual_variable("$curbuf", buffer_s_current, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1319 rb_define_virtual_variable("$curwin", window_s_current, 0);
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1320 }