Commit | Line | Data |
---|---|---|
58ade102 | 1 | /* Copyright (C) 1995,1996,1997,1998, 2000, 2001 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 | |
15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
16 | */ | |
ee2a8b9b JB |
17 | \f |
18 | ||
19 | /* routines to evaluate Scheme code */ | |
20 | ||
a0599745 | 21 | #include "libguile/gh.h" |
ee2a8b9b JB |
22 | |
23 | typedef SCM (*gh_eval_t) (void *data, SCM jmpbuf); | |
24 | ||
ee2a8b9b | 25 | /* Evaluate the string; toss the value. */ |
ee2a8b9b | 26 | SCM |
6e706938 | 27 | gh_eval_str (const char *scheme_code) |
ee2a8b9b | 28 | { |
2dc6875d | 29 | return scm_c_eval_string (scheme_code); |
ee2a8b9b JB |
30 | } |
31 | ||
32 | /* evaluate the file by passing it to the lower level scm_primitive_load() */ | |
33 | SCM | |
6e706938 | 34 | gh_eval_file (const char *fname) |
ee2a8b9b JB |
35 | { |
36 | return scm_primitive_load (gh_str02scm (fname)); | |
37 | } | |
38 | ||
39 | static SCM | |
39752bec | 40 | eval_str_wrapper (void *data) |
ee2a8b9b JB |
41 | { |
42 | /* gh_eval_t real_eval_proc = (gh_eval_t) (* ((gh_eval_t *) data)); */ | |
43 | ||
44 | char *scheme_code = (char *) data; | |
45 | return gh_eval_str (scheme_code); | |
46 | } | |
47 | ||
48 | SCM | |
92c2555f | 49 | gh_eval_str_with_catch (const char *scheme_code, scm_t_catch_handler handler) |
ee2a8b9b JB |
50 | { |
51 | /* FIXME: not there yet */ | |
92c2555f MV |
52 | return gh_catch (SCM_BOOL_T, (scm_t_catch_body) eval_str_wrapper, (void *) scheme_code, |
53 | (scm_t_catch_handler) handler, (void *) scheme_code); | |
ee2a8b9b JB |
54 | } |
55 | ||
56 | SCM | |
6e706938 | 57 | gh_eval_str_with_standard_handler (const char *scheme_code) |
ee2a8b9b JB |
58 | { |
59 | return gh_eval_str_with_catch (scheme_code, gh_standard_handler); | |
60 | } | |
61 | ||
ee2a8b9b | 62 | SCM |
6e706938 | 63 | gh_eval_str_with_stack_saving_handler (const char *scheme_code) |
ee2a8b9b | 64 | { |
95384717 | 65 | return scm_internal_stack_catch (SCM_BOOL_T, |
92c2555f | 66 | (scm_t_catch_body) eval_str_wrapper, |
6e706938 | 67 | (void *) scheme_code, |
92c2555f | 68 | (scm_t_catch_handler) |
95384717 | 69 | gh_standard_handler, |
6e706938 | 70 | (void *) scheme_code); |
ee2a8b9b JB |
71 | } |
72 | ||
73 | static SCM | |
39752bec | 74 | eval_file_wrapper (void *data) |
ee2a8b9b JB |
75 | { |
76 | /* gh_eval_t real_eval_proc = (gh_eval_t) (* ((gh_eval_t *) data)); */ | |
77 | ||
78 | char *scheme_code = (char *) data; | |
79 | return gh_eval_file (scheme_code); | |
80 | } | |
81 | ||
82 | SCM | |
92c2555f | 83 | gh_eval_file_with_catch (const char *scheme_code, scm_t_catch_handler handler) |
ee2a8b9b JB |
84 | { |
85 | /* FIXME: not there yet */ | |
92c2555f MV |
86 | return gh_catch (SCM_BOOL_T, (scm_t_catch_body) eval_file_wrapper, |
87 | (void *) scheme_code, (scm_t_catch_handler) handler, | |
6e706938 | 88 | (void *) scheme_code); |
ee2a8b9b JB |
89 | } |
90 | ||
91 | SCM | |
6e706938 | 92 | gh_eval_file_with_standard_handler (const char *scheme_code) |
ee2a8b9b JB |
93 | { |
94 | return gh_eval_file_with_catch (scheme_code, gh_standard_handler); | |
95 | } | |
89e00824 ML |
96 | |
97 | /* | |
98 | Local Variables: | |
99 | c-file-style: "gnu" | |
100 | End: | |
101 | */ |