* snarf.h (SCM_KEYWORD, SCM_GLOBAL_KEYWORD): New macros.
[bpt/guile.git] / libguile / snarf.h
1
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
9 /* Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
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
23 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
24 * Boston, MA 02111-1307 USA
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) \
53 static const char RANAME[]=STR
54 #define SCM_PROC1(RANAME, STR, TYPE, CFN) \
55 static const char RANAME[]=STR
56 #else
57 #define SCM_PROC(RANAME, STR, REQ, OPT, VAR, CFN) \
58 %%% scm_make_gsubr (RANAME, REQ, OPT, VAR, (SCM (*)()) CFN)
59 #define SCM_PROC1(RANAME, STR, TYPE, CFN) \
60 %%% scm_make_subr(RANAME, TYPE, CFN)
61 #endif
62
63 #ifndef SCM_MAGIC_SNARFER
64 #define SCM_SYNTAX(RANAME, STR, TYPE, CFN) \
65 static const char RANAME[]=STR
66 #else
67 #define SCM_SYNTAX(RANAME, STR, TYPE, CFN) \
68 %%% scm_make_synt (RANAME, TYPE, CFN)
69 #endif
70
71 #ifndef SCM_MAGIC_SNARFER
72 #define SCM_SYMBOL(c_name, scheme_name) \
73 static SCM c_name = SCM_BOOL_F
74 #else
75 #define SCM_SYMBOL(C_NAME, SCHEME_NAME) \
76 %%% C_NAME = scm_permanent_object (SCM_CAR (scm_intern0 (SCHEME_NAME)))
77 #endif
78
79 #ifndef SCM_MAGIC_SNARFER
80 #define SCM_GLOBAL_SYMBOL(c_name, scheme_name) \
81 SCM c_name = SCM_BOOL_F
82 #else
83 #define SCM_GLOBAL_SYMBOL(C_NAME, SCHEME_NAME) \
84 %%% C_NAME = scm_permanent_object (SCM_CAR (scm_intern0 (SCHEME_NAME)))
85 #endif
86
87 #ifndef SCM_MAGIC_SNARFER
88 #define SCM_KEYWORD(c_name, scheme_name) \
89 static SCM c_name = SCM_BOOL_F
90 #else
91 #define SCM_KEYWORD(C_NAME, SCHEME_NAME) \
92 %%% C_NAME = scm_permanent_object (scm_c_make_keyword (SCHEME_NAME))
93 #endif
94
95 #ifndef SCM_MAGIC_SNARFER
96 #define SCM_GLOBAL_KEYWORD(c_name, scheme_name) \
97 SCM c_name = SCM_BOOL_F
98 #else
99 #define SCM_GLOBAL_KEYWORD(C_NAME, SCHEME_NAME) \
100 %%% C_NAME = scm_permanent_object (scm_makekey (SCHEME_NAME))
101 #endif
102
103 #ifndef SCM_MAGIC_SNARFER
104 #define SCM_VCELL(c_name, scheme_name) \
105 static SCM c_name = SCM_BOOL_F
106 #else
107 #define SCM_VCELL(C_NAME, SCHEME_NAME) \
108 %%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, SCM_BOOL_F)
109 #endif
110
111 #ifndef SCM_MAGIC_SNARFER
112 #define SCM_GLOBAL_VCELL(c_name, scheme_name) \
113 SCM c_name = SCM_BOOL_F
114 #else
115 #define SCM_GLOBAL_VCELL(C_NAME, SCHEME_NAME) \
116 %%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, SCM_BOOL_F)
117 #endif
118
119 #ifndef SCM_MAGIC_SNARFER
120 #define SCM_VCELL_INIT(c_name, scheme_name, init_val) \
121 static SCM c_name = SCM_BOOL_F
122 #else
123 #define SCM_VCELL_INIT(C_NAME, SCHEME_NAME, init_val) \
124 %%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, init_val)
125 #endif
126
127 #ifndef SCM_MAGIC_SNARFER
128 #define SCM_GLOBAL_VCELL_INIT(c_name, scheme_name, init_val) \
129 SCM c_name = SCM_BOOL_F
130 #else
131 #define SCM_GLOBAL_VCELL_INIT(C_NAME, SCHEME_NAME, init_val) \
132 %%% C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, init_val)
133 #endif
134
135 #define SCM_CONST_LONG(C_NAME, SCHEME_NAME,VALUE) SCM_VCELL_INIT(C_NAME, SCHEME_NAME, scm_long2num(VALUE));
136
137 #endif /* LIBGUILE_SNARF_H */