comparison src/lisp.h @ 814:a634e3b7acc8

[xemacs-hg @ 2002-04-14 12:41:59 by ben] latest changes TODO.ben-mule-21-5: Update. make-docfile.c: Add basic support for handling ISO 2022 doc strings -- we parse the basic charset designation sequences so we know whether we're in ASCII and have to pay attention to end quotes and such. Reformat code according to coding standards. abbrev.el: Add `global-abbrev-mode', which turns on or off abbrev-mode in all buffers. Added `defining-abbrev-turns-on-abbrev-mode' -- if non-nil, defining an abbrev through an interactive function will automatically turn on abbrev-mode, either globally or locally depending on the command. This is the "what you'd expect" behavior. indent.el: general function for indenting a balanced expression in a mode-correct way. Works similar to indent-region in that a mode can specify a specific command to do the whole operation; if not, figure out the region using forward-sexp and indent each line using indent-according-to-mode. keydefs.el: Removed. Modify M-C-backslash to do indent-region-or-balanced-expression. Make S-Tab just insert a TAB char, like it's meant to do. make-docfile.el: Now that we're using the call-process-in-lisp, we need to load an extra file win32-native.el because we're running a bare temacs. menubar-items.el: Totally redo the Cmds menu so that most used commands appear directly on the menu and less used commands appear in submenus. The old way may have been very pretty, but rather impractical. process.el: Under Windows, don't ever use old-call-process-internal, even in batch mode. We can do processes in batch mode. subr.el: Someone recoded truncate-string-to-width, saying "the FSF version is too complicated and does lots of hard-to-understand stuff" but the resulting recoded version was *totally* wrong! it misunderstood the basic point of this function, which is work in *columns* not chars. i dumped ours and copied the version from FSF 21.1. Also added truncate-string-with-continuation-dots, since this idiom is used often. config.inc.samp, xemacs.mak: Separate out debug and optimize flags. Remove all vestiges of USE_MINIMAL_TAGBITS, USE_INDEXED_LRECORD_IMPLEMENTATION, and GUNG_HO, since those ifdefs have long been removed. Make error-checking support actually work. Some rearrangement of config.inc.samp to make it more logical. Remove callproc.c and ntproc.c from xemacs.mak, no longer used. Make pdump the default. lisp.h: Add support for strong type-checking of Bytecount, Bytebpos, Charcount, Charbpos, and others, by making them classes, overloading the operators to provide integer-like operation and carefully controlling what operations are allowed. Not currently enabled in C++ builds because there are still a number of compile errors, and it won't really work till we merge in my "8-bit-Mule" workspace, in which I make use of the new types Charxpos, Bytexpos, Memxpos, representing a "position" either in a buffer or a string. (This is especially important in the extent code.) abbrev.c, alloc.c, eval.c, buffer.c, buffer.h, editfns.c, fns.c, text.h: Warning fixes, some of them related to new C++ strict type checking of Bytecount, Charbpos, etc. dired.c: Caught an actual error due to strong type checking -- char len being passed when should be byte len. alloc.c, backtrace.h, bytecode.c, bytecode.h, eval.c, sysdep.c: Further optimize Ffuncall: -- process arg list at compiled-function creation time, converting into an array for extra-quick access at funcall time. -- rewrite funcall_compiled_function to use it, and inline this function. -- change the order of check for magic stuff in SPECBIND_FAST_UNSAFE to be faster. -- move the check for need to garbage collect into the allocation code, so only a single flag needs to be checked in funcall. buffer.c, symbols.c: add debug funs to check on mule optimization info in buffers and strings. eval.c, emacs.c, text.c, regex.c, scrollbar-msw.c, search.c: Fix evil crashes due to eistrings not properly reinitialized under pdump. Redo a bit some of the init routines; convert some complex_vars_of() into simple vars_of(), because they didn't need complex processing. callproc.c, emacs.c, event-stream.c, nt.c, process.c, process.h, sysdep.c, sysdep.h, syssignal.h, syswindows.h, ntproc.c: Delete. Hallelujah, praise the Lord, there is no god but Allah!!! fix so that processes can be invoked in bare temacs -- thereby eliminating any need for callproc.c. (currently only eliminated under NT.) remove all crufty and unnecessary old process code in ntproc.c and elsewhere. move non-callproc-specific stuff (mostly environment) into process.c, so callproc.c can be left out under NT. console-tty.c, doc.c, file-coding.c, file-coding.h, lstream.c, lstream.h: fix doc string handling so it works with Japanese, etc docs. change handling of "character mode" so callers don't have to manually set it (quite error-prone). event-msw.c: spacing fixes. lread.c: eliminate unused crufty vintage-19 "FSF defun hack" code. lrecord.h: improve pdump description docs. buffer.c, ntheap.c, unexnt.c, win32.c, emacs.c: Mule-ize some unexec and startup code. It was pseudo-Mule-ized before by simply always calling the ...A versions of functions, but that won't cut it -- eventually we want to be able to run properly even if XEmacs has been installed in a Japanese directory. (The current problem is the timing of the loading of the Unicode tables; this will eventually be fixed.) Go through and fix various other places where the code was not Mule-clean. Provide a function mswindows_get_module_file_name() to get our own name without resort to PATH_MAX and such. Add a big comment in main() about the problem with Unicode table load timing that I just alluded to. emacs.c: When error-checking is enabled (interpreted as "user is developing XEmacs"), don't ask user to "pause to read messages" when a fatal error has occurred, because it will wedge if we are in an inner modal loop (typically when a menu is popped up) and make us unable to get a useful stack trace in the debugger. text.c: Correct update_entirely_ascii_p_flag to actually work. lisp.h, symsinit.h: declarations for above changes.
author ben
date Sun, 14 Apr 2002 12:43:31 +0000
parents 19dfb459d51a
children 6504113e7c2d
comparison
equal deleted inserted replaced
813:9541922fb765 814:a634e3b7acc8
144 sort of position is being used. See extents.c for a description 144 sort of position is being used. See extents.c for a description
145 of the different positions. We put them here instead of in 145 of the different positions. We put them here instead of in
146 buffer.h (where they rightfully belong) to avoid syntax errors 146 buffer.h (where they rightfully belong) to avoid syntax errors
147 in function prototypes. */ 147 in function prototypes. */
148 148
149 #if !defined (__cplusplus) || !defined (CPLUSPLUS_INTEGRAL_CLASSES_NOT_YET)
149 150
150 typedef EMACS_INT Charbpos; 151 typedef EMACS_INT Charbpos;
151 typedef EMACS_INT Bytebpos; 152 typedef EMACS_INT Bytebpos;
152 typedef EMACS_INT Membpos; 153 typedef EMACS_INT Membpos;
153 154
154 /* Counts of bytes or chars */ 155 /* Counts of bytes or chars */
155 typedef EMACS_INT Bytecount; 156 typedef EMACS_INT Bytecount;
156 typedef EMACS_INT Charcount; 157 typedef EMACS_INT Charcount;
158
159 /* Not yet used */
160 typedef EMACS_INT Charxpos;
161 typedef EMACS_INT Bytexpos;
162 typedef EMACS_INT Memxpos;
163
164 #else /* __cplusplus */
165
166 /* Implement strong type-checking of the above integral types by declaring
167 them to be classes and using operator overloading. Unfortunately this
168 is a huge pain in the ass because C++ doesn't strongly distinguish
169 "bool" and "size_t" from int. The problem is especially bad with "bool"
170 -- if you want to be able to say 'if (len--)' where len is e.g. a
171 Bytecount, you need to declare a conversion operator to bool(); and
172 since bool is just an alias for int, you suddenly get tons and tons of
173 ambiguities, which need to be resolved by lots of laborious declarations
174 for every single possible type combination. Hence the multitude of
175 declarations in DECLARE_INTCLASS_ARITH_COMPARE(). The bool/int
176 equivalence also means that we have to forcibly block the combinations
177 we don't want by creating overloaded versions of them and declaring them
178 private. */
179
180 #undef class
181 #undef this
182
183 class Bytecount;
184 class Bytebpos;
185 class Bytexpos;
186 class Charcount;
187 class Charbpos;
188 class Charxpos;
189 class Membpos;
190 class Memxpos;
191
192 /* Declare the arithmetic and comparison operations for an integral class,
193 i.e. one of the above classes. If this is a "position" class, where the
194 difference between two positions is a different class (a "count" class),
195 then use POSCL for the position class and COUNTCL for the count class.
196 If this is a simple class, where all operations yield the same class,
197 substitute the same class for POSCL and COUNTCL. */
198
199 #define DECLARE_INTCLASS_ARITH_COMPARE(poscl, countcl) \
200 poscl operator += (const countcl& l) { data += l.data; return *this; } \
201 poscl operator -= (const countcl& l) { data -= l.data; return *this; } \
202 poscl operator + (const countcl& l) const { return poscl (data + l.data); } \
203 poscl operator - (const countcl& l) const { return poscl (data - l.data); } \
204 poscl operator += (const int& l) { data += l; return *this; } \
205 poscl operator -= (const int& l) { data -= l; return *this; } \
206 poscl operator + (const int& l) const { return poscl (data + l); } \
207 poscl operator - (const int& l) const { return poscl (data - l); } \
208 poscl operator += (const unsigned int& l) { data += l; return *this; } \
209 poscl operator -= (const unsigned int& l) { data -= l; return *this; } \
210 poscl operator + (const unsigned int& l) const \
211 { return poscl (data + l); } \
212 poscl operator - (const unsigned int& l) const \
213 { return poscl (data - l); } \
214 poscl operator += (const long& l) { data += l; return *this; } \
215 poscl operator -= (const long& l) { data -= l; return *this; } \
216 poscl operator + (const long& l) const { return poscl (data + l); } \
217 poscl operator - (const long& l) const { return poscl (data - l); } \
218 poscl operator += (const unsigned long& l) { data += l; return *this; } \
219 poscl operator -= (const unsigned long& l) { data -= l; return *this; } \
220 poscl operator + (const unsigned long& l) const \
221 { return poscl (data + l); } \
222 poscl operator - (const unsigned long& l) const \
223 { return poscl (data - l); } \
224 poscl operator += (const short& l) { data += l; return *this; } \
225 poscl operator -= (const short& l) { data -= l; return *this; } \
226 poscl operator + (const short& l) const { return poscl (data + l); } \
227 poscl operator - (const short& l) const { return poscl (data - l); } \
228 poscl operator += (const unsigned short& l) { data += l; return *this; } \
229 poscl operator -= (const unsigned short& l) { data -= l; return *this; } \
230 poscl operator + (const unsigned short& l) const \
231 { return poscl (data + l); } \
232 poscl operator - (const unsigned short& l) const \
233 { return poscl (data - l); } \
234 \
235 poscl operator *= (const countcl& l) { data *= l.data; return *this; } \
236 poscl operator /= (const countcl& l) { data /= l.data; return *this; } \
237 poscl operator * (const countcl& l) const { return poscl (data * l.data); } \
238 poscl operator / (const countcl& l) const { return poscl (data / l.data); } \
239 poscl operator *= (const int& l) { data *= l; return *this; } \
240 poscl operator /= (const int& l) { data /= l; return *this; } \
241 poscl operator * (const int& l) const { return poscl (data * l); } \
242 poscl operator / (const int& l) const { return poscl (data / l); } \
243 poscl operator *= (const unsigned int& l) { data *= l; return *this; } \
244 poscl operator /= (const unsigned int& l) { data /= l; return *this; } \
245 poscl operator * (const unsigned int& l) const { return poscl (data * l); } \
246 poscl operator / (const unsigned int& l) const { return poscl (data / l); } \
247 poscl operator *= (const long& l) { data *= l; return *this; } \
248 poscl operator /= (const long& l) { data /= l; return *this; } \
249 poscl operator * (const long& l) const { return poscl (data * l); } \
250 poscl operator / (const long& l) const { return poscl (data / l); } \
251 poscl operator *= (const unsigned long& l) { data *= l; return *this; } \
252 poscl operator /= (const unsigned long& l) { data /= l; return *this; } \
253 poscl operator * (const unsigned long& l) const \
254 { return poscl (data * l); } \
255 poscl operator / (const unsigned long& l) const \
256 { return poscl (data / l); } \
257 poscl operator *= (const short& l) { data *= l; return *this; } \
258 poscl operator /= (const short& l) { data /= l; return *this; } \
259 poscl operator * (const short& l) const { return poscl (data * l); } \
260 poscl operator / (const short& l) const { return poscl (data / l); } \
261 poscl operator *= (const unsigned short& l) { data *= l; return *this; } \
262 poscl operator /= (const unsigned short& l) { data /= l; return *this; } \
263 poscl operator * (const unsigned short& l) const \
264 { return poscl (data * l); } \
265 poscl operator / (const unsigned short& l) const \
266 { return poscl (data / l); } \
267 \
268 poscl operator &= (const countcl& l) { data &= l.data; return *this; } \
269 poscl operator |= (const countcl& l) { data |= l.data; return *this; } \
270 poscl operator & (const countcl& l) const { return poscl (data & l.data); } \
271 poscl operator | (const countcl& l) const { return poscl (data | l.data); } \
272 poscl operator &= (const int& l) { data &= l; return *this; } \
273 poscl operator |= (const int& l) { data |= l; return *this; } \
274 poscl operator & (const int& l) const { return poscl (data & l); } \
275 poscl operator | (const int& l) const { return poscl (data | l); } \
276 poscl operator &= (const unsigned int& l) { data &= l; return *this; } \
277 poscl operator |= (const unsigned int& l) { data |= l; return *this; } \
278 poscl operator & (const unsigned int& l) const { return poscl (data & l); } \
279 poscl operator | (const unsigned int& l) const { return poscl (data | l); } \
280 poscl operator &= (const long& l) { data &= l; return *this; } \
281 poscl operator |= (const long& l) { data |= l; return *this; } \
282 poscl operator & (const long& l) const { return poscl (data & l); } \
283 poscl operator | (const long& l) const { return poscl (data | l); } \
284 poscl operator &= (const unsigned long& l) { data &= l; return *this; } \
285 poscl operator |= (const unsigned long& l) { data |= l; return *this; } \
286 poscl operator & (const unsigned long& l) const \
287 { return poscl (data & l); } \
288 poscl operator | (const unsigned long& l) const \
289 { return poscl (data | l); } \
290 poscl operator &= (const short& l) { data &= l; return *this; } \
291 poscl operator |= (const short& l) { data |= l; return *this; } \
292 poscl operator & (const short& l) const { return poscl (data & l); } \
293 poscl operator | (const short& l) const { return poscl (data | l); } \
294 poscl operator &= (const unsigned short& l) { data &= l; return *this; } \
295 poscl operator |= (const unsigned short& l) { data |= l; return *this; } \
296 poscl operator & (const unsigned short& l) const \
297 { return poscl (data & l); } \
298 poscl operator | (const unsigned short& l) const \
299 { return poscl (data | l); } \
300 \
301 poscl operator - () { return poscl (-data); } \
302 poscl operator-- () { data--; return *this; } \
303 poscl operator-- (int) { data--; return poscl (data + 1); } \
304 poscl operator++ () { data++; return *this; } \
305 poscl operator++ (int) { data++; return poscl (data - 1); } \
306 \
307 bool operator < (const poscl& l) const { return data < l.data; } \
308 bool operator <= (const poscl& l) const { return data <= l.data; } \
309 bool operator > (const poscl& l) const { return data > l.data; } \
310 bool operator >= (const poscl& l) const { return data >= l.data; } \
311 bool operator == (const poscl& l) const { return data == l.data; } \
312 bool operator != (const poscl& l) const { return data != l.data; } \
313 bool operator < (const int& l) const { return data < (EMACS_INT) l; } \
314 bool operator <= (const int& l) const { return data <= (EMACS_INT) l; } \
315 bool operator > (const int& l) const { return data > (EMACS_INT) l; } \
316 bool operator >= (const int& l) const { return data >= (EMACS_INT) l; } \
317 bool operator == (const int& l) const { return data == (EMACS_INT) l; } \
318 bool operator != (const int& l) const { return data != (EMACS_INT) l; } \
319 bool operator < (const unsigned int& l) const \
320 { return data < (EMACS_INT) l; } \
321 bool operator <= (const unsigned int& l) const \
322 { return data <= (EMACS_INT) l; } \
323 bool operator > (const unsigned int& l) const \
324 { return data > (EMACS_INT) l; } \
325 bool operator >= (const unsigned int& l) const \
326 { return data >= (EMACS_INT) l; } \
327 bool operator == (const unsigned int& l) const \
328 { return data == (EMACS_INT) l; } \
329 bool operator != (const unsigned int& l) const \
330 { return data != (EMACS_INT) l; } \
331 bool operator < (const long& l) const { return data < (EMACS_INT) l; } \
332 bool operator <= (const long& l) const { return data <= (EMACS_INT) l; } \
333 bool operator > (const long& l) const { return data > (EMACS_INT) l; } \
334 bool operator >= (const long& l) const { return data >= (EMACS_INT) l; } \
335 bool operator == (const long& l) const { return data == (EMACS_INT) l; } \
336 bool operator != (const long& l) const { return data != (EMACS_INT) l; } \
337 bool operator < (const unsigned long& l) const \
338 { return data < (EMACS_INT) l; } \
339 bool operator <= (const unsigned long& l) const \
340 { return data <= (EMACS_INT) l; } \
341 bool operator > (const unsigned long& l) const \
342 { return data > (EMACS_INT) l; } \
343 bool operator >= (const unsigned long& l) const \
344 { return data >= (EMACS_INT) l; } \
345 bool operator == (const unsigned long& l) const \
346 { return data == (EMACS_INT) l; } \
347 bool operator != (const unsigned long& l) const \
348 { return data != (EMACS_INT) l; } \
349 bool operator < (const short& l) const { return data < (EMACS_INT) l; } \
350 bool operator <= (const short& l) const { return data <= (EMACS_INT) l; } \
351 bool operator > (const short& l) const { return data > (EMACS_INT) l; } \
352 bool operator >= (const short& l) const { return data >= (EMACS_INT) l; } \
353 bool operator == (const short& l) const { return data == (EMACS_INT) l; } \
354 bool operator != (const short& l) const { return data != (EMACS_INT) l; } \
355 bool operator < (const unsigned short& l) const \
356 { return data < (EMACS_INT) l; } \
357 bool operator <= (const unsigned short& l) const \
358 { return data <= (EMACS_INT) l; } \
359 bool operator > (const unsigned short& l) const \
360 { return data > (EMACS_INT) l; } \
361 bool operator >= (const unsigned short& l) const \
362 { return data >= (EMACS_INT) l; } \
363 bool operator == (const unsigned short& l) const \
364 { return data == (EMACS_INT) l; } \
365 bool operator != (const unsigned short& l) const \
366 { return data != (EMACS_INT) l; } \
367 bool operator ! () const { return !data; }
368
369 /* Declare the "bad" or disallowed arithmetic and comparion operations
370 between class GOOD and class BAD. Meant to go inside the private
371 section of class GOOD. */
372
373 #define DECLARE_BAD_INTCLASS_ARITH_COMPARE(good, bad) \
374 good operator += (const bad& l) { return badret; } \
375 good operator -= (const bad& l) { return badret; } \
376 good operator *= (const bad& l) { return badret; } \
377 good operator /= (const bad& l) { return badret; } \
378 good operator + (const bad& l) { return badret; } \
379 good operator - (const bad& l) { return badret; } \
380 good operator * (const bad& l) { return badret; } \
381 good operator / (const bad& l) { return badret; } \
382 \
383 bool operator < (const bad& l) { return 0; } \
384 bool operator <= (const bad& l) { return 0; } \
385 bool operator > (const bad& l) { return 0; } \
386 bool operator >= (const bad& l) { return 0; } \
387 bool operator == (const bad& l) { return 0; } \
388 bool operator != (const bad& l) { return 0; }
389
390 /* Declare the "bad" or disallowed arithmetic operations between class GOOD
391 and another of the same class, for a position class. Meant to go inside
392 the private section of class GOOD. */
393
394 #define DECLARE_BAD_POS_CLASS_ARITH(good) \
395 good operator += (const good& l) { return badret; } \
396 good operator -= (const good& l) { return badret; } \
397 good operator *= (const good& l) { return badret; } \
398 good operator /= (const good& l) { return badret; } \
399 good operator + (const good& l) { return badret; } \
400 good operator * (const good& l) { return badret; } \
401 good operator / (const good& l) { return badret; }
402
403 /* Basic declaration at the top of all integral classes. Don't call
404 directly, use one of the more specific versions below. */
405
406 #define DECLARE_INTCLASS(cl) \
407 public: \
408 EMACS_INT data; \
409 cl () { data = 0xCDCDCDCD; } \
410 cl (int i) { data = i; } \
411 cl (unsigned int i) { data = i; } \
412 cl (long i) { data = i; } \
413 cl (unsigned long i) { data = i; } \
414 cl (short i) { data = i; } \
415 cl (unsigned short i) { data = i; } \
416 operator EMACS_INT () const { return data; }
417
418 /* Basic declaration at the top of all count classes. */
419
420 #define DECLARE_COUNT_CLASS(cl) \
421 DECLARE_INTCLASS (cl) \
422 DECLARE_INTCLASS_ARITH_COMPARE (cl, cl) \
423 private: \
424 static cl badret;
425
426 /* Basic declaration at the bottom of the prelude of all position classes.
427 Don't call directly. */
428
429 #define DECLARE_POS_CLASS_SECOND_HALF(cl, countcl) \
430 DECLARE_INTCLASS_ARITH_COMPARE (cl, countcl) \
431 countcl operator - (const cl& l) const { return countcl (data - l.data); } \
432 private: \
433 static cl badret; \
434 DECLARE_BAD_POS_INTCLASS_ARITH (cl)
435
436 /* Basic declaration at the top of all buffer position classes. */
437
438 #define DECLARE_BPOS_CLASS(cl, countcl) \
439 DECLARE_INTCLASS (cl) \
440 DECLARE_POS_CLASS_SECOND_HALF (cl, countcl)
441
442 /* Basic declaration at the top of all X-position classes (that can refer
443 to buffers or strings). CL1 and CL2 are the equivalent more specific
444 classes referring only to buffers or strings, respefitvely. */
445
446 #define DECLARE_XPOS_CLASS(cl, countcl, cl1, cl2) \
447 DECLARE_INTCLASS (cl) \
448 cl (const cl1& x) { data = x.data; } \
449 cl (const cl2& x) { data = x.data; } \
450 operator cl1 () const { return cl1 (data); } \
451 operator cl2 () const { return cl2 (data); } \
452 DECLARE_POS_CLASS_SECOND_HALF (cl, countcl)
453
454 /* Declare the "bad" or disallowed arithmetic and comparion operations
455 between class CHARCL (a character class) and various non-character
456 classes. Meant to go inside the private section of class GOOD. */
457
458 #define DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE(charcl) \
459 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Bytecount) \
460 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Bytebpos) \
461 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Bytexpos) \
462 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Membpos) \
463 DECLARE_BAD_INTCLASS_ARITH_COMPARE (charcl, Memxpos)
464
465 /* Declare the "bad" or disallowed arithmetic and comparion operations
466 between class BYTECL (a byte class) and various non-byte classes.
467 Meant to go inside the private section of class GOOD. */
468
469 #define DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE(bytecl) \
470 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charcount) \
471 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charbpos) \
472 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charxpos) \
473 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Membpos) \
474 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Memxpos)
475
476 /* Declare the "bad" or disallowed arithmetic and comparion operations
477 between class BYTECL (a mem class) and various non-mem classes.
478 Meant to go inside the private section of class GOOD. */
479
480 #define DECLARE_BAD_MEM_INTCLASS_ARITH_COMPARE(bytecl) \
481 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charcount) \
482 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charbpos) \
483 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Charxpos) \
484 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Bytebpos) \
485 DECLARE_BAD_INTCLASS_ARITH_COMPARE (bytecl, Bytexpos)
486
487 class Charcount
488 {
489 DECLARE_COUNT_CLASS (Charcount)
490 DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE (Charcount)
491 };
492
493 class Charbpos
494 {
495 DECLARE_BPOS_CLASS (Charbpos, Charcount)
496 DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE (Charbpos)
497 };
498
499 class Charxpos
500 {
501 DECLARE_XPOS_CLASS (Charxpos, Charcount, Charbpos, Charcount)
502 DECLARE_BAD_CHAR_INTCLASS_ARITH_COMPARE (Charxpos)
503 };
504
505 class Bytecount
506 {
507 DECLARE_COUNT_CLASS (Bytecount)
508 DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE (Bytecount)
509 };
510
511 class Bytebpos
512 {
513 DECLARE_BPOS_CLASS (Bytebpos, Bytecount)
514 DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE (Bytebpos)
515 };
516
517 class Bytexpos
518 {
519 DECLARE_XPOS_CLASS (Bytexpos, Bytecount, Bytebpos, Bytecount)
520 DECLARE_BAD_BYTE_INTCLASS_ARITH_COMPARE (Bytexpos)
521 };
522
523 class Membpos
524 {
525 DECLARE_BPOS_CLASS (Membpos, Bytecount)
526 DECLARE_BAD_MEM_INTCLASS_ARITH_COMPARE (Membpos)
527 };
528
529 class Memxpos
530 {
531 DECLARE_XPOS_CLASS (Memxpos, Bytecount, Membpos, Bytecount)
532 DECLARE_BAD_MEM_INTCLASS_ARITH_COMPARE (Memxpos)
533 };
534
535 #define DECLARE_POINTER_TYPE_ARITH_COUNT(pointer, countcl) \
536 inline pointer operator += (pointer & x, const countcl& y) \
537 { x += y.data; return x; } \
538 inline pointer operator -= (pointer & x, const countcl& y) \
539 { x -= y.data; return x; } \
540 inline pointer operator + (pointer x, const countcl& y) \
541 { return x + y.data; } \
542 inline pointer operator - (pointer x, const countcl& y) \
543 { return x - y.data; }
544
545 #define DECLARE_INTEGRAL_TYPE_ARITH_COUNT(integral, countcl) \
546 inline integral operator += (integral & x, const countcl& y) \
547 { x += y.data; return x; } \
548 inline integral operator -= (integral & x, const countcl& y) \
549 { x -= y.data; return x; } \
550 inline countcl operator + (integral x, const countcl& y) \
551 { return countcl (x + y.data); } \
552 inline countcl operator - (integral x, const countcl& y) \
553 { return countcl (x - y.data); }
554
555 #define DECLARE_INTEGRAL_TYPE_COMPARE(integral, cl) \
556 inline bool operator < (integral x, const cl& y) \
557 { return (EMACS_INT) x < y.data; } \
558 inline bool operator <= (integral x, const cl& y) \
559 { return (EMACS_INT) x <= y.data; } \
560 inline bool operator > (integral x, const cl& y) \
561 { return (EMACS_INT) x > y.data; } \
562 inline bool operator >= (integral x, const cl& y) \
563 { return (EMACS_INT) x >= y.data; } \
564 inline bool operator == (integral x, const cl& y) \
565 { return (EMACS_INT) x == y.data; } \
566 inline bool operator != (integral x, const cl& y) \
567 { return (EMACS_INT) x != y.data; }
568
569 #if 0
570 /* Unfortunately C++ doesn't let you overload the ?: operator, so we have
571 to manually deal with ambiguities using casting */
572 #define DECLARE_INTEGRAL_TYPE_TRISTATE(integral, cl) \
573 inline cl operator ?: (bool b, integral x, const cl& y) \
574 { return b ? cl (x) : y; } \
575 inline cl operator ?: (bool b, const cl& x, integral y) \
576 { return b ? x : cl (y); }
577 #endif /* 0 */
578
579 DECLARE_POINTER_TYPE_ARITH_COUNT (const Intbyte *, Bytecount);
580 DECLARE_POINTER_TYPE_ARITH_COUNT (const Extbyte *, Bytecount);
581 DECLARE_POINTER_TYPE_ARITH_COUNT (Intbyte *, Bytecount);
582 DECLARE_POINTER_TYPE_ARITH_COUNT (Extbyte *, Bytecount);
583
584 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (int, Bytecount);
585 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (int, Charcount);
586 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned int, Bytecount);
587 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned int, Charcount);
588 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (long, Bytecount);
589 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (long, Charcount);
590 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned long, Bytecount);
591 DECLARE_INTEGRAL_TYPE_ARITH_COUNT (unsigned long, Charcount);
592
593 DECLARE_INTEGRAL_TYPE_COMPARE (int, Bytecount);
594 DECLARE_INTEGRAL_TYPE_COMPARE (int, Charcount);
595 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned int, Bytecount);
596 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned int, Charcount);
597 DECLARE_INTEGRAL_TYPE_COMPARE (long, Bytecount);
598 DECLARE_INTEGRAL_TYPE_COMPARE (long, Charcount);
599 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned long, Bytecount);
600 DECLARE_INTEGRAL_TYPE_COMPARE (unsigned long, Charcount);
601
602 #if 0 /* doesn't work */
603 inline Bytecount operator - (const Intbyte *x, const Intbyte *y) \
604 { return Bytecount (x - y); }
605 #endif
606
607 #define class c_class
608 #define this c_this
609
610 #endif /* __cplusplus */
611
157 /* Counts of elements */ 612 /* Counts of elements */
158 typedef EMACS_INT Elemcount; 613 typedef EMACS_INT Elemcount;
159 /* Hash codes */ 614 /* Hash codes */
160 typedef unsigned long Hashcode; 615 typedef unsigned long Hashcode;
161 616
1451 string_index_byte_to_char (Lisp_Object s, Bytecount idx) 1906 string_index_byte_to_char (Lisp_Object s, Bytecount idx)
1452 ) 1907 )
1453 { 1908 {
1454 Charcount retval; 1909 Charcount retval;
1455 if (idx <= (Bytecount) XSTRING_ASCII_BEGIN (s)) 1910 if (idx <= (Bytecount) XSTRING_ASCII_BEGIN (s))
1456 retval = idx; 1911 retval = (Charcount) idx;
1457 else 1912 else
1458 retval = (XSTRING_ASCII_BEGIN (s) + 1913 retval = (XSTRING_ASCII_BEGIN (s) +
1459 bytecount_to_charcount (XSTRING_DATA (s) + 1914 bytecount_to_charcount (XSTRING_DATA (s) +
1460 XSTRING_ASCII_BEGIN (s), 1915 XSTRING_ASCII_BEGIN (s),
1461 idx - XSTRING_ASCII_BEGIN (s))); 1916 idx - XSTRING_ASCII_BEGIN (s)));
1471 string_index_char_to_byte (Lisp_Object s, Charcount idx) 1926 string_index_char_to_byte (Lisp_Object s, Charcount idx)
1472 ) 1927 )
1473 { 1928 {
1474 Bytecount retval; 1929 Bytecount retval;
1475 if (idx <= (Charcount) XSTRING_ASCII_BEGIN (s)) 1930 if (idx <= (Charcount) XSTRING_ASCII_BEGIN (s))
1476 retval = idx; 1931 retval = (Bytecount) idx;
1477 else 1932 else
1478 retval = (XSTRING_ASCII_BEGIN (s) + 1933 retval = (XSTRING_ASCII_BEGIN (s) +
1479 charcount_to_bytecount (XSTRING_DATA (s) + 1934 charcount_to_bytecount (XSTRING_DATA (s) +
1480 XSTRING_ASCII_BEGIN (s), 1935 XSTRING_ASCII_BEGIN (s),
1481 idx - XSTRING_ASCII_BEGIN (s))); 1936 idx - XSTRING_ASCII_BEGIN (s)));
1492 string_offset_byte_to_char_len (Lisp_Object s, Bytecount off, Bytecount len) 1947 string_offset_byte_to_char_len (Lisp_Object s, Bytecount off, Bytecount len)
1493 ) 1948 )
1494 { 1949 {
1495 Charcount retval; 1950 Charcount retval;
1496 if (off + len <= (Bytecount) XSTRING_ASCII_BEGIN (s)) 1951 if (off + len <= (Bytecount) XSTRING_ASCII_BEGIN (s))
1497 retval = len; 1952 retval = (Charcount) len;
1498 else if (off < (Bytecount) XSTRING_ASCII_BEGIN (s)) 1953 else if (off < (Bytecount) XSTRING_ASCII_BEGIN (s))
1499 retval = 1954 retval =
1500 XSTRING_ASCII_BEGIN (s) - off + 1955 XSTRING_ASCII_BEGIN (s) - (Charcount) off +
1501 bytecount_to_charcount (XSTRING_DATA (s) + XSTRING_ASCII_BEGIN (s), 1956 bytecount_to_charcount (XSTRING_DATA (s) + XSTRING_ASCII_BEGIN (s),
1502 len - (XSTRING_ASCII_BEGIN (s) - off)); 1957 len - (XSTRING_ASCII_BEGIN (s) - off));
1503 else 1958 else
1504 retval = bytecount_to_charcount (XSTRING_DATA (s) + off, len); 1959 retval = bytecount_to_charcount (XSTRING_DATA (s) + off, len);
1505 #ifdef SLEDGEHAMMER_CHECK_ASCII_BEGIN 1960 #ifdef SLEDGEHAMMER_CHECK_ASCII_BEGIN
1514 Bytecount 1969 Bytecount
1515 string_offset_char_to_byte_len (Lisp_Object s, Bytecount off, Charcount len) 1970 string_offset_char_to_byte_len (Lisp_Object s, Bytecount off, Charcount len)
1516 ) 1971 )
1517 { 1972 {
1518 Bytecount retval; 1973 Bytecount retval;
1519 if (off + len <= (Bytecount) XSTRING_ASCII_BEGIN (s)) 1974 /* casts to avoid errors from combining Bytecount/Charcount and warnings
1520 retval = len; 1975 from signed/unsigned comparisons */
1976 if (off + (Bytecount) len <= (Bytecount) XSTRING_ASCII_BEGIN (s))
1977 retval = (Bytecount) len;
1521 else if (off < (Bytecount) XSTRING_ASCII_BEGIN (s)) 1978 else if (off < (Bytecount) XSTRING_ASCII_BEGIN (s))
1522 retval = 1979 retval =
1523 XSTRING_ASCII_BEGIN (s) - off + 1980 XSTRING_ASCII_BEGIN (s) - off +
1524 charcount_to_bytecount (XSTRING_DATA (s) + XSTRING_ASCII_BEGIN (s), 1981 charcount_to_bytecount (XSTRING_DATA (s) + XSTRING_ASCII_BEGIN (s),
1525 len - (XSTRING_ASCII_BEGIN (s) - off)); 1982 len - (XSTRING_ASCII_BEGIN (s) -
1983 (Charcount) off));
1526 else 1984 else
1527 retval = charcount_to_bytecount (XSTRING_DATA (s) + off, len); 1985 retval = charcount_to_bytecount (XSTRING_DATA (s) + off, len);
1528 #ifdef SLEDGEHAMMER_CHECK_ASCII_BEGIN 1986 #ifdef SLEDGEHAMMER_CHECK_ASCII_BEGIN
1529 assert (retval == charcount_to_bytecount (XSTRING_DATA (s) + off, len)); 1987 assert (retval == charcount_to_bytecount (XSTRING_DATA (s) + off, len));
1530 #endif 1988 #endif
1531 return retval; 1989 return retval;
1532 } 1990 }
1533 1991
1534 DECLARE_INLINE_HEADER ( 1992 DECLARE_INLINE_HEADER (
1535 Intbyte * 1993 const Intbyte *
1536 string_char_addr (Lisp_Object s, Charcount idx) 1994 string_char_addr (Lisp_Object s, Charcount idx)
1537 ) 1995 )
1538 { 1996 {
1539 return XSTRING_DATA (s) + string_index_char_to_byte (s, idx); 1997 return XSTRING_DATA (s) + string_index_char_to_byte (s, idx);
1540 } 1998 }
2697 void mark_conses_in_list (Lisp_Object); 3155 void mark_conses_in_list (Lisp_Object);
2698 void free_marker (Lisp_Marker *); 3156 void free_marker (Lisp_Marker *);
2699 int object_dead_p (Lisp_Object); 3157 int object_dead_p (Lisp_Object);
2700 void mark_object (Lisp_Object obj); 3158 void mark_object (Lisp_Object obj);
2701 int marked_p (Lisp_Object obj); 3159 int marked_p (Lisp_Object obj);
2702 int need_to_garbage_collect (void); 3160 extern int need_to_garbage_collect;
2703 3161
2704 #ifdef MEMORY_USAGE_STATS 3162 #ifdef MEMORY_USAGE_STATS
2705 Bytecount malloced_storage_size (void *, Bytecount, struct overhead_stats *); 3163 Bytecount malloced_storage_size (void *, Bytecount, struct overhead_stats *);
2706 Bytecount fixed_type_block_overhead (Bytecount); 3164 Bytecount fixed_type_block_overhead (Bytecount);
2707 #endif 3165 #endif
2809 /* Defined in dired.c */ 3267 /* Defined in dired.c */
2810 Lisp_Object make_directory_hash_table (const Intbyte *); 3268 Lisp_Object make_directory_hash_table (const Intbyte *);
2811 Lisp_Object wasteful_word_to_lisp (unsigned int); 3269 Lisp_Object wasteful_word_to_lisp (unsigned int);
2812 3270
2813 /* Defined in doc.c */ 3271 /* Defined in doc.c */
2814 Lisp_Object unparesseuxify_doc_string (int, EMACS_INT, Intbyte *, Lisp_Object); 3272 Lisp_Object unparesseuxify_doc_string (int fd, EMACS_INT position,
3273 Intbyte *name_nonreloc,
3274 Lisp_Object name_reloc,
3275 int standard_doc_file);
2815 Lisp_Object read_doc_string (Lisp_Object); 3276 Lisp_Object read_doc_string (Lisp_Object);
2816 3277
2817 /* Defined in doprnt.c */ 3278 /* Defined in doprnt.c */
2818 3279
2819 Bytecount emacs_doprnt_va (Lisp_Object stream, const Intbyte *format_nonreloc, 3280 Bytecount emacs_doprnt_va (Lisp_Object stream, const Intbyte *format_nonreloc,
3395 void debug_backtrace (void); 3856 void debug_backtrace (void);
3396 3857
3397 /* Defined in process.c */ 3858 /* Defined in process.c */
3398 DECLARE_DOESNT_RETURN (report_process_error (const char *, Lisp_Object)); 3859 DECLARE_DOESNT_RETURN (report_process_error (const char *, Lisp_Object));
3399 DECLARE_DOESNT_RETURN (report_network_error (const char *, Lisp_Object)); 3860 DECLARE_DOESNT_RETURN (report_network_error (const char *, Lisp_Object));
3861 extern Lisp_Object Vlisp_EXEC_SUFFIXES;
3400 3862
3401 /* Defined in profile.c */ 3863 /* Defined in profile.c */
3402 void mark_profiling_info (void); 3864 void mark_profiling_info (void);
3403 void profile_increase_call_count (Lisp_Object); 3865 void profile_increase_call_count (Lisp_Object);
3404 extern int profiling_active; 3866 extern int profiling_active;
3449 3911
3450 /* Defined in symbols.c */ 3912 /* Defined in symbols.c */
3451 unsigned int hash_string (const Intbyte *, Bytecount); 3913 unsigned int hash_string (const Intbyte *, Bytecount);
3452 Lisp_Object intern_int (const Intbyte *str); 3914 Lisp_Object intern_int (const Intbyte *str);
3453 Lisp_Object intern (const CIntbyte *str); 3915 Lisp_Object intern (const CIntbyte *str);
3916 Lisp_Object intern_converting_underscores_to_dashes (const CIntbyte *str);
3454 Lisp_Object oblookup (Lisp_Object, const Intbyte *, Bytecount); 3917 Lisp_Object oblookup (Lisp_Object, const Intbyte *, Bytecount);
3455 void map_obarray (Lisp_Object, int (*) (Lisp_Object, void *), void *); 3918 void map_obarray (Lisp_Object, int (*) (Lisp_Object, void *), void *);
3456 Lisp_Object indirect_function (Lisp_Object, int); 3919 Lisp_Object indirect_function (Lisp_Object, int);
3457 Lisp_Object symbol_value_in_buffer (Lisp_Object, Lisp_Object); 3920 Lisp_Object symbol_value_in_buffer (Lisp_Object, Lisp_Object);
3458 void kill_buffer_local_variables (struct buffer *); 3921 void kill_buffer_local_variables (struct buffer *);
3808 void record_insert (struct buffer *, Charbpos, Charcount); 4271 void record_insert (struct buffer *, Charbpos, Charcount);
3809 void record_delete (struct buffer *, Charbpos, Charcount); 4272 void record_delete (struct buffer *, Charbpos, Charcount);
3810 void record_change (struct buffer *, Charbpos, Charcount); 4273 void record_change (struct buffer *, Charbpos, Charcount);
3811 4274
3812 /* Defined in unex*.c */ 4275 /* Defined in unex*.c */
3813 int unexec (char *, char *, uintptr_t, uintptr_t, uintptr_t); 4276 #ifdef WIN32_NATIVE
4277 int unexec (Intbyte *, Intbyte *, uintptr_t, uintptr_t, uintptr_t);
4278 #else
4279 int unexec (Extbyte *, Extbyte *, uintptr_t, uintptr_t, uintptr_t);
4280 #endif
3814 #ifdef RUN_TIME_REMAP 4281 #ifdef RUN_TIME_REMAP
3815 int run_time_remap (char *); 4282 int run_time_remap (char *);
3816 #endif 4283 #endif
3817 4284
3818 /* Defined in vm-limit.c */ 4285 /* Defined in vm-limit.c */
4107 ;; finally terminate the last line. 4574 ;; finally terminate the last line.
4108 (princ ";\n")))))) 4575 (princ ";\n"))))))
4109 4576
4110 */ 4577 */
4111 4578
4112 extern Lisp_Object Qactivate_menubar_hook, Qarith_error, Qarrayp, Qautoload; 4579 extern Lisp_Object Qactivate_menubar_hook, Qand_optional, Qand_rest;
4113 extern Lisp_Object Qbackground, Qbackground_pixmap, Qbeginning_of_buffer; 4580 extern Lisp_Object Qarith_error, Qarrayp, Qautoload, Qbackground;
4114 extern Lisp_Object Qbitp, Qblinking, Qbuffer_glyph_p, Qbuffer_live_p; 4581 extern Lisp_Object Qbackground_pixmap, Qbeginning_of_buffer, Qbitp, Qblinking;
4115 extern Lisp_Object Qbuffer_read_only, Qbyte_code, Qcall_interactively; 4582 extern Lisp_Object Qbuffer_glyph_p, Qbuffer_live_p, Qbuffer_read_only;
4116 extern Lisp_Object Qcategory_designator_p, Qcategory_table_value_p, Qcdr; 4583 extern Lisp_Object Qbyte_code, Qcall_interactively, Qcategory_designator_p;
4117 extern Lisp_Object Qchar_or_string_p, Qcharacterp, Qcircular_list; 4584 extern Lisp_Object Qcategory_table_value_p, Qcdr, Qchar_or_string_p;
4118 extern Lisp_Object Qcircular_property_list, Qcolor_pixmap_image_instance_p; 4585 extern Lisp_Object Qcharacterp, Qcircular_list, Qcircular_property_list;
4119 extern Lisp_Object Qcommandp, Qcompletion_ignore_case, Qconsole_live_p; 4586 extern Lisp_Object Qcolor_pixmap_image_instance_p, Qcommandp;
4120 extern Lisp_Object Qconst_specifier, Qconversion_error, Qcurrent_menubar; 4587 extern Lisp_Object Qcompletion_ignore_case, Qconsole_live_p, Qconst_specifier;
4588 extern Lisp_Object Qconversion_error, Qcurrent_menubar;
4121 extern Lisp_Object Qcyclic_variable_indirection, Qdefun, Qdevice_live_p, Qdim; 4589 extern Lisp_Object Qcyclic_variable_indirection, Qdefun, Qdevice_live_p, Qdim;
4122 extern Lisp_Object Qdirection, Qdisabled, Qdisabled_command_hook; 4590 extern Lisp_Object Qdirection, Qdisabled, Qdisabled_command_hook;
4123 extern Lisp_Object Qdisplay_table, Qdomain_error, Qediting_error; 4591 extern Lisp_Object Qdisplay_table, Qdomain_error, Qediting_error;
4124 extern Lisp_Object Qend_of_buffer, Qend_of_file, Qend_open, Qerror; 4592 extern Lisp_Object Qend_of_buffer, Qend_of_file, Qend_open, Qerror;
4125 extern Lisp_Object Qerror_conditions, Qerror_lacks_explanatory_string; 4593 extern Lisp_Object Qerror_conditions, Qerror_lacks_explanatory_string;