Commit | Line | Data |
---|---|---|
dbb605f5 | 1 | /* Copyright (C) 1995,1996,1997,1998, 2000, 2001, 2006, 2008 Free Software Foundation, Inc. |
ee2a8b9b | 2 | |
73be1d9e MV |
3 | * This library is free software; you can redistribute it and/or |
4 | * modify it under the terms of the GNU Lesser General Public | |
5 | * License as published by the Free Software Foundation; either | |
6 | * version 2.1 of the License, or (at your option) any later version. | |
ee2a8b9b | 7 | * |
73be1d9e MV |
8 | * This library is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | * Lesser General Public License for more details. | |
ee2a8b9b | 12 | * |
73be1d9e MV |
13 | * You should have received a copy of the GNU Lesser General Public |
14 | * License along with this library; if not, write to the Free Software | |
92205699 | 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
73be1d9e | 16 | */ |
ee2a8b9b JB |
17 | \f |
18 | ||
19 | /* routines to evaluate Scheme code */ | |
20 | ||
dbb605f5 LC |
21 | #ifdef HAVE_CONFIG_H |
22 | # include <config.h> | |
23 | #endif | |
24 | ||
a0599745 | 25 | #include "libguile/gh.h" |
ee2a8b9b | 26 | |
5c56ebe1 MV |
27 | #if SCM_ENABLE_DEPRECATED |
28 | ||
ee2a8b9b JB |
29 | typedef SCM (*gh_eval_t) (void *data, SCM jmpbuf); |
30 | ||
ee2a8b9b | 31 | /* Evaluate the string; toss the value. */ |
ee2a8b9b | 32 | SCM |
6e706938 | 33 | gh_eval_str (const char *scheme_code) |
ee2a8b9b | 34 | { |
2dc6875d | 35 | return scm_c_eval_string (scheme_code); |
ee2a8b9b JB |
36 | } |
37 | ||
38 | /* evaluate the file by passing it to the lower level scm_primitive_load() */ | |
39 | SCM | |
6e706938 | 40 | gh_eval_file (const char *fname) |
ee2a8b9b JB |
41 | { |
42 | return scm_primitive_load (gh_str02scm (fname)); | |
43 | } | |
44 | ||
45 | static SCM | |
39752bec | 46 | eval_str_wrapper (void *data) |
ee2a8b9b JB |
47 | { |
48 | /* gh_eval_t real_eval_proc = (gh_eval_t) (* ((gh_eval_t *) data)); */ | |
49 | ||
50 | char *scheme_code = (char *) data; | |
51 | return gh_eval_str (scheme_code); | |
52 | } | |
53 | ||
54 | SCM | |
92c2555f | 55 | gh_eval_str_with_catch (const char *scheme_code, scm_t_catch_handler handler) |
ee2a8b9b JB |
56 | { |
57 | /* FIXME: not there yet */ | |
92c2555f MV |
58 | return gh_catch (SCM_BOOL_T, (scm_t_catch_body) eval_str_wrapper, (void *) scheme_code, |
59 | (scm_t_catch_handler) handler, (void *) scheme_code); | |
ee2a8b9b JB |
60 | } |
61 | ||
62 | SCM | |
6e706938 | 63 | gh_eval_str_with_standard_handler (const char *scheme_code) |
ee2a8b9b JB |
64 | { |
65 | return gh_eval_str_with_catch (scheme_code, gh_standard_handler); | |
66 | } | |
67 | ||
ee2a8b9b | 68 | SCM |
6e706938 | 69 | gh_eval_str_with_stack_saving_handler (const char *scheme_code) |
ee2a8b9b | 70 | { |
95384717 | 71 | return scm_internal_stack_catch (SCM_BOOL_T, |
92c2555f | 72 | (scm_t_catch_body) eval_str_wrapper, |
6e706938 | 73 | (void *) scheme_code, |
92c2555f | 74 | (scm_t_catch_handler) |
95384717 | 75 | gh_standard_handler, |
6e706938 | 76 | (void *) scheme_code); |
ee2a8b9b JB |
77 | } |
78 | ||
79 | static SCM | |
39752bec | 80 | eval_file_wrapper (void *data) |
ee2a8b9b JB |
81 | { |
82 | /* gh_eval_t real_eval_proc = (gh_eval_t) (* ((gh_eval_t *) data)); */ | |
83 | ||
84 | char *scheme_code = (char *) data; | |
85 | return gh_eval_file (scheme_code); | |
86 | } | |
87 | ||
88 | SCM | |
92c2555f | 89 | gh_eval_file_with_catch (const char *scheme_code, scm_t_catch_handler handler) |
ee2a8b9b JB |
90 | { |
91 | /* FIXME: not there yet */ | |
92c2555f MV |
92 | return gh_catch (SCM_BOOL_T, (scm_t_catch_body) eval_file_wrapper, |
93 | (void *) scheme_code, (scm_t_catch_handler) handler, | |
6e706938 | 94 | (void *) scheme_code); |
ee2a8b9b JB |
95 | } |
96 | ||
97 | SCM | |
6e706938 | 98 | gh_eval_file_with_standard_handler (const char *scheme_code) |
ee2a8b9b JB |
99 | { |
100 | return gh_eval_file_with_catch (scheme_code, gh_standard_handler); | |
101 | } | |
89e00824 | 102 | |
5c56ebe1 MV |
103 | #endif /* SCM_ENABLE_DEPRECATED */ |
104 | ||
89e00824 ML |
105 | /* |
106 | Local Variables: | |
107 | c-file-style: "gnu" | |
108 | End: | |
109 | */ |