Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* classes: h_files */ |
2 | ||
e81d98ec DH |
3 | #ifndef SCM_PAIRS_H |
4 | #define SCM_PAIRS_H | |
0527e687 | 5 | |
c1b7c940 | 6 | /* Copyright (C) 1995,1996,2000,2001, 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. |
0527e687 | 7 | * |
73be1d9e | 8 | * This library is free software; you can redistribute it and/or |
53befeb7 NJ |
9 | * modify it under the terms of the GNU Lesser General Public License |
10 | * as published by the Free Software Foundation; either version 3 of | |
11 | * the License, or (at your option) any later version. | |
0527e687 | 12 | * |
53befeb7 NJ |
13 | * This library is distributed in the hope that it will be useful, but |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
73be1d9e MV |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. | |
0527e687 | 17 | * |
73be1d9e MV |
18 | * You should have received a copy of the GNU Lesser General Public |
19 | * License along with this library; if not, write to the Free Software | |
53befeb7 NJ |
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
21 | * 02110-1301 USA | |
73be1d9e | 22 | */ |
1bbd0b84 | 23 | |
0f2d19dd JB |
24 | \f |
25 | ||
b4309c3c | 26 | #include "libguile/__scm.h" |
0f2d19dd JB |
27 | |
28 | \f | |
29 | ||
e81d98ec | 30 | #if (SCM_DEBUG_PAIR_ACCESSES == 1) |
e81d98ec | 31 | # define SCM_VALIDATE_PAIR(cell, expr) \ |
6fcc7d48 | 32 | ((!scm_is_pair (cell) ? scm_error_pair_access (cell), 0 : 0), (expr)) |
e81d98ec DH |
33 | #else |
34 | # define SCM_VALIDATE_PAIR(cell, expr) (expr) | |
35 | #endif | |
36 | ||
45f4cbdf MW |
37 | /* |
38 | * Use scm_is_null_and_not_nil if it's important (for correctness) | |
92a61010 | 39 | * that #nil must NOT be considered null. |
45f4cbdf MW |
40 | */ |
41 | #define scm_is_null_and_not_nil(x) (scm_is_eq ((x), SCM_EOL)) | |
42 | ||
43 | /* | |
92a61010 AW |
44 | * Use scm_is_null_assume_not_nil if |
45 | #nil will never be tested, | |
45f4cbdf MW |
46 | * for increased efficiency. |
47 | */ | |
48 | #define scm_is_null_assume_not_nil(x) (scm_is_eq ((x), SCM_EOL)) | |
49 | ||
50 | /* | |
51 | * See the comments preceeding the definitions of SCM_BOOL_F and | |
52 | * SCM_MATCHES_BITS_IN_COMMON in tags.h for more information on | |
53 | * how the following macro works. | |
54 | */ | |
c1b7c940 | 55 | #define scm_is_null_or_nil(x) \ |
45f4cbdf | 56 | (SCM_MATCHES_BITS_IN_COMMON ((x), SCM_ELISP_NIL, SCM_EOL)) |
45f4cbdf | 57 | |
cd038da5 | 58 | |
8a4ed2dd AW |
59 | \f |
60 | ||
61 | /* Older spellings for these null, nil, and pair predicates. */ | |
cd038da5 AW |
62 | #define SCM_NILP(x) (scm_is_eq ((x), SCM_ELISP_NIL)) |
63 | #define SCM_NULL_OR_NIL_P(x) (scm_is_null_or_nil (x)) | |
8a4ed2dd AW |
64 | #define SCM_NULLP(x) (scm_is_null (x)) |
65 | #define SCM_NNULLP(x) (!scm_is_null (x)) | |
66 | #define SCM_CONSP(x) (scm_is_pair (x)) | |
67 | #define SCM_NCONSP(x) (!SCM_CONSP (x)) | |
cd038da5 AW |
68 | |
69 | ||
8a4ed2dd AW |
70 | \f |
71 | ||
92a61010 | 72 | /* #nil is null. */ |
2533f10b | 73 | #define scm_is_null(x) (scm_is_null_or_nil(x)) |
0f2d19dd | 74 | |
e81d98ec DH |
75 | #define SCM_CAR(x) (SCM_VALIDATE_PAIR (x, SCM_CELL_OBJECT_0 (x))) |
76 | #define SCM_CDR(x) (SCM_VALIDATE_PAIR (x, SCM_CELL_OBJECT_1 (x))) | |
76a369d9 | 77 | |
e81d98ec DH |
78 | #define SCM_SETCAR(x, v) (SCM_VALIDATE_PAIR (x, SCM_SET_CELL_OBJECT_0 ((x), (v)))) |
79 | #define SCM_SETCDR(x, v) (SCM_VALIDATE_PAIR (x, SCM_SET_CELL_OBJECT_1 ((x), (v)))) | |
24e68a57 | 80 | |
0f2d19dd JB |
81 | #define SCM_CAAR(OBJ) SCM_CAR (SCM_CAR (OBJ)) |
82 | #define SCM_CDAR(OBJ) SCM_CDR (SCM_CAR (OBJ)) | |
83 | #define SCM_CADR(OBJ) SCM_CAR (SCM_CDR (OBJ)) | |
84 | #define SCM_CDDR(OBJ) SCM_CDR (SCM_CDR (OBJ)) | |
85 | ||
86 | #define SCM_CAAAR(OBJ) SCM_CAR (SCM_CAR (SCM_CAR (OBJ))) | |
87 | #define SCM_CDAAR(OBJ) SCM_CDR (SCM_CAR (SCM_CAR (OBJ))) | |
88 | #define SCM_CADAR(OBJ) SCM_CAR (SCM_CDR (SCM_CAR (OBJ))) | |
89 | #define SCM_CDDAR(OBJ) SCM_CDR (SCM_CDR (SCM_CAR (OBJ))) | |
90 | #define SCM_CAADR(OBJ) SCM_CAR (SCM_CAR (SCM_CDR (OBJ))) | |
91 | #define SCM_CDADR(OBJ) SCM_CDR (SCM_CAR (SCM_CDR (OBJ))) | |
92 | #define SCM_CADDR(OBJ) SCM_CAR (SCM_CDR (SCM_CDR (OBJ))) | |
93 | #define SCM_CDDDR(OBJ) SCM_CDR (SCM_CDR (SCM_CDR (OBJ))) | |
94 | ||
95 | #define SCM_CAAAAR(OBJ) SCM_CAR (SCM_CAR (SCM_CAR (SCM_CAR (OBJ)))) | |
96 | #define SCM_CDAAAR(OBJ) SCM_CDR (SCM_CAR (SCM_CAR (SCM_CAR (OBJ)))) | |
97 | #define SCM_CADAAR(OBJ) SCM_CAR (SCM_CDR (SCM_CAR (SCM_CAR (OBJ)))) | |
98 | #define SCM_CDDAAR(OBJ) SCM_CDR (SCM_CDR (SCM_CAR (SCM_CAR (OBJ)))) | |
99 | #define SCM_CAADAR(OBJ) SCM_CAR (SCM_CAR (SCM_CDR (SCM_CAR (OBJ)))) | |
100 | #define SCM_CDADAR(OBJ) SCM_CDR (SCM_CAR (SCM_CDR (SCM_CAR (OBJ)))) | |
101 | #define SCM_CADDAR(OBJ) SCM_CAR (SCM_CDR (SCM_CDR (SCM_CAR (OBJ)))) | |
102 | #define SCM_CDDDAR(OBJ) SCM_CDR (SCM_CDR (SCM_CDR (SCM_CAR (OBJ)))) | |
103 | #define SCM_CAAADR(OBJ) SCM_CAR (SCM_CAR (SCM_CAR (SCM_CDR (OBJ)))) | |
104 | #define SCM_CDAADR(OBJ) SCM_CDR (SCM_CAR (SCM_CAR (SCM_CDR (OBJ)))) | |
105 | #define SCM_CADADR(OBJ) SCM_CAR (SCM_CDR (SCM_CAR (SCM_CDR (OBJ)))) | |
106 | #define SCM_CDDADR(OBJ) SCM_CDR (SCM_CDR (SCM_CAR (SCM_CDR (OBJ)))) | |
107 | #define SCM_CAADDR(OBJ) SCM_CAR (SCM_CAR (SCM_CDR (SCM_CDR (OBJ)))) | |
108 | #define SCM_CDADDR(OBJ) SCM_CDR (SCM_CAR (SCM_CDR (SCM_CDR (OBJ)))) | |
109 | #define SCM_CADDDR(OBJ) SCM_CAR (SCM_CDR (SCM_CDR (SCM_CDR (OBJ)))) | |
110 | #define SCM_CDDDDR(OBJ) SCM_CDR (SCM_CDR (SCM_CDR (SCM_CDR (OBJ)))) | |
111 | ||
0f2d19dd | 112 | \f |
1cc91f1b | 113 | |
e81d98ec | 114 | #if (SCM_DEBUG_PAIR_ACCESSES == 1) |
33b001fd | 115 | SCM_API void scm_error_pair_access (SCM); |
e81d98ec | 116 | #endif |
6fcc7d48 | 117 | |
33b001fd MV |
118 | SCM_API SCM scm_cons (SCM x, SCM y); |
119 | SCM_API SCM scm_cons2 (SCM w, SCM x, SCM y); | |
120 | SCM_API SCM scm_pair_p (SCM x); | |
ddda5e8f MV |
121 | SCM_API SCM scm_car (SCM x); |
122 | SCM_API SCM scm_cdr (SCM x); | |
33b001fd MV |
123 | SCM_API SCM scm_set_car_x (SCM pair, SCM value); |
124 | SCM_API SCM scm_set_cdr_x (SCM pair, SCM value); | |
ddda5e8f | 125 | |
f36878ba AW |
126 | SCM_API SCM scm_cddr (SCM x); |
127 | SCM_API SCM scm_cdar (SCM x); | |
128 | SCM_API SCM scm_cadr (SCM x); | |
129 | SCM_API SCM scm_caar (SCM x); | |
130 | SCM_API SCM scm_cdddr (SCM x); | |
131 | SCM_API SCM scm_cddar (SCM x); | |
132 | SCM_API SCM scm_cdadr (SCM x); | |
133 | SCM_API SCM scm_cdaar (SCM x); | |
134 | SCM_API SCM scm_caddr (SCM x); | |
135 | SCM_API SCM scm_cadar (SCM x); | |
136 | SCM_API SCM scm_caadr (SCM x); | |
137 | SCM_API SCM scm_caaar (SCM x); | |
138 | SCM_API SCM scm_cddddr (SCM x); | |
139 | SCM_API SCM scm_cdddar (SCM x); | |
140 | SCM_API SCM scm_cddadr (SCM x); | |
141 | SCM_API SCM scm_cddaar (SCM x); | |
142 | SCM_API SCM scm_cdaddr (SCM x); | |
143 | SCM_API SCM scm_cdadar (SCM x); | |
144 | SCM_API SCM scm_cdaadr (SCM x); | |
145 | SCM_API SCM scm_cdaaar (SCM x); | |
146 | SCM_API SCM scm_cadddr (SCM x); | |
147 | SCM_API SCM scm_caddar (SCM x); | |
148 | SCM_API SCM scm_cadadr (SCM x); | |
149 | SCM_API SCM scm_cadaar (SCM x); | |
150 | SCM_API SCM scm_caaddr (SCM x); | |
151 | SCM_API SCM scm_caadar (SCM x); | |
152 | SCM_API SCM scm_caaadr (SCM x); | |
153 | SCM_API SCM scm_caaaar (SCM x); | |
ddda5e8f | 154 | |
102dbb6f | 155 | SCM_INTERNAL void scm_init_pairs (void); |
1cc91f1b | 156 | |
e81d98ec | 157 | #endif /* SCM_PAIRS_H */ |
89e00824 ML |
158 | |
159 | /* | |
160 | Local Variables: | |
161 | c-file-style: "gnu" | |
162 | End: | |
163 | */ |