Mercurial > vim
annotate src/if_mzsch.c @ 21457:26bdc67a3918 v8.2.1279
patch 8.2.1279: some tests on Travis have EXITFREE duplicated
Commit: https://github.com/vim/vim/commit/8d5f6af5e5a5edfd3fa95f33540c204f4e74331e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jul 23 15:50:40 2020 +0200
patch 8.2.1279: some tests on Travis have EXITFREE duplicated
Problem: Some tests on Travis have EXITFREE duplicated.
Solution: Remove EXITFREE from shadowopt. Add "shadow" to job name.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 23 Jul 2020 16:00:03 +0200 |
parents | d571231175b4 |
children | 35921b7fc07a |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9961
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
14 | 2 * |
151 | 3 * MzScheme interface by Sergey Khorev <sergey.khorev@gmail.com> |
4074 | 4 * Based on work by Brent Fulgham <bfulgham@debian.org> |
14 | 5 * (Based on lots of help from Matthew Flatt) |
6 * | |
7 * This consists of six parts: | |
8 * 1. MzScheme interpreter main program | |
9 * 2. Routines that handle the external interface between MzScheme and | |
10 * Vim. | |
11 * 3. MzScheme input/output handlers: writes output via [e]msg(). | |
12 * 4. Implementation of the Vim Features for MzScheme | |
13 * 5. Vim Window-related Manipulation Functions. | |
14 * 6. Vim Buffer-related Manipulation Functions | |
15 * | |
16 * NOTES | |
17 * 1. Memory, allocated with scheme_malloc*, need not to be freed explicitly, | |
18 * garbage collector will do it self | |
19 * 2. Requires at least NORMAL features. I can't imagine why one may want | |
20 * to build with SMALL or TINY features but with MzScheme interface. | |
1894 | 21 * 3. I don't use K&R-style functions. Anyways, MzScheme headers are ANSI. |
14 | 22 */ |
23 | |
24 #include "vim.h" | |
1284 | 25 |
14 | 26 #include "if_mzsch.h" |
27 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
28 // Only do the following when the feature is enabled. Needed for "make |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
29 // depend". |
800 | 30 #if defined(FEAT_MZSCHEME) || defined(PROTO) |
31 | |
7813
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
32 #ifdef PROTO |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
33 typedef int Scheme_Object; |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
34 typedef int Scheme_Closed_Prim; |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
35 typedef int Scheme_Env; |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
36 typedef int Scheme_Hash_Table; |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
37 typedef int Scheme_Type; |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
38 typedef int Scheme_Thread; |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
39 typedef int Scheme_Closed_Prim; |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
40 typedef int mzshort; |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
41 typedef int Scheme_Prim; |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
42 typedef int HINSTANCE; |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
43 #endif |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
44 |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
45 /* |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
46 * scheme_register_tls_space is only available on 32-bit Windows until |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
47 * racket-6.3. See |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
48 * http://docs.racket-lang.org/inside/im_memoryalloc.html?q=scheme_register_tls_space |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
49 */ |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
50 #if MZSCHEME_VERSION_MAJOR >= 500 && defined(MSWIN) \ |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
51 && defined(USE_THREAD_LOCAL) \ |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
52 && (!defined(_WIN64) || MZSCHEME_VERSION_MAJOR >= 603) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
53 # define HAVE_TLS_SPACE 1 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
54 #endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
55 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
56 /* |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
57 * Since version 4.x precise GC requires trampolined startup. |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
58 * Futures and places in version 5.x need it too. |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
59 */ |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
60 #if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR >= 400 \ |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
61 || MZSCHEME_VERSION_MAJOR >= 500 \ |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
62 && (defined(MZ_USE_FUTURES) || defined(MZ_USE_PLACES)) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
63 # define TRAMPOLINED_MZVIM_STARTUP |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
64 #endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
65 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
66 // Base data structures |
14 | 67 #define SCHEME_VIMBUFFERP(obj) SAME_TYPE(SCHEME_TYPE(obj), mz_buffer_type) |
68 #define SCHEME_VIMWINDOWP(obj) SAME_TYPE(SCHEME_TYPE(obj), mz_window_type) | |
69 | |
70 typedef struct | |
71 { | |
1894 | 72 Scheme_Object so; |
14 | 73 buf_T *buf; |
74 } vim_mz_buffer; | |
75 | |
76 #define INVALID_BUFFER_VALUE ((buf_T *)(-1)) | |
77 | |
78 typedef struct | |
79 { | |
1894 | 80 Scheme_Object so; |
667 | 81 win_T *win; |
14 | 82 } vim_mz_window; |
83 | |
84 #define INVALID_WINDOW_VALUE ((win_T *)(-1)) | |
85 | |
86 /* | |
87 * Prims that form MzScheme Vim interface | |
88 */ | |
89 typedef struct | |
90 { | |
91 Scheme_Closed_Prim *prim; | |
92 char *name; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
93 int mina; // arity information |
14 | 94 int maxa; |
95 } Vim_Prim; | |
96 | |
97 typedef struct | |
98 { | |
99 char *name; | |
100 Scheme_Object *port; | |
101 } Port_Info; | |
102 | |
103 /* | |
104 *======================================================================== | |
105 * Vim-Control Commands | |
106 *======================================================================== | |
107 */ | |
108 /* | |
109 *======================================================================== | |
110 * Utility functions for the vim/mzscheme interface | |
111 *======================================================================== | |
112 */ | |
274 | 113 #ifdef HAVE_SANDBOX |
114 static Scheme_Object *sandbox_file_guard(int, Scheme_Object **); | |
115 static Scheme_Object *sandbox_network_guard(int, Scheme_Object **); | |
1125 | 116 static void sandbox_check(void); |
274 | 117 #endif |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
118 // Buffer-related commands |
14 | 119 static Scheme_Object *buffer_new(buf_T *buf); |
120 static Scheme_Object *get_buffer_by_num(void *, int, Scheme_Object **); | |
121 static vim_mz_buffer *get_vim_curr_buffer(void); | |
122 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
123 // Window-related commands |
14 | 124 static Scheme_Object *window_new(win_T *win); |
125 static vim_mz_window *get_vim_curr_window(void); | |
126 | |
127 /* | |
128 *======================================================================== | |
129 * Internal Function Prototypes | |
130 *======================================================================== | |
131 */ | |
132 static int vim_error_check(void); | |
133 static int do_mzscheme_command(exarg_T *, void *, Scheme_Closed_Prim *what); | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
134 static int startup_mzscheme(void); |
14 | 135 static char *string_to_line(Scheme_Object *obj); |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
136 #if MZSCHEME_VERSION_MAJOR >= 501 |
4074 | 137 # define OUTPUT_LEN_TYPE intptr_t |
138 #else | |
139 # define OUTPUT_LEN_TYPE long | |
140 #endif | |
141 static void do_output(char *mesg, OUTPUT_LEN_TYPE len); | |
14 | 142 static void do_printf(char *format, ...); |
143 static void do_flush(void); | |
144 static Scheme_Object *_apply_thunk_catch_exceptions( | |
145 Scheme_Object *, Scheme_Object **); | |
146 static Scheme_Object *extract_exn_message(Scheme_Object *v); | |
147 static Scheme_Object *do_eval(void *, int noargc, Scheme_Object **noargv); | |
148 static Scheme_Object *do_load(void *, int noargc, Scheme_Object **noargv); | |
1894 | 149 static void register_vim_exn(void); |
14 | 150 static vim_mz_buffer *get_buffer_arg(const char *fname, int argnum, |
151 int argc, Scheme_Object **argv); | |
152 static vim_mz_window *get_window_arg(const char *fname, int argnum, | |
153 int argc, Scheme_Object **argv); | |
154 static int line_in_range(linenr_T, buf_T *); | |
155 static void check_line_range(linenr_T, buf_T *); | |
156 static void mz_fix_cursor(int lo, int hi, int extra); | |
157 | |
1894 | 158 static int eval_with_exn_handling(void *, Scheme_Closed_Prim *, |
159 Scheme_Object **ret); | |
160 static void make_modules(void); | |
161 static void init_exn_catching_apply(void); | |
162 static int mzscheme_env_main(Scheme_Env *env, int argc, char **argv); | |
163 static int mzscheme_init(void); | |
164 #ifdef FEAT_EVAL | |
4074 | 165 static Scheme_Object *vim_to_mzscheme(typval_T *vim_value); |
166 static Scheme_Object *vim_to_mzscheme_impl(typval_T *vim_value, int depth, | |
1894 | 167 Scheme_Hash_Table *visited); |
4074 | 168 static int mzscheme_to_vim(Scheme_Object *obj, typval_T *tv); |
169 static int mzscheme_to_vim_impl(Scheme_Object *obj, typval_T *tv, int depth, | |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
170 Scheme_Hash_Table *visited); |
4074 | 171 static Scheme_Object *vim_funcref(void *data, int argc, Scheme_Object **argv); |
1894 | 172 #endif |
173 | |
174 #ifdef MZ_PRECISE_GC | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
175 static int buffer_size_proc(void *obj UNUSED) |
1894 | 176 { |
177 return gcBYTES_TO_WORDS(sizeof(vim_mz_buffer)); | |
178 } | |
179 static int buffer_mark_proc(void *obj) | |
180 { | |
181 return buffer_size_proc(obj); | |
182 } | |
183 static int buffer_fixup_proc(void *obj) | |
184 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
185 // apparently not needed as the object will be uncollectable while |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
186 // the buffer is alive |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
187 // vim_mz_buffer* buf = (vim_mz_buffer*) obj; |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
188 // buf->buf->b_mzscheme_ref = GC_fixup_self(obj); |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
189 |
1894 | 190 return buffer_size_proc(obj); |
191 } | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
192 static int window_size_proc(void *obj UNUSED) |
1894 | 193 { |
194 return gcBYTES_TO_WORDS(sizeof(vim_mz_window)); | |
195 } | |
196 static int window_mark_proc(void *obj) | |
197 { | |
198 return window_size_proc(obj); | |
199 } | |
200 static int window_fixup_proc(void *obj) | |
201 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
202 // apparently not needed as the object will be uncollectable while |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
203 // the window is alive |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
204 // vim_mz_window* win = (vim_mz_window*) obj; |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
205 // win->win->w_mzscheme_ref = GC_fixup_self(obj); |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
206 // |
1894 | 207 return window_size_proc(obj); |
208 } | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
209 // with precise GC, w_mzscheme_ref and b_mzscheme_ref are immobile boxes |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
210 // containing pointers to a window/buffer |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
211 // with conservative GC these are simply pointers |
4074 | 212 # define WINDOW_REF(win) *(vim_mz_window **)((win)->w_mzscheme_ref) |
213 # define BUFFER_REF(buf) *(vim_mz_buffer **)((buf)->b_mzscheme_ref) | |
214 #else | |
215 # define WINDOW_REF(win) (vim_mz_window *)((win)->w_mzscheme_ref) | |
216 # define BUFFER_REF(buf) (vim_mz_buffer *)((buf)->b_mzscheme_ref) | |
1894 | 217 #endif |
14 | 218 |
7813
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
219 #if defined(DYNAMIC_MZSCHEME) || defined(PROTO) |
137 | 220 static Scheme_Object *dll_scheme_eof; |
221 static Scheme_Object *dll_scheme_false; | |
222 static Scheme_Object *dll_scheme_void; | |
223 static Scheme_Object *dll_scheme_null; | |
224 static Scheme_Object *dll_scheme_true; | |
225 | |
226 static Scheme_Thread **dll_scheme_current_thread_ptr; | |
227 | |
228 static void (**dll_scheme_console_printf_ptr)(char *str, ...); | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
229 static void (**dll_scheme_console_output_ptr)(char *str, OUTPUT_LEN_TYPE len); |
137 | 230 static void (**dll_scheme_notify_multithread_ptr)(int on); |
231 | |
232 static void *(*dll_GC_malloc)(size_t size_in_bytes); | |
233 static void *(*dll_GC_malloc_atomic)(size_t size_in_bytes); | |
234 static Scheme_Env *(*dll_scheme_basic_env)(void); | |
235 static void (*dll_scheme_check_threads)(void); | |
236 static void (*dll_scheme_register_static)(void *ptr, long size); | |
237 static void (*dll_scheme_set_stack_base)(void *base, int no_auto_statics); | |
238 static void (*dll_scheme_add_global)(const char *name, Scheme_Object *val, | |
239 Scheme_Env *env); | |
240 static void (*dll_scheme_add_global_symbol)(Scheme_Object *name, | |
241 Scheme_Object *val, Scheme_Env *env); | |
242 static Scheme_Object *(*dll_scheme_apply)(Scheme_Object *rator, int num_rands, | |
243 Scheme_Object **rands); | |
244 static Scheme_Object *(*dll_scheme_builtin_value)(const char *name); | |
274 | 245 # if MZSCHEME_VERSION_MAJOR >= 299 |
246 static Scheme_Object *(*dll_scheme_byte_string_to_char_string)(Scheme_Object *s); | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
247 static Scheme_Object *(*dll_scheme_make_path)(const char *chars); |
274 | 248 # endif |
137 | 249 static void (*dll_scheme_close_input_port)(Scheme_Object *port); |
250 static void (*dll_scheme_count_lines)(Scheme_Object *port); | |
1284 | 251 #if MZSCHEME_VERSION_MAJOR < 360 |
137 | 252 static Scheme_Object *(*dll_scheme_current_continuation_marks)(void); |
1284 | 253 #else |
254 static Scheme_Object *(*dll_scheme_current_continuation_marks)(Scheme_Object *prompt_tag); | |
255 #endif | |
137 | 256 static void (*dll_scheme_display)(Scheme_Object *obj, Scheme_Object *port); |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
257 static char *(*dll_scheme_display_to_string)(Scheme_Object *obj, OUTPUT_LEN_TYPE *len); |
274 | 258 static int (*dll_scheme_eq)(Scheme_Object *obj1, Scheme_Object *obj2); |
137 | 259 static Scheme_Object *(*dll_scheme_do_eval)(Scheme_Object *obj, |
260 int _num_rands, Scheme_Object **rands, int val); | |
261 static void (*dll_scheme_dont_gc_ptr)(void *p); | |
262 static Scheme_Object *(*dll_scheme_eval)(Scheme_Object *obj, Scheme_Env *env); | |
263 static Scheme_Object *(*dll_scheme_eval_string)(const char *str, | |
264 Scheme_Env *env); | |
344 | 265 static Scheme_Object *(*dll_scheme_eval_string_all)(const char *str, |
137 | 266 Scheme_Env *env, int all); |
267 static void (*dll_scheme_finish_primitive_module)(Scheme_Env *env); | |
151 | 268 # if MZSCHEME_VERSION_MAJOR < 299 |
137 | 269 static char *(*dll_scheme_format)(char *format, int flen, int argc, |
270 Scheme_Object **argv, long *rlen); | |
151 | 271 # else |
272 static char *(*dll_scheme_format_utf8)(char *format, int flen, int argc, | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
273 Scheme_Object **argv, OUTPUT_LEN_TYPE *rlen); |
274 | 274 static Scheme_Object *(*dll_scheme_get_param)(Scheme_Config *c, int pos); |
151 | 275 # endif |
137 | 276 static void (*dll_scheme_gc_ptr_ok)(void *p); |
151 | 277 # if MZSCHEME_VERSION_MAJOR < 299 |
137 | 278 static char *(*dll_scheme_get_sized_string_output)(Scheme_Object *, |
279 long *len); | |
151 | 280 # else |
281 static char *(*dll_scheme_get_sized_byte_string_output)(Scheme_Object *, | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
282 OUTPUT_LEN_TYPE *len); |
151 | 283 # endif |
137 | 284 static Scheme_Object *(*dll_scheme_intern_symbol)(const char *name); |
285 static Scheme_Object *(*dll_scheme_lookup_global)(Scheme_Object *symbol, | |
286 Scheme_Env *env); | |
287 static Scheme_Object *(*dll_scheme_make_closed_prim_w_arity) | |
288 (Scheme_Closed_Prim *prim, void *data, const char *name, mzshort mina, | |
289 mzshort maxa); | |
290 static Scheme_Object *(*dll_scheme_make_integer_value)(long i); | |
344 | 291 static Scheme_Object *(*dll_scheme_make_pair)(Scheme_Object *car, |
137 | 292 Scheme_Object *cdr); |
274 | 293 static Scheme_Object *(*dll_scheme_make_prim_w_arity)(Scheme_Prim *prim, |
294 const char *name, mzshort mina, mzshort maxa); | |
151 | 295 # if MZSCHEME_VERSION_MAJOR < 299 |
137 | 296 static Scheme_Object *(*dll_scheme_make_string)(const char *chars); |
297 static Scheme_Object *(*dll_scheme_make_string_output_port)(); | |
151 | 298 # else |
299 static Scheme_Object *(*dll_scheme_make_byte_string)(const char *chars); | |
300 static Scheme_Object *(*dll_scheme_make_byte_string_output_port)(); | |
301 # endif | |
137 | 302 static Scheme_Object *(*dll_scheme_make_struct_instance)(Scheme_Object *stype, |
303 int argc, Scheme_Object **argv); | |
304 static Scheme_Object **(*dll_scheme_make_struct_names)(Scheme_Object *base, | |
305 Scheme_Object *field_names, int flags, int *count_out); | |
306 static Scheme_Object *(*dll_scheme_make_struct_type)(Scheme_Object *base, | |
307 Scheme_Object *parent, Scheme_Object *inspector, int num_fields, | |
308 int num_uninit_fields, Scheme_Object *uninit_val, | |
151 | 309 Scheme_Object *properties |
310 # if MZSCHEME_VERSION_MAJOR >= 299 | |
311 , Scheme_Object *guard | |
312 # endif | |
313 ); | |
137 | 314 static Scheme_Object **(*dll_scheme_make_struct_values)( |
315 Scheme_Object *struct_type, Scheme_Object **names, int count, | |
316 int flags); | |
317 static Scheme_Type (*dll_scheme_make_type)(const char *name); | |
318 static Scheme_Object *(*dll_scheme_make_vector)(int size, | |
319 Scheme_Object *fill); | |
320 static void *(*dll_scheme_malloc_fail_ok)(void *(*f)(size_t), size_t); | |
321 static Scheme_Object *(*dll_scheme_open_input_file)(const char *name, | |
322 const char *who); | |
323 static Scheme_Env *(*dll_scheme_primitive_module)(Scheme_Object *name, | |
324 Scheme_Env *for_env); | |
325 static int (*dll_scheme_proper_list_length)(Scheme_Object *list); | |
326 static void (*dll_scheme_raise)(Scheme_Object *exn); | |
327 static Scheme_Object *(*dll_scheme_read)(Scheme_Object *port); | |
328 static void (*dll_scheme_signal_error)(const char *msg, ...); | |
329 static void (*dll_scheme_wrong_type)(const char *name, const char *expected, | |
330 int which, int argc, Scheme_Object **argv); | |
151 | 331 # if MZSCHEME_VERSION_MAJOR >= 299 |
344 | 332 static void (*dll_scheme_set_param)(Scheme_Config *c, int pos, |
151 | 333 Scheme_Object *o); |
334 static Scheme_Config *(*dll_scheme_current_config)(void); | |
335 static Scheme_Object *(*dll_scheme_char_string_to_byte_string) | |
336 (Scheme_Object *s); | |
1307 | 337 static Scheme_Object *(*dll_scheme_char_string_to_path) |
338 (Scheme_Object *s); | |
4074 | 339 static void *(*dll_scheme_set_collects_path)(Scheme_Object *p); |
151 | 340 # endif |
1894 | 341 static Scheme_Hash_Table *(*dll_scheme_make_hash_table)(int type); |
342 static void (*dll_scheme_hash_set)(Scheme_Hash_Table *table, | |
343 Scheme_Object *key, Scheme_Object *value); | |
344 static Scheme_Object *(*dll_scheme_hash_get)(Scheme_Hash_Table *table, | |
345 Scheme_Object *key); | |
346 static Scheme_Object *(*dll_scheme_make_double)(double d); | |
347 static Scheme_Object *(*dll_scheme_make_sized_byte_string)(char *chars, | |
348 long len, int copy); | |
349 static Scheme_Object *(*dll_scheme_namespace_require)(Scheme_Object *req); | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
350 static Scheme_Object *(*dll_scheme_dynamic_wind)(void (*pre)(void *), Scheme_Object *(* volatile act)(void *), void (* volatile post)(void *), Scheme_Object *(*jmp_handler)(void *), void * volatile data); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
351 # ifdef MZ_PRECISE_GC |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
352 static void *(*dll_GC_malloc_one_tagged)(size_t size_in_bytes); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
353 static void (*dll_GC_register_traversers)(short tag, Size_Proc size, Mark_Proc mark, Fixup_Proc fixup, int is_constant_size, int is_atomic); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
354 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
355 # if MZSCHEME_VERSION_MAJOR >= 400 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
356 static void (*dll_scheme_init_collection_paths)(Scheme_Env *global_env, Scheme_Object *extra_dirs); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
357 static void **(*dll_scheme_malloc_immobile_box)(void *p); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
358 static void (*dll_scheme_free_immobile_box)(void **b); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
359 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
360 # if MZSCHEME_VERSION_MAJOR >= 500 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
361 # ifdef TRAMPOLINED_MZVIM_STARTUP |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
362 static int (*dll_scheme_main_setup)(int no_auto_statics, Scheme_Env_Main _main, int argc, char **argv); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
363 # if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || MZSCHEME_VERSION_MAJOR >= 603 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
364 static void (*dll_scheme_register_tls_space)(void *tls_space, int _tls_index); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
365 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
366 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
367 # if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || defined(IMPLEMENT_THREAD_LOCAL_EXTERNALLY_VIA_PROC) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
368 static Thread_Local_Variables *(*dll_scheme_external_get_thread_local_variables)(void); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
369 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
370 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
371 # if MZSCHEME_VERSION_MAJOR >= 600 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
372 static void (*dll_scheme_embedded_load)(intptr_t len, const char *s, int predefined); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
373 static void (*dll_scheme_register_embedded_load)(intptr_t len, const char *s); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
374 static void (*dll_scheme_set_config_path)(Scheme_Object *p); |
1894 | 375 # endif |
137 | 376 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
377 #if defined(DYNAMIC_MZSCHEME) // not when defined(PROTO) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
378 |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
379 // arrays are imported directly |
137 | 380 # define scheme_eof dll_scheme_eof |
381 # define scheme_false dll_scheme_false | |
382 # define scheme_void dll_scheme_void | |
383 # define scheme_null dll_scheme_null | |
384 # define scheme_true dll_scheme_true | |
385 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
386 // pointers are GetProceAddress'ed as pointers to pointer |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
387 #if !defined(USE_THREAD_LOCAL) && !defined(LINK_EXTENSIONS_BY_TABLE) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
388 # define scheme_current_thread (*dll_scheme_current_thread_ptr) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
389 # endif |
137 | 390 # define scheme_console_printf (*dll_scheme_console_printf_ptr) |
391 # define scheme_console_output (*dll_scheme_console_output_ptr) | |
392 # define scheme_notify_multithread (*dll_scheme_notify_multithread_ptr) | |
393 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
394 // and functions in a usual way |
137 | 395 # define GC_malloc dll_GC_malloc |
396 # define GC_malloc_atomic dll_GC_malloc_atomic | |
397 | |
398 # define scheme_add_global dll_scheme_add_global | |
399 # define scheme_add_global_symbol dll_scheme_add_global_symbol | |
400 # define scheme_apply dll_scheme_apply | |
401 # define scheme_basic_env dll_scheme_basic_env | |
402 # define scheme_builtin_value dll_scheme_builtin_value | |
274 | 403 # if MZSCHEME_VERSION_MAJOR >= 299 |
404 # define scheme_byte_string_to_char_string dll_scheme_byte_string_to_char_string | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
405 # define scheme_make_path dll_scheme_make_path |
274 | 406 # endif |
137 | 407 # define scheme_check_threads dll_scheme_check_threads |
408 # define scheme_close_input_port dll_scheme_close_input_port | |
409 # define scheme_count_lines dll_scheme_count_lines | |
410 # define scheme_current_continuation_marks \ | |
411 dll_scheme_current_continuation_marks | |
412 # define scheme_display dll_scheme_display | |
413 # define scheme_display_to_string dll_scheme_display_to_string | |
414 # define scheme_do_eval dll_scheme_do_eval | |
415 # define scheme_dont_gc_ptr dll_scheme_dont_gc_ptr | |
274 | 416 # define scheme_eq dll_scheme_eq |
137 | 417 # define scheme_eval dll_scheme_eval |
418 # define scheme_eval_string dll_scheme_eval_string | |
419 # define scheme_eval_string_all dll_scheme_eval_string_all | |
420 # define scheme_finish_primitive_module dll_scheme_finish_primitive_module | |
151 | 421 # if MZSCHEME_VERSION_MAJOR < 299 |
422 # define scheme_format dll_scheme_format | |
423 # else | |
424 # define scheme_format_utf8 dll_scheme_format_utf8 | |
425 # endif | |
137 | 426 # define scheme_gc_ptr_ok dll_scheme_gc_ptr_ok |
151 | 427 # if MZSCHEME_VERSION_MAJOR < 299 |
4074 | 428 # define scheme_get_sized_byte_string_output dll_scheme_get_sized_string_output |
151 | 429 # else |
430 # define scheme_get_sized_byte_string_output \ | |
431 dll_scheme_get_sized_byte_string_output | |
4074 | 432 # define scheme_get_param dll_scheme_get_param |
151 | 433 # endif |
137 | 434 # define scheme_intern_symbol dll_scheme_intern_symbol |
435 # define scheme_lookup_global dll_scheme_lookup_global | |
436 # define scheme_make_closed_prim_w_arity dll_scheme_make_closed_prim_w_arity | |
437 # define scheme_make_integer_value dll_scheme_make_integer_value | |
438 # define scheme_make_pair dll_scheme_make_pair | |
274 | 439 # define scheme_make_prim_w_arity dll_scheme_make_prim_w_arity |
151 | 440 # if MZSCHEME_VERSION_MAJOR < 299 |
4074 | 441 # define scheme_make_byte_string dll_scheme_make_string |
442 # define scheme_make_byte_string_output_port dll_scheme_make_string_output_port | |
151 | 443 # else |
444 # define scheme_make_byte_string dll_scheme_make_byte_string | |
445 # define scheme_make_byte_string_output_port \ | |
446 dll_scheme_make_byte_string_output_port | |
447 # endif | |
137 | 448 # define scheme_make_struct_instance dll_scheme_make_struct_instance |
449 # define scheme_make_struct_names dll_scheme_make_struct_names | |
450 # define scheme_make_struct_type dll_scheme_make_struct_type | |
451 # define scheme_make_struct_values dll_scheme_make_struct_values | |
452 # define scheme_make_type dll_scheme_make_type | |
453 # define scheme_make_vector dll_scheme_make_vector | |
454 # define scheme_malloc_fail_ok dll_scheme_malloc_fail_ok | |
455 # define scheme_open_input_file dll_scheme_open_input_file | |
456 # define scheme_primitive_module dll_scheme_primitive_module | |
457 # define scheme_proper_list_length dll_scheme_proper_list_length | |
458 # define scheme_raise dll_scheme_raise | |
459 # define scheme_read dll_scheme_read | |
460 # define scheme_register_static dll_scheme_register_static | |
461 # define scheme_set_stack_base dll_scheme_set_stack_base | |
462 # define scheme_signal_error dll_scheme_signal_error | |
463 # define scheme_wrong_type dll_scheme_wrong_type | |
151 | 464 # if MZSCHEME_VERSION_MAJOR >= 299 |
465 # define scheme_set_param dll_scheme_set_param | |
466 # define scheme_current_config dll_scheme_current_config | |
467 # define scheme_char_string_to_byte_string \ | |
468 dll_scheme_char_string_to_byte_string | |
1307 | 469 # define scheme_char_string_to_path \ |
470 dll_scheme_char_string_to_path | |
4074 | 471 # define scheme_set_collects_path dll_scheme_set_collects_path |
151 | 472 # endif |
1894 | 473 # define scheme_make_hash_table dll_scheme_make_hash_table |
474 # define scheme_hash_set dll_scheme_hash_set | |
475 # define scheme_hash_get dll_scheme_hash_get | |
476 # define scheme_make_double dll_scheme_make_double | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
477 # define scheme_make_sized_byte_string dll_scheme_make_sized_byte_string |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
478 # define scheme_namespace_require dll_scheme_namespace_require |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
479 # define scheme_dynamic_wind dll_scheme_dynamic_wind |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
480 # ifdef MZ_PRECISE_GC |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
481 # define GC_malloc_one_tagged dll_GC_malloc_one_tagged |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
482 # define GC_register_traversers dll_GC_register_traversers |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
483 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
484 # if MZSCHEME_VERSION_MAJOR >= 400 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
485 # ifdef TRAMPOLINED_MZVIM_STARTUP |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
486 # define scheme_main_setup dll_scheme_main_setup |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
487 # if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || MZSCHEME_VERSION_MAJOR >= 603 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
488 # define scheme_register_tls_space dll_scheme_register_tls_space |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
489 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
490 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
491 # define scheme_init_collection_paths dll_scheme_init_collection_paths |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
492 # define scheme_malloc_immobile_box dll_scheme_malloc_immobile_box |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
493 # define scheme_free_immobile_box dll_scheme_free_immobile_box |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
494 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
495 # if MZSCHEME_VERSION_MAJOR >= 600 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
496 # define scheme_embedded_load dll_scheme_embedded_load |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
497 # define scheme_register_embedded_load dll_scheme_register_embedded_load |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
498 # define scheme_set_config_path dll_scheme_set_config_path |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
499 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
500 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
501 # if MZSCHEME_VERSION_MAJOR >= 500 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
502 # if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || defined(IMPLEMENT_THREAD_LOCAL_EXTERNALLY_VIA_PROC) |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
503 // define as function for macro in schthread.h |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
504 Thread_Local_Variables * |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
505 scheme_external_get_thread_local_variables(void) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
506 { |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
507 return dll_scheme_external_get_thread_local_variables(); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
508 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
509 # endif |
1894 | 510 # endif |
137 | 511 |
7813
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
512 #endif |
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
513 |
137 | 514 typedef struct |
515 { | |
516 char *name; | |
517 void **ptr; | |
518 } Thunk_Info; | |
519 | |
520 static Thunk_Info mzgc_imports[] = { | |
521 {"GC_malloc", (void **)&dll_GC_malloc}, | |
522 {"GC_malloc_atomic", (void **)&dll_GC_malloc_atomic}, | |
523 {NULL, NULL}}; | |
524 | |
525 static Thunk_Info mzsch_imports[] = { | |
526 {"scheme_eof", (void **)&dll_scheme_eof}, | |
527 {"scheme_false", (void **)&dll_scheme_false}, | |
528 {"scheme_void", (void **)&dll_scheme_void}, | |
529 {"scheme_null", (void **)&dll_scheme_null}, | |
530 {"scheme_true", (void **)&dll_scheme_true}, | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
531 #if !defined(USE_THREAD_LOCAL) && !defined(LINK_EXTENSIONS_BY_TABLE) |
137 | 532 {"scheme_current_thread", (void **)&dll_scheme_current_thread_ptr}, |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
533 #endif |
137 | 534 {"scheme_console_printf", (void **)&dll_scheme_console_printf_ptr}, |
535 {"scheme_console_output", (void **)&dll_scheme_console_output_ptr}, | |
344 | 536 {"scheme_notify_multithread", |
137 | 537 (void **)&dll_scheme_notify_multithread_ptr}, |
538 {"scheme_add_global", (void **)&dll_scheme_add_global}, | |
539 {"scheme_add_global_symbol", (void **)&dll_scheme_add_global_symbol}, | |
540 {"scheme_apply", (void **)&dll_scheme_apply}, | |
541 {"scheme_basic_env", (void **)&dll_scheme_basic_env}, | |
274 | 542 # if MZSCHEME_VERSION_MAJOR >= 299 |
543 {"scheme_byte_string_to_char_string", (void **)&dll_scheme_byte_string_to_char_string}, | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
544 {"scheme_make_path", (void **)&dll_scheme_make_path}, |
274 | 545 # endif |
137 | 546 {"scheme_builtin_value", (void **)&dll_scheme_builtin_value}, |
547 {"scheme_check_threads", (void **)&dll_scheme_check_threads}, | |
548 {"scheme_close_input_port", (void **)&dll_scheme_close_input_port}, | |
549 {"scheme_count_lines", (void **)&dll_scheme_count_lines}, | |
344 | 550 {"scheme_current_continuation_marks", |
137 | 551 (void **)&dll_scheme_current_continuation_marks}, |
552 {"scheme_display", (void **)&dll_scheme_display}, | |
553 {"scheme_display_to_string", (void **)&dll_scheme_display_to_string}, | |
554 {"scheme_do_eval", (void **)&dll_scheme_do_eval}, | |
555 {"scheme_dont_gc_ptr", (void **)&dll_scheme_dont_gc_ptr}, | |
274 | 556 {"scheme_eq", (void **)&dll_scheme_eq}, |
137 | 557 {"scheme_eval", (void **)&dll_scheme_eval}, |
558 {"scheme_eval_string", (void **)&dll_scheme_eval_string}, | |
559 {"scheme_eval_string_all", (void **)&dll_scheme_eval_string_all}, | |
344 | 560 {"scheme_finish_primitive_module", |
137 | 561 (void **)&dll_scheme_finish_primitive_module}, |
151 | 562 # if MZSCHEME_VERSION_MAJOR < 299 |
137 | 563 {"scheme_format", (void **)&dll_scheme_format}, |
151 | 564 # else |
565 {"scheme_format_utf8", (void **)&dll_scheme_format_utf8}, | |
274 | 566 {"scheme_get_param", (void **)&dll_scheme_get_param}, |
151 | 567 #endif |
137 | 568 {"scheme_gc_ptr_ok", (void **)&dll_scheme_gc_ptr_ok}, |
151 | 569 # if MZSCHEME_VERSION_MAJOR < 299 |
344 | 570 {"scheme_get_sized_string_output", |
137 | 571 (void **)&dll_scheme_get_sized_string_output}, |
151 | 572 # else |
344 | 573 {"scheme_get_sized_byte_string_output", |
151 | 574 (void **)&dll_scheme_get_sized_byte_string_output}, |
575 #endif | |
137 | 576 {"scheme_intern_symbol", (void **)&dll_scheme_intern_symbol}, |
577 {"scheme_lookup_global", (void **)&dll_scheme_lookup_global}, | |
344 | 578 {"scheme_make_closed_prim_w_arity", |
137 | 579 (void **)&dll_scheme_make_closed_prim_w_arity}, |
580 {"scheme_make_integer_value", (void **)&dll_scheme_make_integer_value}, | |
581 {"scheme_make_pair", (void **)&dll_scheme_make_pair}, | |
274 | 582 {"scheme_make_prim_w_arity", (void **)&dll_scheme_make_prim_w_arity}, |
151 | 583 # if MZSCHEME_VERSION_MAJOR < 299 |
137 | 584 {"scheme_make_string", (void **)&dll_scheme_make_string}, |
344 | 585 {"scheme_make_string_output_port", |
137 | 586 (void **)&dll_scheme_make_string_output_port}, |
151 | 587 # else |
588 {"scheme_make_byte_string", (void **)&dll_scheme_make_byte_string}, | |
344 | 589 {"scheme_make_byte_string_output_port", |
151 | 590 (void **)&dll_scheme_make_byte_string_output_port}, |
591 # endif | |
344 | 592 {"scheme_make_struct_instance", |
137 | 593 (void **)&dll_scheme_make_struct_instance}, |
594 {"scheme_make_struct_names", (void **)&dll_scheme_make_struct_names}, | |
595 {"scheme_make_struct_type", (void **)&dll_scheme_make_struct_type}, | |
596 {"scheme_make_struct_values", (void **)&dll_scheme_make_struct_values}, | |
597 {"scheme_make_type", (void **)&dll_scheme_make_type}, | |
598 {"scheme_make_vector", (void **)&dll_scheme_make_vector}, | |
599 {"scheme_malloc_fail_ok", (void **)&dll_scheme_malloc_fail_ok}, | |
600 {"scheme_open_input_file", (void **)&dll_scheme_open_input_file}, | |
601 {"scheme_primitive_module", (void **)&dll_scheme_primitive_module}, | |
602 {"scheme_proper_list_length", (void **)&dll_scheme_proper_list_length}, | |
603 {"scheme_raise", (void **)&dll_scheme_raise}, | |
604 {"scheme_read", (void **)&dll_scheme_read}, | |
605 {"scheme_register_static", (void **)&dll_scheme_register_static}, | |
606 {"scheme_set_stack_base", (void **)&dll_scheme_set_stack_base}, | |
607 {"scheme_signal_error", (void **)&dll_scheme_signal_error}, | |
608 {"scheme_wrong_type", (void **)&dll_scheme_wrong_type}, | |
151 | 609 # if MZSCHEME_VERSION_MAJOR >= 299 |
610 {"scheme_set_param", (void **)&dll_scheme_set_param}, | |
611 {"scheme_current_config", (void **)&dll_scheme_current_config}, | |
612 {"scheme_char_string_to_byte_string", | |
613 (void **)&dll_scheme_char_string_to_byte_string}, | |
1894 | 614 {"scheme_char_string_to_path", (void **)&dll_scheme_char_string_to_path}, |
4074 | 615 {"scheme_set_collects_path", (void **)&dll_scheme_set_collects_path}, |
151 | 616 # endif |
1894 | 617 {"scheme_make_hash_table", (void **)&dll_scheme_make_hash_table}, |
618 {"scheme_hash_set", (void **)&dll_scheme_hash_set}, | |
619 {"scheme_hash_get", (void **)&dll_scheme_hash_get}, | |
620 {"scheme_make_double", (void **)&dll_scheme_make_double}, | |
621 {"scheme_make_sized_byte_string", (void **)&dll_scheme_make_sized_byte_string}, | |
622 {"scheme_namespace_require", (void **)&dll_scheme_namespace_require}, | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
623 {"scheme_dynamic_wind", (void **)&dll_scheme_dynamic_wind}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
624 # ifdef MZ_PRECISE_GC |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
625 {"GC_malloc_one_tagged", (void **)&dll_GC_malloc_one_tagged}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
626 {"GC_register_traversers", (void **)&dll_GC_register_traversers}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
627 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
628 # if MZSCHEME_VERSION_MAJOR >= 400 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
629 # ifdef TRAMPOLINED_MZVIM_STARTUP |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
630 {"scheme_main_setup", (void **)&dll_scheme_main_setup}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
631 # if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || MZSCHEME_VERSION_MAJOR >= 603 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
632 {"scheme_register_tls_space", (void **)&dll_scheme_register_tls_space}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
633 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
634 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
635 {"scheme_init_collection_paths", (void **)&dll_scheme_init_collection_paths}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
636 {"scheme_malloc_immobile_box", (void **)&dll_scheme_malloc_immobile_box}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
637 {"scheme_free_immobile_box", (void **)&dll_scheme_free_immobile_box}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
638 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
639 # if MZSCHEME_VERSION_MAJOR >= 500 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
640 # if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || defined(IMPLEMENT_THREAD_LOCAL_EXTERNALLY_VIA_PROC) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
641 {"scheme_external_get_thread_local_variables", (void **)&dll_scheme_external_get_thread_local_variables}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
642 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
643 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
644 # if MZSCHEME_VERSION_MAJOR >= 600 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
645 {"scheme_embedded_load", (void **)&dll_scheme_embedded_load}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
646 {"scheme_register_embedded_load", (void **)&dll_scheme_register_embedded_load}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
647 {"scheme_set_config_path", (void **)&dll_scheme_set_config_path}, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
648 # endif |
137 | 649 {NULL, NULL}}; |
650 | |
651 static HINSTANCE hMzGC = 0; | |
652 static HINSTANCE hMzSch = 0; | |
653 | |
654 static void dynamic_mzscheme_end(void); | |
655 static int mzscheme_runtime_link_init(char *sch_dll, char *gc_dll, | |
656 int verbose); | |
657 | |
658 static int | |
659 mzscheme_runtime_link_init(char *sch_dll, char *gc_dll, int verbose) | |
660 { | |
661 Thunk_Info *thunk = NULL; | |
662 | |
663 if (hMzGC && hMzSch) | |
664 return OK; | |
2612 | 665 hMzSch = vimLoadLib(sch_dll); |
666 hMzGC = vimLoadLib(gc_dll); | |
137 | 667 |
3348 | 668 if (!hMzGC) |
669 { | |
670 if (verbose) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15412
diff
changeset
|
671 semsg(_(e_loadlib), gc_dll); |
3348 | 672 return FAIL; |
673 } | |
674 | |
137 | 675 if (!hMzSch) |
676 { | |
677 if (verbose) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15412
diff
changeset
|
678 semsg(_(e_loadlib), sch_dll); |
137 | 679 return FAIL; |
680 } | |
681 | |
682 for (thunk = mzsch_imports; thunk->name; thunk++) | |
683 { | |
344 | 684 if ((*thunk->ptr = |
137 | 685 (void *)GetProcAddress(hMzSch, thunk->name)) == NULL) |
686 { | |
687 FreeLibrary(hMzSch); | |
688 hMzSch = 0; | |
689 FreeLibrary(hMzGC); | |
690 hMzGC = 0; | |
691 if (verbose) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15412
diff
changeset
|
692 semsg(_(e_loadfunc), thunk->name); |
137 | 693 return FAIL; |
694 } | |
695 } | |
696 for (thunk = mzgc_imports; thunk->name; thunk++) | |
697 { | |
344 | 698 if ((*thunk->ptr = |
137 | 699 (void *)GetProcAddress(hMzGC, thunk->name)) == NULL) |
700 { | |
701 FreeLibrary(hMzSch); | |
702 hMzSch = 0; | |
703 FreeLibrary(hMzGC); | |
704 hMzGC = 0; | |
705 if (verbose) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15412
diff
changeset
|
706 semsg(_(e_loadfunc), thunk->name); |
137 | 707 return FAIL; |
708 } | |
709 } | |
710 return OK; | |
711 } | |
712 | |
713 int | |
714 mzscheme_enabled(int verbose) | |
715 { | |
716 return mzscheme_runtime_link_init( | |
12608
b390f5003e2f
patch 8.0.1182: cannot see or change mzscheme dll name
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
717 (char *)p_mzschemedll, (char *)p_mzschemegcdll, verbose) == OK; |
137 | 718 } |
719 | |
720 static void | |
721 dynamic_mzscheme_end(void) | |
722 { | |
723 if (hMzSch) | |
724 { | |
725 FreeLibrary(hMzSch); | |
726 hMzSch = 0; | |
727 } | |
728 if (hMzGC) | |
729 { | |
730 FreeLibrary(hMzGC); | |
731 hMzGC = 0; | |
732 } | |
733 } | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
734 #endif // DYNAMIC_MZSCHEME |
137 | 735 |
4074 | 736 #if MZSCHEME_VERSION_MAJOR < 299 |
737 # define GUARANTEED_STRING_ARG(proc, num) GUARANTEE_STRING(proc, num) | |
738 #else | |
739 static Scheme_Object * | |
740 guaranteed_byte_string_arg(char *proc, int num, int argc, Scheme_Object **argv) | |
741 { | |
742 if (SCHEME_BYTE_STRINGP(argv[num])) | |
743 { | |
744 return argv[num]; | |
745 } | |
746 else if (SCHEME_CHAR_STRINGP(argv[num])) | |
747 { | |
748 Scheme_Object *tmp = NULL; | |
749 MZ_GC_DECL_REG(2); | |
750 MZ_GC_VAR_IN_REG(0, argv[num]); | |
751 MZ_GC_VAR_IN_REG(1, tmp); | |
752 MZ_GC_REG(); | |
753 tmp = scheme_char_string_to_byte_string(argv[num]); | |
754 MZ_GC_UNREG(); | |
755 return tmp; | |
756 } | |
757 else | |
758 scheme_wrong_type(proc, "string", num, argc, argv); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
759 // unreachable |
4074 | 760 return scheme_void; |
761 } | |
762 # define GUARANTEED_STRING_ARG(proc, num) guaranteed_byte_string_arg(proc, num, argc, argv) | |
763 #endif | |
764 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
765 // need to put it here for dynamic stuff to work |
1950 | 766 #if defined(INCLUDE_MZSCHEME_BASE) |
1894 | 767 # include "mzscheme_base.c" |
768 #endif | |
769 | |
14 | 770 /* |
771 *======================================================================== | |
772 * 1. MzScheme interpreter startup | |
773 *======================================================================== | |
774 */ | |
775 | |
776 static Scheme_Type mz_buffer_type; | |
777 static Scheme_Type mz_window_type; | |
778 | |
1894 | 779 static int initialized = FALSE; |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
780 #ifdef DYNAMIC_MZSCHEME |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
781 static int disabled = FALSE; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
782 #endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
783 static int load_base_module_failed = FALSE; |
14 | 784 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
785 // global environment |
14 | 786 static Scheme_Env *environment = NULL; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
787 // output/error handlers |
14 | 788 static Scheme_Object *curout = NULL; |
789 static Scheme_Object *curerr = NULL; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
790 // exn:vim exception |
14 | 791 static Scheme_Object *exn_catching_apply = NULL; |
792 static Scheme_Object *exn_p = NULL; | |
793 static Scheme_Object *exn_message = NULL; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
794 static Scheme_Object *vim_exn = NULL; // Vim Error exception |
1894 | 795 |
796 #if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400 | |
797 static void *stack_base = NULL; | |
798 #endif | |
14 | 799 |
800 static long range_start; | |
801 static long range_end; | |
802 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
803 // MzScheme threads scheduling stuff |
14 | 804 static int mz_threads_allow = 0; |
805 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
806 #if defined(FEAT_GUI_MSWIN) |
9173
b64c314a4990
commit https://github.com/vim/vim/commit/dec6c7beda5491b28f67f430fc9d01467050c1ca
Christian Brabandt <cb@256bit.org>
parents:
9159
diff
changeset
|
807 static void CALLBACK timer_proc(HWND, UINT, UINT_PTR, DWORD); |
14 | 808 static UINT timer_id = 0; |
809 #elif defined(FEAT_GUI_GTK) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8110
diff
changeset
|
810 static gboolean timer_proc(gpointer); |
14 | 811 static guint timer_id = 0; |
812 #elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) | |
813 static void timer_proc(XtPointer, XtIntervalId *); | |
814 static XtIntervalId timer_id = (XtIntervalId)0; | |
815 #elif defined(FEAT_GUI_MAC) | |
816 pascal void timer_proc(EventLoopTimerRef, void *); | |
817 static EventLoopTimerRef timer_id = NULL; | |
818 static EventLoopTimerUPP timerUPP; | |
819 #endif | |
820 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
821 #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) // Win32 console and Unix |
14 | 822 void |
823 mzvim_check_threads(void) | |
824 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
825 // Last time MzScheme threads were scheduled |
14 | 826 static time_t mz_last_time = 0; |
827 | |
828 if (mz_threads_allow && p_mzq > 0) | |
829 { | |
830 time_t now = time(NULL); | |
831 | |
832 if ((now - mz_last_time) * 1000 > p_mzq) | |
833 { | |
834 mz_last_time = now; | |
835 scheme_check_threads(); | |
836 } | |
837 } | |
838 } | |
839 #endif | |
840 | |
7813
744c66477ba9
commit https://github.com/vim/vim/commit/4349c57543a98dc417b74da5a08c326337aa0bd3
Christian Brabandt <cb@256bit.org>
parents:
7728
diff
changeset
|
841 #if defined(MZSCHEME_GUI_THREADS) || defined(PROTO) |
16 | 842 static void setup_timer(void); |
843 static void remove_timer(void); | |
844 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
845 // timers are presented in GUI only |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
846 # if defined(FEAT_GUI_MSWIN) |
14 | 847 static void CALLBACK |
9159
6b003ff07234
commit https://github.com/vim/vim/commit/9b0ac229bcfc91acabd35fc576055a94c1687c32
Christian Brabandt <cb@256bit.org>
parents:
8800
diff
changeset
|
848 timer_proc(HWND hwnd UNUSED, UINT uMsg UNUSED, UINT_PTR idEvent UNUSED, DWORD dwTime UNUSED) |
14 | 849 # elif defined(FEAT_GUI_GTK) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8110
diff
changeset
|
850 static gboolean |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
851 timer_proc(gpointer data UNUSED) |
14 | 852 # elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) |
853 static void | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
854 timer_proc(XtPointer timed_out UNUSED, XtIntervalId *interval_id UNUSED) |
14 | 855 # elif defined(FEAT_GUI_MAC) |
856 pascal void | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
857 timer_proc(EventLoopTimerRef theTimer UNUSED, void *userData UNUSED) |
14 | 858 # endif |
859 { | |
860 scheme_check_threads(); | |
861 # if defined(FEAT_GUI_GTK) | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
862 return TRUE; // continue receiving notifications |
14 | 863 # elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
864 // renew timeout |
14 | 865 if (mz_threads_allow && p_mzq > 0) |
866 timer_id = XtAppAddTimeOut(app_context, p_mzq, | |
867 timer_proc, NULL); | |
868 # endif | |
869 } | |
870 | |
871 static void | |
872 setup_timer(void) | |
873 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
874 # if defined(FEAT_GUI_MSWIN) |
14 | 875 timer_id = SetTimer(NULL, 0, p_mzq, timer_proc); |
876 # elif defined(FEAT_GUI_GTK) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8110
diff
changeset
|
877 timer_id = g_timeout_add((guint)p_mzq, (GSourceFunc)timer_proc, NULL); |
14 | 878 # elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) |
879 timer_id = XtAppAddTimeOut(app_context, p_mzq, timer_proc, NULL); | |
880 # elif defined(FEAT_GUI_MAC) | |
881 timerUPP = NewEventLoopTimerUPP(timer_proc); | |
882 InstallEventLoopTimer(GetMainEventLoop(), p_mzq * kEventDurationMillisecond, | |
883 p_mzq * kEventDurationMillisecond, timerUPP, NULL, &timer_id); | |
884 # endif | |
885 } | |
886 | |
887 static void | |
888 remove_timer(void) | |
889 { | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
890 # if defined(FEAT_GUI_MSWIN) |
14 | 891 KillTimer(NULL, timer_id); |
892 # elif defined(FEAT_GUI_GTK) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
8110
diff
changeset
|
893 g_source_remove(timer_id); |
14 | 894 # elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) |
895 XtRemoveTimeOut(timer_id); | |
896 # elif defined(FEAT_GUI_MAC) | |
897 RemoveEventLoopTimer(timer_id); | |
898 DisposeEventLoopTimerUPP(timerUPP); | |
899 # endif | |
900 timer_id = 0; | |
901 } | |
902 | |
903 void | |
904 mzvim_reset_timer(void) | |
905 { | |
906 if (timer_id != 0) | |
907 remove_timer(); | |
908 if (mz_threads_allow && p_mzq > 0 && gui.in_use) | |
909 setup_timer(); | |
910 } | |
911 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
912 #endif // MZSCHEME_GUI_THREADS |
14 | 913 |
914 static void | |
915 notify_multithread(int on) | |
916 { | |
917 mz_threads_allow = on; | |
16 | 918 #ifdef MZSCHEME_GUI_THREADS |
14 | 919 if (on && timer_id == 0 && p_mzq > 0 && gui.in_use) |
920 setup_timer(); | |
921 if (!on && timer_id != 0) | |
922 remove_timer(); | |
923 #endif | |
924 } | |
925 | |
926 void | |
927 mzscheme_end(void) | |
928 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
929 // We can not unload the DLL. Racket's thread might be still alive. |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
930 #if 0 |
137 | 931 #ifdef DYNAMIC_MZSCHEME |
932 dynamic_mzscheme_end(); | |
933 #endif | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
934 #endif |
14 | 935 } |
936 | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
937 #if HAVE_TLS_SPACE |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
938 # if defined(_MSC_VER) |
2628 | 939 static __declspec(thread) void *tls_space; |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
940 extern intptr_t _tls_index; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
941 # elif defined(__MINGW32__) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
942 static __thread void *tls_space; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
943 extern intptr_t _tls_index; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
944 # else |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
945 static THREAD_LOCAL void *tls_space; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
946 static intptr_t _tls_index = 0; |
3348 | 947 # endif |
948 #endif | |
949 | |
9961
f4e903ba38d8
commit https://github.com/vim/vim/commit/54b6352c6f0617ff9c963588ccc7d31815348029
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
950 /* |
f4e903ba38d8
commit https://github.com/vim/vim/commit/54b6352c6f0617ff9c963588ccc7d31815348029
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
951 * mzscheme_main() is called early in main(). |
f4e903ba38d8
commit https://github.com/vim/vim/commit/54b6352c6f0617ff9c963588ccc7d31815348029
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
952 * We may call scheme_main_setup() which calls mzscheme_env_main() which then |
f4e903ba38d8
commit https://github.com/vim/vim/commit/54b6352c6f0617ff9c963588ccc7d31815348029
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
953 * trampolines into vim_main2(), which never returns. |
f4e903ba38d8
commit https://github.com/vim/vim/commit/54b6352c6f0617ff9c963588ccc7d31815348029
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
954 */ |
3348 | 955 int |
9961
f4e903ba38d8
commit https://github.com/vim/vim/commit/54b6352c6f0617ff9c963588ccc7d31815348029
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
956 mzscheme_main(void) |
1894 | 957 { |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
958 int argc = 0; |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
959 char *argv = NULL; |
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
960 |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
961 #ifdef DYNAMIC_MZSCHEME |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
962 /* |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
963 * Racket requires trampolined startup. We can not load it later. |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
964 * If dynamic dll loading is failed, disable it. |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
965 */ |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
966 if (!mzscheme_enabled(FALSE)) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
967 { |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
968 disabled = TRUE; |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
969 return vim_main2(); |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
970 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
971 #endif |
6905 | 972 #ifdef HAVE_TLS_SPACE |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
973 scheme_register_tls_space(&tls_space, _tls_index); |
2628 | 974 #endif |
3348 | 975 #ifdef TRAMPOLINED_MZVIM_STARTUP |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
976 return scheme_main_setup(TRUE, mzscheme_env_main, argc, &argv); |
1894 | 977 #else |
9802
4cb5ab124239
commit https://github.com/vim/vim/commit/a8e691d44937fd9d72dcbad2b8c673682277f13d
Christian Brabandt <cb@256bit.org>
parents:
9723
diff
changeset
|
978 return mzscheme_env_main(NULL, argc, &argv); |
1894 | 979 #endif |
980 } | |
981 | |
982 static int | |
9961
f4e903ba38d8
commit https://github.com/vim/vim/commit/54b6352c6f0617ff9c963588ccc7d31815348029
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
983 mzscheme_env_main(Scheme_Env *env, int argc UNUSED, char **argv UNUSED) |
1894 | 984 { |
3348 | 985 #ifdef TRAMPOLINED_MZVIM_STARTUP |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
986 // Scheme has created the environment for us |
3348 | 987 environment = env; |
988 #else | |
989 # ifdef MZ_PRECISE_GC | |
1894 | 990 Scheme_Object *dummy = NULL; |
991 MZ_GC_DECL_REG(1); | |
992 MZ_GC_VAR_IN_REG(0, dummy); | |
993 | |
994 stack_base = &__gc_var_stack__; | |
995 # else | |
996 int dummy = 0; | |
997 stack_base = (void *)&dummy; | |
3348 | 998 # endif |
1894 | 999 #endif |
3348 | 1000 |
9961
f4e903ba38d8
commit https://github.com/vim/vim/commit/54b6352c6f0617ff9c963588ccc7d31815348029
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
1001 vim_main2(); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1002 // not reached, vim_main2() will loop until exit() |
9961
f4e903ba38d8
commit https://github.com/vim/vim/commit/54b6352c6f0617ff9c963588ccc7d31815348029
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
1003 |
f4e903ba38d8
commit https://github.com/vim/vim/commit/54b6352c6f0617ff9c963588ccc7d31815348029
Christian Brabandt <cb@256bit.org>
parents:
9802
diff
changeset
|
1004 return 0; |
1894 | 1005 } |
1006 | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1007 static Scheme_Object* |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1008 load_base_module(void *data) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1009 { |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1010 scheme_namespace_require(scheme_intern_symbol((char *)data)); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1011 return scheme_null; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1012 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1013 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1014 static Scheme_Object * |
8779
26495bd795d2
commit https://github.com/vim/vim/commit/8b29aba0192cc56294ef49bb3c01adff4b8f3a28
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
1015 load_base_module_on_error(void *data UNUSED) |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1016 { |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1017 load_base_module_failed = TRUE; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1018 return scheme_null; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1019 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1020 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1021 static int |
14 | 1022 startup_mzscheme(void) |
1023 { | |
3348 | 1024 #ifndef TRAMPOLINED_MZVIM_STARTUP |
1894 | 1025 scheme_set_stack_base(stack_base, 1); |
1026 #endif | |
14 | 1027 |
4074 | 1028 #ifndef TRAMPOLINED_MZVIM_STARTUP |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1029 // in newer versions of precise GC the initial env has been created |
4074 | 1030 environment = scheme_basic_env(); |
1031 #endif | |
1032 | |
14 | 1033 MZ_REGISTER_STATIC(environment); |
1034 MZ_REGISTER_STATIC(curout); | |
1035 MZ_REGISTER_STATIC(curerr); | |
1036 MZ_REGISTER_STATIC(exn_catching_apply); | |
1037 MZ_REGISTER_STATIC(exn_p); | |
1038 MZ_REGISTER_STATIC(exn_message); | |
1039 MZ_REGISTER_STATIC(vim_exn); | |
1894 | 1040 |
1041 MZ_GC_CHECK(); | |
1042 | |
1043 #ifdef INCLUDE_MZSCHEME_BASE | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1044 // invoke function from generated and included mzscheme_base.c |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1045 declare_modules(environment); |
1894 | 1046 #endif |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1047 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1048 // setup 'current-library-collection-paths' parameter |
1307 | 1049 # if MZSCHEME_VERSION_MAJOR >= 299 |
1894 | 1050 { |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1051 Scheme_Object *coll_path = NULL; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1052 int mustfree = FALSE; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1053 char_u *s; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1054 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1055 MZ_GC_DECL_REG(1); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1056 MZ_GC_VAR_IN_REG(0, coll_path); |
1894 | 1057 MZ_GC_REG(); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1058 // workaround for dynamic loading on windows |
8110
d1974721ddc5
commit https://github.com/vim/vim/commit/74a97b1ea0fe2c729e26718d0eec4164c8bed151
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
1059 s = vim_getenv((char_u *)"PLTCOLLECTS", &mustfree); |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1060 if (s != NULL) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1061 { |
8110
d1974721ddc5
commit https://github.com/vim/vim/commit/74a97b1ea0fe2c729e26718d0eec4164c8bed151
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
1062 coll_path = scheme_make_path((char *)s); |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1063 MZ_GC_CHECK(); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1064 if (mustfree) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1065 vim_free(s); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1066 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1067 # ifdef MZSCHEME_COLLECTS |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1068 if (coll_path == NULL) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1069 { |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1070 coll_path = scheme_make_path(MZSCHEME_COLLECTS); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1071 MZ_GC_CHECK(); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1072 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1073 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1074 if (coll_path != NULL) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1075 { |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1076 scheme_set_collects_path(coll_path); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1077 MZ_GC_CHECK(); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1078 } |
1894 | 1079 MZ_GC_UNREG(); |
1080 } | |
1307 | 1081 # else |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1082 # ifdef MZSCHEME_COLLECTS |
1894 | 1083 { |
1084 Scheme_Object *coll_string = NULL; | |
1085 Scheme_Object *coll_pair = NULL; | |
1086 Scheme_Config *config = NULL; | |
1087 | |
1088 MZ_GC_DECL_REG(3); | |
1089 MZ_GC_VAR_IN_REG(0, coll_string); | |
1090 MZ_GC_VAR_IN_REG(1, coll_pair); | |
1091 MZ_GC_VAR_IN_REG(2, config); | |
1092 MZ_GC_REG(); | |
4074 | 1093 coll_string = scheme_make_byte_string(MZSCHEME_COLLECTS); |
1894 | 1094 MZ_GC_CHECK(); |
1095 coll_pair = scheme_make_pair(coll_string, scheme_null); | |
1096 MZ_GC_CHECK(); | |
4074 | 1097 config = scheme_current_config(); |
1894 | 1098 MZ_GC_CHECK(); |
1099 scheme_set_param(config, MZCONFIG_COLLECTION_PATHS, coll_pair); | |
1100 MZ_GC_CHECK(); | |
1101 MZ_GC_UNREG(); | |
1102 } | |
1307 | 1103 # endif |
14 | 1104 #endif |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1105 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1106 # if MZSCHEME_VERSION_MAJOR >= 600 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1107 { |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1108 Scheme_Object *config_path = NULL; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1109 int mustfree = FALSE; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1110 char_u *s; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1111 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1112 MZ_GC_DECL_REG(1); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1113 MZ_GC_VAR_IN_REG(0, config_path); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1114 MZ_GC_REG(); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1115 // workaround for dynamic loading on windows |
9289
29de7dda7a6a
commit https://github.com/vim/vim/commit/5b7d177e8994c003ae77ddab5bd54f8cd1ee181b
Christian Brabandt <cb@256bit.org>
parents:
9228
diff
changeset
|
1116 s = vim_getenv((char_u *)"PLTCONFIGDIR", &mustfree); |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1117 if (s != NULL) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1118 { |
9289
29de7dda7a6a
commit https://github.com/vim/vim/commit/5b7d177e8994c003ae77ddab5bd54f8cd1ee181b
Christian Brabandt <cb@256bit.org>
parents:
9228
diff
changeset
|
1119 config_path = scheme_make_path((char *)s); |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1120 MZ_GC_CHECK(); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1121 if (mustfree) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1122 vim_free(s); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1123 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1124 #ifdef MZSCHEME_CONFIGDIR |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1125 if (config_path == NULL) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1126 { |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1127 config_path = scheme_make_path(MZSCHEME_CONFIGDIR); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1128 MZ_GC_CHECK(); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1129 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1130 #endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1131 if (config_path != NULL) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1132 { |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1133 scheme_set_config_path(config_path); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1134 MZ_GC_CHECK(); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1135 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1136 MZ_GC_UNREG(); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1137 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1138 # endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1139 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1140 #if MZSCHEME_VERSION_MAJOR >= 400 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1141 scheme_init_collection_paths(environment, scheme_null); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1142 #endif |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1143 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1144 /* |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1145 * versions 4.x do not provide Scheme bindings by default |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1146 * we need to add them explicitly |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1147 */ |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1148 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1149 // use error handler to avoid abort |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1150 scheme_dynamic_wind(NULL, load_base_module, NULL, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1151 load_base_module_on_error, "racket/base"); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1152 if (load_base_module_failed) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1153 { |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1154 load_base_module_failed = FALSE; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1155 scheme_dynamic_wind(NULL, load_base_module, NULL, |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1156 load_base_module_on_error, "scheme/base"); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1157 if (load_base_module_failed) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1158 return -1; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1159 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1160 } |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1161 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1162 register_vim_exn(); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1163 // use new environment to initialise exception handling |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1164 init_exn_catching_apply(); |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1165 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1166 // redirect output |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1167 scheme_console_output = do_output; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1168 scheme_console_printf = do_printf; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1169 |
274 | 1170 #ifdef HAVE_SANDBOX |
1171 { | |
1894 | 1172 Scheme_Object *make_security_guard = NULL; |
1173 MZ_GC_DECL_REG(1); | |
1174 MZ_GC_VAR_IN_REG(0, make_security_guard); | |
1175 MZ_GC_REG(); | |
1176 | |
1177 #if MZSCHEME_VERSION_MAJOR < 400 | |
1178 { | |
1179 Scheme_Object *make_security_guard_symbol = NULL; | |
1180 MZ_GC_DECL_REG(1); | |
1181 MZ_GC_VAR_IN_REG(0, make_security_guard_symbol); | |
1182 MZ_GC_REG(); | |
1183 make_security_guard_symbol = scheme_intern_symbol("make-security-guard"); | |
1184 MZ_GC_CHECK(); | |
1185 make_security_guard = scheme_lookup_global( | |
1186 make_security_guard_symbol, environment); | |
1187 MZ_GC_UNREG(); | |
1188 } | |
1189 #else | |
1190 make_security_guard = scheme_builtin_value("make-security-guard"); | |
1191 MZ_GC_CHECK(); | |
1192 #endif | |
1193 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1194 // setup sandbox guards |
1894 | 1195 if (make_security_guard != NULL) |
1196 { | |
1197 Scheme_Object *args[3] = {NULL, NULL, NULL}; | |
1198 Scheme_Object *guard = NULL; | |
1199 Scheme_Config *config = NULL; | |
1200 MZ_GC_DECL_REG(5); | |
1201 MZ_GC_ARRAY_VAR_IN_REG(0, args, 3); | |
1202 MZ_GC_VAR_IN_REG(3, guard); | |
1203 MZ_GC_VAR_IN_REG(4, config); | |
1204 MZ_GC_REG(); | |
4074 | 1205 config = scheme_current_config(); |
1894 | 1206 MZ_GC_CHECK(); |
1207 args[0] = scheme_get_param(config, MZCONFIG_SECURITY_GUARD); | |
1208 MZ_GC_CHECK(); | |
1209 args[1] = scheme_make_prim_w_arity(sandbox_file_guard, | |
1210 "sandbox-file-guard", 3, 3); | |
1211 args[2] = scheme_make_prim_w_arity(sandbox_network_guard, | |
1212 "sandbox-network-guard", 4, 4); | |
1213 guard = scheme_apply(make_security_guard, 3, args); | |
1214 MZ_GC_CHECK(); | |
1215 scheme_set_param(config, MZCONFIG_SECURITY_GUARD, guard); | |
1216 MZ_GC_CHECK(); | |
1217 MZ_GC_UNREG(); | |
1218 } | |
1219 MZ_GC_UNREG(); | |
274 | 1220 } |
1221 #endif | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1222 // Create buffer and window types for use in Scheme code |
14 | 1223 mz_buffer_type = scheme_make_type("<vim-buffer>"); |
1894 | 1224 MZ_GC_CHECK(); |
14 | 1225 mz_window_type = scheme_make_type("<vim-window>"); |
1894 | 1226 MZ_GC_CHECK(); |
1227 #ifdef MZ_PRECISE_GC | |
1228 GC_register_traversers(mz_buffer_type, | |
1229 buffer_size_proc, buffer_mark_proc, buffer_fixup_proc, | |
1230 TRUE, TRUE); | |
1231 GC_register_traversers(mz_window_type, | |
1232 window_size_proc, window_mark_proc, window_fixup_proc, | |
1233 TRUE, TRUE); | |
1234 #endif | |
1235 | |
1236 make_modules(); | |
14 | 1237 |
1238 /* | |
1239 * setup callback to receive notifications | |
1240 * whether thread scheduling is (or not) required | |
1241 */ | |
1242 scheme_notify_multithread = notify_multithread; | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1243 |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1244 return 0; |
14 | 1245 } |
1246 | |
1247 /* | |
1248 * This routine is called for each new invocation of MzScheme | |
1249 * to make sure things are properly initialized. | |
1250 */ | |
1251 static int | |
1252 mzscheme_init(void) | |
1253 { | |
1254 if (!initialized) | |
1255 { | |
137 | 1256 #ifdef DYNAMIC_MZSCHEME |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1257 if (disabled || !mzscheme_enabled(TRUE)) |
137 | 1258 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15412
diff
changeset
|
1259 emsg(_("E815: Sorry, this command is disabled, the MzScheme libraries could not be loaded.")); |
137 | 1260 return -1; |
1261 } | |
1262 #endif | |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1263 if (load_base_module_failed || startup_mzscheme()) |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1264 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15412
diff
changeset
|
1265 emsg(_("E895: Sorry, this command is disabled, the MzScheme's racket/base module could not be loaded.")); |
7609
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1266 return -1; |
77a14f3bc18b
commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents:
6949
diff
changeset
|
1267 } |
1894 | 1268 initialized = TRUE; |
14 | 1269 } |
1270 { | |
1894 | 1271 Scheme_Config *config = NULL; |
1272 MZ_GC_DECL_REG(1); | |
1273 MZ_GC_VAR_IN_REG(0, config); | |
1274 MZ_GC_REG(); | |
4074 | 1275 config = scheme_current_config(); |
1894 | 1276 MZ_GC_CHECK(); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1277 // recreate ports each call effectively clearing these ones |
4074 | 1278 curout = scheme_make_byte_string_output_port(); |
1894 | 1279 MZ_GC_CHECK(); |
4074 | 1280 curerr = scheme_make_byte_string_output_port(); |
1894 | 1281 MZ_GC_CHECK(); |
1282 scheme_set_param(config, MZCONFIG_OUTPUT_PORT, curout); | |
1283 MZ_GC_CHECK(); | |
1284 scheme_set_param(config, MZCONFIG_ERROR_PORT, curerr); | |
1285 MZ_GC_CHECK(); | |
1286 MZ_GC_UNREG(); | |
14 | 1287 } |
1288 | |
1289 return 0; | |
1290 } | |
1291 | |
1292 /* | |
1293 *======================================================================== | |
1294 * 2. External Interface | |
1295 *======================================================================== | |
1296 */ | |
1297 | |
1298 /* | |
1894 | 1299 * Evaluate command with exception handling |
14 | 1300 */ |
1301 static int | |
1894 | 1302 eval_with_exn_handling(void *data, Scheme_Closed_Prim *what, Scheme_Object **ret) |
14 | 1303 { |
1894 | 1304 Scheme_Object *value = NULL; |
1305 Scheme_Object *exn = NULL; | |
1306 Scheme_Object *prim = NULL; | |
1307 | |
1308 MZ_GC_DECL_REG(3); | |
1309 MZ_GC_VAR_IN_REG(0, value); | |
1310 MZ_GC_VAR_IN_REG(1, exn); | |
1311 MZ_GC_VAR_IN_REG(2, prim); | |
1312 MZ_GC_REG(); | |
1313 | |
1314 prim = scheme_make_closed_prim_w_arity(what, data, "mzvim", 0, 0); | |
1315 MZ_GC_CHECK(); | |
1316 value = _apply_thunk_catch_exceptions(prim, &exn); | |
1317 MZ_GC_CHECK(); | |
14 | 1318 |
1319 if (!value) | |
1320 { | |
1321 value = extract_exn_message(exn); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1322 // Got an exn? |
14 | 1323 if (value) |
1324 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1325 scheme_display(value, curerr); // Send to stderr-vim |
1894 | 1326 MZ_GC_CHECK(); |
14 | 1327 do_flush(); |
1328 } | |
1894 | 1329 MZ_GC_UNREG(); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1330 // `raise' was called on some arbitrary value |
14 | 1331 return FAIL; |
1332 } | |
1333 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1334 if (ret != NULL) // if pointer to retval supported give it up |
14 | 1335 *ret = value; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1336 // Print any result, as long as it's not a void |
14 | 1337 else if (!SCHEME_VOIDP(value)) |
1894 | 1338 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1339 scheme_display(value, curout); // Send to stdout-vim |
1894 | 1340 MZ_GC_CHECK(); |
1341 } | |
14 | 1342 |
1343 do_flush(); | |
1894 | 1344 MZ_GC_UNREG(); |
14 | 1345 return OK; |
1346 } | |
1347 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1348 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1349 * :mzscheme |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1350 */ |
14 | 1351 static int |
1352 do_mzscheme_command(exarg_T *eap, void *data, Scheme_Closed_Prim *what) | |
1353 { | |
1354 if (mzscheme_init()) | |
1355 return FAIL; | |
1356 | |
1357 range_start = eap->line1; | |
1358 range_end = eap->line2; | |
1359 | |
1894 | 1360 return eval_with_exn_handling(data, what, NULL); |
14 | 1361 } |
1362 | |
1363 /* | |
1364 * Routine called by VIM when deleting a buffer | |
1365 */ | |
1366 void | |
1367 mzscheme_buffer_free(buf_T *buf) | |
1368 { | |
502 | 1369 if (buf->b_mzscheme_ref) |
14 | 1370 { |
4074 | 1371 vim_mz_buffer *bp = NULL; |
1372 MZ_GC_DECL_REG(1); | |
1373 MZ_GC_VAR_IN_REG(0, bp); | |
1374 MZ_GC_REG(); | |
1375 | |
1376 bp = BUFFER_REF(buf); | |
14 | 1377 bp->buf = INVALID_BUFFER_VALUE; |
4074 | 1378 #ifndef MZ_PRECISE_GC |
14 | 1379 scheme_gc_ptr_ok(bp); |
4074 | 1380 #else |
1381 scheme_free_immobile_box(buf->b_mzscheme_ref); | |
1382 #endif | |
1383 buf->b_mzscheme_ref = NULL; | |
1894 | 1384 MZ_GC_CHECK(); |
4074 | 1385 MZ_GC_UNREG(); |
14 | 1386 } |
1387 } | |
1388 | |
1389 /* | |
1390 * Routine called by VIM when deleting a Window | |
1391 */ | |
1392 void | |
1393 mzscheme_window_free(win_T *win) | |
1394 { | |
502 | 1395 if (win->w_mzscheme_ref) |
14 | 1396 { |
4074 | 1397 vim_mz_window *wp = NULL; |
1398 MZ_GC_DECL_REG(1); | |
1399 MZ_GC_VAR_IN_REG(0, wp); | |
1400 MZ_GC_REG(); | |
1401 wp = WINDOW_REF(win); | |
14 | 1402 wp->win = INVALID_WINDOW_VALUE; |
4074 | 1403 #ifndef MZ_PRECISE_GC |
14 | 1404 scheme_gc_ptr_ok(wp); |
4074 | 1405 #else |
1406 scheme_free_immobile_box(win->w_mzscheme_ref); | |
1407 #endif | |
1408 win->w_mzscheme_ref = NULL; | |
1894 | 1409 MZ_GC_CHECK(); |
4074 | 1410 MZ_GC_UNREG(); |
14 | 1411 } |
1412 } | |
1413 | |
1414 /* | |
1415 * ":mzscheme" (or ":mz") | |
1416 */ | |
1417 void | |
1418 ex_mzscheme(exarg_T *eap) | |
1419 { | |
1420 char_u *script; | |
1421 | |
1422 script = script_get(eap, eap->arg); | |
1423 if (!eap->skip) | |
1424 { | |
1425 if (script == NULL) | |
1426 do_mzscheme_command(eap, eap->arg, do_eval); | |
1427 else | |
1428 { | |
1429 do_mzscheme_command(eap, script, do_eval); | |
1430 vim_free(script); | |
1431 } | |
1432 } | |
1433 } | |
1434 | |
1435 static Scheme_Object * | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1436 do_load(void *data, int noargc UNUSED, Scheme_Object **noargv UNUSED) |
14 | 1437 { |
1894 | 1438 Scheme_Object *expr = NULL; |
1439 Scheme_Object *result = NULL; | |
1440 char *file = NULL; | |
1441 Port_Info *pinfo = (Port_Info *)data; | |
1442 | |
1443 MZ_GC_DECL_REG(3); | |
1444 MZ_GC_VAR_IN_REG(0, expr); | |
1445 MZ_GC_VAR_IN_REG(1, result); | |
1446 MZ_GC_VAR_IN_REG(2, file); | |
1447 MZ_GC_REG(); | |
1448 | |
1449 file = (char *)scheme_malloc_fail_ok(scheme_malloc_atomic, MAXPATHL + 1); | |
1450 MZ_GC_CHECK(); | |
14 | 1451 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1452 // make Vim expansion |
1894 | 1453 expand_env((char_u *)pinfo->name, (char_u *)file, MAXPATHL); |
14 | 1454 pinfo->port = scheme_open_input_file(file, "mzfile"); |
1894 | 1455 MZ_GC_CHECK(); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1456 scheme_count_lines(pinfo->port); // to get accurate read error location |
1894 | 1457 MZ_GC_CHECK(); |
14 | 1458 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1459 // Like REPL but print only last result |
14 | 1460 while (!SCHEME_EOFP(expr = scheme_read(pinfo->port))) |
1894 | 1461 { |
1462 result = scheme_eval(expr, environment); | |
1463 MZ_GC_CHECK(); | |
1464 } | |
14 | 1465 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1466 // errors will be caught in do_mzscheme_command and ex_mzfile |
14 | 1467 scheme_close_input_port(pinfo->port); |
1894 | 1468 MZ_GC_CHECK(); |
14 | 1469 pinfo->port = NULL; |
1894 | 1470 MZ_GC_UNREG(); |
14 | 1471 return result; |
1472 } | |
1473 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1474 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1475 * :mzfile |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1476 */ |
14 | 1477 void |
1478 ex_mzfile(exarg_T *eap) | |
1479 { | |
1894 | 1480 Port_Info pinfo = {NULL, NULL}; |
1481 | |
1482 MZ_GC_DECL_REG(1); | |
1483 MZ_GC_VAR_IN_REG(0, pinfo.port); | |
1484 MZ_GC_REG(); | |
14 | 1485 |
1486 pinfo.name = (char *)eap->arg; | |
1487 if (do_mzscheme_command(eap, &pinfo, do_load) != OK | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1488 && pinfo.port != NULL) // looks like port was not closed |
1894 | 1489 { |
14 | 1490 scheme_close_input_port(pinfo.port); |
1894 | 1491 MZ_GC_CHECK(); |
1492 } | |
1493 MZ_GC_UNREG(); | |
14 | 1494 } |
1495 | |
1496 | |
1497 /* | |
1498 *======================================================================== | |
1499 * Exception handling code -- cribbed form the MzScheme sources and | |
1500 * Matthew Flatt's "Inside PLT MzScheme" document. | |
1501 *======================================================================== | |
1502 */ | |
1503 static void | |
1504 init_exn_catching_apply(void) | |
1505 { | |
1506 if (!exn_catching_apply) | |
1507 { | |
1508 char *e = | |
1509 "(lambda (thunk) " | |
856 | 1510 "(with-handlers ([void (lambda (exn) (cons #f exn))]) " |
14 | 1511 "(cons #t (thunk))))"; |
1512 | |
1894 | 1513 exn_catching_apply = scheme_eval_string(e, environment); |
1514 MZ_GC_CHECK(); | |
1515 exn_p = scheme_builtin_value("exn?"); | |
1516 MZ_GC_CHECK(); | |
1517 exn_message = scheme_builtin_value("exn-message"); | |
1518 MZ_GC_CHECK(); | |
14 | 1519 } |
1520 } | |
1521 | |
1522 /* | |
1523 * This function applies a thunk, returning the Scheme value if there's | |
1524 * no exception, otherwise returning NULL and setting *exn to the raised | |
1525 * value (usually an exn structure). | |
1526 */ | |
1527 static Scheme_Object * | |
1528 _apply_thunk_catch_exceptions(Scheme_Object *f, Scheme_Object **exn) | |
1529 { | |
1530 Scheme_Object *v; | |
1531 | |
1532 v = _scheme_apply(exn_catching_apply, 1, &f); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1533 // v is a pair: (cons #t value) or (cons #f exn) |
14 | 1534 |
1535 if (SCHEME_TRUEP(SCHEME_CAR(v))) | |
1536 return SCHEME_CDR(v); | |
1537 else | |
1538 { | |
1539 *exn = SCHEME_CDR(v); | |
1540 return NULL; | |
1541 } | |
1542 } | |
1543 | |
1544 static Scheme_Object * | |
1545 extract_exn_message(Scheme_Object *v) | |
1546 { | |
1547 if (SCHEME_TRUEP(_scheme_apply(exn_p, 1, &v))) | |
1548 return _scheme_apply(exn_message, 1, &v); | |
1549 else | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1550 return NULL; // Not an exn structure |
14 | 1551 } |
1552 | |
1553 static Scheme_Object * | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1554 do_eval(void *s, int noargc UNUSED, Scheme_Object **noargv UNUSED) |
14 | 1555 { |
1894 | 1556 return scheme_eval_string_all((char *)s, environment, TRUE); |
14 | 1557 } |
1558 | |
1559 /* | |
1560 *======================================================================== | |
1561 * 3. MzScheme I/O Handlers | |
1562 *======================================================================== | |
1563 */ | |
1564 static void | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1565 do_intrnl_output(char *mesg, int error) |
14 | 1566 { |
1567 char *p, *prev; | |
1568 | |
1569 prev = mesg; | |
1570 p = strchr(prev, '\n'); | |
1571 while (p) | |
1572 { | |
1573 *p = '\0'; | |
1574 if (error) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15412
diff
changeset
|
1575 emsg(prev); |
14 | 1576 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1577 msg(prev); |
14 | 1578 prev = p + 1; |
1579 p = strchr(prev, '\n'); | |
1580 } | |
1581 | |
1582 if (error) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15412
diff
changeset
|
1583 emsg(prev); |
14 | 1584 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1585 msg(prev); |
14 | 1586 } |
1587 | |
1588 static void | |
4074 | 1589 do_output(char *mesg, OUTPUT_LEN_TYPE len UNUSED) |
14 | 1590 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1591 // TODO: use len, the string may not be NUL terminated |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1592 do_intrnl_output(mesg, 0); |
14 | 1593 } |
1594 | |
1595 static void | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1596 do_err_output(char *mesg) |
14 | 1597 { |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1598 do_intrnl_output(mesg, 1); |
14 | 1599 } |
1600 | |
1601 static void | |
1602 do_printf(char *format, ...) | |
1603 { | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1604 do_intrnl_output(format, 1); |
14 | 1605 } |
1606 | |
1607 static void | |
1608 do_flush(void) | |
1609 { | |
1610 char *buff; | |
4074 | 1611 OUTPUT_LEN_TYPE length; |
1612 | |
1613 buff = scheme_get_sized_byte_string_output(curerr, &length); | |
1894 | 1614 MZ_GC_CHECK(); |
14 | 1615 if (length) |
1616 { | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1617 do_err_output(buff); |
14 | 1618 return; |
1619 } | |
1620 | |
4074 | 1621 buff = scheme_get_sized_byte_string_output(curout, &length); |
1894 | 1622 MZ_GC_CHECK(); |
14 | 1623 if (length) |
1624 do_output(buff, length); | |
1625 } | |
1626 | |
1627 /* | |
1628 *======================================================================== | |
1629 * 4. Implementation of the Vim Features for MzScheme | |
1630 *======================================================================== | |
1631 */ | |
1632 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1633 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1634 * (command {command-string}) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1635 */ |
14 | 1636 static Scheme_Object * |
1637 vim_command(void *data, int argc, Scheme_Object **argv) | |
1638 { | |
1639 Vim_Prim *prim = (Vim_Prim *)data; | |
4074 | 1640 Scheme_Object *cmd = NULL; |
1641 MZ_GC_DECL_REG(1); | |
1642 MZ_GC_VAR_IN_REG(0, cmd); | |
1643 MZ_GC_REG(); | |
1644 cmd = GUARANTEED_STRING_ARG(prim->name, 0); | |
14 | 1645 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1646 // may be use do_cmdline_cmd? |
4074 | 1647 do_cmdline(BYTE_STRING_VALUE(cmd), NULL, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE); |
14 | 1648 update_screen(VALID); |
1649 | |
4074 | 1650 MZ_GC_UNREG(); |
14 | 1651 raise_if_error(); |
1652 return scheme_void; | |
1653 } | |
1654 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1655 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1656 * (eval {expr-string}) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1657 */ |
14 | 1658 static Scheme_Object * |
4082 | 1659 vim_eval(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) |
14 | 1660 { |
1661 #ifdef FEAT_EVAL | |
1894 | 1662 Vim_Prim *prim = (Vim_Prim *)data; |
4074 | 1663 Scheme_Object *result = NULL; |
1894 | 1664 typval_T *vim_result; |
4074 | 1665 Scheme_Object *expr = NULL; |
1666 MZ_GC_DECL_REG(2); | |
1667 MZ_GC_VAR_IN_REG(0, result); | |
1668 MZ_GC_VAR_IN_REG(1, expr); | |
1894 | 1669 MZ_GC_REG(); |
4074 | 1670 expr = GUARANTEED_STRING_ARG(prim->name, 0); |
1671 | |
1672 vim_result = eval_expr(BYTE_STRING_VALUE(expr), NULL); | |
1894 | 1673 |
1674 if (vim_result == NULL) | |
14 | 1675 raise_vim_exn(_("invalid expression")); |
1676 | |
4074 | 1677 result = vim_to_mzscheme(vim_result); |
1678 MZ_GC_CHECK(); | |
1894 | 1679 free_tv(vim_result); |
1680 | |
1681 MZ_GC_UNREG(); | |
14 | 1682 return result; |
1683 #else | |
1684 raise_vim_exn(_("expressions disabled at compile time")); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1685 // unreachable |
14 | 1686 return scheme_false; |
1687 #endif | |
1688 } | |
1689 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1690 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1691 * (range-start) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1692 */ |
14 | 1693 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1694 get_range_start(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) |
14 | 1695 { |
1696 return scheme_make_integer(range_start); | |
1697 } | |
1698 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1699 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1700 * (range-end) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1701 */ |
14 | 1702 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1703 get_range_end(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) |
14 | 1704 { |
1705 return scheme_make_integer(range_end); | |
1706 } | |
1707 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1708 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1709 * (beep) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1710 */ |
14 | 1711 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1712 mzscheme_beep(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) |
14 | 1713 { |
6949 | 1714 vim_beep(BO_LANG); |
14 | 1715 return scheme_void; |
1716 } | |
1717 | |
1718 static Scheme_Object *M_global = NULL; | |
1719 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1720 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1721 * (get-option {option-name}) [buffer/window] |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1722 */ |
14 | 1723 static Scheme_Object * |
1724 get_option(void *data, int argc, Scheme_Object **argv) | |
1725 { | |
1726 Vim_Prim *prim = (Vim_Prim *)data; | |
1727 long value; | |
1894 | 1728 char *strval; |
14 | 1729 int rc; |
4074 | 1730 Scheme_Object *rval = NULL; |
1731 Scheme_Object *name = NULL; | |
14 | 1732 int opt_flags = 0; |
1733 buf_T *save_curb = curbuf; | |
1734 win_T *save_curw = curwin; | |
1735 | |
4074 | 1736 MZ_GC_DECL_REG(2); |
1737 MZ_GC_VAR_IN_REG(0, rval); | |
1738 MZ_GC_VAR_IN_REG(1, name); | |
1739 MZ_GC_REG(); | |
1740 | |
1741 name = GUARANTEED_STRING_ARG(prim->name, 0); | |
14 | 1742 |
1743 if (argc > 1) | |
1744 { | |
1745 if (M_global == NULL) | |
1746 { | |
1747 MZ_REGISTER_STATIC(M_global); | |
1748 M_global = scheme_intern_symbol("global"); | |
1894 | 1749 MZ_GC_CHECK(); |
14 | 1750 } |
1751 | |
1752 if (argv[1] == M_global) | |
1753 opt_flags = OPT_GLOBAL; | |
1754 else if (SCHEME_VIMBUFFERP(argv[1])) | |
1755 { | |
1756 curbuf = get_valid_buffer(argv[1]); | |
1757 opt_flags = OPT_LOCAL; | |
1758 } | |
1759 else if (SCHEME_VIMWINDOWP(argv[1])) | |
1760 { | |
1761 win_T *win = get_valid_window(argv[1]); | |
1762 | |
1763 curwin = win; | |
1764 curbuf = win->w_buffer; | |
1765 opt_flags = OPT_LOCAL; | |
1766 } | |
1767 else | |
1768 scheme_wrong_type(prim->name, "vim-buffer/window", 1, argc, argv); | |
1769 } | |
1770 | |
4074 | 1771 rc = get_option_value(BYTE_STRING_VALUE(name), &value, (char_u **)&strval, opt_flags); |
14 | 1772 curbuf = save_curb; |
1773 curwin = save_curw; | |
1774 | |
1775 switch (rc) | |
1776 { | |
1777 case 1: | |
4074 | 1778 MZ_GC_UNREG(); |
14 | 1779 return scheme_make_integer_value(value); |
1780 case 0: | |
4074 | 1781 rval = scheme_make_byte_string(strval); |
1894 | 1782 MZ_GC_CHECK(); |
14 | 1783 vim_free(strval); |
4074 | 1784 MZ_GC_UNREG(); |
14 | 1785 return rval; |
1786 case -1: | |
1787 case -2: | |
4074 | 1788 MZ_GC_UNREG(); |
856 | 1789 raise_vim_exn(_("hidden option")); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1790 //NOTREACHED |
14 | 1791 case -3: |
4074 | 1792 MZ_GC_UNREG(); |
856 | 1793 raise_vim_exn(_("unknown option")); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1794 //NOTREACHED |
14 | 1795 } |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1796 // unreachable |
14 | 1797 return scheme_void; |
1798 } | |
1799 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1800 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1801 * (set-option {option-changing-string} [buffer/window]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1802 */ |
14 | 1803 static Scheme_Object * |
1804 set_option(void *data, int argc, Scheme_Object **argv) | |
1805 { | |
4074 | 1806 char_u *command = NULL; |
14 | 1807 int opt_flags = 0; |
1808 buf_T *save_curb = curbuf; | |
1809 win_T *save_curw = curwin; | |
1810 Vim_Prim *prim = (Vim_Prim *)data; | |
4074 | 1811 Scheme_Object *cmd = NULL; |
1812 | |
1813 MZ_GC_DECL_REG(1); | |
1814 MZ_GC_VAR_IN_REG(0, cmd); | |
1815 MZ_GC_REG(); | |
1816 cmd = GUARANTEED_STRING_ARG(prim->name, 0); | |
1817 | |
14 | 1818 if (argc > 1) |
1819 { | |
1820 if (M_global == NULL) | |
1821 { | |
1822 MZ_REGISTER_STATIC(M_global); | |
1823 M_global = scheme_intern_symbol("global"); | |
1894 | 1824 MZ_GC_CHECK(); |
14 | 1825 } |
1826 | |
1827 if (argv[1] == M_global) | |
1828 opt_flags = OPT_GLOBAL; | |
1829 else if (SCHEME_VIMBUFFERP(argv[1])) | |
1830 { | |
1831 curbuf = get_valid_buffer(argv[1]); | |
1832 opt_flags = OPT_LOCAL; | |
1833 } | |
1834 else if (SCHEME_VIMWINDOWP(argv[1])) | |
1835 { | |
1836 win_T *win = get_valid_window(argv[1]); | |
1837 curwin = win; | |
1838 curbuf = win->w_buffer; | |
1839 opt_flags = OPT_LOCAL; | |
1840 } | |
1841 else | |
1842 scheme_wrong_type(prim->name, "vim-buffer/window", 1, argc, argv); | |
1843 } | |
1844 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1845 // do_set can modify cmd, make copy |
4074 | 1846 command = vim_strsave(BYTE_STRING_VALUE(cmd)); |
1847 MZ_GC_UNREG(); | |
1848 do_set(command, opt_flags); | |
1849 vim_free(command); | |
14 | 1850 update_screen(NOT_VALID); |
1851 curbuf = save_curb; | |
1852 curwin = save_curw; | |
1853 raise_if_error(); | |
1854 return scheme_void; | |
1855 } | |
1856 | |
1857 /* | |
1858 *=========================================================================== | |
1859 * 5. Vim Window-related Manipulation Functions | |
1860 *=========================================================================== | |
1861 */ | |
1862 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1863 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1864 * (curr-win) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1865 */ |
14 | 1866 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1867 get_curr_win(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) |
14 | 1868 { |
1869 return (Scheme_Object *)get_vim_curr_window(); | |
1870 } | |
1871 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1872 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1873 * (win-count) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1874 */ |
14 | 1875 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
1876 get_window_count(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) |
14 | 1877 { |
4082 | 1878 int n = 0; |
14 | 1879 win_T *w; |
1880 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9289
diff
changeset
|
1881 FOR_ALL_WINDOWS(w) |
671 | 1882 ++n; |
14 | 1883 return scheme_make_integer(n); |
1884 } | |
1885 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1886 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1887 * (get-win-list [buffer]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1888 */ |
14 | 1889 static Scheme_Object * |
1890 get_window_list(void *data, int argc, Scheme_Object **argv) | |
1891 { | |
1892 Vim_Prim *prim = (Vim_Prim *)data; | |
1893 vim_mz_buffer *buf; | |
1894 Scheme_Object *list; | |
4082 | 1895 win_T *w = firstwin; |
14 | 1896 |
1897 buf = get_buffer_arg(prim->name, 0, argc, argv); | |
1898 list = scheme_null; | |
1899 | |
4082 | 1900 for ( ; w != NULL; w = w->w_next) |
856 | 1901 if (w->w_buffer == buf->buf) |
1894 | 1902 { |
14 | 1903 list = scheme_make_pair(window_new(w), list); |
1894 | 1904 MZ_GC_CHECK(); |
1905 } | |
14 | 1906 |
1907 return list; | |
1908 } | |
1909 | |
1910 static Scheme_Object * | |
1911 window_new(win_T *win) | |
1912 { | |
1894 | 1913 vim_mz_window *self = NULL; |
1914 | |
1915 MZ_GC_DECL_REG(1); | |
1916 MZ_GC_VAR_IN_REG(0, self); | |
14 | 1917 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1918 // We need to handle deletion of windows underneath us. |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1919 // If we add a "w_mzscheme_ref" field to the win_T structure, |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1920 // then we can get at it in win_free() in vim. |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1921 // |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1922 // On a win_free() we set the Scheme object's win_T *field |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1923 // to an invalid value. We trap all uses of a window |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1924 // object, and reject them if the win_T *field is invalid. |
502 | 1925 if (win->w_mzscheme_ref != NULL) |
4074 | 1926 return (Scheme_Object *)WINDOW_REF(win); |
1927 | |
1928 MZ_GC_REG(); | |
1929 self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_window)); | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
1930 CLEAR_POINTER(self); |
4074 | 1931 #ifndef MZ_PRECISE_GC |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1932 scheme_dont_gc_ptr(self); // because win isn't visible to GC |
4074 | 1933 #else |
1934 win->w_mzscheme_ref = scheme_malloc_immobile_box(NULL); | |
1935 #endif | |
1894 | 1936 MZ_GC_CHECK(); |
4074 | 1937 WINDOW_REF(win) = self; |
1938 MZ_GC_CHECK(); | |
14 | 1939 self->win = win; |
1894 | 1940 self->so.type = mz_window_type; |
1941 | |
1942 MZ_GC_UNREG(); | |
4074 | 1943 return (Scheme_Object *)self; |
14 | 1944 } |
1945 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1946 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1947 * (get-win-num [window]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1948 */ |
14 | 1949 static Scheme_Object * |
4082 | 1950 get_window_num(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) |
14 | 1951 { |
4082 | 1952 int nr = 1; |
14 | 1953 Vim_Prim *prim = (Vim_Prim *)data; |
1954 win_T *win = get_window_arg(prim->name, 0, argc, argv)->win; | |
1955 win_T *wp; | |
1956 | |
1957 for (wp = firstwin; wp != win; wp = wp->w_next) | |
1958 ++nr; | |
1959 | |
1960 return scheme_make_integer(nr); | |
1961 } | |
1962 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1963 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1964 * (get-win-by-num {windownum}) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1965 */ |
14 | 1966 static Scheme_Object * |
1967 get_window_by_num(void *data, int argc, Scheme_Object **argv) | |
1968 { | |
1969 Vim_Prim *prim = (Vim_Prim *)data; | |
4082 | 1970 win_T *win = firstwin; |
14 | 1971 int fnum; |
1972 | |
1973 fnum = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); | |
1974 if (fnum < 1) | |
1975 scheme_signal_error(_("window index is out of range")); | |
1976 | |
4082 | 1977 for ( ; win != NULL; win = win->w_next, --fnum) |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1978 if (fnum == 1) // to be 1-based |
14 | 1979 return window_new(win); |
1980 | |
1981 return scheme_false; | |
1982 } | |
1983 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1984 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1985 * (get-win-buffer [window]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1986 */ |
14 | 1987 static Scheme_Object * |
1988 get_window_buffer(void *data, int argc, Scheme_Object **argv) | |
1989 { | |
1990 Vim_Prim *prim = (Vim_Prim *)data; | |
1991 vim_mz_window *win = get_window_arg(prim->name, 0, argc, argv); | |
1992 | |
1993 return buffer_new(win->win->w_buffer); | |
1994 } | |
1995 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1996 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1997 * (get-win-height [window]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1998 */ |
14 | 1999 static Scheme_Object * |
2000 get_window_height(void *data, int argc, Scheme_Object **argv) | |
2001 { | |
2002 Vim_Prim *prim = (Vim_Prim *)data; | |
2003 vim_mz_window *win = get_window_arg(prim->name, 0, argc, argv); | |
2004 | |
2005 return scheme_make_integer(win->win->w_height); | |
2006 } | |
2007 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2008 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2009 * (set-win-height {height} [window]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2010 */ |
14 | 2011 static Scheme_Object * |
2012 set_window_height(void *data, int argc, Scheme_Object **argv) | |
2013 { | |
2014 Vim_Prim *prim = (Vim_Prim *)data; | |
2015 vim_mz_window *win; | |
2016 win_T *savewin; | |
2017 int height; | |
2018 | |
2019 win = get_window_arg(prim->name, 1, argc, argv); | |
2020 height = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); | |
2021 | |
2022 #ifdef FEAT_GUI | |
2023 need_mouse_correct = TRUE; | |
2024 #endif | |
2025 | |
2026 savewin = curwin; | |
2027 curwin = win->win; | |
2028 win_setheight(height); | |
2029 curwin = savewin; | |
2030 | |
2031 raise_if_error(); | |
2032 return scheme_void; | |
2033 } | |
2034 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2035 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2036 * (get-win-width [window]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2037 */ |
14 | 2038 static Scheme_Object * |
2039 get_window_width(void *data, int argc, Scheme_Object **argv) | |
2040 { | |
2041 Vim_Prim *prim = (Vim_Prim *)data; | |
2042 vim_mz_window *win = get_window_arg(prim->name, 0, argc, argv); | |
2043 | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
2044 return scheme_make_integer(win->win->w_width); |
14 | 2045 } |
2046 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2047 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2048 * (set-win-width {width} [window]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2049 */ |
14 | 2050 static Scheme_Object * |
2051 set_window_width(void *data, int argc, Scheme_Object **argv) | |
2052 { | |
2053 Vim_Prim *prim = (Vim_Prim *)data; | |
2054 vim_mz_window *win; | |
2055 win_T *savewin; | |
2056 int width = 0; | |
2057 | |
2058 win = get_window_arg(prim->name, 1, argc, argv); | |
2059 width = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); | |
2060 | |
2061 # ifdef FEAT_GUI | |
2062 need_mouse_correct = TRUE; | |
2063 # endif | |
2064 | |
2065 savewin = curwin; | |
2066 curwin = win->win; | |
2067 win_setwidth(width); | |
2068 curwin = savewin; | |
2069 | |
2070 raise_if_error(); | |
2071 return scheme_void; | |
2072 } | |
2073 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2074 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2075 * (get-cursor [window]) -> (line . col) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2076 */ |
14 | 2077 static Scheme_Object * |
2078 get_cursor(void *data, int argc, Scheme_Object **argv) | |
2079 { | |
2080 Vim_Prim *prim = (Vim_Prim *)data; | |
2081 vim_mz_window *win; | |
2082 pos_T pos; | |
2083 | |
2084 win = get_window_arg(prim->name, 0, argc, argv); | |
2085 pos = win->win->w_cursor; | |
2086 return scheme_make_pair(scheme_make_integer_value((long)pos.lnum), | |
2087 scheme_make_integer_value((long)pos.col + 1)); | |
2088 } | |
2089 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2090 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2091 * (set-cursor (line . col) [window]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2092 */ |
14 | 2093 static Scheme_Object * |
2094 set_cursor(void *data, int argc, Scheme_Object **argv) | |
2095 { | |
2096 Vim_Prim *prim = (Vim_Prim *)data; | |
2097 vim_mz_window *win; | |
2098 long lnum = 0; | |
2099 long col = 0; | |
2100 | |
274 | 2101 #ifdef HAVE_SANDBOX |
2102 sandbox_check(); | |
2103 #endif | |
14 | 2104 win = get_window_arg(prim->name, 1, argc, argv); |
2105 GUARANTEE_PAIR(prim->name, 0); | |
2106 | |
2107 if (!SCHEME_INTP(SCHEME_CAR(argv[0])) | |
2108 || !SCHEME_INTP(SCHEME_CDR(argv[0]))) | |
2109 scheme_wrong_type(prim->name, "integer pair", 0, argc, argv); | |
2110 | |
2111 lnum = SCHEME_INT_VAL(SCHEME_CAR(argv[0])); | |
2112 col = SCHEME_INT_VAL(SCHEME_CDR(argv[0])) - 1; | |
2113 | |
2114 check_line_range(lnum, win->win->w_buffer); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2115 // don't know how to catch invalid column value |
14 | 2116 |
2117 win->win->w_cursor.lnum = lnum; | |
2118 win->win->w_cursor.col = col; | |
14395
c15bef307de6
patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents:
12608
diff
changeset
|
2119 win->win->w_set_curswant = TRUE; |
14 | 2120 update_screen(VALID); |
2121 | |
2122 raise_if_error(); | |
2123 return scheme_void; | |
2124 } | |
2125 /* | |
2126 *=========================================================================== | |
2127 * 6. Vim Buffer-related Manipulation Functions | |
2128 *=========================================================================== | |
2129 */ | |
2130 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2131 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2132 * (open-buff {filename}) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2133 */ |
14 | 2134 static Scheme_Object * |
2135 mzscheme_open_buffer(void *data, int argc, Scheme_Object **argv) | |
2136 { | |
2137 Vim_Prim *prim = (Vim_Prim *)data; | |
2138 int num = 0; | |
4074 | 2139 Scheme_Object *onum = NULL; |
2140 Scheme_Object *buf = NULL; | |
2141 Scheme_Object *fname; | |
2142 | |
2143 MZ_GC_DECL_REG(3); | |
2144 MZ_GC_VAR_IN_REG(0, onum); | |
2145 MZ_GC_VAR_IN_REG(1, buf); | |
2146 MZ_GC_VAR_IN_REG(2, fname); | |
2147 MZ_GC_REG(); | |
2148 fname = GUARANTEED_STRING_ARG(prim->name, 0); | |
14 | 2149 |
274 | 2150 #ifdef HAVE_SANDBOX |
2151 sandbox_check(); | |
2152 #endif | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2153 // TODO make open existing file |
4074 | 2154 num = buflist_add(BYTE_STRING_VALUE(fname), BLN_LISTED | BLN_CURBUF); |
14 | 2155 |
2156 if (num == 0) | |
2157 raise_vim_exn(_("couldn't open buffer")); | |
2158 | |
2159 onum = scheme_make_integer(num); | |
4074 | 2160 buf = get_buffer_by_num(data, 1, &onum); |
2161 MZ_GC_UNREG(); | |
2162 return buf; | |
14 | 2163 } |
2164 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2165 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2166 * (get-buff-by-num {buffernum}) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2167 */ |
14 | 2168 static Scheme_Object * |
2169 get_buffer_by_num(void *data, int argc, Scheme_Object **argv) | |
2170 { | |
2171 Vim_Prim *prim = (Vim_Prim *)data; | |
2172 buf_T *buf; | |
2173 int fnum; | |
2174 | |
2175 fnum = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); | |
2176 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9289
diff
changeset
|
2177 FOR_ALL_BUFFERS(buf) |
856 | 2178 if (buf->b_fnum == fnum) |
14 | 2179 return buffer_new(buf); |
2180 | |
2181 return scheme_false; | |
2182 } | |
2183 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2184 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2185 * (get-buff-by-name {buffername}) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2186 */ |
14 | 2187 static Scheme_Object * |
2188 get_buffer_by_name(void *data, int argc, Scheme_Object **argv) | |
2189 { | |
2190 Vim_Prim *prim = (Vim_Prim *)data; | |
2191 buf_T *buf; | |
4074 | 2192 Scheme_Object *buffer = NULL; |
2193 Scheme_Object *fname = NULL; | |
2194 | |
2195 MZ_GC_DECL_REG(2); | |
2196 MZ_GC_VAR_IN_REG(0, buffer); | |
2197 MZ_GC_VAR_IN_REG(1, fname); | |
2198 MZ_GC_REG(); | |
2199 fname = GUARANTEED_STRING_ARG(prim->name, 0); | |
2200 buffer = scheme_false; | |
14 | 2201 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9289
diff
changeset
|
2202 FOR_ALL_BUFFERS(buf) |
4074 | 2203 { |
14 | 2204 if (buf->b_ffname == NULL || buf->b_sfname == NULL) |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2205 // empty string |
14 | 2206 { |
4074 | 2207 if (BYTE_STRING_VALUE(fname)[0] == NUL) |
2208 buffer = buffer_new(buf); | |
14 | 2209 } |
4074 | 2210 else if (!fnamecmp(buf->b_ffname, BYTE_STRING_VALUE(fname)) |
2211 || !fnamecmp(buf->b_sfname, BYTE_STRING_VALUE(fname))) | |
2212 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2213 // either short or long filename matches |
4074 | 2214 buffer = buffer_new(buf); |
2215 } | |
2216 } | |
2217 | |
2218 MZ_GC_UNREG(); | |
2219 return buffer; | |
14 | 2220 } |
2221 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2222 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2223 * (get-next-buff [buffer]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2224 */ |
14 | 2225 static Scheme_Object * |
2226 get_next_buffer(void *data, int argc, Scheme_Object **argv) | |
2227 { | |
2228 Vim_Prim *prim = (Vim_Prim *)data; | |
2229 buf_T *buf = get_buffer_arg(prim->name, 0, argc, argv)->buf; | |
2230 | |
2231 if (buf->b_next == NULL) | |
2232 return scheme_false; | |
2233 else | |
2234 return buffer_new(buf->b_next); | |
2235 } | |
2236 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2237 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2238 * (get-prev-buff [buffer]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2239 */ |
14 | 2240 static Scheme_Object * |
2241 get_prev_buffer(void *data, int argc, Scheme_Object **argv) | |
2242 { | |
2243 Vim_Prim *prim = (Vim_Prim *)data; | |
2244 buf_T *buf = get_buffer_arg(prim->name, 0, argc, argv)->buf; | |
2245 | |
2246 if (buf->b_prev == NULL) | |
2247 return scheme_false; | |
2248 else | |
2249 return buffer_new(buf->b_prev); | |
2250 } | |
2251 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2252 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2253 * (get-buff-num [buffer]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2254 */ |
14 | 2255 static Scheme_Object * |
2256 get_buffer_num(void *data, int argc, Scheme_Object **argv) | |
2257 { | |
2258 Vim_Prim *prim = (Vim_Prim *)data; | |
2259 vim_mz_buffer *buf = get_buffer_arg(prim->name, 0, argc, argv); | |
2260 | |
2261 return scheme_make_integer(buf->buf->b_fnum); | |
2262 } | |
2263 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2264 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2265 * (buff-count) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2266 */ |
14 | 2267 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
2268 get_buffer_count(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) |
14 | 2269 { |
2270 buf_T *b; | |
2271 int n = 0; | |
2272 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9289
diff
changeset
|
2273 FOR_ALL_BUFFERS(b) ++n; |
14 | 2274 return scheme_make_integer(n); |
2275 } | |
2276 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2277 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2278 * (get-buff-name [buffer]) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2279 */ |
14 | 2280 static Scheme_Object * |
2281 get_buffer_name(void *data, int argc, Scheme_Object **argv) | |
2282 { | |
2283 Vim_Prim *prim = (Vim_Prim *)data; | |
2284 vim_mz_buffer *buf = get_buffer_arg(prim->name, 0, argc, argv); | |
2285 | |
4074 | 2286 return scheme_make_byte_string((char *)buf->buf->b_ffname); |
14 | 2287 } |
2288 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2289 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2290 * (curr-buff) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2291 */ |
14 | 2292 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
2293 get_curr_buffer(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) |
14 | 2294 { |
2295 return (Scheme_Object *)get_vim_curr_buffer(); | |
2296 } | |
2297 | |
2298 static Scheme_Object * | |
2299 buffer_new(buf_T *buf) | |
2300 { | |
1894 | 2301 vim_mz_buffer *self = NULL; |
2302 | |
2303 MZ_GC_DECL_REG(1); | |
2304 MZ_GC_VAR_IN_REG(0, self); | |
14 | 2305 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2306 // We need to handle deletion of buffers underneath us. |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2307 // If we add a "b_mzscheme_ref" field to the buf_T structure, |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2308 // then we can get at it in buf_freeall() in vim. |
502 | 2309 if (buf->b_mzscheme_ref) |
4074 | 2310 return (Scheme_Object *)BUFFER_REF(buf); |
2311 | |
2312 MZ_GC_REG(); | |
2313 self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_buffer)); | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
2314 CLEAR_POINTER(self); |
4074 | 2315 #ifndef MZ_PRECISE_GC |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2316 scheme_dont_gc_ptr(self); // because buf isn't visible to GC |
4074 | 2317 #else |
2318 buf->b_mzscheme_ref = scheme_malloc_immobile_box(NULL); | |
2319 #endif | |
1894 | 2320 MZ_GC_CHECK(); |
4074 | 2321 BUFFER_REF(buf) = self; |
2322 MZ_GC_CHECK(); | |
14 | 2323 self->buf = buf; |
1894 | 2324 self->so.type = mz_buffer_type; |
2325 | |
2326 MZ_GC_UNREG(); | |
4074 | 2327 return (Scheme_Object *)self; |
14 | 2328 } |
2329 | |
2330 /* | |
2331 * (get-buff-size [buffer]) | |
2332 * | |
2333 * Get the size (number of lines) in the current buffer. | |
2334 */ | |
2335 static Scheme_Object * | |
2336 get_buffer_size(void *data, int argc, Scheme_Object **argv) | |
2337 { | |
2338 Vim_Prim *prim = (Vim_Prim *)data; | |
2339 vim_mz_buffer *buf = get_buffer_arg(prim->name, 0, argc, argv); | |
2340 | |
2341 return scheme_make_integer(buf->buf->b_ml.ml_line_count); | |
2342 } | |
2343 | |
2344 /* | |
2345 * (get-buff-line {linenr} [buffer]) | |
2346 * | |
2347 * Get a line from the specified buffer. The line number is | |
2348 * in Vim format (1-based). The line is returned as a MzScheme | |
2349 * string object. | |
2350 */ | |
2351 static Scheme_Object * | |
2352 get_buffer_line(void *data, int argc, Scheme_Object **argv) | |
2353 { | |
2354 Vim_Prim *prim = (Vim_Prim *)data; | |
2355 vim_mz_buffer *buf; | |
2356 int linenr; | |
1894 | 2357 char_u *line; |
14 | 2358 |
2359 buf = get_buffer_arg(prim->name, 1, argc, argv); | |
2360 linenr = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); | |
2361 line = ml_get_buf(buf->buf, (linenr_T)linenr, FALSE); | |
2362 | |
2363 raise_if_error(); | |
4074 | 2364 return scheme_make_byte_string((char *)line); |
14 | 2365 } |
2366 | |
2367 | |
2368 /* | |
2369 * (get-buff-line-list {start} {end} [buffer]) | |
2370 * | |
2371 * Get a list of lines from the specified buffer. The line numbers | |
2372 * are in Vim format (1-based). The range is from lo up to, but not | |
2373 * including, hi. The list is returned as a list of string objects. | |
2374 */ | |
2375 static Scheme_Object * | |
2376 get_buffer_line_list(void *data, int argc, Scheme_Object **argv) | |
2377 { | |
2378 Vim_Prim *prim = (Vim_Prim *)data; | |
2379 vim_mz_buffer *buf; | |
2380 int i, hi, lo, n; | |
1894 | 2381 Scheme_Object *list = NULL; |
2382 | |
2383 MZ_GC_DECL_REG(1); | |
2384 MZ_GC_VAR_IN_REG(0, list); | |
2385 MZ_GC_REG(); | |
14 | 2386 |
2387 buf = get_buffer_arg(prim->name, 2, argc, argv); | |
2388 list = scheme_null; | |
2389 hi = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 1)); | |
2390 lo = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); | |
2391 | |
2392 /* | |
2393 * Handle some error conditions | |
2394 */ | |
2395 if (lo < 0) | |
856 | 2396 lo = 0; |
14 | 2397 |
2398 if (hi < 0) | |
2399 hi = 0; | |
2400 if (hi < lo) | |
856 | 2401 hi = lo; |
14 | 2402 |
2403 n = hi - lo; | |
2404 | |
2405 for (i = n; i >= 0; --i) | |
2406 { | |
4074 | 2407 Scheme_Object *str = scheme_make_byte_string( |
14 | 2408 (char *)ml_get_buf(buf->buf, (linenr_T)(lo+i), FALSE)); |
2409 raise_if_error(); | |
2410 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2411 // Set the list item |
14 | 2412 list = scheme_make_pair(str, list); |
1894 | 2413 MZ_GC_CHECK(); |
14 | 2414 } |
1894 | 2415 MZ_GC_UNREG(); |
14 | 2416 return list; |
2417 } | |
2418 | |
2419 /* | |
2420 * (set-buff-line {linenr} {string/#f} [buffer]) | |
2421 * | |
2422 * Replace a line in the specified buffer. The line number is | |
2423 * in Vim format (1-based). The replacement line is given as | |
2424 * an MzScheme string object. The object is checked for validity | |
2425 * and correct format. An exception is thrown if the values are not | |
2426 * the correct format. | |
2427 * | |
2428 * It returns a Scheme Object that indicates the length of the | |
2429 * string changed. | |
2430 */ | |
2431 static Scheme_Object * | |
2432 set_buffer_line(void *data, int argc, Scheme_Object **argv) | |
2433 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2434 // First of all, we check the value of the supplied MzScheme object. |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2435 // There are three cases: |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2436 // 1. #f - this is a deletion. |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2437 // 2. A string - this is a replacement. |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2438 // 3. Anything else - this is an error. |
14 | 2439 Vim_Prim *prim = (Vim_Prim *)data; |
2440 vim_mz_buffer *buf; | |
1894 | 2441 Scheme_Object *line = NULL; |
14 | 2442 char *save; |
2443 int n; | |
2444 | |
1894 | 2445 MZ_GC_DECL_REG(1); |
2446 MZ_GC_VAR_IN_REG(0, line); | |
2447 MZ_GC_REG(); | |
2448 | |
274 | 2449 #ifdef HAVE_SANDBOX |
2450 sandbox_check(); | |
2451 #endif | |
14 | 2452 n = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); |
2453 if (!SCHEME_STRINGP(argv[1]) && !SCHEME_FALSEP(argv[1])) | |
856 | 2454 scheme_wrong_type(prim->name, "string or #f", 1, argc, argv); |
14 | 2455 line = argv[1]; |
2456 buf = get_buffer_arg(prim->name, 2, argc, argv); | |
2457 | |
2458 check_line_range(n, buf->buf); | |
2459 | |
2460 if (SCHEME_FALSEP(line)) | |
2461 { | |
1894 | 2462 buf_T *savebuf = curbuf; |
2463 | |
14 | 2464 curbuf = buf->buf; |
2465 | |
2466 if (u_savedel((linenr_T)n, 1L) == FAIL) | |
2467 { | |
2468 curbuf = savebuf; | |
2469 raise_vim_exn(_("cannot save undo information")); | |
2470 } | |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2471 else if (ml_delete((linenr_T)n) == FAIL) |
14 | 2472 { |
2473 curbuf = savebuf; | |
2474 raise_vim_exn(_("cannot delete line")); | |
2475 } | |
2476 if (buf->buf == curwin->w_buffer) | |
2477 mz_fix_cursor(n, n + 1, -1); | |
1929 | 2478 deleted_lines_mark((linenr_T)n, 1L); |
14 | 2479 |
2480 curbuf = savebuf; | |
2481 | |
1894 | 2482 MZ_GC_UNREG(); |
14 | 2483 raise_if_error(); |
2484 return scheme_void; | |
2485 } | |
1894 | 2486 else |
14 | 2487 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2488 // Otherwise it's a line |
1894 | 2489 buf_T *savebuf = curbuf; |
2490 | |
2491 save = string_to_line(line); | |
2492 | |
2493 curbuf = buf->buf; | |
2494 | |
2495 if (u_savesub((linenr_T)n) == FAIL) | |
2496 { | |
2497 curbuf = savebuf; | |
2498 vim_free(save); | |
2499 raise_vim_exn(_("cannot save undo information")); | |
2500 } | |
2501 else if (ml_replace((linenr_T)n, (char_u *)save, TRUE) == FAIL) | |
2502 { | |
2503 curbuf = savebuf; | |
2504 vim_free(save); | |
2505 raise_vim_exn(_("cannot replace line")); | |
2506 } | |
2507 else | |
2508 { | |
2509 vim_free(save); | |
2510 changed_bytes((linenr_T)n, 0); | |
2511 } | |
2512 | |
14 | 2513 curbuf = savebuf; |
1894 | 2514 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2515 // Check that the cursor is not beyond the end of the line now. |
1894 | 2516 if (buf->buf == curwin->w_buffer) |
2517 check_cursor_col(); | |
2518 | |
2519 MZ_GC_UNREG(); | |
2520 raise_if_error(); | |
2521 return scheme_void; | |
14 | 2522 } |
1894 | 2523 } |
2524 | |
2525 static void | |
2526 free_array(char **array) | |
2527 { | |
2528 char **curr = array; | |
2529 while (*curr != NULL) | |
2530 vim_free(*curr++); | |
2531 vim_free(array); | |
14 | 2532 } |
2533 | |
2534 /* | |
2535 * (set-buff-line-list {start} {end} {string-list/#f/null} [buffer]) | |
2536 * | |
2537 * Replace a range of lines in the specified buffer. The line numbers are in | |
2538 * Vim format (1-based). The range is from lo up to, but not including, hi. | |
2539 * The replacement lines are given as a Scheme list of string objects. The | |
2540 * list is checked for validity and correct format. | |
2541 * | |
2542 * Errors are returned as a value of FAIL. The return value is OK on success. | |
2543 * If OK is returned and len_change is not NULL, *len_change is set to the | |
2544 * change in the buffer length. | |
2545 */ | |
2546 static Scheme_Object * | |
2547 set_buffer_line_list(void *data, int argc, Scheme_Object **argv) | |
2548 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2549 // First of all, we check the type of the supplied MzScheme object. |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2550 // There are three cases: |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2551 // 1. #f - this is a deletion. |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2552 // 2. A list - this is a replacement. |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2553 // 3. Anything else - this is an error. |
14 | 2554 Vim_Prim *prim = (Vim_Prim *)data; |
1894 | 2555 vim_mz_buffer *buf = NULL; |
2556 Scheme_Object *line_list = NULL; | |
14 | 2557 int i, old_len, new_len, hi, lo; |
2558 long extra; | |
2559 | |
1894 | 2560 MZ_GC_DECL_REG(1); |
2561 MZ_GC_VAR_IN_REG(0, line_list); | |
2562 MZ_GC_REG(); | |
2563 | |
274 | 2564 #ifdef HAVE_SANDBOX |
2565 sandbox_check(); | |
2566 #endif | |
14 | 2567 lo = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); |
2568 hi = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 1)); | |
2569 if (!SCHEME_PAIRP(argv[2]) | |
2570 && !SCHEME_FALSEP(argv[2]) && !SCHEME_NULLP(argv[2])) | |
2571 scheme_wrong_type(prim->name, "list or #f", 2, argc, argv); | |
2572 line_list = argv[2]; | |
2573 buf = get_buffer_arg(prim->name, 3, argc, argv); | |
2574 old_len = hi - lo; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2575 if (old_len < 0) // process inverse values wisely |
14 | 2576 { |
2577 i = lo; | |
2578 lo = hi; | |
2579 hi = i; | |
2580 old_len = -old_len; | |
2581 } | |
2582 extra = 0; | |
2583 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2584 check_line_range(lo, buf->buf); // inclusive |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2585 check_line_range(hi - 1, buf->buf); // exclusive |
14 | 2586 |
2587 if (SCHEME_FALSEP(line_list) || SCHEME_NULLP(line_list)) | |
2588 { | |
1894 | 2589 buf_T *savebuf = curbuf; |
14 | 2590 curbuf = buf->buf; |
2591 | |
2592 if (u_savedel((linenr_T)lo, (long)old_len) == FAIL) | |
2593 { | |
2594 curbuf = savebuf; | |
2595 raise_vim_exn(_("cannot save undo information")); | |
2596 } | |
2597 else | |
2598 { | |
2599 for (i = 0; i < old_len; i++) | |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2600 if (ml_delete((linenr_T)lo) == FAIL) |
14 | 2601 { |
2602 curbuf = savebuf; | |
2603 raise_vim_exn(_("cannot delete line")); | |
2604 } | |
2605 if (buf->buf == curwin->w_buffer) | |
2606 mz_fix_cursor(lo, hi, -old_len); | |
1929 | 2607 deleted_lines_mark((linenr_T)lo, (long)old_len); |
14 | 2608 } |
2609 | |
2610 curbuf = savebuf; | |
2611 | |
1894 | 2612 MZ_GC_UNREG(); |
14 | 2613 raise_if_error(); |
2614 return scheme_void; | |
2615 } | |
1894 | 2616 else |
14 | 2617 { |
1894 | 2618 buf_T *savebuf = curbuf; |
2619 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2620 // List |
1894 | 2621 new_len = scheme_proper_list_length(line_list); |
2622 MZ_GC_CHECK(); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2623 if (new_len < 0) // improper or cyclic list |
1894 | 2624 scheme_wrong_type(prim->name, "proper list", |
2625 2, argc, argv); | |
2626 else | |
14 | 2627 { |
1894 | 2628 char **array = NULL; |
2629 Scheme_Object *line = NULL; | |
2630 Scheme_Object *rest = NULL; | |
2631 | |
2632 MZ_GC_DECL_REG(2); | |
2633 MZ_GC_VAR_IN_REG(0, line); | |
2634 MZ_GC_VAR_IN_REG(1, rest); | |
2635 MZ_GC_REG(); | |
2636 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
2637 array = ALLOC_CLEAR_MULT(char *, new_len + 1); |
1894 | 2638 |
2639 rest = line_list; | |
2640 for (i = 0; i < new_len; ++i) | |
2641 { | |
2642 line = SCHEME_CAR(rest); | |
2643 rest = SCHEME_CDR(rest); | |
2644 if (!SCHEME_STRINGP(line)) | |
2645 { | |
2646 free_array(array); | |
2647 scheme_wrong_type(prim->name, "string-list", 2, argc, argv); | |
2648 } | |
2649 array[i] = string_to_line(line); | |
2650 } | |
2651 | |
2652 curbuf = buf->buf; | |
2653 | |
2654 if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL) | |
2655 { | |
2656 curbuf = savebuf; | |
2657 free_array(array); | |
2658 raise_vim_exn(_("cannot save undo information")); | |
2659 } | |
2660 | |
2661 /* | |
2662 * If the size of the range is reducing (ie, new_len < old_len) we | |
2663 * need to delete some old_len. We do this at the start, by | |
2664 * repeatedly deleting line "lo". | |
2665 */ | |
2666 for (i = 0; i < old_len - new_len; ++i) | |
2667 { | |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
2668 if (ml_delete((linenr_T)lo) == FAIL) |
1894 | 2669 { |
2670 curbuf = savebuf; | |
2671 free_array(array); | |
2672 raise_vim_exn(_("cannot delete line")); | |
2673 } | |
2674 extra--; | |
2675 } | |
2676 | |
2677 /* | |
2678 * For as long as possible, replace the existing old_len with the | |
2679 * new old_len. This is a more efficient operation, as it requires | |
2680 * less memory allocation and freeing. | |
2681 */ | |
2682 for (i = 0; i < old_len && i < new_len; i++) | |
2683 if (ml_replace((linenr_T)(lo+i), (char_u *)array[i], TRUE) == FAIL) | |
2684 { | |
2685 curbuf = savebuf; | |
2686 free_array(array); | |
2687 raise_vim_exn(_("cannot replace line")); | |
2688 } | |
2689 | |
2690 /* | |
2691 * Now we may need to insert the remaining new_len. We don't need to | |
2692 * free the string passed back because MzScheme has control of that | |
2693 * memory. | |
2694 */ | |
2695 while (i < new_len) | |
2696 { | |
2697 if (ml_append((linenr_T)(lo + i - 1), | |
2698 (char_u *)array[i], 0, FALSE) == FAIL) | |
2699 { | |
2700 curbuf = savebuf; | |
2701 free_array(array); | |
2702 raise_vim_exn(_("cannot insert line")); | |
2703 } | |
2704 ++i; | |
2705 ++extra; | |
2706 } | |
2707 MZ_GC_UNREG(); | |
2708 free_array(array); | |
14 | 2709 } |
1894 | 2710 |
2711 /* | |
2712 * Adjust marks. Invalidate any which lie in the | |
2713 * changed range, and move any in the remainder of the buffer. | |
2714 */ | |
9228
ea504064c996
commit https://github.com/vim/vim/commit/fd89d7ea81b18d32363456b16258174dc9e095dc
Christian Brabandt <cb@256bit.org>
parents:
9173
diff
changeset
|
2715 mark_adjust((linenr_T)lo, (linenr_T)(hi - 1), |
ea504064c996
commit https://github.com/vim/vim/commit/fd89d7ea81b18d32363456b16258174dc9e095dc
Christian Brabandt <cb@256bit.org>
parents:
9173
diff
changeset
|
2716 (long)MAXLNUM, (long)extra); |
1894 | 2717 changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra); |
2718 | |
2719 if (buf->buf == curwin->w_buffer) | |
2720 mz_fix_cursor(lo, hi, extra); | |
2721 curbuf = savebuf; | |
2722 | |
2723 MZ_GC_UNREG(); | |
2724 raise_if_error(); | |
2725 return scheme_void; | |
14 | 2726 } |
2727 } | |
2728 | |
2729 /* | |
2730 * (insert-buff-line-list {linenr} {string/string-list} [buffer]) | |
2731 * | |
2023 | 2732 * Insert a number of lines into the specified buffer after the specified line. |
14 | 2733 * The line number is in Vim format (1-based). The lines to be inserted are |
2734 * given as an MzScheme list of string objects or as a single string. The lines | |
2735 * to be added are checked for validity and correct format. Errors are | |
2736 * returned as a value of FAIL. The return value is OK on success. | |
2737 * If OK is returned and len_change is not NULL, *len_change | |
2738 * is set to the change in the buffer length. | |
2739 */ | |
2740 static Scheme_Object * | |
2741 insert_buffer_line_list(void *data, int argc, Scheme_Object **argv) | |
2742 { | |
2743 Vim_Prim *prim = (Vim_Prim *)data; | |
1894 | 2744 vim_mz_buffer *buf = NULL; |
2745 Scheme_Object *list = NULL; | |
2746 char *str = NULL; | |
14 | 2747 int i, n, size; |
2748 | |
1894 | 2749 MZ_GC_DECL_REG(1); |
2750 MZ_GC_VAR_IN_REG(0, list); | |
2751 MZ_GC_REG(); | |
2752 | |
274 | 2753 #ifdef HAVE_SANDBOX |
2754 sandbox_check(); | |
2755 #endif | |
14 | 2756 /* |
2757 * First of all, we check the type of the supplied MzScheme object. | |
2758 * It must be a string or a list, or the call is in error. | |
2759 */ | |
2760 n = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0)); | |
2761 list = argv[1]; | |
2762 | |
2763 if (!SCHEME_STRINGP(list) && !SCHEME_PAIRP(list)) | |
2764 scheme_wrong_type(prim->name, "string or list", 1, argc, argv); | |
2765 buf = get_buffer_arg(prim->name, 2, argc, argv); | |
2766 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2767 if (n != 0) // 0 can be used in insert |
856 | 2768 check_line_range(n, buf->buf); |
14 | 2769 if (SCHEME_STRINGP(list)) |
2770 { | |
1894 | 2771 buf_T *savebuf = curbuf; |
2772 | |
14 | 2773 str = string_to_line(list); |
2774 curbuf = buf->buf; | |
2775 | |
2776 if (u_save((linenr_T)n, (linenr_T)(n+1)) == FAIL) | |
2777 { | |
2778 curbuf = savebuf; | |
1894 | 2779 vim_free(str); |
14 | 2780 raise_vim_exn(_("cannot save undo information")); |
2781 } | |
2782 else if (ml_append((linenr_T)n, (char_u *)str, 0, FALSE) == FAIL) | |
2783 { | |
2784 curbuf = savebuf; | |
1894 | 2785 vim_free(str); |
14 | 2786 raise_vim_exn(_("cannot insert line")); |
2787 } | |
2788 else | |
1894 | 2789 { |
2790 vim_free(str); | |
14 | 2791 appended_lines_mark((linenr_T)n, 1L); |
1894 | 2792 } |
14 | 2793 |
2794 curbuf = savebuf; | |
2795 update_screen(VALID); | |
2796 | |
1894 | 2797 MZ_GC_UNREG(); |
14 | 2798 raise_if_error(); |
2799 return scheme_void; | |
2800 } | |
2801 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2802 // List |
14 | 2803 size = scheme_proper_list_length(list); |
1894 | 2804 MZ_GC_CHECK(); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2805 if (size < 0) // improper or cyclic list |
14 | 2806 scheme_wrong_type(prim->name, "proper list", |
2807 2, argc, argv); | |
2808 else | |
2809 { | |
1894 | 2810 Scheme_Object *line = NULL; |
2811 Scheme_Object *rest = NULL; | |
2812 char **array; | |
2813 buf_T *savebuf = curbuf; | |
2814 | |
2815 MZ_GC_DECL_REG(2); | |
2816 MZ_GC_VAR_IN_REG(0, line); | |
2817 MZ_GC_VAR_IN_REG(1, rest); | |
2818 MZ_GC_REG(); | |
2819 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19229
diff
changeset
|
2820 array = ALLOC_CLEAR_MULT(char *, size + 1); |
1894 | 2821 |
2822 rest = list; | |
856 | 2823 for (i = 0; i < size; ++i) |
1894 | 2824 { |
2825 line = SCHEME_CAR(rest); | |
2826 rest = SCHEME_CDR(rest); | |
2827 array[i] = string_to_line(line); | |
2828 } | |
2829 | |
2830 curbuf = buf->buf; | |
2831 | |
2832 if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL) | |
2833 { | |
2834 curbuf = savebuf; | |
2835 free_array(array); | |
2836 raise_vim_exn(_("cannot save undo information")); | |
2837 } | |
2838 else | |
2839 { | |
2840 for (i = 0; i < size; ++i) | |
2841 if (ml_append((linenr_T)(n + i), (char_u *)array[i], | |
2842 0, FALSE) == FAIL) | |
2843 { | |
2844 curbuf = savebuf; | |
2845 free_array(array); | |
2846 raise_vim_exn(_("cannot insert line")); | |
2847 } | |
2848 | |
2849 if (i > 0) | |
2850 appended_lines_mark((linenr_T)n, (long)i); | |
2851 } | |
2852 free_array(array); | |
2853 MZ_GC_UNREG(); | |
2854 curbuf = savebuf; | |
2855 update_screen(VALID); | |
14 | 2856 } |
2857 | |
1894 | 2858 MZ_GC_UNREG(); |
14 | 2859 raise_if_error(); |
2860 return scheme_void; | |
2861 } | |
2862 | |
2863 /* | |
2864 * Predicates | |
2865 */ | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2866 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2867 * (buff? obj) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2868 */ |
14 | 2869 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
2870 vim_bufferp(void *data UNUSED, int argc UNUSED, Scheme_Object **argv) |
14 | 2871 { |
2872 if (SCHEME_VIMBUFFERP(argv[0])) | |
2873 return scheme_true; | |
2874 else | |
2875 return scheme_false; | |
2876 } | |
2877 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2878 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2879 * (win? obj) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2880 */ |
14 | 2881 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
2882 vim_windowp(void *data UNUSED, int argc UNUSED, Scheme_Object **argv) |
14 | 2883 { |
2884 if (SCHEME_VIMWINDOWP(argv[0])) | |
2885 return scheme_true; | |
2886 else | |
2887 return scheme_false; | |
2888 } | |
2889 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2890 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2891 * (buff-valid? obj) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2892 */ |
14 | 2893 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
2894 vim_buffer_validp(void *data UNUSED, int argc UNUSED, Scheme_Object **argv) |
14 | 2895 { |
2896 if (SCHEME_VIMBUFFERP(argv[0]) | |
2897 && ((vim_mz_buffer *)argv[0])->buf != INVALID_BUFFER_VALUE) | |
2898 return scheme_true; | |
2899 else | |
2900 return scheme_false; | |
2901 } | |
2902 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2903 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2904 * (win-valid? obj) |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2905 */ |
14 | 2906 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
2907 vim_window_validp(void *data UNUSED, int argc UNUSED, Scheme_Object **argv) |
14 | 2908 { |
2909 if (SCHEME_VIMWINDOWP(argv[0]) | |
2910 && ((vim_mz_window *)argv[0])->win != INVALID_WINDOW_VALUE) | |
2911 return scheme_true; | |
2912 else | |
2913 return scheme_false; | |
2914 } | |
2915 | |
2916 /* | |
2917 *=========================================================================== | |
2918 * Utilities | |
2919 *=========================================================================== | |
2920 */ | |
2921 | |
2922 /* | |
2923 * Convert an MzScheme string into a Vim line. | |
2924 * | |
1894 | 2925 * All internal nulls are replaced by newline characters. |
2926 * It is an error for the string to contain newline characters. | |
14 | 2927 * |
1894 | 2928 * Returns pointer to Vim allocated memory |
14 | 2929 */ |
2930 static char * | |
2931 string_to_line(Scheme_Object *obj) | |
2932 { | |
1894 | 2933 char *scheme_str = NULL; |
2934 char *vim_str = NULL; | |
4074 | 2935 OUTPUT_LEN_TYPE len; |
14 | 2936 int i; |
2937 | |
1894 | 2938 scheme_str = scheme_display_to_string(obj, &len); |
14 | 2939 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2940 // Error checking: String must not contain newlines, as we |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2941 // are replacing a single line, and we must replace it with |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2942 // a single line. |
4074 | 2943 if (memchr(scheme_str, '\n', len)) |
14 | 2944 scheme_signal_error(_("string cannot contain newlines")); |
2945 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2946 vim_str = alloc(len + 1); |
1894 | 2947 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2948 // Create a copy of the string, with internal nulls replaced by |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2949 // newline characters, as is the vim convention. |
14 | 2950 for (i = 0; i < len; ++i) |
2951 { | |
1894 | 2952 if (scheme_str[i] == '\0') |
2953 vim_str[i] = '\n'; | |
2954 else | |
2955 vim_str[i] = scheme_str[i]; | |
2956 } | |
2957 | |
2958 vim_str[i] = '\0'; | |
2959 | |
2960 MZ_GC_CHECK(); | |
2961 return vim_str; | |
2962 } | |
2963 | |
2964 #ifdef FEAT_EVAL | |
2965 /* | |
2966 * Convert Vim value into MzScheme, adopted from if_python.c | |
2967 */ | |
2968 static Scheme_Object * | |
4074 | 2969 vim_to_mzscheme(typval_T *vim_value) |
2970 { | |
2971 Scheme_Object *result = NULL; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
2972 // hash table to store visited values to avoid infinite loops |
4074 | 2973 Scheme_Hash_Table *visited = NULL; |
2974 | |
2975 MZ_GC_DECL_REG(2); | |
2976 MZ_GC_VAR_IN_REG(0, result); | |
2977 MZ_GC_VAR_IN_REG(1, visited); | |
2978 MZ_GC_REG(); | |
2979 | |
2980 visited = scheme_make_hash_table(SCHEME_hash_ptr); | |
2981 MZ_GC_CHECK(); | |
2982 | |
2983 result = vim_to_mzscheme_impl(vim_value, 1, visited); | |
2984 | |
2985 MZ_GC_UNREG(); | |
2986 return result; | |
2987 } | |
2988 | |
2989 static Scheme_Object * | |
2990 vim_to_mzscheme_impl(typval_T *vim_value, int depth, Scheme_Hash_Table *visited) | |
1894 | 2991 { |
2992 Scheme_Object *result = NULL; | |
2993 int new_value = TRUE; | |
2994 | |
4074 | 2995 MZ_GC_DECL_REG(2); |
1894 | 2996 MZ_GC_VAR_IN_REG(0, result); |
4074 | 2997 MZ_GC_VAR_IN_REG(1, visited); |
1894 | 2998 MZ_GC_REG(); |
2999 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3000 // Avoid infinite recursion |
1894 | 3001 if (depth > 100) |
3002 { | |
3003 MZ_GC_UNREG(); | |
3004 return scheme_void; | |
3005 } | |
3006 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3007 // Check if we run into a recursive loop. The item must be in visited |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3008 // then and we can use it again. |
1894 | 3009 result = scheme_hash_get(visited, (Scheme_Object *)vim_value); |
3010 MZ_GC_CHECK(); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3011 if (result != NULL) // found, do nothing |
1894 | 3012 new_value = FALSE; |
3013 else if (vim_value->v_type == VAR_STRING) | |
3014 { | |
4074 | 3015 result = scheme_make_byte_string((char *)vim_value->vval.v_string); |
1894 | 3016 MZ_GC_CHECK(); |
3017 } | |
3018 else if (vim_value->v_type == VAR_NUMBER) | |
3019 { | |
3020 result = scheme_make_integer((long)vim_value->vval.v_number); | |
3021 MZ_GC_CHECK(); | |
3022 } | |
3023 # ifdef FEAT_FLOAT | |
3024 else if (vim_value->v_type == VAR_FLOAT) | |
3025 { | |
3026 result = scheme_make_double((double)vim_value->vval.v_float); | |
3027 MZ_GC_CHECK(); | |
14 | 3028 } |
1894 | 3029 # endif |
3030 else if (vim_value->v_type == VAR_LIST) | |
3031 { | |
3032 list_T *list = vim_value->vval.v_list; | |
3033 listitem_T *curr; | |
3034 | |
3035 if (list == NULL || list->lv_first == NULL) | |
3036 result = scheme_null; | |
3037 else | |
3038 { | |
3039 Scheme_Object *obj = NULL; | |
3040 | |
3041 MZ_GC_DECL_REG(1); | |
3042 MZ_GC_VAR_IN_REG(0, obj); | |
3043 MZ_GC_REG(); | |
3044 | |
19229
d776967d0f0d
patch 8.2.0173: build fails with old compiler
Bram Moolenaar <Bram@vim.org>
parents:
19102
diff
changeset
|
3045 curr = list->lv_u.mat.lv_last; |
4074 | 3046 obj = vim_to_mzscheme_impl(&curr->li_tv, depth + 1, visited); |
1894 | 3047 result = scheme_make_pair(obj, scheme_null); |
3048 MZ_GC_CHECK(); | |
3049 | |
3050 while (curr != list->lv_first) | |
3051 { | |
3052 curr = curr->li_prev; | |
4074 | 3053 obj = vim_to_mzscheme_impl(&curr->li_tv, depth + 1, visited); |
1894 | 3054 result = scheme_make_pair(obj, result); |
3055 MZ_GC_CHECK(); | |
3056 } | |
3057 } | |
3058 MZ_GC_UNREG(); | |
3059 } | |
3060 else if (vim_value->v_type == VAR_DICT) | |
3061 { | |
3062 Scheme_Object *key = NULL; | |
3063 Scheme_Object *obj = NULL; | |
3064 | |
3065 MZ_GC_DECL_REG(2); | |
3066 MZ_GC_VAR_IN_REG(0, key); | |
3067 MZ_GC_VAR_IN_REG(1, obj); | |
3068 MZ_GC_REG(); | |
3069 | |
3070 result = (Scheme_Object *)scheme_make_hash_table(SCHEME_hash_ptr); | |
3071 MZ_GC_CHECK(); | |
3072 if (vim_value->vval.v_dict != NULL) | |
3073 { | |
3074 hashtab_T *ht = &vim_value->vval.v_dict->dv_hashtab; | |
3075 long_u todo = ht->ht_used; | |
3076 hashitem_T *hi; | |
3077 dictitem_T *di; | |
3078 | |
3079 for (hi = ht->ht_array; todo > 0; ++hi) | |
3080 { | |
3081 if (!HASHITEM_EMPTY(hi)) | |
3082 { | |
3083 --todo; | |
3084 | |
3085 di = dict_lookup(hi); | |
4074 | 3086 obj = vim_to_mzscheme_impl(&di->di_tv, depth + 1, visited); |
3087 key = scheme_make_byte_string((char *)hi->hi_key); | |
1894 | 3088 MZ_GC_CHECK(); |
3089 scheme_hash_set((Scheme_Hash_Table *)result, key, obj); | |
3090 MZ_GC_CHECK(); | |
3091 } | |
3092 } | |
3093 } | |
3094 MZ_GC_UNREG(); | |
3095 } | |
4074 | 3096 else if (vim_value->v_type == VAR_FUNC) |
3097 { | |
3098 Scheme_Object *funcname = NULL; | |
3099 | |
3100 MZ_GC_DECL_REG(1); | |
3101 MZ_GC_VAR_IN_REG(0, funcname); | |
3102 MZ_GC_REG(); | |
3103 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3104 // FIXME: func_ref() and func_unref() are needed. |
4074 | 3105 funcname = scheme_make_byte_string((char *)vim_value->vval.v_string); |
3106 MZ_GC_CHECK(); | |
3107 result = scheme_make_closed_prim_w_arity(vim_funcref, funcname, | |
3108 (const char *)BYTE_STRING_VALUE(funcname), 0, -1); | |
3109 MZ_GC_CHECK(); | |
3110 | |
3111 MZ_GC_UNREG(); | |
3112 } | |
8800
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3113 else if (vim_value->v_type == VAR_PARTIAL) |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3114 { |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3115 if (vim_value->vval.v_partial == NULL) |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3116 result = scheme_null; |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3117 else |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3118 { |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3119 Scheme_Object *funcname = NULL; |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3120 |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3121 MZ_GC_DECL_REG(1); |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3122 MZ_GC_VAR_IN_REG(0, funcname); |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3123 MZ_GC_REG(); |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3124 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3125 // FIXME: func_ref() and func_unref() are needed. |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3126 // TODO: Support pt_dict and pt_argv. |
8800
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3127 funcname = scheme_make_byte_string( |
9723
80ac9cf77c9b
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
3128 (char *)partial_name(vim_value->vval.v_partial)); |
8800
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3129 MZ_GC_CHECK(); |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3130 result = scheme_make_closed_prim_w_arity(vim_funcref, funcname, |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3131 (const char *)BYTE_STRING_VALUE(funcname), 0, -1); |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3132 MZ_GC_CHECK(); |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3133 |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3134 MZ_GC_UNREG(); |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3135 } |
f57949e1e9f1
commit https://github.com/vim/vim/commit/67c2c058ea34628bd575aac7ddba4cd3b244ed57
Christian Brabandt <cb@256bit.org>
parents:
8779
diff
changeset
|
3136 } |
19102
ba9f50bfda83
patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
3137 else if (vim_value->v_type == VAR_BOOL || vim_value->v_type == VAR_SPECIAL) |
7712
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7609
diff
changeset
|
3138 { |
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7609
diff
changeset
|
3139 if (vim_value->vval.v_number <= VVAL_TRUE) |
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7609
diff
changeset
|
3140 result = scheme_make_integer((long)vim_value->vval.v_number); |
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7609
diff
changeset
|
3141 else |
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7609
diff
changeset
|
3142 result = scheme_null; |
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7609
diff
changeset
|
3143 MZ_GC_CHECK(); |
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7609
diff
changeset
|
3144 } |
1894 | 3145 else |
3146 { | |
3147 result = scheme_void; | |
3148 new_value = FALSE; | |
3149 } | |
3150 if (new_value) | |
3151 { | |
3152 scheme_hash_set(visited, (Scheme_Object *)vim_value, result); | |
3153 MZ_GC_CHECK(); | |
3154 } | |
3155 MZ_GC_UNREG(); | |
3156 return result; | |
14 | 3157 } |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3158 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3159 static int |
4074 | 3160 mzscheme_to_vim(Scheme_Object *obj, typval_T *tv) |
3161 { | |
3162 int i, status; | |
3163 Scheme_Hash_Table *visited = NULL; | |
3164 | |
3165 MZ_GC_DECL_REG(2); | |
3166 MZ_GC_VAR_IN_REG(0, obj); | |
3167 MZ_GC_VAR_IN_REG(1, visited); | |
3168 MZ_GC_REG(); | |
3169 | |
3170 visited = scheme_make_hash_table(SCHEME_hash_ptr); | |
3171 MZ_GC_CHECK(); | |
3172 | |
3173 status = mzscheme_to_vim_impl(obj, tv, 1, visited); | |
3174 for (i = 0; i < visited->size; ++i) | |
3175 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3176 // free up remembered objects |
4074 | 3177 if (visited->vals[i] != NULL) |
3178 free_tv((typval_T *)visited->vals[i]); | |
3179 } | |
3180 | |
3181 MZ_GC_UNREG(); | |
3182 return status; | |
3183 } | |
3184 static int | |
3185 mzscheme_to_vim_impl(Scheme_Object *obj, typval_T *tv, int depth, | |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3186 Scheme_Hash_Table *visited) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3187 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3188 int status = OK; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3189 typval_T *found; |
4074 | 3190 |
3191 MZ_GC_DECL_REG(2); | |
3192 MZ_GC_VAR_IN_REG(0, obj); | |
3193 MZ_GC_VAR_IN_REG(1, visited); | |
3194 MZ_GC_REG(); | |
3195 | |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3196 MZ_GC_CHECK(); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3197 if (depth > 100) // limit the deepest recursion level |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3198 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3199 tv->v_type = VAR_NUMBER; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3200 tv->vval.v_number = 0; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3201 return FAIL; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3202 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3203 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3204 found = (typval_T *)scheme_hash_get(visited, obj); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3205 if (found != NULL) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3206 copy_tv(found, tv); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3207 else if (SCHEME_VOIDP(obj)) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3208 { |
7712
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7609
diff
changeset
|
3209 tv->v_type = VAR_SPECIAL; |
bce3b5ddb393
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Christian Brabandt <cb@256bit.org>
parents:
7609
diff
changeset
|
3210 tv->vval.v_number = VVAL_NULL; |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3211 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3212 else if (SCHEME_INTP(obj)) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3213 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3214 tv->v_type = VAR_NUMBER; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3215 tv->vval.v_number = SCHEME_INT_VAL(obj); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3216 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3217 else if (SCHEME_BOOLP(obj)) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3218 { |
19102
ba9f50bfda83
patch 8.2.0111: VAR_SPECIAL is also used for booleans
Bram Moolenaar <Bram@vim.org>
parents:
18798
diff
changeset
|
3219 tv->v_type = VAR_BOOL; |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3220 tv->vval.v_number = SCHEME_TRUEP(obj); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3221 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3222 # ifdef FEAT_FLOAT |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3223 else if (SCHEME_DBLP(obj)) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3224 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3225 tv->v_type = VAR_FLOAT; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3226 tv->vval.v_float = SCHEME_DBL_VAL(obj); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3227 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3228 # endif |
4074 | 3229 else if (SCHEME_BYTE_STRINGP(obj)) |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3230 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3231 tv->v_type = VAR_STRING; |
4074 | 3232 tv->vval.v_string = vim_strsave(BYTE_STRING_VALUE(obj)); |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3233 } |
4074 | 3234 # if MZSCHEME_VERSION_MAJOR >= 299 |
3235 else if (SCHEME_CHAR_STRINGP(obj)) | |
3236 { | |
3237 Scheme_Object *tmp = NULL; | |
3238 MZ_GC_DECL_REG(1); | |
3239 MZ_GC_VAR_IN_REG(0, tmp); | |
3240 MZ_GC_REG(); | |
3241 | |
3242 tmp = scheme_char_string_to_byte_string(obj); | |
3243 tv->v_type = VAR_STRING; | |
3244 tv->vval.v_string = vim_strsave(BYTE_STRING_VALUE(tmp)); | |
3245 MZ_GC_UNREG(); | |
3246 } | |
3247 #endif | |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3248 else if (SCHEME_VECTORP(obj) || SCHEME_NULLP(obj) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3249 || SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj)) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3250 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3251 list_T *list = list_alloc(); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3252 if (list == NULL) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3253 status = FAIL; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3254 else |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3255 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3256 int i; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3257 Scheme_Object *curr = NULL; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3258 Scheme_Object *cval = NULL; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3259 // temporary var to hold current element of vectors and pairs |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3260 typval_T *v; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3261 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3262 MZ_GC_DECL_REG(2); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3263 MZ_GC_VAR_IN_REG(0, curr); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3264 MZ_GC_VAR_IN_REG(1, cval); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3265 MZ_GC_REG(); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3266 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3267 tv->v_type = VAR_LIST; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3268 tv->vval.v_list = list; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3269 ++list->lv_refcount; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3270 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3271 v = ALLOC_ONE(typval_T); |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3272 if (v == NULL) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3273 status = FAIL; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3274 else |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3275 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3276 // add the value in advance to allow handling of self-referential |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3277 // data structures |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3278 typval_T *visited_tv = ALLOC_ONE(typval_T); |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3279 copy_tv(tv, visited_tv); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3280 scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3281 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3282 if (SCHEME_VECTORP(obj)) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3283 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3284 for (i = 0; i < SCHEME_VEC_SIZE(obj); ++i) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3285 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3286 cval = SCHEME_VEC_ELS(obj)[i]; |
4074 | 3287 status = mzscheme_to_vim_impl(cval, v, depth + 1, visited); |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3288 if (status == FAIL) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3289 break; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3290 status = list_append_tv(list, v); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3291 clear_tv(v); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3292 if (status == FAIL) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3293 break; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3294 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3295 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3296 else if (SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj)) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3297 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3298 for (curr = obj; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3299 SCHEME_PAIRP(curr) || SCHEME_MUTABLE_PAIRP(curr); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3300 curr = SCHEME_CDR(curr)) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3301 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3302 cval = SCHEME_CAR(curr); |
4074 | 3303 status = mzscheme_to_vim_impl(cval, v, depth + 1, visited); |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3304 if (status == FAIL) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3305 break; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3306 status = list_append_tv(list, v); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3307 clear_tv(v); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3308 if (status == FAIL) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3309 break; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3310 } |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3311 // improper list not terminated with null |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3312 // need to handle the last element |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3313 if (status == OK && !SCHEME_NULLP(curr)) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3314 { |
4074 | 3315 status = mzscheme_to_vim_impl(cval, v, depth + 1, visited); |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3316 if (status == OK) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3317 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3318 status = list_append_tv(list, v); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3319 clear_tv(v); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3320 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3321 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3322 } |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3323 // nothing to do for scheme_null |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3324 vim_free(v); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3325 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3326 MZ_GC_UNREG(); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3327 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3328 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3329 else if (SCHEME_HASHTP(obj)) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3330 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3331 int i; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3332 dict_T *dict; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3333 Scheme_Object *key = NULL; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3334 Scheme_Object *val = NULL; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3335 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3336 MZ_GC_DECL_REG(2); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3337 MZ_GC_VAR_IN_REG(0, key); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3338 MZ_GC_VAR_IN_REG(1, val); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3339 MZ_GC_REG(); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3340 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3341 dict = dict_alloc(); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3342 if (dict == NULL) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3343 status = FAIL; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3344 else |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3345 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3346 typval_T *visited_tv = ALLOC_ONE(typval_T); |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3347 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3348 tv->v_type = VAR_DICT; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3349 tv->vval.v_dict = dict; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3350 ++dict->dv_refcount; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3351 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3352 copy_tv(tv, visited_tv); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3353 scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3354 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3355 for (i = 0; i < ((Scheme_Hash_Table *)obj)->size; ++i) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3356 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3357 if (((Scheme_Hash_Table *) obj)->vals[i] != NULL) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3358 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3359 // generate item for `display'ed Scheme key |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3360 dictitem_T *item = dictitem_alloc((char_u *)string_to_line( |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3361 ((Scheme_Hash_Table *) obj)->keys[i])); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3362 // convert Scheme val to Vim and add it to the dict |
4074 | 3363 if (mzscheme_to_vim_impl(((Scheme_Hash_Table *) obj)->vals[i], |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3364 &item->di_tv, depth + 1, visited) == FAIL |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3365 || dict_add(dict, item) == FAIL) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3366 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3367 dictitem_free(item); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3368 status = FAIL; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3369 break; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3370 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3371 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3372 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3373 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3374 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3375 MZ_GC_UNREG(); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3376 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3377 else |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3378 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3379 // `display' any other value to string |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3380 tv->v_type = VAR_STRING; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3381 tv->vval.v_string = (char_u *)string_to_line(obj); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3382 } |
4074 | 3383 MZ_GC_UNREG(); |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3384 return status; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3385 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3386 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3387 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3388 * Scheme prim procedure wrapping Vim funcref |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3389 */ |
4074 | 3390 static Scheme_Object * |
3391 vim_funcref(void *name, int argc, Scheme_Object **argv) | |
3392 { | |
3393 int i; | |
3394 typval_T args; | |
3395 int status = OK; | |
3396 Scheme_Object *result = NULL; | |
3397 list_T *list = list_alloc(); | |
3398 | |
3399 MZ_GC_DECL_REG(1); | |
3400 MZ_GC_VAR_IN_REG(0, result); | |
3401 MZ_GC_REG(); | |
3402 | |
3403 result = scheme_void; | |
3404 if (list == NULL) | |
3405 status = FAIL; | |
3406 else | |
3407 { | |
3408 args.v_type = VAR_LIST; | |
3409 args.vval.v_list = list; | |
3410 ++list->lv_refcount; | |
3411 for (i = 0; status == OK && i < argc; ++i) | |
3412 { | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3413 typval_T *v = ALLOC_ONE(typval_T); |
4074 | 3414 if (v == NULL) |
3415 status = FAIL; | |
3416 else | |
3417 { | |
3418 status = mzscheme_to_vim(argv[i], v); | |
3419 if (status == OK) | |
3420 { | |
3421 status = list_append_tv(list, v); | |
3422 clear_tv(v); | |
3423 } | |
3424 vim_free(v); | |
3425 } | |
3426 } | |
3427 if (status == OK) | |
3428 { | |
3429 typval_T ret; | |
3430 ret.v_type = VAR_UNKNOWN; | |
3431 | |
3432 mzscheme_call_vim(BYTE_STRING_VALUE((Scheme_Object *)name), &args, &ret); | |
3433 MZ_GC_CHECK(); | |
3434 result = vim_to_mzscheme(&ret); | |
3435 clear_tv(&ret); | |
3436 MZ_GC_CHECK(); | |
3437 } | |
3438 } | |
3439 clear_tv(&args); | |
3440 MZ_GC_UNREG(); | |
3441 if (status != OK) | |
3442 raise_vim_exn(_("error converting Scheme values to Vim")); | |
3443 else | |
3444 raise_if_error(); | |
3445 return result; | |
3446 } | |
3447 | |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3448 void |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3449 do_mzeval(char_u *str, typval_T *rettv) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3450 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3451 Scheme_Object *ret = NULL; |
4074 | 3452 |
3453 MZ_GC_DECL_REG(1); | |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3454 MZ_GC_VAR_IN_REG(0, ret); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3455 MZ_GC_REG(); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3456 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3457 if (mzscheme_init()) |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3458 { |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3459 MZ_GC_UNREG(); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3460 return; |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3461 } |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3462 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3463 MZ_GC_CHECK(); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3464 if (eval_with_exn_handling(str, do_eval, &ret) == OK) |
4074 | 3465 mzscheme_to_vim(ret, rettv); |
2050
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3466 |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3467 MZ_GC_UNREG(); |
afcf9db31561
updated for version 7.2.336
Bram Moolenaar <bram@zimbu.org>
parents:
2023
diff
changeset
|
3468 } |
1894 | 3469 #endif |
14 | 3470 |
3471 /* | |
3472 * Check to see whether a Vim error has been reported, or a keyboard | |
3473 * interrupt (from vim --> got_int) has been detected. | |
3474 */ | |
3475 static int | |
3476 vim_error_check(void) | |
3477 { | |
3478 return (got_int || did_emsg); | |
3479 } | |
3480 | |
3481 /* | |
3482 * register Scheme exn:vim | |
3483 */ | |
3484 static void | |
1894 | 3485 register_vim_exn(void) |
14 | 3486 { |
1894 | 3487 int nc = 0; |
3488 int i; | |
3489 Scheme_Object *struct_exn = NULL; | |
3490 Scheme_Object *exn_name = NULL; | |
3491 | |
3492 MZ_GC_DECL_REG(2); | |
3493 MZ_GC_VAR_IN_REG(0, struct_exn); | |
3494 MZ_GC_VAR_IN_REG(1, exn_name); | |
3495 MZ_GC_REG(); | |
3496 | |
3497 exn_name = scheme_intern_symbol("exn:vim"); | |
3498 MZ_GC_CHECK(); | |
3499 struct_exn = scheme_builtin_value("struct:exn"); | |
3500 MZ_GC_CHECK(); | |
14 | 3501 |
3502 if (vim_exn == NULL) | |
3503 vim_exn = scheme_make_struct_type(exn_name, | |
1894 | 3504 struct_exn, NULL, 0, 0, NULL, NULL |
14 | 3505 #if MZSCHEME_VERSION_MAJOR >= 299 |
3506 , NULL | |
3507 #endif | |
3508 ); | |
3509 | |
1894 | 3510 |
14 | 3511 { |
1894 | 3512 Scheme_Object **tmp = NULL; |
3513 Scheme_Object *exn_names[5] = {NULL, NULL, NULL, NULL, NULL}; | |
3514 Scheme_Object *exn_values[5] = {NULL, NULL, NULL, NULL, NULL}; | |
3515 MZ_GC_DECL_REG(6); | |
3516 MZ_GC_ARRAY_VAR_IN_REG(0, exn_names, 5); | |
3517 MZ_GC_ARRAY_VAR_IN_REG(3, exn_values, 5); | |
3518 MZ_GC_REG(); | |
3519 | |
3520 tmp = scheme_make_struct_names(exn_name, scheme_null, 0, &nc); | |
3521 mch_memmove(exn_names, tmp, nc * sizeof(Scheme_Object *)); | |
3522 MZ_GC_CHECK(); | |
3523 | |
3524 tmp = scheme_make_struct_values(vim_exn, exn_names, nc, 0); | |
3525 mch_memmove(exn_values, tmp, nc * sizeof(Scheme_Object *)); | |
3526 MZ_GC_CHECK(); | |
3527 | |
3528 for (i = 0; i < nc; i++) | |
3529 { | |
3530 scheme_add_global_symbol(exn_names[i], | |
3531 exn_values[i], environment); | |
3532 MZ_GC_CHECK(); | |
3533 } | |
3534 MZ_GC_UNREG(); | |
14 | 3535 } |
1894 | 3536 MZ_GC_UNREG(); |
14 | 3537 } |
3538 | |
3539 /* | |
3540 * raise exn:vim, may be with additional info string | |
3541 */ | |
3542 void | |
3543 raise_vim_exn(const char *add_info) | |
3544 { | |
1894 | 3545 char *fmt = _("Vim error: ~a"); |
3546 Scheme_Object *argv[2] = {NULL, NULL}; | |
3547 Scheme_Object *exn = NULL; | |
4074 | 3548 Scheme_Object *byte_string = NULL; |
3549 | |
3550 MZ_GC_DECL_REG(5); | |
1894 | 3551 MZ_GC_ARRAY_VAR_IN_REG(0, argv, 2); |
3552 MZ_GC_VAR_IN_REG(3, exn); | |
4074 | 3553 MZ_GC_VAR_IN_REG(4, byte_string); |
1894 | 3554 MZ_GC_REG(); |
14 | 3555 |
3556 if (add_info != NULL) | |
3557 { | |
1894 | 3558 char *c_string = NULL; |
3559 Scheme_Object *info = NULL; | |
3560 | |
3561 MZ_GC_DECL_REG(3); | |
3562 MZ_GC_VAR_IN_REG(0, c_string); | |
3563 MZ_GC_VAR_IN_REG(2, info); | |
3564 MZ_GC_REG(); | |
3565 | |
4074 | 3566 info = scheme_make_byte_string(add_info); |
1894 | 3567 MZ_GC_CHECK(); |
9159
6b003ff07234
commit https://github.com/vim/vim/commit/9b0ac229bcfc91acabd35fc576055a94c1687c32
Christian Brabandt <cb@256bit.org>
parents:
8800
diff
changeset
|
3568 c_string = scheme_format_utf8(fmt, (int)STRLEN(fmt), 1, &info, NULL); |
1894 | 3569 MZ_GC_CHECK(); |
4074 | 3570 byte_string = scheme_make_byte_string(c_string); |
1894 | 3571 MZ_GC_CHECK(); |
3572 argv[0] = scheme_byte_string_to_char_string(byte_string); | |
274 | 3573 SCHEME_SET_IMMUTABLE(argv[0]); |
1894 | 3574 MZ_GC_UNREG(); |
14 | 3575 } |
3576 else | |
4074 | 3577 { |
3578 byte_string = scheme_make_byte_string(_("Vim error")); | |
3579 MZ_GC_CHECK(); | |
3580 argv[0] = scheme_byte_string_to_char_string(byte_string); | |
3581 MZ_GC_CHECK(); | |
3582 } | |
1894 | 3583 MZ_GC_CHECK(); |
14 | 3584 |
1284 | 3585 #if MZSCHEME_VERSION_MAJOR < 360 |
3586 argv[1] = scheme_current_continuation_marks(); | |
1894 | 3587 MZ_GC_CHECK(); |
1284 | 3588 #else |
1125 | 3589 argv[1] = scheme_current_continuation_marks(NULL); |
1894 | 3590 MZ_GC_CHECK(); |
1284 | 3591 #endif |
14 | 3592 |
1894 | 3593 exn = scheme_make_struct_instance(vim_exn, 2, argv); |
3594 MZ_GC_CHECK(); | |
3595 scheme_raise(exn); | |
3596 MZ_GC_UNREG(); | |
14 | 3597 } |
3598 | |
3599 void | |
3600 raise_if_error(void) | |
3601 { | |
3602 if (vim_error_check()) | |
3603 raise_vim_exn(NULL); | |
3604 } | |
3605 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3606 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3607 * get buffer: |
14 | 3608 * either current |
3609 * or passed as argv[argnum] with checks | |
3610 */ | |
3611 static vim_mz_buffer * | |
3612 get_buffer_arg(const char *fname, int argnum, int argc, Scheme_Object **argv) | |
3613 { | |
3614 vim_mz_buffer *b; | |
3615 | |
3616 if (argc < argnum + 1) | |
3617 return get_vim_curr_buffer(); | |
3618 if (!SCHEME_VIMBUFFERP(argv[argnum])) | |
3619 scheme_wrong_type(fname, "vim-buffer", argnum, argc, argv); | |
3620 b = (vim_mz_buffer *)argv[argnum]; | |
3621 (void)get_valid_buffer(argv[argnum]); | |
3622 return b; | |
3623 } | |
3624 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3625 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3626 * get window: |
14 | 3627 * either current |
3628 * or passed as argv[argnum] with checks | |
3629 */ | |
3630 static vim_mz_window * | |
3631 get_window_arg(const char *fname, int argnum, int argc, Scheme_Object **argv) | |
3632 { | |
3633 vim_mz_window *w; | |
3634 | |
3635 if (argc < argnum + 1) | |
3636 return get_vim_curr_window(); | |
3637 w = (vim_mz_window *)argv[argnum]; | |
3638 if (!SCHEME_VIMWINDOWP(argv[argnum])) | |
3639 scheme_wrong_type(fname, "vim-window", argnum, argc, argv); | |
3640 (void)get_valid_window(argv[argnum]); | |
3641 return w; | |
3642 } | |
3643 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3644 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3645 * get valid Vim buffer from Scheme_Object* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3646 */ |
14 | 3647 buf_T *get_valid_buffer(void *obj) |
3648 { | |
3649 buf_T *buf = ((vim_mz_buffer *)obj)->buf; | |
3650 | |
3651 if (buf == INVALID_BUFFER_VALUE) | |
3652 scheme_signal_error(_("buffer is invalid")); | |
3653 return buf; | |
3654 } | |
3655 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3656 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3657 * get valid Vim window from Scheme_Object* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3658 */ |
14 | 3659 win_T *get_valid_window(void *obj) |
3660 { | |
3661 win_T *win = ((vim_mz_window *)obj)->win; | |
3662 if (win == INVALID_WINDOW_VALUE) | |
3663 scheme_signal_error(_("window is invalid")); | |
3664 return win; | |
3665 } | |
3666 | |
3667 int | |
3668 mzthreads_allowed(void) | |
3669 { | |
3670 return mz_threads_allow; | |
3671 } | |
3672 | |
3673 static int | |
3674 line_in_range(linenr_T lnum, buf_T *buf) | |
3675 { | |
3676 return (lnum > 0 && lnum <= buf->b_ml.ml_line_count); | |
3677 } | |
3678 | |
3679 static void | |
3680 check_line_range(linenr_T lnum, buf_T *buf) | |
3681 { | |
3682 if (!line_in_range(lnum, buf)) | |
3683 scheme_signal_error(_("linenr out of range")); | |
3684 } | |
3685 | |
3686 /* | |
3687 * Check if deleting lines made the cursor position invalid | |
3688 * (or you'll get msg from Vim about invalid linenr). | |
3689 * Changed the lines from "lo" to "hi" and added "extra" lines (negative if | |
3690 * deleted). Got from if_python.c | |
3691 */ | |
3692 static void | |
3693 mz_fix_cursor(int lo, int hi, int extra) | |
3694 { | |
3695 if (curwin->w_cursor.lnum >= lo) | |
3696 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3697 // Adjust the cursor position if it's in/after the changed |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3698 // lines. |
14 | 3699 if (curwin->w_cursor.lnum >= hi) |
3700 { | |
3701 curwin->w_cursor.lnum += extra; | |
3702 check_cursor_col(); | |
3703 } | |
3704 else if (extra < 0) | |
3705 { | |
3706 curwin->w_cursor.lnum = lo; | |
3707 check_cursor(); | |
3708 } | |
1894 | 3709 else |
3710 check_cursor_col(); | |
14 | 3711 changed_cline_bef_curs(); |
3712 } | |
3713 invalidate_botline(); | |
3714 } | |
3715 | |
3716 static Vim_Prim prims[]= | |
3717 { | |
3718 /* | |
3719 * Buffer-related commands | |
3720 */ | |
3721 {get_buffer_line, "get-buff-line", 1, 2}, | |
3722 {set_buffer_line, "set-buff-line", 2, 3}, | |
3723 {get_buffer_line_list, "get-buff-line-list", 2, 3}, | |
3724 {get_buffer_name, "get-buff-name", 0, 1}, | |
3725 {get_buffer_num, "get-buff-num", 0, 1}, | |
3726 {get_buffer_size, "get-buff-size", 0, 1}, | |
3727 {set_buffer_line_list, "set-buff-line-list", 3, 4}, | |
3728 {insert_buffer_line_list, "insert-buff-line-list", 2, 3}, | |
3729 {get_curr_buffer, "curr-buff", 0, 0}, | |
3730 {get_buffer_count, "buff-count", 0, 0}, | |
3731 {get_next_buffer, "get-next-buff", 0, 1}, | |
3732 {get_prev_buffer, "get-prev-buff", 0, 1}, | |
3733 {mzscheme_open_buffer, "open-buff", 1, 1}, | |
3734 {get_buffer_by_name, "get-buff-by-name", 1, 1}, | |
3735 {get_buffer_by_num, "get-buff-by-num", 1, 1}, | |
3736 /* | |
3737 * Window-related commands | |
3738 */ | |
3739 {get_curr_win, "curr-win", 0, 0}, | |
3740 {get_window_count, "win-count", 0, 0}, | |
3741 {get_window_by_num, "get-win-by-num", 1, 1}, | |
3742 {get_window_num, "get-win-num", 0, 1}, | |
3743 {get_window_buffer, "get-win-buffer", 0, 1}, | |
3744 {get_window_height, "get-win-height", 0, 1}, | |
3745 {set_window_height, "set-win-height", 1, 2}, | |
3746 {get_window_width, "get-win-width", 0, 1}, | |
3747 {set_window_width, "set-win-width", 1, 2}, | |
3748 {get_cursor, "get-cursor", 0, 1}, | |
3749 {set_cursor, "set-cursor", 1, 2}, | |
3750 {get_window_list, "get-win-list", 0, 1}, | |
3751 /* | |
3752 * Vim-related commands | |
3753 */ | |
3754 {vim_command, "command", 1, 1}, | |
3755 {vim_eval, "eval", 1, 1}, | |
3756 {get_range_start, "range-start", 0, 0}, | |
3757 {get_range_end, "range-end", 0, 0}, | |
3758 {mzscheme_beep, "beep", 0, 0}, | |
3759 {get_option, "get-option", 1, 2}, | |
3760 {set_option, "set-option", 1, 2}, | |
3761 /* | |
3762 * small utilities | |
3763 */ | |
3764 {vim_bufferp, "buff?", 1, 1}, | |
3765 {vim_windowp, "win?", 1, 1}, | |
3766 {vim_buffer_validp, "buff-valid?", 1, 1}, | |
3767 {vim_window_validp, "win-valid?", 1, 1} | |
3768 }; | |
3769 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3770 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3771 * return MzScheme wrapper for curbuf |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3772 */ |
14 | 3773 static vim_mz_buffer * |
3774 get_vim_curr_buffer(void) | |
3775 { | |
502 | 3776 if (curbuf->b_mzscheme_ref == NULL) |
14 | 3777 return (vim_mz_buffer *)buffer_new(curbuf); |
3778 else | |
4074 | 3779 return BUFFER_REF(curbuf); |
14 | 3780 } |
3781 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3782 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3783 * return MzScheme wrapper for curwin |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3784 */ |
14 | 3785 static vim_mz_window * |
3786 get_vim_curr_window(void) | |
3787 { | |
502 | 3788 if (curwin->w_mzscheme_ref == NULL) |
14 | 3789 return (vim_mz_window *)window_new(curwin); |
3790 else | |
4074 | 3791 return WINDOW_REF(curwin); |
14 | 3792 } |
3793 | |
3794 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7813
diff
changeset
|
3795 make_modules(void) |
14 | 3796 { |
1894 | 3797 int i; |
3798 Scheme_Env *mod = NULL; | |
3799 Scheme_Object *vimext_symbol = NULL; | |
3800 Scheme_Object *closed_prim = NULL; | |
3801 | |
3802 MZ_GC_DECL_REG(3); | |
3803 MZ_GC_VAR_IN_REG(0, mod); | |
3804 MZ_GC_VAR_IN_REG(1, vimext_symbol); | |
3805 MZ_GC_VAR_IN_REG(2, closed_prim); | |
3806 MZ_GC_REG(); | |
3807 | |
3808 vimext_symbol = scheme_intern_symbol("vimext"); | |
3809 MZ_GC_CHECK(); | |
3810 mod = scheme_primitive_module(vimext_symbol, environment); | |
3811 MZ_GC_CHECK(); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3812 // all prims made closed so they can access their own names |
1894 | 3813 for (i = 0; i < (int)(sizeof(prims)/sizeof(prims[0])); i++) |
14 | 3814 { |
3815 Vim_Prim *prim = prims + i; | |
1894 | 3816 closed_prim = scheme_make_closed_prim_w_arity(prim->prim, prim, prim->name, |
3817 prim->mina, prim->maxa); | |
3818 scheme_add_global(prim->name, closed_prim, mod); | |
3819 MZ_GC_CHECK(); | |
14 | 3820 } |
3821 scheme_finish_primitive_module(mod); | |
1894 | 3822 MZ_GC_CHECK(); |
3823 MZ_GC_UNREG(); | |
14 | 3824 } |
344 | 3825 |
274 | 3826 #ifdef HAVE_SANDBOX |
3827 static Scheme_Object *M_write = NULL; | |
3828 static Scheme_Object *M_read = NULL; | |
3829 static Scheme_Object *M_execute = NULL; | |
3830 static Scheme_Object *M_delete = NULL; | |
3831 | |
3832 static void | |
1125 | 3833 sandbox_check(void) |
274 | 3834 { |
3835 if (sandbox) | |
3836 raise_vim_exn(_("not allowed in the Vim sandbox")); | |
3837 } | |
3838 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3839 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3840 * security guards to force Vim's sandbox restrictions on MzScheme level |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3841 */ |
274 | 3842 static Scheme_Object * |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
3843 sandbox_file_guard(int argc UNUSED, Scheme_Object **argv) |
274 | 3844 { |
3845 if (sandbox) | |
3846 { | |
3847 Scheme_Object *requested_access = argv[2]; | |
3848 | |
3849 if (M_write == NULL) | |
3850 { | |
3851 MZ_REGISTER_STATIC(M_write); | |
3852 M_write = scheme_intern_symbol("write"); | |
1894 | 3853 MZ_GC_CHECK(); |
274 | 3854 } |
3855 if (M_read == NULL) | |
3856 { | |
3857 MZ_REGISTER_STATIC(M_read); | |
3858 M_read = scheme_intern_symbol("read"); | |
1894 | 3859 MZ_GC_CHECK(); |
274 | 3860 } |
3861 if (M_execute == NULL) | |
3862 { | |
3863 MZ_REGISTER_STATIC(M_execute); | |
3864 M_execute = scheme_intern_symbol("execute"); | |
1894 | 3865 MZ_GC_CHECK(); |
274 | 3866 } |
3867 if (M_delete == NULL) | |
3868 { | |
3869 MZ_REGISTER_STATIC(M_delete); | |
3870 M_delete = scheme_intern_symbol("delete"); | |
1894 | 3871 MZ_GC_CHECK(); |
274 | 3872 } |
3873 | |
3874 while (!SCHEME_NULLP(requested_access)) | |
3875 { | |
3876 Scheme_Object *item = SCHEME_CAR(requested_access); | |
3877 if (scheme_eq(item, M_write) || scheme_eq(item, M_read) | |
3878 || scheme_eq(item, M_execute) || scheme_eq(item, M_delete)) | |
3879 raise_vim_exn(_("not allowed in the Vim sandbox")); | |
3880 requested_access = SCHEME_CDR(requested_access); | |
3881 } | |
3882 } | |
3883 return scheme_void; | |
3884 } | |
3885 | |
3886 static Scheme_Object * | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2050
diff
changeset
|
3887 sandbox_network_guard(int argc UNUSED, Scheme_Object **argv UNUSED) |
274 | 3888 { |
3889 return scheme_void; | |
3890 } | |
3891 #endif | |
800 | 3892 |
3893 #endif |