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