]> git.donarmstrong.com Git - lilypond.git/blob - guile18/libguile/pairs.h
New upstream version 2.19.65
[lilypond.git] / guile18 / libguile / pairs.h
1 /* classes: h_files */
2
3 #ifndef SCM_PAIRS_H
4 #define SCM_PAIRS_H
5
6 /* Copyright (C) 1995,1996,2000,2001, 2004, 2006, 2008 Free Software Foundation, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library 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 GNU
16  * Lesser General Public License for more details.
17  *
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
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22
23 \f
24
25 #include "libguile/__scm.h"
26
27 \f
28
29 #if (SCM_DEBUG_PAIR_ACCESSES == 1)
30 # define SCM_VALIDATE_PAIR(cell, expr) \
31     ((!scm_is_pair (cell) ? scm_error_pair_access (cell), 0 : 0), (expr))
32 #else
33 # define SCM_VALIDATE_PAIR(cell, expr) (expr)
34 #endif
35
36 #define scm_is_null(x)          (scm_is_eq ((x), SCM_EOL))
37
38 #define SCM_CAR(x)              (SCM_VALIDATE_PAIR (x, SCM_CELL_OBJECT_0 (x)))
39 #define SCM_CDR(x)              (SCM_VALIDATE_PAIR (x, SCM_CELL_OBJECT_1 (x)))
40
41 #define SCM_SETCAR(x, v)        (SCM_VALIDATE_PAIR (x, SCM_SET_CELL_OBJECT_0 ((x), (v))))
42 #define SCM_SETCDR(x, v)        (SCM_VALIDATE_PAIR (x, SCM_SET_CELL_OBJECT_1 ((x), (v))))
43
44 #define SCM_CAAR(OBJ)           SCM_CAR (SCM_CAR (OBJ))
45 #define SCM_CDAR(OBJ)           SCM_CDR (SCM_CAR (OBJ))
46 #define SCM_CADR(OBJ)           SCM_CAR (SCM_CDR (OBJ))
47 #define SCM_CDDR(OBJ)           SCM_CDR (SCM_CDR (OBJ))
48
49 #define SCM_CAAAR(OBJ)          SCM_CAR (SCM_CAR (SCM_CAR (OBJ)))
50 #define SCM_CDAAR(OBJ)          SCM_CDR (SCM_CAR (SCM_CAR (OBJ)))
51 #define SCM_CADAR(OBJ)          SCM_CAR (SCM_CDR (SCM_CAR (OBJ)))
52 #define SCM_CDDAR(OBJ)          SCM_CDR (SCM_CDR (SCM_CAR (OBJ)))
53 #define SCM_CAADR(OBJ)          SCM_CAR (SCM_CAR (SCM_CDR (OBJ)))
54 #define SCM_CDADR(OBJ)          SCM_CDR (SCM_CAR (SCM_CDR (OBJ)))
55 #define SCM_CADDR(OBJ)          SCM_CAR (SCM_CDR (SCM_CDR (OBJ)))
56 #define SCM_CDDDR(OBJ)          SCM_CDR (SCM_CDR (SCM_CDR (OBJ)))
57
58 #define SCM_CAAAAR(OBJ)         SCM_CAR (SCM_CAR (SCM_CAR (SCM_CAR (OBJ))))
59 #define SCM_CDAAAR(OBJ)         SCM_CDR (SCM_CAR (SCM_CAR (SCM_CAR (OBJ))))
60 #define SCM_CADAAR(OBJ)         SCM_CAR (SCM_CDR (SCM_CAR (SCM_CAR (OBJ))))
61 #define SCM_CDDAAR(OBJ)         SCM_CDR (SCM_CDR (SCM_CAR (SCM_CAR (OBJ))))
62 #define SCM_CAADAR(OBJ)         SCM_CAR (SCM_CAR (SCM_CDR (SCM_CAR (OBJ))))
63 #define SCM_CDADAR(OBJ)         SCM_CDR (SCM_CAR (SCM_CDR (SCM_CAR (OBJ))))
64 #define SCM_CADDAR(OBJ)         SCM_CAR (SCM_CDR (SCM_CDR (SCM_CAR (OBJ))))
65 #define SCM_CDDDAR(OBJ)         SCM_CDR (SCM_CDR (SCM_CDR (SCM_CAR (OBJ))))
66 #define SCM_CAAADR(OBJ)         SCM_CAR (SCM_CAR (SCM_CAR (SCM_CDR (OBJ))))
67 #define SCM_CDAADR(OBJ)         SCM_CDR (SCM_CAR (SCM_CAR (SCM_CDR (OBJ))))
68 #define SCM_CADADR(OBJ)         SCM_CAR (SCM_CDR (SCM_CAR (SCM_CDR (OBJ))))
69 #define SCM_CDDADR(OBJ)         SCM_CDR (SCM_CDR (SCM_CAR (SCM_CDR (OBJ))))
70 #define SCM_CAADDR(OBJ)         SCM_CAR (SCM_CAR (SCM_CDR (SCM_CDR (OBJ))))
71 #define SCM_CDADDR(OBJ)         SCM_CDR (SCM_CAR (SCM_CDR (SCM_CDR (OBJ))))
72 #define SCM_CADDDR(OBJ)         SCM_CAR (SCM_CDR (SCM_CDR (SCM_CDR (OBJ))))
73 #define SCM_CDDDDR(OBJ)         SCM_CDR (SCM_CDR (SCM_CDR (SCM_CDR (OBJ))))
74
75 \f
76
77 #if (SCM_DEBUG_PAIR_ACCESSES == 1)
78 SCM_API void scm_error_pair_access (SCM);
79 #endif
80
81 SCM_API SCM scm_cons (SCM x, SCM y);
82 SCM_API SCM scm_cons2 (SCM w, SCM x, SCM y);
83 SCM_API SCM scm_pair_p (SCM x);
84 SCM_API SCM scm_car (SCM x);
85 SCM_API SCM scm_cdr (SCM x);
86 SCM_API SCM scm_set_car_x (SCM pair, SCM value);
87 SCM_API SCM scm_set_cdr_x (SCM pair, SCM value);
88
89 #define SCM_I_D_PAT    0x02 /* 00000010 */
90 #define SCM_I_A_PAT    0x03 /* 00000011 */
91 #define SCM_I_DD_PAT   0x0a /* 00001010 */
92 #define SCM_I_DA_PAT   0x0b /* 00001011 */
93 #define SCM_I_AD_PAT   0x0e /* 00001110 */
94 #define SCM_I_AA_PAT   0x0f /* 00001111 */
95 #define SCM_I_DDD_PAT  0x2a /* 00101010 */
96 #define SCM_I_DDA_PAT  0x2b /* 00101011 */
97 #define SCM_I_DAD_PAT  0x2e /* 00101110 */
98 #define SCM_I_DAA_PAT  0x2f /* 00101111 */
99 #define SCM_I_ADD_PAT  0x3a /* 00111010 */
100 #define SCM_I_ADA_PAT  0x3b /* 00111011 */
101 #define SCM_I_AAD_PAT  0x3e /* 00111110 */
102 #define SCM_I_AAA_PAT  0x3f /* 00111111 */
103 #define SCM_I_DDDD_PAT 0xaa /* 10101010 */
104 #define SCM_I_DDDA_PAT 0xab /* 10101011 */
105 #define SCM_I_DDAD_PAT 0xae /* 10101110 */
106 #define SCM_I_DDAA_PAT 0xaf /* 10101111 */
107 #define SCM_I_DADD_PAT 0xba /* 10111010 */
108 #define SCM_I_DADA_PAT 0xbb /* 10111011 */
109 #define SCM_I_DAAD_PAT 0xbe /* 10111110 */
110 #define SCM_I_DAAA_PAT 0xbf /* 10111111 */
111 #define SCM_I_ADDD_PAT 0xea /* 11101010 */
112 #define SCM_I_ADDA_PAT 0xeb /* 11101011 */
113 #define SCM_I_ADAD_PAT 0xee /* 11101110 */
114 #define SCM_I_ADAA_PAT 0xef /* 11101111 */
115 #define SCM_I_AADD_PAT 0xfa /* 11111010 */
116 #define SCM_I_AADA_PAT 0xfb /* 11111011 */
117 #define SCM_I_AAAD_PAT 0xfe /* 11111110 */
118 #define SCM_I_AAAA_PAT 0xff /* 11111111 */
119
120 SCM_API SCM scm_i_chase_pairs (SCM x, scm_t_uint32 pattern);
121
122 #define scm_cddr(x)   scm_i_chase_pairs ((x), SCM_I_DD_PAT)
123 #define scm_cdar(x)   scm_i_chase_pairs ((x), SCM_I_DA_PAT)
124 #define scm_cadr(x)   scm_i_chase_pairs ((x), SCM_I_AD_PAT)
125 #define scm_caar(x)   scm_i_chase_pairs ((x), SCM_I_AA_PAT)
126 #define scm_cdddr(x)  scm_i_chase_pairs ((x), SCM_I_DDD_PAT)
127 #define scm_cddar(x)  scm_i_chase_pairs ((x), SCM_I_DDA_PAT)
128 #define scm_cdadr(x)  scm_i_chase_pairs ((x), SCM_I_DAD_PAT)
129 #define scm_cdaar(x)  scm_i_chase_pairs ((x), SCM_I_DAA_PAT)
130 #define scm_caddr(x)  scm_i_chase_pairs ((x), SCM_I_ADD_PAT)
131 #define scm_cadar(x)  scm_i_chase_pairs ((x), SCM_I_ADA_PAT)
132 #define scm_caadr(x)  scm_i_chase_pairs ((x), SCM_I_AAD_PAT)
133 #define scm_caaar(x)  scm_i_chase_pairs ((x), SCM_I_AAA_PAT)
134 #define scm_cddddr(x) scm_i_chase_pairs ((x), SCM_I_DDDD_PAT)
135 #define scm_cdddar(x) scm_i_chase_pairs ((x), SCM_I_DDDA_PAT)
136 #define scm_cddadr(x) scm_i_chase_pairs ((x), SCM_I_DDAD_PAT)
137 #define scm_cddaar(x) scm_i_chase_pairs ((x), SCM_I_DDAA_PAT)
138 #define scm_cdaddr(x) scm_i_chase_pairs ((x), SCM_I_DADD_PAT)
139 #define scm_cdadar(x) scm_i_chase_pairs ((x), SCM_I_DADA_PAT)
140 #define scm_cdaadr(x) scm_i_chase_pairs ((x), SCM_I_DAAD_PAT)
141 #define scm_cdaaar(x) scm_i_chase_pairs ((x), SCM_I_DAAA_PAT)
142 #define scm_cadddr(x) scm_i_chase_pairs ((x), SCM_I_ADDD_PAT)
143 #define scm_caddar(x) scm_i_chase_pairs ((x), SCM_I_ADDA_PAT)
144 #define scm_cadadr(x) scm_i_chase_pairs ((x), SCM_I_ADAD_PAT)
145 #define scm_cadaar(x) scm_i_chase_pairs ((x), SCM_I_ADAA_PAT)
146 #define scm_caaddr(x) scm_i_chase_pairs ((x), SCM_I_AADD_PAT)
147 #define scm_caadar(x) scm_i_chase_pairs ((x), SCM_I_AADA_PAT)
148 #define scm_caaadr(x) scm_i_chase_pairs ((x), SCM_I_AAAD_PAT)
149 #define scm_caaaar(x) scm_i_chase_pairs ((x), SCM_I_AAAA_PAT)
150
151 SCM_API void scm_init_pairs (void);
152
153 #endif  /* SCM_PAIRS_H */
154
155 /*
156   Local Variables:
157   c-file-style: "gnu"
158   End:
159 */