* gh_init.c (gh_standard_handler): Return SCM_BOOL_F, not garbage.
[bpt/guile.git] / libguile / gh.h
CommitLineData
ee2a8b9b
JB
1/* Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
6 * any later version.
7 *
8 * This program 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
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; see the file COPYING. If not, write to
15 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16 *
17 * As a special exception, the Free Software Foundation gives permission
18 * for additional uses of the text contained in its release of GUILE.
19 *
20 * The exception is that, if you link the GUILE library with other files
21 * to produce an executable, this does not by itself cause the
22 * resulting executable to be covered by the GNU General Public License.
23 * Your use of that executable is in no way restricted on account of
24 * linking the GUILE library code into it.
25 *
26 * This exception does not however invalidate any other reasons why
27 * the executable file might be covered by the GNU General Public License.
28 *
29 * This exception applies only to the code released by the
30 * Free Software Foundation under the name GUILE. If you copy
31 * code from other Free Software Foundation releases into a copy of
32 * GUILE, as the General Public License permits, the exception does
33 * not apply to the code that you add in this way. To avoid misleading
34 * anyone as to the status of such modified files, you must delete
35 * this exception notice from them.
36 *
37 * If you write modifications of your own for GUILE, it is your choice
38 * whether to permit this exception to apply to your modifications.
39 * If you do not wish that, delete this exception notice.
40 */
41\f
42
43#ifndef __GH_H
44#define __GH_H
45
46#include <stdio.h>
47
48#include <libguile.h>
49
50/* gcc has extern inline functions that are basically as fast as macros */
51#ifdef __GNUC__
52# define INL inline
53# define EXTINL extern inline
54#else
55# define INL
56#define EXTINL
57#endif /* __GNUC__ */
58
59void gh_enter(int argc, char *argv[], void (*c_main_prog)());
60void gh_repl();
61SCM gh_catch(SCM tag, scm_catch_body_t body, void *body_data,
62 scm_catch_handler_t handler, void *handler_data);
63
64/* SCM gh_catch_with_saved_stack (SCM tag, scm_catch_body_t body, */
65/* void *body_data, scm_catch_handler_t handler, */
66/* void *handler_data); */
67SCM gh_standard_handler(void *data, SCM tag, SCM throw_args);
68#if 0
69SCM gh_repl_handler(void *data, SCM tag, SCM throw_args);
70void gh_enter_repl(int argc, char *argv[], void (*init_proc)());
71#endif /* 0 */
72
73SCM gh_eval_str(char *scheme_code);
74SCM gh_eval_str_with_catch(char *scheme_code, scm_catch_handler_t handler);
75SCM gh_eval_str_with_standard_handler(char *scheme_code);
76SCM gh_eval_str_with_stack_saving_handler(char *scheme_code);
77
78SCM gh_eval_file(char *fname);
79SCM gh_eval_file_with_catch(char *scheme_code, scm_catch_handler_t handler);
80SCM gh_eval_file_with_standard_handler(char *scheme_code);
81
82#define gh_defer_ints() SCM_DEFER_INTS
83#define gh_allow_ints() SCM_ALLOW_INTS
84
85SCM gh_new_procedure(char *proc_name, SCM (*fn)(),
86 int n_required_args, int n_optional_args, int varp);
87SCM gh_new_procedure0_0(char *proc_name, SCM (*fn)());
88SCM gh_new_procedure0_1(char *proc_name, SCM (*fn)());
89SCM gh_new_procedure0_2(char *proc_name, SCM (*fn)());
90SCM gh_new_procedure1_0(char *proc_name, SCM (*fn)());
91SCM gh_new_procedure1_1(char *proc_name, SCM (*fn)());
92SCM gh_new_procedure1_2(char *proc_name, SCM (*fn)());
93SCM gh_new_procedure2_0(char *proc_name, SCM (*fn)());
94SCM gh_new_procedure2_1(char *proc_name, SCM (*fn)());
95SCM gh_new_procedure2_2(char *proc_name, SCM (*fn)());
96SCM gh_new_procedure3_0(char *proc_name, SCM (*fn)());
97SCM gh_new_procedure4_0(char *proc_name, SCM (*fn)());
98SCM gh_new_procedure5_0(char *proc_name, SCM (*fn)());
99
100/* C to Scheme conversion */
101SCM gh_bool2scm(int x);
102SCM gh_int2scm(int x);
103SCM gh_ulong2scm(unsigned long x);
104SCM gh_long2scm(long x);
105SCM gh_double2scm(double x);
106SCM gh_char2scm(char c);
107SCM gh_str2scm(char *s, int len);
108SCM gh_str02scm(char *s);
109void gh_set_substr(char *src, SCM dst, int start, int len);
110SCM gh_symbol2scm(char *symbol_str);
111
112
113/* Scheme to C conversion */
114int gh_scm2bool(SCM obj);
115int gh_scm2int(SCM obj);
116unsigned long gh_scm2ulong(SCM obj);
117long gh_scm2long(SCM obj);
118char gh_scm2char(SCM obj);
119double gh_scm2double(SCM obj);
120char *gh_scm2newstr(SCM str, int *lenp);
121void gh_get_substr(SCM src, char *dst, int start, int len);
122char *gh_symbol2newstr(SCM sym, int *lenp);
123
124/* type predicates: tell you if an SCM object has a given type */
125int gh_boolean_p(SCM val);
126int gh_symbol_p(SCM val);
127int gh_char_p(SCM val);
128int gh_vector_p(SCM val);
129int gh_pair_p(SCM val);
130int gh_number_p(SCM val);
131int gh_string_p(SCM val);
132int gh_procedure_p(SCM val);
133int gh_list_p(SCM val);
134int gh_inexact_p(SCM val);
135int gh_exact_p(SCM val);
136
137/* more predicates */
138int gh_eq_p(SCM x, SCM y);
139int gh_eqv_p(SCM x, SCM y);
140int gh_equal_p(SCM x, SCM y);
141
142/* standard Scheme procedures available from C */
143
144SCM gh_define(char *name, SCM val);
145
146SCM gh_vector(SCM length, SCM val);
147SCM gh_vset(SCM vec, SCM pos, SCM val);
148SCM gh_vref(SCM vec, SCM pos);
149unsigned long gh_vector_length(SCM v);
150
151SCM gh_cons(SCM x, SCM y);
152#define gh_list scm_listify
153unsigned long gh_list_length(SCM l);
154
155SCM gh_car(SCM x);
156SCM gh_cdr(SCM x);
157
158SCM gh_caar(SCM x);
159SCM gh_cadr(SCM x);
160SCM gh_cdar(SCM x);
161SCM gh_cddr(SCM x);
162
163SCM gh_caaar(SCM x);
164SCM gh_caadr(SCM x);
165SCM gh_cadar(SCM x);
166SCM gh_caddr(SCM x);
167SCM gh_cdaar(SCM x);
168SCM gh_cdadr(SCM x);
169SCM gh_cddar(SCM x);
170SCM gh_cdddr(SCM x);
171
172/* Calling Scheme functions from C. */
173SCM gh_apply (SCM proc, SCM ls);
174SCM gh_call0 (SCM proc);
175SCM gh_call1 (SCM proc, SCM arg);
176SCM gh_call2 (SCM proc, SCM arg1, SCM arg2);
177SCM gh_call3 (SCM proc, SCM arg1, SCM arg2, SCM arg3);
178
179/* reading and writing Scheme objects. */
180void gh_display (SCM x);
181void gh_newline (void);
182
183/* void gh_gc_mark(SCM) : mark an SCM as in use. */
184/* void gh_defer_ints() : don't interrupt code section. */
185/* void gh_allow_ints() : see gh_defer_ints(). */
186/* void gh_new_cell(SCM, int tag) : initialize SCM to be of type 'tag' */
187/* int gh_type_p(SCM, tag) : test if SCM is of type 'tag' */
188/* SCM gh_intern(char*) : get symbol corresponding to c-string.*/
189/* void gh_set_ext_data(SCM, void*) : set extension data on SCM */
190/* void *gh_get_ext_data(SCM) : return extension data from SCM. */
191
192/* void gh_assert(int cond, char *msg, SCM obj); */
193
194
195#endif /* __GH_H */