fix
[bpt/guile.git] / libguile / snarf.h
CommitLineData
2e07d033 1
5b4215a8
JB
2/* classes: h_files */
3
4/* Macros for snarfing initialization actions from C source. */
5
6#ifndef LIBGUILE_SNARF_H
7#define LIBGUILE_SNARF_H
8
37a33fed 9/* Copyright (C) 1995,1996,1997,1998, 1999 Free Software Foundation, Inc.
5b4215a8
JB
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this software; see the file COPYING. If not, write to
82892bed
JB
23 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
24 * Boston, MA 02111-1307 USA
5b4215a8
JB
25 *
26 * As a special exception, the Free Software Foundation gives permission
27 * for additional uses of the text contained in its release of GUILE.
28 *
29 * The exception is that, if you link the GUILE library with other files
30 * to produce an executable, this does not by itself cause the
31 * resulting executable to be covered by the GNU General Public License.
32 * Your use of that executable is in no way restricted on account of
33 * linking the GUILE library code into it.
34 *
35 * This exception does not however invalidate any other reasons why
36 * the executable file might be covered by the GNU General Public License.
37 *
38 * This exception applies only to the code released by the
39 * Free Software Foundation under the name GUILE. If you copy
40 * code from other Free Software Foundation releases into a copy of
41 * GUILE, as the General Public License permits, the exception does
42 * not apply to the code that you add in this way. To avoid misleading
43 * anyone as to the status of such modified files, you must delete
44 * this exception notice from them.
45 *
46 * If you write modifications of your own for GUILE, it is your choice
47 * whether to permit this exception to apply to your modifications.
48 * If you do not wish that, delete this exception notice. */
49\f
50
51#ifndef SCM_MAGIC_SNARFER
52#define SCM_PROC(RANAME, STR, REQ, OPT, VAR, CFN) \
3eeba8d4 53 static const char RANAME[]=STR
5b4215a8 54#define SCM_PROC1(RANAME, STR, TYPE, CFN) \
3eeba8d4 55 static const char RANAME[]=STR
5b4215a8 56#else
37a33fed
JB
57#if defined(__cplusplus) || defined(GUILE_CPLUSPLUS_SNARF)
58#define SCM_PROC(RANAME, STR, REQ, OPT, VAR, CFN) \
59%%% scm_make_gsubr (RANAME, REQ, OPT, VAR, (SCM (*)(...))CFN)
60#define SCM_PROC1(RANAME, STR, TYPE, CFN) \
61%%% scm_make_subr(RANAME, TYPE, (SCM (*)(...))CFN)
62#else
5b4215a8 63#define SCM_PROC(RANAME, STR, REQ, OPT, VAR, CFN) \
e9b6a0fb 64%%% scm_make_gsubr (RANAME, REQ, OPT, VAR, (SCM (*)()) CFN)
5b4215a8
JB
65#define SCM_PROC1(RANAME, STR, TYPE, CFN) \
66%%% scm_make_subr(RANAME, TYPE, CFN)
5b4215a8 67#endif
37a33fed 68#endif
5b4215a8 69
b8229a3b
MS
70#ifndef SCM_MAGIC_SNARFER
71#define SCM_SYNTAX(RANAME, STR, TYPE, CFN) \
e4755e5c 72 static const char RANAME[]=STR
b8229a3b
MS
73#else
74#define SCM_SYNTAX(RANAME, STR, TYPE, CFN) \
75%%% scm_make_synt (RANAME, TYPE, CFN)
76#endif
77
5b4215a8
JB
78#ifndef SCM_MAGIC_SNARFER
79#define SCM_SYMBOL(c_name, scheme_name) \
80 static SCM c_name = SCM_BOOL_F
81#else
82#define SCM_SYMBOL(C_NAME, SCHEME_NAME) \
83%%% C_NAME = scm_permanent_object (SCM_CAR (scm_intern0 (SCHEME_NAME)))
84#endif
85
78f9f47b
MD
86#ifndef SCM_MAGIC_SNARFER
87#define SCM_GLOBAL_SYMBOL(c_name, scheme_name) \
88 SCM c_name = SCM_BOOL_F
89#else
90#define SCM_GLOBAL_SYMBOL(C_NAME, SCHEME_NAME) \
91%%% C_NAME = scm_permanent_object (SCM_CAR (scm_intern0 (SCHEME_NAME)))
92#endif
93
37b83f68
MD
94#ifndef SCM_MAGIC_SNARFER
95#define SCM_KEYWORD(c_name, scheme_name) \
96 static SCM c_name = SCM_BOOL_F
97#else
98#define SCM_KEYWORD(C_NAME, SCHEME_NAME) \
99%%% C_NAME = scm_permanent_object (scm_c_make_keyword (SCHEME_NAME))
100#endif
101
102#ifndef SCM_MAGIC_SNARFER
103#define SCM_GLOBAL_KEYWORD(c_name, scheme_name) \
104 SCM c_name = SCM_BOOL_F
105#else
106#define SCM_GLOBAL_KEYWORD(C_NAME, SCHEME_NAME) \
107%%% C_NAME = scm_permanent_object (scm_makekey (SCHEME_NAME))
108#endif
5b4215a8
JB
109
110#ifndef SCM_MAGIC_SNARFER
78f9f47b 111#define SCM_VCELL(c_name, scheme_name) \
5b4215a8
JB
112 static SCM c_name = SCM_BOOL_F
113#else
78f9f47b
MD
114#define SCM_VCELL(C_NAME, SCHEME_NAME) \
115%%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, SCM_BOOL_F)
116#endif
117
118#ifndef SCM_MAGIC_SNARFER
119#define SCM_GLOBAL_VCELL(c_name, scheme_name) \
120 SCM c_name = SCM_BOOL_F
121#else
122#define SCM_GLOBAL_VCELL(C_NAME, SCHEME_NAME) \
5b4215a8
JB
123%%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, SCM_BOOL_F)
124#endif
125
2e07d033
JB
126#ifndef SCM_MAGIC_SNARFER
127#define SCM_VCELL_INIT(c_name, scheme_name, init_val) \
128 static SCM c_name = SCM_BOOL_F
129#else
130#define SCM_VCELL_INIT(C_NAME, SCHEME_NAME, init_val) \
131%%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, init_val)
132#endif
5b4215a8
JB
133
134#ifndef SCM_MAGIC_SNARFER
2e07d033
JB
135#define SCM_GLOBAL_VCELL_INIT(c_name, scheme_name, init_val) \
136 SCM c_name = SCM_BOOL_F
5b4215a8 137#else
2e07d033
JB
138#define SCM_GLOBAL_VCELL_INIT(C_NAME, SCHEME_NAME, init_val) \
139%%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, init_val)
5b4215a8
JB
140#endif
141
af68fb84 142#define SCM_CONST_LONG(C_NAME, SCHEME_NAME,VALUE) SCM_VCELL_INIT(C_NAME, SCHEME_NAME, scm_long2num(VALUE))
2e07d033 143
5b4215a8 144#endif /* LIBGUILE_SNARF_H */