annotate src/lisp-disunion.h @ 452:3d3049ae1304 r21-2-41

Import from CVS: tag r21-2-41
author cvs
date Mon, 13 Aug 2007 11:40:21 +0200
parents abe6d1db359e
children c33ae14dd6d0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Fundamental definitions for XEmacs Lisp interpreter -- non-union objects.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.30. Split out from lisp.h. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* This file has diverged greatly from FSF Emacs. Syncing is no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 longer desirable or possible */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 Format of a non-union-type Lisp Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 3 2 1 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 bit 10987654321098765432109876543210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 --------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 Integers are treated specially, and look like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 3 2 1 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 bit 10987654321098765432109876543210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 --------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 For integral Lisp types, i.e. integers and characters, the value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 bits are the Lisp object.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 The object is obtained by masking off the type and mark bits.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 Bit 1 is used as a value bit by splitting the Lisp integer type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 into two subtypes, Lisp_Type_Int_Even and Lisp_Type_Int_Odd. By
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 this trickery we get 31 bits for integers instead of 30.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 For non-integral types, the value bits of a Lisp_Object contain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 a pointer to a structure containing the object. The pointer is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 obtained by masking off the type and mark bits.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 All pointer-based types are coalesced under a single type called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 Lisp_Type_Record. The type bits for this type are required
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 by the implementation to be 00, just like the least
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 significant bits of word-aligned struct pointers on 32-bit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 hardware. Because of this, Lisp_Object pointers don't have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 to be masked and are full-sized.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 There are no mark bits.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 Integers and characters don't need to be marked. All other types
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 are lrecord-based, which means they get marked by incrementing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 their ->implementation pointer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 Here is a brief description of the following macros:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 XTYPE The type bits of a Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 XPNTRVAL The value bits of a Lisp_Object storing a pointer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 XCHARVAL The value bits of a Lisp_Object storing a Emchar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 XREALINT The value bits of a Lisp_Object storing an integer, signed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 XUINT The value bits of a Lisp_Object storing an integer, unsigned
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 INTP Non-zero if this Lisp_Object an integer?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 Qzero Lisp Integer 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 EQ Non-zero if two Lisp_Objects are identical */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 typedef EMACS_INT Lisp_Object;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 #define Lisp_Type_Int_Bit (Lisp_Type_Int_Even & Lisp_Type_Int_Odd)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
79 #define wrap_object(ptr) ((Lisp_Object) (ptr))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 #define make_int(x) ((Lisp_Object) (((x) << INT_GCBITS) | Lisp_Type_Int_Bit))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #define make_char(x) ((Lisp_Object) (((x) << GCBITS) | Lisp_Type_Char))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #define VALMASK (((1UL << VALBITS) - 1UL) << GCTYPEBITS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #define XTYPE(x) ((enum Lisp_Type) (((EMACS_UINT)(x)) & ~VALMASK))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #define XPNTRVAL(x) (x) /* This depends on Lisp_Type_Record == 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 #define XCHARVAL(x) ((x) >> GCBITS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 #define XREALINT(x) ((x) >> INT_GCBITS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 #define XUINT(x) ((EMACS_UINT)(x) >> INT_GCBITS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 #define INTP(x) ((EMACS_UINT)(x) & Lisp_Type_Int_Bit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 #define INT_PLUS(x,y) ((x)+(y)-Lisp_Type_Int_Bit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 #define INT_MINUS(x,y) ((x)-(y)+Lisp_Type_Int_Bit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 #define INT_PLUS1(x) INT_PLUS (x, make_int (1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 #define INT_MINUS1(x) INT_MINUS (x, make_int (1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 #define Qzero make_int (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 #define Qnull_pointer ((Lisp_Object) 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 #define EQ(x,y) ((x) == (y))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
97 #define XSETINT(var, value) ((void) ((var) = make_int (value)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 #define XSETCHAR(var, value) ((void) ((var) = make_char (value)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
99 #define XSETOBJ(var, value) ((void) ((var) = wrap_object (value)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 /* Convert between a (void *) and a Lisp_Object, as when the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 Lisp_Object is passed to a toolkit callback function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 #define VOID_TO_LISP(larg,varg) ((void) ((larg) = ((Lisp_Object) (varg))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 #define CVOID_TO_LISP VOID_TO_LISP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 #define LISP_TO_VOID(larg) ((void *) (larg))
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 442
diff changeset
106 #define LISP_TO_CVOID(larg) ((const void *) (larg))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 /* Convert a Lisp_Object into something that can't be used as an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 lvalue. Useful for type-checking. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 #define NON_LVALUE(larg) ((larg) + 0)