annotate src/if_mzsch.c @ 20498:55a373a243c0 v8.2.0803

patch 8.2.0803: libvterm code lags behind the upstream version Commit: https://github.com/vim/vim/commit/83a52533b23c88f90be0dea01bc5e32ddadc1d6a Author: Bram Moolenaar <Bram@vim.org> Date: Wed May 20 19:30:19 2020 +0200 patch 8.2.0803: libvterm code lags behind the upstream version Problem: Libvterm code lags behind the upstream version. Solution: Include revisions 764 - 767
author Bram Moolenaar <Bram@vim.org>
date Wed, 20 May 2020 19:45:04 +0200
parents aadd1cae2ff5
children d571231175b4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9961
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2 *
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
3 * MzScheme interface by Sergey Khorev <sergey.khorev@gmail.com>
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
4 * Based on work by Brent Fulgham <bfulgham@debian.org>
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
5 * (Based on lots of help from Matthew Flatt)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
6 *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
7 * This consists of six parts:
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
8 * 1. MzScheme interpreter main program
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
9 * 2. Routines that handle the external interface between MzScheme and
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
10 * Vim.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
11 * 3. MzScheme input/output handlers: writes output via [e]msg().
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
12 * 4. Implementation of the Vim Features for MzScheme
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
13 * 5. Vim Window-related Manipulation Functions.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
14 * 6. Vim Buffer-related Manipulation Functions
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
15 *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
16 * NOTES
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
17 * 1. Memory, allocated with scheme_malloc*, need not to be freed explicitly,
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
18 * garbage collector will do it self
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
19 * 2. Requires at least NORMAL features. I can't imagine why one may want
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
20 * to build with SMALL or TINY features but with MzScheme interface.
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
21 * 3. I don't use K&R-style functions. Anyways, MzScheme headers are ANSI.
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
22 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
23
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
24 #include "vim.h"
1284
30f057789239 updated for version 7.1
vimboss
parents: 1228
diff changeset
25
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
26 #include "if_mzsch.h"
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
d8f905020502 updated for version 7.0b
vimboss
parents: 714
diff changeset
30 #if defined(FEAT_MZSCHEME) || defined(PROTO)
d8f905020502 updated for version 7.0b
vimboss
parents: 714
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
67 #define SCHEME_VIMBUFFERP(obj) SAME_TYPE(SCHEME_TYPE(obj), mz_buffer_type)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
68 #define SCHEME_VIMWINDOWP(obj) SAME_TYPE(SCHEME_TYPE(obj), mz_window_type)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
69
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
70 typedef struct
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
71 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
72 Scheme_Object so;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
73 buf_T *buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
74 } vim_mz_buffer;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
75
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
76 #define INVALID_BUFFER_VALUE ((buf_T *)(-1))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
77
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
78 typedef struct
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
79 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
80 Scheme_Object so;
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 575
diff changeset
81 win_T *win;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
82 } vim_mz_window;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
83
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
84 #define INVALID_WINDOW_VALUE ((win_T *)(-1))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
85
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
86 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
87 * Prims that form MzScheme Vim interface
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
88 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
89 typedef struct
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
90 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
91 Scheme_Closed_Prim *prim;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
94 int maxa;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
95 } Vim_Prim;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
96
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
97 typedef struct
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
98 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
99 char *name;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
100 Scheme_Object *port;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
101 } Port_Info;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
102
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
103 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
104 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
105 * Vim-Control Commands
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
106 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
107 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
108 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
109 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
110 * Utility functions for the vim/mzscheme interface
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
111 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
112 */
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
113 #ifdef HAVE_SANDBOX
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
114 static Scheme_Object *sandbox_file_guard(int, Scheme_Object **);
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
115 static Scheme_Object *sandbox_network_guard(int, Scheme_Object **);
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 856
diff changeset
116 static void sandbox_check(void);
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
119 static Scheme_Object *buffer_new(buf_T *buf);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
120 static Scheme_Object *get_buffer_by_num(void *, int, Scheme_Object **);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
121 static vim_mz_buffer *get_vim_curr_buffer(void);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
124 static Scheme_Object *window_new(win_T *win);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
125 static vim_mz_window *get_vim_curr_window(void);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
126
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
127 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
128 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
129 * Internal Function Prototypes
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
130 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
131 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
132 static int vim_error_check(void);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
137 # define OUTPUT_LEN_TYPE intptr_t
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
138 #else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
139 # define OUTPUT_LEN_TYPE long
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
140 #endif
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
141 static void do_output(char *mesg, OUTPUT_LEN_TYPE len);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
142 static void do_printf(char *format, ...);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
143 static void do_flush(void);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
144 static Scheme_Object *_apply_thunk_catch_exceptions(
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
145 Scheme_Object *, Scheme_Object **);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
146 static Scheme_Object *extract_exn_message(Scheme_Object *v);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
147 static Scheme_Object *do_eval(void *, int noargc, Scheme_Object **noargv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
148 static Scheme_Object *do_load(void *, int noargc, Scheme_Object **noargv);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
149 static void register_vim_exn(void);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
150 static vim_mz_buffer *get_buffer_arg(const char *fname, int argnum,
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
151 int argc, Scheme_Object **argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
152 static vim_mz_window *get_window_arg(const char *fname, int argnum,
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
153 int argc, Scheme_Object **argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
154 static int line_in_range(linenr_T, buf_T *);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
155 static void check_line_range(linenr_T, buf_T *);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
156 static void mz_fix_cursor(int lo, int hi, int extra);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
157
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
158 static int eval_with_exn_handling(void *, Scheme_Closed_Prim *,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
159 Scheme_Object **ret);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
160 static void make_modules(void);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
161 static void init_exn_catching_apply(void);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
162 static int mzscheme_env_main(Scheme_Env *env, int argc, char **argv);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
163 static int mzscheme_init(void);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
164 #ifdef FEAT_EVAL
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
165 static Scheme_Object *vim_to_mzscheme(typval_T *vim_value);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
166 static Scheme_Object *vim_to_mzscheme_impl(typval_T *vim_value, int depth,
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
167 Scheme_Hash_Table *visited);
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
168 static int mzscheme_to_vim(Scheme_Object *obj, typval_T *tv);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
171 static Scheme_Object *vim_funcref(void *data, int argc, Scheme_Object **argv);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
172 #endif
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
173
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
176 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
177 return gcBYTES_TO_WORDS(sizeof(vim_mz_buffer));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
178 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
179 static int buffer_mark_proc(void *obj)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
180 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
181 return buffer_size_proc(obj);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
182 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
183 static int buffer_fixup_proc(void *obj)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
190 return buffer_size_proc(obj);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
193 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
194 return gcBYTES_TO_WORDS(sizeof(vim_mz_window));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
195 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
196 static int window_mark_proc(void *obj)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
197 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
198 return window_size_proc(obj);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
199 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
200 static int window_fixup_proc(void *obj)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
207 return window_size_proc(obj);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
212 # define WINDOW_REF(win) *(vim_mz_window **)((win)->w_mzscheme_ref)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
213 # define BUFFER_REF(buf) *(vim_mz_buffer **)((buf)->b_mzscheme_ref)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
214 #else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
215 # define WINDOW_REF(win) (vim_mz_window *)((win)->w_mzscheme_ref)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
216 # define BUFFER_REF(buf) (vim_mz_buffer *)((buf)->b_mzscheme_ref)
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
217 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
220 static Scheme_Object *dll_scheme_eof;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
221 static Scheme_Object *dll_scheme_false;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
222 static Scheme_Object *dll_scheme_void;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
223 static Scheme_Object *dll_scheme_null;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
224 static Scheme_Object *dll_scheme_true;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
225
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
226 static Scheme_Thread **dll_scheme_current_thread_ptr;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
227
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
230 static void (**dll_scheme_notify_multithread_ptr)(int on);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
231
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
232 static void *(*dll_GC_malloc)(size_t size_in_bytes);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
233 static void *(*dll_GC_malloc_atomic)(size_t size_in_bytes);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
234 static Scheme_Env *(*dll_scheme_basic_env)(void);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
235 static void (*dll_scheme_check_threads)(void);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
236 static void (*dll_scheme_register_static)(void *ptr, long size);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
237 static void (*dll_scheme_set_stack_base)(void *base, int no_auto_statics);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
238 static void (*dll_scheme_add_global)(const char *name, Scheme_Object *val,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
239 Scheme_Env *env);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
240 static void (*dll_scheme_add_global_symbol)(Scheme_Object *name,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
241 Scheme_Object *val, Scheme_Env *env);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
242 static Scheme_Object *(*dll_scheme_apply)(Scheme_Object *rator, int num_rands,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
243 Scheme_Object **rands);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
244 static Scheme_Object *(*dll_scheme_builtin_value)(const char *name);
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
245 # if MZSCHEME_VERSION_MAJOR >= 299
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
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
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
248 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
249 static void (*dll_scheme_close_input_port)(Scheme_Object *port);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
250 static void (*dll_scheme_count_lines)(Scheme_Object *port);
1284
30f057789239 updated for version 7.1
vimboss
parents: 1228
diff changeset
251 #if MZSCHEME_VERSION_MAJOR < 360
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
252 static Scheme_Object *(*dll_scheme_current_continuation_marks)(void);
1284
30f057789239 updated for version 7.1
vimboss
parents: 1228
diff changeset
253 #else
30f057789239 updated for version 7.1
vimboss
parents: 1228
diff changeset
254 static Scheme_Object *(*dll_scheme_current_continuation_marks)(Scheme_Object *prompt_tag);
30f057789239 updated for version 7.1
vimboss
parents: 1228
diff changeset
255 #endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
258 static int (*dll_scheme_eq)(Scheme_Object *obj1, Scheme_Object *obj2);
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
259 static Scheme_Object *(*dll_scheme_do_eval)(Scheme_Object *obj,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
260 int _num_rands, Scheme_Object **rands, int val);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
261 static void (*dll_scheme_dont_gc_ptr)(void *p);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
262 static Scheme_Object *(*dll_scheme_eval)(Scheme_Object *obj, Scheme_Env *env);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
263 static Scheme_Object *(*dll_scheme_eval_string)(const char *str,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
264 Scheme_Env *env);
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
265 static Scheme_Object *(*dll_scheme_eval_string_all)(const char *str,
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
266 Scheme_Env *env, int all);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
267 static void (*dll_scheme_finish_primitive_module)(Scheme_Env *env);
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
268 # if MZSCHEME_VERSION_MAJOR < 299
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
269 static char *(*dll_scheme_format)(char *format, int flen, int argc,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
270 Scheme_Object **argv, long *rlen);
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
271 # else
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
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
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
274 static Scheme_Object *(*dll_scheme_get_param)(Scheme_Config *c, int pos);
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
275 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
276 static void (*dll_scheme_gc_ptr_ok)(void *p);
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
277 # if MZSCHEME_VERSION_MAJOR < 299
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
278 static char *(*dll_scheme_get_sized_string_output)(Scheme_Object *,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
279 long *len);
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
280 # else
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
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
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
283 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
284 static Scheme_Object *(*dll_scheme_intern_symbol)(const char *name);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
285 static Scheme_Object *(*dll_scheme_lookup_global)(Scheme_Object *symbol,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
286 Scheme_Env *env);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
287 static Scheme_Object *(*dll_scheme_make_closed_prim_w_arity)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
288 (Scheme_Closed_Prim *prim, void *data, const char *name, mzshort mina,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
289 mzshort maxa);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
290 static Scheme_Object *(*dll_scheme_make_integer_value)(long i);
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
291 static Scheme_Object *(*dll_scheme_make_pair)(Scheme_Object *car,
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
292 Scheme_Object *cdr);
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
293 static Scheme_Object *(*dll_scheme_make_prim_w_arity)(Scheme_Prim *prim,
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
294 const char *name, mzshort mina, mzshort maxa);
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
295 # if MZSCHEME_VERSION_MAJOR < 299
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
296 static Scheme_Object *(*dll_scheme_make_string)(const char *chars);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
297 static Scheme_Object *(*dll_scheme_make_string_output_port)();
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
298 # else
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
299 static Scheme_Object *(*dll_scheme_make_byte_string)(const char *chars);
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
300 static Scheme_Object *(*dll_scheme_make_byte_string_output_port)();
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
301 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
302 static Scheme_Object *(*dll_scheme_make_struct_instance)(Scheme_Object *stype,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
303 int argc, Scheme_Object **argv);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
304 static Scheme_Object **(*dll_scheme_make_struct_names)(Scheme_Object *base,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
305 Scheme_Object *field_names, int flags, int *count_out);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
306 static Scheme_Object *(*dll_scheme_make_struct_type)(Scheme_Object *base,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
307 Scheme_Object *parent, Scheme_Object *inspector, int num_fields,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
308 int num_uninit_fields, Scheme_Object *uninit_val,
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
309 Scheme_Object *properties
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
310 # if MZSCHEME_VERSION_MAJOR >= 299
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
311 , Scheme_Object *guard
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
312 # endif
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
313 );
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
314 static Scheme_Object **(*dll_scheme_make_struct_values)(
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
315 Scheme_Object *struct_type, Scheme_Object **names, int count,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
316 int flags);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
317 static Scheme_Type (*dll_scheme_make_type)(const char *name);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
318 static Scheme_Object *(*dll_scheme_make_vector)(int size,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
319 Scheme_Object *fill);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
320 static void *(*dll_scheme_malloc_fail_ok)(void *(*f)(size_t), size_t);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
321 static Scheme_Object *(*dll_scheme_open_input_file)(const char *name,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
322 const char *who);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
323 static Scheme_Env *(*dll_scheme_primitive_module)(Scheme_Object *name,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
324 Scheme_Env *for_env);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
325 static int (*dll_scheme_proper_list_length)(Scheme_Object *list);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
326 static void (*dll_scheme_raise)(Scheme_Object *exn);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
327 static Scheme_Object *(*dll_scheme_read)(Scheme_Object *port);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
328 static void (*dll_scheme_signal_error)(const char *msg, ...);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
329 static void (*dll_scheme_wrong_type)(const char *name, const char *expected,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
330 int which, int argc, Scheme_Object **argv);
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
331 # if MZSCHEME_VERSION_MAJOR >= 299
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
332 static void (*dll_scheme_set_param)(Scheme_Config *c, int pos,
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
333 Scheme_Object *o);
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
334 static Scheme_Config *(*dll_scheme_current_config)(void);
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
335 static Scheme_Object *(*dll_scheme_char_string_to_byte_string)
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
336 (Scheme_Object *s);
1307
64dd70f176c9 updated for version 7.1-021
vimboss
parents: 1301
diff changeset
337 static Scheme_Object *(*dll_scheme_char_string_to_path)
64dd70f176c9 updated for version 7.1-021
vimboss
parents: 1301
diff changeset
338 (Scheme_Object *s);
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
339 static void *(*dll_scheme_set_collects_path)(Scheme_Object *p);
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
340 # endif
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
341 static Scheme_Hash_Table *(*dll_scheme_make_hash_table)(int type);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
342 static void (*dll_scheme_hash_set)(Scheme_Hash_Table *table,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
343 Scheme_Object *key, Scheme_Object *value);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
344 static Scheme_Object *(*dll_scheme_hash_get)(Scheme_Hash_Table *table,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
345 Scheme_Object *key);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
346 static Scheme_Object *(*dll_scheme_make_double)(double d);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
347 static Scheme_Object *(*dll_scheme_make_sized_byte_string)(char *chars,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
348 long len, int copy);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
375 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
380 # define scheme_eof dll_scheme_eof
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
381 # define scheme_false dll_scheme_false
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
382 # define scheme_void dll_scheme_void
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
383 # define scheme_null dll_scheme_null
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
384 # define scheme_true dll_scheme_true
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
390 # define scheme_console_printf (*dll_scheme_console_printf_ptr)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
391 # define scheme_console_output (*dll_scheme_console_output_ptr)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
392 # define scheme_notify_multithread (*dll_scheme_notify_multithread_ptr)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
395 # define GC_malloc dll_GC_malloc
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
396 # define GC_malloc_atomic dll_GC_malloc_atomic
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
397
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
398 # define scheme_add_global dll_scheme_add_global
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
399 # define scheme_add_global_symbol dll_scheme_add_global_symbol
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
400 # define scheme_apply dll_scheme_apply
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
401 # define scheme_basic_env dll_scheme_basic_env
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
402 # define scheme_builtin_value dll_scheme_builtin_value
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
403 # if MZSCHEME_VERSION_MAJOR >= 299
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
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
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
406 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
407 # define scheme_check_threads dll_scheme_check_threads
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
408 # define scheme_close_input_port dll_scheme_close_input_port
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
409 # define scheme_count_lines dll_scheme_count_lines
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
410 # define scheme_current_continuation_marks \
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
411 dll_scheme_current_continuation_marks
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
412 # define scheme_display dll_scheme_display
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
413 # define scheme_display_to_string dll_scheme_display_to_string
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
414 # define scheme_do_eval dll_scheme_do_eval
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
415 # define scheme_dont_gc_ptr dll_scheme_dont_gc_ptr
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
416 # define scheme_eq dll_scheme_eq
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
417 # define scheme_eval dll_scheme_eval
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
418 # define scheme_eval_string dll_scheme_eval_string
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
419 # define scheme_eval_string_all dll_scheme_eval_string_all
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
420 # define scheme_finish_primitive_module dll_scheme_finish_primitive_module
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
421 # if MZSCHEME_VERSION_MAJOR < 299
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
422 # define scheme_format dll_scheme_format
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
423 # else
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
424 # define scheme_format_utf8 dll_scheme_format_utf8
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
425 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
426 # define scheme_gc_ptr_ok dll_scheme_gc_ptr_ok
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
427 # if MZSCHEME_VERSION_MAJOR < 299
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
428 # define scheme_get_sized_byte_string_output dll_scheme_get_sized_string_output
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
429 # else
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
430 # define scheme_get_sized_byte_string_output \
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
431 dll_scheme_get_sized_byte_string_output
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
432 # define scheme_get_param dll_scheme_get_param
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
433 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
434 # define scheme_intern_symbol dll_scheme_intern_symbol
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
435 # define scheme_lookup_global dll_scheme_lookup_global
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
436 # define scheme_make_closed_prim_w_arity dll_scheme_make_closed_prim_w_arity
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
437 # define scheme_make_integer_value dll_scheme_make_integer_value
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
438 # define scheme_make_pair dll_scheme_make_pair
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
439 # define scheme_make_prim_w_arity dll_scheme_make_prim_w_arity
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
440 # if MZSCHEME_VERSION_MAJOR < 299
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
441 # define scheme_make_byte_string dll_scheme_make_string
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
442 # define scheme_make_byte_string_output_port dll_scheme_make_string_output_port
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
443 # else
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
444 # define scheme_make_byte_string dll_scheme_make_byte_string
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
445 # define scheme_make_byte_string_output_port \
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
446 dll_scheme_make_byte_string_output_port
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
447 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
448 # define scheme_make_struct_instance dll_scheme_make_struct_instance
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
449 # define scheme_make_struct_names dll_scheme_make_struct_names
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
450 # define scheme_make_struct_type dll_scheme_make_struct_type
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
451 # define scheme_make_struct_values dll_scheme_make_struct_values
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
452 # define scheme_make_type dll_scheme_make_type
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
453 # define scheme_make_vector dll_scheme_make_vector
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
454 # define scheme_malloc_fail_ok dll_scheme_malloc_fail_ok
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
455 # define scheme_open_input_file dll_scheme_open_input_file
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
456 # define scheme_primitive_module dll_scheme_primitive_module
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
457 # define scheme_proper_list_length dll_scheme_proper_list_length
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
458 # define scheme_raise dll_scheme_raise
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
459 # define scheme_read dll_scheme_read
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
460 # define scheme_register_static dll_scheme_register_static
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
461 # define scheme_set_stack_base dll_scheme_set_stack_base
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
462 # define scheme_signal_error dll_scheme_signal_error
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
463 # define scheme_wrong_type dll_scheme_wrong_type
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
464 # if MZSCHEME_VERSION_MAJOR >= 299
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
465 # define scheme_set_param dll_scheme_set_param
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
466 # define scheme_current_config dll_scheme_current_config
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
467 # define scheme_char_string_to_byte_string \
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
468 dll_scheme_char_string_to_byte_string
1307
64dd70f176c9 updated for version 7.1-021
vimboss
parents: 1301
diff changeset
469 # define scheme_char_string_to_path \
64dd70f176c9 updated for version 7.1-021
vimboss
parents: 1301
diff changeset
470 dll_scheme_char_string_to_path
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
471 # define scheme_set_collects_path dll_scheme_set_collects_path
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
472 # endif
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
473 # define scheme_make_hash_table dll_scheme_make_hash_table
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
474 # define scheme_hash_set dll_scheme_hash_set
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
475 # define scheme_hash_get dll_scheme_hash_get
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
510 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
514 typedef struct
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
515 {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
516 char *name;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
517 void **ptr;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
518 } Thunk_Info;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
519
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
520 static Thunk_Info mzgc_imports[] = {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
521 {"GC_malloc", (void **)&dll_GC_malloc},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
522 {"GC_malloc_atomic", (void **)&dll_GC_malloc_atomic},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
523 {NULL, NULL}};
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
524
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
525 static Thunk_Info mzsch_imports[] = {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
526 {"scheme_eof", (void **)&dll_scheme_eof},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
527 {"scheme_false", (void **)&dll_scheme_false},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
528 {"scheme_void", (void **)&dll_scheme_void},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
529 {"scheme_null", (void **)&dll_scheme_null},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
534 {"scheme_console_printf", (void **)&dll_scheme_console_printf_ptr},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
535 {"scheme_console_output", (void **)&dll_scheme_console_output_ptr},
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
536 {"scheme_notify_multithread",
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
537 (void **)&dll_scheme_notify_multithread_ptr},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
538 {"scheme_add_global", (void **)&dll_scheme_add_global},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
539 {"scheme_add_global_symbol", (void **)&dll_scheme_add_global_symbol},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
540 {"scheme_apply", (void **)&dll_scheme_apply},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
541 {"scheme_basic_env", (void **)&dll_scheme_basic_env},
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
542 # if MZSCHEME_VERSION_MAJOR >= 299
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
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
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
545 # endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
546 {"scheme_builtin_value", (void **)&dll_scheme_builtin_value},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
547 {"scheme_check_threads", (void **)&dll_scheme_check_threads},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
548 {"scheme_close_input_port", (void **)&dll_scheme_close_input_port},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
549 {"scheme_count_lines", (void **)&dll_scheme_count_lines},
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
550 {"scheme_current_continuation_marks",
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
551 (void **)&dll_scheme_current_continuation_marks},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
552 {"scheme_display", (void **)&dll_scheme_display},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
553 {"scheme_display_to_string", (void **)&dll_scheme_display_to_string},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
554 {"scheme_do_eval", (void **)&dll_scheme_do_eval},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
555 {"scheme_dont_gc_ptr", (void **)&dll_scheme_dont_gc_ptr},
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
556 {"scheme_eq", (void **)&dll_scheme_eq},
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
557 {"scheme_eval", (void **)&dll_scheme_eval},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
558 {"scheme_eval_string", (void **)&dll_scheme_eval_string},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
559 {"scheme_eval_string_all", (void **)&dll_scheme_eval_string_all},
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
560 {"scheme_finish_primitive_module",
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
561 (void **)&dll_scheme_finish_primitive_module},
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
562 # if MZSCHEME_VERSION_MAJOR < 299
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
563 {"scheme_format", (void **)&dll_scheme_format},
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
564 # else
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
565 {"scheme_format_utf8", (void **)&dll_scheme_format_utf8},
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
566 {"scheme_get_param", (void **)&dll_scheme_get_param},
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
567 #endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
568 {"scheme_gc_ptr_ok", (void **)&dll_scheme_gc_ptr_ok},
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
569 # if MZSCHEME_VERSION_MAJOR < 299
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
570 {"scheme_get_sized_string_output",
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
571 (void **)&dll_scheme_get_sized_string_output},
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
572 # else
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
573 {"scheme_get_sized_byte_string_output",
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
574 (void **)&dll_scheme_get_sized_byte_string_output},
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
575 #endif
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
576 {"scheme_intern_symbol", (void **)&dll_scheme_intern_symbol},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
577 {"scheme_lookup_global", (void **)&dll_scheme_lookup_global},
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
578 {"scheme_make_closed_prim_w_arity",
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
579 (void **)&dll_scheme_make_closed_prim_w_arity},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
580 {"scheme_make_integer_value", (void **)&dll_scheme_make_integer_value},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
581 {"scheme_make_pair", (void **)&dll_scheme_make_pair},
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
582 {"scheme_make_prim_w_arity", (void **)&dll_scheme_make_prim_w_arity},
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
583 # if MZSCHEME_VERSION_MAJOR < 299
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
584 {"scheme_make_string", (void **)&dll_scheme_make_string},
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
585 {"scheme_make_string_output_port",
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
586 (void **)&dll_scheme_make_string_output_port},
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
587 # else
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
588 {"scheme_make_byte_string", (void **)&dll_scheme_make_byte_string},
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
589 {"scheme_make_byte_string_output_port",
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
590 (void **)&dll_scheme_make_byte_string_output_port},
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
591 # endif
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
592 {"scheme_make_struct_instance",
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
593 (void **)&dll_scheme_make_struct_instance},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
594 {"scheme_make_struct_names", (void **)&dll_scheme_make_struct_names},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
595 {"scheme_make_struct_type", (void **)&dll_scheme_make_struct_type},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
596 {"scheme_make_struct_values", (void **)&dll_scheme_make_struct_values},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
597 {"scheme_make_type", (void **)&dll_scheme_make_type},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
598 {"scheme_make_vector", (void **)&dll_scheme_make_vector},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
599 {"scheme_malloc_fail_ok", (void **)&dll_scheme_malloc_fail_ok},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
600 {"scheme_open_input_file", (void **)&dll_scheme_open_input_file},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
601 {"scheme_primitive_module", (void **)&dll_scheme_primitive_module},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
602 {"scheme_proper_list_length", (void **)&dll_scheme_proper_list_length},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
603 {"scheme_raise", (void **)&dll_scheme_raise},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
604 {"scheme_read", (void **)&dll_scheme_read},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
605 {"scheme_register_static", (void **)&dll_scheme_register_static},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
606 {"scheme_set_stack_base", (void **)&dll_scheme_set_stack_base},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
607 {"scheme_signal_error", (void **)&dll_scheme_signal_error},
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
608 {"scheme_wrong_type", (void **)&dll_scheme_wrong_type},
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
609 # if MZSCHEME_VERSION_MAJOR >= 299
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
610 {"scheme_set_param", (void **)&dll_scheme_set_param},
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
611 {"scheme_current_config", (void **)&dll_scheme_current_config},
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
612 {"scheme_char_string_to_byte_string",
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
613 (void **)&dll_scheme_char_string_to_byte_string},
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
614 {"scheme_char_string_to_path", (void **)&dll_scheme_char_string_to_path},
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
615 {"scheme_set_collects_path", (void **)&dll_scheme_set_collects_path},
151
40a0699b6c62 updated for version 7.0046
vimboss
parents: 137
diff changeset
616 # endif
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
617 {"scheme_make_hash_table", (void **)&dll_scheme_make_hash_table},
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
618 {"scheme_hash_set", (void **)&dll_scheme_hash_set},
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
619 {"scheme_hash_get", (void **)&dll_scheme_hash_get},
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
620 {"scheme_make_double", (void **)&dll_scheme_make_double},
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
621 {"scheme_make_sized_byte_string", (void **)&dll_scheme_make_sized_byte_string},
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
649 {NULL, NULL}};
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
650
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
651 static HINSTANCE hMzGC = 0;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
652 static HINSTANCE hMzSch = 0;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
653
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
654 static void dynamic_mzscheme_end(void);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
655 static int mzscheme_runtime_link_init(char *sch_dll, char *gc_dll,
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
656 int verbose);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
657
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
658 static int
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
659 mzscheme_runtime_link_init(char *sch_dll, char *gc_dll, int verbose)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
660 {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
661 Thunk_Info *thunk = NULL;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
662
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
663 if (hMzGC && hMzSch)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
664 return OK;
2612
fa5dee44df3f updated for version 7.3.034
Bram Moolenaar <bram@vim.org>
parents: 2278
diff changeset
665 hMzSch = vimLoadLib(sch_dll);
fa5dee44df3f updated for version 7.3.034
Bram Moolenaar <bram@vim.org>
parents: 2278
diff changeset
666 hMzGC = vimLoadLib(gc_dll);
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
667
3348
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
668 if (!hMzGC)
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
669 {
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
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
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
672 return FAIL;
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
673 }
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
674
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
675 if (!hMzSch)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
676 {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
679 return FAIL;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
680 }
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
681
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
682 for (thunk = mzsch_imports; thunk->name; thunk++)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
683 {
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
684 if ((*thunk->ptr =
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
685 (void *)GetProcAddress(hMzSch, thunk->name)) == NULL)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
686 {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
687 FreeLibrary(hMzSch);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
688 hMzSch = 0;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
689 FreeLibrary(hMzGC);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
690 hMzGC = 0;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
693 return FAIL;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
694 }
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
695 }
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
696 for (thunk = mzgc_imports; thunk->name; thunk++)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
697 {
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
698 if ((*thunk->ptr =
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
699 (void *)GetProcAddress(hMzGC, thunk->name)) == NULL)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
700 {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
701 FreeLibrary(hMzSch);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
702 hMzSch = 0;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
703 FreeLibrary(hMzGC);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
704 hMzGC = 0;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
707 return FAIL;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
708 }
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
709 }
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
710 return OK;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
711 }
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
712
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
713 int
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
714 mzscheme_enabled(int verbose)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
715 {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
718 }
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
719
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
720 static void
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
721 dynamic_mzscheme_end(void)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
722 {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
723 if (hMzSch)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
724 {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
725 FreeLibrary(hMzSch);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
726 hMzSch = 0;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
727 }
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
728 if (hMzGC)
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
729 {
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
730 FreeLibrary(hMzGC);
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
731 hMzGC = 0;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
732 }
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
735
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
736 #if MZSCHEME_VERSION_MAJOR < 299
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
737 # define GUARANTEED_STRING_ARG(proc, num) GUARANTEE_STRING(proc, num)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
738 #else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
739 static Scheme_Object *
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
740 guaranteed_byte_string_arg(char *proc, int num, int argc, Scheme_Object **argv)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
741 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
742 if (SCHEME_BYTE_STRINGP(argv[num]))
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
743 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
744 return argv[num];
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
745 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
746 else if (SCHEME_CHAR_STRINGP(argv[num]))
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
747 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
748 Scheme_Object *tmp = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
749 MZ_GC_DECL_REG(2);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
750 MZ_GC_VAR_IN_REG(0, argv[num]);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
751 MZ_GC_VAR_IN_REG(1, tmp);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
752 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
753 tmp = scheme_char_string_to_byte_string(argv[num]);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
754 MZ_GC_UNREG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
755 return tmp;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
756 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
757 else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
760 return scheme_void;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
761 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
762 # define GUARANTEED_STRING_ARG(proc, num) guaranteed_byte_string_arg(proc, num, argc, argv)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
763 #endif
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
1c64bf25bbcd updated for version 7.2-247
vimboss
parents: 1929
diff changeset
766 #if defined(INCLUDE_MZSCHEME_BASE)
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
767 # include "mzscheme_base.c"
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
768 #endif
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
769
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
770 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
771 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
772 * 1. MzScheme interpreter startup
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
773 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
774 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
775
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
776 static Scheme_Type mz_buffer_type;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
777 static Scheme_Type mz_window_type;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
778
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
788 static Scheme_Object *curout = NULL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
791 static Scheme_Object *exn_catching_apply = NULL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
792 static Scheme_Object *exn_p = NULL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
795
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
796 #if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
797 static void *stack_base = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
798 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
799
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
800 static long range_start;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
801 static long range_end;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
804 static int mz_threads_allow = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
808 static UINT timer_id = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
811 static guint timer_id = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
812 #elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
813 static void timer_proc(XtPointer, XtIntervalId *);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
814 static XtIntervalId timer_id = (XtIntervalId)0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
815 #elif defined(FEAT_GUI_MAC)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
816 pascal void timer_proc(EventLoopTimerRef, void *);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
817 static EventLoopTimerRef timer_id = NULL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
818 static EventLoopTimerUPP timerUPP;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
819 #endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
822 void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
823 mzvim_check_threads(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
826 static time_t mz_last_time = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
827
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
828 if (mz_threads_allow && p_mzq > 0)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
829 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
830 time_t now = time(NULL);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
831
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
832 if ((now - mz_last_time) * 1000 > p_mzq)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
833 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
834 mz_last_time = now;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
835 scheme_check_threads();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
836 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
837 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
838 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
839 #endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
3ba373b54370 updated for version 7.0008
vimboss
parents: 15
diff changeset
842 static void setup_timer(void);
3ba373b54370 updated for version 7.0008
vimboss
parents: 15
diff changeset
843 static void remove_timer(void);
3ba373b54370 updated for version 7.0008
vimboss
parents: 15
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
852 # elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
855 # elif defined(FEAT_GUI_MAC)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
858 # endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
859 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
860 scheme_check_threads();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
865 if (mz_threads_allow && p_mzq > 0)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
866 timer_id = XtAppAddTimeOut(app_context, p_mzq,
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
867 timer_proc, NULL);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
868 # endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
869 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
870
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
871 static void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
872 setup_timer(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
875 timer_id = SetTimer(NULL, 0, p_mzq, timer_proc);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
878 # elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
879 timer_id = XtAppAddTimeOut(app_context, p_mzq, timer_proc, NULL);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
880 # elif defined(FEAT_GUI_MAC)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
881 timerUPP = NewEventLoopTimerUPP(timer_proc);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
882 InstallEventLoopTimer(GetMainEventLoop(), p_mzq * kEventDurationMillisecond,
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
883 p_mzq * kEventDurationMillisecond, timerUPP, NULL, &timer_id);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
884 # endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
885 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
886
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
887 static void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
888 remove_timer(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
891 KillTimer(NULL, timer_id);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
894 # elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
895 XtRemoveTimeOut(timer_id);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
896 # elif defined(FEAT_GUI_MAC)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
897 RemoveEventLoopTimer(timer_id);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
898 DisposeEventLoopTimerUPP(timerUPP);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
899 # endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
900 timer_id = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
901 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
902
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
903 void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
904 mzvim_reset_timer(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
905 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
906 if (timer_id != 0)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
907 remove_timer();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
908 if (mz_threads_allow && p_mzq > 0 && gui.in_use)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
909 setup_timer();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
910 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
913
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
914 static void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
915 notify_multithread(int on)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
916 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
917 mz_threads_allow = on;
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 15
diff changeset
918 #ifdef MZSCHEME_GUI_THREADS
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
919 if (on && timer_id == 0 && p_mzq > 0 && gui.in_use)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
920 setup_timer();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
921 if (!on && timer_id != 0)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
922 remove_timer();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
923 #endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
924 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
925
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
926 void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
927 mzscheme_end(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
931 #ifdef DYNAMIC_MZSCHEME
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
932 dynamic_mzscheme_end();
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
933 #endif
7609
77a14f3bc18b commit https://github.com/vim/vim/commit/4e640bd930d133889dbc9f9a77e29bab902e3b7d
Christian Brabandt <cb@256bit.org>
parents: 6949
diff changeset
934 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
935 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
5c4b2fc4f067 updated for version 7.3.049
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
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
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
947 # endif
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
948 #endif
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
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
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
d973e23c3bf8 patch 7.4.772
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
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
5c4b2fc4f067 updated for version 7.3.049
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
974 #endif
3348
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
979 #endif
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
980 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
981
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
984 {
3348
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
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
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
987 environment = env;
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
988 #else
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
989 # ifdef MZ_PRECISE_GC
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
990 Scheme_Object *dummy = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
991 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
992 MZ_GC_VAR_IN_REG(0, dummy);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
993
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
994 stack_base = &__gc_var_stack__;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
995 # else
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
996 int dummy = 0;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
997 stack_base = (void *)&dummy;
3348
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
998 # endif
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
999 #endif
3348
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1005 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1022 startup_mzscheme(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1023 {
3348
af4ed13ca541 updated for version 7.3.441
Bram Moolenaar <bram@vim.org>
parents: 2628
diff changeset
1024 #ifndef TRAMPOLINED_MZVIM_STARTUP
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1025 scheme_set_stack_base(stack_base, 1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1026 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1027
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1030 environment = scheme_basic_env();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1031 #endif
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1032
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1033 MZ_REGISTER_STATIC(environment);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1034 MZ_REGISTER_STATIC(curout);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1035 MZ_REGISTER_STATIC(curerr);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1036 MZ_REGISTER_STATIC(exn_catching_apply);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1037 MZ_REGISTER_STATIC(exn_p);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1038 MZ_REGISTER_STATIC(exn_message);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1039 MZ_REGISTER_STATIC(vim_exn);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1040
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1041 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1042
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
64dd70f176c9 updated for version 7.1-021
vimboss
parents: 1301
diff changeset
1049 # if MZSCHEME_VERSION_MAJOR >= 299
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1079 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1080 }
1307
64dd70f176c9 updated for version 7.1-021
vimboss
parents: 1301
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1083 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1084 Scheme_Object *coll_string = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1085 Scheme_Object *coll_pair = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1086 Scheme_Config *config = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1087
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1088 MZ_GC_DECL_REG(3);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1089 MZ_GC_VAR_IN_REG(0, coll_string);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1090 MZ_GC_VAR_IN_REG(1, coll_pair);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1091 MZ_GC_VAR_IN_REG(2, config);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1092 MZ_GC_REG();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1093 coll_string = scheme_make_byte_string(MZSCHEME_COLLECTS);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1094 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1095 coll_pair = scheme_make_pair(coll_string, scheme_null);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1096 MZ_GC_CHECK();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1097 config = scheme_current_config();
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1098 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1099 scheme_set_param(config, MZCONFIG_COLLECTION_PATHS, coll_pair);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1100 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1101 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1102 }
1307
64dd70f176c9 updated for version 7.1-021
vimboss
parents: 1301
diff changeset
1103 # endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
1170 #ifdef HAVE_SANDBOX
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
1171 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1172 Scheme_Object *make_security_guard = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1173 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1174 MZ_GC_VAR_IN_REG(0, make_security_guard);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1175 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1176
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1177 #if MZSCHEME_VERSION_MAJOR < 400
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1178 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1179 Scheme_Object *make_security_guard_symbol = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1180 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1181 MZ_GC_VAR_IN_REG(0, make_security_guard_symbol);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1182 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1183 make_security_guard_symbol = scheme_intern_symbol("make-security-guard");
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1184 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1185 make_security_guard = scheme_lookup_global(
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1186 make_security_guard_symbol, environment);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1187 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1188 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1189 #else
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1190 make_security_guard = scheme_builtin_value("make-security-guard");
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1191 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1192 #endif
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1195 if (make_security_guard != NULL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1196 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1197 Scheme_Object *args[3] = {NULL, NULL, NULL};
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1198 Scheme_Object *guard = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1199 Scheme_Config *config = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1200 MZ_GC_DECL_REG(5);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1201 MZ_GC_ARRAY_VAR_IN_REG(0, args, 3);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1202 MZ_GC_VAR_IN_REG(3, guard);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1203 MZ_GC_VAR_IN_REG(4, config);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1204 MZ_GC_REG();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1205 config = scheme_current_config();
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1206 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1207 args[0] = scheme_get_param(config, MZCONFIG_SECURITY_GUARD);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1208 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1209 args[1] = scheme_make_prim_w_arity(sandbox_file_guard,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1210 "sandbox-file-guard", 3, 3);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1211 args[2] = scheme_make_prim_w_arity(sandbox_network_guard,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1212 "sandbox-network-guard", 4, 4);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1213 guard = scheme_apply(make_security_guard, 3, args);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1214 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1215 scheme_set_param(config, MZCONFIG_SECURITY_GUARD, guard);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1216 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1217 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1218 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1219 MZ_GC_UNREG();
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
1220 }
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1223 mz_buffer_type = scheme_make_type("<vim-buffer>");
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1224 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1225 mz_window_type = scheme_make_type("<vim-window>");
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1226 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1227 #ifdef MZ_PRECISE_GC
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1228 GC_register_traversers(mz_buffer_type,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1229 buffer_size_proc, buffer_mark_proc, buffer_fixup_proc,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1230 TRUE, TRUE);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1231 GC_register_traversers(mz_window_type,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1232 window_size_proc, window_mark_proc, window_fixup_proc,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1233 TRUE, TRUE);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1234 #endif
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1235
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1236 make_modules();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1237
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1238 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1239 * setup callback to receive notifications
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1240 * whether thread scheduling is (or not) required
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1241 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1245 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1246
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1247 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1248 * This routine is called for each new invocation of MzScheme
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1249 * to make sure things are properly initialized.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1250 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1251 static int
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1252 mzscheme_init(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1253 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1254 if (!initialized)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1255 {
137
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
1260 return -1;
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
1261 }
3e7d17e425b0 updated for version 7.0044
vimboss
parents: 16
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1268 initialized = TRUE;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1269 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1270 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1271 Scheme_Config *config = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1272 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1273 MZ_GC_VAR_IN_REG(0, config);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1274 MZ_GC_REG();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1275 config = scheme_current_config();
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1278 curout = scheme_make_byte_string_output_port();
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1279 MZ_GC_CHECK();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1280 curerr = scheme_make_byte_string_output_port();
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1281 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1282 scheme_set_param(config, MZCONFIG_OUTPUT_PORT, curout);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1283 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1284 scheme_set_param(config, MZCONFIG_ERROR_PORT, curerr);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1285 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1286 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1287 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1288
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1289 return 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1290 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1291
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1292 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1293 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1294 * 2. External Interface
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1295 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1296 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1297
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1298 /*
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1299 * Evaluate command with exception handling
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1300 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1301 static int
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1302 eval_with_exn_handling(void *data, Scheme_Closed_Prim *what, Scheme_Object **ret)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1303 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1304 Scheme_Object *value = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1305 Scheme_Object *exn = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1306 Scheme_Object *prim = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1307
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1308 MZ_GC_DECL_REG(3);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1309 MZ_GC_VAR_IN_REG(0, value);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1310 MZ_GC_VAR_IN_REG(1, exn);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1311 MZ_GC_VAR_IN_REG(2, prim);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1312 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1313
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1314 prim = scheme_make_closed_prim_w_arity(what, data, "mzvim", 0, 0);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1315 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1316 value = _apply_thunk_catch_exceptions(prim, &exn);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1317 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1318
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1319 if (!value)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1320 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1323 if (value)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1326 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1327 do_flush();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1328 }
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1331 return FAIL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1332 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1337 else if (!SCHEME_VOIDP(value))
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1340 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1341 }
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1342
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1343 do_flush();
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1344 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1345 return OK;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1346 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1351 static int
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1352 do_mzscheme_command(exarg_T *eap, void *data, Scheme_Closed_Prim *what)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1353 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1354 if (mzscheme_init())
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1355 return FAIL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1356
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1357 range_start = eap->line1;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1358 range_end = eap->line2;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1359
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1360 return eval_with_exn_handling(data, what, NULL);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1361 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1362
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1363 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1364 * Routine called by VIM when deleting a buffer
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1365 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1366 void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1367 mzscheme_buffer_free(buf_T *buf)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1368 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 344
diff changeset
1369 if (buf->b_mzscheme_ref)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1370 {
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1371 vim_mz_buffer *bp = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1372 MZ_GC_DECL_REG(1);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1373 MZ_GC_VAR_IN_REG(0, bp);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1374 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1375
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1376 bp = BUFFER_REF(buf);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1377 bp->buf = INVALID_BUFFER_VALUE;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1378 #ifndef MZ_PRECISE_GC
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1379 scheme_gc_ptr_ok(bp);
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1380 #else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1381 scheme_free_immobile_box(buf->b_mzscheme_ref);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1382 #endif
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1383 buf->b_mzscheme_ref = NULL;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1384 MZ_GC_CHECK();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1385 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1386 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1387 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1388
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1389 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1390 * Routine called by VIM when deleting a Window
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1391 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1392 void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1393 mzscheme_window_free(win_T *win)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1394 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 344
diff changeset
1395 if (win->w_mzscheme_ref)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1396 {
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1397 vim_mz_window *wp = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1398 MZ_GC_DECL_REG(1);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1399 MZ_GC_VAR_IN_REG(0, wp);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1400 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1401 wp = WINDOW_REF(win);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1402 wp->win = INVALID_WINDOW_VALUE;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1403 #ifndef MZ_PRECISE_GC
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1404 scheme_gc_ptr_ok(wp);
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1405 #else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1406 scheme_free_immobile_box(win->w_mzscheme_ref);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1407 #endif
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1408 win->w_mzscheme_ref = NULL;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1409 MZ_GC_CHECK();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1410 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1411 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1412 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1413
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1414 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1415 * ":mzscheme" (or ":mz")
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1416 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1417 void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1418 ex_mzscheme(exarg_T *eap)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1419 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1420 char_u *script;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1421
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1422 script = script_get(eap, eap->arg);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1423 if (!eap->skip)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1424 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1425 if (script == NULL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1426 do_mzscheme_command(eap, eap->arg, do_eval);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1427 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1428 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1429 do_mzscheme_command(eap, script, do_eval);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1430 vim_free(script);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1431 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1432 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1433 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1434
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1437 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1438 Scheme_Object *expr = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1439 Scheme_Object *result = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1440 char *file = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1441 Port_Info *pinfo = (Port_Info *)data;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1442
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1443 MZ_GC_DECL_REG(3);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1444 MZ_GC_VAR_IN_REG(0, expr);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1445 MZ_GC_VAR_IN_REG(1, result);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1446 MZ_GC_VAR_IN_REG(2, file);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1447 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1448
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1449 file = (char *)scheme_malloc_fail_ok(scheme_malloc_atomic, MAXPATHL + 1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1450 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1453 expand_env((char_u *)pinfo->name, (char_u *)file, MAXPATHL);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1454 pinfo->port = scheme_open_input_file(file, "mzfile");
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1457 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1460 while (!SCHEME_EOFP(expr = scheme_read(pinfo->port)))
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1461 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1462 result = scheme_eval(expr, environment);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1463 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1464 }
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1467 scheme_close_input_port(pinfo->port);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1468 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1469 pinfo->port = NULL;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1470 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1471 return result;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1472 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1477 void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1478 ex_mzfile(exarg_T *eap)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1479 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1480 Port_Info pinfo = {NULL, NULL};
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1481
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1482 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1483 MZ_GC_VAR_IN_REG(0, pinfo.port);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1484 MZ_GC_REG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1485
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1486 pinfo.name = (char *)eap->arg;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1489 {
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1490 scheme_close_input_port(pinfo.port);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1491 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1492 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1493 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1494 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1495
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1496
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1497 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1498 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1499 * Exception handling code -- cribbed form the MzScheme sources and
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1500 * Matthew Flatt's "Inside PLT MzScheme" document.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1501 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1502 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1503 static void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1504 init_exn_catching_apply(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1505 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1506 if (!exn_catching_apply)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1507 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1508 char *e =
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1509 "(lambda (thunk) "
856
8cd729851562 updated for version 7.0g
vimboss
parents: 800
diff changeset
1510 "(with-handlers ([void (lambda (exn) (cons #f exn))]) "
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1511 "(cons #t (thunk))))";
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1512
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1513 exn_catching_apply = scheme_eval_string(e, environment);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1514 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1515 exn_p = scheme_builtin_value("exn?");
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1516 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1517 exn_message = scheme_builtin_value("exn-message");
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1518 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1519 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1520 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1521
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1522 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1523 * This function applies a thunk, returning the Scheme value if there's
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1524 * no exception, otherwise returning NULL and setting *exn to the raised
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1525 * value (usually an exn structure).
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1526 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1527 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1528 _apply_thunk_catch_exceptions(Scheme_Object *f, Scheme_Object **exn)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1529 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1530 Scheme_Object *v;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1531
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1534
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1535 if (SCHEME_TRUEP(SCHEME_CAR(v)))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1536 return SCHEME_CDR(v);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1537 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1538 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1539 *exn = SCHEME_CDR(v);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1540 return NULL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1541 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1542 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1543
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1544 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1545 extract_exn_message(Scheme_Object *v)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1546 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1547 if (SCHEME_TRUEP(_scheme_apply(exn_p, 1, &v)))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1548 return _scheme_apply(exn_message, 1, &v);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1551 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1552
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1555 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1556 return scheme_eval_string_all((char *)s, environment, TRUE);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1557 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1558
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1559 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1560 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1561 * 3. MzScheme I/O Handlers
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1562 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1563 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1566 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1567 char *p, *prev;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1568
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1569 prev = mesg;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1570 p = strchr(prev, '\n');
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1571 while (p)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1572 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1573 *p = '\0';
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1578 prev = p + 1;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1579 p = strchr(prev, '\n');
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1580 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1581
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1586 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1587
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1588 static void
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1589 do_output(char *mesg, OUTPUT_LEN_TYPE len UNUSED)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1593 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1594
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1599 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1600
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1601 static void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1602 do_printf(char *format, ...)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1605 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1606
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1607 static void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1608 do_flush(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1609 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1610 char *buff;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1611 OUTPUT_LEN_TYPE length;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1612
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1613 buff = scheme_get_sized_byte_string_output(curerr, &length);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1614 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1615 if (length)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1616 {
2278
0b3be97064e5 Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents: 2050
diff changeset
1617 do_err_output(buff);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1618 return;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1619 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1620
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1621 buff = scheme_get_sized_byte_string_output(curout, &length);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1622 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1623 if (length)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1624 do_output(buff, length);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1625 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1626
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1627 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1628 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1629 * 4. Implementation of the Vim Features for MzScheme
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1630 *========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1631 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1636 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1637 vim_command(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1638 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1639 Vim_Prim *prim = (Vim_Prim *)data;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1640 Scheme_Object *cmd = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1641 MZ_GC_DECL_REG(1);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1642 MZ_GC_VAR_IN_REG(0, cmd);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1643 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1644 cmd = GUARANTEED_STRING_ARG(prim->name, 0);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1647 do_cmdline(BYTE_STRING_VALUE(cmd), NULL, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1648 update_screen(VALID);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1649
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1650 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1651 raise_if_error();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1652 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1653 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1658 static Scheme_Object *
4082
17a312ba38a0 updated for version 7.3.795
Bram Moolenaar <bram@vim.org>
parents: 4074
diff changeset
1659 vim_eval(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1660 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1661 #ifdef FEAT_EVAL
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1662 Vim_Prim *prim = (Vim_Prim *)data;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1663 Scheme_Object *result = NULL;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1664 typval_T *vim_result;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1665 Scheme_Object *expr = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1666 MZ_GC_DECL_REG(2);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1667 MZ_GC_VAR_IN_REG(0, result);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1668 MZ_GC_VAR_IN_REG(1, expr);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1669 MZ_GC_REG();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1670 expr = GUARANTEED_STRING_ARG(prim->name, 0);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1671
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1672 vim_result = eval_expr(BYTE_STRING_VALUE(expr), NULL);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1673
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1674 if (vim_result == NULL)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1675 raise_vim_exn(_("invalid expression"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1676
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1677 result = vim_to_mzscheme(vim_result);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1678 MZ_GC_CHECK();
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1679 free_tv(vim_result);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1680
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1681 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1682 return result;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1683 #else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1686 return scheme_false;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1687 #endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1688 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1695 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1696 return scheme_make_integer(range_start);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1697 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1704 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1705 return scheme_make_integer(range_end);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1706 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1713 {
6949
1e621b31948b patch 7.4.793
Bram Moolenaar <bram@vim.org>
parents: 6905
diff changeset
1714 vim_beep(BO_LANG);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1715 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1716 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1717
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1718 static Scheme_Object *M_global = NULL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1723 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1724 get_option(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1725 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1726 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1727 long value;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1728 char *strval;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1729 int rc;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1730 Scheme_Object *rval = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1731 Scheme_Object *name = NULL;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1732 int opt_flags = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1733 buf_T *save_curb = curbuf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1734 win_T *save_curw = curwin;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1735
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1736 MZ_GC_DECL_REG(2);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1737 MZ_GC_VAR_IN_REG(0, rval);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1738 MZ_GC_VAR_IN_REG(1, name);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1739 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1740
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1741 name = GUARANTEED_STRING_ARG(prim->name, 0);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1742
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1743 if (argc > 1)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1744 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1745 if (M_global == NULL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1746 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1747 MZ_REGISTER_STATIC(M_global);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1748 M_global = scheme_intern_symbol("global");
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1749 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1750 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1751
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1752 if (argv[1] == M_global)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1753 opt_flags = OPT_GLOBAL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1754 else if (SCHEME_VIMBUFFERP(argv[1]))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1755 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1756 curbuf = get_valid_buffer(argv[1]);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1757 opt_flags = OPT_LOCAL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1758 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1759 else if (SCHEME_VIMWINDOWP(argv[1]))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1760 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1761 win_T *win = get_valid_window(argv[1]);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1762
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1763 curwin = win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1764 curbuf = win->w_buffer;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1765 opt_flags = OPT_LOCAL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1766 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1767 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1768 scheme_wrong_type(prim->name, "vim-buffer/window", 1, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1769 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1770
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1771 rc = get_option_value(BYTE_STRING_VALUE(name), &value, (char_u **)&strval, opt_flags);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1772 curbuf = save_curb;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1773 curwin = save_curw;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1774
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1775 switch (rc)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1776 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1777 case 1:
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1778 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1779 return scheme_make_integer_value(value);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1780 case 0:
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1781 rval = scheme_make_byte_string(strval);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1782 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1783 vim_free(strval);
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1784 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1785 return rval;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1786 case -1:
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1787 case -2:
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1788 MZ_GC_UNREG();
856
8cd729851562 updated for version 7.0g
vimboss
parents: 800
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1791 case -3:
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1792 MZ_GC_UNREG();
856
8cd729851562 updated for version 7.0g
vimboss
parents: 800
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1795 }
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1796 // unreachable
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1797 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1798 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1803 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1804 set_option(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1805 {
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1806 char_u *command = NULL;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1807 int opt_flags = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1808 buf_T *save_curb = curbuf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1809 win_T *save_curw = curwin;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1810 Vim_Prim *prim = (Vim_Prim *)data;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1811 Scheme_Object *cmd = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1812
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1813 MZ_GC_DECL_REG(1);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1814 MZ_GC_VAR_IN_REG(0, cmd);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1815 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1816 cmd = GUARANTEED_STRING_ARG(prim->name, 0);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1817
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1818 if (argc > 1)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1819 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1820 if (M_global == NULL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1821 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1822 MZ_REGISTER_STATIC(M_global);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1823 M_global = scheme_intern_symbol("global");
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1824 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1825 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1826
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1827 if (argv[1] == M_global)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1828 opt_flags = OPT_GLOBAL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1829 else if (SCHEME_VIMBUFFERP(argv[1]))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1830 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1831 curbuf = get_valid_buffer(argv[1]);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1832 opt_flags = OPT_LOCAL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1833 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1834 else if (SCHEME_VIMWINDOWP(argv[1]))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1835 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1836 win_T *win = get_valid_window(argv[1]);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1837 curwin = win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1838 curbuf = win->w_buffer;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1839 opt_flags = OPT_LOCAL;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1840 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1841 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1842 scheme_wrong_type(prim->name, "vim-buffer/window", 1, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1843 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1846 command = vim_strsave(BYTE_STRING_VALUE(cmd));
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1847 MZ_GC_UNREG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1848 do_set(command, opt_flags);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1849 vim_free(command);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1850 update_screen(NOT_VALID);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1851 curbuf = save_curb;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1852 curwin = save_curw;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1853 raise_if_error();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1854 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1855 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1856
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1857 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1858 *===========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1859 * 5. Vim Window-related Manipulation Functions
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1860 *===========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1861 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1868 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1869 return (Scheme_Object *)get_vim_curr_window();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1870 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1877 {
4082
17a312ba38a0 updated for version 7.3.795
Bram Moolenaar <bram@vim.org>
parents: 4074
diff changeset
1878 int n = 0;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1879 win_T *w;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
1882 ++n;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1883 return scheme_make_integer(n);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1884 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1889 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1890 get_window_list(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1891 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1892 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1893 vim_mz_buffer *buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1894 Scheme_Object *list;
4082
17a312ba38a0 updated for version 7.3.795
Bram Moolenaar <bram@vim.org>
parents: 4074
diff changeset
1895 win_T *w = firstwin;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1896
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1897 buf = get_buffer_arg(prim->name, 0, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1898 list = scheme_null;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1899
4082
17a312ba38a0 updated for version 7.3.795
Bram Moolenaar <bram@vim.org>
parents: 4074
diff changeset
1900 for ( ; w != NULL; w = w->w_next)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 800
diff changeset
1901 if (w->w_buffer == buf->buf)
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1902 {
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1903 list = scheme_make_pair(window_new(w), list);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1904 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1905 }
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1906
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1907 return list;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1908 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1909
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1910 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1911 window_new(win_T *win)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1912 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1913 vim_mz_window *self = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1914
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1915 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1916 MZ_GC_VAR_IN_REG(0, self);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 344
diff changeset
1925 if (win->w_mzscheme_ref != NULL)
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1926 return (Scheme_Object *)WINDOW_REF(win);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1927
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1928 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1933 #else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1934 win->w_mzscheme_ref = scheme_malloc_immobile_box(NULL);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1935 #endif
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1936 MZ_GC_CHECK();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1937 WINDOW_REF(win) = self;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1938 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1939 self->win = win;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1940 self->so.type = mz_window_type;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1941
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
1942 MZ_GC_UNREG();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
1943 return (Scheme_Object *)self;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1944 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1949 static Scheme_Object *
4082
17a312ba38a0 updated for version 7.3.795
Bram Moolenaar <bram@vim.org>
parents: 4074
diff changeset
1950 get_window_num(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1951 {
4082
17a312ba38a0 updated for version 7.3.795
Bram Moolenaar <bram@vim.org>
parents: 4074
diff changeset
1952 int nr = 1;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1953 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1954 win_T *win = get_window_arg(prim->name, 0, argc, argv)->win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1955 win_T *wp;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1956
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1957 for (wp = firstwin; wp != win; wp = wp->w_next)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1958 ++nr;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1959
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1960 return scheme_make_integer(nr);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1961 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1966 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1967 get_window_by_num(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1968 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1969 Vim_Prim *prim = (Vim_Prim *)data;
4082
17a312ba38a0 updated for version 7.3.795
Bram Moolenaar <bram@vim.org>
parents: 4074
diff changeset
1970 win_T *win = firstwin;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1971 int fnum;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1972
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1973 fnum = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1974 if (fnum < 1)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1975 scheme_signal_error(_("window index is out of range"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1976
4082
17a312ba38a0 updated for version 7.3.795
Bram Moolenaar <bram@vim.org>
parents: 4074
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1979 return window_new(win);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1980
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1981 return scheme_false;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1982 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1987 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1988 get_window_buffer(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1989 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1990 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1991 vim_mz_window *win = get_window_arg(prim->name, 0, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1992
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1993 return buffer_new(win->win->w_buffer);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1994 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
1999 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2000 get_window_height(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2001 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2002 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2003 vim_mz_window *win = get_window_arg(prim->name, 0, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2004
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2005 return scheme_make_integer(win->win->w_height);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2006 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2011 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2012 set_window_height(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2013 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2014 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2015 vim_mz_window *win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2016 win_T *savewin;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2017 int height;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2018
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2019 win = get_window_arg(prim->name, 1, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2020 height = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2021
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2022 #ifdef FEAT_GUI
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2023 need_mouse_correct = TRUE;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2024 #endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2025
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2026 savewin = curwin;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2027 curwin = win->win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2028 win_setheight(height);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2029 curwin = savewin;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2030
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2031 raise_if_error();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2032 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2033 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2038 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2039 get_window_width(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2040 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2041 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2042 vim_mz_window *win = get_window_arg(prim->name, 0, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2045 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2050 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2051 set_window_width(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2052 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2053 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2054 vim_mz_window *win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2055 win_T *savewin;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2056 int width = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2057
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2058 win = get_window_arg(prim->name, 1, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2059 width = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2060
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2061 # ifdef FEAT_GUI
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2062 need_mouse_correct = TRUE;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2063 # endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2064
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2065 savewin = curwin;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2066 curwin = win->win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2067 win_setwidth(width);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2068 curwin = savewin;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2069
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2070 raise_if_error();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2071 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2072 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2077 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2078 get_cursor(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2079 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2080 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2081 vim_mz_window *win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2082 pos_T pos;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2083
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2084 win = get_window_arg(prim->name, 0, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2085 pos = win->win->w_cursor;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2086 return scheme_make_pair(scheme_make_integer_value((long)pos.lnum),
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2087 scheme_make_integer_value((long)pos.col + 1));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2088 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2093 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2094 set_cursor(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2095 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2096 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2097 vim_mz_window *win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2098 long lnum = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2099 long col = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2100
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2101 #ifdef HAVE_SANDBOX
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2102 sandbox_check();
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2103 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2104 win = get_window_arg(prim->name, 1, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2105 GUARANTEE_PAIR(prim->name, 0);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2106
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2107 if (!SCHEME_INTP(SCHEME_CAR(argv[0]))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2108 || !SCHEME_INTP(SCHEME_CDR(argv[0])))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2109 scheme_wrong_type(prim->name, "integer pair", 0, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2110
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2111 lnum = SCHEME_INT_VAL(SCHEME_CAR(argv[0]));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2112 col = SCHEME_INT_VAL(SCHEME_CDR(argv[0])) - 1;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2113
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2116
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2117 win->win->w_cursor.lnum = lnum;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2120 update_screen(VALID);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2121
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2122 raise_if_error();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2123 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2124 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2125 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2126 *===========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2127 * 6. Vim Buffer-related Manipulation Functions
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2128 *===========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2129 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2134 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2135 mzscheme_open_buffer(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2136 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2137 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2138 int num = 0;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2139 Scheme_Object *onum = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2140 Scheme_Object *buf = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2141 Scheme_Object *fname;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2142
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2143 MZ_GC_DECL_REG(3);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2144 MZ_GC_VAR_IN_REG(0, onum);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2145 MZ_GC_VAR_IN_REG(1, buf);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2146 MZ_GC_VAR_IN_REG(2, fname);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2147 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2148 fname = GUARANTEED_STRING_ARG(prim->name, 0);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2149
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2150 #ifdef HAVE_SANDBOX
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2151 sandbox_check();
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2154 num = buflist_add(BYTE_STRING_VALUE(fname), BLN_LISTED | BLN_CURBUF);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2155
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2156 if (num == 0)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2157 raise_vim_exn(_("couldn't open buffer"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2158
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2159 onum = scheme_make_integer(num);
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2160 buf = get_buffer_by_num(data, 1, &onum);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2161 MZ_GC_UNREG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2162 return buf;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2163 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2168 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2169 get_buffer_by_num(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2170 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2171 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2172 buf_T *buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2173 int fnum;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2174
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2175 fnum = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
8cd729851562 updated for version 7.0g
vimboss
parents: 800
diff changeset
2178 if (buf->b_fnum == fnum)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2179 return buffer_new(buf);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2180
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2181 return scheme_false;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2182 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2187 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2188 get_buffer_by_name(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2189 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2190 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2191 buf_T *buf;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2192 Scheme_Object *buffer = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2193 Scheme_Object *fname = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2194
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2195 MZ_GC_DECL_REG(2);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2196 MZ_GC_VAR_IN_REG(0, buffer);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2197 MZ_GC_VAR_IN_REG(1, fname);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2198 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2199 fname = GUARANTEED_STRING_ARG(prim->name, 0);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2200 buffer = scheme_false;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2203 {
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2206 {
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2207 if (BYTE_STRING_VALUE(fname)[0] == NUL)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2208 buffer = buffer_new(buf);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2209 }
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2210 else if (!fnamecmp(buf->b_ffname, BYTE_STRING_VALUE(fname))
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2211 || !fnamecmp(buf->b_sfname, BYTE_STRING_VALUE(fname)))
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2214 buffer = buffer_new(buf);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2215 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2216 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2217
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2218 MZ_GC_UNREG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2219 return buffer;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2220 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2225 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2226 get_next_buffer(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2227 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2228 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2229 buf_T *buf = get_buffer_arg(prim->name, 0, argc, argv)->buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2230
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2231 if (buf->b_next == NULL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2232 return scheme_false;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2233 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2234 return buffer_new(buf->b_next);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2235 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2240 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2241 get_prev_buffer(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2242 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2243 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2244 buf_T *buf = get_buffer_arg(prim->name, 0, argc, argv)->buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2245
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2246 if (buf->b_prev == NULL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2247 return scheme_false;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2248 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2249 return buffer_new(buf->b_prev);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2250 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2255 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2256 get_buffer_num(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2257 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2258 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2259 vim_mz_buffer *buf = get_buffer_arg(prim->name, 0, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2260
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2261 return scheme_make_integer(buf->buf->b_fnum);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2262 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2269 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2270 buf_T *b;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2271 int n = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2274 return scheme_make_integer(n);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2275 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2280 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2281 get_buffer_name(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2282 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2283 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2284 vim_mz_buffer *buf = get_buffer_arg(prim->name, 0, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2285
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2286 return scheme_make_byte_string((char *)buf->buf->b_ffname);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2287 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2294 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2295 return (Scheme_Object *)get_vim_curr_buffer();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2296 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2297
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2298 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2299 buffer_new(buf_T *buf)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2300 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2301 vim_mz_buffer *self = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2302
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2303 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2304 MZ_GC_VAR_IN_REG(0, self);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 344
diff changeset
2309 if (buf->b_mzscheme_ref)
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2310 return (Scheme_Object *)BUFFER_REF(buf);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2311
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2312 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2317 #else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2318 buf->b_mzscheme_ref = scheme_malloc_immobile_box(NULL);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2319 #endif
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2320 MZ_GC_CHECK();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2321 BUFFER_REF(buf) = self;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2322 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2323 self->buf = buf;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2324 self->so.type = mz_buffer_type;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2325
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2326 MZ_GC_UNREG();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2327 return (Scheme_Object *)self;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2328 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2329
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2330 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2331 * (get-buff-size [buffer])
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2332 *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2333 * Get the size (number of lines) in the current buffer.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2334 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2335 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2336 get_buffer_size(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2337 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2338 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2339 vim_mz_buffer *buf = get_buffer_arg(prim->name, 0, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2340
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2341 return scheme_make_integer(buf->buf->b_ml.ml_line_count);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2342 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2343
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2344 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2345 * (get-buff-line {linenr} [buffer])
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2346 *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2347 * Get a line from the specified buffer. The line number is
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2348 * in Vim format (1-based). The line is returned as a MzScheme
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2349 * string object.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2350 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2351 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2352 get_buffer_line(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2353 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2354 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2355 vim_mz_buffer *buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2356 int linenr;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2357 char_u *line;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2358
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2359 buf = get_buffer_arg(prim->name, 1, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2360 linenr = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2361 line = ml_get_buf(buf->buf, (linenr_T)linenr, FALSE);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2362
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2363 raise_if_error();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2364 return scheme_make_byte_string((char *)line);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2365 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2366
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2367
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2368 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2369 * (get-buff-line-list {start} {end} [buffer])
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2370 *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2371 * Get a list of lines from the specified buffer. The line numbers
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2372 * are in Vim format (1-based). The range is from lo up to, but not
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2373 * including, hi. The list is returned as a list of string objects.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2374 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2375 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2376 get_buffer_line_list(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2377 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2378 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2379 vim_mz_buffer *buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2380 int i, hi, lo, n;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2381 Scheme_Object *list = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2382
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2383 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2384 MZ_GC_VAR_IN_REG(0, list);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2385 MZ_GC_REG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2386
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2387 buf = get_buffer_arg(prim->name, 2, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2388 list = scheme_null;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2389 hi = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 1));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2390 lo = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2391
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2392 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2393 * Handle some error conditions
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2394 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2395 if (lo < 0)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 800
diff changeset
2396 lo = 0;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2397
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2398 if (hi < 0)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2399 hi = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2400 if (hi < lo)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 800
diff changeset
2401 hi = lo;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2402
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2403 n = hi - lo;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2404
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2405 for (i = n; i >= 0; --i)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2406 {
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2407 Scheme_Object *str = scheme_make_byte_string(
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2408 (char *)ml_get_buf(buf->buf, (linenr_T)(lo+i), FALSE));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2409 raise_if_error();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2412 list = scheme_make_pair(str, list);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2413 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2414 }
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2415 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2416 return list;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2417 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2418
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2419 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2420 * (set-buff-line {linenr} {string/#f} [buffer])
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2421 *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2422 * Replace a line in the specified buffer. The line number is
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2423 * in Vim format (1-based). The replacement line is given as
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2424 * an MzScheme string object. The object is checked for validity
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2425 * and correct format. An exception is thrown if the values are not
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2426 * the correct format.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2427 *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2428 * It returns a Scheme Object that indicates the length of the
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2429 * string changed.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2430 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2431 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2432 set_buffer_line(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2439 Vim_Prim *prim = (Vim_Prim *)data;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2440 vim_mz_buffer *buf;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2441 Scheme_Object *line = NULL;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2442 char *save;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2443 int n;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2444
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2445 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2446 MZ_GC_VAR_IN_REG(0, line);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2447 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2448
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2449 #ifdef HAVE_SANDBOX
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2450 sandbox_check();
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2451 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2452 n = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2453 if (!SCHEME_STRINGP(argv[1]) && !SCHEME_FALSEP(argv[1]))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 800
diff changeset
2454 scheme_wrong_type(prim->name, "string or #f", 1, argc, argv);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2455 line = argv[1];
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2456 buf = get_buffer_arg(prim->name, 2, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2457
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2458 check_line_range(n, buf->buf);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2459
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2460 if (SCHEME_FALSEP(line))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2461 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2462 buf_T *savebuf = curbuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2463
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2464 curbuf = buf->buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2465
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2466 if (u_savedel((linenr_T)n, 1L) == FAIL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2467 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2468 curbuf = savebuf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2469 raise_vim_exn(_("cannot save undo information"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2470 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2471 else if (ml_delete((linenr_T)n, FALSE) == FAIL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2472 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2473 curbuf = savebuf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2474 raise_vim_exn(_("cannot delete line"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2475 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2476 if (buf->buf == curwin->w_buffer)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2477 mz_fix_cursor(n, n + 1, -1);
1929
9230c45fdde6 updated for version 7.2-226
vimboss
parents: 1919
diff changeset
2478 deleted_lines_mark((linenr_T)n, 1L);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2479
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2480 curbuf = savebuf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2481
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2482 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2483 raise_if_error();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2484 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2485 }
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2486 else
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2489 buf_T *savebuf = curbuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2490
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2491 save = string_to_line(line);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2492
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2493 curbuf = buf->buf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2494
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2495 if (u_savesub((linenr_T)n) == FAIL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2496 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2497 curbuf = savebuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2498 vim_free(save);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2499 raise_vim_exn(_("cannot save undo information"));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2500 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2501 else if (ml_replace((linenr_T)n, (char_u *)save, TRUE) == FAIL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2502 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2503 curbuf = savebuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2504 vim_free(save);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2505 raise_vim_exn(_("cannot replace line"));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2506 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2507 else
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2508 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2509 vim_free(save);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2510 changed_bytes((linenr_T)n, 0);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2511 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2512
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2513 curbuf = savebuf;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2516 if (buf->buf == curwin->w_buffer)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2517 check_cursor_col();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2518
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2519 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2520 raise_if_error();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2521 return scheme_void;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2522 }
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2523 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2524
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2525 static void
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2526 free_array(char **array)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2527 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2528 char **curr = array;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2529 while (*curr != NULL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2530 vim_free(*curr++);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2531 vim_free(array);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2532 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2533
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2534 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2535 * (set-buff-line-list {start} {end} {string-list/#f/null} [buffer])
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2536 *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2537 * Replace a range of lines in the specified buffer. The line numbers are in
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2538 * Vim format (1-based). The range is from lo up to, but not including, hi.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2539 * The replacement lines are given as a Scheme list of string objects. The
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2540 * list is checked for validity and correct format.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2541 *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2542 * Errors are returned as a value of FAIL. The return value is OK on success.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2543 * If OK is returned and len_change is not NULL, *len_change is set to the
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2544 * change in the buffer length.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2545 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2546 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2547 set_buffer_line_list(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2554 Vim_Prim *prim = (Vim_Prim *)data;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2555 vim_mz_buffer *buf = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2556 Scheme_Object *line_list = NULL;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2557 int i, old_len, new_len, hi, lo;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2558 long extra;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2559
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2560 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2561 MZ_GC_VAR_IN_REG(0, line_list);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2562 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2563
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2564 #ifdef HAVE_SANDBOX
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2565 sandbox_check();
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2566 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2567 lo = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2568 hi = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 1));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2569 if (!SCHEME_PAIRP(argv[2])
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2570 && !SCHEME_FALSEP(argv[2]) && !SCHEME_NULLP(argv[2]))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2571 scheme_wrong_type(prim->name, "list or #f", 2, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2572 line_list = argv[2];
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2573 buf = get_buffer_arg(prim->name, 3, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2576 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2577 i = lo;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2578 lo = hi;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2579 hi = i;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2580 old_len = -old_len;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2581 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2582 extra = 0;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2586
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2587 if (SCHEME_FALSEP(line_list) || SCHEME_NULLP(line_list))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2588 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2589 buf_T *savebuf = curbuf;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2590 curbuf = buf->buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2591
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2592 if (u_savedel((linenr_T)lo, (long)old_len) == FAIL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2593 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2594 curbuf = savebuf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2595 raise_vim_exn(_("cannot save undo information"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2596 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2597 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2598 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2599 for (i = 0; i < old_len; i++)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2600 if (ml_delete((linenr_T)lo, FALSE) == FAIL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2601 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2602 curbuf = savebuf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2603 raise_vim_exn(_("cannot delete line"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2604 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2605 if (buf->buf == curwin->w_buffer)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2606 mz_fix_cursor(lo, hi, -old_len);
1929
9230c45fdde6 updated for version 7.2-226
vimboss
parents: 1919
diff changeset
2607 deleted_lines_mark((linenr_T)lo, (long)old_len);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2608 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2609
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2610 curbuf = savebuf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2611
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2612 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2613 raise_if_error();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2614 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2615 }
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2616 else
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2617 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2618 buf_T *savebuf = curbuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2619
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2620 // List
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2621 new_len = scheme_proper_list_length(line_list);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2624 scheme_wrong_type(prim->name, "proper list",
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2625 2, argc, argv);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2626 else
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2627 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2628 char **array = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2629 Scheme_Object *line = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2630 Scheme_Object *rest = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2631
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2632 MZ_GC_DECL_REG(2);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2633 MZ_GC_VAR_IN_REG(0, line);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2634 MZ_GC_VAR_IN_REG(1, rest);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2635 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2638
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2639 rest = line_list;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2640 for (i = 0; i < new_len; ++i)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2641 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2642 line = SCHEME_CAR(rest);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2643 rest = SCHEME_CDR(rest);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2644 if (!SCHEME_STRINGP(line))
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2645 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2646 free_array(array);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2647 scheme_wrong_type(prim->name, "string-list", 2, argc, argv);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2648 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2649 array[i] = string_to_line(line);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2650 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2651
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2652 curbuf = buf->buf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2653
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2654 if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2655 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2656 curbuf = savebuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2657 free_array(array);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2658 raise_vim_exn(_("cannot save undo information"));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2659 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2660
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2661 /*
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2662 * If the size of the range is reducing (ie, new_len < old_len) we
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2663 * need to delete some old_len. We do this at the start, by
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2664 * repeatedly deleting line "lo".
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2665 */
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2666 for (i = 0; i < old_len - new_len; ++i)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2667 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2668 if (ml_delete((linenr_T)lo, FALSE) == FAIL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2669 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2670 curbuf = savebuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2671 free_array(array);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2672 raise_vim_exn(_("cannot delete line"));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2673 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2674 extra--;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2675 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2676
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2677 /*
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2678 * For as long as possible, replace the existing old_len with the
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2679 * new old_len. This is a more efficient operation, as it requires
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2680 * less memory allocation and freeing.
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2681 */
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2682 for (i = 0; i < old_len && i < new_len; i++)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2683 if (ml_replace((linenr_T)(lo+i), (char_u *)array[i], TRUE) == FAIL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2684 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2685 curbuf = savebuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2686 free_array(array);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2687 raise_vim_exn(_("cannot replace line"));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2688 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2689
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2690 /*
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2691 * Now we may need to insert the remaining new_len. We don't need to
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2692 * free the string passed back because MzScheme has control of that
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2693 * memory.
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2694 */
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2695 while (i < new_len)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2696 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2697 if (ml_append((linenr_T)(lo + i - 1),
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2698 (char_u *)array[i], 0, FALSE) == FAIL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2699 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2700 curbuf = savebuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2701 free_array(array);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2702 raise_vim_exn(_("cannot insert line"));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2703 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2704 ++i;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2705 ++extra;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2706 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2707 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2708 free_array(array);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2709 }
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2710
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2711 /*
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2712 * Adjust marks. Invalidate any which lie in the
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2713 * changed range, and move any in the remainder of the buffer.
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2717 changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2718
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2719 if (buf->buf == curwin->w_buffer)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2720 mz_fix_cursor(lo, hi, extra);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2721 curbuf = savebuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2722
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2723 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2724 raise_if_error();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2725 return scheme_void;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2726 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2727 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2728
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2729 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2730 * (insert-buff-line-list {linenr} {string/string-list} [buffer])
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2731 *
2023
db3ca1048f7f updated for version 7.2-320
vimboss
parents: 1950
diff changeset
2732 * Insert a number of lines into the specified buffer after the specified line.
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2733 * The line number is in Vim format (1-based). The lines to be inserted are
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2734 * given as an MzScheme list of string objects or as a single string. The lines
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2735 * to be added are checked for validity and correct format. Errors are
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2736 * returned as a value of FAIL. The return value is OK on success.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2737 * If OK is returned and len_change is not NULL, *len_change
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2738 * is set to the change in the buffer length.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2739 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2740 static Scheme_Object *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2741 insert_buffer_line_list(void *data, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2742 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2743 Vim_Prim *prim = (Vim_Prim *)data;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2744 vim_mz_buffer *buf = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2745 Scheme_Object *list = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2746 char *str = NULL;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2747 int i, n, size;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2748
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2749 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2750 MZ_GC_VAR_IN_REG(0, list);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2751 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2752
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2753 #ifdef HAVE_SANDBOX
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2754 sandbox_check();
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
2755 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2756 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2757 * First of all, we check the type of the supplied MzScheme object.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2758 * It must be a string or a list, or the call is in error.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2759 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2760 n = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2761 list = argv[1];
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2762
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2763 if (!SCHEME_STRINGP(list) && !SCHEME_PAIRP(list))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2764 scheme_wrong_type(prim->name, "string or list", 1, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2765 buf = get_buffer_arg(prim->name, 2, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
8cd729851562 updated for version 7.0g
vimboss
parents: 800
diff changeset
2768 check_line_range(n, buf->buf);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2769 if (SCHEME_STRINGP(list))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2770 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2771 buf_T *savebuf = curbuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2772
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2773 str = string_to_line(list);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2774 curbuf = buf->buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2775
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2776 if (u_save((linenr_T)n, (linenr_T)(n+1)) == FAIL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2777 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2778 curbuf = savebuf;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2779 vim_free(str);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2780 raise_vim_exn(_("cannot save undo information"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2781 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2782 else if (ml_append((linenr_T)n, (char_u *)str, 0, FALSE) == FAIL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2783 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2784 curbuf = savebuf;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2785 vim_free(str);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2786 raise_vim_exn(_("cannot insert line"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2787 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2788 else
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2789 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2790 vim_free(str);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2791 appended_lines_mark((linenr_T)n, 1L);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2792 }
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2793
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2794 curbuf = savebuf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2795 update_screen(VALID);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2796
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2797 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2798 raise_if_error();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2799 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2800 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2801
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2802 // List
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2803 size = scheme_proper_list_length(list);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2806 scheme_wrong_type(prim->name, "proper list",
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2807 2, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2808 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2809 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2810 Scheme_Object *line = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2811 Scheme_Object *rest = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2812 char **array;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2813 buf_T *savebuf = curbuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2814
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2815 MZ_GC_DECL_REG(2);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2816 MZ_GC_VAR_IN_REG(0, line);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2817 MZ_GC_VAR_IN_REG(1, rest);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2818 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2821
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2822 rest = list;
856
8cd729851562 updated for version 7.0g
vimboss
parents: 800
diff changeset
2823 for (i = 0; i < size; ++i)
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2824 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2825 line = SCHEME_CAR(rest);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2826 rest = SCHEME_CDR(rest);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2827 array[i] = string_to_line(line);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2828 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2829
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2830 curbuf = buf->buf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2831
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2832 if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2833 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2834 curbuf = savebuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2835 free_array(array);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2836 raise_vim_exn(_("cannot save undo information"));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2837 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2838 else
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2839 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2840 for (i = 0; i < size; ++i)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2841 if (ml_append((linenr_T)(n + i), (char_u *)array[i],
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2842 0, FALSE) == FAIL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2843 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2844 curbuf = savebuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2845 free_array(array);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2846 raise_vim_exn(_("cannot insert line"));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2847 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2848
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2849 if (i > 0)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2850 appended_lines_mark((linenr_T)n, (long)i);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2851 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2852 free_array(array);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2853 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2854 curbuf = savebuf;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2855 update_screen(VALID);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2856 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2857
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2858 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2859 raise_if_error();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2860 return scheme_void;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2861 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2862
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2863 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2864 * Predicates
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2871 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2872 if (SCHEME_VIMBUFFERP(argv[0]))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2873 return scheme_true;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2874 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2875 return scheme_false;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2876 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2883 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2884 if (SCHEME_VIMWINDOWP(argv[0]))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2885 return scheme_true;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2886 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2887 return scheme_false;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2888 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2895 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2896 if (SCHEME_VIMBUFFERP(argv[0])
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2897 && ((vim_mz_buffer *)argv[0])->buf != INVALID_BUFFER_VALUE)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2898 return scheme_true;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2899 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2900 return scheme_false;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2901 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2908 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2909 if (SCHEME_VIMWINDOWP(argv[0])
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2910 && ((vim_mz_window *)argv[0])->win != INVALID_WINDOW_VALUE)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2911 return scheme_true;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2912 else
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2913 return scheme_false;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2914 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2915
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2916 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2917 *===========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2918 * Utilities
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2919 *===========================================================================
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2920 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2921
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2922 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2923 * Convert an MzScheme string into a Vim line.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2924 *
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2925 * All internal nulls are replaced by newline characters.
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2926 * It is an error for the string to contain newline characters.
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2927 *
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2928 * Returns pointer to Vim allocated memory
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2929 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2930 static char *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2931 string_to_line(Scheme_Object *obj)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2932 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2933 char *scheme_str = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2934 char *vim_str = NULL;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2935 OUTPUT_LEN_TYPE len;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2936 int i;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2937
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2938 scheme_str = scheme_display_to_string(obj, &len);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2943 if (memchr(scheme_str, '\n', len))
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2944 scheme_signal_error(_("string cannot contain newlines"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2950 for (i = 0; i < len; ++i)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
2951 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2952 if (scheme_str[i] == '\0')
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2953 vim_str[i] = '\n';
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2954 else
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2955 vim_str[i] = scheme_str[i];
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2956 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2957
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2958 vim_str[i] = '\0';
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2959
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2960 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2961 return vim_str;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2962 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2963
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2964 #ifdef FEAT_EVAL
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2965 /*
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2966 * Convert Vim value into MzScheme, adopted from if_python.c
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2967 */
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2968 static Scheme_Object *
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2969 vim_to_mzscheme(typval_T *vim_value)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2970 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2973 Scheme_Hash_Table *visited = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2974
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2975 MZ_GC_DECL_REG(2);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2976 MZ_GC_VAR_IN_REG(0, result);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2977 MZ_GC_VAR_IN_REG(1, visited);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2978 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2979
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2980 visited = scheme_make_hash_table(SCHEME_hash_ptr);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2981 MZ_GC_CHECK();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2982
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2983 result = vim_to_mzscheme_impl(vim_value, 1, visited);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2984
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2985 MZ_GC_UNREG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2986 return result;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2987 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2988
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2989 static Scheme_Object *
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2990 vim_to_mzscheme_impl(typval_T *vim_value, int depth, Scheme_Hash_Table *visited)
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2991 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2992 Scheme_Object *result = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2993 int new_value = TRUE;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2994
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2995 MZ_GC_DECL_REG(2);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2996 MZ_GC_VAR_IN_REG(0, result);
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
2997 MZ_GC_VAR_IN_REG(1, visited);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
2998 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3001 if (depth > 100)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3002 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3003 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3004 return scheme_void;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3005 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3009 result = scheme_hash_get(visited, (Scheme_Object *)vim_value);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3012 new_value = FALSE;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3013 else if (vim_value->v_type == VAR_STRING)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3014 {
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3015 result = scheme_make_byte_string((char *)vim_value->vval.v_string);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3016 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3017 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3018 else if (vim_value->v_type == VAR_NUMBER)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3019 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3020 result = scheme_make_integer((long)vim_value->vval.v_number);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3021 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3022 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3023 # ifdef FEAT_FLOAT
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3024 else if (vim_value->v_type == VAR_FLOAT)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3025 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3026 result = scheme_make_double((double)vim_value->vval.v_float);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3027 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3028 }
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3029 # endif
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3030 else if (vim_value->v_type == VAR_LIST)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3031 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3032 list_T *list = vim_value->vval.v_list;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3033 listitem_T *curr;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3034
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3035 if (list == NULL || list->lv_first == NULL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3036 result = scheme_null;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3037 else
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3038 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3039 Scheme_Object *obj = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3040
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3041 MZ_GC_DECL_REG(1);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3042 MZ_GC_VAR_IN_REG(0, obj);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3043 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3046 obj = vim_to_mzscheme_impl(&curr->li_tv, depth + 1, visited);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3047 result = scheme_make_pair(obj, scheme_null);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3048 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3049
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3050 while (curr != list->lv_first)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3051 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3052 curr = curr->li_prev;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3053 obj = vim_to_mzscheme_impl(&curr->li_tv, depth + 1, visited);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3054 result = scheme_make_pair(obj, result);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3055 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3056 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3057 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3058 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3059 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3060 else if (vim_value->v_type == VAR_DICT)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3061 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3062 Scheme_Object *key = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3063 Scheme_Object *obj = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3064
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3065 MZ_GC_DECL_REG(2);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3066 MZ_GC_VAR_IN_REG(0, key);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3067 MZ_GC_VAR_IN_REG(1, obj);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3068 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3069
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3070 result = (Scheme_Object *)scheme_make_hash_table(SCHEME_hash_ptr);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3071 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3072 if (vim_value->vval.v_dict != NULL)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3073 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3074 hashtab_T *ht = &vim_value->vval.v_dict->dv_hashtab;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3075 long_u todo = ht->ht_used;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3076 hashitem_T *hi;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3077 dictitem_T *di;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3078
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3079 for (hi = ht->ht_array; todo > 0; ++hi)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3080 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3081 if (!HASHITEM_EMPTY(hi))
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3082 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3083 --todo;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3084
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3085 di = dict_lookup(hi);
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3086 obj = vim_to_mzscheme_impl(&di->di_tv, depth + 1, visited);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3087 key = scheme_make_byte_string((char *)hi->hi_key);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3088 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3089 scheme_hash_set((Scheme_Hash_Table *)result, key, obj);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3090 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3091 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3092 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3093 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3094 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3095 }
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3096 else if (vim_value->v_type == VAR_FUNC)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3097 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3098 Scheme_Object *funcname = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3099
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3100 MZ_GC_DECL_REG(1);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3101 MZ_GC_VAR_IN_REG(0, funcname);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3102 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3105 funcname = scheme_make_byte_string((char *)vim_value->vval.v_string);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3106 MZ_GC_CHECK();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3107 result = scheme_make_closed_prim_w_arity(vim_funcref, funcname,
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3108 (const char *)BYTE_STRING_VALUE(funcname), 0, -1);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3109 MZ_GC_CHECK();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3110
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3111 MZ_GC_UNREG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3145 else
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3146 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3147 result = scheme_void;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3148 new_value = FALSE;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3149 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3150 if (new_value)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3151 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3152 scheme_hash_set(visited, (Scheme_Object *)vim_value, result);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3153 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3154 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3155 MZ_GC_UNREG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3156 return result;
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3160 mzscheme_to_vim(Scheme_Object *obj, typval_T *tv)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3161 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3162 int i, status;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3163 Scheme_Hash_Table *visited = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3164
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3165 MZ_GC_DECL_REG(2);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3166 MZ_GC_VAR_IN_REG(0, obj);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3167 MZ_GC_VAR_IN_REG(1, visited);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3168 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3169
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3170 visited = scheme_make_hash_table(SCHEME_hash_ptr);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3171 MZ_GC_CHECK();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3172
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3173 status = mzscheme_to_vim_impl(obj, tv, 1, visited);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3174 for (i = 0; i < visited->size; ++i)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3177 if (visited->vals[i] != NULL)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3178 free_tv((typval_T *)visited->vals[i]);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3179 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3180
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3181 MZ_GC_UNREG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3182 return status;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3183 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3184 static int
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3190
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3191 MZ_GC_DECL_REG(2);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3192 MZ_GC_VAR_IN_REG(0, obj);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3193 MZ_GC_VAR_IN_REG(1, visited);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3194 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3234 # if MZSCHEME_VERSION_MAJOR >= 299
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3235 else if (SCHEME_CHAR_STRINGP(obj))
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3236 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3237 Scheme_Object *tmp = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3238 MZ_GC_DECL_REG(1);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3239 MZ_GC_VAR_IN_REG(0, tmp);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3240 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3241
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3242 tmp = scheme_char_string_to_byte_string(obj);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3243 tv->v_type = VAR_STRING;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3244 tv->vval.v_string = vim_strsave(BYTE_STRING_VALUE(tmp));
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3245 MZ_GC_UNREG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3246 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3390 static Scheme_Object *
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3391 vim_funcref(void *name, int argc, Scheme_Object **argv)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3392 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3393 int i;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3394 typval_T args;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3395 int status = OK;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3396 Scheme_Object *result = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3397 list_T *list = list_alloc();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3398
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3399 MZ_GC_DECL_REG(1);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3400 MZ_GC_VAR_IN_REG(0, result);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3401 MZ_GC_REG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3402
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3403 result = scheme_void;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3404 if (list == NULL)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3405 status = FAIL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3406 else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3407 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3408 args.v_type = VAR_LIST;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3409 args.vval.v_list = list;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3410 ++list->lv_refcount;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3411 for (i = 0; status == OK && i < argc; ++i)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3414 if (v == NULL)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3415 status = FAIL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3416 else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3417 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3418 status = mzscheme_to_vim(argv[i], v);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3419 if (status == OK)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3420 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3421 status = list_append_tv(list, v);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3422 clear_tv(v);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3423 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3424 vim_free(v);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3425 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3426 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3427 if (status == OK)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3428 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3429 typval_T ret;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3430 ret.v_type = VAR_UNKNOWN;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3431
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3432 mzscheme_call_vim(BYTE_STRING_VALUE((Scheme_Object *)name), &args, &ret);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3433 MZ_GC_CHECK();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3434 result = vim_to_mzscheme(&ret);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3435 clear_tv(&ret);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3436 MZ_GC_CHECK();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3437 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3438 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3439 clear_tv(&args);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3440 MZ_GC_UNREG();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3441 if (status != OK)
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3442 raise_vim_exn(_("error converting Scheme values to Vim"));
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3443 else
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3444 raise_if_error();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3445 return result;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3446 }
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3452
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3469 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3470
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3471 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3472 * Check to see whether a Vim error has been reported, or a keyboard
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3473 * interrupt (from vim --> got_int) has been detected.
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3474 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3475 static int
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3476 vim_error_check(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3477 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3478 return (got_int || did_emsg);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3479 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3480
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3481 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3482 * register Scheme exn:vim
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3483 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3484 static void
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3485 register_vim_exn(void)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3486 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3487 int nc = 0;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3488 int i;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3489 Scheme_Object *struct_exn = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3490 Scheme_Object *exn_name = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3491
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3492 MZ_GC_DECL_REG(2);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3493 MZ_GC_VAR_IN_REG(0, struct_exn);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3494 MZ_GC_VAR_IN_REG(1, exn_name);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3495 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3496
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3497 exn_name = scheme_intern_symbol("exn:vim");
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3498 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3499 struct_exn = scheme_builtin_value("struct:exn");
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3500 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3501
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3502 if (vim_exn == NULL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3503 vim_exn = scheme_make_struct_type(exn_name,
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3504 struct_exn, NULL, 0, 0, NULL, NULL
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3505 #if MZSCHEME_VERSION_MAJOR >= 299
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3506 , NULL
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3507 #endif
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3508 );
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3509
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3510
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3511 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3512 Scheme_Object **tmp = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3513 Scheme_Object *exn_names[5] = {NULL, NULL, NULL, NULL, NULL};
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3514 Scheme_Object *exn_values[5] = {NULL, NULL, NULL, NULL, NULL};
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3515 MZ_GC_DECL_REG(6);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3516 MZ_GC_ARRAY_VAR_IN_REG(0, exn_names, 5);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3517 MZ_GC_ARRAY_VAR_IN_REG(3, exn_values, 5);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3518 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3519
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3520 tmp = scheme_make_struct_names(exn_name, scheme_null, 0, &nc);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3521 mch_memmove(exn_names, tmp, nc * sizeof(Scheme_Object *));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3522 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3523
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3524 tmp = scheme_make_struct_values(vim_exn, exn_names, nc, 0);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3525 mch_memmove(exn_values, tmp, nc * sizeof(Scheme_Object *));
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3526 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3527
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3528 for (i = 0; i < nc; i++)
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3529 {
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3530 scheme_add_global_symbol(exn_names[i],
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3531 exn_values[i], environment);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3532 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3533 }
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3534 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3535 }
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3536 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3537 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3538
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3539 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3540 * raise exn:vim, may be with additional info string
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3541 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3542 void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3543 raise_vim_exn(const char *add_info)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3544 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3545 char *fmt = _("Vim error: ~a");
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3546 Scheme_Object *argv[2] = {NULL, NULL};
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3547 Scheme_Object *exn = NULL;
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3548 Scheme_Object *byte_string = NULL;
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3549
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3550 MZ_GC_DECL_REG(5);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3551 MZ_GC_ARRAY_VAR_IN_REG(0, argv, 2);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3552 MZ_GC_VAR_IN_REG(3, exn);
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3553 MZ_GC_VAR_IN_REG(4, byte_string);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3554 MZ_GC_REG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3555
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3556 if (add_info != NULL)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3557 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3558 char *c_string = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3559 Scheme_Object *info = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3560
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3561 MZ_GC_DECL_REG(3);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3562 MZ_GC_VAR_IN_REG(0, c_string);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3563 MZ_GC_VAR_IN_REG(2, info);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3564 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3565
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3566 info = scheme_make_byte_string(add_info);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3569 MZ_GC_CHECK();
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3570 byte_string = scheme_make_byte_string(c_string);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3571 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3572 argv[0] = scheme_byte_string_to_char_string(byte_string);
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3573 SCHEME_SET_IMMUTABLE(argv[0]);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3574 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3575 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3576 else
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3577 {
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3578 byte_string = scheme_make_byte_string(_("Vim error"));
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3579 MZ_GC_CHECK();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3580 argv[0] = scheme_byte_string_to_char_string(byte_string);
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3581 MZ_GC_CHECK();
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3582 }
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3583 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3584
1284
30f057789239 updated for version 7.1
vimboss
parents: 1228
diff changeset
3585 #if MZSCHEME_VERSION_MAJOR < 360
30f057789239 updated for version 7.1
vimboss
parents: 1228
diff changeset
3586 argv[1] = scheme_current_continuation_marks();
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3587 MZ_GC_CHECK();
1284
30f057789239 updated for version 7.1
vimboss
parents: 1228
diff changeset
3588 #else
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 856
diff changeset
3589 argv[1] = scheme_current_continuation_marks(NULL);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3590 MZ_GC_CHECK();
1284
30f057789239 updated for version 7.1
vimboss
parents: 1228
diff changeset
3591 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3592
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3593 exn = scheme_make_struct_instance(vim_exn, 2, argv);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3594 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3595 scheme_raise(exn);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3596 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3597 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3598
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3599 void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3600 raise_if_error(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3601 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3602 if (vim_error_check())
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3603 raise_vim_exn(NULL);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3604 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3608 * either current
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3609 * or passed as argv[argnum] with checks
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3610 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3611 static vim_mz_buffer *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3612 get_buffer_arg(const char *fname, int argnum, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3613 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3614 vim_mz_buffer *b;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3615
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3616 if (argc < argnum + 1)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3617 return get_vim_curr_buffer();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3618 if (!SCHEME_VIMBUFFERP(argv[argnum]))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3619 scheme_wrong_type(fname, "vim-buffer", argnum, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3620 b = (vim_mz_buffer *)argv[argnum];
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3621 (void)get_valid_buffer(argv[argnum]);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3622 return b;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3623 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3627 * either current
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3628 * or passed as argv[argnum] with checks
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3629 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3630 static vim_mz_window *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3631 get_window_arg(const char *fname, int argnum, int argc, Scheme_Object **argv)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3632 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3633 vim_mz_window *w;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3634
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3635 if (argc < argnum + 1)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3636 return get_vim_curr_window();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3637 w = (vim_mz_window *)argv[argnum];
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3638 if (!SCHEME_VIMWINDOWP(argv[argnum]))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3639 scheme_wrong_type(fname, "vim-window", argnum, argc, argv);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3640 (void)get_valid_window(argv[argnum]);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3641 return w;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3642 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3647 buf_T *get_valid_buffer(void *obj)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3648 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3649 buf_T *buf = ((vim_mz_buffer *)obj)->buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3650
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3651 if (buf == INVALID_BUFFER_VALUE)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3652 scheme_signal_error(_("buffer is invalid"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3653 return buf;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3654 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3659 win_T *get_valid_window(void *obj)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3660 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3661 win_T *win = ((vim_mz_window *)obj)->win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3662 if (win == INVALID_WINDOW_VALUE)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3663 scheme_signal_error(_("window is invalid"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3664 return win;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3665 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3666
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3667 int
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3668 mzthreads_allowed(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3669 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3670 return mz_threads_allow;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3671 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3672
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3673 static int
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3674 line_in_range(linenr_T lnum, buf_T *buf)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3675 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3676 return (lnum > 0 && lnum <= buf->b_ml.ml_line_count);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3677 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3678
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3679 static void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3680 check_line_range(linenr_T lnum, buf_T *buf)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3681 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3682 if (!line_in_range(lnum, buf))
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3683 scheme_signal_error(_("linenr out of range"));
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3684 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3685
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3686 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3687 * Check if deleting lines made the cursor position invalid
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3688 * (or you'll get msg from Vim about invalid linenr).
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3689 * Changed the lines from "lo" to "hi" and added "extra" lines (negative if
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3690 * deleted). Got from if_python.c
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3691 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3692 static void
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3693 mz_fix_cursor(int lo, int hi, int extra)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3694 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3695 if (curwin->w_cursor.lnum >= lo)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3699 if (curwin->w_cursor.lnum >= hi)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3700 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3701 curwin->w_cursor.lnum += extra;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3702 check_cursor_col();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3703 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3704 else if (extra < 0)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3705 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3706 curwin->w_cursor.lnum = lo;
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3707 check_cursor();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3708 }
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3709 else
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3710 check_cursor_col();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3711 changed_cline_bef_curs();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3712 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3713 invalidate_botline();
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3714 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3715
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3716 static Vim_Prim prims[]=
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3717 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3718 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3719 * Buffer-related commands
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3720 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3721 {get_buffer_line, "get-buff-line", 1, 2},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3722 {set_buffer_line, "set-buff-line", 2, 3},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3723 {get_buffer_line_list, "get-buff-line-list", 2, 3},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3724 {get_buffer_name, "get-buff-name", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3725 {get_buffer_num, "get-buff-num", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3726 {get_buffer_size, "get-buff-size", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3727 {set_buffer_line_list, "set-buff-line-list", 3, 4},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3728 {insert_buffer_line_list, "insert-buff-line-list", 2, 3},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3729 {get_curr_buffer, "curr-buff", 0, 0},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3730 {get_buffer_count, "buff-count", 0, 0},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3731 {get_next_buffer, "get-next-buff", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3732 {get_prev_buffer, "get-prev-buff", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3733 {mzscheme_open_buffer, "open-buff", 1, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3734 {get_buffer_by_name, "get-buff-by-name", 1, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3735 {get_buffer_by_num, "get-buff-by-num", 1, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3736 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3737 * Window-related commands
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3738 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3739 {get_curr_win, "curr-win", 0, 0},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3740 {get_window_count, "win-count", 0, 0},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3741 {get_window_by_num, "get-win-by-num", 1, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3742 {get_window_num, "get-win-num", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3743 {get_window_buffer, "get-win-buffer", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3744 {get_window_height, "get-win-height", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3745 {set_window_height, "set-win-height", 1, 2},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3746 {get_window_width, "get-win-width", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3747 {set_window_width, "set-win-width", 1, 2},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3748 {get_cursor, "get-cursor", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3749 {set_cursor, "set-cursor", 1, 2},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3750 {get_window_list, "get-win-list", 0, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3751 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3752 * Vim-related commands
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3753 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3754 {vim_command, "command", 1, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3755 {vim_eval, "eval", 1, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3756 {get_range_start, "range-start", 0, 0},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3757 {get_range_end, "range-end", 0, 0},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3758 {mzscheme_beep, "beep", 0, 0},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3759 {get_option, "get-option", 1, 2},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3760 {set_option, "set-option", 1, 2},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3761 /*
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3762 * small utilities
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3763 */
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3764 {vim_bufferp, "buff?", 1, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3765 {vim_windowp, "win?", 1, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3766 {vim_buffer_validp, "buff-valid?", 1, 1},
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3767 {vim_window_validp, "win-valid?", 1, 1}
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3768 };
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3773 static vim_mz_buffer *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3774 get_vim_curr_buffer(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3775 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 344
diff changeset
3776 if (curbuf->b_mzscheme_ref == NULL)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3777 return (vim_mz_buffer *)buffer_new(curbuf);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3778 else
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3779 return BUFFER_REF(curbuf);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3780 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3785 static vim_mz_window *
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3786 get_vim_curr_window(void)
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3787 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 344
diff changeset
3788 if (curwin->w_mzscheme_ref == NULL)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3789 return (vim_mz_window *)window_new(curwin);
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3790 else
4074
16e8a09e8ab0 updated for version 7.3.791
Bram Moolenaar <bram@vim.org>
parents: 3953
diff changeset
3791 return WINDOW_REF(curwin);
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3792 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3793
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
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
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3796 {
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3797 int i;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3798 Scheme_Env *mod = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3799 Scheme_Object *vimext_symbol = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3800 Scheme_Object *closed_prim = NULL;
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3801
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3802 MZ_GC_DECL_REG(3);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3803 MZ_GC_VAR_IN_REG(0, mod);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3804 MZ_GC_VAR_IN_REG(1, vimext_symbol);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3805 MZ_GC_VAR_IN_REG(2, closed_prim);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3806 MZ_GC_REG();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3807
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3808 vimext_symbol = scheme_intern_symbol("vimext");
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3809 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3810 mod = scheme_primitive_module(vimext_symbol, environment);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
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
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3813 for (i = 0; i < (int)(sizeof(prims)/sizeof(prims[0])); i++)
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3814 {
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3815 Vim_Prim *prim = prims + i;
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3816 closed_prim = scheme_make_closed_prim_w_arity(prim->prim, prim, prim->name,
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3817 prim->mina, prim->maxa);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3818 scheme_add_global(prim->name, closed_prim, mod);
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3819 MZ_GC_CHECK();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3820 }
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3821 scheme_finish_primitive_module(mod);
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3822 MZ_GC_CHECK();
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3823 MZ_GC_UNREG();
14
946da5994c01 updated for version 7.0006
vimboss
parents:
diff changeset
3824 }
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 274
diff changeset
3825
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3826 #ifdef HAVE_SANDBOX
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3827 static Scheme_Object *M_write = NULL;
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3828 static Scheme_Object *M_read = NULL;
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3829 static Scheme_Object *M_execute = NULL;
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3830 static Scheme_Object *M_delete = NULL;
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3831
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3832 static void
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 856
diff changeset
3833 sandbox_check(void)
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3834 {
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3835 if (sandbox)
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3836 raise_vim_exn(_("not allowed in the Vim sandbox"));
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3837 }
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
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
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
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
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3844 {
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3845 if (sandbox)
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3846 {
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3847 Scheme_Object *requested_access = argv[2];
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3848
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3849 if (M_write == NULL)
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3850 {
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3851 MZ_REGISTER_STATIC(M_write);
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3852 M_write = scheme_intern_symbol("write");
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3853 MZ_GC_CHECK();
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3854 }
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3855 if (M_read == NULL)
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3856 {
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3857 MZ_REGISTER_STATIC(M_read);
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3858 M_read = scheme_intern_symbol("read");
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3859 MZ_GC_CHECK();
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3860 }
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3861 if (M_execute == NULL)
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3862 {
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3863 MZ_REGISTER_STATIC(M_execute);
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3864 M_execute = scheme_intern_symbol("execute");
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3865 MZ_GC_CHECK();
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3866 }
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3867 if (M_delete == NULL)
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3868 {
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3869 MZ_REGISTER_STATIC(M_delete);
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3870 M_delete = scheme_intern_symbol("delete");
1894
afb740b5dfab updated for version 7.2-191
vimboss
parents: 1884
diff changeset
3871 MZ_GC_CHECK();
274
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3872 }
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3873
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3874 while (!SCHEME_NULLP(requested_access))
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3875 {
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3876 Scheme_Object *item = SCHEME_CAR(requested_access);
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3877 if (scheme_eq(item, M_write) || scheme_eq(item, M_read)
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3878 || scheme_eq(item, M_execute) || scheme_eq(item, M_delete))
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3879 raise_vim_exn(_("not allowed in the Vim sandbox"));
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3880 requested_access = SCHEME_CDR(requested_access);
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3881 }
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3882 }
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3883 return scheme_void;
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3884 }
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3885
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
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
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3888 {
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3889 return scheme_void;
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3890 }
8fa8d7964cf1 updated for version 7.0073
vimboss
parents: 151
diff changeset
3891 #endif
800
d8f905020502 updated for version 7.0b
vimboss
parents: 714
diff changeset
3892
d8f905020502 updated for version 7.0b
vimboss
parents: 714
diff changeset
3893 #endif