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