Mercurial > hg > xemacs-beta
comparison src/lisp.h @ 207:e45d5e7c476e r20-4b2
Import from CVS: tag r20-4b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:03:52 +0200 |
parents | eb5470882647 |
children | 41ff10fd062f |
comparison
equal
deleted
inserted
replaced
206:d3e9274cbc4e | 207:e45d5e7c476e |
---|---|
628 | 628 |
629 /************************************************************************/ | 629 /************************************************************************/ |
630 /* Definition of Lisp_Object data type */ | 630 /* Definition of Lisp_Object data type */ |
631 /************************************************************************/ | 631 /************************************************************************/ |
632 | 632 |
633 /* There's not any particular reason not to use lrecords for these; some | 633 #ifdef USE_MINIMAL_TAGBITS |
634 objects get slightly larger, but we get 3 bit tags instead of 4. | 634 # define LRECORD_CONS |
635 */ | 635 # define LRECORD_VECTOR |
636 /* #define LRECORD_SYMBOL */ | 636 # define LRECORD_SYMBOL |
637 | 637 # define LRECORD_STRING |
638 #endif | |
638 | 639 |
639 /* Define the fundamental Lisp data structures */ | 640 /* Define the fundamental Lisp data structures */ |
640 | 641 |
641 /* This is the set of Lisp data types */ | 642 /* This is the set of Lisp data types */ |
642 | 643 |
644 #ifndef USE_MINIMAL_TAGBITS | |
645 | |
643 enum Lisp_Type | 646 enum Lisp_Type |
644 { | 647 { |
645 /* Integer. XINT(obj) is the integer value. */ | 648 /* Integer. XINT(obj) is the integer value. */ |
646 Lisp_Type_Int, /* 0 DTP-FIXNUM */ | 649 Lisp_Type_Int, |
647 | 650 |
648 /* XRECORD_LHEADER (object) points to a struct lrecord_header | 651 /* XRECORD_LHEADER (object) points to a struct lrecord_header |
649 lheader->implementation determines the type (and GC behaviour) | 652 lheader->implementation determines the type (and GC behaviour) |
650 of the object. */ | 653 of the object. */ |
651 Lisp_Type_Record, /* 1 DTP-OTHER-POINTER */ | 654 Lisp_Type_Record, |
652 | 655 |
656 #ifndef LRECORD_CONS | |
653 /* Cons. XCONS (object) points to a struct Lisp_Cons. */ | 657 /* Cons. XCONS (object) points to a struct Lisp_Cons. */ |
654 Lisp_Type_Cons, /* 2 DTP-LIST */ | 658 Lisp_Type_Cons, |
655 | 659 #endif |
656 /* LRECORD_STRING is NYI */ | 660 |
661 #ifndef LRECORD_STRING | |
657 /* String. XSTRING (object) points to a struct Lisp_String. | 662 /* String. XSTRING (object) points to a struct Lisp_String. |
658 The length of the string, and its contents, are stored therein. */ | 663 The length of the string, and its contents, are stored therein. */ |
659 Lisp_Type_String, /* 3 DTP-STRING */ | 664 Lisp_Type_String, |
665 #endif | |
660 | 666 |
661 #ifndef LRECORD_VECTOR | 667 #ifndef LRECORD_VECTOR |
662 /* Vector of Lisp objects. XVECTOR(object) points to a struct Lisp_Vector. | 668 /* Vector of Lisp objects. XVECTOR(object) points to a struct Lisp_Vector. |
663 The length of the vector, and its contents, are stored therein. */ | 669 The length of the vector, and its contents, are stored therein. */ |
664 Lisp_Type_Vector, /* 4 DTP-SIMPLE-ARRAY */ | 670 Lisp_Type_Vector, |
665 #endif /* !LRECORD_VECTOR */ | 671 #endif /* !LRECORD_VECTOR */ |
666 | 672 |
667 #ifndef LRECORD_SYMBOL | 673 #ifndef LRECORD_SYMBOL |
668 /* Symbol. XSYMBOL (object) points to a struct Lisp_Symbol. */ | 674 /* Symbol. XSYMBOL (object) points to a struct Lisp_Symbol. */ |
669 Lisp_Type_Symbol, | 675 Lisp_Type_Symbol, |
670 #endif /* !LRECORD_SYMBOL */ | 676 #endif /* !LRECORD_SYMBOL */ |
671 | 677 |
672 Lisp_Type_Char /* 5 DTP-CHAR */ | 678 Lisp_Type_Char |
673 }; | 679 }; |
674 | 680 |
675 /* unsafe! */ | 681 # define POINTER_TYPE_P(type) \ |
676 #define POINTER_TYPE_P(type) ((type) != Lisp_Type_Int && (type) != Lisp_Type_Char) | 682 ((type) != Lisp_Type_Int && (type) != Lisp_Type_Char) |
683 | |
684 #else | |
685 | |
686 enum Lisp_Type | |
687 { | |
688 Lisp_Type_Record, | |
689 Lisp_Type_Int_Even, | |
690 Lisp_Type_Char, | |
691 Lisp_Type_Int_Odd | |
692 }; | |
693 | |
694 #define POINTER_TYPE_P(type) ((type) == Lisp_Type_Record) | |
695 | |
696 #endif | |
677 | 697 |
678 /* This should be the underlying type into which a Lisp_Object must fit. | 698 /* This should be the underlying type into which a Lisp_Object must fit. |
679 In a strict ANSI world, this must be `int', since ANSI says you can't | 699 In a strict ANSI world, this must be `int', since ANSI says you can't |
680 use bitfields on any type other than `int'. However, on a machine | 700 use bitfields on any type other than `int'. However, on a machine |
681 where `int' and `long' are not the same size, this should be the | 701 where `int' and `long' are not the same size, this should be the |
695 # define ASSERT_VALID_POINTER(pnt) (assert ((((EMACS_UINT) pnt) & 3) == 0)) | 715 # define ASSERT_VALID_POINTER(pnt) (assert ((((EMACS_UINT) pnt) & 3) == 0)) |
696 #endif | 716 #endif |
697 | 717 |
698 /* These values are overridden by the m- file on some machines. */ | 718 /* These values are overridden by the m- file on some machines. */ |
699 #ifndef GCTYPEBITS | 719 #ifndef GCTYPEBITS |
700 # define GCTYPEBITS 3L | 720 # ifdef USE_MINIMAL_TAGBITS |
721 # define GCTYPEBITS 2L | |
722 # else | |
723 # define GCTYPEBITS 3L | |
724 # endif | |
725 #endif | |
726 | |
727 /* Valid values for GCMARKBITS are 0 and 1. */ | |
728 #ifdef USE_MINIMAL_TAGBITS | |
729 # define GCMARKBITS 0L | |
730 #else | |
731 # define GCMARKBITS 1L | |
701 #endif | 732 #endif |
702 | 733 |
703 #ifndef VALBITS | 734 #ifndef VALBITS |
704 # define VALBITS ((LONGBITS)-((GCTYPEBITS)+1L)) | 735 # define VALBITS ((LONGBITS)-(GCTYPEBITS)-(GCMARKBITS)) |
705 #endif | 736 #endif |
706 | 737 |
707 #ifdef NO_UNION_TYPE | 738 #ifdef NO_UNION_TYPE |
708 # include "lisp-disunion.h" | 739 # include "lisp-disunion.h" |
709 #else /* !NO_UNION_TYPE */ | 740 #else /* !NO_UNION_TYPE */ |
720 /* Close your eyes now lest you vomit or spontaneously combust ... */ | 751 /* Close your eyes now lest you vomit or spontaneously combust ... */ |
721 | 752 |
722 #define HACKEQ_UNSAFE(obj1, obj2) \ | 753 #define HACKEQ_UNSAFE(obj1, obj2) \ |
723 (EQ (obj1, obj2) || (!POINTER_TYPE_P (XGCTYPE (obj1)) \ | 754 (EQ (obj1, obj2) || (!POINTER_TYPE_P (XGCTYPE (obj1)) \ |
724 && !POINTER_TYPE_P (XGCTYPE (obj2)) \ | 755 && !POINTER_TYPE_P (XGCTYPE (obj2)) \ |
725 && XREALINT (obj1) == XREALINT (obj2))) | 756 && XCHAR_OR_INT (obj1) == XCHAR_OR_INT (obj2))) |
726 | 757 |
727 #ifdef DEBUG_XEMACS | 758 #ifdef DEBUG_XEMACS |
728 extern int debug_issue_ebola_notices; | 759 extern int debug_issue_ebola_notices; |
729 int eq_with_ebola_notice (Lisp_Object, Lisp_Object); | 760 int eq_with_ebola_notice (Lisp_Object, Lisp_Object); |
730 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) \ | 761 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) \ |
756 | 787 |
757 /* In a cons, the markbit of the car is the gc mark bit */ | 788 /* In a cons, the markbit of the car is the gc mark bit */ |
758 | 789 |
759 struct Lisp_Cons | 790 struct Lisp_Cons |
760 { | 791 { |
792 #ifdef LRECORD_CONS | |
793 struct lrecord_header lheader; | |
794 #endif | |
761 Lisp_Object car, cdr; | 795 Lisp_Object car, cdr; |
762 }; | 796 }; |
763 | 797 |
764 #if 0 /* FSFmacs */ | 798 #if 0 /* FSFmacs */ |
765 /* Like a cons, but records info on where the text lives that it was read from */ | 799 /* Like a cons, but records info on where the text lives that it was read from */ |
770 Lisp_Object car, cdr; | 804 Lisp_Object car, cdr; |
771 struct buffer *buffer; | 805 struct buffer *buffer; |
772 int bufpos; | 806 int bufpos; |
773 }; | 807 }; |
774 #endif | 808 #endif |
809 | |
810 #ifdef LRECORD_CONS | |
811 | |
812 DECLARE_LRECORD (cons, struct Lisp_Cons); | |
813 #define XCONS(x) XRECORD (x, cons, struct Lisp_Cons) | |
814 #define XSETCONS(x, p) XSETRECORD (x, p, cons) | |
815 #define CONSP(x) RECORDP (x, cons) | |
816 #define GC_CONSP(x) GC_RECORDP (x, cons) | |
817 #define CHECK_CONS(x) CHECK_RECORD (x, cons) | |
818 #define CONCHECK_CONS(x) CONCHECK_RECORD (x, cons) | |
819 | |
820 #define CONS_MARKED_P(c) MARKED_RECORD_HEADER_P(&((c)->lheader)) | |
821 #define MARK_CONS(c) MARK_RECORD_HEADER (&((c)->lheader)) | |
822 | |
823 #else /* ! LRECORD_CONS */ | |
775 | 824 |
776 DECLARE_NONRECORD (cons, Lisp_Type_Cons, struct Lisp_Cons); | 825 DECLARE_NONRECORD (cons, Lisp_Type_Cons, struct Lisp_Cons); |
777 #define XCONS(a) XNONRECORD (a, cons, Lisp_Type_Cons, struct Lisp_Cons) | 826 #define XCONS(a) XNONRECORD (a, cons, Lisp_Type_Cons, struct Lisp_Cons) |
778 #define XSETCONS(c, p) XSETOBJ (c, Lisp_Type_Cons, p) | 827 #define XSETCONS(c, p) XSETOBJ (c, Lisp_Type_Cons, p) |
779 #define CONSP(x) (XTYPE (x) == Lisp_Type_Cons) | 828 #define CONSP(x) (XTYPE (x) == Lisp_Type_Cons) |
783 | 832 |
784 /* Define these because they're used in a few places, inside and | 833 /* Define these because they're used in a few places, inside and |
785 out of alloc.c */ | 834 out of alloc.c */ |
786 #define CONS_MARKED_P(c) XMARKBIT (c->car) | 835 #define CONS_MARKED_P(c) XMARKBIT (c->car) |
787 #define MARK_CONS(c) XMARK (c->car) | 836 #define MARK_CONS(c) XMARK (c->car) |
837 | |
838 #endif /* ! LRECORD_CONS */ | |
788 | 839 |
789 #define NILP(x) EQ (x, Qnil) | 840 #define NILP(x) EQ (x, Qnil) |
790 #define GC_NILP(x) GC_EQ (x, Qnil) | 841 #define GC_NILP(x) GC_EQ (x, Qnil) |
791 #define CHECK_LIST(x) \ | 842 #define CHECK_LIST(x) \ |
792 do { if ((!CONSP (x)) && !NILP (x)) dead_wrong_type_argument (Qlistp, x); } while (0) | 843 do { if ((!CONSP (x)) && !NILP (x)) dead_wrong_type_argument (Qlistp, x); } while (0) |
921 /*********** vector ***********/ | 972 /*********** vector ***********/ |
922 | 973 |
923 struct Lisp_Vector | 974 struct Lisp_Vector |
924 { | 975 { |
925 #ifdef LRECORD_VECTOR | 976 #ifdef LRECORD_VECTOR |
926 struct lrecord_header lheader; | 977 struct lcrecord_header header; |
927 #endif | 978 #endif |
928 long size; | 979 long size; |
929 /* next is now chained through v->contents[size], terminated by Qzero. | 980 /* next is now chained through v->contents[size], terminated by Qzero. |
930 This means that pure vectors don't need a "next" */ | 981 This means that pure vectors don't need a "next" */ |
931 /* struct Lisp_Vector *next; */ | 982 /* struct Lisp_Vector *next; */ |
956 | 1007 |
957 #define vector_length(v) ((v)->size) | 1008 #define vector_length(v) ((v)->size) |
958 #define XVECTOR_LENGTH(s) vector_length (XVECTOR (s)) | 1009 #define XVECTOR_LENGTH(s) vector_length (XVECTOR (s)) |
959 #define vector_data(v) ((v)->contents) | 1010 #define vector_data(v) ((v)->contents) |
960 #define XVECTOR_DATA(s) vector_data (XVECTOR (s)) | 1011 #define XVECTOR_DATA(s) vector_data (XVECTOR (s)) |
961 #define vector_next(v) ((v)->contents[(v)->size]) | 1012 #ifndef LRECORD_VECTOR |
962 | 1013 # define vector_next(v) ((v)->contents[(v)->size]) |
1014 #endif | |
963 | 1015 |
964 /*********** bit vector ***********/ | 1016 /*********** bit vector ***********/ |
965 | 1017 |
966 #if (LONGBITS < 16) | 1018 #if (LONGBITS < 16) |
967 #error What the hell?! | 1019 #error What the hell?! |
1139 INLINE Emchar XCHAR (Lisp_Object obj); | 1191 INLINE Emchar XCHAR (Lisp_Object obj); |
1140 INLINE Emchar | 1192 INLINE Emchar |
1141 XCHAR (Lisp_Object obj) | 1193 XCHAR (Lisp_Object obj) |
1142 { | 1194 { |
1143 assert (CHARP (obj)); | 1195 assert (CHARP (obj)); |
1144 return XREALINT (obj); | 1196 return XCHARVAL (obj); |
1145 } | 1197 } |
1146 | 1198 |
1147 #else | 1199 #else |
1148 | 1200 |
1149 #define XCHAR(x) XREALINT (x) | 1201 #define XCHAR(x) XCHARVAL (x) |
1150 | 1202 |
1151 #endif | 1203 #endif |
1152 | 1204 |
1153 #define CHECK_CHAR(x) CHECK_NONRECORD (x, Lisp_Type_Char, Qcharacterp) | 1205 #define CHECK_CHAR(x) CHECK_NONRECORD (x, Lisp_Type_Char, Qcharacterp) |
1154 #define CONCHECK_CHAR(x) CONCHECK_NONRECORD (x, Lisp_Type_Char, Qcharacterp) | 1206 #define CONCHECK_CHAR(x) CONCHECK_NONRECORD (x, Lisp_Type_Char, Qcharacterp) |
1228 #define INT_OR_FLOATP(x) (INTP (x)) | 1280 #define INT_OR_FLOATP(x) (INTP (x)) |
1229 # define GC_INT_OR_FLOATP(x) (GC_INTP (x)) | 1281 # define GC_INT_OR_FLOATP(x) (GC_INTP (x)) |
1230 | 1282 |
1231 #endif /* not LISP_FLOAT_TYPE */ | 1283 #endif /* not LISP_FLOAT_TYPE */ |
1232 | 1284 |
1233 #define INTP(x) (XTYPE (x) == Lisp_Type_Int) | 1285 #ifdef USE_MINIMAL_TAGBITS |
1234 #define GC_INTP(x) (XGCTYPE (x) == Lisp_Type_Int) | 1286 # define INTP(x) \ |
1287 (XTYPE (x) == Lisp_Type_Int_Even || XTYPE(x) == Lisp_Type_Int_Odd) | |
1288 # define GC_INTP(x) \ | |
1289 (XGCTYPE (x) == Lisp_Type_Int_Even || XGCTYPE(x) == Lisp_Type_Int_Odd) | |
1290 #else | |
1291 # define INTP(x) (XTYPE (x) == Lisp_Type_Int) | |
1292 # define GC_INTP(x) (XGCTYPE (x) == Lisp_Type_Int) | |
1293 #endif | |
1235 | 1294 |
1236 #define ZEROP(x) EQ (x, Qzero) | 1295 #define ZEROP(x) EQ (x, Qzero) |
1237 #define GC_ZEROP(x) GC_EQ (x, Qzero) | 1296 #define GC_ZEROP(x) GC_EQ (x, Qzero) |
1238 | 1297 |
1239 #ifdef ERROR_CHECK_TYPECHECK | 1298 #ifdef ERROR_CHECK_TYPECHECK |
1250 | 1309 |
1251 #define XINT(obj) XREALINT (obj) | 1310 #define XINT(obj) XREALINT (obj) |
1252 | 1311 |
1253 #endif | 1312 #endif |
1254 | 1313 |
1255 #define CHECK_INT(x) CHECK_NONRECORD (x, Lisp_Type_Int, Qintegerp) | 1314 #ifdef ERROR_CHECK_TYPECHECK |
1256 #define CONCHECK_INT(x) CONCHECK_NONRECORD (x, Lisp_Type_Int, Qintegerp) | 1315 |
1316 INLINE EMACS_INT XCHAR_OR_INT (Lisp_Object obj); | |
1317 INLINE EMACS_INT | |
1318 XCHAR_OR_INT (Lisp_Object obj) | |
1319 { | |
1320 assert (INTP (obj) || CHARP (obj)); | |
1321 return CHARP (obj) ? XCHAR (obj) : XINT (obj); | |
1322 } | |
1323 | |
1324 #else | |
1325 | |
1326 #define XCHAR_OR_INT(obj) (CHARP ((obj)) ? XCHAR ((obj)) : XINT ((obj))) | |
1327 | |
1328 #endif | |
1329 | |
1330 #ifdef USE_MINIMAL_TAGBITS | |
1331 /* | |
1332 * can't use CHECK_NONRECORD and CONCHECK_NONRECORD here because in | |
1333 * the USE_MINIMAL_TAGBITS implementation Lisp integers have two types. | |
1334 */ | |
1335 # define CHECK_INT(x) do { \ | |
1336 if (! INTP (x)) \ | |
1337 dead_wrong_type_argument (Qintegerp, x); \ | |
1338 } while (0) | |
1339 # define CONCHECK_INT(x) do { \ | |
1340 if (! INTP (x)) \ | |
1341 x = wrong_type_argument (Qintegerp, x); \ | |
1342 } while (0) | |
1343 #else | |
1344 # define CHECK_INT(x) CHECK_NONRECORD (x, Lisp_Type_Int, Qintegerp) | |
1345 # define CONCHECK_INT(x) CONCHECK_NONRECORD (x, Lisp_Type_Int, Qintegerp) | |
1346 #endif | |
1257 | 1347 |
1258 #define NATNUMP(x) (INTP (x) && XINT (x) >= 0) | 1348 #define NATNUMP(x) (INTP (x) && XINT (x) >= 0) |
1259 #define GC_NATNUMP(x) (GC_INTP (x) && XINT (x) >= 0) | 1349 #define GC_NATNUMP(x) (GC_INTP (x) && XINT (x) >= 0) |
1260 | 1350 |
1261 #define CHECK_NATNUM(x) \ | 1351 #define CHECK_NATNUM(x) \ |
1433 The docstring for the function is placed as a "C" comment between | 1523 The docstring for the function is placed as a "C" comment between |
1434 the prompt and the `args' argument. make-docfile reads the | 1524 the prompt and the `args' argument. make-docfile reads the |
1435 comment and creates the DOC file form it. | 1525 comment and creates the DOC file form it. |
1436 */ | 1526 */ |
1437 | 1527 |
1438 #define SUBR_MAX_ARGS 8 | 1528 #define SUBR_MAX_ARGS 12 |
1439 #define MANY -2 | 1529 #define MANY -2 |
1440 #define UNEVALLED -1 | 1530 #define UNEVALLED -1 |
1441 | 1531 |
1442 /* Can't be const, because then subr->doc is read-only and | 1532 /* Can't be const, because then subr->doc is read-only and |
1443 Snarf_documentation chokes */ | 1533 Snarf_documentation chokes */ |
1453 `Lisp_Object' type declaration to the formal C arguments. */ | 1543 `Lisp_Object' type declaration to the formal C arguments. */ |
1454 | 1544 |
1455 #define DEFUN_MANY(named_int, named_Lisp_Object) named_int, named_Lisp_Object | 1545 #define DEFUN_MANY(named_int, named_Lisp_Object) named_int, named_Lisp_Object |
1456 #define DEFUN_UNEVALLED(args) Lisp_Object args | 1546 #define DEFUN_UNEVALLED(args) Lisp_Object args |
1457 #define DEFUN_0() void | 1547 #define DEFUN_0() void |
1458 #define DEFUN_1(a) Lisp_Object a | 1548 #define DEFUN_1(a) Lisp_Object a |
1459 #define DEFUN_2(a,b) DEFUN_1(a), Lisp_Object b | 1549 #define DEFUN_2(a,b) DEFUN_1(a), Lisp_Object b |
1460 #define DEFUN_3(a,b,c) DEFUN_2(a,b), Lisp_Object c | 1550 #define DEFUN_3(a,b,c) DEFUN_2(a,b), Lisp_Object c |
1461 #define DEFUN_4(a,b,c,d) DEFUN_3(a,b,c), Lisp_Object d | 1551 #define DEFUN_4(a,b,c,d) DEFUN_3(a,b,c), Lisp_Object d |
1462 #define DEFUN_5(a,b,c,d,e) DEFUN_4(a,b,c,d), Lisp_Object e | 1552 #define DEFUN_5(a,b,c,d,e) DEFUN_4(a,b,c,d), Lisp_Object e |
1463 #define DEFUN_6(a,b,c,d,e,f) DEFUN_5(a,b,c,d,e), Lisp_Object f | 1553 #define DEFUN_6(a,b,c,d,e,f) DEFUN_5(a,b,c,d,e), Lisp_Object f |
1464 #define DEFUN_7(a,b,c,d,e,f,g) DEFUN_6(a,b,c,d,e,f), Lisp_Object g | 1554 #define DEFUN_7(a,b,c,d,e,f,g) DEFUN_6(a,b,c,d,e,f), Lisp_Object g |
1465 #define DEFUN_8(a,b,c,d,e,f,g,h) DEFUN_7(a,b,c,d,e,f,g), Lisp_Object h | 1555 #define DEFUN_8(a,b,c,d,e,f,g,h) DEFUN_7(a,b,c,d,e,f,g), Lisp_Object h |
1556 #define DEFUN_9(a,b,c,d,e,f,g,h,i) DEFUN_8(a,b,c,d,e,f,g,h), Lisp_Object i | |
1557 #define DEFUN_10(a,b,c,d,e,f,g,h,i,j) DEFUN_9(a,b,c,d,e,f,g,h,i), Lisp_Object j | |
1558 #define DEFUN_11(a,b,c,d,e,f,g,h,i,j,k) DEFUN_10(a,b,c,d,e,f,g,h,i,j), Lisp_Object k | |
1559 #define DEFUN_12(a,b,c,d,e,f,g,h,i,j,k,l) DEFUN_11(a,b,c,d,e,f,g,h,i,j,k), Lisp_Object l | |
1466 | 1560 |
1467 /* WARNING: If you add defines here for higher values of maxargs, | 1561 /* WARNING: If you add defines here for higher values of maxargs, |
1468 make sure to also fix the clauses in primitive_funcall(), | 1562 make sure to also fix the clauses in primitive_funcall(), |
1469 and change the define of SUBR_MAX_ARGS above. */ | 1563 and change the define of SUBR_MAX_ARGS above. */ |
1470 | 1564 |