Commit | Line | Data |
---|---|---|
5b4215a8 JB |
1 | /* classes: h_files */ |
2 | ||
3 | /* Macros for snarfing initialization actions from C source. */ | |
4 | ||
5 | #ifndef LIBGUILE_SNARF_H | |
6 | #define LIBGUILE_SNARF_H | |
7 | ||
37a33fed | 8 | /* Copyright (C) 1995,1996,1997,1998, 1999 Free Software Foundation, Inc. |
5b4215a8 JB |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; either version 2, or (at your option) | |
13 | * any later version. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with this software; see the file COPYING. If not, write to | |
82892bed JB |
22 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
23 | * Boston, MA 02111-1307 USA | |
5b4215a8 JB |
24 | * |
25 | * As a special exception, the Free Software Foundation gives permission | |
26 | * for additional uses of the text contained in its release of GUILE. | |
27 | * | |
28 | * The exception is that, if you link the GUILE library with other files | |
29 | * to produce an executable, this does not by itself cause the | |
30 | * resulting executable to be covered by the GNU General Public License. | |
31 | * Your use of that executable is in no way restricted on account of | |
32 | * linking the GUILE library code into it. | |
33 | * | |
34 | * This exception does not however invalidate any other reasons why | |
35 | * the executable file might be covered by the GNU General Public License. | |
36 | * | |
37 | * This exception applies only to the code released by the | |
38 | * Free Software Foundation under the name GUILE. If you copy | |
39 | * code from other Free Software Foundation releases into a copy of | |
40 | * GUILE, as the General Public License permits, the exception does | |
41 | * not apply to the code that you add in this way. To avoid misleading | |
42 | * anyone as to the status of such modified files, you must delete | |
43 | * this exception notice from them. | |
44 | * | |
45 | * If you write modifications of your own for GUILE, it is your choice | |
46 | * whether to permit this exception to apply to your modifications. | |
47 | * If you do not wish that, delete this exception notice. */ | |
1bbd0b84 GB |
48 | |
49 | /* Software engineering face-lift by Greg J. Badros, 11-Dec-1999, | |
50 | gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */ | |
51 | ||
5b4215a8 JB |
52 | \f |
53 | ||
54 | #ifndef SCM_MAGIC_SNARFER | |
1bbd0b84 GB |
55 | |
56 | #define GUILE_PROC(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ | |
57 | static const char s_ ## FNAME [] = PRIMNAME; \ | |
58 | SCM FNAME ARGLIST | |
59 | #define GUILE_PROC1(FNAME, PRIMNAME, TYPE, ARGLIST, DOCSTRING) \ | |
60 | static const char s_ ## FNAME [] = PRIMNAME; \ | |
61 | SCM FNAME ARGLIST | |
62 | ||
1bbd0b84 GB |
63 | #define SCM_REGISTER_PROC(RANAME, STR, REQ, OPT, VAR, CFN) \ |
64 | static const char RANAME[]=STR | |
9de33deb MD |
65 | #define SCM_GPROC(RANAME, STR, REQ, OPT, VAR, CFN, GF) \ |
66 | static const char RANAME[]=STR; \ | |
67 | static SCM GF = 0 | |
9de33deb MD |
68 | #define SCM_GPROC1(RANAME, STR, TYPE, CFN, GF) \ |
69 | static const char RANAME[]=STR; \ | |
70 | static SCM GF = 0 | |
5b4215a8 | 71 | #else |
37a33fed | 72 | #if defined(__cplusplus) || defined(GUILE_CPLUSPLUS_SNARF) |
3dc81fba | 73 | /* for C++ snarfing */ |
1bbd0b84 GB |
74 | |
75 | #define GUILE_PROC(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ | |
6e8d25a6 | 76 | %%% scm_make_gsubr (s_ ## FNAME, REQ, OPT, VAR, (SCM (*)(...)) FNAME); \ |
3dc81fba | 77 | $$$P PRIMNAME #ARGLIST | REQ | OPT | VAR | __FILE__:__LINE__ | @@@ DOCSTRING @!!! |
6e8d25a6 | 78 | |
1bbd0b84 | 79 | #define GUILE_PROC1(FNAME, PRIMNAME, TYPE, ARGLIST, DOCSTRING) \ |
6e8d25a6 | 80 | %%% scm_make_subr (s_ ## FNAME, TYPE, FNAME); \ |
3dc81fba | 81 | $$$1 PRIMNAME #ARGLIST | 2 | 0 | 0 | __FILE__:__LINE__ | @@@ DOCSTRING @!!! |
1bbd0b84 | 82 | |
1bbd0b84 | 83 | #define SCM_REGISTER_PROC(RANAME, STR, REQ, OPT, VAR, CFN) \ |
3dc81fba | 84 | %%% scm_make_gsubr (RANAME, REQ, OPT, VAR, (SCM (*)(...)) CFN); \ |
eff08ab6 | 85 | $$$R STR | REQ | OPT | VAR | __FILE__:__LINE__ | @@@ CFN @!!! |
6e8d25a6 | 86 | |
9de33deb MD |
87 | #define SCM_GPROC(RANAME, STR, REQ, OPT, VAR, CFN, GF) \ |
88 | %%% scm_make_gsubr_with_generic (RANAME, REQ, OPT, VAR, (SCM (*)(...))CFN, &GF) | |
3dc81fba | 89 | |
9de33deb MD |
90 | #define SCM_GPROC1(RANAME, STR, TYPE, CFN, GF) \ |
91 | %%% scm_make_subr_with_generic(RANAME, TYPE, (SCM (*)(...))CFN, &GF) | |
3dc81fba | 92 | |
37a33fed | 93 | #else |
3dc81fba | 94 | /* for ANSI C snarfing, not C++ */ |
1bbd0b84 GB |
95 | |
96 | #define GUILE_PROC(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ | |
3dc81fba GB |
97 | %%% scm_make_gsubr (s_ ## FNAME, REQ, OPT, VAR, (SCM (*)()) FNAME); \ |
98 | $$$P PRIMNAME #ARGLIST | REQ | OPT | VAR | __FILE__:__LINE__ | @@@ DOCSTRING @!!! | |
1bbd0b84 | 99 | |
3dc81fba GB |
100 | #define GUILE_PROC1(FNAME, PRIMNAME, TYPE, ARGLIST, DOCSTRING) \ |
101 | %%% scm_make_subr (s_ ## FNAME, TYPE, FNAME); \ | |
102 | $$$1 PRIMNAME #ARGLIST | 2 | 0 | 0 | __FILE__:__LINE__ | @@@ DOCSTRING @!!! | |
1bbd0b84 | 103 | |
1bbd0b84 | 104 | #define SCM_REGISTER_PROC(RANAME, STR, REQ, OPT, VAR, CFN) \ |
3dc81fba | 105 | %%% scm_make_gsubr (RANAME, REQ, OPT, VAR, (SCM (*)()) CFN); \ |
eff08ab6 | 106 | $$$R STR | REQ | OPT | VAR | __FILE__:__LINE__ | @@@ CFN @!!! |
3dc81fba | 107 | |
9de33deb MD |
108 | #define SCM_GPROC(RANAME, STR, REQ, OPT, VAR, CFN, GF) \ |
109 | %%% scm_make_gsubr_with_generic (RANAME, REQ, OPT, VAR, (SCM (*)()) CFN, &GF) | |
3dc81fba | 110 | |
9de33deb MD |
111 | #define SCM_GPROC1(RANAME, STR, TYPE, CFN, GF) \ |
112 | %%% scm_make_subr_with_generic(RANAME, TYPE, CFN, &GF) | |
5b4215a8 | 113 | #endif |
37a33fed | 114 | #endif |
5b4215a8 | 115 | |
b8229a3b MS |
116 | #ifndef SCM_MAGIC_SNARFER |
117 | #define SCM_SYNTAX(RANAME, STR, TYPE, CFN) \ | |
e4755e5c | 118 | static const char RANAME[]=STR |
b8229a3b MS |
119 | #else |
120 | #define SCM_SYNTAX(RANAME, STR, TYPE, CFN) \ | |
121 | %%% scm_make_synt (RANAME, TYPE, CFN) | |
122 | #endif | |
123 | ||
5b4215a8 JB |
124 | #ifndef SCM_MAGIC_SNARFER |
125 | #define SCM_SYMBOL(c_name, scheme_name) \ | |
126 | static SCM c_name = SCM_BOOL_F | |
127 | #else | |
128 | #define SCM_SYMBOL(C_NAME, SCHEME_NAME) \ | |
129 | %%% C_NAME = scm_permanent_object (SCM_CAR (scm_intern0 (SCHEME_NAME))) | |
130 | #endif | |
131 | ||
78f9f47b MD |
132 | #ifndef SCM_MAGIC_SNARFER |
133 | #define SCM_GLOBAL_SYMBOL(c_name, scheme_name) \ | |
134 | SCM c_name = SCM_BOOL_F | |
135 | #else | |
136 | #define SCM_GLOBAL_SYMBOL(C_NAME, SCHEME_NAME) \ | |
137 | %%% C_NAME = scm_permanent_object (SCM_CAR (scm_intern0 (SCHEME_NAME))) | |
138 | #endif | |
139 | ||
37b83f68 MD |
140 | #ifndef SCM_MAGIC_SNARFER |
141 | #define SCM_KEYWORD(c_name, scheme_name) \ | |
142 | static SCM c_name = SCM_BOOL_F | |
143 | #else | |
144 | #define SCM_KEYWORD(C_NAME, SCHEME_NAME) \ | |
145 | %%% C_NAME = scm_permanent_object (scm_c_make_keyword (SCHEME_NAME)) | |
146 | #endif | |
147 | ||
148 | #ifndef SCM_MAGIC_SNARFER | |
149 | #define SCM_GLOBAL_KEYWORD(c_name, scheme_name) \ | |
150 | SCM c_name = SCM_BOOL_F | |
151 | #else | |
152 | #define SCM_GLOBAL_KEYWORD(C_NAME, SCHEME_NAME) \ | |
1bf17bb4 | 153 | %%% C_NAME = scm_permanent_object (scm_c_make_keyword (SCHEME_NAME)) |
37b83f68 | 154 | #endif |
5b4215a8 JB |
155 | |
156 | #ifndef SCM_MAGIC_SNARFER | |
78f9f47b | 157 | #define SCM_VCELL(c_name, scheme_name) \ |
5b4215a8 JB |
158 | static SCM c_name = SCM_BOOL_F |
159 | #else | |
78f9f47b MD |
160 | #define SCM_VCELL(C_NAME, SCHEME_NAME) \ |
161 | %%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, SCM_BOOL_F) | |
162 | #endif | |
163 | ||
164 | #ifndef SCM_MAGIC_SNARFER | |
165 | #define SCM_GLOBAL_VCELL(c_name, scheme_name) \ | |
166 | SCM c_name = SCM_BOOL_F | |
167 | #else | |
168 | #define SCM_GLOBAL_VCELL(C_NAME, SCHEME_NAME) \ | |
5b4215a8 JB |
169 | %%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, SCM_BOOL_F) |
170 | #endif | |
171 | ||
2e07d033 JB |
172 | #ifndef SCM_MAGIC_SNARFER |
173 | #define SCM_VCELL_INIT(c_name, scheme_name, init_val) \ | |
174 | static SCM c_name = SCM_BOOL_F | |
175 | #else | |
176 | #define SCM_VCELL_INIT(C_NAME, SCHEME_NAME, init_val) \ | |
177 | %%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, init_val) | |
178 | #endif | |
5b4215a8 JB |
179 | |
180 | #ifndef SCM_MAGIC_SNARFER | |
2e07d033 JB |
181 | #define SCM_GLOBAL_VCELL_INIT(c_name, scheme_name, init_val) \ |
182 | SCM c_name = SCM_BOOL_F | |
5b4215a8 | 183 | #else |
2e07d033 JB |
184 | #define SCM_GLOBAL_VCELL_INIT(C_NAME, SCHEME_NAME, init_val) \ |
185 | %%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, init_val) | |
5b4215a8 JB |
186 | #endif |
187 | ||
af68fb84 | 188 | #define SCM_CONST_LONG(C_NAME, SCHEME_NAME,VALUE) SCM_VCELL_INIT(C_NAME, SCHEME_NAME, scm_long2num(VALUE)) |
2e07d033 | 189 | |
5b4215a8 | 190 | #endif /* LIBGUILE_SNARF_H */ |