7ea7583bba91e2a85b2bb20a9d03ce1e35249c85
[bpt/guile.git] / libguile / gh_eval.c
1 /* Copyright (C) 1995,1996,1997,1998, 2000, 2001, 2006 Free Software Foundation, Inc.
2
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.
7 *
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.
12 *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 \f
18
19 /* routines to evaluate Scheme code */
20
21 #include "libguile/gh.h"
22
23 #if SCM_ENABLE_DEPRECATED
24
25 typedef SCM (*gh_eval_t) (void *data, SCM jmpbuf);
26
27 /* Evaluate the string; toss the value. */
28 SCM
29 gh_eval_str (const char *scheme_code)
30 {
31 return scm_c_eval_string (scheme_code);
32 }
33
34 /* evaluate the file by passing it to the lower level scm_primitive_load() */
35 SCM
36 gh_eval_file (const char *fname)
37 {
38 return scm_primitive_load (gh_str02scm (fname));
39 }
40
41 static SCM
42 eval_str_wrapper (void *data)
43 {
44 /* gh_eval_t real_eval_proc = (gh_eval_t) (* ((gh_eval_t *) data)); */
45
46 char *scheme_code = (char *) data;
47 return gh_eval_str (scheme_code);
48 }
49
50 SCM
51 gh_eval_str_with_catch (const char *scheme_code, scm_t_catch_handler handler)
52 {
53 /* FIXME: not there yet */
54 return gh_catch (SCM_BOOL_T, (scm_t_catch_body) eval_str_wrapper, (void *) scheme_code,
55 (scm_t_catch_handler) handler, (void *) scheme_code);
56 }
57
58 SCM
59 gh_eval_str_with_standard_handler (const char *scheme_code)
60 {
61 return gh_eval_str_with_catch (scheme_code, gh_standard_handler);
62 }
63
64 SCM
65 gh_eval_str_with_stack_saving_handler (const char *scheme_code)
66 {
67 return scm_internal_stack_catch (SCM_BOOL_T,
68 (scm_t_catch_body) eval_str_wrapper,
69 (void *) scheme_code,
70 (scm_t_catch_handler)
71 gh_standard_handler,
72 (void *) scheme_code);
73 }
74
75 static SCM
76 eval_file_wrapper (void *data)
77 {
78 /* gh_eval_t real_eval_proc = (gh_eval_t) (* ((gh_eval_t *) data)); */
79
80 char *scheme_code = (char *) data;
81 return gh_eval_file (scheme_code);
82 }
83
84 SCM
85 gh_eval_file_with_catch (const char *scheme_code, scm_t_catch_handler handler)
86 {
87 /* FIXME: not there yet */
88 return gh_catch (SCM_BOOL_T, (scm_t_catch_body) eval_file_wrapper,
89 (void *) scheme_code, (scm_t_catch_handler) handler,
90 (void *) scheme_code);
91 }
92
93 SCM
94 gh_eval_file_with_standard_handler (const char *scheme_code)
95 {
96 return gh_eval_file_with_catch (scheme_code, gh_standard_handler);
97 }
98
99 #endif /* SCM_ENABLE_DEPRECATED */
100
101 /*
102 Local Variables:
103 c-file-style: "gnu"
104 End:
105 */