annotate src/lisp-union.h @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 8626e4521993
children 2f8bb876ab1d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Fundamental definitions for XEmacs Lisp interpreter -- union objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
22 /* Divergent from FSF. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
23
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
24 /* Definition of Lisp_Object type as a union.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
25 The declaration order of the objects within the struct members
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
26 of the union is dependent on ENDIAN-ness.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
27 See lisp-disunion.h for more details. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 typedef
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 union Lisp_Object
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
31 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
32 /* if non-valbits are at lower addresses */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
33 #if defined(WORDS_BIGENDIAN)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
34 struct
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
36 EMACS_UINT val : VALBITS;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
37 enum_field (Lisp_Type) type : GCTYPEBITS;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
38 } gu;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
39
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
40 struct
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
41 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
42 signed EMACS_INT val : INT_VALBITS;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
43 unsigned int bits : INT_GCBITS;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
44 } s;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
45
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
46 struct
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
47 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
48 EMACS_UINT val : INT_VALBITS;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
49 unsigned int bits : INT_GCBITS;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
50 } u;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
51 #else /* non-valbits are at higher addresses */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
52 struct
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
54 enum_field (Lisp_Type) type : GCTYPEBITS;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
55 EMACS_UINT val : VALBITS;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
56 } gu;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
57
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
58 struct
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
59 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
60 unsigned int bits : INT_GCBITS;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
61 signed EMACS_INT val : INT_VALBITS;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
62 } s;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
63
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 185
diff changeset
64 struct
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 185
diff changeset
65 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
66 unsigned int bits : INT_GCBITS;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
67 EMACS_UINT val : INT_VALBITS;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
68 } u;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
69
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
70 #endif /* non-valbits are at higher addresses */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
71
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 185
diff changeset
72 EMACS_UINT ui;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
73 signed EMACS_INT i;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
74
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
75 /* This was formerly declared 'void *v' etc. but that causes
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
76 GCC to accept any (yes, any) pointer as the argument of
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
77 a function declared to accept a Lisp_Object. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
78 struct nosuchstruct *v;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
79 const struct nosuchstruct *cv;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
80 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 Lisp_Object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
83 #define XCHARVAL(x) ((x).gu.val)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
84
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
85 # define XSETINT(var, value) do { \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
86 EMACS_INT xset_value = (value); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
87 Lisp_Object *xset_var = &(var); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
88 xset_var->s.bits = 1; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
89 xset_var->s.val = xset_value; \
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
90 } while (0)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
91 # define XSETCHAR(var, value) do { \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
92 Emchar xset_value = (value); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
93 Lisp_Object *xset_var = &(var); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
94 xset_var->gu.type = Lisp_Type_Char; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
95 xset_var->gu.val = xset_value; \
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
96 } while (0)
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
97 # define XSETOBJ(var, vartype, value) do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
98 EMACS_UINT xset_value = (EMACS_UINT) (value); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
99 (var).ui = xset_value; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
100 } while (0)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
101 # define XPNTRVAL(x) ((x).ui)
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
102
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
103 INLINE Lisp_Object make_int (EMACS_INT val);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
104 INLINE Lisp_Object
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
105 make_int (EMACS_INT val)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
106 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
107 Lisp_Object obj;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
108 XSETINT(obj, val);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
109 return obj;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
110 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
112 INLINE Lisp_Object make_char (Emchar val);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
113 INLINE Lisp_Object
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
114 make_char (Emchar val)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
115 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
116 Lisp_Object obj;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
117 XSETCHAR(obj, val);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
118 return obj;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
119 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
121 extern Lisp_Object Qnull_pointer, Qzero;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
122
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
123 #define XREALINT(x) ((x).s.val)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
124 #define XUINT(x) ((x).u.val)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
125 #define XTYPE(x) ((x).gu.type)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
126 #define EQ(x,y) ((x).v == (y).v)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
128 #define INTP(x) ((x).s.bits)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
129 #define INT_PLUS(x,y) make_int (XINT (x) + XINT (y))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
130 #define INT_MINUS(x,y) make_int (XINT (x) - XINT (y))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
131 #define INT_PLUS1(x) make_int (XINT (x) + 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
132 #define INT_MINUS1(x) make_int (XINT (x) - 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
134 /* Convert between a (void *) and a Lisp_Object, as when the
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
135 Lisp_Object is passed to a toolkit callback function */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 #define VOID_TO_LISP(larg,varg) \
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
137 ((void) ((larg).v = (struct nosuchstruct *) (varg)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 #define CVOID_TO_LISP(larg,varg) \
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
139 ((void) ((larg).cv = (const struct nosuchstruct *) (varg)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 #define LISP_TO_VOID(larg) ((void *) ((larg).v))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
141 #define LISP_TO_CVOID(larg) ((const void *) ((larg).cv))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 /* Convert a Lisp_Object into something that can't be used as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 lvalue. Useful for type-checking. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 #if (__GNUC__ > 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 #define NON_LVALUE(larg) ({ (larg); })
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 /* Well, you can't really do it without using a function call, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 there's no real point in that; no-union-type is the rule, and that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 will catch errors. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 #define NON_LVALUE(larg) (larg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 #endif