Mercurial > hg > xemacs-beta
annotate src/lisp.h @ 4995:8431b52e43b1
Move the various map* functions to C; add #'map-into.
src/ChangeLog addition:
2010-01-31 Aidan Kehoe <kehoea@parhasard.net>
Move #'mapcar*, #'mapcan, #'mapc, #'map, #'mapl, #'mapcon to C;
extend #'mapvector, #'mapconcat, #'mapcar to support more
SEQUENCES; have them all error with circular lists.
* fns.c (Fsubseq): Call CHECK_SEQUENCE here; Flength can return
from the debugger if it errors with a non-sequence, leading to a
crash in Fsubseq if sequence really is *not* a sequence.
(mapcarX): Rename mapcar1 to mapcarX; rework it comprehensively to
take an optional lisp output argument, and a varying number of
sequences.
Special-case a single list argument, as we used to, saving its
elements in the stack space for the results before calling
FUNCTION, so FUNCTION can corrupt the list all it
wants. dead_wrong_type_argument() in the other cases if we
encounter a non-cons where we expected a cons.
(Fmapconcat):
Accept further SEQUENCES after separator here. Special-case
the idiom (mapconcat 'identity SEQUENCE), don't even funcall.
(FmapcarX): Rename this from Fmapcar. Accept optional SEQUENCES.
(Fmapvector): Accept optional SEQUENCES.
(Fmapcan, Fmapc, Fmap): Move these here from cl-extra.el.
(Fmap_into): New function, as specified by Common Lisp.
(maplist): New function, the guts of the implementation of
Fmaplist and Fmapl.
(Fmaplist, Fmapl, Fmapcon): Move these from cl-extra.el.
(syms_of_fns):
Add a few needed symbols here, for the type tests
used by #'map. Add the new subrs, with aliases for #'mapc-internal
and #'mapcar.
* general-slots.h: Declare Qcoerce here, now it's used in both
indent.c and fns.c
* indent.c (syms_of_indent): Qcoerce is gone from here.
* lisp.h: Add ARRAYP(), SEQUENCEP(), and the corresponding CHECK_*
macros. Declare Fbit_vector, Fstring, FmapcarX, now other files
need to use them.
* data.c (Farrayp, Fsequencep): Use ARRAYP and SEQUENCEP, just
added to lisp.h
* buffer.c (Fbuffer_list): Now Fmapcar has been renamed FmapcarX
and takes MANY arguments, update this function to reflect that.
lisp/ChangeLog addition:
2010-01-31 Aidan Kehoe <kehoea@parhasard.net>
* cl.el (mapcar*): Delete; this is now in fns.c.
Use #'mapc, not #'mapc-internal in a couple of places.
* cl-macs.el (mapc, mapcar*, map): Delete these compiler macros
now the corresponding functions are in fns.c; there's no run-time
advantage to the macros.
* cl-extra.el (coerce): Extend the possible conversions here a
little; it's not remotely comprehensive yet, though it does allow
running slightly more Common Lisp code than previously.
(cl-mapcar-many): Delete.
(map, maplist, mapc, mapl, mapcan, mapcon): Move these to fns.c.
* bytecomp.el (byte-compile-maybe-mapc):
Use #'mapc itself, not #'mapc-internal, now the former is in C.
(mapcar*): Use #'byte-compile-maybe-mapc as this function's
byte-compile method, now a #'mapc that can take more than one
sequence is in C.
* obsolete.el (cl-mapc): Move this compatibility alias to this file.
* update-elc.el (do-autoload-commands): Use #'mapc, not
#'mapc-internal here.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 31 Jan 2010 18:29:48 +0000 |
parents | c27efc9acb5a |
children | c17c857e20bf |
rev | line source |
---|---|
428 | 1 /* Fundamental definitions for XEmacs Lisp interpreter. |
2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc. | |
3 Copyright (C) 1993-1996 Richard Mlynarik. | |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
4 Copyright (C) 1995, 1996, 2000-2005, 2009, 2010 Ben Wing. |
428 | 5 |
6 This file is part of XEmacs. | |
7 | |
8 XEmacs is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 2, or (at your option) any | |
11 later version. | |
12 | |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with XEmacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
22 | |
23 /* Synched up with: FSF 19.30. */ | |
24 | |
853 | 25 /* Authorship: |
26 | |
27 Based on code from pre-release FSF 19, c. 1991. | |
28 Various changes by Jamie Zawinski 1991-1994: | |
29 converting to ANSI C, splitting out function prototypes to a separate | |
30 file (later moved back for unknown reasons by Steve Baur?), debug-gcpro | |
31 stuff (now moribund). | |
32 ANSI-fication of DEFUN macros by Felix Lee, c. 1992? | |
33 NOT_REACHED, DOESNT_RETURN, PRINTF_ARGS by Richard Mlynarik, c. 1994. | |
34 Many changes over the years corresponding to Lisp_Object definition | |
35 changes, esp. by Richard Mlynarik (c. 1993) and Kyle Jones (c. 1998). | |
36 See alloc.c for more details. | |
37 Overhauled and reordered by Ben Wing, 1995-1996, and many things added: | |
38 Dynarrs, REALLOC macros, asserts, typedefs, inline header code, | |
39 first LIST_LOOP macros, CONCHECK_*, all error-checking code | |
40 (e.g. error-checking versions of XFOO macros), structure read syntax, | |
41 weak lists, lcrecord lists, reworking of quit handling, object hashing, | |
42 nested GCPRO, character objects and Ebola checking, memory usage stats, | |
43 others. | |
44 LOADHIST changes from Steve Baur, c. 1997? | |
45 Various macro-related changes by Martin Buchholz, 1998-1999: | |
46 LIST_LOOP macros greatly expanded and tortoise-hared; | |
47 RETURN_SANS_WARNINGS; reworked DEFUN macros; EXFUN macros (???). | |
1743 | 48 Various macro-related changes by Jerry James, 2003: |
49 MODULE_API introduced; | |
50 Compiler-specific definitions modernized and moved to compiler.h. | |
853 | 51 */ |
52 | |
440 | 53 #ifndef INCLUDED_lisp_h_ |
54 #define INCLUDED_lisp_h_ | |
428 | 55 |
56 /************************************************************************/ | |
57 /* general definitions */ | |
58 /************************************************************************/ | |
59 | |
2367 | 60 /* Conventions in comments: |
61 | |
62 "Mule-izing" is the process of going through a file and eliminating | |
63 assumptions that the internal format (Ibyte * text) is the same as the | |
64 external format used by library routines. Mule-ization should also | |
65 include replacing *ALL* raw references to `char' or `unsigned char' with | |
66 one of the self-documenting types created below. How exactly to do the | |
67 conversion, and how to write correctly Mule-ized code, is described in | |
68 the internals manual. Files that say "This file is Mule-ized" have | |
69 been reviewed at some point; that's not to say that incorrect code hasn't | |
70 crept in, though. | |
71 | |
72 "Unicode-splitting" is the process of fixing a file so that it will | |
73 handle external text in Unicode under Microsoft Windows, as appropriate. | |
74 ("splitting" because it needs to handle either Unicode or variable-width | |
75 multibyte depending on the OS -- NT or 9x). See intl-win32.c. | |
76 | |
77 #### is a way of marking problems of any sort. | |
78 | |
79 !!#### marks places that are not properly Mule-ized. | |
80 | |
81 &&#### marks places that need to be fixed in order for the "8-bit mule" | |
82 conversion to work correctly, i.e. in order to support multiple different | |
83 buffer formats under Mule, including a fixed 8-bit format. | |
84 | |
85 ^^#### marks places that need to be fixed in order to eliminate the | |
86 assumption that Ibyte * text is composed of 1-byte units (e.g. UTF-16 | |
87 is composed of 2-byte units and might be a possible format to consider | |
88 for Ibyte * text). | |
89 | |
90 %%#### marks places that need work for KKCC (the new garbage collector). | |
91 | |
92 */ | |
93 | |
1318 | 94 /* -------------------------- include files --------------------- */ |
442 | 95 |
428 | 96 /* We include the following generally useful header files so that you |
97 don't have to worry about prototypes when using the standard C | |
98 library functions and macros. These files shouldn't be excessively | |
99 large so they shouldn't cause that much of a slowdown. */ | |
100 | |
101 #include <stdlib.h> | |
102 #include <string.h> /* primarily for memcpy, etc. */ | |
103 #include <stdio.h> /* NULL, etc. */ | |
104 #include <ctype.h> | |
105 #include <stdarg.h> | |
106 #include <stddef.h> /* offsetof */ | |
107 #include <sys/types.h> | |
442 | 108 #include <limits.h> |
109 | |
1318 | 110 /* -------------------------- error-checking ------------------------ */ |
853 | 111 |
112 /* The large categories established by configure can be subdivided into | |
113 smaller subcategories, for problems in specific modules. You can't | |
114 control this using configure, but you can manually stick in a define as | |
115 necessary. */ | |
116 | |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
117 /* How these work: |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
118 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
119 The most common classes will be `text' and `type', followed by `structure'. |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
120 `text' is for problems related to bad textual format. `type' is for |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
121 problems related to wrongly typed arguments, structure fields, etc. |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
122 `structure' is for bad data inside of a structure. Sometimes these are |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
123 used "incorrectly", e.g. `type' is often used for structure-checking. |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
124 Consider `text': |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
125 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
126 `text_checking_assert() will assert() only when ERROR_CHECK_TEXT is defined; |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
127 otherwise it's a no-op. text_checking_assert_at_line() is similar, but |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
128 allows you to override the file name and line number normally supplied in |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
129 the message. This is especially useful in inline header functions, and |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
130 so there's a special inline_text_checking_assert() for this; this works |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
131 like text_checking_assert() but supplies the file and line of the calling |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
132 function. In order for this to work, you need to declare your inline |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
133 function with INLINE_TEXT_CHECK_ARGS at the end of its argument list, |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
134 and give its function name a _1 extension or similar. Then create a |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
135 macro that calls your inline function and includes INLINE_TEXT_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
136 at the end of the parameter list. This will arrange to pass in and receive |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
137 the file and line (__FILE__, __LINE__) at place where the call occurs in |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
138 the calling function; but nothing will get passed in when ERROR_CHECK_TEXT |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
139 is not defined. |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
140 */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
141 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
142 |
853 | 143 #ifdef ERROR_CHECK_STRUCTURES |
144 /* Check for problems with the catch list and specbind stack */ | |
145 #define ERROR_CHECK_CATCH | |
146 /* Check for insufficient use of call_trapping_problems(), particularly | |
147 due to glyph-related changes causing eval or QUIT within redisplay */ | |
148 #define ERROR_CHECK_TRAPPING_PROBLEMS | |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
149 #endif /* ERROR_CHECK_STRUCTURES */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
150 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
151 #define INLINE_ERROR_CHECK_ARGS , const char *__file__, int __line__ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
152 #define INLINE_ERROR_CHECK_CALL , __FILE__, __LINE__ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
153 #define DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
154 #define DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
155 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
156 /* For assertions in inline header functions which will report the file and |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
157 line of the calling function */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
158 #define inline_assert(assertion) assert_at_line (assertion, __file__, __line__) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
159 #define disabled_inline_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
160 disabled_assert_at_line (assertion, __file__, __line__) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
161 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
162 #ifdef ERROR_CHECK_TEXT |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
163 #define text_checking_assert(assertion) assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
164 #define text_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
165 assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
166 #define inline_text_checking_assert(assertion) inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
167 #define INLINE_TEXT_CHECK_ARGS INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
168 #define INLINE_TEXT_CHECK_CALL INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
169 #define text_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
170 assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
171 #else /* not ERROR_CHECK_TEXT */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
172 #define text_checking_assert(assertion) disabled_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
173 #define text_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
174 disabled_assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
175 #define inline_text_checking_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
176 disabled_inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
177 #define INLINE_TEXT_CHECK_ARGS DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
178 #define INLINE_TEXT_CHECK_CALL DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
179 #define text_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
180 disabled_assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
181 #endif /* ERROR_CHECK_TEXT */ |
853 | 182 |
1318 | 183 #ifdef ERROR_CHECK_TYPES |
184 #define type_checking_assert(assertion) assert (assertion) | |
185 #define type_checking_assert_at_line(assertion, file, line) \ | |
186 assert_at_line (assertion, file, line) | |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
187 #define inline_type_checking_assert(assertion) inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
188 #define INLINE_TYPE_CHECK_ARGS INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
189 #define INLINE_TYPE_CHECK_CALL INLINE_ERROR_CHECK_CALL |
1318 | 190 #define type_checking_assert_with_message(assertion, msg) \ |
191 assert_with_message (assertion, msg) | |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
192 #else /* not ERROR_CHECK_TYPES */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
193 #define type_checking_assert(assertion) disabled_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
194 #define type_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
195 disabled_assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
196 #define inline_type_checking_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
197 disabled_inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
198 #define INLINE_TYPE_CHECK_ARGS DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
199 #define INLINE_TYPE_CHECK_CALL DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
200 #define type_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
201 disabled_assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
202 #endif /* ERROR_CHECK_TYPES */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
203 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
204 #ifdef ERROR_CHECK_STRUCTURES |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
205 #define structure_checking_assert(assertion) assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
206 #define structure_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
207 assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
208 #define inline_structure_checking_assert(assertion) inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
209 #define INLINE_STRUCTURE_CHECK_ARGS INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
210 #define INLINE_STRUCTURE_CHECK_CALL INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
211 #define structure_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
212 assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
213 #else /* not ERROR_CHECK_STRUCTURES */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
214 #define structure_checking_assert(assertion) disabled_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
215 #define structure_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
216 disabled_assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
217 #define inline_structure_checking_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
218 disabled_inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
219 #define INLINE_STRUCTURE_CHECK_ARGS DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
220 #define INLINE_STRUCTURE_CHECK_CALL DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
221 #define structure_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
222 disabled_assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
223 #endif /* ERROR_CHECK_STRUCTURES */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
224 |
1318 | 225 #ifdef ERROR_CHECK_GC |
226 #define gc_checking_assert(assertion) assert (assertion) | |
227 #define gc_checking_assert_at_line(assertion, file, line) \ | |
228 assert_at_line (assertion, file, line) | |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
229 #define inline_gc_checking_assert(assertion) inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
230 #define INLINE_GC_CHECK_ARGS INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
231 #define INLINE_GC_CHECK_CALL INLINE_ERROR_CHECK_CALL |
1318 | 232 #define gc_checking_assert_with_message(assertion, msg) \ |
233 assert_with_message (assertion, msg) | |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
234 #else /* not ERROR_CHECK_GC */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
235 #define gc_checking_assert(assertion) disabled_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
236 #define gc_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
237 disabled_assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
238 #define inline_gc_checking_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
239 disabled_inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
240 #define INLINE_GC_CHECK_ARGS DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
241 #define INLINE_GC_CHECK_CALL DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
242 #define gc_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
243 disabled_assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
244 #endif /* ERROR_CHECK_GC */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
245 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
246 #ifdef ERROR_CHECK_DISPLAY |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
247 #define display_checking_assert(assertion) assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
248 #define display_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
249 assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
250 #define inline_display_checking_assert(assertion) inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
251 #define INLINE_DISPLAY_CHECK_ARGS INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
252 #define INLINE_DISPLAY_CHECK_CALL INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
253 #define display_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
254 assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
255 #else /* not ERROR_CHECK_DISPLAY */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
256 #define display_checking_assert(assertion) disabled_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
257 #define display_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
258 disabled_assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
259 #define inline_display_checking_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
260 disabled_inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
261 #define INLINE_DISPLAY_CHECK_ARGS DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
262 #define INLINE_DISPLAY_CHECK_CALL DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
263 #define display_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
264 disabled_assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
265 #endif /* ERROR_CHECK_DISPLAY */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
266 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
267 #ifdef ERROR_CHECK_GLYPHS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
268 #define glyph_checking_assert(assertion) assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
269 #define glyph_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
270 assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
271 #define inline_glyph_checking_assert(assertion) inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
272 #define INLINE_GLYPH_CHECK_ARGS INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
273 #define INLINE_GLYPH_CHECK_CALL INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
274 #define glyph_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
275 assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
276 #else /* not ERROR_CHECK_GLYPHS */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
277 #define glyph_checking_assert(assertion) disabled_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
278 #define glyph_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
279 disabled_assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
280 #define inline_glyph_checking_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
281 disabled_inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
282 #define INLINE_GLYPH_CHECK_ARGS DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
283 #define INLINE_GLYPH_CHECK_CALL DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
284 #define glyph_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
285 disabled_assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
286 #endif /* ERROR_CHECK_GLYPHS */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
287 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
288 #ifdef ERROR_CHECK_EXTENTS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
289 #define extent_checking_assert(assertion) assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
290 #define extent_checking_assert_at_line(assertion, file, line) \ |
1318 | 291 assert_at_line (assertion, file, line) |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
292 #define inline_extent_checking_assert(assertion) inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
293 #define INLINE_EXTENT_CHECK_ARGS INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
294 #define INLINE_EXTENT_CHECK_CALL INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
295 #define extent_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
296 assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
297 #else /* not ERROR_CHECK_EXTENTS */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
298 #define extent_checking_assert(assertion) disabled_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
299 #define extent_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
300 disabled_assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
301 #define inline_extent_checking_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
302 disabled_inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
303 #define INLINE_EXTENT_CHECK_ARGS DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
304 #define INLINE_EXTENT_CHECK_CALL DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
305 #define extent_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
306 disabled_assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
307 #endif /* ERROR_CHECK_EXTENTS */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
308 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
309 #ifdef ERROR_CHECK_MALLOC |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
310 #define malloc_checking_assert(assertion) assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
311 #define malloc_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
312 assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
313 #define inline_malloc_checking_assert(assertion) inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
314 #define INLINE_MALLOC_CHECK_ARGS INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
315 #define INLINE_MALLOC_CHECK_CALL INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
316 #define malloc_checking_assert_with_message(assertion, msg) \ |
1318 | 317 assert_with_message (assertion, msg) |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
318 #else /* not ERROR_CHECK_MALLOC */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
319 #define malloc_checking_assert(assertion) disabled_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
320 #define malloc_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
321 disabled_assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
322 #define inline_malloc_checking_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
323 disabled_inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
324 #define INLINE_MALLOC_CHECK_ARGS DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
325 #define INLINE_MALLOC_CHECK_CALL DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
326 #define malloc_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
327 disabled_assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
328 #endif /* ERROR_CHECK_MALLOC */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
329 |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
330 #ifdef ERROR_CHECK_BYTE_CODE |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
331 #define byte_code_checking_assert(assertion) assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
332 #define byte_code_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
333 assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
334 #define inline_byte_code_checking_assert(assertion) inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
335 #define INLINE_BYTE_CODE_CHECK_ARGS INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
336 #define INLINE_BYTE_CODE_CHECK_CALL INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
337 #define byte_code_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
338 assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
339 #else /* not ERROR_CHECK_BYTE_CODE */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
340 #define byte_code_checking_assert(assertion) disabled_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
341 #define byte_code_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
342 disabled_assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
343 #define inline_byte_code_checking_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
344 disabled_inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
345 #define INLINE_BYTE_CODE_CHECK_ARGS DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
346 #define INLINE_BYTE_CODE_CHECK_CALL DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
347 #define byte_code_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
348 disabled_assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
349 #endif /* ERROR_CHECK_BYTE_CODE */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
350 |
1318 | 351 #ifdef ERROR_CHECK_TRAPPING_PROBLEMS |
352 #define trapping_problems_checking_assert(assertion) assert (assertion) | |
353 #define trapping_problems_checking_assert_at_line(assertion, file, line) \ | |
354 assert_at_line (assertion, file, line) | |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
355 #define inline_trapping_problems_checking_assert(assertion) inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
356 #define INLINE_TRAPPING_PROBLEMS_CHECK_ARGS INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
357 #define INLINE_TRAPPING_PROBLEMS_CHECK_CALL INLINE_ERROR_CHECK_CALL |
1318 | 358 #define trapping_problems_checking_assert_with_message(assertion, msg) \ |
359 assert_with_message (assertion, msg) | |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
360 #else /* not ERROR_CHECK_TRAPPING_PROBLEMS */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
361 #define trapping_problems_checking_assert(assertion) disabled_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
362 #define trapping_problems_checking_assert_at_line(assertion, file, line) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
363 disabled_assert_at_line (assertion, file, line) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
364 #define inline_trapping_problems_checking_assert(assertion) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
365 disabled_inline_assert (assertion) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
366 #define INLINE_TRAPPING_PROBLEMS_CHECK_ARGS DISABLED_INLINE_ERROR_CHECK_ARGS |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
367 #define INLINE_TRAPPING_PROBLEMS_CHECK_CALL DISABLED_INLINE_ERROR_CHECK_CALL |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
368 #define trapping_problems_checking_assert_with_message(assertion, msg) \ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
369 disabled_assert_with_message (assertion, msg) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
370 #endif /* ERROR_CHECK_TRAPPING_PROBLEMS */ |
1318 | 371 |
2367 | 372 /************************************************************************/ |
373 /** Definitions of basic types **/ | |
374 /************************************************************************/ | |
375 | |
376 /* ------------- generic 8/16/32/64/128-bit integral types ------------ */ | |
647 | 377 |
826 | 378 #if SIZEOF_SHORT == 2 |
379 #define INT_16_BIT short | |
380 #define UINT_16_BIT unsigned short | |
381 #elif SIZEOF_INT == 2 | |
382 /* Bwa ha ha. As if XEmacs could actually support such systems. */ | |
383 #define INT_16_BIT int | |
384 #define UINT_16_BIT unsigned int | |
385 #else | |
386 #error Unable to find a 16-bit integral type | |
387 #endif | |
388 | |
389 #if SIZEOF_INT == 4 | |
390 #define INT_32_BIT int | |
391 #define UINT_32_BIT unsigned int | |
392 #define MAKE_32_BIT_UNSIGNED_CONSTANT(num) num##U | |
393 #elif SIZEOF_LONG == 4 | |
394 /* Bwa ha ha again. */ | |
395 #define INT_32_BIT long | |
396 #define UINT_32_BIT unsigned long | |
397 #define MAKE_32_BIT_UNSIGNED_CONSTANT(num) num##UL | |
398 #elif SIZEOF_SHORT == 4 | |
399 /* And again. */ | |
400 #define INT_32_BIT short | |
401 #define UINT_32_BIT unsigned short | |
402 #define MAKE_32_BIT_UNSIGNED_CONSTANT(num) num##U | |
1429 | 403 #elif 1 /* Unable to find a 32-bit integral type! */ |
826 | 404 #error What kind of strange-ass system are you running on? |
405 #endif | |
406 | |
407 #if SIZEOF_LONG == 8 | |
408 #define INT_64_BIT long | |
409 #define UINT_64_BIT unsigned long | |
410 #define MAKE_64_BIT_UNSIGNED_CONSTANT(num) num##UL | |
411 #elif SIZEOF_LONG_LONG == 8 | |
412 #define INT_64_BIT long long | |
413 #define UINT_64_BIT unsigned long long | |
414 #define MAKE_64_BIT_UNSIGNED_CONSTANT(num) num##ULL | |
4682
648f4a0dac3e
Fix build problems on WIN32 platforms caused by the large image crash fix.
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
415 #elif defined(WIN32_ANY) |
648f4a0dac3e
Fix build problems on WIN32 platforms caused by the large image crash fix.
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
416 #define INT_64_BIT __int64 |
648f4a0dac3e
Fix build problems on WIN32 platforms caused by the large image crash fix.
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
417 #define UINT_64_BIT unsigned __int64 |
648f4a0dac3e
Fix build problems on WIN32 platforms caused by the large image crash fix.
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
418 #define MAKE_64_BIT_UNSIGNED_CONSTANT(num) num##UI64 |
826 | 419 /* No error otherwise; just leave undefined */ |
420 #endif | |
421 | |
422 #if SIZEOF_LONG_LONG == 16 | |
423 #define INT_128_BIT long long | |
424 #define UINT_128_BIT unsigned long long | |
425 #define MAKE_128_BIT_UNSIGNED_CONSTANT(num) num##ULL | |
426 /* No error otherwise; just leave undefined */ | |
427 #endif | |
428 | |
429 /* #### Fill this in for other systems */ | |
430 #if defined (INT_64_BIT) && !(defined (i386) || defined (__i386__)) | |
431 #define EFFICIENT_INT_64_BIT INT_64_BIT | |
432 #define EFFICIENT_UINT_64_BIT UINT_64_BIT | |
433 #endif | |
434 | |
435 #if defined (INT_128_BIT) | |
436 #define EFFICIENT_INT_128_BIT INT_128_BIT | |
437 #define EFFICIENT_UINT_128_BIT UINT_128_BIT | |
438 #endif | |
439 | |
2367 | 440 #ifdef HAVE_INTTYPES_H |
441 #include <inttypes.h> | |
442 #elif defined (HAVE_INTPTR_T_IN_SYS_TYPES_H) | |
443 /* included elsewhere */ | |
444 #elif SIZEOF_VOID_P == SIZEOF_INT | |
445 typedef int intptr_t; | |
446 typedef unsigned int uintptr_t; | |
447 #elif SIZEOF_VOID_P == SIZEOF_LONG | |
448 typedef long intptr_t; | |
449 typedef unsigned long uintptr_t; | |
450 #elif defined (SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG | |
451 typedef long long intptr_t; | |
452 typedef unsigned long long uintptr_t; | |
453 #else | |
454 /* Just pray. May break, may not. */ | |
455 typedef long intptr_t; | |
456 typedef unsigned long uintptr_t; | |
457 #endif | |
458 | |
3988 | 459 #if SIZEOF_VOID_P == 8 |
460 #define DEADBEEF_CONSTANT 0xCAFEBABEDEADBEEF | |
461 #elif SIZEOF_VOID_P == 4 | |
462 #define DEADBEEF_CONSTANT 0xDEADBEEF | |
463 #else | |
464 #error "What size are your pointers, really?" | |
465 #endif /* SIZEOF_VOID_P == 8 */ | |
466 | |
2367 | 467 /* ---------------------- definition of EMACS_INT --------------------- */ |
468 | |
469 /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit. | |
470 In particular, it must be large enough to contain a pointer. | |
471 config.h can override this, e.g. to use `long long' for bigger lisp ints. | |
472 | |
473 #### In point of fact, it would NOT be a good idea for config.h to mess | |
474 with EMACS_INT. A lot of code makes the basic assumption that EMACS_INT | |
475 is the size of a pointer. */ | |
476 | |
477 #ifndef SIZEOF_EMACS_INT | |
478 # define SIZEOF_EMACS_INT SIZEOF_VOID_P | |
479 #endif | |
480 | |
481 #ifndef EMACS_INT | |
482 # if SIZEOF_EMACS_INT == SIZEOF_LONG | |
483 # define EMACS_INT long | |
484 # elif SIZEOF_EMACS_INT == SIZEOF_INT | |
485 # define EMACS_INT int | |
486 # elif SIZEOF_EMACS_INT == SIZEOF_LONG_LONG | |
487 # define EMACS_INT long long | |
488 # else | |
489 # error Unable to determine suitable type for EMACS_INT | |
490 # endif | |
491 #endif | |
492 | |
493 #ifndef EMACS_UINT | |
494 # define EMACS_UINT unsigned EMACS_INT | |
495 #endif | |
496 | |
497 #define BITS_PER_EMACS_INT (SIZEOF_EMACS_INT * BITS_PER_CHAR) | |
498 | |
499 /* -------------------------- basic byte typedefs --------------------- */ | |
500 | |
501 /* The definitions we put here and in the next section use typedefs to | |
502 attribute specific meaning to types that by themselves are pretty | |
503 general. | |
504 | |
505 REMEMBER! These typedefs are purely for documentation purposes; from | |
647 | 506 the C code's perspective, they are exactly equivalent to `char *', |
507 `unsigned char *', etc., so you can freely use them with library | |
2367 | 508 functions declared as such. |
509 | |
510 (See also "Byte/Character Types" in text.c) | |
511 | |
512 The basic semantics for `char': | |
513 | |
514 a) [Ibyte] pointer to internally-formatted text | |
515 b) [Extbyte] pointer to text in some external format, which can be | |
516 defined as all formats other than the internal one | |
517 c) [Ascbyte] pure ASCII text | |
518 d) [Binbyte] binary data that is not meant to be interpreted as text | |
519 e) [Rawbyte] general data in memory, where we don't care about whether | |
520 it's text or binary | |
521 f) [Boolbyte] a zero or a one | |
522 g) [Bitbyte] a byte used for bit fields | |
523 h) [Chbyte] null-semantics `char *'; used when casting an argument to | |
524 an external API where the the other types may not be | |
525 appropriate | |
526 | |
527 | |
528 Prefixing codes: | |
529 | |
530 C = plain char, when the base type is unsigned | |
531 U = unsigned | |
532 S = signed | |
533 | |
534 Ideally, XEmacs code should NEVER directly use `char' or any type | |
535 derived from it. This is for Mule-cleanliness. If you find yourself | |
536 wanting or needing to use `char' and one of the above six semantics does | |
537 not apply, add a new type of semantics; don't use `char' directly. | |
538 | |
539 See text.c under "Byte Types", and following sections. | |
540 */ | |
647 | 541 |
542 /* The data representing the text in a buffer is logically a set | |
867 | 543 of Ibytes, declared as follows. */ |
544 | |
545 typedef unsigned char Ibyte; | |
647 | 546 |
547 /* The following should be used when you are working with internal data | |
548 but for whatever reason need to have it declared a "char *". Examples | |
549 are function arguments whose values are most commonly literal strings, | |
550 or where you have to apply a stdlib string function to internal data. | |
551 | |
2367 | 552 In general, you should avoid this where possible and use Ascbyte if the |
553 text is just ASCII (e.g. string literals) or otherwise Ibyte, for | |
554 consistency. For example, the new Mule workspace contains Ibyte | |
555 versions of the stdlib string functions. */ | |
867 | 556 |
557 typedef char CIbyte; | |
647 | 558 |
559 /* The data representing a string in "external" format (binary or any | |
560 external encoding) is logically a set of Extbytes, declared as | |
561 follows. Extbyte is guaranteed to be just a char, so for example | |
562 strlen (Extbyte *) is OK. Extbyte is only a documentation device | |
563 for referring to external text. */ | |
564 | |
565 typedef char Extbyte; | |
771 | 566 typedef unsigned char UExtbyte; |
647 | 567 |
2367 | 568 #define EXTTEXT_ZTERM_SIZE (sizeof (Extbyte)) |
647 | 569 |
570 /* A byte in a string in entirely US-ASCII format: (Nothing outside | |
571 the range 00 - 7F) */ | |
572 | |
2367 | 573 typedef char Ascbyte; |
574 typedef unsigned char UAscbyte; | |
575 | |
576 /* A generic memory pointer, no text or binary semantics assumed. | |
577 In general, there should be no manipulation of the memory pointed to | |
578 by these pointers other than just copying it around. */ | |
579 | |
580 typedef unsigned char Rawbyte; | |
581 typedef char CRawbyte; | |
582 | |
583 /* A byte in a string in binary (not meant as text) format: */ | |
584 | |
585 typedef unsigned char Binbyte; | |
586 typedef char CBinbyte; | |
587 typedef signed char SBinbyte; | |
588 | |
589 /* A byte used to represent a boolean value: 0 or 1. | |
590 Normally use plain Boolint, and only use Boolbyte to save space. */ | |
591 | |
592 typedef char Boolbyte; | |
593 | |
594 /* A byte composed of bitfields. Hardly ever used. */ | |
595 | |
596 typedef unsigned char Bitbyte; | |
597 | |
598 /* A no-semantics `char'. Used (pretty-much) ONLY for casting arguments to | |
599 functions accepting a `char *', `unsigned char *', etc. where the other | |
600 types don't exactly apply and what you are logically concerned with is | |
601 the type of the function's argument and not its semantics. | |
602 | |
603 DO NOT DO NOT DO NOT DO NOT use this as a sloppy replacement for one of | |
604 the other types. If you're not using this as part of casting an | |
605 argument to a function call, and you're not Ben Wing, you're using it | |
606 wrong. Go find another one of the types. */ | |
607 | |
608 typedef char Chbyte; | |
609 typedef unsigned char UChbyte; | |
610 typedef signed char SChbyte; | |
611 | |
612 /* ------------------------ other text-related typedefs ------------------- */ | |
647 | 613 |
826 | 614 /* To the user, a buffer is made up of characters. In the non-Mule world, |
867 | 615 characters and Ibytes are equivalent, restricted to the range 0 - 255. |
3498 | 616 In the Mule world, many more characters are possible (21 bits worth, |
867 | 617 more or less), and a character requires (typically) 1 to 4 Ibytes for |
826 | 618 its representation in a buffer or string. Note that the representation |
619 of a character by itself, in a variable, is very different from its | |
620 representation in a string of text (in a buffer or Lisp string). | |
621 | |
622 Under Mule, text can be represented in more than one way. The "default" | |
623 format is variable-width (1 to 4 bytes) and compatible with ASCII -- | |
624 ASCII chars are stored in one byte, as themselves, and all other chars | |
625 use only high bytes. The default format is currently the only format | |
626 used for text stored anywhere but in a buffer. In a buffer, other | |
627 formats -- fixed-width formats (1, 2, or 4 bytes) -- are possible, for | |
628 speed. | |
629 | |
630 See text.c/text.h for a detailed discussion of all of this. */ | |
631 | |
632 /* A character, as represented on its own. */ | |
647 | 633 |
867 | 634 typedef int Ichar; |
647 | 635 |
826 | 636 /* The "raw value" of a character as stored in the buffer. In the default |
637 format, this is just the same as the character. In fixed-width formats, | |
638 this is the actual value in the buffer, which will be limited to the | |
639 range as established by the format. This is used when searching for a | |
640 character in a buffer -- it's faster to convert the character to the raw | |
641 value and look for that, than repeatedly convert each raw value in the | |
642 buffer into a character. */ | |
643 | |
867 | 644 typedef int Raw_Ichar; |
826 | 645 |
2367 | 646 /* Internal text as a series of textual units (8-bit bytes in the old |
647 "Mule" encoding -- still the standard internal encoding -- and in UTF-8, | |
648 but 16-bit bytes in UTF-16 and 32-bit bytes in UTF-32). See text.c. */ | |
649 | |
650 #ifdef UTF16_IBYTE_FORMAT | |
651 #define NON_ASCII_INTERNAL_FORMAT | |
652 typedef unsigned short Itext; | |
653 #else | |
654 typedef Ibyte Itext; | |
655 #endif | |
656 typedef EMACS_INT Textcount; | |
657 | |
658 #define ITEXT_SIZE (sizeof (Itext)) | |
659 /* Use this to emphasize that we are adding space for the zero-terminator */ | |
660 #define ITEXT_ZTERM_SIZE ITEXT_SIZE | |
661 | |
662 /* Wexttext is wchar_t on WIN32_NATIVE (and perhaps other systems that | |
663 support wchar_t's in library functions), and Extbyte otherwise. This is | |
664 used whenever we have to do any sort of manipulation of | |
665 externally-encoded strings -- generally a very bad idea, and unsafe, but | |
666 in some cases we have no choice (especially at startup, and esp. prior | |
667 to pdump, where we haven't loaded the Unicode tables necessary for | |
668 conversion under Windows). On platforms where the external encoding may | |
669 be Unicode (i.e. Windows), we always do our manipulations in Unicode, | |
670 converting to and from multibyte if necessary -- otherwise we'd have to | |
671 conditionalize on Unicode vs. multibyte all over the place, which is | |
672 just a nightmare. */ | |
673 #ifdef WIN32_NATIVE | |
674 #define WEXTTEXT_IS_WIDE | |
675 typedef wchar_t Wexttext; | |
676 #else | |
677 typedef Extbyte Wexttext; | |
678 #endif | |
826 | 679 |
680 #if !defined (__cplusplus) || !defined (CPLUSPLUS_INTEGRAL_CLASSES_NOT_YET) | |
681 | |
682 /* Counts of bytes or chars */ | |
683 | |
684 typedef EMACS_INT Bytecount; | |
685 typedef EMACS_INT Charcount; | |
686 | |
647 | 687 /* Different ways of referring to a position in a buffer. We use |
688 the typedefs in preference to 'EMACS_INT' to make it clearer what | |
826 | 689 sort of position is being used. See text.c for a description |
690 of the different positions. | |
691 | |
692 Note that buffer positions are 1-based, and there's a gap in the middle | |
693 of a buffer; that's why we have separate typedefs. For Lisp strings and | |
694 other strings of text, we just use Bytecount and Charcount. */ | |
800 | 695 |
665 | 696 typedef EMACS_INT Charbpos; |
697 typedef EMACS_INT Bytebpos; | |
698 typedef EMACS_INT Membpos; | |
647 | 699 |
826 | 700 /* Different ways of referring to a position that can be either in a buffer |
701 or string; used when passing around an object that can be either a | |
702 buffer or string, and an associated position. Conceptually, they | |
703 resolve as follows: | |
704 | |
705 Typedef Buffer String | |
706 ------------------------------------------------------ | |
707 Charxpos Charbpos Charcount | |
708 Bytexpos Bytebpos Bytecount | |
709 Memxpos Membpos Bytecount | |
710 | |
711 */ | |
712 | |
814 | 713 typedef EMACS_INT Charxpos; |
714 typedef EMACS_INT Bytexpos; | |
715 typedef EMACS_INT Memxpos; | |
716 | |
717 #else /* __cplusplus */ | |
718 | |
719 /* Implement strong type-checking of the above integral types by declaring | |
720 them to be classes and using operator overloading. Unfortunately this | |
721 is a huge pain in the ass because C++ doesn't strongly distinguish | |
722 "bool" and "size_t" from int. The problem is especially bad with "bool" | |
2956 | 723 -- if you want to be able to say `if (len--)' where len is e.g. a |
814 | 724 Bytecount, you need to declare a conversion operator to bool(); and |
725 since bool is just an alias for int, you suddenly get tons and tons of | |
726 ambiguities, which need to be resolved by lots of laborious declarations | |
727 for every single possible type combination. Hence the multitude of | |
728 declarations in DECLARE_INTCLASS_ARITH_COMPARE(). The bool/int | |
729 equivalence also means that we have to forcibly block the combinations | |
730 we don't want by creating overloaded versions of them and declaring them | |
731 private. */ | |
732 | |
733 class Bytecount; | |
734 class Bytebpos; | |
735 class Bytexpos; | |
736 class Charcount; | |
737 class Charbpos; | |
738 class Charxpos; | |
739 class Membpos; | |
740 class Memxpos; | |
741 | |
742 /* Declare the arithmetic and comparison operations for an integral class, | |
743 i.e. one of the above classes. If this is a "position" class, where the | |
744 difference between two positions is a different class (a "count" class), | |
745 then use POSCL for the position class and COUNTCL for the count class. | |
746 If this is a simple class, where all operations yield the same class, | |
747 substitute the same class for POSCL and COUNTCL. */ | |
748 | |
749 #define DECLARE_INTCLASS_ARITH_COMPARE(poscl, countcl) \ | |
750 poscl operator += (const countcl& l) { data += l.data; return *this; } \ | |
751 poscl operator -= (const countcl& l) { data -= l.data; return *this; } \ | |
752 poscl operator + (const countcl& l) const { return poscl (data + l.data); } \ | |
753 poscl operator - (const countcl& l) const { return poscl (data - l.data); } \ | |
754 poscl operator += (const int& l) { data += l; return *this; } \ | |
755 poscl operator -= (const int& l) { data -= l; return *this; } \ | |
756 poscl operator + (const int& l) const { return poscl (data + l); } \ | |
757 poscl operator - (const int& l) const { return poscl (data - l); } \ | |
758 poscl operator += (const unsigned int& l) { data += l; return *this; } \ | |
759 poscl operator -= (const unsigned int& l) { data -= l; return *this; } \ | |
760 poscl operator + (const unsigned int& l) const \ | |
761 { return poscl (data + l); } \ | |
762 poscl operator - (const unsigned int& l) const \ | |
763 { return poscl (data - l); } \ | |
764 poscl operator += (const long& l) { data += l; return *this; } \ | |
765 poscl operator -= (const long& l) { data -= l; return *this; } \ | |
766 poscl operator + (const long& l) const { return poscl (data + l); } \ | |
767 poscl operator - (const long& l) const { return poscl (data - l); } \ | |
768 poscl operator += (const unsigned long& l) { data += l; return *this; } \ | |
769 poscl operator -= (const unsigned long& l) { data -= l; return *this; } \ | |
770 poscl operator + (const unsigned long& l) const \ | |
771 { return poscl (data + l); } \ | |
772 poscl operator - (const unsigned long& l) const \ | |
773 { return poscl (data - l); } \ | |
774 poscl operator += (const short& l) { data += l; return *this; } \ | |
775 poscl operator -= (const short& l) { data -= l; return *this; } \ | |
776 poscl operator + (const short& l) const { return poscl (data + l); } \ | |
777 poscl operator - (const short& l) const { return poscl (data - l); } \ | |
778 poscl operator += (const unsigned short& l) { data += l; return *this; } \ | |
779 poscl operator -= (const unsigned short& l) { data -= l; return *this; } \ | |
780 poscl operator + (const unsigned short& l) const \ | |
781 { return poscl (data + l); } \ | |
782 poscl operator - (const unsigned short& l) const \ | |
783 { return poscl (data - l); } \ | |
784 \ | |
785 poscl operator *= (const countcl& l) { data *= l.data; return *this; } \ | |
786 poscl operator /= (const countcl& l) { data /= l.data; return *this; } \ | |
787 poscl operator * (const countcl& l) const { return poscl (data * l.data); } \ | |
788 poscl operator / (const countcl& l) const { return poscl (data / l.data); } \ | |
789 poscl operator *= (const int& l) { data *= l; return *this; } \ | |
790 poscl operator /= (const int& l) { data /= l; return *this; } \ | |
791 poscl operator * (const int& l) const { return poscl (data * l); } \ | |
792 poscl operator / (const int& l) const { return poscl (data / l); } \ | |
793 poscl operator *= (const unsigned int& l) { data *= l; return *this; } \ | |
794 poscl operator /= (const unsigned int& l) { data /= l; return *this; } \ | |
795 poscl operator * (const unsigned int& l) const { return poscl (data * l); } \ | |
796 poscl operator / (const unsigned int& l) const { return poscl (data / l); } \ | |
797 poscl operator *= (const long& l) { data *= l; return *this; } \ | |
798 poscl operator /= (const long& l) { data /= l; return *this; } \ | |
799 poscl operator * (const long& l) const { return poscl (data * l); } \ | |
800 poscl operator / (const long& l) const { return poscl (data / l); } \ | |
801 poscl operator *= (const unsigned long& l) { data *= l; return *this; } \ | |
802 poscl operator /= (const unsigned long& l) { data /= l; return *this; } \ | |
803 poscl operator * (const unsigned long& l) const \ | |
804 { return poscl (data * l); } \ | |
805 poscl operator / (const unsigned long& l) const \ | |
806 { return poscl (data / l); } \ | |
807 poscl operator *= (const short& l) { data *= l; return *this; } \ | |
808 poscl operator /= (const short& l) { data /= l; return *this; } \ | |
809 poscl operator * (const short& l) const { return poscl (data * l); } \ | |
810 poscl operator / (const short& l) const { return poscl (data / l); } \ | |
811 poscl operator *= (const unsigned short& l) { data *= l; return *this; } \ | |
812 poscl operator /= (const unsigned short& l) { data /= l; return *this; } \ | |
813 poscl operator * (const unsigned short& l) const \ | |
814 { return poscl (data * l); } \ | |
815 poscl operator / (const unsigned short& l) const \ | |
816 { return poscl (data / l); } \ | |
817 \ | |
818 poscl operator &= (const countcl& l) { data &= l.data; return *this; } \ | |
819 poscl operator |= (const countcl& l) { data |= l.data; return *this; } \ | |
820 poscl operator & (const countcl& l) const { return poscl (data & l.data); } \ | |
821 poscl operator | (const countcl& l) const { return poscl (data | l.data); } \ | |
822 poscl operator &= (const int& l) { data &= l; return *this; } \ | |
823 poscl operator |= (const int& l) { data |= l; return *this; } \ | |
824 poscl operator & (const int& l) const { return poscl (data & l); } \ | |
825 poscl operator | (const int& l) const { return poscl (data | l); } \ | |
826 poscl operator &= (const unsigned int& l) { data &= l; return *this; } \ | |
827 poscl operator |= (const unsigned int& l) { data |= l; return *this; } \ | |
828 poscl operator & (const unsigned int& l) const { return poscl (data & l); } \ | |
829 poscl operator | (const unsigned int& l) const { return poscl (data | l); } \ | |
830 poscl operator &= (const long& l) { data &= l; return *this; } \ | |
831 poscl operator |= (const long& l) { data |= l; return *this; } \ | |
832 poscl operator & (const long& l) const { return poscl (data & l); } \ | |
833 poscl operator | (const long& l) const { return poscl (data | l); } \ | |
834 poscl operator &= (const unsigned long& l) { data &= l; return *this; } \ | |
835 poscl operator |= (const unsigned long& l) { data |= l; return *this; } \ | |
836 poscl operator & (const unsigned long& l) const \ | |
837 { return poscl (data & l); } \ | |
838 poscl operator | (const unsigned long& l) const \ | |
839 { return poscl (data | l); } \ | |
840 poscl operator &= (const short& l) { data &= l; return *this; } \ | |
841 poscl operator |= (const short& l) { data |= l; return *this; } \ | |
842 poscl operator & (const short& l) const { return poscl (data & l); } \ | |
843 poscl operator | (const short& l) const { return poscl (data | l); } \ | |
844 poscl operator &= (const unsigned short& l) { data &= l; return *this; } \ | |
845 poscl operator |= (const unsigned short& l) { data |= l; return *this; } \ | |
846 poscl operator & (const unsigned short& l) const \ | |
847 { return poscl (data & l); } \ | |
848 poscl operator | (const unsigned short& l) const \ | |
849 { return poscl (data | l); } \ | |
850 \ | |
851 poscl operator - () { return poscl (-data); } \ | |
852 poscl operator-- () { data--; return *this; } \ | |
853 poscl operator-- (int) { data--; return poscl (data + 1); } \ | |
854 poscl operator++ () { data++; return *this; } \ | |
855 poscl operator++ (int) { data++; return poscl (data - 1); } \ | |
856 \ | |
857 bool operator < (const poscl& l) const { return data < l.data; } \ | |
858 bool operator <= (const poscl& l) const { return data <= l.data; } \ | |
859 bool operator > (const poscl& l) const { return data > l.data; } \ | |
860 bool operator >= (const poscl& l) const { return data >= l.data; } \ | |
861 bool operator == (const poscl& l) const { return data == l.data; } \ | |
862 bool operator != (const poscl& l) const { return data != l.data; } \ | |
863 bool operator < (const int& l) const { return data < (EMACS_INT) l; } \ | |
864 bool operator <= (const int& l) const { return data <= (EMACS_INT) l; } \ | |
865 bool operator > (const int& l) const { return data > (EMACS_INT) l; } \ | |
866 bool operator >= (const int& l) const { return data >= (EMACS_INT) l; } \ | |
867 bool operator == (const int& l) const { return data == (EMACS_INT) l; } \ | |
868 bool operator != (const int& l) const { return data != (EMACS_INT) l; } \ | |
869 bool operator < (const unsigned int& l) const \ | |
870 { return data < (EMACS_INT) l; } \ | |
871 bool operator <= (const unsigned int& l) const \ | |
872 { return data <= (EMACS_INT) l; } \ | |
873 bool operator > (const unsigned int& l) const \ | |
874 { return data > (EMACS_INT) l; } \ | |
875 bool operator >= (const unsigned int& l) const \ | |
876 { return data >= (EMACS_INT) l; } \ | |
877 bool operator == (const unsigned int& l) const \ | |
878 { return data == (EMACS_INT) l; } \ | |
879 bool operator != (const unsigned int& l) const \ | |
880 { return data != (EMACS_INT) l; } \ | |
881 bool operator < (const long& l) const { return data < (EMACS_INT) l; } \ | |
882 bool operator <= (const long& l) const { return data <= (EMACS_INT) l; } \ | |
883 bool operator > (const long& l) const { return data > (EMACS_INT) l; } \ | |
884 bool operator >= (const long& l) const { return data >= (EMACS_INT) l; } \ | |
885 bool operator == (const long& l) const { return data == (EMACS_INT) l; } \ | |
886 bool operator != (const long& l) const { return data != (EMACS_INT) l; } \ | |
887 bool operator < (const unsigned long& l) const \ | |
888 { return data < (EMACS_INT) l; } \ | |
889 bool operator <= (const unsigned long& l) const \ | |
890 { return data <= (EMACS_INT) l; } \ | |
891 bool operator > (const unsigned long& l) const \ | |
892 { return data > (EMACS_INT) l; } \ | |
893 bool operator >= (const unsigned long& l) const \ | |
894 { return data >= (EMACS_INT) l; } \ | |
895 bool operator == (const unsigned long& l) const \ | |
896 { return data == (EMACS_INT) l; } \ | |
897 bool operator != (const unsigned long& l) const \ | |
898 { return data != (EMACS_INT) l; } \ | |
899 bool operator < (const short& l) const { return data < (EMACS_INT) l; } \ | |
900 bool operator <= (const short& l) const { return data <= (EMACS_INT) l; } \ | |
901 bool operator > (const short& l) const { return data > (EMACS_INT) l; } \ | |
902 bool operator >= (const short& l) const { return data >= (EMACS_INT) l; } \ | |
903 bool operator == (const short& l) const { return data == (EMACS_INT) l; } \ | |
904 bool operator != (const short& l) const { return data != (EMACS_INT) l; } \ | |
905 bool operator < (const unsigned short& l) const \ | |
906 { return data < (EMACS_INT) l; } \ | |
907 bool operator <= (const unsigned short& l) const \ | |
908 { return data <= (EMACS_INT) l; } \ | |
909 bool operator > (const unsigned short& l) const \ | |
910 { return data > (EMACS_INT) l; } \ | |
911 bool operator >= (const unsigned short& l) const \ | |
912 { return data >= (EMACS_INT) l; } \ | |
913 bool operator == (const unsigned short& l) const \ | |
914 { return data == (EMACS_INT) l; } \ | |
915 bool operator != (const unsigned short& l) const \ | |
916 { return data != (EMACS_INT) l; } \ | |
917 bool operator ! () const { return !data; } | |
918 | |
919 /* Declare the "bad" or disallowed arithmetic and comparion operations | |
920 between class GOOD and class BAD. Meant to go inside the private | |
921 section of class GOOD. */ | |
922 | |
923 #define DECLARE_BAD_INTCLASS_ARITH_COMPARE(good, bad) \ | |
924 good operator += (const bad& l) { return badret; } \ | |
925 good operator -= (const bad& l) { return badret; } \ | |
926 good operator *= (const bad& l) { return badret; } \ | |
927 good operator /= (const bad& l) { return badret; } \ | |
928 good operator + (const bad& l) { return badret; } \ | |
929 good operator - (const bad& l) { return badret; } \ | |
930 good operator * (const bad& l) { return badret; } \ | |
931 good operator / (const bad& l) { return badret; } \ | |
932 \ | |
933 bool operator < (const bad& l) { return 0; } \ | |
934 bool operator <= (const bad& l) { return 0; } \ | |
935 bool operator > (const bad& l) { return 0; } \ | |
936 bool operator >= (const bad& l) { return 0; } \ | |
937 bool operator == (const bad& l) { return 0; } \ | |
938 bool operator != (const bad& l) { return 0; } | |
939 | |
940 /* Declare the "bad" or disallowed arithmetic operations between class GOOD | |
941 and another of the same class, for a position class. Meant to go inside | |
942 the private section of class GOOD. */ | |
943 | |
944 #define DECLARE_BAD_POS_CLASS_ARITH(good) \ | |
945 good operator += (const good& l) { return badret; } \ | |
946 good operator -= (const good& l) { return badret; } \ | |
947 good operator *= (const good& l) { return badret; } \ | |
948 good operator /= (const good& l) { return badret; } \ | |
949 good operator + (const good& l) { return badret; } \ | |
950 good operator * (const good& l) { return badret; } \ | |
951 good operator / (const good& l) { return badret; } | |
952 | |
953 /* Basic declaration at the top of all integral classes. Don't call | |
954 directly, use one of the more specific versions below. */ | |
955 | |
956 #define DECLARE_INTCLASS(cl) \ | |
957 public: \ | |
958 EMACS_INT data; \ | |
959 cl () { data = 0xCDCDCDCD; } \ | |
960 cl (int i) { data = i; } \ | |
961 cl (unsigned int i) { data = i; } \ | |
962 cl (long i) { data = i; } \ | |
963 cl (unsigned long i) { data = i; } \ | |
964 cl (short i) { data = i; } \ | |
965 cl (unsigned short i) { data = i; } \ | |
966 operator EMACS_INT () const { return data; } | |
967 | |
968 /* Basic declaration at the top of all count classes. */ | |
969 | |
970 #define DECLARE_COUNT_CLASS(cl) \ | |
971 DECLARE_INTCLASS (cl) \ | |
972 DECLARE_INTCLASS_ARITH_COMPARE (cl, cl) \ | |
973 private: \ | |
974 static cl badret; | |
975 | |
976 /* Basic declaration at the bottom of the prelude of all position classes. | |
977 Don't call directly. */ | |
978 | |
979 #define DECLARE_POS_CLASS_SECOND_HALF(cl, countcl) \ | |
980 DECLARE_INTCLASS_ARITH_COMPARE (cl, countcl) \ | |
981 countcl operator - (const cl& l) const { return countcl (data - l.data); } \ | |
982 private: \ | |
983 static cl badret; \ | |
984 DECLARE_BAD_POS_INTCLASS_ARITH (cl) | |
985 | |
986 /* Basic declaration at the top of all buffer position classes. */ | |
987 | |
988 #define DECLARE_BPOS_CLASS(cl, countcl) \ | |
989 DECLARE_INTCLASS (cl) \ | |
990 DECLARE_POS_CLASS_SECOND_HALF (cl, countcl) | |
991 | |
992 /* Basic declaration at the top of all X-position classes (that can refer | |
993 to buffers or strings). CL1 and CL2 are the equivalent more specific | |
1318 | 994 classes referring only to buffers or strings, respectively. */ |
814 | 995 |
996 #define DECLARE_XPOS_CLASS(cl, countcl, cl1, cl2) \ | |
997 DECLARE_INTCLASS (cl) \ | |
998 cl (const cl1& x) { data = x.data; } \ | |
999 cl (const cl2& x) { data = x.data; } \ | |
1000 operator cl1 () const { return cl1 (data); } \ | |
1001 operator cl2 () const { return cl2 (data); } \ | |
1002 DECLARE_POS_CLASS_SECOND_HALF (cl, countcl) | |
1003 | |
1004 /* Declare the "bad" or disallowed arithmetic and comparion operations | |
1005 between class CHARCL (a character class) and various non-character | |
1006 classes. Meant to go inside the private section of class GOOD. */ | |
1007 | |
1008 #define DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE(charcl) \ | |
1009 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Bytecount) \ | |
1010 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Bytebpos) \ | |
1011 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Bytexpos) \ | |
1012 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Membpos) \ | |
1013 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Memxpos) | |
1014 | |
1015 /* Declare the "bad" or disallowed arithmetic and comparion operations | |
1016 between class BYTECL (a byte class) and various non-byte classes. | |
1017 Meant to go inside the private section of class GOOD. */ | |
1018 | |
1019 #define DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE(bytecl) \ | |
1020 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charcount) \ | |
1021 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charbpos) \ | |
1022 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charxpos) \ | |
1023 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Membpos) \ | |
1024 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Memxpos) | |
1025 | |
1026 /* Declare the "bad" or disallowed arithmetic and comparion operations | |
1027 between class BYTECL (a mem class) and various non-mem classes. | |
1028 Meant to go inside the private section of class GOOD. */ | |
1029 | |
1030 #define DECLARE_BAD_MEM_INTCLASS_ARITH_COMPARE(bytecl) \ | |
1031 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charcount) \ | |
1032 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charbpos) \ | |
1033 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charxpos) \ | |
1034 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Bytebpos) \ | |
1035 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Bytexpos) | |
1036 | |
1037 class Charcount | |
1038 { | |
1039 DECLARE_COUNT_CLASS (Charcount) | |
1040 DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE (Charcount) | |
1041 }; | |
1042 | |
1043 class Charbpos | |
1044 { | |
1045 DECLARE_BPOS_CLASS (Charbpos, Charcount) | |
1046 DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE (Charbpos) | |
1047 }; | |
1048 | |
1049 class Charxpos | |
1050 { | |
1051 DECLARE_XPOS_CLASS (Charxpos, Charcount, Charbpos, Charcount) | |
1052 DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE (Charxpos) | |
1053 }; | |
1054 | |
1055 class Bytecount | |
1056 { | |
1057 DECLARE_COUNT_CLASS (Bytecount) | |
1058 DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE (Bytecount) | |
1059 }; | |
1060 | |
1061 class Bytebpos | |
1062 { | |
1063 DECLARE_BPOS_CLASS (Bytebpos, Bytecount) | |
1064 DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE (Bytebpos) | |
1065 }; | |
1066 | |
1067 class Bytexpos | |
1068 { | |
1069 DECLARE_XPOS_CLASS (Bytexpos, Bytecount, Bytebpos, Bytecount) | |
1070 DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE (Bytexpos) | |
1071 }; | |
1072 | |
1073 class Membpos | |
1074 { | |
1075 DECLARE_BPOS_CLASS (Membpos, Bytecount) | |
1076 DECLARE_BAD_MEM_INTCLASS_ARITH_COMPARE (Membpos) | |
1077 }; | |
1078 | |
1079 class Memxpos | |
1080 { | |
1081 DECLARE_XPOS_CLASS (Memxpos, Bytecount, Membpos, Bytecount) | |
1082 DECLARE_BAD_MEM_INTCLASS_ARITH_COMPARE (Memxpos) | |
1083 }; | |
1084 | |
826 | 1085 #define DECLARE_POINTER_TYPE_ARITH_COUNT(pointer, countcl) \ |
1086 inline pointer operator += (const pointer & x, const countcl& y) \ | |
1087 { x += y.data; return x; } \ | |
1088 inline pointer operator -= (const pointer & x, const countcl& y) \ | |
1089 { x -= y.data; return x; } \ | |
1090 inline pointer operator + (const pointer x, const countcl& y) \ | |
1091 { return x + y.data; } \ | |
1092 inline pointer operator - (const pointer x, const countcl& y) \ | |
814 | 1093 { return x - y.data; } |
1094 | |
1095 #define DECLARE_INTEGRAL_TYPE_ARITH_COUNT(integral, countcl) \ | |
1096 inline integral operator += (integral & x, const countcl& y) \ | |
1097 { x += y.data; return x; } \ | |
1098 inline integral operator -= (integral & x, const countcl& y) \ | |
1099 { x -= y.data; return x; } \ | |
1100 inline countcl operator + (integral x, const countcl& y) \ | |
1101 { return countcl (x + y.data); } \ | |
1102 inline countcl operator - (integral x, const countcl& y) \ | |
1103 { return countcl (x - y.data); } | |
1104 | |
1105 #define DECLARE_INTEGRAL_TYPE_COMPARE(integral, cl) \ | |
1106 inline bool operator < (integral x, const cl& y) \ | |
1107 { return (EMACS_INT) x < y.data; } \ | |
1108 inline bool operator <= (integral x, const cl& y) \ | |
1109 { return (EMACS_INT) x <= y.data; } \ | |
1110 inline bool operator > (integral x, const cl& y) \ | |
1111 { return (EMACS_INT) x > y.data; } \ | |
1112 inline bool operator >= (integral x, const cl& y) \ | |
1113 { return (EMACS_INT) x >= y.data; } \ | |
1114 inline bool operator == (integral x, const cl& y) \ | |
1115 { return (EMACS_INT) x == y.data; } \ | |
1116 inline bool operator != (integral x, const cl& y) \ | |
1117 { return (EMACS_INT) x != y.data; } | |
1118 | |
1119 #if 0 | |
1120 /* Unfortunately C++ doesn't let you overload the ?: operator, so we have | |
1121 to manually deal with ambiguities using casting */ | |
1122 #define DECLARE_INTEGRAL_TYPE_TRISTATE(integral, cl) \ | |
1123 inline cl operator ?: (bool b, integral x, const cl& y) \ | |
1124 { return b ? cl (x) : y; } \ | |
1125 inline cl operator ?: (bool b, const cl& x, integral y) \ | |
1126 { return b ? x : cl (y); } | |
1127 #endif /* 0 */ | |
1128 | |
867 | 1129 /* DECLARE_POINTER_TYPE_ARITH_COUNT (const Ibyte *, Bytecount); |
826 | 1130 DECLARE_POINTER_TYPE_ARITH_COUNT (const Extbyte *, Bytecount); */ |
867 | 1131 DECLARE_POINTER_TYPE_ARITH_COUNT (Ibyte *, Bytecount); |
814 | 1132 DECLARE_POINTER_TYPE_ARITH_COUNT (Extbyte *, Bytecount); |
1133 | |
1134 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (int, Bytecount); | |
1135 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (int, Charcount); | |
1136 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned int, Bytecount); | |
1137 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned int, Charcount); | |
1138 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (long, Bytecount); | |
1139 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (long, Charcount); | |
1140 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned long, Bytecount); | |
1141 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned long, Charcount); | |
1142 | |
1143 DECLARE_INTEGRAL_TYPE_COMPARE (int, Bytecount); | |
1144 DECLARE_INTEGRAL_TYPE_COMPARE (int, Charcount); | |
1145 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned int, Bytecount); | |
1146 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned int, Charcount); | |
1147 DECLARE_INTEGRAL_TYPE_COMPARE (long, Bytecount); | |
1148 DECLARE_INTEGRAL_TYPE_COMPARE (long, Charcount); | |
1149 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned long, Bytecount); | |
1150 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned long, Charcount); | |
1151 | |
1152 #if 0 /* doesn't work */ | |
867 | 1153 inline Bytecount operator - (const Ibyte *x, const Ibyte *y) \ |
814 | 1154 { return Bytecount (x - y); } |
1155 #endif | |
1156 | |
1157 #endif /* __cplusplus */ | |
1158 | |
665 | 1159 /* Counts of elements */ |
1160 typedef EMACS_INT Elemcount; | |
1161 /* Hash codes */ | |
1162 typedef unsigned long Hashcode; | |
2367 | 1163 /* Booleans */ |
1164 typedef int Boolint; | |
771 | 1165 |
793 | 1166 /* ------------------------ basic compiler defines ------------------- */ |
428 | 1167 |
1743 | 1168 #include "compiler.h" |
1632 | 1169 |
793 | 1170 /* ------------------------ alignment definitions ------------------- */ |
1171 | |
454 | 1172 /* No type has a greater alignment requirement than max_align_t. |
1173 (except perhaps for types we don't use, like long double) */ | |
1174 typedef union | |
1175 { | |
1176 struct { long l; } l; | |
1177 struct { void *p; } p; | |
1178 struct { void (*f)(void); } f; | |
1179 struct { double d; } d; | |
1180 } max_align_t; | |
1181 | |
771 | 1182 /* ALIGNOF returns the required alignment of a type -- i.e. a value such |
1183 that data of this type must begin at a memory address which is a | |
1184 multiple of that value. For simple types, this is often the same size | |
1185 as the type itself. */ | |
1186 | |
428 | 1187 #ifndef ALIGNOF |
1188 # if defined (__GNUC__) && (__GNUC__ >= 2) | |
454 | 1189 /* gcc has an extension that gives us exactly what we want. */ |
1190 # define ALIGNOF(type) __alignof__ (type) | |
1191 # elif ! defined (__cplusplus) | |
1192 /* The following is mostly portable, except that: | |
1193 - it doesn't work for inside out declarations like void (*) (void). | |
1194 (so just call ALIGNOF with a typedef'ed name) | |
1195 - it doesn't work with C++. The C++ committee has decided, | |
1196 in its infinite wisdom, that: | |
1197 "Types must be declared in declarations, not in expressions." */ | |
1198 # define ALIGNOF(type) offsetof (struct { char c; type member; }, member) | |
428 | 1199 # else |
456 | 1200 /* C++ is annoying, but it has a big bag of tricks. |
1201 The following doesn't have the "inside out" declaration bug C does. */ | |
458 | 1202 template<typename T> struct alignment_trick { char c; T member; }; |
456 | 1203 # define ALIGNOF(type) offsetof (alignment_trick<type>, member) |
428 | 1204 # endif |
454 | 1205 #endif /* ALIGNOF */ |
428 | 1206 |
771 | 1207 /* ALIGN_SIZE returns the smallest size greater than or equal to LEN which |
1208 is a multiple of UNIT. This can be used to assure that data that | |
1209 follows a block of the returned size is of correct alignment for a type | |
1210 whose alignment (as returned by ALIGNOF) is UNIT (provided that the | |
1211 block itself is correctly aligned for this type; memory returned by | |
1212 malloc() is guaranteed to be correctly aligned for all types). */ | |
1213 | |
428 | 1214 #define ALIGN_SIZE(len, unit) \ |
1215 ((((len) + (unit) - 1) / (unit)) * (unit)) | |
1216 | |
826 | 1217 /* ALIGN_FOR_TYPE returns the smallest size greater than or equal to LEN |
1218 which is aligned for the given type. This can be used to assure that | |
1219 data that follows a block of the returned size is of correct alignment | |
1220 for the type (provided that the block itself is correctly aligned for | |
1221 this type; memory returned by malloc() is guaranteed to be correctly | |
1222 aligned for all types). */ | |
1223 | |
1224 #define ALIGN_FOR_TYPE(len, type) ALIGN_SIZE (len, ALIGNOF (type)) | |
1225 | |
771 | 1226 /* MAX_ALIGN_SIZE returns the smallest size greater than or equal to LEN |
1227 which guarantees that data following a block of such size is correctly | |
1228 aligned for all types (provided that the block itself is so aligned, | |
1229 which is the case for memory returned by malloc()). */ | |
1230 | |
826 | 1231 #define MAX_ALIGN_SIZE(len) ALIGN_FOR_TYPE (len, max_align_t) |
1232 | |
1233 /* ALIGN_PTR returns the smallest pointer >= PTR which is aligned for | |
1234 data of TYPE. */ | |
1235 #define ALIGN_PTR(ptr, type) ((void *) ALIGN_FOR_TYPE ((size_t) (ptr), type)) | |
428 | 1236 |
1743 | 1237 BEGIN_C_DECLS |
1650 | 1238 |
793 | 1239 /* ------------------------ assertions ------------------- */ |
428 | 1240 |
1241 /* We define assert iff USE_ASSERTIONS or DEBUG_XEMACS is defined. | |
1242 Otherwise we define it to be empty. Quantify has shown that the | |
1243 time the assert checks take is measurable so let's not include them | |
771 | 1244 in production binaries. |
1245 | |
788 | 1246 If ASSERTIONS_DONT_ABORT defined, we will continue after assertion |
1247 failures. | |
1248 | |
1249 assert_at_line() is used for asserts inside of inline functions called | |
1250 from error-checking macros. If we're not tricky, we just get the file | |
1251 and line of the inline function, which is not very useful. */ | |
428 | 1252 |
1253 /* Highly dubious kludge */ | |
1254 /* (thanks, Jamie, I feel better now -- ben) */ | |
2367 | 1255 MODULE_API void assert_failed (const Ascbyte *, int, const Ascbyte *); |
2535 | 1256 #define ABORT() (assert_failed (__FILE__, __LINE__, "ABORT()")) |
1257 | |
4843
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
1258 /* This used to be ((void) (0)) but that triggers lots of unused variable |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
1259 warnings. It's pointless to force all that code to be rewritten, with |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
1260 added ifdefs. Any reasonable compiler will eliminate an expression with |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
1261 no effects. We keep this abstracted out like this in case we want to |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
1262 change it in the future. */ |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
1263 #define disabled_assert(x) ((void) (x)) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
1264 #define disabled_assert_with_message(x, msg) disabled_assert (x) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
1265 #define disabled_assert_at_line(x, file, line) disabled_assert (x) |
715b15990d0a
add more foo_checking_assert macros
Ben Wing <ben@xemacs.org>
parents:
4841
diff
changeset
|
1266 |
2535 | 1267 #ifdef USE_ASSERTIONS |
428 | 1268 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x)) |
853 | 1269 # define assert_with_message(x, msg) \ |
1270 ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, msg)) | |
788 | 1271 # define assert_at_line(x, file, line) \ |
1272 ((x) ? (void) 0 : assert_failed (file, line, #x)) | |
2535 | 1273 #elif defined (DEBUG_XEMACS) |
1274 # define assert(x) ((x) ? (void) 0 : (void) ABORT ()) | |
2956 | 1275 # define assert_with_message(x, msg) assert (x) |
2535 | 1276 # define assert_at_line(x, file, line) assert (x) |
428 | 1277 #else |
2956 | 1278 /* This used to be ((void) (0)) but that triggers lots of unused variable |
1279 warnings. It's pointless to force all that code to be rewritten, with | |
1280 added ifdefs. Any reasonable compiler will eliminate an expression with | |
1281 no effects. */ | |
1282 # define assert(x) ((void) (x)) | |
1283 # define assert_with_message(x, msg) assert (x) | |
2535 | 1284 # define assert_at_line(x, file, line) assert (x) |
428 | 1285 #endif |
1286 | |
2367 | 1287 /************************************************************************/ |
1288 /** Memory allocation **/ | |
1289 /************************************************************************/ | |
853 | 1290 |
793 | 1291 /* ------------------------ simple memory allocation ------------------- */ |
1292 | |
2367 | 1293 /* Basic memory allocation and freeing functions */ |
1294 void malloc_warning (const Ascbyte *); | |
1743 | 1295 MODULE_API void *xmalloc (Bytecount size) ATTRIBUTE_MALLOC; |
1296 MODULE_API void *xmalloc_and_zero (Bytecount size) ATTRIBUTE_MALLOC; | |
1297 MODULE_API void *xrealloc (void *, Bytecount size) ATTRIBUTE_MALLOC; | |
2367 | 1298 MODULE_API Chbyte *xstrdup (const Chbyte *) ATTRIBUTE_MALLOC; |
1299 | |
1300 /* Basic free function */ | |
1301 | |
1302 MODULE_API void xfree_1 (void *); | |
1303 #ifdef ERROR_CHECK_MALLOC | |
1304 /* This used to use a temporary variable, which both avoided the multiple | |
1305 evaluation and obviated the need for the TYPE argument. But that triggered | |
1306 complaints under strict aliasing. #### There should be a better way. */ | |
1307 #define xfree(lvalue, type) do \ | |
1308 { \ | |
1309 xfree_1 (lvalue); \ | |
3988 | 1310 VOIDP_CAST (lvalue) = (void *) DEADBEEF_CONSTANT; \ |
2367 | 1311 } while (0) |
1312 #else | |
1313 #define xfree(lvalue,type) xfree_1 (lvalue) | |
1314 #endif /* ERROR_CHECK_MALLOC */ | |
1315 | |
1316 /* ------------------------ stack allocation -------------------------- */ | |
1317 | |
1318 /* Allocating excessively large blocks on the stack can cause crashes. | |
851 | 1319 We provide MALLOC_OR_ALLOCA() below for places where it's likely that |
1320 large amounts will be allocated; it mallocs the block if it's too big. | |
1321 Unfortunately, that requires a call to unbind_to() at the end of the | |
1322 function, and it's not feasible to rewrite all calls to alloca() this | |
1323 way. | |
1324 | |
1325 Instead, we use the portable C alloca() substitute in alloca.c above a | |
1326 certain size. This actually uses malloc(), but checks the current stack | |
1327 pointer to see if data from previous alloca() calls needs to be freed. | |
1328 However, this can lead to large heap sizes -- especially since cleanup | |
1329 can only happen in a parent function, and will never happen if (as will | |
1330 often be the case) it's the same function in the same place in the code | |
1331 that keeps tripping the alloca() limit. | |
1332 | |
1333 So we set up a system to periodically force cleanup. Currently we | |
1334 do cleanup: | |
1335 | |
1336 -- Only when there's C alloca() data, and then | |
1337 -- Every stack alloca() or allocation of Lisp data, every call to | |
1338 next_event_internal() [typically near the top of the stack], | |
1339 or every 10th funcall | |
1340 | |
1341 This should not be a big penalty because | |
1342 | |
1343 (a) If there are few C alloca() chunks, checking them will be fast | |
1344 (b) If not, we've allocated a huge amount of heap space (remember, each | |
1345 chunk represents > 256K of heap), and we really want them gone | |
1346 */ | |
1347 | |
1348 /* We use a larger maximum when the choice is alloca() vs. the C alloca() | |
1349 substitute than when the choice is vs. malloc(), because in the former | |
1350 case, our alternative choice is less palatable because the memory may | |
1351 not be freed for awhile. */ | |
1352 | |
1353 #define MAX_ALLOCA_VS_C_ALLOCA 262144 | |
1354 #define MAX_ALLOCA_VS_MALLOC 65536 | |
1355 | |
1356 #define MAX_FUNCALLS_BETWEEN_ALLOCA_CLEANUP 10 | |
1357 | |
1632 | 1358 extern MODULE_API Bytecount __temp_alloca_size__; |
851 | 1359 extern Bytecount funcall_alloca_count; |
1360 | |
1333 | 1361 #ifdef ERROR_CHECK_MALLOC |
1632 | 1362 extern MODULE_API int regex_malloc_disallowed; |
1333 | 1363 #define REGEX_MALLOC_CHECK() assert (!regex_malloc_disallowed) |
1364 #else | |
1365 #define REGEX_MALLOC_CHECK() ((void) 0) | |
1366 #endif | |
1367 | |
851 | 1368 /* Do stack or heap alloca() depending on size. |
1369 | |
1370 NOTE: The use of a global temporary like this is unsafe if ALLOCA() occurs | |
1371 twice anywhere in the same expression; but that seems highly unlikely. The | |
1372 alternative is to force all callers to declare a local temporary if the | |
1373 expression has side effects -- something easy to forget. */ | |
1374 | |
1375 #define ALLOCA(size) \ | |
1333 | 1376 (REGEX_MALLOC_CHECK (), \ |
1377 __temp_alloca_size__ = (size), \ | |
851 | 1378 __temp_alloca_size__ > MAX_ALLOCA_VS_C_ALLOCA ? \ |
1379 xemacs_c_alloca (__temp_alloca_size__) : \ | |
1380 (need_to_check_c_alloca ? xemacs_c_alloca (0) : 0, \ | |
1381 alloca (__temp_alloca_size__))) | |
1382 | |
1318 | 1383 /* Version of ALLOCA() that is guaranteed to work inside of function calls |
1384 (i.e., we call the C alloca if regular alloca() is broken inside of | |
1385 function calls). */ | |
1386 #ifdef BROKEN_ALLOCA_IN_FUNCTION_CALLS | |
1387 #define ALLOCA_FUNCALL_OK(size) xemacs_c_alloca (size) | |
1388 #else | |
1389 #define ALLOCA_FUNCALL_OK(size) ALLOCA (size) | |
1390 #endif | |
1391 | |
2367 | 1392 MODULE_API void *xemacs_c_alloca (unsigned int size) ATTRIBUTE_MALLOC; |
1393 | |
1394 MODULE_API int record_unwind_protect_freeing (void *ptr); | |
1395 | |
1396 DECLARE_INLINE_HEADER ( | |
1397 void * | |
1398 xmalloc_and_record_unwind (Bytecount size) | |
1399 ) | |
1400 { | |
1401 void *ptr = xmalloc (size); | |
1402 record_unwind_protect_freeing (ptr); | |
1403 return ptr; | |
1404 } | |
1405 | |
851 | 1406 /* WARNING: If you use this, you must unbind_to() at the end of your |
1407 function! */ | |
1408 | |
1409 #define MALLOC_OR_ALLOCA(size) \ | |
1333 | 1410 (REGEX_MALLOC_CHECK (), \ |
1411 __temp_alloca_size__ = (size), \ | |
851 | 1412 __temp_alloca_size__ > MAX_ALLOCA_VS_MALLOC ? \ |
1413 xmalloc_and_record_unwind (__temp_alloca_size__) : \ | |
1414 (need_to_check_c_alloca ? xemacs_c_alloca (0) : 0, \ | |
1415 alloca (__temp_alloca_size__))) | |
793 | 1416 |
2367 | 1417 /* -------------- convenience functions for memory allocation ------------- */ |
1418 | |
1419 #define countof(x) ((int) (sizeof(x)/sizeof((x)[0]))) | |
1420 #define xnew(type) ((type *) xmalloc (sizeof (type))) | |
1421 #define xnew_array(type, len) ((type *) xmalloc ((len) * sizeof (type))) | |
1422 #define xnew_and_zero(type) ((type *) xmalloc_and_zero (sizeof (type))) | |
1423 #define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue))) | |
1424 #define xnew_array_and_zero(type, len) ((type *) xmalloc_and_zero ((len) * sizeof (type))) | |
1425 | |
1426 #define alloca_new(type) ((type *) ALLOCA (sizeof (type))) | |
1427 #define alloca_array(type, len) ((type *) ALLOCA ((len) * sizeof (type))) | |
1428 | |
1429 #define alloca_itexts(num) alloca_array (Itext, num) | |
1430 #define alloca_ibytes(num) alloca_array (Ibyte, num) | |
1431 #define alloca_extbytes(num) alloca_array (Extbyte, num) | |
1432 #define alloca_rawbytes(num) alloca_array (Rawbyte, num) | |
1433 #define alloca_binbytes(num) alloca_array (Binbyte, num) | |
1434 #define alloca_ascbytes(num) alloca_array (Ascbyte, num) | |
1435 #define xmalloc_itexts(num) xnew_array (Itext, num) | |
1436 #define xnew_ibytes(num) xnew_array (Ibyte, num) | |
1437 #define xnew_extbytes(num) xnew_array (Extbyte, num) | |
1438 #define xnew_rawbytes(num) xnew_array (Rawbyte, num) | |
1439 #define xnew_binbytes(num) xnew_array (Binbyte, num) | |
1440 #define xnew_ascbytes(num) xnew_array (Ascbyte, num) | |
1441 | |
1442 /* Make an alloca'd copy of a Ibyte * */ | |
1443 #define IBYTE_STRING_TO_ALLOCA(p, lval) \ | |
1444 do { \ | |
1445 Ibyte **_bsta_ = (Ibyte **) &(lval); \ | |
1446 const Ibyte *_bsta_2 = (p); \ | |
1447 Bytecount _bsta_3 = qxestrlen (_bsta_2); \ | |
1448 *_bsta_ = alloca_ibytes (1 + _bsta_3); \ | |
1449 memcpy (*_bsta_, _bsta_2, 1 + _bsta_3); \ | |
1450 } while (0) | |
1451 | |
1452 /* ----------------- convenience functions for reallocation --------------- */ | |
1453 | |
1454 #define XREALLOC_ARRAY(ptr, type, len) \ | |
1455 ((void) (ptr = (type *) xrealloc (ptr, (len) * sizeof (type)))) | |
1456 | |
793 | 1457 /* also generally useful if you want to avoid arbitrary size limits |
1458 but don't need a full dynamic array. Assumes that BASEVAR points | |
1459 to a malloced array of TYPE objects (or possibly a NULL pointer, | |
1460 if SIZEVAR is 0), with the total size stored in SIZEVAR. This | |
1461 macro will realloc BASEVAR as necessary so that it can hold at | |
1462 least NEEDED_SIZE objects. The reallocing is done by doubling, | |
1463 which ensures constant amortized time per element. */ | |
1464 #define DO_REALLOC(basevar, sizevar, needed_size, type) do { \ | |
1465 Bytecount do_realloc_needed_size = (needed_size); \ | |
1333 | 1466 REGEX_MALLOC_CHECK (); \ |
793 | 1467 if ((sizevar) < do_realloc_needed_size) \ |
1468 { \ | |
1469 if ((sizevar) < 32) \ | |
1470 (sizevar) = 32; \ | |
1471 while ((sizevar) < do_realloc_needed_size) \ | |
1472 (sizevar) *= 2; \ | |
1473 XREALLOC_ARRAY (basevar, type, (sizevar)); \ | |
1474 } \ | |
1475 } while (0) | |
1476 | |
2367 | 1477 /************************************************************************/ |
1478 /** Definitions of more complex types **/ | |
1479 /************************************************************************/ | |
428 | 1480 |
647 | 1481 /* Note that the simplest typedefs are near the top of this file. */ |
1482 | |
428 | 1483 /* We put typedefs here so that prototype declarations don't choke. |
1484 Note that we don't actually declare the structures here (except | |
1485 maybe for simple structures like Dynarrs); that keeps them private | |
1486 to the routines that actually use them. */ | |
1487 | |
771 | 1488 /* ------------------------------- */ |
1489 /* Error_Behavior typedefs */ | |
1490 /* ------------------------------- */ | |
1491 | |
800 | 1492 #ifndef ERROR_CHECK_TYPES |
771 | 1493 |
1494 typedef enum error_behavior | |
428 | 1495 { |
771 | 1496 ERROR_ME, |
1497 ERROR_ME_NOT, | |
793 | 1498 ERROR_ME_WARN, |
1499 ERROR_ME_DEBUG_WARN | |
771 | 1500 } Error_Behavior; |
1501 | |
1502 #define ERRB_EQ(a, b) ((a) == (b)) | |
1503 | |
1504 #else | |
1505 | |
1506 /* By defining it like this, we provide strict type-checking | |
1507 for code that lazily uses ints. */ | |
1508 | |
1509 typedef struct _error_behavior_struct_ | |
428 | 1510 { |
771 | 1511 int really_unlikely_name_to_have_accidentally_in_a_non_errb_structure; |
1512 } Error_Behavior; | |
1513 | |
1514 extern Error_Behavior ERROR_ME; | |
1515 extern Error_Behavior ERROR_ME_NOT; | |
1516 extern Error_Behavior ERROR_ME_WARN; | |
793 | 1517 extern Error_Behavior ERROR_ME_DEBUG_WARN; |
771 | 1518 |
1519 #define ERRB_EQ(a, b) \ | |
1520 ((a).really_unlikely_name_to_have_accidentally_in_a_non_errb_structure == \ | |
1521 (b).really_unlikely_name_to_have_accidentally_in_a_non_errb_structure) | |
1522 | |
1523 #endif | |
1524 | |
1525 /* ------------------------------- */ | |
1526 /* Empty structures and typedefs */ | |
1527 /* ------------------------------- */ | |
428 | 1528 |
1529 struct buffer; /* "buffer.h" */ | |
1530 struct console; /* "console.h" */ | |
1531 struct device; /* "device.h" */ | |
1532 struct extent_fragment; | |
1533 struct extent; | |
1534 struct frame; /* "frame.h" */ | |
1535 struct window; /* "window.h" */ | |
771 | 1536 struct utimbuf; /* "systime.h" or <utime.h> */ |
428 | 1537 struct display_line; |
1538 struct display_glyph_area; | |
1539 struct display_box; | |
1540 struct redisplay_info; | |
1541 struct window_mirror; | |
1542 struct scrollbar_instance; | |
1543 struct font_metric_info; | |
1544 struct face_cachel; | |
1545 struct console_type_entry; | |
1546 | |
771 | 1547 /* This is shared by process.h, events.h and others in future. |
1548 See events.h for description */ | |
4123 | 1549 typedef unsigned EMACS_INT USID; |
771 | 1550 typedef int face_index; |
1551 typedef int glyph_index; | |
1726 | 1552 typedef struct lstream Lstream; /* lstream.h */ |
872 | 1553 typedef struct extent *EXTENT; /* extents-impl.h */ |
771 | 1554 typedef struct Lisp_Event Lisp_Event; /* "events.h" */ |
872 | 1555 typedef struct Lisp_Face Lisp_Face; /* "faces-impl.h" */ |
771 | 1556 typedef struct Lisp_Process Lisp_Process; /* "procimpl.h" */ |
872 | 1557 typedef struct Lisp_Color_Instance Lisp_Color_Instance; /* objects-impl.h */ |
1558 typedef struct Lisp_Font_Instance Lisp_Font_Instance; /* objects-impl.h */ | |
1726 | 1559 typedef struct Lisp_Image_Instance Lisp_Image_Instance; /* glyphs.h */ |
771 | 1560 typedef struct Lisp_Gui_Item Lisp_Gui_Item; |
1561 | |
1562 /* ------------------------------- */ | |
1563 /* enum typedefs */ | |
1564 /* ------------------------------- */ | |
1565 | |
428 | 1566 enum run_hooks_condition |
1567 { | |
1568 RUN_HOOKS_TO_COMPLETION, | |
1569 RUN_HOOKS_UNTIL_SUCCESS, | |
1570 RUN_HOOKS_UNTIL_FAILURE | |
1571 }; | |
1572 | |
1573 #ifdef HAVE_TOOLBARS | |
1574 enum toolbar_pos | |
1575 { | |
1576 TOP_TOOLBAR, | |
1577 BOTTOM_TOOLBAR, | |
1578 LEFT_TOOLBAR, | |
1579 RIGHT_TOOLBAR | |
1580 }; | |
1581 #endif | |
1582 | |
1583 enum edge_style | |
1584 { | |
1585 EDGE_ETCHED_IN, | |
1586 EDGE_ETCHED_OUT, | |
1587 EDGE_BEVEL_IN, | |
1588 EDGE_BEVEL_OUT | |
1589 }; | |
1590 | |
1591 enum munge_me_out_the_door | |
1592 { | |
1593 MUNGE_ME_FUNCTION_KEY, | |
1594 MUNGE_ME_KEY_TRANSLATION | |
1595 }; | |
1596 | |
771 | 1597 /* ------------------------------- */ |
1598 /* misc */ | |
1599 /* ------------------------------- */ | |
1600 | |
1601 #ifdef MEMORY_USAGE_STATS | |
1602 | |
1603 /* This structure is used to keep statistics on the amount of memory | |
1604 in use. | |
1605 | |
1606 WAS_REQUESTED stores the actual amount of memory that was requested | |
1607 of the allocation function. The *_OVERHEAD fields store the | |
1608 additional amount of memory that was grabbed by the functions to | |
1609 facilitate allocation, reallocation, etc. MALLOC_OVERHEAD is for | |
1610 memory allocated with malloc(); DYNARR_OVERHEAD is for dynamic | |
1611 arrays; GAP_OVERHEAD is for gap arrays. Note that for (e.g.) | |
1612 dynamic arrays, there is both MALLOC_OVERHEAD and DYNARR_OVERHEAD | |
1613 memory: The dynamic array allocates memory above and beyond what | |
1614 was asked of it, and when it in turns allocates memory using | |
1615 malloc(), malloc() allocates memory beyond what it was asked | |
1616 to allocate. | |
1617 | |
1618 Functions that accept a structure of this sort do not initialize | |
1619 the fields to 0, and add any existing values to whatever was there | |
1620 before; this way, you can get a cumulative effect. */ | |
1621 | |
1622 struct overhead_stats | |
1623 { | |
1624 int was_requested; | |
1625 int malloc_overhead; | |
1626 int dynarr_overhead; | |
1627 int gap_overhead; | |
1628 }; | |
1629 | |
1630 #endif /* MEMORY_USAGE_STATS */ | |
1631 | |
428 | 1632 |
1633 /************************************************************************/ | |
1634 /* Definition of Lisp_Object data type */ | |
1635 /************************************************************************/ | |
1636 | |
1637 /* Define the fundamental Lisp data structures */ | |
1638 | |
1639 /* This is the set of Lisp data types */ | |
1640 | |
1641 enum Lisp_Type | |
1642 { | |
1643 Lisp_Type_Record, | |
1644 Lisp_Type_Int_Even, | |
1645 Lisp_Type_Char, | |
1646 Lisp_Type_Int_Odd | |
1647 }; | |
1648 | |
1649 #define POINTER_TYPE_P(type) ((type) == Lisp_Type_Record) | |
1650 | |
1651 /* Overridden by m/next.h */ | |
1652 #ifndef ASSERT_VALID_POINTER | |
1653 # define ASSERT_VALID_POINTER(pnt) (assert ((((EMACS_UINT) pnt) & 3) == 0)) | |
1654 #endif | |
1655 | |
1656 #define GCMARKBITS 0 | |
1657 #define GCTYPEBITS 2 | |
1658 #define GCBITS 2 | |
1659 #define INT_GCBITS 1 | |
1660 | |
1661 #define INT_VALBITS (BITS_PER_EMACS_INT - INT_GCBITS) | |
1662 #define VALBITS (BITS_PER_EMACS_INT - GCBITS) | |
542 | 1663 #define EMACS_INT_MAX ((EMACS_INT) ((1UL << (INT_VALBITS - 1)) -1UL)) |
442 | 1664 #define EMACS_INT_MIN (-(EMACS_INT_MAX) - 1) |
802 | 1665 /* WARNING: evaluates its arg twice. */ |
1666 #define NUMBER_FITS_IN_AN_EMACS_INT(num) \ | |
1667 ((num) <= EMACS_INT_MAX && (num) >= EMACS_INT_MIN) | |
428 | 1668 |
1669 #ifdef USE_UNION_TYPE | |
1670 # include "lisp-union.h" | |
1671 #else /* !USE_UNION_TYPE */ | |
1672 # include "lisp-disunion.h" | |
1673 #endif /* !USE_UNION_TYPE */ | |
1674 | |
1675 #define XPNTR(x) ((void *) XPNTRVAL(x)) | |
1676 | |
1677 /* Close your eyes now lest you vomit or spontaneously combust ... */ | |
1678 | |
1679 #define HACKEQ_UNSAFE(obj1, obj2) \ | |
1680 (EQ (obj1, obj2) || (!POINTER_TYPE_P (XTYPE (obj1)) \ | |
1681 && !POINTER_TYPE_P (XTYPE (obj2)) \ | |
1682 && XCHAR_OR_INT (obj1) == XCHAR_OR_INT (obj2))) | |
1683 | |
1684 #ifdef DEBUG_XEMACS | |
1632 | 1685 extern MODULE_API int debug_issue_ebola_notices; |
1686 MODULE_API int eq_with_ebola_notice (Lisp_Object, Lisp_Object); | |
428 | 1687 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) \ |
1688 (debug_issue_ebola_notices ? eq_with_ebola_notice (obj1, obj2) \ | |
1689 : EQ (obj1, obj2)) | |
1690 #else | |
1691 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) EQ (obj1, obj2) | |
1692 #endif | |
1693 | |
1694 /* OK, you can open them again */ | |
1695 | |
1743 | 1696 END_C_DECLS |
1650 | 1697 |
428 | 1698 /************************************************************************/ |
442 | 1699 /** Definitions of basic Lisp objects **/ |
428 | 1700 /************************************************************************/ |
1701 | |
1702 #include "lrecord.h" | |
1703 | |
1743 | 1704 BEGIN_C_DECLS |
1650 | 1705 |
3293 | 1706 /* ------------------------ dynamic arrays ------------------- */ |
1707 | |
3092 | 1708 #ifdef NEW_GC |
1709 #ifdef ERROR_CHECK_STRUCTURES | |
1710 #define Dynarr_declare(type) \ | |
1711 struct lrecord_header header; \ | |
1712 type *base; \ | |
1713 const struct lrecord_implementation *lisp_imp; \ | |
1714 int locked; \ | |
1715 int elsize; \ | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1716 int len; \ |
3092 | 1717 int largest; \ |
1718 int max | |
1719 #else | |
1720 #define Dynarr_declare(type) \ | |
1721 struct lrecord_header header; \ | |
1722 type *base; \ | |
1723 const struct lrecord_implementation *lisp_imp; \ | |
1724 int elsize; \ | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1725 int len; \ |
3092 | 1726 int largest; \ |
1727 int max | |
1728 #endif /* ERROR_CHECK_STRUCTURES */ | |
3293 | 1729 #else /* not NEW_GC */ |
1730 #ifdef ERROR_CHECK_STRUCTURES | |
1731 #define Dynarr_declare(type) \ | |
1732 struct lrecord_header header; \ | |
1733 type *base; \ | |
1734 int locked; \ | |
1735 int elsize; \ | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1736 int len; \ |
3293 | 1737 int largest; \ |
1738 int max | |
1739 #else | |
1740 #define Dynarr_declare(type) \ | |
1741 struct lrecord_header header; \ | |
1742 type *base; \ | |
1743 int elsize; \ | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1744 int len; \ |
3293 | 1745 int largest; \ |
1746 int max | |
1747 #endif /* ERROR_CHECK_STRUCTURES */ | |
1748 #endif /* not NEW_GC */ | |
3092 | 1749 |
1750 typedef struct dynarr | |
1751 { | |
1752 Dynarr_declare (void); | |
1753 } Dynarr; | |
1754 | |
1755 MODULE_API void *Dynarr_newf (int elsize); | |
1756 MODULE_API void Dynarr_resize (void *dy, Elemcount size); | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1757 MODULE_API void Dynarr_insert_many (void *d, const void *el, int len, |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1758 int start); |
3092 | 1759 MODULE_API void Dynarr_delete_many (void *d, int start, int len); |
1760 MODULE_API void Dynarr_free (void *d); | |
1761 | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1762 #ifdef ERROR_CHECK_TYPES |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1763 DECLARE_INLINE_HEADER ( |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1764 int |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1765 Dynarr_verify_pos_at (void *d, int pos, const Ascbyte *file, int line) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1766 ) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1767 { |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1768 Dynarr *dy = (Dynarr *) d; |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1769 /* We use `largest', not `len', because the redisplay code often |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1770 accesses stuff between len and largest. */ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1771 assert_at_line (pos >= 0 && pos < dy->largest, file, line); |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1772 return pos; |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1773 } |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1774 #else |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1775 #define Dynarr_verify_pos(d, pos, file, line) (pos) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1776 #endif /* ERROR_CHECK_TYPES */ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1777 |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1778 #ifdef ERROR_CHECK_TYPES |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1779 DECLARE_INLINE_HEADER ( |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1780 int |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1781 Dynarr_verify_pos_atp (void *d, int pos, const Ascbyte *file, int line) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1782 ) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1783 { |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1784 Dynarr *dy = (Dynarr *) d; |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1785 /* We use `largest', not `len', because the redisplay code often |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1786 accesses stuff between len and largest. */ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1787 /* Code will often do something like ... |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1788 |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1789 val = make_bit_vector_from_byte_vector (Dynarr_atp (dyn, 0), |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1790 Dynarr_length (dyn)); |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1791 |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1792 which works fine when the Dynarr_length is non-zero, but when zero, |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1793 the result of Dynarr_atp() not only points past the end of the |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1794 allocated array, but the array may not have ever been allocated and |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1795 hence the return value is NULL. But the length of 0 causes the |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1796 pointer to never get checked. These can occur throughout the code |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1797 so we put in a special check. */ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1798 if (pos == 0 && dy->len == 0) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1799 return pos; |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1800 /* #### It's vaguely possible that some code could legitimately want to |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1801 retrieve a pointer to the position just past the end of dynarr memory. |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1802 This could happen with Dynarr_atp() but not Dynarr_at(). If so, it |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1803 will trigger this assert(). In such cases, it should be obvious that |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1804 the code wants to do this; rather than relaxing the assert, we should |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1805 probably create a new macro Dynarr_atp_allow_end() which is like |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1806 Dynarr_atp() but which allows for pointing at invalid addresses -- we |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1807 really want to check for cases of accessing just past the end of |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1808 memory, which is a likely off-by-one problem to occur and will usually |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1809 not trigger a protection fault (instead, you'll just get random |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1810 behavior, possibly overwriting other memory, which is bad). */ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1811 assert_at_line (pos >= 0 && pos < dy->largest, file, line); |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1812 return pos; |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1813 } |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1814 |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1815 DECLARE_INLINE_HEADER ( |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1816 int |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1817 Dynarr_verify_pos_atp_allow_end (void *d, int pos, const Ascbyte *file, |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1818 int line) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1819 ) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1820 { |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1821 Dynarr *dy = (Dynarr *) d; |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1822 /* We use `largest', not `len', because the redisplay code often |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1823 accesses stuff between len and largest. |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1824 We also allow referencing the very end, past the end of allocated |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1825 legitimately space. See comments in Dynarr_verify_pos_atp.()*/ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1826 assert_at_line (pos >= 0 && pos <= dy->largest, file, line); |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1827 return pos; |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1828 } |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1829 |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1830 #else |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1831 #define Dynarr_verify_pos_at(d, pos, file, line) (pos) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1832 #define Dynarr_verify_pos_atp(d, pos, file, line) (pos) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1833 #define Dynarr_verify_pos_atp_allow_end(d, pos, file, line) (pos) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1834 #endif /* ERROR_CHECK_TYPES */ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1835 |
3293 | 1836 #ifdef NEW_GC |
3092 | 1837 MODULE_API void *Dynarr_lisp_newf (int elsize, |
1838 const struct lrecord_implementation | |
1839 *dynarr_imp, | |
1840 const struct lrecord_implementation *imp); | |
1841 | |
1842 #define Dynarr_lisp_new(type, dynarr_imp, imp) \ | |
1843 ((type##_dynarr *) Dynarr_lisp_newf (sizeof (type), dynarr_imp, imp)) | |
1844 #define Dynarr_lisp_new2(dynarr_type, type, dynarr_imp, imp) \ | |
1845 ((dynarr_type *) Dynarr_lisp_newf (sizeof (type)), dynarr_imp, imp) | |
3293 | 1846 #endif /* NEW_GC */ |
3092 | 1847 #define Dynarr_new(type) ((type##_dynarr *) Dynarr_newf (sizeof (type))) |
1848 #define Dynarr_new2(dynarr_type, type) \ | |
1849 ((dynarr_type *) Dynarr_newf (sizeof (type))) | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1850 |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1851 #define Dynarr_at(d, pos) \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1852 ((d)->base[Dynarr_verify_pos_at (d, pos, __FILE__, __LINE__)]) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1853 #define Dynarr_atp_allow_end(d, pos) \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1854 (&((d)->base[Dynarr_verify_pos_atp_allow_end (d, pos, __FILE__, __LINE__)])) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1855 #define Dynarr_atp(d, pos) \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1856 (&((d)->base[Dynarr_verify_pos_atp (d, pos, __FILE__, __LINE__)])) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1857 |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1858 /* Old #define Dynarr_atp(d, pos) (&Dynarr_at (d, pos)) */ |
3092 | 1859 #define Dynarr_begin(d) Dynarr_atp (d, 0) |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1860 #define Dynarr_lastp(d) Dynarr_atp (d, Dynarr_length (d) - 1) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1861 #define Dynarr_past_lastp(d) Dynarr_atp_allow_end (d, Dynarr_length (d)) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1862 #define Dynarr_sizeof(d) ((d)->len * (d)->elsize) |
3092 | 1863 |
1864 #ifdef ERROR_CHECK_STRUCTURES | |
1865 DECLARE_INLINE_HEADER ( | |
1866 Dynarr * | |
1867 Dynarr_verify_1 (void *d, const Ascbyte *file, int line) | |
1868 ) | |
1869 { | |
1870 Dynarr *dy = (Dynarr *) d; | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1871 assert_at_line (dy->len >= 0 && dy->len <= dy->largest && |
3092 | 1872 dy->largest <= dy->max, file, line); |
1873 return dy; | |
1874 } | |
1875 | |
1876 DECLARE_INLINE_HEADER ( | |
1877 Dynarr * | |
1878 Dynarr_verify_mod_1 (void *d, const Ascbyte *file, int line) | |
1879 ) | |
1880 { | |
1881 Dynarr *dy = (Dynarr *) d; | |
1882 assert_at_line (!dy->locked, file, line); | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1883 assert_at_line (dy->len >= 0 && dy->len <= dy->largest && |
3092 | 1884 dy->largest <= dy->max, file, line); |
1885 return dy; | |
1886 } | |
1887 | |
1888 #define Dynarr_verify(d) Dynarr_verify_1 (d, __FILE__, __LINE__) | |
1889 #define Dynarr_verify_mod(d) Dynarr_verify_mod_1 (d, __FILE__, __LINE__) | |
1890 #define Dynarr_lock(d) (Dynarr_verify_mod (d)->locked = 1) | |
1891 #define Dynarr_unlock(d) ((d)->locked = 0) | |
1892 #else | |
1893 #define Dynarr_verify(d) (d) | |
1894 #define Dynarr_verify_mod(d) (d) | |
1895 #define Dynarr_lock(d) | |
1896 #define Dynarr_unlock(d) | |
1897 #endif /* ERROR_CHECK_STRUCTURES */ | |
1898 | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1899 #define Dynarr_length(d) (Dynarr_verify (d)->len) |
3092 | 1900 #define Dynarr_largest(d) (Dynarr_verify (d)->largest) |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1901 #define Dynarr_reset(d) (Dynarr_verify_mod (d)->len = 0) |
3092 | 1902 #define Dynarr_insert_many_at_start(d, el, len) \ |
1903 Dynarr_insert_many (d, el, len, 0) | |
1904 #define Dynarr_add_literal_string(d, s) Dynarr_add_many (d, s, sizeof (s) - 1) | |
1905 #define Dynarr_add_lisp_string(d, s, codesys) \ | |
1906 do { \ | |
1907 Lisp_Object dyna_ls_s = (s); \ | |
1908 Lisp_Object dyna_ls_cs = (codesys); \ | |
1909 Extbyte *dyna_ls_eb; \ | |
1910 Bytecount dyna_ls_bc; \ | |
1911 \ | |
1912 LISP_STRING_TO_SIZED_EXTERNAL (dyna_ls_s, dyna_ls_eb, \ | |
1913 dyna_ls_bc, dyna_ls_cs); \ | |
1914 Dynarr_add_many (d, dyna_ls_eb, dyna_ls_bc); \ | |
1915 } while (0) | |
1916 | |
3293 | 1917 #ifdef NEW_GC |
3092 | 1918 #define Dynarr_add(d, el) \ |
1919 do { \ | |
3319 | 1920 const struct lrecord_implementation *imp = (d)->lisp_imp; \ |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1921 if (Dynarr_verify_mod (d)->len >= (d)->max) \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1922 Dynarr_resize ((d), (d)->len+1); \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1923 ((d)->base)[(d)->len] = (el); \ |
3092 | 1924 \ |
3319 | 1925 if (imp) \ |
3092 | 1926 set_lheader_implementation \ |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1927 ((struct lrecord_header *)&(((d)->base)[(d)->len]), imp); \ |
3092 | 1928 \ |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1929 (d)->len++; \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1930 if ((d)->len > (d)->largest) \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1931 (d)->largest = (d)->len; \ |
3092 | 1932 } while (0) |
3293 | 1933 #else /* not NEW_GC */ |
3092 | 1934 #define Dynarr_add(d, el) ( \ |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1935 Dynarr_verify_mod (d)->len >= (d)->max ? Dynarr_resize ((d), (d)->len+1) : \ |
3092 | 1936 (void) 0, \ |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1937 ((d)->base)[(d)->len++] = (el), \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1938 (d)->len > (d)->largest ? (d)->largest = (d)->len : (int) 0) |
3293 | 1939 #endif /* not NEW_GC */ |
3092 | 1940 |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1941 /* Add LEN contiguous elements to a Dynarr */ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1942 |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1943 DECLARE_INLINE_HEADER ( |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1944 void |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1945 Dynarr_add_many (void *d, const void *el, int len) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1946 ) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1947 { |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1948 /* This duplicates Dynarr_insert_many to some extent; but since it is |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1949 called so often, it seemed useful to remove the unnecessary stuff |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1950 from that function and to make it inline */ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1951 Dynarr *dy = (Dynarr *) Dynarr_verify (d); |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1952 |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1953 if (dy->len + len > dy->max) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1954 Dynarr_resize (dy, dy->len + len); |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1955 /* Some functions call us with a value of 0 to mean "reserve space but |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1956 don't write into it" */ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1957 if (el) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1958 memcpy ((char *) dy->base + dy->len*dy->elsize, el, len*dy->elsize); |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1959 dy->len += len; |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1960 |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1961 if (dy->len > dy->largest) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1962 dy->largest = dy->len; |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1963 } |
3092 | 1964 |
1965 /* The following defines will get you into real trouble if you aren't | |
1966 careful. But they can save a lot of execution time when used wisely. */ | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1967 #define Dynarr_increment(d) (Dynarr_verify_mod (d)->len++) |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1968 #define Dynarr_set_size(d, n) \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1969 do { \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1970 Bytecount _dss_n = (n); \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1971 structure_checking_assert (_dss_n >= 0 && _dss_n <= (d)->largest); \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1972 Dynarr_verify_mod (d)->len = _dss_n; \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1973 } while (0) |
3092 | 1974 |
1975 #define Dynarr_pop(d) \ | |
4844
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1976 (assert ((d)->len > 0), Dynarr_verify_mod (d)->len--, \ |
91b3d00e717f
Various cleanups for Dynarr code, from Unicode-internal ws
Ben Wing <ben@xemacs.org>
parents:
4843
diff
changeset
|
1977 Dynarr_at (d, (d)->len)) |
3092 | 1978 #define Dynarr_delete(d, i) Dynarr_delete_many (d, i, 1) |
1979 #define Dynarr_delete_by_pointer(d, p) \ | |
1980 Dynarr_delete_many (d, (p) - ((d)->base), 1) | |
1981 | |
1982 #define Dynarr_delete_object(d, el) \ | |
1983 do \ | |
1984 { \ | |
1985 REGISTER int i; \ | |
1986 for (i = Dynarr_length (d) - 1; i >= 0; i--) \ | |
1987 { \ | |
1988 if (el == Dynarr_at (d, i)) \ | |
1989 Dynarr_delete_many (d, i, 1); \ | |
1990 } \ | |
1991 } while (0) | |
1992 | |
1993 #ifdef MEMORY_USAGE_STATS | |
1994 struct overhead_stats; | |
1995 Bytecount Dynarr_memory_usage (void *d, struct overhead_stats *stats); | |
1996 #endif | |
1997 | |
1998 void *stack_like_malloc (Bytecount size); | |
1999 void stack_like_free (void *val); | |
2000 | |
2001 /* ------------------------------- */ | |
2002 /* Dynarr typedefs */ | |
2003 /* ------------------------------- */ | |
2004 | |
2005 /* Dynarr typedefs -- basic types first */ | |
2006 | |
2007 typedef struct | |
2008 { | |
2009 Dynarr_declare (Ibyte); | |
2010 } Ibyte_dynarr; | |
2011 | |
2012 typedef struct | |
2013 { | |
2014 Dynarr_declare (Extbyte); | |
2015 } Extbyte_dynarr; | |
2016 | |
2017 typedef struct | |
2018 { | |
2019 Dynarr_declare (Ichar); | |
2020 } Ichar_dynarr; | |
2021 | |
2022 typedef struct | |
2023 { | |
2024 Dynarr_declare (char); | |
2025 } char_dynarr; | |
2026 | |
2027 typedef struct | |
2028 { | |
2029 Dynarr_declare (char *); | |
2030 } char_ptr_dynarr; | |
2031 | |
2032 typedef unsigned char unsigned_char; | |
2033 typedef struct | |
2034 { | |
2035 Dynarr_declare (unsigned char); | |
2036 } unsigned_char_dynarr; | |
2037 | |
2038 typedef unsigned long unsigned_long; | |
2039 typedef struct | |
2040 { | |
2041 Dynarr_declare (unsigned long); | |
2042 } unsigned_long_dynarr; | |
2043 | |
2044 typedef struct | |
2045 { | |
2046 Dynarr_declare (int); | |
2047 } int_dynarr; | |
2048 | |
2049 typedef struct | |
2050 { | |
2051 Dynarr_declare (Charbpos); | |
2052 } Charbpos_dynarr; | |
2053 | |
2054 typedef struct | |
2055 { | |
2056 Dynarr_declare (Bytebpos); | |
2057 } Bytebpos_dynarr; | |
2058 | |
2059 typedef struct | |
2060 { | |
2061 Dynarr_declare (Charcount); | |
2062 } Charcount_dynarr; | |
2063 | |
2064 typedef struct | |
2065 { | |
2066 Dynarr_declare (Bytecount); | |
2067 } Bytecount_dynarr; | |
2068 | |
2069 /* Dynarr typedefs -- more complex types */ | |
2070 | |
2071 typedef struct | |
2072 { | |
2073 Dynarr_declare (struct face_cachel); | |
2074 } face_cachel_dynarr; | |
2075 | |
3293 | 2076 #ifdef NEW_GC |
3092 | 2077 DECLARE_LRECORD (face_cachel_dynarr, face_cachel_dynarr); |
2078 #define XFACE_CACHEL_DYNARR(x) \ | |
2079 XRECORD (x, face_cachel_dynarr, face_cachel_dynarr) | |
2080 #define wrap_face_cachel_dynarr(p) wrap_record (p, face_cachel_dynarr) | |
2081 #define FACE_CACHEL_DYNARRP(x) RECORDP (x, face_cachel_dynarr) | |
2082 #define CHECK_FACE_CACHEL_DYNARR(x) CHECK_RECORD (x, face_cachel_dynarr) | |
2083 #define CONCHECK_FACE_CACHEL_DYNARR(x) CONCHECK_RECORD (x, face_cachel_dynarr) | |
3293 | 2084 #endif /* NEW_GC */ |
3092 | 2085 |
2086 typedef struct | |
2087 { | |
2088 Dynarr_declare (struct glyph_cachel); | |
2089 } glyph_cachel_dynarr; | |
2090 | |
3293 | 2091 #ifdef NEW_GC |
3092 | 2092 DECLARE_LRECORD (glyph_cachel_dynarr, glyph_cachel_dynarr); |
2093 #define XGLYPH_CACHEL_DYNARR(x) \ | |
2094 XRECORD (x, glyph_cachel_dynarr, glyph_cachel_dynarr) | |
2095 #define wrap_glyph_cachel_dynarr(p) wrap_record (p, glyph_cachel_dynarr) | |
2096 #define GLYPH_CACHEL_DYNARRP(x) RECORDP (x, glyph_cachel_dynarr) | |
2097 #define CHECK_GLYPH_CACHEL_DYNARR(x) CHECK_RECORD (x, glyph_cachel_dynarr) | |
2098 #define CONCHECK_GLYPH_CACHEL_DYNARR(x) \ | |
2099 CONCHECK_RECORD (x, glyph_cachel_dynarr) | |
3293 | 2100 #endif /* NEW_GC */ |
3092 | 2101 |
2102 typedef struct | |
2103 { | |
2104 Dynarr_declare (struct console_type_entry); | |
2105 } console_type_entry_dynarr; | |
2106 | |
2107 /* WARNING WARNING WARNING. You must ensure on your own that proper | |
2108 GC protection is provided for the elements in this array. */ | |
2109 typedef struct | |
2110 { | |
2111 Dynarr_declare (Lisp_Object); | |
2112 } Lisp_Object_dynarr; | |
2113 | |
2114 typedef struct | |
2115 { | |
2116 Dynarr_declare (Lisp_Object *); | |
2117 } Lisp_Object_ptr_dynarr; | |
2118 | |
442 | 2119 /*------------------------------ unbound -------------------------------*/ |
428 | 2120 |
2121 /* Qunbound is a special Lisp_Object (actually of type | |
2122 symbol-value-forward), that can never be visible to | |
2123 the Lisp caller and thus can be used in the C code | |
2124 to mean "no such value". */ | |
2125 | |
2126 #define UNBOUNDP(val) EQ (val, Qunbound) | |
2127 | |
771 | 2128 /* Evaluate expr, return it if it's not Qunbound. */ |
2129 #define RETURN_IF_NOT_UNBOUND(expr) do \ | |
2130 { \ | |
2131 Lisp_Object ret_nunb_val = (expr); \ | |
2132 if (!UNBOUNDP (ret_nunb_val)) \ | |
2133 RETURN_SANS_WARNINGS ret_nunb_val; \ | |
2134 } while (0) | |
2135 | |
442 | 2136 /*------------------------------- cons ---------------------------------*/ |
428 | 2137 |
2138 /* In a cons, the markbit of the car is the gc mark bit */ | |
2139 | |
2140 struct Lisp_Cons | |
2141 { | |
2142 struct lrecord_header lheader; | |
853 | 2143 Lisp_Object car_, cdr_; |
428 | 2144 }; |
2145 typedef struct Lisp_Cons Lisp_Cons; | |
2146 | |
2147 #if 0 /* FSFmacs */ | |
2148 /* Like a cons, but records info on where the text lives that it was read from */ | |
2149 /* This is not really in use now */ | |
2150 | |
2151 struct Lisp_Buffer_Cons | |
2152 { | |
2153 Lisp_Object car, cdr; | |
2154 struct buffer *buffer; | |
665 | 2155 int charbpos; |
428 | 2156 }; |
2157 #endif | |
2158 | |
1632 | 2159 DECLARE_MODULE_API_LRECORD (cons, Lisp_Cons); |
428 | 2160 #define XCONS(x) XRECORD (x, cons, Lisp_Cons) |
617 | 2161 #define wrap_cons(p) wrap_record (p, cons) |
428 | 2162 #define CONSP(x) RECORDP (x, cons) |
2163 #define CHECK_CONS(x) CHECK_RECORD (x, cons) | |
2164 #define CONCHECK_CONS(x) CONCHECK_RECORD (x, cons) | |
2165 | |
3263 | 2166 #ifdef NEW_GC |
2720 | 2167 #define CONS_MARKED_P(c) MARKED_P (&((c)->lheader)) |
2168 #define MARK_CONS(c) MARK (&((c)->lheader)) | |
3263 | 2169 #else /* not NEW_GC */ |
428 | 2170 #define CONS_MARKED_P(c) MARKED_RECORD_HEADER_P(&((c)->lheader)) |
2171 #define MARK_CONS(c) MARK_RECORD_HEADER (&((c)->lheader)) | |
3263 | 2172 #endif /* not NEW_GC */ |
428 | 2173 |
1632 | 2174 extern MODULE_API Lisp_Object Qnil; |
428 | 2175 |
2176 #define NILP(x) EQ (x, Qnil) | |
853 | 2177 #define cons_car(a) ((a)->car_) |
2178 #define cons_cdr(a) ((a)->cdr_) | |
2179 #define XCAR(a) (XCONS (a)->car_) | |
2180 #define XCDR(a) (XCONS (a)->cdr_) | |
1318 | 2181 #define XCADR(a) (XCAR (XCDR (a))) |
2182 #define XCDDR(a) (XCDR (XCDR (a))) | |
2183 #define XCADDR(a) (XCAR (XCDDR (a))) | |
2184 #define XCDDDR(a) (XCDR (XCDDR (a))) | |
2185 #define XCADDDR(a) (XCAR (XCDDDR (a))) | |
2186 #define XCDDDDR(a) (XCDR (XCDDDR (a))) | |
2187 #define XCADDDDR(a) (XCAR (XCDDDDR (a))) | |
2188 #define XCDDDDDR(a) (XCDR (XCDDDDR (a))) | |
2189 #define XCADDDDDR(a) (XCAR (XCDDDDDR (a))) | |
2190 #define XCDDDDDDR(a) (XCDR (XCDDDDDR (a))) | |
2191 #define X1ST(a) XCAR (a) | |
2192 #define X2ND(a) XCADR (a) | |
2193 #define X3RD(a) XCADDR (a) | |
2194 #define X4TH(a) XCADDDR (a) | |
2195 #define X5TH(a) XCADDDDR (a) | |
2196 #define X6TH(a) XCADDDDDR (a) | |
2197 | |
853 | 2198 #define XSETCAR(a, b) (XCONS (a)->car_ = (b)) |
2199 #define XSETCDR(a, b) (XCONS (a)->cdr_ = (b)) | |
428 | 2200 #define LISTP(x) (CONSP(x) || NILP(x)) |
2201 | |
2202 #define CHECK_LIST(x) do { \ | |
2203 if (!LISTP (x)) \ | |
2204 dead_wrong_type_argument (Qlistp, x); \ | |
2205 } while (0) | |
2206 | |
2207 #define CONCHECK_LIST(x) do { \ | |
2208 if (!LISTP (x)) \ | |
2209 x = wrong_type_argument (Qlistp, x); \ | |
2210 } while (0) | |
2211 | |
442 | 2212 /*---------------------- list traversal macros -------------------------*/ |
2213 | |
2214 /* Note: These macros are for traversing through a list in some format, | |
2215 and executing code that you specify on each member of the list. | |
2216 | |
2217 There are two kinds of macros, those requiring surrounding braces, and | |
2218 those not requiring this. Which type of macro will be indicated. | |
2219 The general format for using a brace-requiring macro is | |
2220 | |
2221 { | |
2222 LIST_LOOP_3 (elt, list, tail) | |
2223 execute_code_here; | |
2224 } | |
2225 | |
2226 or | |
2227 | |
2228 { | |
2229 LIST_LOOP_3 (elt, list, tail) | |
2230 { | |
2231 execute_code_here; | |
2232 } | |
2233 } | |
2234 | |
2235 You can put variable declarations between the brace and beginning of | |
2236 macro, but NOTHING ELSE. | |
2237 | |
2238 The brace-requiring macros typically declare themselves any arguments | |
2239 that are initialized and iterated by the macros. If for some reason | |
2240 you need to declare these arguments yourself (e.g. to do something on | |
2241 them before the iteration starts, use the _NO_DECLARE versions of the | |
2242 macros.) | |
2243 */ | |
2244 | |
2245 /* There are two basic kinds of macros: those that handle "internal" lists | |
2246 that are known to be correctly structured (i.e. first element is a cons | |
2247 or nil, and the car of each cons is also a cons or nil, and there are | |
2248 no circularities), and those that handle "external" lists, where the | |
2249 list may have any sort of invalid formation. This is reflected in | |
2250 the names: those with "EXTERNAL_" work with external lists, and those | |
2251 without this prefix work with internal lists. The internal-list | |
2252 macros will hit an assertion failure if the structure is ill-formed; | |
2253 the external-list macros will signal an error in this case, either a | |
2254 malformed-list error or a circular-list error. | |
2255 */ | |
2256 | |
2367 | 2257 /* LIST_LOOP is a simple, old-fashioned macro. It doesn't require brace |
2258 surrounding, and iterates through a list, which may or may not known to | |
2259 be syntactically correct. It accepts two args, TAIL (set progressively | |
2260 to each cons starting with the first), and LIST, the list to iterate | |
2261 over. TAIL needs to be defined by the caller. | |
442 | 2262 |
2263 In each iteration, you can retrieve the current list item using XCAR | |
2264 (tail), or destructively modify the list using XSETCAR (tail, | |
2265 ...). */ | |
2266 | |
428 | 2267 #define LIST_LOOP(tail, list) \ |
2268 for (tail = list; \ | |
2269 !NILP (tail); \ | |
2270 tail = XCDR (tail)) | |
2271 | |
442 | 2272 /* The following macros are the "core" macros for list traversal. |
2273 | |
2274 *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. *** | |
2275 | |
2276 LIST_LOOP_2 and EXTERNAL_LIST_LOOP_2 are the standard, most-often used | |
2277 macros. They take two arguments, an element variable ELT and the list | |
2278 LIST. ELT is automatically declared, and set to each element in turn | |
2279 from LIST. | |
2280 | |
2281 LIST_LOOP_3 and EXTERNAL_LIST_LOOP_3 are the same, but they have a third | |
2282 argument TAIL, another automatically-declared variable. At each iteration, | |
2283 this one points to the cons cell for which ELT is the car. | |
2284 | |
2285 EXTERNAL_LIST_LOOP_4 is like EXTERNAL_LIST_LOOP_3 but takes an additional | |
2286 LEN argument, again automatically declared, which counts the number of | |
2287 iterations gone by. It is 0 during the first iteration. | |
2288 | |
2289 EXTERNAL_LIST_LOOP_4_NO_DECLARE is like EXTERNAL_LIST_LOOP_4 but none | |
2290 of the variables are automatically declared, and so you need to declare | |
2291 them yourself. (ELT and TAIL are Lisp_Objects, and LEN is an EMACS_INT.) | |
2292 */ | |
2293 | |
2294 #define LIST_LOOP_2(elt, list) \ | |
2295 LIST_LOOP_3(elt, list, unused_tail_##elt) | |
2296 | |
2297 #define LIST_LOOP_3(elt, list, tail) \ | |
2298 Lisp_Object elt, tail; \ | |
2299 for (tail = list; \ | |
2300 NILP (tail) ? \ | |
2301 0 : (elt = XCAR (tail), 1); \ | |
2302 tail = XCDR (tail)) | |
428 | 2303 |
2304 /* The following macros are for traversing lisp lists. | |
2305 Signal an error if LIST is not properly acyclic and nil-terminated. | |
2306 | |
2307 Use tortoise/hare algorithm to check for cycles, but only if it | |
2308 looks like the list is getting too long. Not only is the hare | |
2309 faster than the tortoise; it even gets a head start! */ | |
2310 | |
2311 /* Optimized and safe macros for looping over external lists. */ | |
2312 #define CIRCULAR_LIST_SUSPICION_LENGTH 1024 | |
2313 | |
2314 #define EXTERNAL_LIST_LOOP_1(list) \ | |
2315 Lisp_Object ELL1_elt, ELL1_hare, ELL1_tortoise; \ | |
442 | 2316 EMACS_INT ELL1_len; \ |
2317 PRIVATE_EXTERNAL_LIST_LOOP_6 (ELL1_elt, list, ELL1_len, ELL1_hare, \ | |
428 | 2318 ELL1_tortoise, CIRCULAR_LIST_SUSPICION_LENGTH) |
2319 | |
2320 #define EXTERNAL_LIST_LOOP_2(elt, list) \ | |
442 | 2321 Lisp_Object elt, hare_##elt, tortoise_##elt; \ |
2322 EMACS_INT len_##elt; \ | |
2323 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, hare_##elt, \ | |
428 | 2324 tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH) |
2325 | |
2367 | 2326 |
2327 #define GC_EXTERNAL_LIST_LOOP_2(elt, list) \ | |
2328 do { \ | |
2329 XGCDECL3 (elt); \ | |
2330 Lisp_Object elt, hare_##elt, tortoise_##elt; \ | |
2331 EMACS_INT len_##elt; \ | |
2332 XGCPRO3 (elt, elt, hare_##elt, tortoise_##elt); \ | |
2333 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, hare_##elt, \ | |
2334 tortoise_##elt, \ | |
2335 CIRCULAR_LIST_SUSPICION_LENGTH) | |
2336 | |
2337 #define END_GC_EXTERNAL_LIST_LOOP(elt) \ | |
2338 XUNGCPRO (elt); \ | |
2339 } \ | |
2340 while (0) | |
2341 | |
428 | 2342 #define EXTERNAL_LIST_LOOP_3(elt, list, tail) \ |
442 | 2343 Lisp_Object elt, tail, tortoise_##elt; \ |
2344 EMACS_INT len_##elt; \ | |
2345 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len_##elt, tail, \ | |
2346 tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH) | |
2347 | |
2348 #define EXTERNAL_LIST_LOOP_4_NO_DECLARE(elt, list, tail, len) \ | |
428 | 2349 Lisp_Object tortoise_##elt; \ |
442 | 2350 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, tail, \ |
428 | 2351 tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH) |
2352 | |
2353 #define EXTERNAL_LIST_LOOP_4(elt, list, tail, len) \ | |
442 | 2354 Lisp_Object elt, tail, tortoise_##elt; \ |
2355 EMACS_INT len; \ | |
2356 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, tail, \ | |
428 | 2357 tortoise_##elt, CIRCULAR_LIST_SUSPICION_LENGTH) |
2358 | |
2359 | |
444 | 2360 #define PRIVATE_EXTERNAL_LIST_LOOP_6(elt, list, len, hare, \ |
2361 tortoise, suspicion_length) \ | |
2362 for (tortoise = hare = list, len = 0; \ | |
2363 \ | |
2364 (CONSP (hare) ? ((elt = XCAR (hare)), 1) : \ | |
2365 (NILP (hare) ? 0 : \ | |
2366 (signal_malformed_list_error (list), 0))); \ | |
2367 \ | |
2368 hare = XCDR (hare), \ | |
2369 (void) \ | |
2370 ((++len > suspicion_length) \ | |
2371 && \ | |
2372 ((((len & 1) != 0) && (tortoise = XCDR (tortoise), 0)), \ | |
2373 (EQ (hare, tortoise) && (signal_circular_list_error (list), 0))))) | |
428 | 2374 |
442 | 2375 /* GET_LIST_LENGTH and GET_EXTERNAL_LIST_LENGTH: |
2376 | |
2377 These two macros return the length of LIST (either an internal or external | |
2378 list, according to which macro is used), stored into LEN (which must | |
2379 be declared by the caller). Circularities are trapped in external lists | |
2380 (and cause errors). Neither macro need be declared inside brackets. */ | |
2381 | |
2382 #define GET_LIST_LENGTH(list, len) do { \ | |
2383 Lisp_Object GLL_tail; \ | |
2384 for (GLL_tail = list, len = 0; \ | |
2385 !NILP (GLL_tail); \ | |
2386 GLL_tail = XCDR (GLL_tail), ++len) \ | |
2387 DO_NOTHING; \ | |
2388 } while (0) | |
2389 | |
2390 #define GET_EXTERNAL_LIST_LENGTH(list, len) \ | |
2391 do { \ | |
2392 Lisp_Object GELL_elt, GELL_tail; \ | |
2393 EXTERNAL_LIST_LOOP_4_NO_DECLARE (GELL_elt, list, GELL_tail, len) \ | |
2394 ; \ | |
2395 } while (0) | |
2396 | |
2397 /* For a list that's known to be in valid list format, where we may | |
2398 be deleting the current element out of the list -- | |
2500 | 2399 will ABORT() if the list is not in valid format */ |
442 | 2400 #define LIST_LOOP_DELETING(consvar, nextconsvar, list) \ |
2401 for (consvar = list; \ | |
2402 !NILP (consvar) ? (nextconsvar = XCDR (consvar), 1) :0; \ | |
2403 consvar = nextconsvar) | |
2404 | |
2405 /* LIST_LOOP_DELETE_IF and EXTERNAL_LIST_LOOP_DELETE_IF: | |
2406 | |
2407 These two macros delete all elements of LIST (either an internal or | |
2408 external list, according to which macro is used) satisfying | |
2409 CONDITION, a C expression referring to variable ELT. ELT is | |
2410 automatically declared. Circularities are trapped in external | |
2411 lists (and cause errors). Neither macro need be declared inside | |
2412 brackets. */ | |
2413 | |
2414 #define LIST_LOOP_DELETE_IF(elt, list, condition) do { \ | |
2415 /* Do not use ##list when creating new variables because \ | |
2416 that may not be just a variable name. */ \ | |
2417 Lisp_Object prev_tail_##elt = Qnil; \ | |
2418 LIST_LOOP_3 (elt, list, tail_##elt) \ | |
2419 { \ | |
2420 if (condition) \ | |
2421 { \ | |
2422 if (NILP (prev_tail_##elt)) \ | |
2423 list = XCDR (tail_##elt); \ | |
2424 else \ | |
2425 XCDR (prev_tail_##elt) = XCDR (tail_##elt); \ | |
2426 } \ | |
2427 else \ | |
2428 prev_tail_##elt = tail_##elt; \ | |
2429 } \ | |
2430 } while (0) | |
2431 | |
2432 #define EXTERNAL_LIST_LOOP_DELETE_IF(elt, list, condition) do { \ | |
2433 Lisp_Object prev_tail_##elt = Qnil; \ | |
2434 EXTERNAL_LIST_LOOP_4 (elt, list, tail_##elt, len_##elt) \ | |
2435 { \ | |
2436 if (condition) \ | |
2437 { \ | |
2438 if (NILP (prev_tail_##elt)) \ | |
2439 list = XCDR (tail_##elt); \ | |
2440 else \ | |
2441 XCDR (prev_tail_##elt) = XCDR (tail_##elt); \ | |
2442 /* Keep tortoise from ever passing hare. */ \ | |
2443 len_##elt = 0; \ | |
2444 } \ | |
2445 else \ | |
2446 prev_tail_##elt = tail_##elt; \ | |
2447 } \ | |
2448 } while (0) | |
2449 | |
2450 | |
1204 | 2451 /* Macros for looping over internal alists. |
2452 | |
2453 *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. *** | |
2454 | |
2455 ALIST_LOOP_3 loops over an alist, at each iteration setting CAR and CDR | |
2456 to the car and cdr of the acons. CAR and CDR are automatically | |
2457 declared. | |
2458 | |
2459 ALIST_LOOP_4 is similar to ALIST_LOOP_3 but contains an additional | |
2460 variable ACONS at the beginning for access to the acons itself.All of | |
2461 the variables ACONS, CAR and CDR are automatically declared. | |
2462 */ | |
2463 | |
2464 #define ALIST_LOOP_3(car, cdr, alist) \ | |
2465 Lisp_Object _al3_acons_##car, car, cdr, _al3_tail_##car; \ | |
2466 for (_al3_tail_##car = alist; \ | |
2467 NILP (_al3_tail_##car) ? \ | |
2468 0 : (_al3_acons_##car = XCAR (_al3_tail_##car), \ | |
2469 car = XCAR (_al3_acons_##car), \ | |
2470 cdr = XCDR (_al3_acons_##car), 1); \ | |
2471 _al3_tail_##car = XCDR (_al3_tail_##car)) | |
2472 | |
2473 #define ALIST_LOOP_4(acons, car, cdr, list) \ | |
2474 Lisp_Object acons, car, cdr, _al4_tail_##car; \ | |
2475 for (_al4_tail_##car = list; \ | |
2476 NILP (_al4_tail_##car) ? \ | |
2477 0 : (elt = XCAR (_al4_tail_##car), car = XCAR (elt), \ | |
2478 cdr = XCDR (elt), 1); \ | |
2479 _al4_tail_##car = XCDR (tail)) | |
2480 | |
442 | 2481 /* Macros for looping over external alists. |
2482 | |
2483 *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. *** | |
2484 | |
2485 EXTERNAL_ALIST_LOOP_4 is similar to EXTERNAL_LIST_LOOP_2, but it | |
2486 assumes the elements are aconses (the elements in an alist) and | |
2487 sets two additional argument variables ELT_CAR and ELT_CDR to the | |
2488 car and cdr of the acons. All of the variables ELT, ELT_CAR and | |
2489 ELT_CDR are automatically declared. | |
2490 | |
2491 EXTERNAL_ALIST_LOOP_5 adds a TAIL argument to EXTERNAL_ALIST_LOOP_4, | |
2492 just like EXTERNAL_LIST_LOOP_3 does, and again TAIL is automatically | |
2493 declared. | |
2494 | |
2495 EXTERNAL_ALIST_LOOP_6 adds a LEN argument to EXTERNAL_ALIST_LOOP_5, | |
2496 just like EXTERNAL_LIST_LOOP_4 does, and again LEN is automatically | |
2497 declared. | |
2498 | |
2499 EXTERNAL_ALIST_LOOP_6_NO_DECLARE does not declare any of its arguments, | |
2500 just like EXTERNAL_LIST_LOOP_4_NO_DECLARE, and so these must be declared | |
2501 manually. | |
2502 */ | |
428 | 2503 |
2504 /* Optimized and safe macros for looping over external alists. */ | |
2505 #define EXTERNAL_ALIST_LOOP_4(elt, elt_car, elt_cdr, list) \ | |
442 | 2506 Lisp_Object elt, elt_car, elt_cdr; \ |
428 | 2507 Lisp_Object hare_##elt, tortoise_##elt; \ |
2508 EMACS_INT len_##elt; \ | |
442 | 2509 PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list, \ |
428 | 2510 len_##elt, hare_##elt, tortoise_##elt, \ |
2511 CIRCULAR_LIST_SUSPICION_LENGTH) | |
2512 | |
2513 #define EXTERNAL_ALIST_LOOP_5(elt, elt_car, elt_cdr, list, tail) \ | |
442 | 2514 Lisp_Object elt, elt_car, elt_cdr, tail; \ |
428 | 2515 Lisp_Object tortoise_##elt; \ |
2516 EMACS_INT len_##elt; \ | |
442 | 2517 PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list, \ |
428 | 2518 len_##elt, tail, tortoise_##elt, \ |
2519 CIRCULAR_LIST_SUSPICION_LENGTH) \ | |
2520 | |
2521 #define EXTERNAL_ALIST_LOOP_6(elt, elt_car, elt_cdr, list, tail, len) \ | |
442 | 2522 Lisp_Object elt, elt_car, elt_cdr, tail; \ |
2523 EMACS_INT len; \ | |
428 | 2524 Lisp_Object tortoise_##elt; \ |
442 | 2525 PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list, \ |
428 | 2526 len, tail, tortoise_##elt, \ |
2527 CIRCULAR_LIST_SUSPICION_LENGTH) | |
2528 | |
442 | 2529 #define EXTERNAL_ALIST_LOOP_6_NO_DECLARE(elt, elt_car, elt_cdr, list, \ |
2530 tail, len) \ | |
2531 Lisp_Object tortoise_##elt; \ | |
2532 PRIVATE_EXTERNAL_ALIST_LOOP_8 (elt, elt_car, elt_cdr, list, \ | |
2533 len, tail, tortoise_##elt, \ | |
2534 CIRCULAR_LIST_SUSPICION_LENGTH) | |
2535 | |
2536 | |
2537 #define PRIVATE_EXTERNAL_ALIST_LOOP_8(elt, elt_car, elt_cdr, list, len, \ | |
2538 hare, tortoise, suspicion_length) \ | |
2539 PRIVATE_EXTERNAL_LIST_LOOP_6 (elt, list, len, hare, tortoise, \ | |
2540 suspicion_length) \ | |
428 | 2541 if (CONSP (elt) ? (elt_car = XCAR (elt), elt_cdr = XCDR (elt), 0) :1) \ |
2542 continue; \ | |
2543 else | |
2544 | |
442 | 2545 /* Macros for looping over external property lists. |
2546 | |
2547 *** ALL OF THESE MACROS MUST BE DECLARED INSIDE BRACES -- SEE ABOVE. *** | |
2548 | |
2549 EXTERNAL_PROPERTY_LIST_LOOP_3 maps over an external list assumed to | |
2550 be a property list, consisting of alternating pairs of keys | |
2551 (typically symbols or keywords) and values. Each iteration | |
2552 processes one such pair out of LIST, assigning the two elements to | |
2553 KEY and VALUE respectively. Malformed lists and circularities are | |
2554 trapped as usual, and in addition, property lists with an odd number | |
2555 of elements also signal an error. | |
2556 | |
2557 EXTERNAL_PROPERTY_LIST_LOOP_4 adds a TAIL argument to | |
2558 EXTERNAL_PROPERTY_LIST_LOOP_3, just like EXTERNAL_LIST_LOOP_3 does, | |
2559 and again TAIL is automatically declared. | |
2560 | |
2561 EXTERNAL_PROPERTY_LIST_LOOP_5 adds a LEN argument to | |
2562 EXTERNAL_PROPERTY_LIST_LOOP_4, just like EXTERNAL_LIST_LOOP_4 does, | |
2563 and again LEN is automatically declared. Note that in this case, | |
2564 LEN counts the iterations, NOT the total number of list elements | |
2565 processed, which is 2 * LEN. | |
2566 | |
2567 EXTERNAL_PROPERTY_LIST_LOOP_5_NO_DECLARE does not declare any of its | |
2568 arguments, just like EXTERNAL_LIST_LOOP_4_NO_DECLARE, and so these | |
2569 must be declared manually. */ | |
428 | 2570 |
2571 /* Optimized and safe macros for looping over external property lists. */ | |
2572 #define EXTERNAL_PROPERTY_LIST_LOOP_3(key, value, list) \ | |
2573 Lisp_Object key, value, hare_##key, tortoise_##key; \ | |
442 | 2574 EMACS_INT len_##key; \ |
428 | 2575 EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len_##key, hare_##key, \ |
2576 tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH) | |
2577 | |
2578 #define EXTERNAL_PROPERTY_LIST_LOOP_4(key, value, list, tail) \ | |
2579 Lisp_Object key, value, tail, tortoise_##key; \ | |
442 | 2580 EMACS_INT len_##key; \ |
428 | 2581 EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len_##key, tail, \ |
2582 tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH) | |
2583 | |
2584 #define EXTERNAL_PROPERTY_LIST_LOOP_5(key, value, list, tail, len) \ | |
2585 Lisp_Object key, value, tail, tortoise_##key; \ | |
2586 EMACS_INT len; \ | |
2587 EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len, tail, \ | |
2588 tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH) | |
2589 | |
442 | 2590 #define EXTERNAL_PROPERTY_LIST_LOOP_5_NO_DECLARE(key, value, list, \ |
2591 tail, len) \ | |
2592 Lisp_Object tortoise_##key; \ | |
2593 EXTERNAL_PROPERTY_LIST_LOOP_7 (key, value, list, len, tail, \ | |
2594 tortoise_##key, CIRCULAR_LIST_SUSPICION_LENGTH) | |
2595 | |
428 | 2596 |
2597 #define EXTERNAL_PROPERTY_LIST_LOOP_7(key, value, list, len, hare, \ | |
2598 tortoise, suspicion_length) \ | |
2599 for (tortoise = hare = list, len = 0; \ | |
2600 \ | |
2601 ((CONSP (hare) && \ | |
2602 (key = XCAR (hare), \ | |
2603 hare = XCDR (hare), \ | |
442 | 2604 (CONSP (hare) ? 1 : \ |
2605 (signal_malformed_property_list_error (list), 0)))) ? \ | |
428 | 2606 (value = XCAR (hare), 1) : \ |
2607 (NILP (hare) ? 0 : \ | |
2608 (signal_malformed_property_list_error (list), 0))); \ | |
2609 \ | |
2610 hare = XCDR (hare), \ | |
2611 ((++len < suspicion_length) ? \ | |
2612 ((void) 0) : \ | |
2613 (((len & 1) ? \ | |
2614 ((void) (tortoise = XCDR (XCDR (tortoise)))) : \ | |
2615 ((void) 0)) \ | |
2616 , \ | |
2617 (EQ (hare, tortoise) ? \ | |
2618 ((void) signal_circular_property_list_error (list)) : \ | |
2619 ((void) 0))))) | |
2620 | |
2421 | 2621 #define PRIVATE_PROPERTY_LIST_LOOP_4(tail, key, value, plist) \ |
2622 for (tail = plist; \ | |
2623 NILP (tail) ? 0 : \ | |
2624 (key = XCAR (tail), tail = XCDR (tail), \ | |
2625 value = XCAR (tail), tail = XCDR (tail), 1); \ | |
428 | 2626 ) |
2627 | |
2421 | 2628 #define PROPERTY_LIST_LOOP_3(key, value, plist) \ |
2629 Lisp_Object key, value, tail_##key; \ | |
2630 PRIVATE_PROPERTY_LIST_LOOP_4 (tail_##key, key, value, plist) | |
2631 | |
2632 #define GC_PROPERTY_LIST_LOOP_3(key, value, plist) \ | |
2633 do { \ | |
2634 XGCDECL3 (key); \ | |
2635 Lisp_Object key, value, tail_##key; \ | |
2636 XGCPRO3 (key, key, value, tail_##key); \ | |
2637 PRIVATE_PROPERTY_LIST_LOOP_4 (tail_##key, key, value, plist) | |
2638 | |
2639 #define END_GC_PROPERTY_LIST_LOOP(key) \ | |
2640 XUNGCPRO (key); \ | |
2641 } \ | |
2642 while (0) | |
2643 | |
428 | 2644 /* Return 1 if LIST is properly acyclic and nil-terminated, else 0. */ |
826 | 2645 DECLARE_INLINE_HEADER ( |
2646 int | |
428 | 2647 TRUE_LIST_P (Lisp_Object object) |
826 | 2648 ) |
428 | 2649 { |
2650 Lisp_Object hare, tortoise; | |
2651 EMACS_INT len; | |
2652 | |
2653 for (hare = tortoise = object, len = 0; | |
2654 CONSP (hare); | |
2655 hare = XCDR (hare), len++) | |
2656 { | |
2657 if (len < CIRCULAR_LIST_SUSPICION_LENGTH) | |
2658 continue; | |
2659 | |
2660 if (len & 1) | |
2661 tortoise = XCDR (tortoise); | |
2662 else if (EQ (hare, tortoise)) | |
2663 return 0; | |
2664 } | |
2665 | |
2666 return NILP (hare); | |
2667 } | |
2668 | |
2669 /* Signal an error if LIST is not properly acyclic and nil-terminated. */ | |
2670 #define CHECK_TRUE_LIST(list) do { \ | |
2671 Lisp_Object CTL_list = (list); \ | |
2672 Lisp_Object CTL_hare, CTL_tortoise; \ | |
436 | 2673 EMACS_INT CTL_len; \ |
428 | 2674 \ |
2675 for (CTL_hare = CTL_tortoise = CTL_list, CTL_len = 0; \ | |
2676 CONSP (CTL_hare); \ | |
2677 CTL_hare = XCDR (CTL_hare), CTL_len++) \ | |
2678 { \ | |
2679 if (CTL_len < CIRCULAR_LIST_SUSPICION_LENGTH) \ | |
2680 continue; \ | |
2681 \ | |
2682 if (CTL_len & 1) \ | |
2683 CTL_tortoise = XCDR (CTL_tortoise); \ | |
2684 else if (EQ (CTL_hare, CTL_tortoise)) \ | |
2685 Fsignal (Qcircular_list, list1 (CTL_list)); \ | |
2686 } \ | |
2687 \ | |
2688 if (! NILP (CTL_hare)) \ | |
2689 signal_malformed_list_error (CTL_list); \ | |
2690 } while (0) | |
2691 | |
442 | 2692 /*------------------------------ string --------------------------------*/ |
428 | 2693 |
3092 | 2694 #ifdef NEW_GC |
2695 struct Lisp_String_Direct_Data | |
2696 { | |
2697 struct lrecord_header header; | |
2698 Bytecount size; | |
2699 Ibyte data[1]; | |
2700 }; | |
2701 typedef struct Lisp_String_Direct_Data Lisp_String_Direct_Data; | |
2702 | |
2703 DECLARE_MODULE_API_LRECORD (string_direct_data, Lisp_String_Direct_Data); | |
2704 #define XSTRING_DIRECT_DATA(x) \ | |
2705 XRECORD (x, string_direct_data, Lisp_String_Direct_Data) | |
2706 #define wrap_string_direct_data(p) wrap_record (p, string_direct_data) | |
2707 #define STRING_DIRECT_DATAP(x) RECORDP (x, string_direct_data) | |
2708 #define CHECK_STRING_DIRECT_DATA(x) CHECK_RECORD (x, string_direct_data) | |
2709 #define CONCHECK_STRING_DIRECT_DATA(x) CONCHECK_RECORD (x, string_direct_data) | |
2710 | |
2711 #define XSTRING_DIRECT_DATA_SIZE(x) XSTRING_DIRECT_DATA (x)->size | |
2712 #define XSTRING_DIRECT_DATA_DATA(x) XSTRING_DIRECT_DATA (x)->data | |
2713 | |
2714 | |
2715 struct Lisp_String_Indirect_Data | |
2716 { | |
2717 struct lrecord_header header; | |
2718 Bytecount size; | |
2719 Ibyte *data; | |
2720 }; | |
2721 typedef struct Lisp_String_Indirect_Data Lisp_String_Indirect_Data; | |
2722 | |
2723 DECLARE_MODULE_API_LRECORD (string_indirect_data, Lisp_String_Indirect_Data); | |
2724 #define XSTRING_INDIRECT_DATA(x) \ | |
2725 XRECORD (x, string_indirect_data, Lisp_String_Indirect_Data) | |
2726 #define wrap_string_indirect_data(p) wrap_record (p, string_indirect_data) | |
2727 #define STRING_INDIRECT_DATAP(x) RECORDP (x, string_indirect_data) | |
2728 #define CHECK_STRING_INDIRECT_DATA(x) CHECK_RECORD (x, string_indirect_data) | |
2729 #define CONCHECK_STRING_INDIRECT_DATA(x) \ | |
2730 CONCHECK_RECORD (x, string_indirect_data) | |
2731 | |
2732 #define XSTRING_INDIRECT_DATA_SIZE(x) XSTRING_INDIRECT_DATA (x)->size | |
2733 #define XSTRING_INDIRECT_DATA_DATA(x) XSTRING_INDIRECT_DATA (x)->data | |
2734 | |
2735 | |
2736 #define XSTRING_DATA_SIZE(s) ((s)->indirect)? \ | |
2737 XSTRING_INDIRECT_DATA_SIZE ((s)->data_object): \ | |
2738 XSTRING_DIRECT_DATA_SIZE ((s)->data_object) | |
2739 #define XSTRING_DATA_DATA(s) ((s)->indirect)? \ | |
2740 XSTRING_INDIRECT_DATA_DATA ((s)->data_object): \ | |
2741 XSTRING_DIRECT_DATA_DATA ((s)->data_object) | |
2742 | |
2743 #define XSET_STRING_DATA_SIZE(s, len) \ | |
2744 if ((s)->indirect) \ | |
2745 XSTRING_INDIRECT_DATA_SIZE ((s)->data_object) = len; \ | |
2746 else \ | |
2747 XSTRING_DIRECT_DATA_SIZE ((s)->data_object) = len | |
2748 #define XSET_STRING_DATA_DATA(s, ptr) \ | |
2749 if ((s)->indirect) \ | |
2750 XSTRING_INDIRECT_DATA_DATA ((s)->data_object) = ptr; \ | |
2751 else \ | |
2752 XSTRING_DIRECT_DATA_DATA ((s)->data_object) = ptr | |
2753 #endif /* NEW_GC */ | |
2754 | |
428 | 2755 struct Lisp_String |
2756 { | |
771 | 2757 union |
2758 { | |
2759 struct lrecord_header lheader; | |
2760 struct | |
2761 { | |
2762 /* WARNING: Everything before ascii_begin must agree exactly with | |
2763 struct lrecord_header */ | |
2764 unsigned int type :8; | |
3263 | 2765 #ifdef NEW_GC |
2720 | 2766 unsigned int lisp_readonly :1; |
2767 unsigned int free :1; | |
2768 /* Number of chars at beginning of string that are one byte in length | |
2769 (byte_ascii_p) */ | |
2770 unsigned int ascii_begin :22; | |
3263 | 2771 #else /* not NEW_GC */ |
771 | 2772 unsigned int mark :1; |
2773 unsigned int c_readonly :1; | |
2774 unsigned int lisp_readonly :1; | |
2775 /* Number of chars at beginning of string that are one byte in length | |
826 | 2776 (byte_ascii_p) */ |
771 | 2777 unsigned int ascii_begin :21; |
3263 | 2778 #endif /* not NEW_GC */ |
771 | 2779 } v; |
2780 } u; | |
3092 | 2781 #ifdef NEW_GC |
2782 int indirect; | |
2783 Lisp_Object data_object; | |
2784 #else /* not NEW_GC */ | |
793 | 2785 Bytecount size_; |
867 | 2786 Ibyte *data_; |
3092 | 2787 #endif /* not NEW_GC */ |
428 | 2788 Lisp_Object plist; |
2789 }; | |
2790 typedef struct Lisp_String Lisp_String; | |
2791 | |
3263 | 2792 #ifdef NEW_GC |
3063 | 2793 #define MAX_STRING_ASCII_BEGIN ((1 << 22) - 1) |
3263 | 2794 #else /* not NEW_GC */ |
851 | 2795 #define MAX_STRING_ASCII_BEGIN ((1 << 21) - 1) |
3263 | 2796 #endif /* not NEW_GC */ |
771 | 2797 |
1632 | 2798 DECLARE_MODULE_API_LRECORD (string, Lisp_String); |
428 | 2799 #define XSTRING(x) XRECORD (x, string, Lisp_String) |
617 | 2800 #define wrap_string(p) wrap_record (p, string) |
428 | 2801 #define STRINGP(x) RECORDP (x, string) |
2802 #define CHECK_STRING(x) CHECK_RECORD (x, string) | |
2803 #define CONCHECK_STRING(x) CONCHECK_RECORD (x, string) | |
2804 | |
826 | 2805 /* Most basic macros for strings -- basically just accessing or setting |
2806 fields -- are here. Everything else is in text.h, since they depend on | |
2807 stuff there. */ | |
428 | 2808 |
793 | 2809 /* Operations on Lisp_String *'s; only ones left */ |
3092 | 2810 #ifdef NEW_GC |
3304 | 2811 #define set_lispstringp_direct(s) ((s)->indirect = 0) |
3092 | 2812 #define set_lispstringp_indirect(s) ((s)->indirect = 1) |
2813 #define set_lispstringp_length(s, len) XSET_STRING_DATA_SIZE (s, len) | |
2814 #define set_lispstringp_data(s, ptr) XSET_STRING_DATA_DATA (s, ptr) | |
2815 #else /* not NEW_GC */ | |
826 | 2816 #define set_lispstringp_length(s, len) ((void) ((s)->size_ = (len))) |
2817 #define set_lispstringp_data(s, ptr) ((void) ((s)->data_ = (ptr))) | |
3092 | 2818 #endif /* not NEW_GC */ |
826 | 2819 |
2820 /* Operations on strings as Lisp_Objects. Don't manipulate Lisp_String *'s | |
2821 in any new code. */ | |
3092 | 2822 #ifdef NEW_GC |
2823 #define STRING_DATA_OBJECT(s) ((s)->data_object) | |
2824 #define XSTRING_DATA_OBJECT(s) (STRING_DATA_OBJECT (XSTRING (s))) | |
2825 #define XSTRING_LENGTH(s) (XSTRING_DATA_SIZE (XSTRING (s))) | |
2826 #else /* not NEW_GC */ | |
793 | 2827 #define XSTRING_LENGTH(s) (XSTRING (s)->size_) |
3092 | 2828 #endif /* not NEW_GC */ |
793 | 2829 #define XSTRING_PLIST(s) (XSTRING (s)->plist) |
3092 | 2830 #ifdef NEW_GC |
2831 #define XSTRING_DATA(s) (XSTRING_DATA_DATA (XSTRING (s))) | |
2832 #else /* not NEW_GC */ | |
793 | 2833 #define XSTRING_DATA(s) (XSTRING (s)->data_ + 0) |
3092 | 2834 #endif /* not NEW_GC */ |
793 | 2835 #define XSTRING_ASCII_BEGIN(s) (XSTRING (s)->u.v.ascii_begin + 0) |
826 | 2836 #define XSET_STRING_LENGTH(s, ptr) set_lispstringp_length (XSTRING (s), ptr) |
2837 #define XSET_STRING_DATA(s, ptr) set_lispstringp_data (XSTRING (s), ptr) | |
771 | 2838 /* WARNING: If you modify an existing string, you must call |
2839 bump_string_modiff() afterwards. */ | |
793 | 2840 #define XSET_STRING_ASCII_BEGIN(s, val) \ |
2841 ((void) (XSTRING (s)->u.v.ascii_begin = (val))) | |
826 | 2842 #define XSTRING_FORMAT(s) FORMAT_DEFAULT |
428 | 2843 |
456 | 2844 /* Return the true aligned size of a struct whose last member is a |
2845 variable-length array field. (this is known as the "struct hack") */ | |
2846 /* Implementation: in practice, structtype and fieldtype usually have | |
2847 the same alignment, but we can't be sure. We need to use | |
2848 ALIGN_SIZE to be absolutely sure of getting the correct alignment. | |
2849 To help the compiler's optimizer, we use a ternary expression that | |
2850 only a very stupid compiler would fail to correctly simplify. */ | |
2851 #define FLEXIBLE_ARRAY_STRUCT_SIZEOF(structtype, \ | |
2852 fieldtype, \ | |
2853 fieldname, \ | |
2854 array_length) \ | |
2855 (ALIGNOF (structtype) == ALIGNOF (fieldtype) \ | |
2856 ? (offsetof (structtype, fieldname) + \ | |
2857 (offsetof (structtype, fieldname[1]) - \ | |
2858 offsetof (structtype, fieldname[0])) * \ | |
2859 (array_length)) \ | |
826 | 2860 : (ALIGN_FOR_TYPE \ |
456 | 2861 ((offsetof (structtype, fieldname) + \ |
2862 (offsetof (structtype, fieldname[1]) - \ | |
2863 offsetof (structtype, fieldname[0])) * \ | |
2864 (array_length)), \ | |
826 | 2865 structtype))) |
442 | 2866 |
2867 /*------------------------------ vector --------------------------------*/ | |
428 | 2868 |
2869 struct Lisp_Vector | |
2870 { | |
3017 | 2871 struct LCRECORD_HEADER header; |
428 | 2872 long size; |
2873 Lisp_Object contents[1]; | |
2874 }; | |
2875 typedef struct Lisp_Vector Lisp_Vector; | |
2876 | |
2877 DECLARE_LRECORD (vector, Lisp_Vector); | |
2878 #define XVECTOR(x) XRECORD (x, vector, Lisp_Vector) | |
617 | 2879 #define wrap_vector(p) wrap_record (p, vector) |
428 | 2880 #define VECTORP(x) RECORDP (x, vector) |
2881 #define CHECK_VECTOR(x) CHECK_RECORD (x, vector) | |
2882 #define CONCHECK_VECTOR(x) CONCHECK_RECORD (x, vector) | |
2883 | |
2884 #define vector_length(v) ((v)->size) | |
2885 #define XVECTOR_LENGTH(s) vector_length (XVECTOR (s)) | |
2886 #define vector_data(v) ((v)->contents) | |
2887 #define XVECTOR_DATA(s) vector_data (XVECTOR (s)) | |
2888 | |
442 | 2889 /*---------------------------- bit vectors -----------------------------*/ |
428 | 2890 |
2891 #if (LONGBITS < 16) | |
2892 #error What the hell?! | |
2893 #elif (LONGBITS < 32) | |
2894 # define LONGBITS_LOG2 4 | |
2895 # define LONGBITS_POWER_OF_2 16 | |
2896 #elif (LONGBITS < 64) | |
2897 # define LONGBITS_LOG2 5 | |
2898 # define LONGBITS_POWER_OF_2 32 | |
2899 #elif (LONGBITS < 128) | |
2900 # define LONGBITS_LOG2 6 | |
2901 # define LONGBITS_POWER_OF_2 64 | |
2902 #else | |
2903 #error You really have 128-bit integers?! | |
2904 #endif | |
2905 | |
2906 struct Lisp_Bit_Vector | |
2907 { | |
3017 | 2908 struct LCRECORD_HEADER lheader; |
665 | 2909 Elemcount size; |
428 | 2910 unsigned long bits[1]; |
2911 }; | |
2912 typedef struct Lisp_Bit_Vector Lisp_Bit_Vector; | |
2913 | |
2914 DECLARE_LRECORD (bit_vector, Lisp_Bit_Vector); | |
2915 #define XBIT_VECTOR(x) XRECORD (x, bit_vector, Lisp_Bit_Vector) | |
617 | 2916 #define wrap_bit_vector(p) wrap_record (p, bit_vector) |
428 | 2917 #define BIT_VECTORP(x) RECORDP (x, bit_vector) |
2918 #define CHECK_BIT_VECTOR(x) CHECK_RECORD (x, bit_vector) | |
2919 #define CONCHECK_BIT_VECTOR(x) CONCHECK_RECORD (x, bit_vector) | |
2920 | |
2921 #define BITP(x) (INTP (x) && (XINT (x) == 0 || XINT (x) == 1)) | |
2922 | |
2923 #define CHECK_BIT(x) do { \ | |
2924 if (!BITP (x)) \ | |
2925 dead_wrong_type_argument (Qbitp, x);\ | |
2926 } while (0) | |
2927 | |
2928 #define CONCHECK_BIT(x) do { \ | |
2929 if (!BITP (x)) \ | |
2930 x = wrong_type_argument (Qbitp, x); \ | |
2931 } while (0) | |
2932 | |
2933 #define bit_vector_length(v) ((v)->size) | |
2934 | |
826 | 2935 DECLARE_INLINE_HEADER ( |
2936 int | |
665 | 2937 bit_vector_bit (Lisp_Bit_Vector *v, Elemcount n) |
826 | 2938 ) |
428 | 2939 { |
2940 return ((v->bits[n >> LONGBITS_LOG2] >> (n & (LONGBITS_POWER_OF_2 - 1))) | |
2941 & 1); | |
2942 } | |
2943 | |
826 | 2944 DECLARE_INLINE_HEADER ( |
2945 void | |
665 | 2946 set_bit_vector_bit (Lisp_Bit_Vector *v, Elemcount n, int value) |
826 | 2947 ) |
428 | 2948 { |
2949 if (value) | |
2950 v->bits[n >> LONGBITS_LOG2] |= (1UL << (n & (LONGBITS_POWER_OF_2 - 1))); | |
2951 else | |
2952 v->bits[n >> LONGBITS_LOG2] &= ~(1UL << (n & (LONGBITS_POWER_OF_2 - 1))); | |
2953 } | |
2954 | |
2955 /* Number of longs required to hold LEN bits */ | |
2956 #define BIT_VECTOR_LONG_STORAGE(len) \ | |
2957 (((len) + LONGBITS_POWER_OF_2 - 1) >> LONGBITS_LOG2) | |
2958 | |
3659 | 2959 /* For when we want to include a bit vector in another structure, and we |
2960 know it's of a fixed size. */ | |
2961 #define DECLARE_INLINE_LISP_BIT_VECTOR(numbits) struct { \ | |
2962 struct LCRECORD_HEADER lheader; \ | |
2963 Elemcount size; \ | |
2964 unsigned long bits[BIT_VECTOR_LONG_STORAGE(numbits)]; \ | |
2965 } | |
4995
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2966 /*---------------------- array, sequence -----------------------------*/ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2967 |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2968 #define ARRAYP(x) (VECTORP (x) || STRINGP (x) || BIT_VECTORP (x)) |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2969 |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2970 #define CHECK_ARRAY(x) do { \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2971 if (!ARRAYP (x)) \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2972 dead_wrong_type_argument (Qarrayp, x); \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2973 } while (0) |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2974 |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2975 #define CONCHECK_ARRAY(x) do { \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2976 if (!ARRAYP (x)) \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2977 x = wrong_type_argument (Qarrayp, x); \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2978 } while (0) |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2979 |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2980 #define SEQUENCEP(x) (LISTP (x) || ARRAYP (x)) |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2981 |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2982 #define CHECK_SEQUENCE(x) do { \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2983 if (!SEQUENCEP (x)) \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2984 dead_wrong_type_argument (Qsequencep, x); \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2985 } while (0) |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2986 |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2987 #define CONCHECK_SEQUENCE(x) do { \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2988 if (!SEQUENCEP (x)) \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2989 x = wrong_type_argument (Qsequencep, x); \ |
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
2990 } while (0) |
853 | 2991 |
442 | 2992 /*------------------------------ symbol --------------------------------*/ |
428 | 2993 |
440 | 2994 typedef struct Lisp_Symbol Lisp_Symbol; |
428 | 2995 struct Lisp_Symbol |
2996 { | |
2997 struct lrecord_header lheader; | |
2998 /* next symbol in this obarray bucket */ | |
440 | 2999 Lisp_Symbol *next; |
793 | 3000 Lisp_Object name; |
428 | 3001 Lisp_Object value; |
3002 Lisp_Object function; | |
3003 Lisp_Object plist; | |
3004 }; | |
3005 | |
3006 #define SYMBOL_IS_KEYWORD(sym) \ | |
826 | 3007 ((string_byte (symbol_name (XSYMBOL (sym)), 0) == ':') \ |
428 | 3008 && EQ (sym, oblookup (Vobarray, \ |
793 | 3009 XSTRING_DATA (symbol_name (XSYMBOL (sym))), \ |
3010 XSTRING_LENGTH (symbol_name (XSYMBOL (sym)))))) | |
428 | 3011 #define KEYWORDP(obj) (SYMBOLP (obj) && SYMBOL_IS_KEYWORD (obj)) |
3012 | |
1632 | 3013 DECLARE_MODULE_API_LRECORD (symbol, Lisp_Symbol); |
428 | 3014 #define XSYMBOL(x) XRECORD (x, symbol, Lisp_Symbol) |
617 | 3015 #define wrap_symbol(p) wrap_record (p, symbol) |
428 | 3016 #define SYMBOLP(x) RECORDP (x, symbol) |
3017 #define CHECK_SYMBOL(x) CHECK_RECORD (x, symbol) | |
3018 #define CONCHECK_SYMBOL(x) CONCHECK_RECORD (x, symbol) | |
3019 | |
3020 #define symbol_next(s) ((s)->next) | |
3021 #define symbol_name(s) ((s)->name) | |
3022 #define symbol_value(s) ((s)->value) | |
3023 #define symbol_function(s) ((s)->function) | |
3024 #define symbol_plist(s) ((s)->plist) | |
3025 | |
793 | 3026 #define XSYMBOL_NEXT(s) (XSYMBOL (s)->next) |
3027 #define XSYMBOL_NAME(s) (XSYMBOL (s)->name) | |
3028 #define XSYMBOL_VALUE(s) (XSYMBOL (s)->value) | |
3029 #define XSYMBOL_FUNCTION(s) (XSYMBOL (s)->function) | |
3030 #define XSYMBOL_PLIST(s) (XSYMBOL (s)->plist) | |
3031 | |
3032 | |
442 | 3033 /*------------------------------- subr ---------------------------------*/ |
428 | 3034 |
853 | 3035 /* A function that takes no arguments and returns a Lisp_Object. |
3036 We could define such types for n arguments, if needed. */ | |
428 | 3037 typedef Lisp_Object (*lisp_fn_t) (void); |
3038 | |
3039 struct Lisp_Subr | |
3040 { | |
3041 struct lrecord_header lheader; | |
442 | 3042 short min_args; |
3043 short max_args; | |
3379 | 3044 /* #### We should make these const Ascbyte * or const Ibyte *, not const |
3045 char *. */ | |
442 | 3046 const char *prompt; |
3047 const char *doc; | |
3048 const char *name; | |
428 | 3049 lisp_fn_t subr_fn; |
3050 }; | |
3051 typedef struct Lisp_Subr Lisp_Subr; | |
3052 | |
3053 DECLARE_LRECORD (subr, Lisp_Subr); | |
3054 #define XSUBR(x) XRECORD (x, subr, Lisp_Subr) | |
617 | 3055 #define wrap_subr(p) wrap_record (p, subr) |
428 | 3056 #define SUBRP(x) RECORDP (x, subr) |
3057 #define CHECK_SUBR(x) CHECK_RECORD (x, subr) | |
3058 #define CONCHECK_SUBR(x) CONCHECK_RECORD (x, subr) | |
3059 | |
436 | 3060 #define subr_function(subr) ((subr)->subr_fn) |
3061 #define SUBR_FUNCTION(subr,max_args) \ | |
3062 ((Lisp_Object (*) (EXFUN_##max_args)) (subr)->subr_fn) | |
3063 #define subr_name(subr) ((subr)->name) | |
428 | 3064 |
442 | 3065 /*------------------------------ marker --------------------------------*/ |
3066 | |
428 | 3067 |
440 | 3068 typedef struct Lisp_Marker Lisp_Marker; |
428 | 3069 struct Lisp_Marker |
3070 { | |
3071 struct lrecord_header lheader; | |
440 | 3072 Lisp_Marker *next; |
3073 Lisp_Marker *prev; | |
428 | 3074 struct buffer *buffer; |
665 | 3075 Membpos membpos; |
428 | 3076 char insertion_type; |
3077 }; | |
3078 | |
1632 | 3079 DECLARE_MODULE_API_LRECORD (marker, Lisp_Marker); |
428 | 3080 #define XMARKER(x) XRECORD (x, marker, Lisp_Marker) |
617 | 3081 #define wrap_marker(p) wrap_record (p, marker) |
428 | 3082 #define MARKERP(x) RECORDP (x, marker) |
3083 #define CHECK_MARKER(x) CHECK_RECORD (x, marker) | |
3084 #define CONCHECK_MARKER(x) CONCHECK_RECORD (x, marker) | |
3085 | |
3086 /* The second check was looking for GCed markers still in use */ | |
2500 | 3087 /* if (INTP (XMARKER (x)->lheader.next.v)) ABORT (); */ |
428 | 3088 |
3089 #define marker_next(m) ((m)->next) | |
3090 #define marker_prev(m) ((m)->prev) | |
3091 | |
3063 | 3092 /*-------------------basic int (no connection to char)------------------*/ |
3093 | |
3094 #define ZEROP(x) EQ (x, Qzero) | |
428 | 3095 |
800 | 3096 #ifdef ERROR_CHECK_TYPES |
428 | 3097 |
3063 | 3098 #define XINT(x) XINT_1 (x, __FILE__, __LINE__) |
3099 | |
3100 DECLARE_INLINE_HEADER ( | |
3101 EMACS_INT | |
3102 XINT_1 (Lisp_Object obj, const Ascbyte *file, int line) | |
3103 ) | |
3104 { | |
3105 assert_at_line (INTP (obj), file, line); | |
3106 return XREALINT (obj); | |
3107 } | |
3108 | |
3109 #else /* no error checking */ | |
3110 | |
3111 #define XINT(obj) XREALINT (obj) | |
3112 | |
3113 #endif /* no error checking */ | |
3114 | |
3115 #define CHECK_INT(x) do { \ | |
3116 if (!INTP (x)) \ | |
3117 dead_wrong_type_argument (Qintegerp, x); \ | |
3118 } while (0) | |
3119 | |
3120 #define CONCHECK_INT(x) do { \ | |
3121 if (!INTP (x)) \ | |
3122 x = wrong_type_argument (Qintegerp, x); \ | |
3123 } while (0) | |
3124 | |
3125 #define NATNUMP(x) (INTP (x) && XINT (x) >= 0) | |
3126 | |
3127 #define CHECK_NATNUM(x) do { \ | |
3128 if (!NATNUMP (x)) \ | |
3129 dead_wrong_type_argument (Qnatnump, x); \ | |
3130 } while (0) | |
3131 | |
3132 #define CONCHECK_NATNUM(x) do { \ | |
3133 if (!NATNUMP (x)) \ | |
3134 x = wrong_type_argument (Qnatnump, x); \ | |
3135 } while (0) | |
3136 | |
3137 /*------------------------------- char ---------------------------------*/ | |
3138 | |
3139 /* NOTE: There are basic functions for converting between a character and | |
3140 the string representation of a character in text.h, as well as lots of | |
3141 other character-related stuff. There are other functions/macros for | |
3142 working with Ichars in charset.h, for retrieving the charset of an | |
3143 Ichar, the length of an Ichar when converted to text, etc. | |
3144 */ | |
3145 | |
3146 #ifdef MULE | |
3147 | |
3148 MODULE_API int non_ascii_valid_ichar_p (Ichar ch); | |
3149 | |
3150 /* Return whether the given Ichar is valid. | |
3151 */ | |
3152 | |
3153 DECLARE_INLINE_HEADER ( | |
3154 int | |
3155 valid_ichar_p (Ichar ch) | |
3156 ) | |
3157 { | |
3158 return (! (ch & ~0xFF)) || non_ascii_valid_ichar_p (ch); | |
3159 } | |
3160 | |
3161 #else /* not MULE */ | |
3162 | |
3163 /* This works when CH is negative, and correctly returns non-zero only when CH | |
3164 is in the range [0, 255], inclusive. */ | |
3165 #define valid_ichar_p(ch) (! (ch & ~0xFF)) | |
3166 | |
3167 #endif /* not MULE */ | |
3168 | |
3169 #ifdef ERROR_CHECK_TYPES | |
3170 | |
3171 DECLARE_INLINE_HEADER ( | |
3172 int | |
3173 CHARP_1 (Lisp_Object obj, const Ascbyte *file, int line) | |
3174 ) | |
3175 { | |
3176 if (XTYPE (obj) != Lisp_Type_Char) | |
3177 return 0; | |
3178 assert_at_line (valid_ichar_p (XCHARVAL (obj)), file, line); | |
3179 return 1; | |
3180 } | |
3181 | |
3182 #define CHARP(x) CHARP_1 (x, __FILE__, __LINE__) | |
3183 | |
826 | 3184 DECLARE_INLINE_HEADER ( |
867 | 3185 Ichar |
2367 | 3186 XCHAR_1 (Lisp_Object obj, const Ascbyte *file, int line) |
826 | 3187 ) |
428 | 3188 { |
3063 | 3189 Ichar ch; |
788 | 3190 assert_at_line (CHARP (obj), file, line); |
3063 | 3191 ch = XCHARVAL (obj); |
3192 assert_at_line (valid_ichar_p (ch), file, line); | |
3193 return ch; | |
428 | 3194 } |
3195 | |
788 | 3196 #define XCHAR(x) XCHAR_1 (x, __FILE__, __LINE__) |
3197 | |
3063 | 3198 #else /* not ERROR_CHECK_TYPES */ |
3199 | |
3200 #define CHARP(x) (XTYPE (x) == Lisp_Type_Char) | |
3201 #define XCHAR(x) ((Ichar) XCHARVAL (x)) | |
3202 | |
3203 #endif /* (else) not ERROR_CHECK_TYPES */ | |
3204 | |
3205 #define CONCHECK_CHAR(x) do { \ | |
3206 if (!CHARP (x)) \ | |
3207 x = wrong_type_argument (Qcharacterp, x); \ | |
3208 } while (0) | |
3209 | |
3210 #define CHECK_CHAR(x) do { \ | |
3211 if (!CHARP (x)) \ | |
3212 dead_wrong_type_argument (Qcharacterp, x); \ | |
3213 } while (0) | |
3214 | |
3215 | |
3216 DECLARE_INLINE_HEADER ( | |
3217 Lisp_Object | |
3218 make_char (Ichar val) | |
3219 ) | |
3220 { | |
3221 type_checking_assert (valid_ichar_p (val)); | |
3222 /* This is defined in lisp-union.h or lisp-disunion.h */ | |
3223 return make_char_1 (val); | |
3224 } | |
3225 | |
3226 /*------------------------- int-char connection ------------------------*/ | |
3227 | |
3228 #ifdef ERROR_CHECK_TYPES | |
3229 | |
3230 #define XCHAR_OR_INT(x) XCHAR_OR_INT_1 (x, __FILE__, __LINE__) | |
3231 | |
3232 DECLARE_INLINE_HEADER ( | |
3233 EMACS_INT | |
3234 XCHAR_OR_INT_1 (Lisp_Object obj, const Ascbyte *file, int line) | |
3235 ) | |
3236 { | |
3237 assert_at_line (INTP (obj) || CHARP (obj), file, line); | |
3238 return CHARP (obj) ? XCHAR (obj) : XINT (obj); | |
3239 } | |
3240 | |
788 | 3241 #else /* no error checking */ |
3242 | |
4134 | 3243 /* obj is multiply eval'ed and not an lvalue; use an inline function instead |
3244 of a macro. */ | |
3245 DECLARE_INLINE_HEADER ( | |
3246 EMACS_INT | |
3247 XCHAR_OR_INT (Lisp_Object obj) | |
3248 ) | |
3249 { | |
3250 return CHARP (obj) ? XCHAR (obj) : XINT (obj); | |
3251 } | |
788 | 3252 |
3253 #endif /* no error checking */ | |
428 | 3254 |
3063 | 3255 /* True of X is an integer whose value is the valid integral equivalent of a |
3256 character. */ | |
3257 | |
3258 #define CHAR_INTP(x) (INTP (x) && valid_ichar_p (XINT (x))) | |
3259 | |
3260 /* True of X is a character or an integral value that can be converted into a | |
3261 character. */ | |
3262 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x)) | |
3263 | |
3264 DECLARE_INLINE_HEADER ( | |
3265 Ichar | |
3266 XCHAR_OR_CHAR_INT (Lisp_Object obj) | |
3267 ) | |
3268 { | |
3269 return CHARP (obj) ? XCHAR (obj) : XINT (obj); | |
3270 } | |
3271 | |
3272 /* Signal an error if CH is not a valid character or integer Lisp_Object. | |
3273 If CH is an integer Lisp_Object, convert it to a character Lisp_Object, | |
3274 but merely by repackaging, without performing tests for char validity. | |
3275 */ | |
3276 | |
3277 #define CHECK_CHAR_COERCE_INT(x) do { \ | |
3278 if (CHARP (x)) \ | |
3279 ; \ | |
3280 else if (CHAR_INTP (x)) \ | |
3281 x = make_char (XINT (x)); \ | |
3282 else \ | |
3283 x = wrong_type_argument (Qcharacterp, x); \ | |
3284 } while (0) | |
3285 | |
3286 /* next three always continuable because they coerce their arguments. */ | |
3287 #define CHECK_INT_COERCE_CHAR(x) do { \ | |
3288 if (INTP (x)) \ | |
3289 ; \ | |
3290 else if (CHARP (x)) \ | |
3291 x = make_int (XCHAR (x)); \ | |
3292 else \ | |
3293 x = wrong_type_argument (Qinteger_or_char_p, x); \ | |
3294 } while (0) | |
3295 | |
3296 #define CHECK_INT_COERCE_MARKER(x) do { \ | |
3297 if (INTP (x)) \ | |
3298 ; \ | |
3299 else if (MARKERP (x)) \ | |
3300 x = make_int (marker_position (x)); \ | |
3301 else \ | |
3302 x = wrong_type_argument (Qinteger_or_marker_p, x); \ | |
3303 } while (0) | |
3304 | |
3305 #define CHECK_INT_COERCE_CHAR_OR_MARKER(x) do { \ | |
3306 if (INTP (x)) \ | |
3307 ; \ | |
3308 else if (CHARP (x)) \ | |
3309 x = make_int (XCHAR (x)); \ | |
3310 else if (MARKERP (x)) \ | |
3311 x = make_int (marker_position (x)); \ | |
3312 else \ | |
3313 x = wrong_type_argument (Qinteger_char_or_marker_p, x); \ | |
3314 } while (0) | |
428 | 3315 |
442 | 3316 /*------------------------------ float ---------------------------------*/ |
428 | 3317 |
3318 /* Note: the 'unused_next_' field exists only to ensure that the | |
3319 `next' pointer fits within the structure, for the purposes of the | |
3320 free list. This makes a difference in the unlikely case of | |
3321 sizeof(double) being smaller than sizeof(void *). */ | |
3322 | |
3323 struct Lisp_Float | |
3324 { | |
3325 struct lrecord_header lheader; | |
3326 union { double d; struct Lisp_Float *unused_next_; } data; | |
3327 }; | |
3328 typedef struct Lisp_Float Lisp_Float; | |
3329 | |
3330 DECLARE_LRECORD (float, Lisp_Float); | |
3331 #define XFLOAT(x) XRECORD (x, float, Lisp_Float) | |
617 | 3332 #define wrap_float(p) wrap_record (p, float) |
428 | 3333 #define FLOATP(x) RECORDP (x, float) |
3334 #define CHECK_FLOAT(x) CHECK_RECORD (x, float) | |
3335 #define CONCHECK_FLOAT(x) CONCHECK_RECORD (x, float) | |
3336 | |
3337 #define float_data(f) ((f)->data.d) | |
3338 #define XFLOAT_DATA(x) float_data (XFLOAT (x)) | |
3339 | |
3340 #define XFLOATINT(n) extract_float (n) | |
3341 | |
3342 #define CHECK_INT_OR_FLOAT(x) do { \ | |
3343 if (!INT_OR_FLOATP (x)) \ | |
3344 dead_wrong_type_argument (Qnumberp, x); \ | |
3345 } while (0) | |
3346 | |
3347 #define CONCHECK_INT_OR_FLOAT(x) do { \ | |
3348 if (!INT_OR_FLOATP (x)) \ | |
3349 x = wrong_type_argument (Qnumberp, x); \ | |
3350 } while (0) | |
3351 | |
3352 # define INT_OR_FLOATP(x) (INTP (x) || FLOATP (x)) | |
3353 | |
442 | 3354 /*--------------------------- readonly objects -------------------------*/ |
440 | 3355 |
3263 | 3356 #ifndef NEW_GC |
428 | 3357 #define CHECK_C_WRITEABLE(obj) \ |
3358 do { if (c_readonly (obj)) c_write_error (obj); } while (0) | |
3359 | |
2720 | 3360 #define C_READONLY(obj) (C_READONLY_RECORD_HEADER_P(XRECORD_LHEADER (obj))) |
3263 | 3361 #endif /* not NEW_GC */ |
2720 | 3362 |
428 | 3363 #define CHECK_LISP_WRITEABLE(obj) \ |
3364 do { if (lisp_readonly (obj)) lisp_write_error (obj); } while (0) | |
3365 | |
3366 #define LISP_READONLY(obj) (LISP_READONLY_RECORD_HEADER_P(XRECORD_LHEADER (obj))) | |
3367 | |
980 | 3368 /*----------------------------- structures ----------------------------*/ |
428 | 3369 |
3370 typedef struct structure_keyword_entry structure_keyword_entry; | |
3371 struct structure_keyword_entry | |
3372 { | |
3373 Lisp_Object keyword; | |
3374 int (*validate) (Lisp_Object keyword, Lisp_Object value, | |
578 | 3375 Error_Behavior errb); |
428 | 3376 }; |
3377 | |
3378 typedef struct | |
3379 { | |
3380 Dynarr_declare (structure_keyword_entry); | |
3381 } structure_keyword_entry_dynarr; | |
3382 | |
3383 typedef struct structure_type structure_type; | |
3384 struct structure_type | |
3385 { | |
3386 Lisp_Object type; | |
3387 structure_keyword_entry_dynarr *keywords; | |
578 | 3388 int (*validate) (Lisp_Object data, Error_Behavior errb); |
428 | 3389 Lisp_Object (*instantiate) (Lisp_Object data); |
3390 }; | |
3391 | |
3392 typedef struct | |
3393 { | |
3394 Dynarr_declare (structure_type); | |
3395 } structure_type_dynarr; | |
3396 | |
3397 struct structure_type *define_structure_type (Lisp_Object type, | |
3398 int (*validate) | |
3399 (Lisp_Object data, | |
578 | 3400 Error_Behavior errb), |
428 | 3401 Lisp_Object (*instantiate) |
3402 (Lisp_Object data)); | |
3403 void define_structure_type_keyword (struct structure_type *st, | |
3404 Lisp_Object keyword, | |
3405 int (*validate) (Lisp_Object keyword, | |
3406 Lisp_Object value, | |
578 | 3407 Error_Behavior errb)); |
428 | 3408 |
858 | 3409 /*---------------------------- weak boxes ------------------------------*/ |
3410 | |
3411 struct weak_box | |
3412 { | |
3017 | 3413 struct LCRECORD_HEADER header; |
858 | 3414 Lisp_Object value; |
3415 | |
3416 Lisp_Object next_weak_box; /* don't mark through this! */ | |
3417 }; | |
3418 | |
3419 void prune_weak_boxes (void); | |
3420 Lisp_Object make_weak_box (Lisp_Object value); | |
3421 Lisp_Object weak_box_ref (Lisp_Object value); | |
3422 | |
3423 DECLARE_LRECORD (weak_box, struct weak_box); | |
3424 #define XWEAK_BOX(x) XRECORD (x, weak_box, struct weak_box) | |
3425 #define XSET_WEAK_BOX(x, v) (XWEAK_BOX (x)->value = (v)) | |
3426 #define wrap_weak_box(p) wrap_record (p, weak_box) | |
3427 #define WEAK_BOXP(x) RECORDP (x, weak_box) | |
3428 #define CHECK_WEAK_BOX(x) CHECK_RECORD (x, weak_box) | |
3429 #define CONCHECK_WEAK_BOX(x) CONCHECK_RECORD (x, weak_box) | |
3430 | |
888 | 3431 /*--------------------------- ephemerons ----------------------------*/ |
3432 | |
3433 struct ephemeron | |
3434 { | |
3017 | 3435 struct LCRECORD_HEADER header; |
888 | 3436 |
3437 Lisp_Object key; | |
3438 | |
3439 /* This field holds a pair. The cdr of this cons points to the next | |
3440 ephemeron in Vall_ephemerons. The car points to another pair | |
3441 whose car is the value and whose cdr is the finalizer. | |
3442 | |
3443 This representation makes it very easy to unlink an ephemeron | |
3444 from Vall_ephemerons and chain it into | |
3445 Vall_ephemerons_to_finalize. */ | |
3446 | |
3447 Lisp_Object cons_chain; | |
3448 | |
3449 Lisp_Object value; | |
3450 }; | |
3451 | |
3452 void prune_ephemerons (void); | |
3453 Lisp_Object ephemeron_value(Lisp_Object ephi); | |
1590 | 3454 void init_marking_ephemerons(void); |
3455 int continue_marking_ephemerons(void); | |
888 | 3456 int finish_marking_ephemerons(void); |
3457 Lisp_Object zap_finalize_list(void); | |
3458 Lisp_Object make_ephemeron(Lisp_Object key, Lisp_Object value, Lisp_Object finalizer); | |
3459 | |
3460 DECLARE_LRECORD(ephemeron, struct ephemeron); | |
3461 #define XEPHEMERON(x) XRECORD (x, ephemeron, struct ephemeron) | |
3462 #define XEPHEMERON_REF(x) (XEPHEMERON (x)->value) | |
3463 #define XEPHEMERON_NEXT(x) (XCDR (XEPHEMERON(x)->cons_chain)) | |
3464 #define XEPHEMERON_FINALIZER(x) (XCDR (XCAR (XEPHEMERON (x)->cons_chain))) | |
3465 #define XSET_EPHEMERON_NEXT(x, n) (XSETCDR (XEPHEMERON(x)->cons_chain, n)) | |
3466 #define XSET_EPHEMERON_VALUE(x, v) (XEPHEMERON(x)->value = (v)) | |
3467 #define XSET_EPHEMERON_KEY(x, k) (XEPHEMERON(x)->key = (k)) | |
3468 #define wrap_ephemeron(p) wrap_record (p, ephemeron) | |
3469 #define EPHEMERONP(x) RECORDP (x, ephemeron) | |
3470 #define CHECK_EPHEMERON(x) CHECK_RECORD (x, ephemeron) | |
3471 #define CONCHECK_EPHEMERON(x) CONCHECK_RECORD (x, ephemeron) | |
3472 | |
858 | 3473 |
442 | 3474 /*---------------------------- weak lists ------------------------------*/ |
428 | 3475 |
3476 enum weak_list_type | |
3477 { | |
3478 /* element disappears if it's unmarked. */ | |
3479 WEAK_LIST_SIMPLE, | |
3480 /* element disappears if it's a cons and either its car or | |
3481 cdr is unmarked. */ | |
3482 WEAK_LIST_ASSOC, | |
3483 /* element disappears if it's a cons and its car is unmarked. */ | |
3484 WEAK_LIST_KEY_ASSOC, | |
3485 /* element disappears if it's a cons and its cdr is unmarked. */ | |
442 | 3486 WEAK_LIST_VALUE_ASSOC, |
3487 /* element disappears if it's a cons and neither its car nor | |
3488 its cdr is marked. */ | |
3489 WEAK_LIST_FULL_ASSOC | |
428 | 3490 }; |
3491 | |
3492 struct weak_list | |
3493 { | |
3017 | 3494 struct LCRECORD_HEADER header; |
428 | 3495 Lisp_Object list; /* don't mark through this! */ |
3496 enum weak_list_type type; | |
3497 Lisp_Object next_weak; /* don't mark through this! */ | |
3498 }; | |
3499 | |
3500 DECLARE_LRECORD (weak_list, struct weak_list); | |
3501 #define XWEAK_LIST(x) XRECORD (x, weak_list, struct weak_list) | |
617 | 3502 #define wrap_weak_list(p) wrap_record (p, weak_list) |
428 | 3503 #define WEAK_LISTP(x) RECORDP (x, weak_list) |
3504 #define CHECK_WEAK_LIST(x) CHECK_RECORD (x, weak_list) | |
3505 #define CONCHECK_WEAK_LIST(x) CONCHECK_RECORD (x, weak_list) | |
3506 | |
3507 #define weak_list_list(w) ((w)->list) | |
3508 #define XWEAK_LIST_LIST(w) (XWEAK_LIST (w)->list) | |
3509 | |
3510 Lisp_Object make_weak_list (enum weak_list_type type); | |
3511 /* The following two are only called by the garbage collector */ | |
3512 int finish_marking_weak_lists (void); | |
3513 void prune_weak_lists (void); | |
3514 | |
1743 | 3515 END_C_DECLS |
428 | 3516 |
3517 /************************************************************************/ | |
771 | 3518 /* Definitions related to the format of text and of characters */ |
3519 /************************************************************************/ | |
3520 | |
3521 /* Note: | |
3522 | |
3523 "internally formatted text" and the term "internal format" in | |
3524 general are likely to refer to the format of text in buffers and | |
3525 strings; "externally formatted text" and the term "external format" | |
3526 refer to any text format used in the O.S. or elsewhere outside of | |
3527 XEmacs. The format of text and of a character are related and | |
3528 there must be a one-to-one relationship (hopefully through a | |
3529 relatively simple algorithmic means of conversion) between a string | |
3530 of text and an equivalent array of characters, but the conversion | |
3531 between the two is NOT necessarily trivial. | |
3532 | |
3533 In a non-Mule XEmacs, allowed characters are numbered 0 through | |
3534 255, where no fixed meaning is assigned to them, but (when | |
3535 representing text, rather than bytes in a binary file) in practice | |
3536 the lower half represents ASCII and the upper half some other 8-bit | |
3537 character set (chosen by setting the font, case tables, syntax | |
3538 tables, etc. appropriately for the character set through ad-hoc | |
3539 means such as the `iso-8859-1' file and the | |
3540 `standard-display-european' function). | |
3541 | |
3542 #### Finish this. | |
3543 | |
3544 */ | |
3545 #include "text.h" | |
3546 | |
3547 | |
3548 /************************************************************************/ | |
428 | 3549 /* Definitions of primitive Lisp functions and variables */ |
3550 /************************************************************************/ | |
3551 | |
3552 | |
3553 /* DEFUN - Define a built-in Lisp-visible C function or `subr'. | |
3554 `lname' should be the name to give the function in Lisp, | |
3555 as a null-terminated C string. | |
3556 `Fname' should be the C equivalent of `lname', using only characters | |
3557 valid in a C identifier, with an "F" prepended. | |
3558 The name of the C constant structure that records information | |
3559 on this function for internal use is "S" concatenated with Fname. | |
3560 `min_args' should be a number, the minimum number of arguments allowed. | |
3561 `max_args' should be a number, the maximum number of arguments allowed, | |
3562 or else MANY or UNEVALLED. | |
3563 MANY means pass a vector of evaluated arguments, | |
3564 in the form of an integer number-of-arguments | |
3565 followed by the address of a vector of Lisp_Objects | |
3566 which contains the argument values. | |
3567 UNEVALLED means pass the list of unevaluated arguments. | |
3568 `prompt' says how to read arguments for an interactive call. | |
3569 See the doc string for `interactive'. | |
3570 A null string means call interactively with no arguments. | |
3571 `arglist' are the comma-separated arguments (always Lisp_Objects) for | |
3572 the function. | |
3573 The docstring for the function is placed as a "C" comment between | |
3574 the prompt and the `args' argument. make-docfile reads the | |
3575 comment and creates the DOC file from it. | |
3576 */ | |
3577 | |
3578 #define EXFUN_0 void | |
3579 #define EXFUN_1 Lisp_Object | |
3580 #define EXFUN_2 Lisp_Object,Lisp_Object | |
3581 #define EXFUN_3 Lisp_Object,Lisp_Object,Lisp_Object | |
3582 #define EXFUN_4 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object | |
3583 #define EXFUN_5 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object | |
3584 #define EXFUN_6 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object, \ | |
3585 Lisp_Object | |
3586 #define EXFUN_7 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object, \ | |
3587 Lisp_Object,Lisp_Object | |
3588 #define EXFUN_8 Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object,Lisp_Object, \ | |
3589 Lisp_Object,Lisp_Object,Lisp_Object | |
3590 #define EXFUN_MANY int, Lisp_Object* | |
3591 #define EXFUN_UNEVALLED Lisp_Object | |
3592 #define EXFUN(sym, max_args) Lisp_Object sym (EXFUN_##max_args) | |
2268 | 3593 #define EXFUN_NORETURN(sym, max_args) \ |
3594 DECLARE_DOESNT_RETURN_TYPE (Lisp_Object, sym (EXFUN_##max_args)) | |
428 | 3595 |
3596 #define SUBR_MAX_ARGS 8 | |
3597 #define MANY -2 | |
3598 #define UNEVALLED -1 | |
3599 | |
3600 /* Can't be const, because then subr->doc is read-only and | |
3601 Snarf_documentation chokes */ | |
3602 | |
3263 | 3603 #ifdef NEW_GC |
2720 | 3604 #define DEFUN(lname, Fname, min_args, max_args, prompt, arglist) \ |
3605 Lisp_Object Fname (EXFUN_##max_args); \ | |
3606 static struct Lisp_Subr MC_ALLOC_S##Fname = \ | |
3607 { \ | |
3608 { /* struct lrecord_header */ \ | |
3609 lrecord_type_subr, /* lrecord_type_index */ \ | |
3610 1, /* lisp_readonly bit */ \ | |
3611 0, /* free */ \ | |
3612 0 /* uid */ \ | |
3613 }, \ | |
3614 min_args, \ | |
3615 max_args, \ | |
3616 prompt, \ | |
3617 0, /* doc string */ \ | |
3618 lname, \ | |
3619 (lisp_fn_t) Fname \ | |
3620 }; \ | |
2814 | 3621 static struct Lisp_Subr *S##Fname; \ |
2720 | 3622 Lisp_Object Fname (DEFUN_##max_args arglist) |
3623 | |
3624 #define DEFUN_NORETURN(lname, Fname, min_args, max_args, prompt, arglist) \ | |
3625 DECLARE_DOESNT_RETURN_TYPE (Lisp_Object, Fname (EXFUN_##max_args)); \ | |
3626 static struct Lisp_Subr MC_ALLOC_S##Fname = \ | |
3627 { \ | |
3628 { /* struct lrecord_header */ \ | |
3629 lrecord_type_subr, /* lrecord_type_index */ \ | |
3630 1, /* lisp_readonly bit */ \ | |
3631 0, /* free */ \ | |
3632 0 /* uid */ \ | |
3633 }, \ | |
3634 min_args, \ | |
3635 max_args, \ | |
3636 prompt, \ | |
3637 0, /* doc string */ \ | |
3638 lname, \ | |
3639 (lisp_fn_t) Fname \ | |
3640 }; \ | |
2814 | 3641 static struct Lisp_Subr *S##Fname; \ |
2720 | 3642 DOESNT_RETURN_TYPE (Lisp_Object) Fname (DEFUN_##max_args arglist) |
2834 | 3643 #define GET_DEFUN_LISP_OBJECT(Fname) \ |
3644 wrap_subr (S##Fname); | |
3263 | 3645 #else /* not NEW_GC */ |
428 | 3646 #define DEFUN(lname, Fname, min_args, max_args, prompt, arglist) \ |
3647 Lisp_Object Fname (EXFUN_##max_args); \ | |
442 | 3648 static struct Lisp_Subr S##Fname = \ |
3649 { \ | |
3650 { /* struct lrecord_header */ \ | |
3651 lrecord_type_subr, /* lrecord_type_index */ \ | |
3652 1, /* mark bit */ \ | |
3653 1, /* c_readonly bit */ \ | |
1111 | 3654 1, /* lisp_readonly bit */ \ |
3655 0 /* unused */ \ | |
442 | 3656 }, \ |
3657 min_args, \ | |
3658 max_args, \ | |
3659 prompt, \ | |
3660 0, /* doc string */ \ | |
3661 lname, \ | |
3662 (lisp_fn_t) Fname \ | |
3663 }; \ | |
428 | 3664 Lisp_Object Fname (DEFUN_##max_args arglist) |
3665 | |
2268 | 3666 #define DEFUN_NORETURN(lname, Fname, min_args, max_args, prompt, arglist) \ |
3667 DECLARE_DOESNT_RETURN_TYPE (Lisp_Object, Fname (EXFUN_##max_args)); \ | |
3668 static struct Lisp_Subr S##Fname = \ | |
3669 { \ | |
3670 { /* struct lrecord_header */ \ | |
3671 lrecord_type_subr, /* lrecord_type_index */ \ | |
3672 1, /* mark bit */ \ | |
3673 1, /* c_readonly bit */ \ | |
3674 1, /* lisp_readonly bit */ \ | |
3675 0 /* unused */ \ | |
3676 }, \ | |
3677 min_args, \ | |
3678 max_args, \ | |
3679 prompt, \ | |
3680 0, /* doc string */ \ | |
3681 lname, \ | |
3682 (lisp_fn_t) Fname \ | |
3683 }; \ | |
3684 DOESNT_RETURN_TYPE (Lisp_Object) Fname (DEFUN_##max_args arglist) | |
2834 | 3685 #define GET_DEFUN_LISP_OBJECT(Fname) \ |
3686 wrap_subr (&S##Fname); | |
3263 | 3687 #endif /* not NEW_GC */ |
2268 | 3688 |
428 | 3689 /* Heavy ANSI C preprocessor hackery to get DEFUN to declare a |
3690 prototype that matches max_args, and add the obligatory | |
3691 `Lisp_Object' type declaration to the formal C arguments. */ | |
3692 | |
3693 #define DEFUN_MANY(named_int, named_Lisp_Object) named_int, named_Lisp_Object | |
3694 #define DEFUN_UNEVALLED(args) Lisp_Object args | |
3695 #define DEFUN_0() void | |
3696 #define DEFUN_1(a) Lisp_Object a | |
3697 #define DEFUN_2(a,b) DEFUN_1(a), Lisp_Object b | |
3698 #define DEFUN_3(a,b,c) DEFUN_2(a,b), Lisp_Object c | |
3699 #define DEFUN_4(a,b,c,d) DEFUN_3(a,b,c), Lisp_Object d | |
3700 #define DEFUN_5(a,b,c,d,e) DEFUN_4(a,b,c,d), Lisp_Object e | |
3701 #define DEFUN_6(a,b,c,d,e,f) DEFUN_5(a,b,c,d,e), Lisp_Object f | |
3702 #define DEFUN_7(a,b,c,d,e,f,g) DEFUN_6(a,b,c,d,e,f), Lisp_Object g | |
3703 #define DEFUN_8(a,b,c,d,e,f,g,h) DEFUN_7(a,b,c,d,e,f,g),Lisp_Object h | |
3704 | |
3705 /* WARNING: If you add defines here for higher values of max_args, | |
3706 make sure to also fix the clauses in PRIMITIVE_FUNCALL(), | |
3707 and change the define of SUBR_MAX_ARGS above. */ | |
3708 | |
3709 #include "symeval.h" | |
3710 | |
1743 | 3711 BEGIN_C_DECLS |
1650 | 3712 |
428 | 3713 /* `specpdl' is the special binding/unwind-protect stack. |
3714 | |
3715 Knuth says (see the Jargon File): | |
3716 At MIT, `pdl' [abbreviation for `Push Down List'] used to | |
3717 be a more common synonym for `stack'. | |
3718 Everywhere else `stack' seems to be the preferred term. | |
3719 | |
3720 specpdl_depth is the current depth of `specpdl'. | |
771 | 3721 Save this for use later as arg to `unbind_to_1'. */ |
1632 | 3722 extern MODULE_API int specpdl_depth_counter; |
428 | 3723 #define specpdl_depth() specpdl_depth_counter |
3724 | |
442 | 3725 |
3726 #define CHECK_FUNCTION(fun) do { \ | |
3727 while (NILP (Ffunctionp (fun))) \ | |
3728 signal_invalid_function_error (fun); \ | |
3729 } while (0) | |
3730 | |
428 | 3731 |
3732 /************************************************************************/ | |
3733 /* Checking for QUIT */ | |
3734 /************************************************************************/ | |
3735 | |
1123 | 3736 /* NOTE NOTE NOTE: Invoking QUIT can cause random Lisp code to be executed! |
3737 This can happen in numerous ways. For example, on many platforms, QUIT | |
3738 needs to drain the event queue to see whether there's a C-g in the works. | |
3739 A side effect of this is that, if there's a menu-press event, menu filters | |
3740 (i.e. Lisp code) will be invoked. Lisp code could also happen if there's | |
3741 an asynchronous timeout, or if the debugger is invoked as a result of | |
3742 debug-on-quit and the user returns by hitting `r', etc. etc. | |
3743 | |
3744 However, GC CANNOT HAPPEN. It is forbidden everywhere within the QUIT- | |
3745 processing code, because most callers cannot tolerate GC during QUIT | |
3746 since it's just too prevalent. */ | |
3747 | |
853 | 3748 /* The exact workings of this mechanism are described in detail in signal.c. */ |
3749 | |
428 | 3750 /* Asynchronous events set something_happened, and then are processed |
3751 within the QUIT macro. At this point, we are guaranteed to not be in | |
3752 any sensitive code. */ | |
3753 | |
1632 | 3754 extern MODULE_API volatile int something_happened; |
3755 extern MODULE_API int dont_check_for_quit; | |
3756 MODULE_API void check_what_happened (void); | |
3757 | |
3758 extern MODULE_API volatile int quit_check_signal_happened; | |
428 | 3759 extern volatile int quit_check_signal_tick_count; |
1632 | 3760 MODULE_API void check_quit (void); |
3761 | |
3762 MODULE_API void signal_quit (void); | |
428 | 3763 |
853 | 3764 int begin_dont_check_for_quit (void); |
3765 int begin_do_check_for_quit (void); | |
3766 | |
3767 /* Nonzero if the values of `quit-flag' and `inhibit-quit' indicate | |
3768 that a quit should be signalled. */ | |
771 | 3769 #define QUIT_FLAG_SAYS_SHOULD_QUIT \ |
3770 (!NILP (Vquit_flag) && \ | |
3771 (NILP (Vinhibit_quit) \ | |
3772 || (EQ (Vquit_flag, Qcritical) && !dont_check_for_quit))) | |
3773 | |
853 | 3774 /* Nonzero if ought to quit now. This is the "efficient" version, which |
3775 respects the flags set to indicate whether the full quit check should | |
3776 be done. Therefore it may be inaccurate (i.e. lagging reality), esp. | |
3777 when poll for quit is used. | |
3778 | |
3779 This is defined for code that wants to allow quitting, but needs to | |
3780 do some cleanup if that happens. (You could always register the cleanup | |
3781 code using record_unwind_protect(), but sometimes it makes more sense | |
3782 to do it using QUITP.) To use this macro, just call it at the | |
3783 appropriate time, and if its value is non-zero, do your cleanup code | |
3784 and then call QUIT. | |
3785 | |
3786 A different version (below) is used for the actual QUIT macro. */ | |
428 | 3787 #define QUITP \ |
853 | 3788 ((quit_check_signal_happened ? check_quit () : (void) 0), \ |
771 | 3789 QUIT_FLAG_SAYS_SHOULD_QUIT) |
428 | 3790 |
853 | 3791 /* This is the version actually called by QUIT. The difference |
3792 between it and QUITP is that it also has side effects in that it | |
3793 will handle anything else that has recently signalled itself | |
3794 asynchronously and wants to be handled now. Currently this | |
3795 includes executing asynchronous timeouts that may have been set | |
3796 from Lisp or from the poll-for-quit or poll-for-sigchld | |
3797 timers. (#### It seems that, to be slightly more accurate, we | |
3798 should also process poll-for-quit timers in the above version. | |
3799 However, this mechanism is inherently approximate, so it really | |
3800 doesn't matter much.) In the future, it might also include doing a | |
3801 thread context switch. Callers of QUITP generally don't except | |
1123 | 3802 random side effects to happen (#### unfortunately, random side effects |
3803 can happen anyway, e.g. through menu filters -- see comment above), | |
3804 so we have this different version. */ | |
428 | 3805 #define INTERNAL_QUITP \ |
853 | 3806 ((something_happened ? check_what_happened () : (void) 0), \ |
771 | 3807 QUIT_FLAG_SAYS_SHOULD_QUIT) |
428 | 3808 |
3809 /* Check quit-flag and quit if it is non-nil. Also do any other things | |
853 | 3810 that are triggered by asynchronous events and might want to be |
3811 handled. */ | |
428 | 3812 #define QUIT do { if (INTERNAL_QUITP) signal_quit (); } while (0) |
3813 | |
3814 | |
3815 /************************************************************************/ | |
3816 /* hashing */ | |
3817 /************************************************************************/ | |
3818 | |
3819 /* #### for a 64-bit machine, we should substitute a prime just over 2^32 */ | |
3820 #define GOOD_HASH 65599 /* prime number just over 2^16; Dragon book, p. 435 */ | |
3821 #define HASH2(a,b) (GOOD_HASH * (a) + (b)) | |
3822 #define HASH3(a,b,c) (GOOD_HASH * HASH2 (a,b) + (c)) | |
3823 #define HASH4(a,b,c,d) (GOOD_HASH * HASH3 (a,b,c) + (d)) | |
3824 #define HASH5(a,b,c,d,e) (GOOD_HASH * HASH4 (a,b,c,d) + (e)) | |
3825 #define HASH6(a,b,c,d,e,f) (GOOD_HASH * HASH5 (a,b,c,d,e) + (f)) | |
3826 #define HASH7(a,b,c,d,e,f,g) (GOOD_HASH * HASH6 (a,b,c,d,e,f) + (g)) | |
3827 #define HASH8(a,b,c,d,e,f,g,h) (GOOD_HASH * HASH7 (a,b,c,d,e,f,g) + (h)) | |
3828 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i)) | |
3829 | |
3830 #define LISP_HASH(obj) ((unsigned long) LISP_TO_VOID (obj)) | |
2516 | 3831 Hashcode memory_hash (const void *xv, Bytecount size); |
3832 Hashcode internal_hash (Lisp_Object obj, int depth); | |
3833 Hashcode internal_array_hash (Lisp_Object *arr, int size, int depth); | |
428 | 3834 |
3835 | |
3836 /************************************************************************/ | |
3837 /* String translation */ | |
3838 /************************************************************************/ | |
3839 | |
771 | 3840 /* When support for message translation exists, GETTEXT() translates a |
3841 string from English into the language defined by | |
3842 `current-language-environment'. This is done by looking the string | |
3843 up in a large predefined table; if no translation is found, the | |
3844 original string is returned, and the failure is possibly logged so | |
3845 that the translation can later be entered into the table. | |
3846 | |
3847 In addition to this, there is a mechanism to snarf message strings | |
3848 out of the source code so that they can be entered into the tables. | |
3849 This is what make-msgfile.lex does. | |
3850 | |
3851 Handling `format' strings is more difficult: The format string | |
3852 should get translated, but not under all circumstances. When the | |
3853 format string is a Lisp string, what should happen is that | |
3854 Fformat() should format the untranslated args[0] and return that, | |
3855 and also call Fgettext() on args[0] and, if that is different, | |
3856 format it and store it in the `string-translatable' property of the | |
3857 returned string. See Fgettext(). | |
3858 | |
3859 CGETTEXT() is the same as GETTEXT() but works with char * strings | |
867 | 3860 instead of Ibyte * strings. |
771 | 3861 |
3862 build_msg_string() is a shorthand for build_string (GETTEXT (x)). | |
3863 build_msg_intstring() is a shorthand for build_intstring (GETTEXT (x)). | |
3864 */ | |
3865 | |
3866 #define GETTEXT(x) (x) | |
3867 #define CGETTEXT(x) (x) | |
3868 #define LISP_GETTEXT(x) (x) | |
428 | 3869 |
3870 /* DEFER_GETTEXT is used to identify strings which are translated when | |
3871 they are referenced instead of when they are defined. | |
3872 These include Qerror_messages and initialized arrays of strings. | |
3873 */ | |
3874 #define DEFER_GETTEXT(x) (x) | |
3875 | |
3876 | |
3877 /************************************************************************/ | |
3878 /* Garbage collection / GC-protection */ | |
3879 /************************************************************************/ | |
3880 | |
3881 /* Structure for recording stack slots that need marking */ | |
3882 | |
3883 /* This is a chain of structures, each of which points at a Lisp_Object | |
3884 variable whose value should be marked in garbage collection. | |
3885 Normally every link of the chain is an automatic variable of a function, | |
3886 and its `val' points to some argument or local variable of the function. | |
3887 On exit to the function, the chain is set back to the value it had on | |
3888 entry. This way, no link remains in the chain when the stack frame | |
3889 containing the link disappears. | |
3890 | |
3891 Every function that can call Feval must protect in this fashion all | |
3892 Lisp_Object variables whose contents will be used again. */ | |
3893 | |
1632 | 3894 extern MODULE_API struct gcpro *gcprolist; |
428 | 3895 |
1743 | 3896 END_C_DECLS |
1650 | 3897 |
1204 | 3898 /* #### Catching insufficient gcpro: |
3899 | |
3900 The C++ code below catches GCPRO without UNGCPRO or vice-versa. | |
3901 Catching cases where there's no GCPRO or UNGCPRO but should be, however, | |
3902 is much harder, but could be done: | |
3903 | |
3904 1. Lisp_Object becomes a real object. Its creator and destructor need to | |
3905 figure out whether the object is on the stack (by looking at the range | |
3906 that `this' is within), and if so, add the pointer to a list of all | |
3907 stack-based Lisp_Objects. | |
3908 | |
3909 2. The assignment method needs to do reference-counting on actual Lisp | |
3910 objects -- in particular, we need to know if there are any references | |
3911 to a Lisp object that are *NOT* from stack-based Lisp_Objects. | |
3912 | |
3913 3. When we get to a point in the code where we might garbage collect -- | |
3914 i.e. Ffuncall(), Feval(), or Fgarbage_collect() is called -- we look | |
3915 at our list of stack-based Lisp_Objects, and if there are any that | |
3916 point to Lisp objects with no non-stack references, see if there are | |
3917 any gcpros pointing to the object, and if not, set a flag indicating | |
3918 that the object is "destroyed". (Don't abort yet because the function | |
3919 might not use the object any more.) | |
3920 | |
3921 4. When we detag a pointer using XFOO(), abort if its "destroyed" flag | |
3922 is set. | |
3923 | |
3924 --ben | |
3925 */ | |
3926 | |
428 | 3927 struct gcpro |
3928 { | |
3929 struct gcpro *next; | |
771 | 3930 const Lisp_Object *var; /* Address of first protected variable */ |
428 | 3931 int nvars; /* Number of consecutive protected variables */ |
1204 | 3932 #if defined (__cplusplus) && defined (ERROR_CHECK_GC) |
3933 /* Try to catch GCPRO without UNGCPRO, or vice-versa. G++ complains (at | |
3934 least with sufficient numbers of warnings enabled, i.e. -Weffc++) if a | |
3935 copy constructor or assignment operator is not defined. */ | |
3936 gcpro () : next (0), var (0), nvars (0) { } | |
3937 gcpro (const gcpro& g) : next (g.next), var (g.var), nvars (g.nvars) { } | |
3938 gcpro& operator= (const gcpro& g) { next = g.next; var = g.var; | |
3939 nvars = g.nvars; | |
3940 return *this;} | |
3941 ~gcpro () { assert (!next); } | |
3942 #endif /* defined (__cplusplus) && defined (ERROR_CHECK_GC) */ | |
428 | 3943 }; |
3944 | |
3945 /* Normally, you declare variables gcpro1, gcpro2, ... and use the | |
3946 GCPROn() macros. However, if you need to have nested gcpro's, | |
3947 declare ngcpro1, ngcpro2, ... and use NGCPROn(). If you need | |
3948 to nest another level, use nngcpro1, nngcpro2, ... and use | |
3949 NNGCPROn(). If you need to nest yet another level, create | |
3950 the appropriate macros. */ | |
3951 | |
1123 | 3952 /* NOTE: About comments like "This function does not GC": These are there to |
3953 try to track whether GCPROing is necessary. Strictly speaking, some | |
3954 functions that say this might actually GC, but only when it is never | |
3955 possible to return (more specifically, in the process of signalling an | |
3956 error, the debugger may be invoked, and could GC). For GCPRO purposes, | |
3957 you only have to worry about functions that can GC and then return. | |
3958 The QUIT macro cannot GC any more, although this wasn't true at some point, | |
3959 and so some "This function can GC" comments may be inaccurate. | |
3960 */ | |
3961 | |
1743 | 3962 BEGIN_C_DECLS |
1650 | 3963 |
2367 | 3964 #define XGCDECL1(x) struct gcpro x##cpro1 |
3965 #define XGCDECL2(x) struct gcpro x##cpro1, x##cpro2 | |
3966 #define XGCDECL3(x) struct gcpro x##cpro1, x##cpro2, x##cpro3 | |
3967 #define XGCDECL4(x) struct gcpro x##cpro1, x##cpro2, x##cpro3, x##cpro4 | |
3968 #define XGCDECL5(x) struct gcpro x##cpro1, x##cpro2, x##cpro3, x##cpro4, x##cpro5 | |
3969 | |
428 | 3970 #ifdef DEBUG_GCPRO |
3971 | |
2367 | 3972 MODULE_API void debug_gcpro1 (Ascbyte *, int, struct gcpro *, Lisp_Object *); |
3973 MODULE_API void debug_gcpro2 (Ascbyte *, int, struct gcpro *, struct gcpro *, | |
1632 | 3974 Lisp_Object *, Lisp_Object *); |
2367 | 3975 MODULE_API void debug_gcpro3 (Ascbyte *, int, struct gcpro *, struct gcpro *, |
1632 | 3976 struct gcpro *, Lisp_Object *, Lisp_Object *, |
3977 Lisp_Object *); | |
2367 | 3978 MODULE_API void debug_gcpro4 (Ascbyte *, int, struct gcpro *, struct gcpro *, |
1632 | 3979 struct gcpro *, struct gcpro *, Lisp_Object *, |
3980 Lisp_Object *, Lisp_Object *, Lisp_Object *); | |
2367 | 3981 MODULE_API void debug_gcpro5 (Ascbyte *, int, struct gcpro *, struct gcpro *, |
1632 | 3982 struct gcpro *, struct gcpro *, struct gcpro *, |
3983 Lisp_Object *, Lisp_Object *, Lisp_Object *, | |
3984 Lisp_Object *, Lisp_Object *); | |
2367 | 3985 MODULE_API void debug_ungcpro(Ascbyte *, int, struct gcpro *); |
3986 | |
3987 #define XGCPRO1(x,v) \ | |
3988 debug_gcpro1 (__FILE__, __LINE__,&x##cpro1,&v) | |
3989 #define XGCPRO2(x,v1,v2) \ | |
3990 debug_gcpro2 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&v1,&v2) | |
3991 #define XGCPRO3(x,v1,v2,v3) \ | |
3992 debug_gcpro3 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&x##cpro3, \ | |
3993 &v1,&v2,&v3) | |
3994 #define XGCPRO4(x,v1,v2,v3,v4) \ | |
3995 debug_gcpro4 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&x##cpro3, \ | |
3996 &x##cpro4, \ | |
428 | 3997 &v1,&v2,&v3,&v4) |
2367 | 3998 #define XGCPRO5(x,v1,v2,v3,v4,v5) \ |
3999 debug_gcpro5 (__FILE__, __LINE__,&x##cpro1,&x##cpro2,&x##cpro3, \ | |
4000 &x##cpro4,&x##cpro5, \ | |
428 | 4001 &v1,&v2,&v3,&v4,&v5) |
2367 | 4002 #define XUNGCPRO(x) \ |
4003 debug_ungcpro(__FILE__, __LINE__,&x##cpro1) | |
428 | 4004 |
4005 #else /* ! DEBUG_GCPRO */ | |
4006 | |
2367 | 4007 #define XGCPRO1(x, var1) ((void) ( \ |
4008 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \ | |
4009 gcprolist = &x##cpro1 )) | |
4010 | |
4011 #define XGCPRO2(x, var1, var2) ((void) ( \ | |
4012 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \ | |
4013 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \ | |
4014 gcprolist = &x##cpro2 )) | |
4015 | |
4016 #define XGCPRO3(x, var1, var2, var3) ((void) ( \ | |
4017 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \ | |
4018 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \ | |
4019 x##cpro3.next = &x##cpro2, x##cpro3.var = &var3, x##cpro3.nvars = 1, \ | |
4020 gcprolist = &x##cpro3 )) | |
4021 | |
4022 #define XGCPRO4(x, var1, var2, var3, var4) ((void) ( \ | |
4023 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \ | |
4024 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \ | |
4025 x##cpro3.next = &x##cpro2, x##cpro3.var = &var3, x##cpro3.nvars = 1, \ | |
4026 x##cpro4.next = &x##cpro3, x##cpro4.var = &var4, x##cpro4.nvars = 1, \ | |
4027 gcprolist = &x##cpro4 )) | |
4028 | |
4029 #define XGCPRO5(x, var1, var2, var3, var4, var5) ((void) ( \ | |
4030 x##cpro1.next = gcprolist, x##cpro1.var = &var1, x##cpro1.nvars = 1, \ | |
4031 x##cpro2.next = &x##cpro1, x##cpro2.var = &var2, x##cpro2.nvars = 1, \ | |
4032 x##cpro3.next = &x##cpro2, x##cpro3.var = &var3, x##cpro3.nvars = 1, \ | |
4033 x##cpro4.next = &x##cpro3, x##cpro4.var = &var4, x##cpro4.nvars = 1, \ | |
4034 x##cpro5.next = &x##cpro4, x##cpro5.var = &var5, x##cpro5.nvars = 1, \ | |
4035 gcprolist = &x##cpro5 )) | |
4036 | |
4037 #define XGCPRO1_ARRAY(x, array, n) ((void) ( \ | |
4038 x##cpro1.next = gcprolist, x##cpro1.var = array, x##cpro1.nvars = n, \ | |
4039 gcprolist = &x##cpro1 )) | |
4040 | |
4041 #define XGCPRO2_ARRAY(x, array1, n1, array2, n2) ((void) ( \ | |
4042 x##cpro1.next = gcprolist, x##cpro1.var = array1, x##cpro1.nvars = n1, \ | |
4043 x##cpro2.next = &x##cpro1, x##cpro2.var = array2, x##cpro2.nvars = n2, \ | |
4044 gcprolist = &x##cpro2 )) | |
4045 | |
4046 #define XGCPRO3_ARRAY(x, array1, n1, array2, n2, array3, n3) ((void) ( \ | |
4047 x##cpro1.next = gcprolist, x##cpro1.var = array1, x##cpro1.nvars = n1, \ | |
4048 x##cpro2.next = &x##cpro1, x##cpro2.var = array2, x##cpro2.nvars = n2, \ | |
4049 x##cpro3.next = &x##cpro2, x##cpro3.var = array3, x##cpro3.nvars = n3, \ | |
4050 gcprolist = &x##cpro3 )) | |
853 | 4051 |
1204 | 4052 #if defined (__cplusplus) && defined (ERROR_CHECK_GC) |
4053 /* We need to reset each gcpro to avoid triggering the assert() in | |
4054 ~gcpro(). This happens in UNGCPRO and longjmp(). */ | |
4055 #define UNWIND_GCPRO_TO(val) \ | |
4056 do \ | |
4057 { \ | |
4058 struct gcpro *__gcpro_stop = (val); \ | |
4059 /* Try to catch UNGCPRO without GCPRO. We arrange for there to be a \ | |
4060 sentinel at the end of the gcprolist, so it should never be NULL. */ \ | |
4061 assert (__gcpro_stop); \ | |
4062 while (gcprolist != __gcpro_stop) \ | |
4063 { \ | |
4064 struct gcpro *__gcpro_next = gcprolist->next; \ | |
4065 gcprolist->next = 0; \ | |
4066 gcprolist = __gcpro_next; \ | |
4067 assert (gcprolist); \ | |
4068 } \ | |
4069 } while (0) | |
4070 #else | |
4071 #define UNWIND_GCPRO_TO(val) (gcprolist = (val)) | |
4072 #endif /* defined (__cplusplus) && defined (ERROR_CHECK_GC) */ | |
4073 | |
2367 | 4074 #define XUNGCPRO(x) UNWIND_GCPRO_TO (x##cpro1.next) |
428 | 4075 |
4076 #endif /* ! DEBUG_GCPRO */ | |
4077 | |
2367 | 4078 #define GCDECL1 XGCDECL1 (g) |
4079 #define GCDECL2 XGCDECL2 (g) | |
4080 #define GCDECL3 XGCDECL3 (g) | |
4081 #define GCDECL4 XGCDECL4 (g) | |
4082 #define GCDECL5 XGCDECL5 (g) | |
4083 | |
4084 #define GCPRO1(a) XGCPRO1 (g,a) | |
4085 #define GCPRO2(a,b) XGCPRO2 (g,a,b) | |
4086 #define GCPRO3(a,b,c) XGCPRO3 (g,a,b,c) | |
4087 #define GCPRO4(a,b,c,d) XGCPRO4 (g,a,b,c,d) | |
4088 #define GCPRO5(a,b,c,d,e) XGCPRO5 (g,a,b,c,d,e) | |
4089 | |
4090 #define GCPRO1_ARRAY(a1,n1) XGCPRO1_ARRAY(g,a1,n1) | |
4091 #define GCPRO2_ARRAY(a1,n1,a2,n2) XGCPRO2_ARRAY (g,a1,n1,a2,n2) | |
4092 #define GCPRO3_ARRAY(a1,n1,a2,n2,a3,n3) XGCPRO3_ARRAY (g,a1,n1,a2,n2,a3,n3) | |
4093 | |
4094 #define UNGCPRO XUNGCPRO (g) | |
4095 | |
4096 #define NGCDECL1 XGCDECL1 (ng) | |
4097 #define NGCDECL2 XGCDECL2 (ng) | |
4098 #define NGCDECL3 XGCDECL3 (ng) | |
4099 #define NGCDECL4 XGCDECL4 (ng) | |
4100 #define NGCDECL5 XGCDECL5 (ng) | |
4101 | |
4102 #define NGCPRO1(a) XGCPRO1 (ng,a) | |
4103 #define NGCPRO2(a,b) XGCPRO2 (ng,a,b) | |
4104 #define NGCPRO3(a,b,c) XGCPRO3 (ng,a,b,c) | |
4105 #define NGCPRO4(a,b,c,d) XGCPRO4 (ng,a,b,c,d) | |
4106 #define NGCPRO5(a,b,c,d,e) XGCPRO5 (ng,a,b,c,d,e) | |
4107 | |
4108 #define NGCPRO1_ARRAY(a1,n1) XGCPRO1_ARRAY(ng,a1,n1) | |
4109 #define NGCPRO2_ARRAY(a1,n1,a2,n2) XGCPRO2_ARRAY (ng,a1,n1,a2,n2) | |
4110 #define NGCPRO3_ARRAY(a1,n1,a2,n2,a3,n3) XGCPRO3_ARRAY (ng,a1,n1,a2,n2,a3,n3) | |
4111 | |
4112 #define NUNGCPRO XUNGCPRO (ng) | |
4113 | |
4114 #define NNGCDECL1 XGCDECL1 (nng) | |
4115 #define NNGCDECL2 XGCDECL2 (nng) | |
4116 #define NNGCDECL3 XGCDECL3 (nng) | |
4117 #define NNGCDECL4 XGCDECL4 (nng) | |
4118 #define NNGCDECL5 XGCDECL5 (nng) | |
4119 | |
4120 #define NNGCPRO1(a) XGCPRO1 (nng,a) | |
4121 #define NNGCPRO2(a,b) XGCPRO2 (nng,a,b) | |
4122 #define NNGCPRO3(a,b,c) XGCPRO3 (nng,a,b,c) | |
4123 #define NNGCPRO4(a,b,c,d) XGCPRO4 (nng,a,b,c,d) | |
4124 #define NNGCPRO5(a,b,c,d,e) XGCPRO5 (nng,a,b,c,d,e) | |
4125 | |
4126 #define NNGCPRO1_ARRAY(a1,n1) XGCPRO1_ARRAY(nng,a1,n1) | |
4127 #define NNGCPRO2_ARRAY(a1,n1,a2,n2) XGCPRO2_ARRAY (nng,a1,n1,a2,n2) | |
4128 #define NNGCPRO3_ARRAY(a1,n1,a2,n2,a3,n3) XGCPRO3_ARRAY (nng,a1,n1,a2,n2,a3,n3) | |
4129 | |
4130 #define NNUNGCPRO XUNGCPRO (nng) | |
4131 | |
428 | 4132 /* Evaluate expr, UNGCPRO, and then return the value of expr. */ |
4133 #define RETURN_UNGCPRO(expr) do \ | |
4134 { \ | |
4135 Lisp_Object ret_ungc_val = (expr); \ | |
4136 UNGCPRO; \ | |
4137 RETURN_SANS_WARNINGS ret_ungc_val; \ | |
4138 } while (0) | |
4139 | |
4140 /* Evaluate expr, NUNGCPRO, UNGCPRO, and then return the value of expr. */ | |
4141 #define RETURN_NUNGCPRO(expr) do \ | |
4142 { \ | |
4143 Lisp_Object ret_ungc_val = (expr); \ | |
4144 NUNGCPRO; \ | |
4145 UNGCPRO; \ | |
4146 RETURN_SANS_WARNINGS ret_ungc_val; \ | |
4147 } while (0) | |
4148 | |
4149 /* Evaluate expr, NNUNGCPRO, NUNGCPRO, UNGCPRO, and then return the | |
4150 value of expr. */ | |
4151 #define RETURN_NNUNGCPRO(expr) do \ | |
4152 { \ | |
4153 Lisp_Object ret_ungc_val = (expr); \ | |
4154 NNUNGCPRO; \ | |
4155 NUNGCPRO; \ | |
4156 UNGCPRO; \ | |
4157 RETURN_SANS_WARNINGS ret_ungc_val; \ | |
4158 } while (0) | |
4159 | |
452 | 4160 extern Lisp_Object_ptr_dynarr *staticpros; |
3092 | 4161 extern Lisp_Object_ptr_dynarr *staticpros_nodump; |
771 | 4162 #ifdef DEBUG_XEMACS |
4163 | |
4164 /* Help debug crashes gc-marking a staticpro'ed object. */ | |
4165 | |
2367 | 4166 MODULE_API void staticpro_1 (Lisp_Object *, Ascbyte *); |
4167 MODULE_API void staticpro_nodump_1 (Lisp_Object *, Ascbyte *); | |
4511
71bf2c5667ba
Fix g++ const char -> char warnings.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
4168 /* g++ 4.3 complains about the conversion of const char to char. |
71bf2c5667ba
Fix g++ const char -> char warnings.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
4169 These end up in a dynarray, so we would need to define a whole new class |
71bf2c5667ba
Fix g++ const char -> char warnings.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
4170 of dynarray just to handle the const char stuff. |
71bf2c5667ba
Fix g++ const char -> char warnings.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
4171 ####Check to see how hard this might be. */ |
71bf2c5667ba
Fix g++ const char -> char warnings.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
4172 #define staticpro(ptr) staticpro_1 (ptr, (Ascbyte *) #ptr) |
71bf2c5667ba
Fix g++ const char -> char warnings.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
4173 #define staticpro_nodump(ptr) staticpro_nodump_1 (ptr, (Ascbyte *) #ptr) |
771 | 4174 |
996 | 4175 #ifdef HAVE_SHLIB |
2367 | 4176 MODULE_API void unstaticpro_nodump_1 (Lisp_Object *, Ascbyte *); |
4511
71bf2c5667ba
Fix g++ const char -> char warnings.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
4177 #define unstaticpro_nodump(ptr) unstaticpro_nodump_1 (ptr, (Ascbyte *) #ptr) |
996 | 4178 #endif |
4179 | |
771 | 4180 #else |
611 | 4181 |
428 | 4182 /* Call staticpro (&var) to protect static variable `var'. */ |
1632 | 4183 MODULE_API void staticpro (Lisp_Object *); |
428 | 4184 |
4185 /* Call staticpro_nodump (&var) to protect static variable `var'. */ | |
4186 /* var will not be saved at dump time */ | |
1632 | 4187 MODULE_API void staticpro_nodump (Lisp_Object *); |
428 | 4188 |
996 | 4189 #ifdef HAVE_SHLIB |
4190 /* Call unstaticpro_nodump (&var) to stop protecting static variable `var'. */ | |
1632 | 4191 MODULE_API void unstaticpro_nodump (Lisp_Object *); |
996 | 4192 #endif |
4193 | |
771 | 4194 #endif |
4195 | |
3263 | 4196 #ifdef NEW_GC |
2720 | 4197 extern Lisp_Object_dynarr *mcpros; |
4198 #ifdef DEBUG_XEMACS | |
4199 /* Help debug crashes gc-marking a mcpro'ed object. */ | |
4200 MODULE_API void mcpro_1 (Lisp_Object, char *); | |
4201 #define mcpro(ptr) mcpro_1 (ptr, #ptr) | |
4202 #else /* not DEBUG_XEMACS */ | |
4203 /* Call mcpro (&var) to protect mc variable `var'. */ | |
4204 MODULE_API void mcpro (Lisp_Object); | |
4205 #endif /* not DEBUG_XEMACS */ | |
3263 | 4206 #endif /* NEW_GC */ |
2720 | 4207 |
771 | 4208 void register_post_gc_action (void (*fun) (void *), void *arg); |
4209 int begin_gc_forbidden (void); | |
4210 void end_gc_forbidden (int count); | |
1957 | 4211 extern int gc_currently_forbidden; |
771 | 4212 |
1743 | 4213 END_C_DECLS |
1650 | 4214 |
771 | 4215 |
4216 /************************************************************************/ | |
4217 /* Misc definitions */ | |
4218 /************************************************************************/ | |
442 | 4219 |
4220 /************************************************************************/ | |
1983 | 4221 /* Other numeric types */ |
4222 /************************************************************************/ | |
4223 #include "number.h" | |
4224 | |
4225 | |
4226 /************************************************************************/ | |
442 | 4227 /* prototypes */ |
4228 /************************************************************************/ | |
4229 | |
4230 /* NOTE: Prototypes should go HERE, not in various header files, unless | |
4231 they specifically reference a type that's not defined in lisp.h. | |
4232 (And even then, you might consider adding the type to lisp.h.) | |
4233 | |
4234 The idea is that header files typically contain the innards of objects, | |
4235 and we want to minimize the number of "dependencies" of one file on | |
4236 the specifics of such objects. Putting prototypes here minimizes the | |
4237 number of header files that need to be included -- good for a number | |
4238 of reasons. --ben */ | |
4239 | |
4240 /*--------------- prototypes for various public c functions ------------*/ | |
4241 | |
4242 /* Prototypes for all init/syms_of/vars_of initialization functions. */ | |
4243 #include "symsinit.h" | |
4244 | |
1743 | 4245 BEGIN_C_DECLS |
1650 | 4246 |
826 | 4247 /* Defined in abbrev.c */ |
1632 | 4248 MODULE_API EXFUN (Fexpand_abbrev, 0); |
826 | 4249 |
428 | 4250 /* Defined in alloc.c */ |
1632 | 4251 MODULE_API EXFUN (Fcons, 2); |
4252 MODULE_API EXFUN (Flist, MANY); | |
4995
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
4253 EXFUN (Fbit_vector, MANY); |
826 | 4254 EXFUN (Fmake_byte_code, MANY); |
1632 | 4255 MODULE_API EXFUN (Fmake_list, 2); |
4256 MODULE_API EXFUN (Fmake_string, 2); | |
4995
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
4257 EXFUN (Fstring, MANY); |
1632 | 4258 MODULE_API EXFUN (Fmake_symbol, 1); |
4259 MODULE_API EXFUN (Fmake_vector, 2); | |
4260 MODULE_API EXFUN (Fvector, MANY); | |
826 | 4261 |
3263 | 4262 #ifndef NEW_GC |
428 | 4263 void release_breathing_space (void); |
3263 | 4264 #endif /* not NEW_GC */ |
428 | 4265 Lisp_Object noseeum_cons (Lisp_Object, Lisp_Object); |
1632 | 4266 MODULE_API Lisp_Object make_vector (Elemcount, Lisp_Object); |
4267 MODULE_API Lisp_Object vector1 (Lisp_Object); | |
4268 MODULE_API Lisp_Object vector2 (Lisp_Object, Lisp_Object); | |
4269 MODULE_API Lisp_Object vector3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
665 | 4270 Lisp_Object make_bit_vector (Elemcount, Lisp_Object); |
4271 Lisp_Object make_bit_vector_from_byte_vector (unsigned char *, Elemcount); | |
428 | 4272 Lisp_Object noseeum_make_marker (void); |
3092 | 4273 #ifndef NEW_GC |
428 | 4274 void garbage_collect_1 (void); |
3092 | 4275 #endif /* not NEW_GC */ |
1632 | 4276 MODULE_API Lisp_Object acons (Lisp_Object, Lisp_Object, Lisp_Object); |
4277 MODULE_API Lisp_Object cons3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
4278 MODULE_API Lisp_Object list1 (Lisp_Object); | |
4279 MODULE_API Lisp_Object list2 (Lisp_Object, Lisp_Object); | |
4280 MODULE_API Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
4281 MODULE_API Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4282 Lisp_Object); | |
4283 MODULE_API Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, | |
4284 Lisp_Object); | |
4285 MODULE_API Lisp_Object list6 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, | |
4286 Lisp_Object, Lisp_Object); | |
428 | 4287 DECLARE_DOESNT_RETURN (memory_full (void)); |
4288 void disksave_object_finalization (void); | |
4289 extern int purify_flag; | |
3092 | 4290 #ifndef NEW_GC |
428 | 4291 extern EMACS_INT gc_generation_number[1]; |
3092 | 4292 #endif /* not NEW_GC */ |
428 | 4293 int c_readonly (Lisp_Object); |
4294 int lisp_readonly (Lisp_Object); | |
1632 | 4295 MODULE_API void copy_lisp_object (Lisp_Object dst, Lisp_Object src); |
4296 MODULE_API Lisp_Object build_intstring (const Ibyte *); | |
4297 MODULE_API Lisp_Object build_string (const CIbyte *); | |
4298 MODULE_API Lisp_Object build_ext_string (const Extbyte *, Lisp_Object); | |
4299 MODULE_API Lisp_Object build_msg_intstring (const Ibyte *); | |
4300 MODULE_API Lisp_Object build_msg_string (const CIbyte *); | |
4301 MODULE_API Lisp_Object make_string (const Ibyte *, Bytecount); | |
4302 MODULE_API Lisp_Object make_ext_string (const Extbyte *, EMACS_INT, Lisp_Object); | |
771 | 4303 void init_string_ascii_begin (Lisp_Object string); |
428 | 4304 Lisp_Object make_uninit_string (Bytecount); |
1632 | 4305 MODULE_API Lisp_Object make_float (double); |
867 | 4306 Lisp_Object make_string_nocopy (const Ibyte *, Bytecount); |
853 | 4307 void free_cons (Lisp_Object); |
428 | 4308 void free_list (Lisp_Object); |
4309 void free_alist (Lisp_Object); | |
1204 | 4310 void free_marker (Lisp_Object); |
428 | 4311 int object_dead_p (Lisp_Object); |
4312 void mark_object (Lisp_Object obj); | |
3092 | 4313 #ifndef NEW_GC |
1598 | 4314 #ifdef USE_KKCC |
2645 | 4315 #ifdef DEBUG_XEMACS |
4316 void kkcc_gc_stack_push_lisp_object_1 (Lisp_Object obj, int level, int pos); | |
4317 #define kkcc_gc_stack_push_lisp_object(obj, level, pos) \ | |
4318 kkcc_gc_stack_push_lisp_object_1 (obj, level, pos) | |
4319 void kkcc_backtrace (void); | |
4320 #else | |
4321 void kkcc_gc_stack_push_lisp_object_1 (Lisp_Object obj); | |
4322 #define kkcc_gc_stack_push_lisp_object(obj, level, pos) \ | |
4323 kkcc_gc_stack_push_lisp_object_1 (obj) | |
4324 #define kkcc_backtrace() | |
4325 #endif | |
1598 | 4326 #endif /* USE_KKCC */ |
3092 | 4327 #endif /* not NEW_GC */ |
428 | 4328 int marked_p (Lisp_Object obj); |
851 | 4329 extern int funcall_allocation_flag; |
814 | 4330 extern int need_to_garbage_collect; |
1632 | 4331 extern MODULE_API int need_to_check_c_alloca; |
888 | 4332 extern int need_to_signal_post_gc; |
1333 | 4333 extern Lisp_Object Qpost_gc_hook, Qgarbage_collecting; |
851 | 4334 void recompute_funcall_allocation_flag (void); |
428 | 4335 |
4336 #ifdef MEMORY_USAGE_STATS | |
665 | 4337 Bytecount malloced_storage_size (void *, Bytecount, struct overhead_stats *); |
4338 Bytecount fixed_type_block_overhead (Bytecount); | |
428 | 4339 #endif |
1204 | 4340 |
4341 #ifdef EVENT_DATA_AS_OBJECTS | |
4342 Lisp_Object make_key_data (void); | |
4343 Lisp_Object make_button_data (void); | |
4344 Lisp_Object make_motion_data (void); | |
4345 Lisp_Object make_process_data (void); | |
4346 Lisp_Object make_timeout_data (void); | |
4347 Lisp_Object make_magic_data (void); | |
4348 Lisp_Object make_magic_eval_data (void); | |
4349 Lisp_Object make_eval_data (void); | |
4350 Lisp_Object make_misc_user_data (void); | |
4351 void free_key_data (Lisp_Object); | |
4352 void free_button_data (Lisp_Object); | |
4353 void free_motion_data (Lisp_Object); | |
4354 void free_process_data (Lisp_Object); | |
4355 void free_timeout_data (Lisp_Object); | |
4356 void free_magic_data (Lisp_Object); | |
4357 void free_magic_eval_data (Lisp_Object); | |
4358 void free_eval_data (Lisp_Object); | |
4359 void free_misc_user_data (Lisp_Object); | |
4360 #endif /* EVENT_DATA_AS_OBJECTS */ | |
934 | 4361 |
428 | 4362 /* Defined in buffer.c */ |
4363 Lisp_Object get_truename_buffer (Lisp_Object); | |
4364 void switch_to_buffer (Lisp_Object, Lisp_Object); | |
4365 extern int find_file_compare_truenames; | |
4366 extern int find_file_use_truenames; | |
867 | 4367 Ibyte *get_initial_directory (Ibyte *pathname, Bytecount size); |
771 | 4368 void set_buffer_internal (struct buffer *b); |
4369 struct buffer *decode_buffer (Lisp_Object buffer, int allow_string); | |
4370 | |
4371 void record_buffer (Lisp_Object buf); | |
4372 Lisp_Object get_buffer (Lisp_Object name, | |
4373 int error_if_deleted_or_does_not_exist); | |
4374 int map_over_sharing_buffers (struct buffer *buf, | |
4375 int (*mapfun) (struct buffer *buf, | |
4376 void *closure), | |
4377 void *closure); | |
1204 | 4378 void cleanup_buffer_undo_lists (void); |
771 | 4379 |
4380 extern struct buffer *current_buffer; | |
4381 | |
4382 extern void init_initial_directory (void); /* initialize initial_directory */ | |
4383 | |
4384 EXFUN (Fbuffer_disable_undo, 1); | |
1632 | 4385 MODULE_API EXFUN (Fbuffer_modified_p, 1); |
4386 MODULE_API EXFUN (Fbuffer_name, 1); | |
4387 MODULE_API EXFUN (Fcurrent_buffer, 0); | |
771 | 4388 EXFUN (Ferase_buffer, 1); |
4389 EXFUN (Fget_buffer, 1); | |
4390 EXFUN (Fget_buffer_create, 1); | |
4391 EXFUN (Fget_file_buffer, 1); | |
1632 | 4392 MODULE_API EXFUN (Fkill_buffer, 1); |
771 | 4393 EXFUN (Fother_buffer, 3); |
4394 EXFUN (Frecord_buffer, 1); | |
1632 | 4395 MODULE_API EXFUN (Fset_buffer, 1); |
771 | 4396 EXFUN (Fset_buffer_modified_p, 2); |
4397 | |
4398 extern Lisp_Object QSscratch, Qafter_change_function, Qafter_change_functions; | |
4399 extern Lisp_Object Qbefore_change_function, Qbefore_change_functions; | |
4400 extern Lisp_Object Qbuffer_or_string_p, Qdefault_directory, Qfirst_change_hook; | |
4401 extern Lisp_Object Qpermanent_local, Vafter_change_function; | |
4402 extern Lisp_Object Vafter_change_functions, Vbefore_change_function; | |
4403 extern Lisp_Object Vbefore_change_functions, Vbuffer_alist, Vbuffer_defaults; | |
4404 extern Lisp_Object Vinhibit_read_only, Vtransient_mark_mode; | |
428 | 4405 |
563 | 4406 /* Defined in bytecode.c */ |
826 | 4407 EXFUN (Fbyte_code, 3); |
4408 | |
593 | 4409 DECLARE_DOESNT_RETURN (invalid_byte_code |
867 | 4410 (const CIbyte *reason, Lisp_Object frob)); |
563 | 4411 |
826 | 4412 /* Defined in callint.c */ |
4413 EXFUN (Fcall_interactively, 3); | |
4414 EXFUN (Fprefix_numeric_value, 1); | |
4415 | |
4416 /* Defined in casefiddle.c */ | |
4417 EXFUN (Fdowncase, 2); | |
4418 EXFUN (Fupcase, 2); | |
4419 EXFUN (Fupcase_initials, 2); | |
4420 EXFUN (Fupcase_initials_region, 3); | |
4421 EXFUN (Fupcase_region, 3); | |
4422 | |
4423 /* Defined in casetab.c */ | |
4424 EXFUN (Fset_standard_case_table, 1); | |
4425 | |
4426 /* Defined in chartab.c */ | |
4427 EXFUN (Freset_char_table, 1); | |
4428 | |
4429 /* Defined in cmds.c */ | |
4430 EXFUN (Fbeginning_of_line, 2); | |
4431 EXFUN (Fend_of_line, 2); | |
4432 EXFUN (Fforward_char, 2); | |
4433 EXFUN (Fforward_line, 2); | |
4434 | |
428 | 4435 /* Defined in data.c */ |
826 | 4436 EXFUN (Fadd1, 1); |
4437 EXFUN (Faref, 2); | |
4438 EXFUN (Faset, 3); | |
4439 EXFUN (Fcar, 1); | |
4440 EXFUN (Fcar_safe, 1); | |
4441 EXFUN (Fcdr, 1); | |
919 | 4442 EXFUN (Fcdr_safe, 1); |
826 | 4443 EXFUN (Fgeq, MANY); |
4444 EXFUN (Fgtr, MANY); | |
4445 EXFUN (Findirect_function, 1); | |
4446 EXFUN (Fleq, MANY); | |
4447 EXFUN (Flistp, 1); | |
4448 EXFUN (Flss, MANY); | |
4449 EXFUN (Fmax, MANY); | |
4450 EXFUN (Fmin, MANY); | |
4451 EXFUN (Fminus, MANY); | |
4452 EXFUN (Fnumber_to_string, 1); | |
4453 EXFUN (Fplus, MANY); | |
4454 EXFUN (Fquo, MANY); | |
4455 EXFUN (Frem, 2); | |
4456 EXFUN (Fsetcar, 2); | |
4457 EXFUN (Fsetcdr, 2); | |
4458 EXFUN (Fsub1, 1); | |
4459 EXFUN (Fsubr_max_args, 1); | |
4460 EXFUN (Fsubr_min_args, 1); | |
4461 EXFUN (Ftimes, MANY); | |
4462 | |
428 | 4463 DECLARE_DOESNT_RETURN (c_write_error (Lisp_Object)); |
4464 DECLARE_DOESNT_RETURN (lisp_write_error (Lisp_Object)); | |
4465 DECLARE_DOESNT_RETURN (args_out_of_range (Lisp_Object, Lisp_Object)); | |
4466 DECLARE_DOESNT_RETURN (args_out_of_range_3 (Lisp_Object, Lisp_Object, | |
4467 Lisp_Object)); | |
1632 | 4468 MODULE_API Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object); |
4469 MODULE_API | |
428 | 4470 DECLARE_DOESNT_RETURN (dead_wrong_type_argument (Lisp_Object, Lisp_Object)); |
4471 void check_int_range (EMACS_INT, EMACS_INT, EMACS_INT); | |
4472 | |
771 | 4473 EXFUN (Fint_to_char, 1); |
4474 EXFUN (Fchar_to_int, 1); | |
4475 | |
428 | 4476 enum arith_comparison { |
4477 arith_equal, | |
4478 arith_notequal, | |
4479 arith_less, | |
4480 arith_grtr, | |
4481 arith_less_or_equal, | |
4482 arith_grtr_or_equal }; | |
4483 Lisp_Object arithcompare (Lisp_Object, Lisp_Object, enum arith_comparison); | |
4484 | |
707 | 4485 /* Do NOT use word_to_lisp or wasteful_word_to_lisp to decode time_t's |
4486 unless you KNOW arg is non-negative. They cannot return negative | |
4487 values! Use make_time. */ | |
428 | 4488 Lisp_Object word_to_lisp (unsigned int); |
4489 unsigned int lisp_to_word (Lisp_Object); | |
4490 | |
4491 /* Defined in dired.c */ | |
867 | 4492 Lisp_Object make_directory_hash_table (const Ibyte *); |
428 | 4493 Lisp_Object wasteful_word_to_lisp (unsigned int); |
4494 | |
4495 /* Defined in doc.c */ | |
826 | 4496 EXFUN (Fsubstitute_command_keys, 1); |
4497 | |
814 | 4498 Lisp_Object unparesseuxify_doc_string (int fd, EMACS_INT position, |
867 | 4499 Ibyte *name_nonreloc, |
814 | 4500 Lisp_Object name_reloc, |
4501 int standard_doc_file); | |
428 | 4502 Lisp_Object read_doc_string (Lisp_Object); |
4503 | |
4504 /* Defined in doprnt.c */ | |
867 | 4505 Bytecount emacs_doprnt_va (Lisp_Object stream, const Ibyte *format_nonreloc, |
771 | 4506 Bytecount format_length, Lisp_Object format_reloc, |
4507 va_list vargs); | |
867 | 4508 Bytecount emacs_doprnt (Lisp_Object stream, const Ibyte *format_nonreloc, |
771 | 4509 Bytecount format_length, Lisp_Object format_reloc, |
4510 int nargs, const Lisp_Object *largs, ...); | |
867 | 4511 Lisp_Object emacs_vsprintf_string_lisp (const CIbyte *format_nonreloc, |
771 | 4512 Lisp_Object format_reloc, int nargs, |
4513 const Lisp_Object *largs); | |
867 | 4514 Lisp_Object emacs_sprintf_string_lisp (const CIbyte *format_nonreloc, |
771 | 4515 Lisp_Object format_reloc, int nargs, ...); |
867 | 4516 Ibyte *emacs_vsprintf_malloc_lisp (const CIbyte *format_nonreloc, |
771 | 4517 Lisp_Object format_reloc, int nargs, |
4518 const Lisp_Object *largs, | |
4519 Bytecount *len_out); | |
867 | 4520 Ibyte *emacs_sprintf_malloc_lisp (Bytecount *len_out, |
4521 const CIbyte *format_nonreloc, | |
771 | 4522 Lisp_Object format_reloc, int nargs, ...); |
867 | 4523 Lisp_Object emacs_vsprintf_string (const CIbyte *format, va_list vargs); |
4524 Lisp_Object emacs_sprintf_string (const CIbyte *format, ...) | |
771 | 4525 PRINTF_ARGS (1, 2); |
867 | 4526 Ibyte *emacs_vsprintf_malloc (const CIbyte *format, va_list vargs, |
771 | 4527 Bytecount *len_out); |
867 | 4528 Ibyte *emacs_sprintf_malloc (Bytecount *len_out, const CIbyte *format, ...) |
771 | 4529 PRINTF_ARGS (2, 3); |
867 | 4530 Bytecount emacs_vsprintf (Ibyte *output, const CIbyte *format, |
771 | 4531 va_list vargs); |
867 | 4532 Bytecount emacs_sprintf (Ibyte *output, const CIbyte *format, ...) |
771 | 4533 PRINTF_ARGS (2, 3); |
4534 | |
428 | 4535 |
4536 /* Defined in editfns.c */ | |
826 | 4537 EXFUN (Fbobp, 1); |
4538 EXFUN (Fbolp, 1); | |
4539 EXFUN (Fbuffer_substring, 3); | |
4540 EXFUN (Fchar_after, 2); | |
4541 EXFUN (Fchar_to_string, 1); | |
4542 EXFUN (Fdelete_region, 3); | |
4543 EXFUN (Feobp, 1); | |
4544 EXFUN (Feolp, 1); | |
4545 EXFUN (Ffollowing_char, 1); | |
4546 EXFUN (Fformat, MANY); | |
4547 EXFUN (Fgoto_char, 2); | |
4548 EXFUN (Finsert, MANY); | |
4549 EXFUN (Finsert_buffer_substring, 3); | |
4550 EXFUN (Finsert_char, 4); | |
4551 EXFUN (Fnarrow_to_region, 3); | |
4552 EXFUN (Fpoint, 1); | |
4553 EXFUN (Fpoint_marker, 2); | |
4554 EXFUN (Fpoint_max, 1); | |
4555 EXFUN (Fpoint_min, 1); | |
4556 EXFUN (Fpreceding_char, 1); | |
4557 EXFUN (Fsystem_name, 0); | |
4558 EXFUN (Fuser_home_directory, 0); | |
4559 EXFUN (Fuser_login_name, 1); | |
4560 EXFUN (Fwiden, 1); | |
4561 | |
428 | 4562 void uncache_home_directory (void); |
867 | 4563 Ibyte *get_home_directory (void); |
4564 Ibyte *user_login_name (uid_t *); | |
428 | 4565 void buffer_insert1 (struct buffer *, Lisp_Object); |
665 | 4566 Lisp_Object make_string_from_buffer (struct buffer *, Charbpos, Charcount); |
4567 Lisp_Object make_string_from_buffer_no_extents (struct buffer *, Charbpos, Charcount); | |
707 | 4568 Lisp_Object make_time (time_t); |
428 | 4569 Lisp_Object save_excursion_save (void); |
844 | 4570 Lisp_Object save_restriction_save (struct buffer *buf); |
428 | 4571 Lisp_Object save_excursion_restore (Lisp_Object); |
4572 Lisp_Object save_restriction_restore (Lisp_Object); | |
771 | 4573 void widen_buffer (struct buffer *b, int no_clip); |
4574 int beginning_of_line_p (struct buffer *b, Charbpos pt); | |
428 | 4575 |
4576 /* Defined in emacsfns.c */ | |
4577 Lisp_Object save_current_buffer_restore (Lisp_Object); | |
4578 | |
4579 /* Defined in emacs.c */ | |
2268 | 4580 EXFUN_NORETURN (Fkill_emacs, 1); |
826 | 4581 EXFUN (Frunning_temacs_p, 0); |
1123 | 4582 EXFUN (Fforce_debugging_signal, 1); |
826 | 4583 |
428 | 4584 SIGTYPE fatal_error_signal (int); |
2367 | 4585 Lisp_Object make_arg_list (int, Wexttext **); |
4586 void make_argc_argv (Lisp_Object, int *, Wexttext ***); | |
4587 void free_argc_argv (Wexttext **); | |
771 | 4588 Lisp_Object split_external_path (const Extbyte *path); |
867 | 4589 Lisp_Object split_env_path (const CIbyte *evarname, const Ibyte *default_); |
771 | 4590 |
428 | 4591 /* Nonzero means don't do interactive redisplay and don't change tty modes */ |
442 | 4592 extern int noninteractive, noninteractive1; |
2367 | 4593 extern int inhibit_non_essential_conversion_operations; |
428 | 4594 extern int preparing_for_armageddon; |
458 | 4595 extern Fixnum emacs_priority; |
428 | 4596 extern int suppress_early_error_handler_backtrace; |
771 | 4597 void debug_break (void); |
4854 | 4598 int debug_can_access_memory (const void *ptr, Bytecount len); |
2210 | 4599 DECLARE_DOESNT_RETURN (really_abort (void)); |
776 | 4600 void zero_out_command_line_status_vars (void); |
428 | 4601 |
826 | 4602 /* Defined in emodules.c */ |
996 | 4603 #ifdef HAVE_SHLIB |
826 | 4604 EXFUN (Flist_modules, 0); |
4605 EXFUN (Fload_module, 3); | |
996 | 4606 extern int unloading_module; |
4607 #endif | |
826 | 4608 |
428 | 4609 /* Defined in eval.c */ |
1706 | 4610 MODULE_API EXFUN (Fapply, MANY); |
826 | 4611 EXFUN (Fbacktrace, 2); |
4612 EXFUN (Fcommand_execute, 3); | |
4613 EXFUN (Fcommandp, 1); | |
4744
17f7e9191c0b
Rationalise duplicated functionality, #'custom-quote, #'quote-maybe.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4690
diff
changeset
|
4614 EXFUN (Fquote_maybe, 1); |
1706 | 4615 MODULE_API EXFUN (Feval, 1); |
4616 MODULE_API EXFUN (Ffuncall, MANY); | |
826 | 4617 EXFUN (Ffunctionp, 1); |
4618 EXFUN (Finteractive_p, 0); | |
4619 EXFUN (Fprogn, UNEVALLED); | |
1706 | 4620 MODULE_API EXFUN (Fsignal, 2); |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4512
diff
changeset
|
4621 MODULE_API EXFUN_NORETURN (Fthrow, UNEVALLED); |
1706 | 4622 MODULE_API EXFUN (Fcall_with_condition_handler, MANY); |
853 | 4623 EXFUN (Ffunction_max_args, 1); |
4624 EXFUN (Ffunction_min_args, 1); | |
826 | 4625 |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4512
diff
changeset
|
4626 MODULE_API DECLARE_DOESNT_RETURN (throw_or_bomb_out (Lisp_Object, |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4512
diff
changeset
|
4627 Lisp_Object, int, |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4512
diff
changeset
|
4628 Lisp_Object, Lisp_Object)); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4512
diff
changeset
|
4629 |
1632 | 4630 MODULE_API DECLARE_DOESNT_RETURN (signal_error_1 (Lisp_Object, Lisp_Object)); |
563 | 4631 void maybe_signal_error_1 (Lisp_Object, Lisp_Object, Lisp_Object, |
578 | 4632 Error_Behavior); |
563 | 4633 Lisp_Object maybe_signal_continuable_error_1 (Lisp_Object, Lisp_Object, |
578 | 4634 Lisp_Object, Error_Behavior); |
1743 | 4635 MODULE_API DECLARE_DOESNT_RETURN (signal_ferror (Lisp_Object, const CIbyte *, |
4636 ...)) PRINTF_ARGS(2, 3); | |
578 | 4637 void maybe_signal_ferror (Lisp_Object, Lisp_Object, Error_Behavior, |
867 | 4638 const CIbyte *, ...) PRINTF_ARGS (4, 5); |
4639 Lisp_Object signal_continuable_ferror (Lisp_Object, const CIbyte *, ...) | |
442 | 4640 PRINTF_ARGS (2, 3); |
563 | 4641 Lisp_Object maybe_signal_continuable_ferror (Lisp_Object, Lisp_Object, |
578 | 4642 Error_Behavior, |
867 | 4643 const CIbyte *, ...) |
442 | 4644 PRINTF_ARGS (4, 5); |
563 | 4645 |
867 | 4646 Lisp_Object build_error_data (const CIbyte *reason, Lisp_Object frob); |
4647 DECLARE_DOESNT_RETURN (signal_error (Lisp_Object, const CIbyte *, | |
563 | 4648 Lisp_Object)); |
867 | 4649 void maybe_signal_error (Lisp_Object, const CIbyte *, Lisp_Object, |
578 | 4650 Lisp_Object, Error_Behavior); |
867 | 4651 Lisp_Object signal_continuable_error (Lisp_Object, const CIbyte *, |
563 | 4652 Lisp_Object); |
867 | 4653 Lisp_Object maybe_signal_continuable_error (Lisp_Object, const CIbyte *, |
563 | 4654 Lisp_Object, |
578 | 4655 Lisp_Object, Error_Behavior); |
1743 | 4656 DECLARE_DOESNT_RETURN (signal_ferror_with_frob (Lisp_Object, Lisp_Object, |
4657 const CIbyte *, ...)) | |
4658 PRINTF_ARGS(3, 4); | |
563 | 4659 void maybe_signal_ferror_with_frob (Lisp_Object, Lisp_Object, Lisp_Object, |
578 | 4660 Error_Behavior, |
867 | 4661 const CIbyte *, ...) PRINTF_ARGS (5, 6); |
563 | 4662 Lisp_Object signal_continuable_ferror_with_frob (Lisp_Object, Lisp_Object, |
867 | 4663 const CIbyte *, |
563 | 4664 ...) PRINTF_ARGS (3, 4); |
4665 Lisp_Object maybe_signal_continuable_ferror_with_frob (Lisp_Object, | |
4666 Lisp_Object, | |
4667 Lisp_Object, | |
578 | 4668 Error_Behavior, |
867 | 4669 const CIbyte *, ...) |
442 | 4670 PRINTF_ARGS (5, 6); |
867 | 4671 DECLARE_DOESNT_RETURN (signal_error_2 (Lisp_Object, const CIbyte *, |
563 | 4672 Lisp_Object, Lisp_Object)); |
867 | 4673 void maybe_signal_error_2 (Lisp_Object, const CIbyte *, Lisp_Object, |
578 | 4674 Lisp_Object, Lisp_Object, Error_Behavior); |
867 | 4675 Lisp_Object signal_continuable_error_2 (Lisp_Object, const CIbyte *, |
563 | 4676 Lisp_Object, Lisp_Object); |
867 | 4677 Lisp_Object maybe_signal_continuable_error_2 (Lisp_Object, const CIbyte *, |
563 | 4678 Lisp_Object, Lisp_Object, |
4679 Lisp_Object, | |
578 | 4680 Error_Behavior); |
563 | 4681 |
4682 | |
1927 | 4683 MODULE_API DECLARE_DOESNT_RETURN (signal_malformed_list_error (Lisp_Object)); |
4684 MODULE_API DECLARE_DOESNT_RETURN (signal_malformed_property_list_error | |
4685 (Lisp_Object)); | |
4686 MODULE_API DECLARE_DOESNT_RETURN (signal_circular_list_error (Lisp_Object)); | |
4687 MODULE_API DECLARE_DOESNT_RETURN (signal_circular_property_list_error | |
4688 (Lisp_Object)); | |
436 | 4689 |
867 | 4690 DECLARE_DOESNT_RETURN (syntax_error (const CIbyte *reason, |
609 | 4691 Lisp_Object frob)); |
867 | 4692 DECLARE_DOESNT_RETURN (syntax_error_2 (const CIbyte *reason, |
609 | 4693 Lisp_Object frob1, |
442 | 4694 Lisp_Object frob2)); |
867 | 4695 void maybe_syntax_error (const CIbyte *, Lisp_Object, Lisp_Object, |
578 | 4696 Error_Behavior); |
867 | 4697 DECLARE_DOESNT_RETURN (sferror (const CIbyte *reason, Lisp_Object frob)); |
4698 DECLARE_DOESNT_RETURN (sferror_2 (const CIbyte *reason, Lisp_Object frob1, | |
563 | 4699 Lisp_Object frob2)); |
867 | 4700 void maybe_sferror (const CIbyte *, Lisp_Object, Lisp_Object, |
578 | 4701 Error_Behavior); |
1632 | 4702 MODULE_API DECLARE_DOESNT_RETURN (invalid_argument (const CIbyte *reason, |
4703 Lisp_Object frob)); | |
4704 MODULE_API DECLARE_DOESNT_RETURN (invalid_argument_2 (const CIbyte *reason, | |
4705 Lisp_Object frob1, | |
4706 Lisp_Object frob2)); | |
867 | 4707 void maybe_invalid_argument (const CIbyte *, Lisp_Object, Lisp_Object, |
578 | 4708 Error_Behavior); |
1632 | 4709 MODULE_API DECLARE_DOESNT_RETURN (invalid_operation (const CIbyte *reason, |
4710 Lisp_Object frob)); | |
4711 MODULE_API DECLARE_DOESNT_RETURN (invalid_operation_2 (const CIbyte *reason, | |
4712 Lisp_Object frob1, | |
4713 Lisp_Object frob2)); | |
4714 MODULE_API void maybe_invalid_operation (const CIbyte *, Lisp_Object, | |
4715 Lisp_Object, Error_Behavior); | |
867 | 4716 DECLARE_DOESNT_RETURN (invalid_state (const CIbyte *reason, |
563 | 4717 Lisp_Object frob)); |
867 | 4718 DECLARE_DOESNT_RETURN (invalid_state_2 (const CIbyte *reason, |
563 | 4719 Lisp_Object frob1, |
4720 Lisp_Object frob2)); | |
867 | 4721 void maybe_invalid_state (const CIbyte *, Lisp_Object, Lisp_Object, |
609 | 4722 Error_Behavior); |
867 | 4723 DECLARE_DOESNT_RETURN (invalid_change (const CIbyte *reason, |
563 | 4724 Lisp_Object frob)); |
867 | 4725 DECLARE_DOESNT_RETURN (invalid_change_2 (const CIbyte *reason, |
563 | 4726 Lisp_Object frob1, |
4727 Lisp_Object frob2)); | |
867 | 4728 void maybe_invalid_change (const CIbyte *, Lisp_Object, Lisp_Object, |
609 | 4729 Error_Behavior); |
1632 | 4730 MODULE_API DECLARE_DOESNT_RETURN (invalid_constant (const CIbyte *reason, |
4731 Lisp_Object frob)); | |
867 | 4732 DECLARE_DOESNT_RETURN (invalid_constant_2 (const CIbyte *reason, |
563 | 4733 Lisp_Object frob1, |
4734 Lisp_Object frob2)); | |
867 | 4735 void maybe_invalid_constant (const CIbyte *, Lisp_Object, Lisp_Object, |
578 | 4736 Error_Behavior); |
867 | 4737 DECLARE_DOESNT_RETURN (wtaerror (const CIbyte *reason, Lisp_Object frob)); |
1632 | 4738 MODULE_API DECLARE_DOESNT_RETURN (out_of_memory (const CIbyte *reason, |
4739 Lisp_Object frob)); | |
867 | 4740 DECLARE_DOESNT_RETURN (stack_overflow (const CIbyte *reason, |
442 | 4741 Lisp_Object frob)); |
4742 | |
436 | 4743 Lisp_Object signal_void_function_error (Lisp_Object); |
4744 Lisp_Object signal_invalid_function_error (Lisp_Object); | |
4745 Lisp_Object signal_wrong_number_of_arguments_error (Lisp_Object, int); | |
4746 | |
428 | 4747 Lisp_Object run_hook_with_args_in_buffer (struct buffer *, int, Lisp_Object *, |
4748 enum run_hooks_condition); | |
4749 Lisp_Object run_hook_with_args (int, Lisp_Object *, enum run_hooks_condition); | |
4750 void va_run_hook_with_args (Lisp_Object, int, ...); | |
4751 void va_run_hook_with_args_in_buffer (struct buffer *, Lisp_Object, int, ...); | |
4752 Lisp_Object run_hook (Lisp_Object); | |
1706 | 4753 MODULE_API Lisp_Object apply1 (Lisp_Object, Lisp_Object); |
4754 MODULE_API Lisp_Object call0 (Lisp_Object); | |
4755 MODULE_API Lisp_Object call1 (Lisp_Object, Lisp_Object); | |
4756 MODULE_API Lisp_Object call2 (Lisp_Object, Lisp_Object, Lisp_Object); | |
4757 MODULE_API Lisp_Object call3 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4758 Lisp_Object); | |
4759 MODULE_API Lisp_Object call4 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4760 Lisp_Object, Lisp_Object); | |
4761 MODULE_API Lisp_Object call5 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4762 Lisp_Object, Lisp_Object, Lisp_Object); | |
4763 MODULE_API Lisp_Object call6 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4764 Lisp_Object, Lisp_Object, Lisp_Object, | |
4765 Lisp_Object); | |
4766 MODULE_API Lisp_Object call7 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4767 Lisp_Object, Lisp_Object, Lisp_Object, | |
4768 Lisp_Object, Lisp_Object); | |
4769 MODULE_API Lisp_Object call8 (Lisp_Object, Lisp_Object, Lisp_Object, | |
4770 Lisp_Object, Lisp_Object, Lisp_Object, | |
4771 Lisp_Object, Lisp_Object, Lisp_Object); | |
428 | 4772 Lisp_Object call0_in_buffer (struct buffer *, Lisp_Object); |
4773 Lisp_Object call1_in_buffer (struct buffer *, Lisp_Object, Lisp_Object); | |
4774 Lisp_Object call2_in_buffer (struct buffer *, Lisp_Object, Lisp_Object, | |
4775 Lisp_Object); | |
4776 Lisp_Object call3_in_buffer (struct buffer *, Lisp_Object, Lisp_Object, | |
4777 Lisp_Object, Lisp_Object); | |
4778 Lisp_Object call4_in_buffer (struct buffer *, Lisp_Object, Lisp_Object, | |
4779 Lisp_Object, Lisp_Object, Lisp_Object); | |
4780 Lisp_Object call5_in_buffer (struct buffer *, Lisp_Object, Lisp_Object, | |
4781 Lisp_Object, Lisp_Object, Lisp_Object, | |
4782 Lisp_Object); | |
4783 Lisp_Object call6_in_buffer (struct buffer *, Lisp_Object, Lisp_Object, | |
4784 Lisp_Object, Lisp_Object, Lisp_Object, | |
4785 Lisp_Object, Lisp_Object); | |
4786 Lisp_Object eval_in_buffer (struct buffer *, Lisp_Object); | |
853 | 4787 |
4788 struct call_trapping_problems_result | |
4789 { | |
4790 int caught_error, caught_throw; | |
4791 Lisp_Object error_conditions, data; | |
4792 Lisp_Object backtrace; | |
4793 Lisp_Object thrown_tag; | |
4794 Lisp_Object thrown_value; | |
4795 }; | |
4796 | |
4797 #define NO_INHIBIT_ERRORS (1<<0) | |
4798 #define NO_INHIBIT_THROWS (1<<1) | |
4799 #define INTERNAL_INHIBIT_ERRORS (1<<0) | |
4800 #define INTERNAL_INHIBIT_THROWS (1<<1) | |
4801 #define INHIBIT_WARNING_ISSUE (1<<2) | |
4802 #define ISSUE_WARNINGS_AT_DEBUG_LEVEL (1<<3) | |
4803 #define INHIBIT_QUIT (1<<4) | |
4804 #define UNINHIBIT_QUIT (1<<5) | |
4805 #define INHIBIT_GC (1<<6) | |
4806 #define INHIBIT_EXISTING_PERMANENT_DISPLAY_OBJECT_DELETION (1<<7) | |
4807 #define INHIBIT_EXISTING_CODING_SYSTEM_DELETION (1<<8) | |
4808 #define INHIBIT_EXISTING_CHARSET_DELETION (1<<9) | |
4809 #define INHIBIT_PERMANENT_DISPLAY_OBJECT_CREATION (1<<10) | |
4810 #define INHIBIT_CODING_SYSTEM_CREATION (1<<11) | |
4811 #define INHIBIT_CHARSET_CREATION (1<<12) | |
4812 #define INHIBIT_EXISTING_BUFFER_TEXT_MODIFICATION (1<<13) | |
4813 #define INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY (1<<14) | |
4814 #define INHIBIT_ENTERING_DEBUGGER (1<<15) | |
4815 #define CALL_WITH_SUSPENDED_ERRORS (1<<16) | |
1333 | 4816 #define POSTPONE_WARNING_ISSUE (1<<17) |
853 | 4817 |
4818 enum check_allowed_operation | |
4819 { | |
4820 OPERATION_DELETE_OBJECT, | |
4821 OPERATION_CREATE_OBJECT, | |
4822 OPERATION_MODIFY_BUFFER_TEXT, | |
1429 | 4823 OPERATION_MODIFY_OBJECT_PROPERTY |
853 | 4824 }; |
4825 | |
4826 int get_inhibit_flags (void); | |
4827 void check_allowed_operation (int what, Lisp_Object obj, Lisp_Object prop); | |
4828 void note_object_created (Lisp_Object obj); | |
4829 void note_object_deleted (Lisp_Object obj); | |
4830 Lisp_Object call_with_condition_handler (Lisp_Object (*handler) (Lisp_Object, | |
4831 Lisp_Object, | |
4832 Lisp_Object), | |
4833 Lisp_Object handler_arg, | |
4834 Lisp_Object (*fun) (Lisp_Object), | |
4835 Lisp_Object arg); | |
1318 | 4836 int set_trapping_problems_flags (int flags); |
853 | 4837 Lisp_Object call_trapping_problems (Lisp_Object warning_class, |
2367 | 4838 const Ascbyte *warning_string, |
853 | 4839 int flags, |
4840 struct call_trapping_problems_result | |
4841 *problem, | |
4842 Lisp_Object (*fun) (void *), | |
4843 void *arg); | |
4844 Lisp_Object va_call_trapping_problems (Lisp_Object warning_class, | |
2367 | 4845 const Ascbyte *warning_string, |
853 | 4846 int flags, |
4847 struct call_trapping_problems_result | |
4848 *problem, | |
4849 lisp_fn_t fun, int nargs, ...); | |
2367 | 4850 Lisp_Object call0_trapping_problems (const Ascbyte *, Lisp_Object, int); |
4851 Lisp_Object call1_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object, | |
853 | 4852 int); |
2367 | 4853 Lisp_Object call2_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object, |
853 | 4854 Lisp_Object, int); |
2367 | 4855 Lisp_Object call3_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object, |
853 | 4856 Lisp_Object, Lisp_Object, int); |
2367 | 4857 Lisp_Object call4_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object, |
853 | 4858 Lisp_Object, Lisp_Object, Lisp_Object, |
4859 int); | |
2367 | 4860 Lisp_Object call5_trapping_problems (const Ascbyte *, Lisp_Object, Lisp_Object, |
853 | 4861 Lisp_Object, Lisp_Object, Lisp_Object, |
4862 Lisp_Object, int); | |
2367 | 4863 Lisp_Object eval_in_buffer_trapping_problems (const Ascbyte *, struct buffer *, |
853 | 4864 Lisp_Object, int); |
1333 | 4865 Lisp_Object run_hook_trapping_problems (Lisp_Object, Lisp_Object, int); |
4866 Lisp_Object safe_run_hook_trapping_problems (Lisp_Object, Lisp_Object, int); | |
4867 Lisp_Object run_hook_with_args_in_buffer_trapping_problems (Lisp_Object, | |
4868 struct buffer *, | |
4869 int nargs, | |
853 | 4870 Lisp_Object *args, |
4871 enum | |
4872 run_hooks_condition | |
4873 cond, int flags); | |
1333 | 4874 Lisp_Object run_hook_with_args_trapping_problems (Lisp_Object, |
853 | 4875 int nargs, |
4876 Lisp_Object *args, | |
4877 enum run_hooks_condition | |
4878 cond, | |
4879 int flags); | |
1333 | 4880 Lisp_Object va_run_hook_with_args_trapping_problems (Lisp_Object, |
853 | 4881 Lisp_Object hook_var, |
4882 int nargs, ...); | |
1333 | 4883 Lisp_Object va_run_hook_with_args_in_buffer_trapping_problems (Lisp_Object, |
4884 struct buffer *, | |
4885 Lisp_Object, | |
853 | 4886 int nargs, ...); |
4887 Lisp_Object call_with_suspended_errors (lisp_fn_t, Lisp_Object, | |
4888 Lisp_Object, | |
578 | 4889 Error_Behavior, int, ...); |
428 | 4890 /* C Code should be using internal_catch, record_unwind_p, condition_case_1 */ |
1318 | 4891 int proper_redisplay_wrapping_in_place (void); |
428 | 4892 Lisp_Object internal_catch (Lisp_Object, Lisp_Object (*) (Lisp_Object), |
853 | 4893 Lisp_Object, int * volatile, |
2532 | 4894 Lisp_Object * volatile, |
853 | 4895 Lisp_Object * volatile); |
428 | 4896 Lisp_Object condition_case_1 (Lisp_Object, |
4897 Lisp_Object (*) (Lisp_Object), | |
4898 Lisp_Object, | |
4899 Lisp_Object (*) (Lisp_Object, Lisp_Object), | |
4900 Lisp_Object); | |
4901 Lisp_Object condition_case_3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
1632 | 4902 MODULE_API Lisp_Object unbind_to_1 (int, Lisp_Object); |
771 | 4903 #define unbind_to(obj) unbind_to_1 (obj, Qnil) |
428 | 4904 void specbind (Lisp_Object, Lisp_Object); |
1632 | 4905 MODULE_API int record_unwind_protect (Lisp_Object (*) (Lisp_Object), |
4906 Lisp_Object); | |
771 | 4907 int record_unwind_protect_freeing_dynarr (void *ptr); |
1333 | 4908 int record_unwind_protect_restoring_int (int *addr, int val); |
802 | 4909 int internal_bind_int (int *addr, int newval); |
4910 int internal_bind_lisp_object (Lisp_Object *addr, Lisp_Object newval); | |
970 | 4911 void do_autoload (Lisp_Object, Lisp_Object); /* GCPROs both arguments */ |
428 | 4912 Lisp_Object un_autoload (Lisp_Object); |
4913 void warn_when_safe_lispobj (Lisp_Object, Lisp_Object, Lisp_Object); | |
1632 | 4914 MODULE_API void warn_when_safe (Lisp_Object, Lisp_Object, const CIbyte *, |
4915 ...) PRINTF_ARGS (3, 4); | |
1292 | 4916 extern int backtrace_with_internal_sections; |
428 | 4917 |
4841
3465c3161fea
when `debug', abort when lisp error during loadup
Ben Wing <ben@xemacs.org>
parents:
4805
diff
changeset
|
4918 extern Lisp_Object Vdebug_on_error; |
1315 | 4919 extern Lisp_Object Vstack_trace_on_error; |
428 | 4920 |
4921 /* Defined in event-stream.c */ | |
826 | 4922 EXFUN (Faccept_process_output, 3); |
4923 EXFUN (Fadd_timeout, 4); | |
4924 EXFUN (Fdisable_timeout, 1); | |
4925 EXFUN (Fdiscard_input, 0); | |
4926 EXFUN (Fdispatch_event, 1); | |
4927 EXFUN (Fenqueue_eval_event, 2); | |
4928 EXFUN (Fnext_event, 2); | |
4929 EXFUN (Fread_key_sequence, 3); | |
4930 EXFUN (Fsit_for, 2); | |
4931 EXFUN (Fsleep_for, 1); | |
4932 | |
428 | 4933 void wait_delaying_user_input (int (*) (void *), void *); |
1268 | 4934 int detect_input_pending (int how_many); |
428 | 4935 void reset_this_command_keys (Lisp_Object, int); |
4936 Lisp_Object enqueue_misc_user_event (Lisp_Object, Lisp_Object, Lisp_Object); | |
4937 Lisp_Object enqueue_misc_user_event_pos (Lisp_Object, Lisp_Object, | |
4938 Lisp_Object, int, int, int, int); | |
442 | 4939 extern int modifier_keys_are_sticky; |
428 | 4940 |
4941 /* Defined in event-Xt.c */ | |
4942 void signal_special_Xt_user_event (Lisp_Object, Lisp_Object, Lisp_Object); | |
4943 | |
4944 | |
4945 /* Defined in events.c */ | |
826 | 4946 EXFUN (Fcopy_event, 2); |
2862 | 4947 EXFUN (Fevent_to_character, 4); |
826 | 4948 |
428 | 4949 void clear_event_resource (void); |
4950 Lisp_Object allocate_event (void); | |
4951 | |
771 | 4952 EXFUN (Fevent_x_pixel, 1); |
4953 EXFUN (Fevent_y_pixel, 1); | |
4954 | |
4955 | |
4956 /* Defined in file-coding.c */ | |
4957 EXFUN (Fcoding_category_list, 0); | |
4958 EXFUN (Fcoding_category_system, 1); | |
4959 EXFUN (Fcoding_priority_list, 0); | |
4960 EXFUN (Fcoding_system_description, 1); | |
4961 EXFUN (Fcoding_system_documentation, 1); | |
4962 EXFUN (Fcoding_system_list, 1); | |
4963 EXFUN (Fcoding_system_name, 1); | |
4964 EXFUN (Fcoding_system_p, 1); | |
4965 EXFUN (Fcoding_system_property, 2); | |
4966 EXFUN (Fcoding_system_type, 1); | |
4967 EXFUN (Fcopy_coding_system, 2); | |
4968 EXFUN (Fdecode_big5_char, 1); | |
4969 EXFUN (Fdecode_coding_region, 4); | |
4970 EXFUN (Fdecode_shift_jis_char, 1); | |
4971 EXFUN (Fdefine_coding_system_alias, 2); | |
4972 EXFUN (Fdetect_coding_region, 3); | |
4973 EXFUN (Fdefault_encoding_detection_enabled_p, 0); | |
4974 EXFUN (Fencode_big5_char, 1); | |
4975 EXFUN (Fencode_coding_region, 4); | |
4976 EXFUN (Fencode_shift_jis_char, 1); | |
4977 EXFUN (Ffind_coding_system, 1); | |
4978 EXFUN (Fget_coding_system, 1); | |
4690
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4682
diff
changeset
|
4979 EXFUN (Fmake_coding_system_internal, 4); |
771 | 4980 EXFUN (Fset_coding_category_system, 2); |
4981 EXFUN (Fset_coding_priority_list, 1); | |
4982 EXFUN (Fsubsidiary_coding_system, 2); | |
4983 | |
4984 extern Lisp_Object Qshift_jis, Qiso2022, Qbig5, Qccl; | |
4985 extern Lisp_Object Qcharset_g0; | |
4986 extern Lisp_Object Qcharset_g1, Qcharset_g2, Qcharset_g3, Qcoding_system_error; | |
4987 extern Lisp_Object Qcoding_systemp, Qcr, Qcrlf, Qdecode, Qencode; | |
4988 extern Lisp_Object Qeol_cr, Qeol_crlf, Qeol_lf, Qeol_type, Qescape_quoted; | |
4989 extern Lisp_Object Qforce_g0_on_output, Qforce_g1_on_output; | |
4990 extern Lisp_Object Qforce_g2_on_output, Qforce_g3_on_output; | |
4991 extern Lisp_Object Qinput_charset_conversion, Qlf, Qlock_shift; | |
4992 extern Lisp_Object Qmnemonic, Qno_ascii_cntl, Qno_ascii_eol; | |
4993 extern Lisp_Object Qno_conversion, Qraw_text; | |
4994 extern Lisp_Object Qno_iso6429, Qoutput_charset_conversion; | |
4995 extern Lisp_Object Qpost_read_conversion, Qpre_write_conversion, Qseven; | |
4996 extern Lisp_Object Qshort, Vcoding_system_for_read; | |
4997 extern Lisp_Object Vcoding_system_for_write; | |
4998 extern Lisp_Object Vfile_name_coding_system, Vkeyboard_coding_system; | |
4999 extern Lisp_Object Vterminal_coding_system; | |
5000 extern Lisp_Object Qcanonicalize_after_coding; | |
5001 int coding_system_is_for_text_file (Lisp_Object coding_system); | |
5002 Lisp_Object find_coding_system_for_text_file (Lisp_Object name, int eol_wrap); | |
1632 | 5003 MODULE_API Lisp_Object get_coding_system_for_text_file (Lisp_Object name, |
5004 int eol_wrap); | |
771 | 5005 int coding_system_is_binary (Lisp_Object coding_system); |
5006 | |
5007 | |
428 | 5008 /* Defined in fileio.c */ |
826 | 5009 EXFUN (Fdirectory_file_name, 1); |
5010 EXFUN (Fdo_auto_save, 2); | |
5011 EXFUN (Fexpand_file_name, 2); | |
5012 EXFUN (Ffile_accessible_directory_p, 1); | |
5013 EXFUN (Ffile_directory_p, 1); | |
5014 EXFUN (Ffile_executable_p, 1); | |
5015 EXFUN (Ffile_exists_p, 1); | |
5016 EXFUN (Ffile_name_absolute_p, 1); | |
5017 EXFUN (Ffile_name_as_directory, 1); | |
5018 EXFUN (Ffile_name_directory, 1); | |
5019 EXFUN (Ffile_name_nondirectory, 1); | |
5020 EXFUN (Ffile_readable_p, 1); | |
5021 EXFUN (Ffile_symlink_p, 1); | |
5022 EXFUN (Ffile_truename, 2); | |
5023 EXFUN (Ffind_file_name_handler, 2); | |
5024 EXFUN (Finsert_file_contents_internal, 7); | |
5025 EXFUN (Fmake_temp_name, 1); | |
5026 EXFUN (Fsubstitute_in_file_name, 1); | |
5027 EXFUN (Funhandled_file_name_directory, 1); | |
5028 EXFUN (Fverify_visited_file_modtime, 1); | |
5029 | |
428 | 5030 void record_auto_save (void); |
5031 void force_auto_save_soon (void); | |
563 | 5032 DECLARE_DOESNT_RETURN (report_error_with_errno (Lisp_Object errtype, |
867 | 5033 const CIbyte *string, |
563 | 5034 Lisp_Object data)); |
5035 DECLARE_DOESNT_RETURN (report_file_type_error (Lisp_Object errtype, | |
5036 Lisp_Object oserrmess, | |
867 | 5037 const CIbyte *string, |
563 | 5038 Lisp_Object data)); |
867 | 5039 DECLARE_DOESNT_RETURN (report_file_error (const CIbyte *, Lisp_Object)); |
428 | 5040 Lisp_Object lisp_strerror (int); |
5041 Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); | |
5042 int internal_delete_file (Lisp_Object); | |
2526 | 5043 Ibyte *find_end_of_directory_component (const Ibyte *path, |
5044 Bytecount len); | |
428 | 5045 |
5046 /* Defined in filelock.c */ | |
826 | 5047 EXFUN (Funlock_buffer, 0); |
5048 | |
428 | 5049 void lock_file (Lisp_Object); |
5050 void unlock_file (Lisp_Object); | |
5051 void unlock_all_files (void); | |
5052 void unlock_buffer (struct buffer *); | |
5053 | |
5054 /* Defined in floatfns.c */ | |
4678
b5e1d4f6b66f
Make #'floor, #'ceiling, #'round, #'truncate conform to Common Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4677
diff
changeset
|
5055 EXFUN (Ftruncate, 2); |
826 | 5056 |
428 | 5057 double extract_float (Lisp_Object); |
5058 | |
5059 /* Defined in fns.c */ | |
1632 | 5060 MODULE_API EXFUN (Fappend, MANY); |
826 | 5061 EXFUN (Fassoc, 2); |
5062 EXFUN (Fassq, 2); | |
5063 EXFUN (Fcanonicalize_lax_plist, 2); | |
5064 EXFUN (Fcanonicalize_plist, 2); | |
5065 EXFUN (Fcheck_valid_plist, 1); | |
5066 EXFUN (Fconcat, MANY); | |
5067 EXFUN (Fcopy_alist, 1); | |
5068 EXFUN (Fcopy_list, 1); | |
5069 EXFUN (Fcopy_sequence, 1); | |
5070 EXFUN (Fcopy_tree, 2); | |
5071 EXFUN (Fdelete, 2); | |
5072 EXFUN (Fdelq, 2); | |
5073 EXFUN (Fdestructive_alist_to_plist, 1); | |
5074 EXFUN (Felt, 2); | |
1632 | 5075 MODULE_API EXFUN (Fequal, 2); |
5076 MODULE_API EXFUN (Fget, 3); | |
826 | 5077 EXFUN (Flast, 2); |
5078 EXFUN (Flax_plist_get, 3); | |
5079 EXFUN (Flax_plist_remprop, 2); | |
1632 | 5080 MODULE_API EXFUN (Flength, 1); |
4995
8431b52e43b1
Move the various map* functions to C; add #'map-into.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4888
diff
changeset
|
5081 EXFUN (FmapcarX, MANY); |
826 | 5082 EXFUN (Fmember, 2); |
5083 EXFUN (Fmemq, 2); | |
5084 EXFUN (Fnconc, MANY); | |
1632 | 5085 MODULE_API EXFUN (Fnreverse, 1); |
826 | 5086 EXFUN (Fnthcdr, 2); |
5087 EXFUN (Fold_assq, 2); | |
5088 EXFUN (Fold_equal, 2); | |
5089 EXFUN (Fold_member, 2); | |
5090 EXFUN (Fold_memq, 2); | |
5091 EXFUN (Fplist_get, 3); | |
5092 EXFUN (Fplist_member, 2); | |
5093 EXFUN (Fplist_put, 3); | |
1632 | 5094 MODULE_API EXFUN (Fprovide, 1); |
5095 MODULE_API EXFUN (Fput, 3); | |
826 | 5096 EXFUN (Frassq, 2); |
5097 EXFUN (Fremassq, 2); | |
5098 EXFUN (Freplace_list, 2); | |
1632 | 5099 MODULE_API EXFUN (Freverse, 1); |
1268 | 5100 EXFUN (Fsafe_length, 1); |
826 | 5101 EXFUN (Fsort, 2); |
5102 EXFUN (Fstring_equal, 2); | |
5103 EXFUN (Fstring_lessp, 2); | |
5104 EXFUN (Fsubstring, 3); | |
5105 EXFUN (Fvalid_plist_p, 1); | |
5106 | |
428 | 5107 Lisp_Object list_sort (Lisp_Object, Lisp_Object, |
5108 int (*) (Lisp_Object, Lisp_Object, Lisp_Object)); | |
5109 Lisp_Object merge (Lisp_Object, Lisp_Object, Lisp_Object); | |
5110 | |
5111 void bump_string_modiff (Lisp_Object); | |
5112 Lisp_Object memq_no_quit (Lisp_Object, Lisp_Object); | |
5113 Lisp_Object assoc_no_quit (Lisp_Object, Lisp_Object); | |
5114 Lisp_Object assq_no_quit (Lisp_Object, Lisp_Object); | |
5115 Lisp_Object rassq_no_quit (Lisp_Object, Lisp_Object); | |
5116 Lisp_Object delq_no_quit (Lisp_Object, Lisp_Object); | |
5117 Lisp_Object delq_no_quit_and_free_cons (Lisp_Object, Lisp_Object); | |
5118 Lisp_Object remassoc_no_quit (Lisp_Object, Lisp_Object); | |
5119 Lisp_Object remassq_no_quit (Lisp_Object, Lisp_Object); | |
5120 Lisp_Object remrassq_no_quit (Lisp_Object, Lisp_Object); | |
5121 | |
5122 int plists_differ (Lisp_Object, Lisp_Object, int, int, int); | |
5123 Lisp_Object internal_plist_get (Lisp_Object, Lisp_Object); | |
5124 void internal_plist_put (Lisp_Object *, Lisp_Object, Lisp_Object); | |
5125 int internal_remprop (Lisp_Object *, Lisp_Object); | |
5126 Lisp_Object external_plist_get (Lisp_Object *, Lisp_Object, | |
578 | 5127 int, Error_Behavior); |
428 | 5128 void external_plist_put (Lisp_Object *, Lisp_Object, |
578 | 5129 Lisp_Object, int, Error_Behavior); |
5130 int external_remprop (Lisp_Object *, Lisp_Object, int, Error_Behavior); | |
853 | 5131 int internal_equal_trapping_problems (Lisp_Object warning_class, |
2367 | 5132 const Ascbyte *warning_string, |
853 | 5133 int flags, |
5134 struct call_trapping_problems_result *p, | |
5135 int retval, | |
5136 Lisp_Object obj1, Lisp_Object obj2, | |
5137 int depth); | |
428 | 5138 int internal_equal (Lisp_Object, Lisp_Object, int); |
801 | 5139 int internal_equalp (Lisp_Object obj1, Lisp_Object obj2, int depth); |
428 | 5140 Lisp_Object concat2 (Lisp_Object, Lisp_Object); |
5141 Lisp_Object concat3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
5142 Lisp_Object vconcat2 (Lisp_Object, Lisp_Object); | |
5143 Lisp_Object vconcat3 (Lisp_Object, Lisp_Object, Lisp_Object); | |
5144 Lisp_Object nconc2 (Lisp_Object, Lisp_Object); | |
5145 Lisp_Object bytecode_nconc2 (Lisp_Object *); | |
442 | 5146 void check_losing_bytecode (const char *, Lisp_Object); |
428 | 5147 |
771 | 5148 Lisp_Object add_suffix_to_symbol (Lisp_Object symbol, |
2367 | 5149 const Ascbyte *ascii_string); |
5150 Lisp_Object add_prefix_to_symbol (const Ascbyte *ascii_string, | |
771 | 5151 Lisp_Object symbol); |
5152 | |
826 | 5153 /* Defined in free-hook.c */ |
5154 EXFUN (Freally_free, 1); | |
5155 | |
428 | 5156 /* Defined in glyphs.c */ |
826 | 5157 EXFUN (Fmake_glyph_internal, 1); |
5158 | |
578 | 5159 Error_Behavior decode_error_behavior_flag (Lisp_Object); |
5160 Lisp_Object encode_error_behavior_flag (Error_Behavior); | |
428 | 5161 |
563 | 5162 /* Defined in glyphs-shared.c */ |
5163 void shared_resource_validate (Lisp_Object instantiator); | |
5164 Lisp_Object shared_resource_normalize (Lisp_Object inst, | |
5165 Lisp_Object console_type, | |
5166 Lisp_Object dest_mask, | |
5167 Lisp_Object tag); | |
5168 extern Lisp_Object Q_resource_type, Q_resource_id; | |
5169 | |
5170 /* Defined in gui.c */ | |
2367 | 5171 DECLARE_DOESNT_RETURN (gui_error (const Ascbyte *reason, |
563 | 5172 Lisp_Object frob)); |
2367 | 5173 DECLARE_DOESNT_RETURN (gui_error_2 (const Ascbyte *reason, |
569 | 5174 Lisp_Object frob0, Lisp_Object frob1)); |
428 | 5175 /* Defined in indent.c */ |
826 | 5176 EXFUN (Findent_to, 3); |
5177 EXFUN (Fvertical_motion, 3); | |
5178 | |
5179 int byte_spaces_at_point (struct buffer *, Bytebpos); | |
665 | 5180 int column_at_point (struct buffer *, Charbpos, int); |
793 | 5181 int string_column_at_point (Lisp_Object, Charbpos, int); |
428 | 5182 int current_column (struct buffer *); |
5183 void invalidate_current_column (void); | |
665 | 5184 Charbpos vmotion (struct window *, Charbpos, int, int *); |
5185 Charbpos vmotion_pixels (Lisp_Object, Charbpos, int, int, int *); | |
428 | 5186 |
771 | 5187 /* Defined in insdel.c */ |
5188 void set_buffer_point (struct buffer *buf, Charbpos pos, Bytebpos bipos); | |
5189 | |
826 | 5190 /* Defined in intl.c */ |
5191 EXFUN (Fgettext, 1); | |
5192 | |
428 | 5193 /* Defined in keymap.c */ |
826 | 5194 EXFUN (Fdefine_key, 3); |
5195 EXFUN (Fkey_description, 1); | |
5196 EXFUN (Flookup_key, 3); | |
5197 EXFUN (Fmake_sparse_keymap, 1); | |
5198 | |
793 | 5199 void where_is_to_char (Lisp_Object, Eistring *); |
428 | 5200 |
5201 /* Defined in lread.c */ | |
826 | 5202 EXFUN (Fread, 1); |
5203 | |
428 | 5204 void ebolify_bytecode_constants (Lisp_Object); |
5205 void close_load_descs (void); | |
5206 int locate_file (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object *, int); | |
5207 EXFUN (Flocate_file_clear_hashing, 1); | |
442 | 5208 int isfloat_string (const char *); |
1983 | 5209 #ifdef HAVE_RATIO |
5210 int isratio_string (const char *); | |
5211 #endif | |
428 | 5212 |
5213 /* Well, I've decided to enable this. -- ben */ | |
5214 /* And I've decided to make it work right. -- sb */ | |
5215 #define LOADHIST | |
5216 /* Define the following symbol to enable load history of dumped files */ | |
5217 #define LOADHIST_DUMPED | |
5218 /* Define the following symbol to enable load history of C source */ | |
5219 #define LOADHIST_BUILTIN | |
5220 | |
5221 #ifdef LOADHIST /* this is just a stupid idea */ | |
5222 #define LOADHIST_ATTACH(x) \ | |
5223 do { if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); } \ | |
5224 while (0) | |
5225 #else /*! LOADHIST */ | |
5226 # define LOADHIST_ATTACH(x) | |
5227 #endif /*! LOADHIST */ | |
5228 | |
826 | 5229 /* Defined in macros.c */ |
5230 EXFUN (Fexecute_kbd_macro, 2); | |
5231 | |
428 | 5232 /* Defined in marker.c */ |
826 | 5233 EXFUN (Fcopy_marker, 2); |
5234 EXFUN (Fmake_marker, 0); | |
5235 EXFUN (Fmarker_buffer, 1); | |
5236 EXFUN (Fmarker_position, 1); | |
5237 EXFUN (Fset_marker, 3); | |
5238 EXFUN (Fset_marker_insertion_type, 2); | |
5239 | |
5240 Bytebpos byte_marker_position (Lisp_Object); | |
665 | 5241 Charbpos marker_position (Lisp_Object); |
826 | 5242 void set_byte_marker_position (Lisp_Object, Bytebpos); |
665 | 5243 void set_marker_position (Lisp_Object, Charbpos); |
428 | 5244 void unchain_marker (Lisp_Object); |
5245 Lisp_Object noseeum_copy_marker (Lisp_Object, Lisp_Object); | |
5246 Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object); | |
5247 #ifdef MEMORY_USAGE_STATS | |
5248 int compute_buffer_marker_usage (struct buffer *, struct overhead_stats *); | |
5249 #endif | |
771 | 5250 void init_buffer_markers (struct buffer *b); |
5251 void uninit_buffer_markers (struct buffer *b); | |
428 | 5252 |
5253 /* Defined in minibuf.c */ | |
5254 extern int minibuf_level; | |
867 | 5255 Charcount scmp_1 (const Ibyte *, const Ibyte *, Charcount, int); |
428 | 5256 #define scmp(s1, s2, len) scmp_1 (s1, s2, len, completion_ignore_case) |
5257 extern int completion_ignore_case; | |
867 | 5258 int regexp_ignore_completion_p (const Ibyte *, Lisp_Object, |
428 | 5259 Bytecount, Bytecount); |
5260 Lisp_Object clear_echo_area (struct frame *, Lisp_Object, int); | |
5261 Lisp_Object clear_echo_area_from_print (struct frame *, Lisp_Object, int); | |
867 | 5262 void echo_area_append (struct frame *, const Ibyte *, Lisp_Object, |
428 | 5263 Bytecount, Bytecount, Lisp_Object); |
867 | 5264 void echo_area_message (struct frame *, const Ibyte *, Lisp_Object, |
428 | 5265 Bytecount, Bytecount, Lisp_Object); |
5266 Lisp_Object echo_area_status (struct frame *); | |
5267 int echo_area_active (struct frame *); | |
5268 Lisp_Object echo_area_contents (struct frame *); | |
867 | 5269 void message_internal (const Ibyte *, Lisp_Object, Bytecount, Bytecount); |
5270 void message_append_internal (const Ibyte *, Lisp_Object, | |
428 | 5271 Bytecount, Bytecount); |
1632 | 5272 MODULE_API void message (const char *, ...) PRINTF_ARGS (1, 2); |
442 | 5273 void message_append (const char *, ...) PRINTF_ARGS (1, 2); |
5274 void message_no_translate (const char *, ...) PRINTF_ARGS (1, 2); | |
428 | 5275 void clear_message (void); |
5276 | |
771 | 5277 /* Defined in mule-charset.c */ |
826 | 5278 EXFUN (Fmake_charset, 3); |
5279 | |
771 | 5280 extern Lisp_Object Ql2r, Qr2l; |
5281 | |
428 | 5282 /* Defined in print.c */ |
826 | 5283 EXFUN (Fdisplay_error, 2); |
5284 EXFUN (Ferror_message_string, 1); | |
5285 EXFUN (Fprin1, 2); | |
5286 EXFUN (Fprin1_to_string, 2); | |
5287 EXFUN (Fprinc, 2); | |
5288 EXFUN (Fprint, 2); | |
5289 | |
4394
cacc942c0d0f
Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4355
diff
changeset
|
5290 Lisp_Object prin1_to_string (Lisp_Object, int); |
771 | 5291 |
5292 /* Lower-level ways to output data: */ | |
3085 | 5293 void default_object_printer (Lisp_Object, Lisp_Object, int); |
771 | 5294 void print_internal (Lisp_Object, Lisp_Object, int); |
428 | 5295 void debug_print (Lisp_Object); |
1204 | 5296 void debug_p4 (Lisp_Object obj); |
5297 void debug_p3 (Lisp_Object obj); | |
5298 void debug_short_backtrace (int); | |
5299 void debug_backtrace (void); | |
428 | 5300 /* NOTE: Do not call this with the data of a Lisp_String. Use princ. |
5301 * Note: stream should be defaulted before calling | |
5302 * (eg Qnil means stdout, not Vstandard_output, etc) */ | |
1632 | 5303 MODULE_API void write_c_string (Lisp_Object stream, const CIbyte *str); |
771 | 5304 /* Same goes for this function. */ |
1632 | 5305 MODULE_API void write_string (Lisp_Object stream, const Ibyte *str); |
428 | 5306 /* Same goes for this function. */ |
867 | 5307 void write_string_1 (Lisp_Object stream, const Ibyte *str, Bytecount size); |
826 | 5308 void write_eistring (Lisp_Object stream, const Eistring *ei); |
771 | 5309 |
5310 /* Higher-level (printf-style) ways to output data: */ | |
1632 | 5311 MODULE_API void write_fmt_string (Lisp_Object stream, const CIbyte *fmt, ...); |
5312 MODULE_API void write_fmt_string_lisp (Lisp_Object stream, const CIbyte *fmt, | |
5313 int nargs, ...); | |
867 | 5314 void stderr_out (const CIbyte *, ...) PRINTF_ARGS (1, 2); |
5315 void stderr_out_lisp (const CIbyte *, int nargs, ...); | |
5316 void stdout_out (const CIbyte *, ...) PRINTF_ARGS (1, 2); | |
1346 | 5317 void external_out (int dest, const CIbyte *fmt, ...) PRINTF_ARGS (2, 3); |
867 | 5318 void debug_out (const CIbyte *, ...) PRINTF_ARGS (1, 2); |
1743 | 5319 DECLARE_DOESNT_RETURN (fatal (const CIbyte *, ...)) PRINTF_ARGS(1, 2); |
771 | 5320 |
5321 /* Internal functions: */ | |
1261 | 5322 Lisp_Object canonicalize_printcharfun (Lisp_Object printcharfun); |
771 | 5323 void temp_output_buffer_setup (Lisp_Object); |
5324 void temp_output_buffer_show (Lisp_Object, Lisp_Object); | |
428 | 5325 void print_cons (Lisp_Object, Lisp_Object, int); |
5326 void print_vector (Lisp_Object, Lisp_Object, int); | |
5327 void print_string (Lisp_Object, Lisp_Object, int); | |
771 | 5328 void print_symbol (Lisp_Object, Lisp_Object, int); |
5329 void print_float (Lisp_Object, Lisp_Object, int); | |
603 | 5330 /* The number of bytes required to store the decimal printed |
5331 representation of an integral type. Add a few bytes for truncation, | |
5332 optional sign prefix, and null byte terminator. | |
614 | 5333 2.40824 == log (256) / log (10). |
5334 | |
5335 We don't use floating point since Sun cc (buggily?) cannot use | |
5336 floating point computations to define a compile-time integral | |
5337 constant. */ | |
603 | 5338 #define DECIMAL_PRINT_SIZE(integral_type) \ |
614 | 5339 (((2410824 * sizeof (integral_type)) / 1000000) + 3) |
577 | 5340 void long_to_string (char *, long); |
4329
d9eb5ea14f65
Provide %b in #'format; use it for converting between ints and bit vectors.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4134
diff
changeset
|
5341 void ulong_to_bit_string (char *, unsigned long); |
428 | 5342 extern int print_escape_newlines; |
1632 | 5343 extern MODULE_API int print_readably; |
4880
ae81a2c00f4f
try harder to avoid crashing when debug-printing
Ben Wing <ben@xemacs.org>
parents:
4854
diff
changeset
|
5344 extern int in_debug_print; |
428 | 5345 Lisp_Object internal_with_output_to_temp_buffer (Lisp_Object, |
5346 Lisp_Object (*) (Lisp_Object), | |
5347 Lisp_Object, Lisp_Object); | |
5348 void float_to_string (char *, double); | |
5349 void internal_object_printer (Lisp_Object, Lisp_Object, int); | |
4846 | 5350 MODULE_API DECLARE_DOESNT_RETURN (printing_unreadable_object (const CIbyte *, |
5351 ...)) | |
5352 PRINTF_ARGS (1, 2); | |
5353 DECLARE_DOESNT_RETURN (printing_unreadable_lcrecord (Lisp_Object obj, | |
5354 const Ibyte *name)); | |
428 | 5355 |
5356 /* Defined in rangetab.c */ | |
826 | 5357 EXFUN (Fclear_range_table, 1); |
5358 EXFUN (Fget_range_table, 3); | |
2421 | 5359 EXFUN (Fmake_range_table, 1); |
826 | 5360 EXFUN (Fput_range_table, 4); |
4690
257b468bf2ca
Move the #'query-coding-region implementation to C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4682
diff
changeset
|
5361 EXFUN (Fcopy_range_table, 1); |
826 | 5362 |
2421 | 5363 extern Lisp_Object Qstart_closed_end_open; |
5364 extern Lisp_Object Qstart_open_end_open; | |
5365 extern Lisp_Object Qstart_closed_end_closed; | |
5366 extern Lisp_Object Qstart_open_end_closed; | |
5367 | |
428 | 5368 void put_range_table (Lisp_Object, EMACS_INT, EMACS_INT, Lisp_Object); |
5369 int unified_range_table_bytes_needed (Lisp_Object); | |
5370 int unified_range_table_bytes_used (void *); | |
5371 void unified_range_table_copy_data (Lisp_Object, void *); | |
5372 Lisp_Object unified_range_table_lookup (void *, EMACS_INT, Lisp_Object); | |
5373 int unified_range_table_nentries (void *); | |
5374 void unified_range_table_get_range (void *, int, EMACS_INT *, EMACS_INT *, | |
5375 Lisp_Object *); | |
5376 | |
5377 /* Defined in search.c */ | |
826 | 5378 EXFUN (Fmatch_beginning, 1); |
5379 EXFUN (Fmatch_end, 1); | |
5380 EXFUN (Fskip_chars_backward, 3); | |
5381 EXFUN (Fskip_chars_forward, 3); | |
5382 EXFUN (Fstring_match, 4); | |
5383 | |
428 | 5384 struct re_pattern_buffer; |
5385 struct re_registers; | |
867 | 5386 Charbpos scan_buffer (struct buffer *, Ichar, Charbpos, Charbpos, EMACS_INT, |
826 | 5387 EMACS_INT *, int); |
665 | 5388 Charbpos find_next_newline (struct buffer *, Charbpos, int); |
5389 Charbpos find_next_newline_no_quit (struct buffer *, Charbpos, int); | |
826 | 5390 Bytebpos byte_find_next_newline_no_quit (struct buffer *, Bytebpos, int); |
867 | 5391 Bytecount byte_find_next_ichar_in_string (Lisp_Object, Ichar, Bytecount, |
826 | 5392 EMACS_INT); |
665 | 5393 Charbpos find_before_next_newline (struct buffer *, Charbpos, Charbpos, int); |
826 | 5394 struct re_pattern_buffer *compile_pattern (Lisp_Object pattern, |
5395 struct re_registers *regp, | |
5396 Lisp_Object translate, | |
5397 Lisp_Object searchobj, | |
5398 struct buffer *searchbuf, | |
5399 int posix, Error_Behavior errb); | |
867 | 5400 Bytecount fast_string_match (Lisp_Object, const Ibyte *, |
428 | 5401 Lisp_Object, Bytecount, |
578 | 5402 Bytecount, int, Error_Behavior, int); |
428 | 5403 Bytecount fast_lisp_string_match (Lisp_Object, Lisp_Object); |
507 | 5404 extern Fixnum warn_about_possibly_incompatible_back_references; |
502 | 5405 |
428 | 5406 |
5407 /* Defined in signal.c */ | |
5408 void init_interrupts_late (void); | |
5409 | |
5410 /* Defined in sound.c */ | |
826 | 5411 EXFUN (Fding, 3); |
5412 | |
428 | 5413 void init_device_sound (struct device *); |
2367 | 5414 DECLARE_DOESNT_RETURN (report_sound_error (const Ascbyte *, Lisp_Object)); |
428 | 5415 |
5416 /* Defined in specifier.c */ | |
826 | 5417 EXFUN (Fadd_spec_to_specifier, 5); |
5418 EXFUN (Fspecifier_spec_list, 4); | |
5419 | |
428 | 5420 Lisp_Object specifier_instance (Lisp_Object, Lisp_Object, Lisp_Object, |
578 | 5421 Error_Behavior, int, int, Lisp_Object); |
428 | 5422 Lisp_Object specifier_instance_no_quit (Lisp_Object, Lisp_Object, Lisp_Object, |
578 | 5423 Error_Behavior, int, Lisp_Object); |
428 | 5424 |
5425 /* Defined in symbols.c */ | |
826 | 5426 EXFUN (Fboundp, 1); |
5427 EXFUN (Fbuilt_in_variable_type, 1); | |
5428 EXFUN (Fdefault_boundp, 1); | |
5429 EXFUN (Fdefault_value, 1); | |
5430 EXFUN (Ffboundp, 1); | |
5431 EXFUN (Ffset, 2); | |
5432 EXFUN (Fintern, 2); | |
4355
a2af1ff1761f
Provide a DEFAULT argument in #'intern-soft.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4329
diff
changeset
|
5433 EXFUN (Fintern_soft, 3); |
826 | 5434 EXFUN (Fkill_local_variable, 1); |
5435 EXFUN (Fset, 2); | |
5436 EXFUN (Fset_default, 2); | |
5437 EXFUN (Fsymbol_function, 1); | |
5438 EXFUN (Fsymbol_name, 1); | |
5439 EXFUN (Fsymbol_plist, 1); | |
5440 EXFUN (Fsymbol_value, 1); | |
5441 | |
867 | 5442 unsigned int hash_string (const Ibyte *, Bytecount); |
5443 Lisp_Object intern_int (const Ibyte *str); | |
1632 | 5444 MODULE_API Lisp_Object intern (const CIbyte *str); |
867 | 5445 Lisp_Object intern_converting_underscores_to_dashes (const CIbyte *str); |
5446 Lisp_Object oblookup (Lisp_Object, const Ibyte *, Bytecount); | |
428 | 5447 void map_obarray (Lisp_Object, int (*) (Lisp_Object, void *), void *); |
5448 Lisp_Object indirect_function (Lisp_Object, int); | |
5449 Lisp_Object symbol_value_in_buffer (Lisp_Object, Lisp_Object); | |
5450 void kill_buffer_local_variables (struct buffer *); | |
5451 int symbol_value_buffer_local_info (Lisp_Object, struct buffer *); | |
5452 Lisp_Object find_symbol_value (Lisp_Object); | |
5453 Lisp_Object find_symbol_value_quickly (Lisp_Object, int); | |
5454 Lisp_Object top_level_value (Lisp_Object); | |
5455 void reject_constant_symbols (Lisp_Object sym, Lisp_Object newval, | |
5456 int function_p, | |
5457 Lisp_Object follow_past_lisp_magic); | |
5458 | |
5459 /* Defined in syntax.c */ | |
665 | 5460 Charbpos scan_words (struct buffer *, Charbpos, int); |
826 | 5461 EXFUN (Fchar_syntax, 2); |
5462 EXFUN (Fforward_word, 2); | |
5463 extern Lisp_Object Vstandard_syntax_table; | |
3250 | 5464 void signal_syntax_cache_extent_changed (EXTENT extent); |
5465 void signal_syntax_cache_extent_adjust (struct buffer *buf); | |
826 | 5466 void init_buffer_syntax_cache (struct buffer *buf); |
5467 void mark_buffer_syntax_cache (struct buffer *buf); | |
5468 void uninit_buffer_syntax_cache (struct buffer *buf); | |
5469 extern Lisp_Object Qsyntax_table; | |
428 | 5470 |
771 | 5471 /* Defined in sysdep.c */ |
5472 long get_random (void); | |
5473 void seed_random (long arg); | |
5474 | |
5475 /* Defined in text.c */ | |
867 | 5476 void find_charsets_in_ibyte_string (unsigned char *charsets, |
5477 const Ibyte *str, | |
771 | 5478 Bytecount len); |
867 | 5479 void find_charsets_in_ichar_string (unsigned char *charsets, |
5480 const Ichar *str, | |
771 | 5481 Charcount len); |
867 | 5482 int ibyte_string_displayed_columns (const Ibyte *str, Bytecount len); |
5483 int ichar_string_displayed_columns (const Ichar *str, Charcount len); | |
5484 Charcount ibyte_string_nonascii_chars (const Ibyte *str, Bytecount len); | |
5485 void convert_ibyte_string_into_ichar_dynarr (const Ibyte *str, | |
771 | 5486 Bytecount len, |
867 | 5487 Ichar_dynarr *dyn); |
5488 Charcount convert_ibyte_string_into_ichar_string (const Ibyte *str, | |
771 | 5489 Bytecount len, |
867 | 5490 Ichar *arr); |
5491 void convert_ichar_string_into_ibyte_dynarr (Ichar *arr, int nels, | |
5492 Ibyte_dynarr *dyn); | |
5493 Ibyte *convert_ichar_string_into_malloced_string (Ichar *arr, int nels, | |
771 | 5494 Bytecount *len_out); |
867 | 5495 Bytecount copy_text_between_formats (const Ibyte *src, Bytecount srclen, |
826 | 5496 Internal_Format srcfmt, |
5497 Lisp_Object srcobj, | |
867 | 5498 Ibyte *dst, Bytecount dstlen, |
826 | 5499 Internal_Format dstfmt, |
5500 Lisp_Object dstobj, | |
5501 Bytecount *src_used); | |
5502 Bytecount copy_buffer_text_out (struct buffer *buf, Bytebpos pos, | |
867 | 5503 Bytecount len, Ibyte *dst, Bytecount dstlen, |
826 | 5504 Internal_Format dstfmt, Lisp_Object dstobj, |
5505 Bytecount *src_used); | |
771 | 5506 |
5507 /* flags for get_buffer_pos_char(), get_buffer_range_char(), etc. */ | |
5508 /* At most one of GB_COERCE_RANGE and GB_NO_ERROR_IF_BAD should be | |
5509 specified. At most one of GB_NEGATIVE_FROM_END and GB_NO_ERROR_IF_BAD | |
5510 should be specified. */ | |
5511 | |
5512 #define GB_ALLOW_PAST_ACCESSIBLE (1 << 0) | |
5513 #define GB_ALLOW_NIL (1 << 1) | |
5514 #define GB_CHECK_ORDER (1 << 2) | |
5515 #define GB_COERCE_RANGE (1 << 3) | |
5516 #define GB_NO_ERROR_IF_BAD (1 << 4) | |
5517 #define GB_NEGATIVE_FROM_END (1 << 5) | |
5518 #define GB_HISTORICAL_STRING_BEHAVIOR (GB_NEGATIVE_FROM_END | GB_ALLOW_NIL) | |
5519 | |
5520 Charbpos get_buffer_pos_char (struct buffer *b, Lisp_Object pos, | |
5521 unsigned int flags); | |
5522 Bytebpos get_buffer_pos_byte (struct buffer *b, Lisp_Object pos, | |
5523 unsigned int flags); | |
5524 void get_buffer_range_char (struct buffer *b, Lisp_Object from, Lisp_Object to, | |
5525 Charbpos *from_out, Charbpos *to_out, | |
5526 unsigned int flags); | |
5527 void get_buffer_range_byte (struct buffer *b, Lisp_Object from, Lisp_Object to, | |
5528 Bytebpos *from_out, Bytebpos *to_out, | |
5529 unsigned int flags); | |
5530 Charcount get_string_pos_char (Lisp_Object string, Lisp_Object pos, | |
5531 unsigned int flags); | |
5532 Bytecount get_string_pos_byte (Lisp_Object string, Lisp_Object pos, | |
5533 unsigned int flags); | |
5534 void get_string_range_char (Lisp_Object string, Lisp_Object from, | |
5535 Lisp_Object to, Charcount *from_out, | |
5536 Charcount *to_out, unsigned int flags); | |
5537 void get_string_range_byte (Lisp_Object string, Lisp_Object from, | |
5538 Lisp_Object to, Bytecount *from_out, | |
5539 Bytecount *to_out, unsigned int flags); | |
826 | 5540 Charxpos get_buffer_or_string_pos_char (Lisp_Object object, Lisp_Object pos, |
5541 unsigned int flags); | |
5542 Bytexpos get_buffer_or_string_pos_byte (Lisp_Object object, Lisp_Object pos, | |
5543 unsigned int flags); | |
771 | 5544 void get_buffer_or_string_range_char (Lisp_Object object, Lisp_Object from, |
826 | 5545 Lisp_Object to, Charxpos *from_out, |
5546 Charxpos *to_out, unsigned int flags); | |
771 | 5547 void get_buffer_or_string_range_byte (Lisp_Object object, Lisp_Object from, |
826 | 5548 Lisp_Object to, Bytexpos *from_out, |
5549 Bytexpos *to_out, unsigned int flags); | |
5550 Charxpos buffer_or_string_accessible_begin_char (Lisp_Object object); | |
5551 Charxpos buffer_or_string_accessible_end_char (Lisp_Object object); | |
5552 Bytexpos buffer_or_string_accessible_begin_byte (Lisp_Object object); | |
5553 Bytexpos buffer_or_string_accessible_end_byte (Lisp_Object object); | |
5554 Charxpos buffer_or_string_absolute_begin_char (Lisp_Object object); | |
5555 Charxpos buffer_or_string_absolute_end_char (Lisp_Object object); | |
5556 Bytexpos buffer_or_string_absolute_begin_byte (Lisp_Object object); | |
5557 Bytexpos buffer_or_string_absolute_end_byte (Lisp_Object object); | |
5558 Charbpos charbpos_clip_to_bounds (Charbpos lower, Charbpos num, | |
5559 Charbpos upper); | |
5560 Bytebpos bytebpos_clip_to_bounds (Bytebpos lower, Bytebpos num, | |
5561 Bytebpos upper); | |
5562 Charxpos charxpos_clip_to_bounds (Charxpos lower, Charxpos num, | |
5563 Charxpos upper); | |
5564 Bytexpos bytexpos_clip_to_bounds (Bytexpos lower, Bytexpos num, | |
5565 Bytexpos upper); | |
5566 Charxpos buffer_or_string_clip_to_accessible_char (Lisp_Object object, | |
5567 Charxpos pos); | |
5568 Bytexpos buffer_or_string_clip_to_accessible_byte (Lisp_Object object, | |
5569 Bytexpos pos); | |
5570 Charxpos buffer_or_string_clip_to_absolute_char (Lisp_Object object, | |
5571 Charxpos pos); | |
5572 Bytexpos buffer_or_string_clip_to_absolute_byte (Lisp_Object object, | |
5573 Bytexpos pos); | |
5574 | |
771 | 5575 |
5576 #ifdef ENABLE_COMPOSITE_CHARS | |
5577 | |
867 | 5578 Ichar lookup_composite_char (Ibyte *str, int len); |
5579 Lisp_Object composite_char_string (Ichar ch); | |
771 | 5580 #endif /* ENABLE_COMPOSITE_CHARS */ |
5581 | |
5582 EXFUN (Ffind_charset, 1); | |
5583 EXFUN (Fget_charset, 1); | |
5584 EXFUN (Fcharset_list, 0); | |
5585 | |
5586 extern Lisp_Object Vcharset_ascii; | |
5587 extern Lisp_Object Vcharset_control_1; | |
5588 extern Lisp_Object Vcharset_latin_iso8859_1; | |
5589 extern Lisp_Object Vcharset_latin_iso8859_2; | |
5590 extern Lisp_Object Vcharset_latin_iso8859_3; | |
5591 extern Lisp_Object Vcharset_latin_iso8859_4; | |
5592 extern Lisp_Object Vcharset_thai_tis620; | |
5593 extern Lisp_Object Vcharset_greek_iso8859_7; | |
4805
980575c76541
Move the arabic-iso8859-6 character set back to C, otherwise X11 lookup fails.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4744
diff
changeset
|
5594 extern Lisp_Object Vcharset_arabic_iso8859_6; |
771 | 5595 extern Lisp_Object Vcharset_hebrew_iso8859_8; |
5596 extern Lisp_Object Vcharset_katakana_jisx0201; | |
5597 extern Lisp_Object Vcharset_latin_jisx0201; | |
5598 extern Lisp_Object Vcharset_cyrillic_iso8859_5; | |
5599 extern Lisp_Object Vcharset_latin_iso8859_9; | |
3094 | 5600 extern Lisp_Object Vcharset_latin_iso8859_15; |
771 | 5601 extern Lisp_Object Vcharset_japanese_jisx0208_1978; |
5602 extern Lisp_Object Vcharset_chinese_gb2312; | |
5603 extern Lisp_Object Vcharset_japanese_jisx0208; | |
5604 extern Lisp_Object Vcharset_korean_ksc5601; | |
5605 extern Lisp_Object Vcharset_japanese_jisx0212; | |
5606 extern Lisp_Object Vcharset_chinese_cns11643_1; | |
5607 extern Lisp_Object Vcharset_chinese_cns11643_2; | |
5608 extern Lisp_Object Vcharset_chinese_big5_1; | |
5609 extern Lisp_Object Vcharset_chinese_big5_2; | |
5610 extern Lisp_Object Vcharset_composite; | |
5611 | |
867 | 5612 Ichar Lstream_get_ichar_1 (Lstream *stream, int first_char); |
5613 int Lstream_fput_ichar (Lstream *stream, Ichar ch); | |
5614 void Lstream_funget_ichar (Lstream *stream, Ichar ch); | |
5615 | |
5616 DECLARE_INLINE_HEADER (Ibyte *qxestrdup (const Ibyte *s)) | |
771 | 5617 { |
2367 | 5618 return (Ibyte *) xstrdup ((const Chbyte *) s); |
771 | 5619 } |
5620 | |
867 | 5621 DECLARE_INLINE_HEADER (Bytecount qxestrlen (const Ibyte *s)) |
771 | 5622 { |
2367 | 5623 return strlen ((const Chbyte *) s); |
771 | 5624 } |
5625 | |
867 | 5626 DECLARE_INLINE_HEADER (Charcount qxestrcharlen (const Ibyte *s)) |
771 | 5627 { |
5628 return bytecount_to_charcount (s, qxestrlen (s)); | |
5629 } | |
5630 | |
867 | 5631 DECLARE_INLINE_HEADER (int qxestrcmp (const Ibyte *s1, |
5632 const Ibyte *s2)) | |
771 | 5633 { |
2367 | 5634 return strcmp ((const Chbyte *) s1, (const Chbyte *) s2); |
771 | 5635 } |
5636 | |
2367 | 5637 DECLARE_INLINE_HEADER (int qxestrcmp_ascii (const Ibyte *s1, |
5638 const Ascbyte *s2)) | |
771 | 5639 { |
2367 | 5640 return strcmp ((const Chbyte *) s1, s2); |
771 | 5641 } |
5642 | |
867 | 5643 DECLARE_INLINE_HEADER (int qxestrncmp (const Ibyte *string1, |
5644 const Ibyte *string2, | |
771 | 5645 Bytecount count)) |
5646 { | |
2367 | 5647 return strncmp ((const Chbyte *) string1, (const Chbyte *) string2, |
771 | 5648 (size_t) count); |
5649 } | |
5650 | |
2367 | 5651 DECLARE_INLINE_HEADER (int qxestrncmp_ascii (const Ibyte *string1, |
5652 const Ascbyte *string2, | |
5653 Bytecount count)) | |
771 | 5654 { |
2367 | 5655 return strncmp ((const Chbyte *) string1, string2, (size_t) count); |
771 | 5656 } |
5657 | |
867 | 5658 DECLARE_INLINE_HEADER (Ibyte *qxestrcpy (Ibyte *strDest, |
2367 | 5659 const Ibyte *strSource)) |
771 | 5660 { |
2367 | 5661 return (Ibyte *) strcpy ((Chbyte *) strDest, (const Chbyte *) strSource); |
771 | 5662 } |
5663 | |
2367 | 5664 DECLARE_INLINE_HEADER (Ibyte *qxestrcpy_ascii (Ibyte *strDest, |
5665 const Ascbyte *strSource)) | |
771 | 5666 { |
2367 | 5667 return (Ibyte *) strcpy ((Chbyte *) strDest, strSource); |
771 | 5668 } |
5669 | |
867 | 5670 DECLARE_INLINE_HEADER (Ibyte *qxestrncpy (Ibyte *strDest, |
2367 | 5671 const Ibyte *strSource, |
5672 Bytecount count)) | |
771 | 5673 { |
2367 | 5674 return (Ibyte *) strncpy ((Chbyte *) strDest, (const Chbyte *) strSource, |
771 | 5675 (size_t) count); |
5676 } | |
5677 | |
2367 | 5678 DECLARE_INLINE_HEADER (Ibyte *qxestrncpy_ascii (Ibyte *strDest, |
5679 const Ascbyte *strSource, | |
5680 Bytecount count)) | |
771 | 5681 { |
2367 | 5682 return (Ibyte *) strncpy ((Chbyte *) strDest, strSource, (size_t) count); |
771 | 5683 } |
5684 | |
867 | 5685 DECLARE_INLINE_HEADER (Ibyte *qxestrcat (Ibyte *strDest, |
2367 | 5686 const Ibyte *strSource)) |
771 | 5687 { |
2367 | 5688 return (Ibyte *) strcat ((Chbyte *) strDest, (const Chbyte *) strSource); |
771 | 5689 } |
5690 | |
2367 | 5691 DECLARE_INLINE_HEADER (Ibyte *qxestrcat_ascii (Ibyte *strDest, |
5692 const Ascbyte *strSource)) | |
771 | 5693 { |
2367 | 5694 return (Ibyte *) strcat ((Chbyte *) strDest, strSource); |
771 | 5695 } |
5696 | |
867 | 5697 DECLARE_INLINE_HEADER (Ibyte *qxestrncat (Ibyte *strDest, |
2367 | 5698 const Ibyte *strSource, |
5699 Bytecount count)) | |
771 | 5700 { |
2367 | 5701 return (Ibyte *) strncat ((Chbyte *) strDest, (const Chbyte *) strSource, |
771 | 5702 (size_t) count); |
5703 } | |
5704 | |
2367 | 5705 DECLARE_INLINE_HEADER (Ibyte *qxestrncat_ascii (Ibyte *strDest, |
5706 const Ascbyte *strSource, | |
5707 Bytecount count)) | |
771 | 5708 { |
2367 | 5709 return (Ibyte *) strncat ((Chbyte *) strDest, strSource, (size_t) count); |
771 | 5710 } |
5711 | |
867 | 5712 DECLARE_INLINE_HEADER (Ibyte *qxestrchr (const Ibyte *s, Ichar c)) |
771 | 5713 { |
5714 assert (c >= 0 && c <= 255); | |
2367 | 5715 return (Ibyte *) strchr ((const Chbyte *) s, c); |
771 | 5716 } |
5717 | |
867 | 5718 DECLARE_INLINE_HEADER (Ibyte *qxestrrchr (const Ibyte *s, Ichar c)) |
771 | 5719 { |
5720 assert (c >= 0 && c <= 255); | |
2367 | 5721 return (Ibyte *) strrchr ((const Chbyte *) s, c); |
771 | 5722 } |
5723 | |
867 | 5724 DECLARE_INLINE_HEADER (Ibyte *qxestrstr (const Ibyte *string1, |
2367 | 5725 const Ibyte *string2)) |
771 | 5726 { |
2367 | 5727 return (Ibyte *) strstr ((const Chbyte *) string1, (const Chbyte *) string2); |
771 | 5728 } |
5729 | |
867 | 5730 DECLARE_INLINE_HEADER (Bytecount qxestrcspn (const Ibyte *string, |
5731 const CIbyte *strCharSet)) | |
771 | 5732 { |
2367 | 5733 return (Bytecount) strcspn ((const Chbyte *) string, strCharSet); |
771 | 5734 } |
5735 | |
867 | 5736 DECLARE_INLINE_HEADER (Bytecount qxestrspn (const Ibyte *string, |
5737 const CIbyte *strCharSet)) | |
771 | 5738 { |
2367 | 5739 return (Bytecount) strspn ((const Chbyte *) string, strCharSet); |
771 | 5740 } |
5741 | |
867 | 5742 DECLARE_INLINE_HEADER (Ibyte *qxestrpbrk (const Ibyte *string, |
2367 | 5743 const CIbyte *strCharSet)) |
771 | 5744 { |
2367 | 5745 return (Ibyte *) strpbrk ((const Chbyte *) string, strCharSet); |
771 | 5746 } |
5747 | |
867 | 5748 DECLARE_INLINE_HEADER (Ibyte *qxestrtok (Ibyte *strToken, |
2367 | 5749 const CIbyte *strDelimit)) |
771 | 5750 { |
2367 | 5751 return (Ibyte *) strtok ((Chbyte *) strToken, strDelimit); |
771 | 5752 } |
5753 | |
867 | 5754 DECLARE_INLINE_HEADER (double qxestrtod (const Ibyte *nptr, |
5755 Ibyte **endptr)) | |
771 | 5756 { |
2367 | 5757 return strtod ((const Chbyte *) nptr, (Chbyte **) endptr); |
771 | 5758 } |
5759 | |
867 | 5760 DECLARE_INLINE_HEADER (long qxestrtol (const Ibyte *nptr, Ibyte **endptr, |
771 | 5761 int base)) |
5762 { | |
2367 | 5763 return strtol ((const Chbyte *) nptr, (Chbyte **) endptr, base); |
771 | 5764 } |
5765 | |
867 | 5766 DECLARE_INLINE_HEADER (unsigned long qxestrtoul (const Ibyte *nptr, |
5767 Ibyte **endptr, | |
771 | 5768 int base)) |
5769 { | |
2367 | 5770 return strtoul ((const Chbyte *) nptr, (Chbyte **) endptr, base); |
771 | 5771 } |
5772 | |
867 | 5773 DECLARE_INLINE_HEADER (int qxeatoi (const Ibyte *string)) |
771 | 5774 { |
2367 | 5775 return atoi ((const Chbyte *) string); |
771 | 5776 } |
5777 | |
1204 | 5778 DECLARE_INLINE_HEADER (Ibyte *qxestrupr (Ibyte *s)) |
5779 { | |
2367 | 5780 return (Ibyte *) strupr ((Chbyte *) s); |
1204 | 5781 } |
5782 | |
5783 DECLARE_INLINE_HEADER (Ibyte *qxestrlwr (Ibyte *s)) | |
5784 { | |
2367 | 5785 return (Ibyte *) strlwr ((Chbyte *) s); |
1204 | 5786 } |
5787 | |
867 | 5788 int qxesprintf (Ibyte *buffer, const CIbyte *format, ...) |
771 | 5789 PRINTF_ARGS (2, 3); |
5790 | |
2367 | 5791 DECLARE_INLINE_HEADER (int qxesscanf_ascii_1 (Ibyte *buffer, |
5792 const Ascbyte *format, | |
5793 void *ptr)) | |
5794 { | |
5795 /* #### DAMNIT! No vsscanf! */ | |
5796 return sscanf ((Chbyte *) buffer, format, ptr); | |
5797 } | |
5798 | |
771 | 5799 /* Do not use POSIX locale routines. Not Mule-correct. */ |
5800 #define qxestrcoll DO NOT USE. | |
5801 #define qxestrxfrm DO NOT USE. | |
5802 | |
867 | 5803 int qxestrcasecmp (const Ibyte *s1, const Ibyte *s2); |
2367 | 5804 int qxestrcasecmp_ascii (const Ibyte *s1, const Ascbyte *s2); |
867 | 5805 int qxestrcasecmp_i18n (const Ibyte *s1, const Ibyte *s2); |
2367 | 5806 int ascii_strcasecmp (const Ascbyte *s1, const Ascbyte *s2); |
771 | 5807 int lisp_strcasecmp (Lisp_Object s1, Lisp_Object s2); |
5808 int lisp_strcasecmp_i18n (Lisp_Object s1, Lisp_Object s2); | |
867 | 5809 int qxestrncasecmp (const Ibyte *s1, const Ibyte *s2, Bytecount len); |
2367 | 5810 int qxestrncasecmp_ascii (const Ibyte *s1, const Ascbyte *s2, |
5811 Bytecount len); | |
867 | 5812 int qxestrncasecmp_i18n (const Ibyte *s1, const Ibyte *s2, Bytecount len); |
2367 | 5813 int ascii_strncasecmp (const Ascbyte *s1, const Ascbyte *s2, |
771 | 5814 Bytecount len); |
867 | 5815 int qxememcmp (const Ibyte *s1, const Ibyte *s2, Bytecount len); |
5816 int qxememcmp4 (const Ibyte *s1, Bytecount len1, | |
5817 const Ibyte *s2, Bytecount len2); | |
5818 int qxememcasecmp (const Ibyte *s1, const Ibyte *s2, Bytecount len); | |
5819 int qxememcasecmp4 (const Ibyte *s1, Bytecount len1, | |
5820 const Ibyte *s2, Bytecount len2); | |
5821 int qxetextcmp (const Ibyte *s1, Bytecount len1, | |
5822 const Ibyte *s2, Bytecount len2); | |
5823 int qxetextcmp_matching (const Ibyte *s1, Bytecount len1, | |
5824 const Ibyte *s2, Bytecount len2, | |
801 | 5825 Charcount *matching); |
867 | 5826 int qxetextcasecmp (const Ibyte *s1, Bytecount len1, |
5827 const Ibyte *s2, Bytecount len2); | |
5828 int qxetextcasecmp_matching (const Ibyte *s1, Bytecount len1, | |
5829 const Ibyte *s2, Bytecount len2, | |
801 | 5830 Charcount *matching); |
771 | 5831 |
5832 void buffer_mule_signal_inserted_region (struct buffer *buf, Charbpos start, | |
5833 Bytecount bytelength, | |
5834 Charcount charlength); | |
5835 void buffer_mule_signal_deleted_region (struct buffer *buf, Charbpos start, | |
826 | 5836 Charbpos end, Bytebpos byte_start, |
5837 Bytebpos byte_end); | |
771 | 5838 |
2367 | 5839 typedef struct |
5840 { | |
5841 const char *srctext; | |
5842 void *dst; | |
5843 Bytecount dst_size; | |
5844 } alloca_convert_vals; | |
5845 | |
5846 typedef struct | |
5847 { | |
5848 Dynarr_declare (alloca_convert_vals); | |
5849 } alloca_convert_vals_dynarr; | |
5850 | |
5851 extern alloca_convert_vals_dynarr *active_alloca_convert; | |
5852 | |
5853 MODULE_API int find_pos_of_existing_active_alloca_convert (const char * | |
5854 srctext); | |
5855 | |
771 | 5856 /* Defined in unicode.c */ |
1204 | 5857 extern const struct sized_memory_description to_unicode_description; |
5858 extern const struct sized_memory_description from_unicode_description; | |
771 | 5859 void init_charset_unicode_tables (Lisp_Object charset); |
5860 void free_charset_unicode_tables (Lisp_Object charset); | |
5861 void recalculate_unicode_precedence (void); | |
5862 extern Lisp_Object Qunicode; | |
4096 | 5863 extern Lisp_Object Qutf_16, Qutf_8, Qucs_4, Qutf_7, Qutf_32; |
771 | 5864 #ifdef MEMORY_USAGE_STATS |
5865 Bytecount compute_from_unicode_table_size (Lisp_Object charset, | |
5866 struct overhead_stats *stats); | |
5867 Bytecount compute_to_unicode_table_size (Lisp_Object charset, | |
5868 struct overhead_stats *stats); | |
5869 #endif /* MEMORY_USAGE_STATS */ | |
5870 | |
428 | 5871 /* Defined in undo.c */ |
826 | 5872 EXFUN (Fundo_boundary, 0); |
5873 | |
428 | 5874 Lisp_Object truncate_undo_list (Lisp_Object, int, int); |
5875 void record_extent (Lisp_Object, int); | |
665 | 5876 void record_insert (struct buffer *, Charbpos, Charcount); |
5877 void record_delete (struct buffer *, Charbpos, Charcount); | |
5878 void record_change (struct buffer *, Charbpos, Charcount); | |
428 | 5879 |
5880 /* Defined in unex*.c */ | |
814 | 5881 #ifdef WIN32_NATIVE |
867 | 5882 int unexec (Ibyte *, Ibyte *, uintptr_t, uintptr_t, uintptr_t); |
814 | 5883 #else |
5884 int unexec (Extbyte *, Extbyte *, uintptr_t, uintptr_t, uintptr_t); | |
5885 #endif | |
428 | 5886 #ifdef RUN_TIME_REMAP |
5887 int run_time_remap (char *); | |
5888 #endif | |
5889 | |
5890 /* Defined in vm-limit.c */ | |
442 | 5891 void memory_warnings (void *, void (*) (const char *)); |
428 | 5892 |
442 | 5893 /*--------------- prototypes for constant symbols ------------*/ |
5894 | |
826 | 5895 /* #### We should get rid of this and put the prototypes back up there in |
5896 #### the per-file stuff, where they belong. */ | |
5897 | |
771 | 5898 /* Use the following when you have to add a bunch of symbols. */ |
5899 | |
5900 /* | |
5901 | |
5902 (defun redo-symbols (beg end) | |
5903 "Snarf any symbols out of the region and print them into a temporary buffer, | |
5904 which is displayed when the function finishes. The symbols are laid out with | |
5905 `extern Lisp_Object ' before each one, with as many as can fit on one line | |
5906 \(the maximum line width is controlled by the constant `max-line-length' in the | |
5907 code)." | |
5908 (interactive "r") | |
5909 (save-excursion | |
5910 (goto-char beg) | |
5911 (let (syms) | |
5912 (while (re-search-forward "\\s-\\(Q[A-Za-z_0-9]+\\)" end t) | |
5913 (push (match-string 1) syms)) | |
5914 (setq syms (sort syms #'string-lessp)) | |
5915 (with-output-to-temp-buffer "*Symbols*" | |
5916 (let* ((col 0) | |
5917 (start "extern Lisp_Object ") | |
5918 (startlen (length start)) | |
5919 ;; with a default-width frame of 80 chars, you can only fit | |
5920 ;; 79 before wrapping. you can see this to a lower value if | |
5921 ;; you don't want it right up against the right margin. | |
5922 (max-line-length 79)) | |
5923 (dolist (sym syms) | |
5924 (cond (;; if something already on line (this will always be the | |
5925 ;; case except the very first iteration), see what | |
5926 ;; space we've got. (need to take into account 2 | |
5927 ;; for the comma+space, 1 for the semicolon at the | |
5928 ;; end.) if enough space, do it. | |
5929 (and (> col 0) (< (+ col (length sym) 2) | |
5930 (1- max-line-length))) | |
5931 (princ ", ") | |
5932 (princ sym) | |
5933 (incf col 2) | |
5934 (incf col (length sym))) | |
5935 (t | |
5936 ;; either we're first iteration or we ran out of space. | |
5937 ;; if the latter, terminate the previous line. this | |
5938 ;; loop is written on purpose so that it always prints | |
5939 ;; at least one item, even if that would go over. | |
5940 (when (> col 0) | |
5941 (princ ";\n") | |
5942 (setq col 0)) | |
5943 (princ start) | |
5944 (incf col startlen) | |
5945 (princ sym) | |
5946 (incf col (length sym))))) | |
5947 ;; finally terminate the last line. | |
5948 (princ ";\n")))))) | |
5949 | |
5950 */ | |
5951 | |
814 | 5952 extern Lisp_Object Qactivate_menubar_hook, Qand_optional, Qand_rest; |
5953 extern Lisp_Object Qarith_error, Qarrayp, Qautoload, Qbackground; | |
5954 extern Lisp_Object Qbackground_pixmap, Qbeginning_of_buffer, Qbitp, Qblinking; | |
5955 extern Lisp_Object Qbuffer_glyph_p, Qbuffer_live_p, Qbuffer_read_only; | |
5956 extern Lisp_Object Qbyte_code, Qcall_interactively, Qcategory_designator_p; | |
5957 extern Lisp_Object Qcategory_table_value_p, Qcdr, Qchar_or_string_p; | |
5958 extern Lisp_Object Qcharacterp, Qcircular_list, Qcircular_property_list; | |
5959 extern Lisp_Object Qcolor_pixmap_image_instance_p, Qcommandp; | |
5960 extern Lisp_Object Qcompletion_ignore_case, Qconsole_live_p, Qconst_specifier; | |
5961 extern Lisp_Object Qconversion_error, Qcurrent_menubar; | |
771 | 5962 extern Lisp_Object Qcyclic_variable_indirection, Qdefun, Qdevice_live_p, Qdim; |
5963 extern Lisp_Object Qdirection, Qdisabled, Qdisabled_command_hook; | |
930 | 5964 extern Lisp_Object Qdisplay_table, Qdll_error, Qdomain_error, Qediting_error; |
771 | 5965 extern Lisp_Object Qend_of_buffer, Qend_of_file, Qend_open, Qerror; |
5966 extern Lisp_Object Qerror_conditions, Qerror_lacks_explanatory_string; | |
5967 extern Lisp_Object Qerror_message, Qevent_live_p, Qexit, Qextent_live_p; | |
996 | 5968 extern Lisp_Object Qexternal_debugging_output, Qfeaturep, Qfile_error; |
5969 extern Lisp_Object Qfile_name_sans_extension, Qfinal; | |
1111 | 5970 extern Lisp_Object Qforeground, Qformat, Qframe_live_p, Qgraphic; |
771 | 5971 extern Lisp_Object Qgui_error, Qicon_glyph_p, Qidentity, Qinhibit_quit; |
5972 extern Lisp_Object Qinhibit_read_only, Qinteger_char_or_marker_p; | |
1632 | 5973 extern Lisp_Object Qinteger_or_char_p, Qinteger_or_marker_p; |
5974 extern Lisp_Object Qinteractive, Qinternal_error; | |
771 | 5975 extern Lisp_Object Qinvalid_byte_code, Qinvalid_change, Qinvalid_constant; |
5976 extern Lisp_Object Qinvalid_function, Qinvalid_operation; | |
5977 extern Lisp_Object Qinvalid_read_syntax, Qinvalid_state, Qio_error, Qlambda; | |
1111 | 5978 extern Lisp_Object Qlayout, Qlist_formation_error, Qlistp, Qload; |
771 | 5979 extern Lisp_Object Qlong_name, Qmacro, Qmakunbound, Qmalformed_list; |
996 | 5980 extern Lisp_Object Qmalformed_property_list, Qmark, Qmodule; |
771 | 5981 extern Lisp_Object Qmono_pixmap_image_instance_p, Qmouse_leave_buffer_hook; |
5982 extern Lisp_Object Qnative_layout, Qnatnump, Qnetwork_error, Qno_catch; | |
1983 | 5983 extern Lisp_Object Qnonnegativep, Qnothing_image_instance_p; |
5984 extern Lisp_Object Qnumber_char_or_marker_p, Qnumberp, Qout_of_memory; | |
442 | 5985 extern Lisp_Object Qoverflow_error, Qpoint, Qpointer_glyph_p; |
771 | 5986 extern Lisp_Object Qpointer_image_instance_p, Qprint_length; |
563 | 5987 extern Lisp_Object Qprint_string_length, Qprinting_unreadable_object; |
1632 | 5988 extern Lisp_Object Qprogn, Qquit, Qquote, Qrange_error; |
771 | 5989 extern Lisp_Object Qread_char, Qread_from_minibuffer; |
5990 extern Lisp_Object Qreally_early_error_handler, Qregion_beginning; | |
3659 | 5991 extern Lisp_Object Qregion_end, Qregistries, Qreverse_direction_charset; |
771 | 5992 extern Lisp_Object Qrun_hooks, Qsans_modifiers, Qsave_buffers_kill_emacs; |
5993 extern Lisp_Object Qself_insert_command, Qself_insert_defer_undo, Qsequencep; | |
5994 extern Lisp_Object Qset, Qsetting_constant, Qshort_name, Qsingularity_error; | |
5995 extern Lisp_Object Qsound_error, Qstack_overflow, Qstandard_input; | |
5996 extern Lisp_Object Qstandard_output, Qstart_open, Qstring_lessp; | |
5997 extern Lisp_Object Qstructure_formation_error, Qsubwindow; | |
1632 | 5998 extern Lisp_Object Qsubwindow_image_instance_p; |
771 | 5999 extern Lisp_Object Qtext_conversion_error, Qtext_image_instance_p, Qtop_level; |
1632 | 6000 extern Lisp_Object Qtrue_list_p, Qunderflow_error, Qunderline; |
771 | 6001 extern Lisp_Object Quser_files_and_directories, Qvalues; |
6002 extern Lisp_Object Qvariable_documentation, Qvariable_domain, Qvoid_function; | |
6003 extern Lisp_Object Qvoid_variable, Qwindow_live_p, Qwrong_number_of_arguments; | |
442 | 6004 extern Lisp_Object Qwrong_type_argument, Qyes_or_no_p; |
6005 | |
1632 | 6006 extern MODULE_API Lisp_Object Qintegerp, Qinvalid_argument, Qprocess_error; |
6007 extern MODULE_API Lisp_Object Qsyntax_error, Qt, Qunbound; | |
6008 | |
442 | 6009 #define SYMBOL(fou) extern Lisp_Object fou |
1632 | 6010 #define SYMBOL_MODULE_API(fou) extern MODULE_API Lisp_Object fou |
442 | 6011 #define SYMBOL_KEYWORD(la_cle_est_fou) extern Lisp_Object la_cle_est_fou |
6012 #define SYMBOL_GENERAL(tout_le_monde, est_fou) \ | |
6013 extern Lisp_Object tout_le_monde | |
6014 | |
6015 #include "general-slots.h" | |
6016 | |
6017 #undef SYMBOL | |
1632 | 6018 #undef SYMBOL_MODULE_API |
442 | 6019 #undef SYMBOL_KEYWORD |
6020 #undef SYMBOL_GENERAL | |
6021 | |
6022 /*--------------- prototypes for variables of type Lisp_Object ------------*/ | |
6023 | |
826 | 6024 /* #### We should get rid of this and put the prototypes back up there in |
6025 #### the per-file stuff, where they belong. */ | |
6026 | |
446 | 6027 extern Lisp_Object Vactivate_menubar_hook; |
6028 extern Lisp_Object Vautoload_queue, Vblank_menubar; | |
771 | 6029 extern Lisp_Object Vcommand_history; |
428 | 6030 extern Lisp_Object Vcommand_line_args, Vconfigure_info_directory; |
6031 extern Lisp_Object Vconfigure_site_directory, Vconfigure_site_module_directory; | |
6032 extern Lisp_Object Vconsole_list, Vcontrolling_terminal; | |
6033 extern Lisp_Object Vcurrent_compiled_function_annotation, Vcurrent_load_list; | |
6034 extern Lisp_Object Vcurrent_mouse_event, Vcurrent_prefix_arg, Vdata_directory; | |
434 | 6035 extern Lisp_Object Vdirectory_sep_char, Vdisabled_command_hook; |
6036 extern Lisp_Object Vdoc_directory, Vinternal_doc_file_name; | |
428 | 6037 extern Lisp_Object Vecho_area_buffer, Vemacs_major_version; |
6038 extern Lisp_Object Vemacs_minor_version, Vexec_directory, Vexec_path; | |
6039 extern Lisp_Object Vexecuting_macro, Vfeatures, Vfile_domain; | |
1927 | 6040 extern Lisp_Object Vinvocation_directory, Vinvocation_name; |
771 | 6041 extern Lisp_Object Vlast_command, Vlast_command_char; |
428 | 6042 extern Lisp_Object Vlast_command_event, Vlast_input_event; |
2548 | 6043 extern Lisp_Object Vload_file_name_internal, Vload_history; |
428 | 6044 extern Lisp_Object Vload_path, Vmark_even_if_inactive, Vmenubar_configuration; |
6045 extern Lisp_Object Vminibuf_preprompt, Vminibuf_prompt, Vminibuffer_zero; | |
6046 extern Lisp_Object Vmodule_directory, Vmswindows_downcase_file_names; | |
6047 extern Lisp_Object Vmswindows_get_true_file_attributes, Vobarray; | |
6048 extern Lisp_Object Vprint_length, Vprint_level, Vprocess_environment; | |
6049 extern Lisp_Object Vrecent_keys_ring, Vshell_file_name, Vsite_directory; | |
6050 extern Lisp_Object Vsite_module_directory; | |
6051 extern Lisp_Object Vstandard_input, Vstandard_output, Vstdio_str; | |
771 | 6052 extern Lisp_Object Vsynchronous_sounds, Vsystem_name; |
428 | 6053 extern Lisp_Object Vthis_command_keys, Vunread_command_event; |
6054 extern Lisp_Object Vx_initial_argv_list; | |
6055 | |
1927 | 6056 extern MODULE_API Lisp_Object Vinhibit_quit, Vquit_flag; |
6057 | |
1743 | 6058 END_C_DECLS |
1650 | 6059 |
440 | 6060 #endif /* INCLUDED_lisp_h_ */ |