Merge branch 'stable-2.0'
[bpt/guile.git] / test-suite / standalone / test-asmobs-lib.c
CommitLineData
5995c6d8 1/* Copyright (C) 1999,2000,2001,2003, 2006, 2008 Free Software Foundation, Inc.
896f6179
RB
2 *
3 * This library is free software; you can redistribute it and/or
53befeb7
NJ
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
896f6179 7 *
53befeb7
NJ
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
896f6179
RB
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
53befeb7
NJ
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301 USA
896f6179
RB
17 */
18
eb0ffdd8 19#ifdef HAVE_CONFIG_H
3394818c
LC
20# include <config.h>
21#endif
22
5995c6d8 23#include <libguile.h>
896f6179
RB
24
25long asmob000;
26long asmob100;
27long asmob010;
28long asmob001;
29long asmob200;
30long asmob110;
31long asmob020;
32long asmob101;
33long asmob011;
34long asmob300;
35long asmob210;
36long asmob120;
37long asmob030;
38long asmob201;
39long asmob021;
40long asmob111;
41
42/* since we don't have SCM_DEFINE_STATIC or similar */
43SCM scm_make_asmob000 (void);
44SCM scm_make_asmob001 (void);
45SCM scm_make_asmob010 (void);
46SCM scm_make_asmob011 (void);
47SCM scm_make_asmob100 (void);
48SCM scm_make_asmob101 (void);
49SCM scm_make_asmob110 (void);
50SCM scm_make_asmob111 (void);
51SCM scm_make_asmob120 (void);
52SCM scm_make_asmob020 (void);
53SCM scm_make_asmob021 (void);
54SCM scm_make_asmob200 (void);
55SCM scm_make_asmob201 (void);
56SCM scm_make_asmob210 (void);
57SCM scm_make_asmob030 (void);
58SCM scm_make_asmob300 (void);
59
60
61SCM_DEFINE (scm_make_asmob000, "make-asmob000", 0, 0, 0, (), "")
62{
63 SCM_RETURN_NEWSMOB (asmob000, 0);
64}
65
66SCM_DEFINE (scm_make_asmob100, "make-asmob100", 0, 0, 0, (), "")
67{
68 SCM_RETURN_NEWSMOB (asmob100, 0);
69}
70
71SCM_DEFINE (scm_make_asmob010, "make-asmob010", 0, 0, 0, (), "")
72{
73 SCM_RETURN_NEWSMOB (asmob010, 0);
74}
75
76SCM_DEFINE (scm_make_asmob001, "make-asmob001", 0, 0, 0, (), "")
77{
78 SCM_RETURN_NEWSMOB (asmob001, 0);
79}
80
81SCM_DEFINE (scm_make_asmob200, "make-asmob200", 0, 0, 0, (), "")
82{
83 SCM_RETURN_NEWSMOB (asmob200, 0);
84}
85
86SCM_DEFINE (scm_make_asmob110, "make-asmob110", 0, 0, 0, (), "")
87{
88 SCM_RETURN_NEWSMOB (asmob110, 0);
89}
90
91SCM_DEFINE (scm_make_asmob020, "make-asmob020", 0, 0, 0, (), "")
92{
93 SCM_RETURN_NEWSMOB (asmob020, 0);
94}
95
96SCM_DEFINE (scm_make_asmob101, "make-asmob101", 0, 0, 0, (), "")
97{
98 SCM_RETURN_NEWSMOB (asmob101, 0);
99}
100
101SCM_DEFINE (scm_make_asmob011, "make-asmob011", 0, 0, 0, (), "")
102{
103 SCM_RETURN_NEWSMOB (asmob011, 0);
104}
105
106SCM_DEFINE (scm_make_asmob300, "make-asmob300", 0, 0, 0, (), "")
107{
108 SCM_RETURN_NEWSMOB (asmob300, 0);
109}
110
111SCM_DEFINE (scm_make_asmob210, "make-asmob210", 0, 0, 0, (), "")
112{
113 SCM_RETURN_NEWSMOB (asmob210, 0);
114}
115
116SCM_DEFINE (scm_make_asmob120, "make-asmob120", 0, 0, 0, (), "")
117{
118 SCM_RETURN_NEWSMOB (asmob120, 0);
119}
120
121SCM_DEFINE (scm_make_asmob030, "make-asmob030", 0, 0, 0, (), "")
122{
123 SCM_RETURN_NEWSMOB (asmob030, 0);
124}
125
126SCM_DEFINE (scm_make_asmob201, "make-asmob201", 0, 0, 0, (), "")
127{
128 SCM_RETURN_NEWSMOB (asmob201, 0);
129}
130
131SCM_DEFINE (scm_make_asmob021, "make-asmob021", 0, 0, 0, (), "")
132{
133 SCM_RETURN_NEWSMOB (asmob021, 0);
134}
135
136SCM_DEFINE (scm_make_asmob111, "make-asmob111", 0, 0, 0, (), "")
137{
138 SCM_RETURN_NEWSMOB (asmob111, 0);
139}
140
141static SCM
142apply0 (SCM smob)
143{
144 return SCM_EOL;
145}
146
147static SCM
148apply1 (SCM smob, SCM a1)
149{
150 if (SCM_UNBNDP (a1)) a1 = SCM_BOOL_F;
151 return scm_list_1 (a1);
152}
153
154static SCM
155apply2 (SCM smob, SCM a1, SCM a2)
156{
157 if (SCM_UNBNDP (a1)) a1 = SCM_BOOL_F;
158 if (SCM_UNBNDP (a2)) a2 = SCM_BOOL_F;
159 return scm_list_2 (a1, a2);
160}
161
162static SCM
163apply3 (SCM smob, SCM a1, SCM a2, SCM rest)
164{
165 if (SCM_UNBNDP (a1)) a1 = SCM_BOOL_F;
166 if (SCM_UNBNDP (a2)) a2 = SCM_BOOL_F;
167 if (SCM_UNBNDP (rest)) rest = SCM_BOOL_F;
168 return scm_list_3 (a1, a2, rest);
169}
170
171void libtest_asmobs_init (void);
172
173void
174libtest_asmobs_init ()
175{
176 asmob000 = scm_make_smob_type ("asmob000", 0);
177 scm_set_smob_apply (asmob000, apply0, 0, 0, 0);
178 asmob100 = scm_make_smob_type ("asmob100", 0);
179 scm_set_smob_apply (asmob100, apply1, 1, 0, 0);
180 asmob010 = scm_make_smob_type ("asmob010", 0);
181 scm_set_smob_apply (asmob010, apply1, 0, 1, 0);
182 asmob001 = scm_make_smob_type ("asmob001", 0);
183 scm_set_smob_apply (asmob001, apply1, 0, 0, 1);
184 asmob200 = scm_make_smob_type ("asmob200", 0);
185 scm_set_smob_apply (asmob200, apply2, 2, 0, 0);
186 asmob110 = scm_make_smob_type ("asmob110", 0);
187 scm_set_smob_apply (asmob110, apply2, 1, 1, 0);
188 asmob020 = scm_make_smob_type ("asmob020", 0);
189 scm_set_smob_apply (asmob020, apply2, 0, 2, 0);
190 asmob101 = scm_make_smob_type ("asmob101", 0);
191 scm_set_smob_apply (asmob101, apply2, 1, 0, 1);
192 asmob011 = scm_make_smob_type ("asmob011", 0);
193 scm_set_smob_apply (asmob011, apply2, 0, 1, 1);
194 asmob300 = scm_make_smob_type ("asmob300", 0);
195 scm_set_smob_apply (asmob300, apply3, 3, 0, 0);
196 asmob210 = scm_make_smob_type ("asmob210", 0);
197 scm_set_smob_apply (asmob210, apply3, 2, 1, 0);
198 asmob120 = scm_make_smob_type ("asmob120", 0);
199 scm_set_smob_apply (asmob120, apply3, 1, 2, 0);
200 asmob030 = scm_make_smob_type ("asmob030", 0);
201 scm_set_smob_apply (asmob030, apply3, 0, 3, 0);
202 asmob201 = scm_make_smob_type ("asmob201", 0);
203 scm_set_smob_apply (asmob201, apply3, 2, 0, 1);
204 asmob021 = scm_make_smob_type ("asmob021", 0);
205 scm_set_smob_apply (asmob021, apply3, 0, 2, 1);
206 asmob111 = scm_make_smob_type ("asmob111", 0);
207 scm_set_smob_apply (asmob111, apply3, 1, 1, 1);
479c46ea 208# include "test-asmobs-lib.x"
896f6179 209}