* Remove deprecated macros and typenames.
[bpt/guile.git] / libguile / snarf.h
CommitLineData
5b4215a8
JB
1/* classes: h_files */
2
b29058ff
DH
3#ifndef SCM_SNARF_H
4#define SCM_SNARF_H
5b4215a8 5
b29058ff
DH
6/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
7 *
5b4215a8
JB
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
b29058ff 12 *
5b4215a8
JB
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
b29058ff 17 *
5b4215a8
JB
18 * You should have received a copy of the GNU General Public License
19 * along with this software; see the file COPYING. If not, write to
82892bed
JB
20 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21 * Boston, MA 02111-1307 USA
5b4215a8
JB
22 *
23 * As a special exception, the Free Software Foundation gives permission
24 * for additional uses of the text contained in its release of GUILE.
25 *
26 * The exception is that, if you link the GUILE library with other files
27 * to produce an executable, this does not by itself cause the
28 * resulting executable to be covered by the GNU General Public License.
29 * Your use of that executable is in no way restricted on account of
30 * linking the GUILE library code into it.
31 *
32 * This exception does not however invalidate any other reasons why
33 * the executable file might be covered by the GNU General Public License.
34 *
35 * This exception applies only to the code released by the
36 * Free Software Foundation under the name GUILE. If you copy
37 * code from other Free Software Foundation releases into a copy of
38 * GUILE, as the General Public License permits, the exception does
39 * not apply to the code that you add in this way. To avoid misleading
40 * anyone as to the status of such modified files, you must delete
41 * this exception notice from them.
42 *
43 * If you write modifications of your own for GUILE, it is your choice
44 * whether to permit this exception to apply to your modifications.
45 * If you do not wish that, delete this exception notice. */
1bbd0b84 46
5b4215a8
JB
47\f
48
b29058ff
DH
49/* Macros for snarfing initialization actions from C source. */
50
4b4d0898 51#if defined(__cplusplus) || defined(GUILE_CPLUSPLUS_SNARF)
e1fbffa9
MV
52
53/* This used to be "SCM (*)(...)" but GCC on RedHat 7.1 doesn't seem
54 to like it.
55 */
56#define SCM_FUNC_CAST_ARBITRARY_ARGS SCM (*)()
57
bfe19b46 58#else
4b4d0898 59#define SCM_FUNC_CAST_ARBITRARY_ARGS SCM (*)()
bfe19b46
MD
60#endif
61
73d8385e
MD
62/* Generic macros to be used in user macro definitions.
63 *
64 * For example, in order to define a macro which creates ints and
65 * initializes them to the result of foo (), do:
66 *
67 * #define SCM_FOO(NAME) \
94a70859
MD
68 * SCM_SNARF_HERE (int NAME) \
69 * SCM_SNARF_INIT (NAME = foo ())
1e76143f 70 *
94a70859 71 * The SCM_SNARF_INIT text goes into the corresponding .x file
3c6d9d71
DH
72 * up through the first occurrence of SCM_SNARF_DOC_START on that
73 * line, if any.
73d8385e
MD
74 */
75
c99f9605
ML
76#ifdef SCM_MAGIC_SNARF_INITS
77# define SCM_SNARF_HERE(X)
78# define SCM_SNARF_INIT(X) ^^ X
79# define SCM_SNARF_DOCS(TYPE, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING)
1e76143f 80#else
c99f9605 81# ifdef SCM_MAGIC_SNARF_DOCS
94a70859 82# define SCM_SNARF_HERE(X)
c99f9605
ML
83# define SCM_SNARF_INIT(X)
84# define SCM_SNARF_DOCS(TYPE, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) \
ac13d9d2
ML
85^^ { \
86fname FNAME ^^ \
87type TYPE ^^ \
88location __FILE__ __LINE__ ^^ \
89arglist ARGLIST ^^ \
90argsig REQ OPT VAR ^^ \
91DOCSTRING ^^ }
c99f9605
ML
92# else
93# define SCM_SNARF_HERE(X) X
94# define SCM_SNARF_INIT(X)
95# define SCM_SNARF_DOCS(TYPE, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING)
96# endif
1e76143f 97#endif
73d8385e 98
a1ec6916 99#define SCM_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
94a70859 100SCM_SNARF_HERE(\
4b4d0898
GB
101static const char s_ ## FNAME [] = PRIMNAME; \
102SCM FNAME ARGLIST\
103)\
94a70859 104SCM_SNARF_INIT(\
9a441ddb
MV
105scm_c_define_gsubr (s_ ## FNAME, REQ, OPT, VAR, \
106 (SCM_FUNC_CAST_ARBITRARY_ARGS) FNAME); \
2fdcf8bd 107)\
c99f9605 108SCM_SNARF_DOCS(primitive, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING)
1bbd0b84 109
c3ee7520 110#define SCM_DEFINE1(FNAME, PRIMNAME, TYPE, ARGLIST, DOCSTRING) \
94a70859 111SCM_SNARF_HERE(\
4b4d0898
GB
112static const char s_ ## FNAME [] = PRIMNAME; \
113SCM FNAME ARGLIST\
2fdcf8bd 114)\
9a441ddb 115SCM_SNARF_INIT(scm_c_define_subr (s_ ## FNAME, TYPE, FNAME); ) \
c99f9605 116SCM_SNARF_DOCS(1, PRIMNAME, ARGLIST, 2, 0, 0, DOCSTRING)
1bbd0b84 117
9b1594fd 118#define SCM_PROC(RANAME, STR, REQ, OPT, VAR, CFN) \
94a70859 119SCM_SNARF_HERE(static const char RANAME[]=STR) \
9a441ddb
MV
120SCM_SNARF_INIT(scm_c_define_gsubr (RANAME, REQ, OPT, VAR, \
121 (SCM_FUNC_CAST_ARBITRARY_ARGS) CFN))
9b1594fd 122
1bbd0b84 123#define SCM_REGISTER_PROC(RANAME, STR, REQ, OPT, VAR, CFN) \
94a70859 124SCM_SNARF_HERE(static const char RANAME[]=STR) \
9a441ddb
MV
125SCM_SNARF_INIT(scm_c_define_gsubr (RANAME, REQ, OPT, VAR, \
126 (SCM_FUNC_CAST_ARBITRARY_ARGS) CFN);) \
c99f9605
ML
127SCM_SNARF_DOCS(register, STR, (), REQ, OPT, VAR, \
128 "implemented by the C function \"" #CFN "\"")
3dc81fba 129
9de33deb 130#define SCM_GPROC(RANAME, STR, REQ, OPT, VAR, CFN, GF) \
94a70859 131SCM_SNARF_HERE(\
4b4d0898 132static const char RANAME[]=STR;\
54778cd3 133static SCM GF \
94a70859 134)SCM_SNARF_INIT(\
54778cd3 135GF = SCM_PACK (0); /* Dirk:FIXME:: Can we safely use #f instead of 0? */ \
9a441ddb
MV
136scm_c_define_gsubr_with_generic (RANAME, REQ, OPT, VAR, \
137 (SCM_FUNC_CAST_ARBITRARY_ARGS) CFN, &GF) \
4b4d0898 138)
3dc81fba 139
4b4d0898 140#define SCM_PROC1(RANAME, STR, TYPE, CFN) \
94a70859
MD
141SCM_SNARF_HERE(static const char RANAME[]=STR) \
142SCM_SNARF_INIT(\
9a441ddb 143scm_c_define_subr (RANAME, TYPE, (SCM_FUNC_CAST_ARBITRARY_ARGS) CFN) \
4b4d0898 144)
9b1594fd 145
9b1594fd 146
4b4d0898 147#define SCM_GPROC1(RANAME, STR, TYPE, CFN, GF) \
94a70859 148SCM_SNARF_HERE(\
4b4d0898 149static const char RANAME[]=STR; \
54778cd3 150static SCM GF \
94a70859 151)SCM_SNARF_INIT(\
54778cd3 152GF = SCM_PACK (0); /* Dirk:FIXME:: Can we safely use #f instead of 0? */ \
9a441ddb
MV
153scm_c_define_subr_with_generic (RANAME, TYPE, \
154 (SCM_FUNC_CAST_ARBITRARY_ARGS) CFN, &GF) \
4b4d0898 155)
5b4215a8 156
b8229a3b 157#define SCM_SYNTAX(RANAME, STR, TYPE, CFN) \
94a70859
MD
158SCM_SNARF_HERE(static const char RANAME[]=STR)\
159SCM_SNARF_INIT(scm_make_synt (RANAME, TYPE, CFN))
b8229a3b 160
5b4215a8 161#define SCM_SYMBOL(c_name, scheme_name) \
94a70859 162SCM_SNARF_HERE(static SCM c_name) \
38ae064c 163SCM_SNARF_INIT(c_name = scm_permanent_object (scm_str2symbol (scheme_name)))
5b4215a8 164
78f9f47b 165#define SCM_GLOBAL_SYMBOL(c_name, scheme_name) \
94a70859 166SCM_SNARF_HERE(SCM c_name) \
38ae064c 167SCM_SNARF_INIT(c_name = scm_permanent_object (scm_str2symbol (scheme_name)))
78f9f47b 168
37b83f68 169#define SCM_KEYWORD(c_name, scheme_name) \
94a70859
MD
170SCM_SNARF_HERE(static SCM c_name) \
171SCM_SNARF_INIT(c_name = scm_permanent_object (scm_c_make_keyword (scheme_name)))
37b83f68 172
37b83f68 173#define SCM_GLOBAL_KEYWORD(c_name, scheme_name) \
94a70859
MD
174SCM_SNARF_HERE(SCM c_name) \
175SCM_SNARF_INIT(c_name = scm_permanent_object (scm_c_make_keyword (scheme_name)))
5b4215a8 176
86d31dfe
MV
177#define SCM_VARIABLE(c_name, scheme_name) \
178SCM_SNARF_HERE(static SCM c_name) \
179SCM_SNARF_INIT(c_name = scm_permanent_object (scm_c_define (scheme_name, SCM_BOOL_F));)
180
181#define SCM_GLOBAL_VARIABLE(c_name, scheme_name) \
182SCM_SNARF_HERE(SCM c_name) \
183SCM_SNARF_INIT(c_name = scm_permanent_object (scm_c_define (scheme_name, SCM_BOOL_F));)
184
185#define SCM_VARIABLE_INIT(c_name, scheme_name, init_val) \
186SCM_SNARF_HERE(static SCM c_name) \
187SCM_SNARF_INIT(c_name = scm_permanent_object (scm_c_define (scheme_name, init_val));)
188
189#define SCM_GLOBAL_VARIABLE_INIT(c_name, scheme_name, init_val) \
190SCM_SNARF_HERE(SCM c_name) \
191SCM_SNARF_INIT(c_name = scm_permanent_object (scm_c_define (scheme_name, init_val));)
192
c99f9605 193#ifdef SCM_MAGIC_SNARF_DOCS
4b4d0898 194#undef SCM_ASSERT
ac13d9d2 195#define SCM_ASSERT(_cond, _arg, _pos, _subr) ^^ argpos _arg _pos __LINE__ ^^
c99f9605 196#endif /* SCM_MAGIC_SNARF_DOCS */
2e07d033 197
b29058ff 198#endif /* SCM_SNARF_H */
89e00824
ML
199
200/*
201 Local Variables:
202 c-file-style: "gnu"
203 End:
204*/