diff options
| author | Ken Raeburn | 2000-03-29 22:14:34 +0000 |
|---|---|---|
| committer | Ken Raeburn | 2000-03-29 22:14:34 +0000 |
| commit | e0b8c689e2b1d80da6ed235ae400ad10d117b706 (patch) | |
| tree | f54bb195d821f61b0f7c3fbf4eae79b72978fdbe /src/intervals.h | |
| parent | 141384bdd2a332b79b36d118cd13becaf0b326b9 (diff) | |
| download | emacs-e0b8c689e2b1d80da6ed235ae400ad10d117b706.tar.gz emacs-e0b8c689e2b1d80da6ed235ae400ad10d117b706.zip | |
Stop assuming interval pointers and lisp objects can be distinguished by
inspection. Beginnings of support for expensive internal consistency checks.
* config.in (ENABLE_CHECKING): Undef.
* lisp.h (struct interval): Replace "parent" field with a union of interval
pointer and Lisp_Object; add new bitfield to use as discriminant. Change other
flag fields to bitfields.
(CHECK): New macro for consistency checking. If ENABLE_CHECKING is defined and
the supplied test fails, print a message and abort.
(eassert): New macro. Use CHECK to provide an assert-like facility.
* intervals.h (NULL_INTERVAL_P): Now applies only to real interval pointers;
abort if the value looks like a lisp object.
(NULL_INTERVAL_P, NULL_PARENT, HAS_PARENT, HAS_OBJECT, SET_PARENT, SET_OBJECT,
INTERVAL_PARENT, GET_INTERVAL_OBJECT, COPY_PARENT): Modify for new interval
parent definition.
* alloc.c (mark_interval_tree, MARK_INTERVAL_TREE, UNMARK_BALANCE_INTERVALS):
Update references that need an addressable lisp object in the interval
structure.
(die): New function.
(suppress_checking): New variable.
* intervals.c (interval_start_pos): Just return 0 if there's no parent object.
Diffstat (limited to 'src/intervals.h')
| -rw-r--r-- | src/intervals.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/intervals.h b/src/intervals.h index eb50d723784..5db02e78629 100644 --- a/src/intervals.h +++ b/src/intervals.h | |||
| @@ -43,7 +43,8 @@ Boston, MA 02111-1307, USA. */ | |||
| 43 | #define INT_LISPLIKE(i) (BUFFERP ((Lisp_Object){(EMACS_INT)(i)}) \ | 43 | #define INT_LISPLIKE(i) (BUFFERP ((Lisp_Object){(EMACS_INT)(i)}) \ |
| 44 | || STRINGP ((Lisp_Object){(EMACS_INT)(i)})) | 44 | || STRINGP ((Lisp_Object){(EMACS_INT)(i)})) |
| 45 | #endif | 45 | #endif |
| 46 | #define NULL_INTERVAL_P(i) ((i) == NULL_INTERVAL || INT_LISPLIKE (i)) | 46 | #define NULL_INTERVAL_P(i) (CHECK(!INT_LISPLIKE(i),"non-interval"),(i) == NULL_INTERVAL) |
| 47 | /* old #define NULL_INTERVAL_P(i) ((i) == NULL_INTERVAL || INT_LISPLIKE (i)) */ | ||
| 47 | 48 | ||
| 48 | /* True if this interval has no right child. */ | 49 | /* True if this interval has no right child. */ |
| 49 | #define NULL_RIGHT_CHILD(i) ((i)->right == NULL_INTERVAL) | 50 | #define NULL_RIGHT_CHILD(i) ((i)->right == NULL_INTERVAL) |
| @@ -52,7 +53,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 52 | #define NULL_LEFT_CHILD(i) ((i)->left == NULL_INTERVAL) | 53 | #define NULL_LEFT_CHILD(i) ((i)->left == NULL_INTERVAL) |
| 53 | 54 | ||
| 54 | /* True if this interval has no parent. */ | 55 | /* True if this interval has no parent. */ |
| 55 | #define NULL_PARENT(i) (NULL_INTERVAL_P ((i)->parent)) | 56 | #define NULL_PARENT(i) ((i)->up_obj || (i)->up.interval == 0) |
| 56 | 57 | ||
| 57 | /* True if this interval is the left child of some other interval. */ | 58 | /* True if this interval is the left child of some other interval. */ |
| 58 | #define AM_LEFT_CHILD(i) (! NULL_PARENT (i) \ | 59 | #define AM_LEFT_CHILD(i) (! NULL_PARENT (i) \ |
| @@ -104,24 +105,24 @@ Boston, MA 02111-1307, USA. */ | |||
| 104 | 105 | ||
| 105 | /* Test what type of parent we have. Three possibilities: another | 106 | /* Test what type of parent we have. Three possibilities: another |
| 106 | interval, a buffer or string object, or NULL_INTERVAL. */ | 107 | interval, a buffer or string object, or NULL_INTERVAL. */ |
| 107 | #define INTERVAL_HAS_PARENT(i) ((i)->parent && ! INT_LISPLIKE ((i)->parent)) | 108 | #define INTERVAL_HAS_PARENT(i) ((i)->up_obj == 0 && (i)->up.interval != 0) |
| 108 | #define INTERVAL_HAS_OBJECT(i) ((i)->parent && INT_LISPLIKE ((i)->parent)) | 109 | #define INTERVAL_HAS_OBJECT(i) ((i)->up_obj) |
| 109 | 110 | ||
| 110 | /* Set/get parent of an interval. | 111 | /* Set/get parent of an interval. |
| 111 | 112 | ||
| 112 | The choice of macros is dependent on the type needed. Don't add | 113 | The choice of macros is dependent on the type needed. Don't add |
| 113 | casts to get around this, it will break some development work in | 114 | casts to get around this, it will break some development work in |
| 114 | progress. */ | 115 | progress. */ |
| 115 | #define SET_INTERVAL_PARENT(i,p) ((i)->parent = (p)) | 116 | #define SET_INTERVAL_PARENT(i,p) (eassert (!BUFFERP ((Lisp_Object)(p)) && !STRINGP ((Lisp_Object)(p))),(i)->up_obj = 0, (i)->up.interval = (p)) |
| 116 | #define SET_INTERVAL_OBJECT(i,o) ((i)->parent = (INTERVAL) XFASTINT (o)) | 117 | #define SET_INTERVAL_OBJECT(i,o) (eassert ((o) != 0), eassert (BUFFERP (o) || STRINGP (o)),(i)->up_obj = 1, (i)->up.obj = (o)) |
| 117 | #define INTERVAL_PARENT(i) ((i)->parent) | 118 | #define INTERVAL_PARENT(i) (eassert((i) != 0 && (i)->up_obj == 0),(i)->up.interval) |
| 118 | /* Because XSETFASTINT has to be used, this can't simply be | 119 | /* Because XSETFASTINT has to be used, this can't simply be |
| 119 | value-returning. */ | 120 | value-returning. */ |
| 120 | #define GET_INTERVAL_OBJECT(d,s) XSETFASTINT((d), (EMACS_INT) (s)->parent) | 121 | #define GET_INTERVAL_OBJECT(d,s) (eassert((s)->up_obj == 1),XSETFASTINT ((d), (s)->up.obj)) |
| 121 | 122 | ||
| 122 | /* Make the parent of D be whatever the parent of S is, regardless of | 123 | /* Make the parent of D be whatever the parent of S is, regardless of |
| 123 | type. This is used when balancing an interval tree. */ | 124 | type. This is used when balancing an interval tree. */ |
| 124 | #define COPY_INTERVAL_PARENT(d,s) ((d)->parent = (s)->parent) | 125 | #define COPY_INTERVAL_PARENT(d,s) ((d)->up = (s)->up, (d)->up_obj = (s)->up_obj) |
| 125 | 126 | ||
| 126 | /* Get the parent interval, if any, otherwise a null pointer. Useful | 127 | /* Get the parent interval, if any, otherwise a null pointer. Useful |
| 127 | for walking up to the root in a "for" loop; use this to get the | 128 | for walking up to the root in a "for" loop; use this to get the |