428
+ − 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. */
+ − 22 /* This file has diverged greatly from FSF Emacs. Syncing is no
+ − 23 longer desirable or possible */
+ − 24
+ − 25 /*
+ − 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
458
+ − 41 bits are the Lisp object. Some people call such Lisp_Objects "immediate".
428
+ − 42
458
+ − 43 The object is obtained by masking off the type bits.
462
+ − 44 Bit 1 is used as a value bit by splitting the Lisp integer type
458
+ − 45 into two subtypes, Lisp_Type_Int_Even and Lisp_Type_Int_Odd.
+ − 46 By this trickery we get 31 bits for integers instead of 30.
428
+ − 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
462
+ − 52 All pointer-based types are coalesced under a single type called
458
+ − 53 Lisp_Type_Record. The type bits for this type are required by the
+ − 54 implementation to be 00, just like the least significant bits of
+ − 55 word-aligned struct pointers on 32-bit hardware. This requires that
+ − 56 all structs implementing Lisp_Objects have an alignment of at least 4
+ − 57 bytes. Because of this, Lisp_Object pointers don't have to be masked
+ − 58 and are full-sized.
428
+ − 59
458
+ − 60 There are no mark bits in the Lisp_Object itself (there used to be).
+ − 61
+ − 62 Integers and characters don't need to be marked. All other types are
+ − 63 lrecord-based, which means they get marked by setting the mark bit in
+ − 64 the struct lrecord_header.
428
+ − 65
+ − 66 Here is a brief description of the following macros:
+ − 67
+ − 68 XTYPE The type bits of a Lisp_Object
+ − 69 XPNTRVAL The value bits of a Lisp_Object storing a pointer
+ − 70 XCHARVAL The value bits of a Lisp_Object storing a Emchar
+ − 71 XREALINT The value bits of a Lisp_Object storing an integer, signed
+ − 72 XUINT The value bits of a Lisp_Object storing an integer, unsigned
458
+ − 73 INTP Non-zero if this Lisp_Object is an integer
428
+ − 74 Qzero Lisp Integer 0
458
+ − 75 EQ Non-zero if two Lisp_Objects are identical, not merely equal. */
428
+ − 76
+ − 77
+ − 78 typedef EMACS_INT Lisp_Object;
+ − 79
+ − 80 #define Lisp_Type_Int_Bit (Lisp_Type_Int_Even & Lisp_Type_Int_Odd)
617
+ − 81 #define wrap_pointer_1(ptr) ((Lisp_Object) (ptr))
428
+ − 82 #define make_int(x) ((Lisp_Object) (((x) << INT_GCBITS) | Lisp_Type_Int_Bit))
+ − 83 #define make_char(x) ((Lisp_Object) (((x) << GCBITS) | Lisp_Type_Char))
+ − 84 #define VALMASK (((1UL << VALBITS) - 1UL) << GCTYPEBITS)
+ − 85 #define XTYPE(x) ((enum Lisp_Type) (((EMACS_UINT)(x)) & ~VALMASK))
+ − 86 #define XPNTRVAL(x) (x) /* This depends on Lisp_Type_Record == 0 */
+ − 87 #define XCHARVAL(x) ((x) >> GCBITS)
+ − 88 #define XREALINT(x) ((x) >> INT_GCBITS)
+ − 89 #define XUINT(x) ((EMACS_UINT)(x) >> INT_GCBITS)
+ − 90 #define INTP(x) ((EMACS_UINT)(x) & Lisp_Type_Int_Bit)
+ − 91 #define INT_PLUS(x,y) ((x)+(y)-Lisp_Type_Int_Bit)
+ − 92 #define INT_MINUS(x,y) ((x)-(y)+Lisp_Type_Int_Bit)
+ − 93 #define INT_PLUS1(x) INT_PLUS (x, make_int (1))
+ − 94 #define INT_MINUS1(x) INT_MINUS (x, make_int (1))
+ − 95
+ − 96 #define Qzero make_int (0)
+ − 97 #define Qnull_pointer ((Lisp_Object) 0)
+ − 98 #define EQ(x,y) ((x) == (y))
442
+ − 99 #define XSETINT(var, value) ((void) ((var) = make_int (value)))
428
+ − 100 #define XSETCHAR(var, value) ((void) ((var) = make_char (value)))
617
+ − 101 #define XSETOBJ(var, value) ((void) ((var) = wrap_pointer_1 (value)))
428
+ − 102
+ − 103 /* Convert between a (void *) and a Lisp_Object, as when the
+ − 104 Lisp_Object is passed to a toolkit callback function */
+ − 105 #define VOID_TO_LISP(larg,varg) ((void) ((larg) = ((Lisp_Object) (varg))))
+ − 106 #define CVOID_TO_LISP VOID_TO_LISP
+ − 107 #define LISP_TO_VOID(larg) ((void *) (larg))
452
+ − 108 #define LISP_TO_CVOID(larg) ((const void *) (larg))
428
+ − 109
+ − 110 /* Convert a Lisp_Object into something that can't be used as an
+ − 111 lvalue. Useful for type-checking. */
+ − 112 #define NON_LVALUE(larg) ((larg) + 0)