comparison src/console.h @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents b2472a1930f2
children 90d73dddcdc4
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
271 271
272 #define HAS_CONTYPE_METH_P(meth, m) ((meth)->m##_method) 272 #define HAS_CONTYPE_METH_P(meth, m) ((meth)->m##_method)
273 #define CONTYPE_METH(meth, m, args) (((meth)->m##_method) args) 273 #define CONTYPE_METH(meth, m, args) (((meth)->m##_method) args)
274 274
275 /* Call a void-returning console method, if it exists */ 275 /* Call a void-returning console method, if it exists */
276 #define MAYBE_CONTYPE_METH(meth, m, args) \ 276 #define MAYBE_CONTYPE_METH(meth, m, args) do { \
277 do { \
278 struct console_methods *_maybe_contype_meth_meth = (meth); \ 277 struct console_methods *_maybe_contype_meth_meth = (meth); \
279 if (HAS_CONTYPE_METH_P (_maybe_contype_meth_meth, m)) \ 278 if (HAS_CONTYPE_METH_P (_maybe_contype_meth_meth, m)) \
280 CONTYPE_METH (_maybe_contype_meth_meth, m, args); \ 279 CONTYPE_METH (_maybe_contype_meth_meth, m, args); \
281 } while (0) 280 } while (0)
282 281
283 MAC_DECLARE_EXTERN (struct console_methods *, MTcontype_meth_or_given)
284
285 /* Call a console method, if it exists; otherwise return 282 /* Call a console method, if it exists; otherwise return
286 the specified value */ 283 the specified value - meth is multiply evaluated. */
287 #define CONTYPE_METH_OR_GIVEN(meth, m, args, given) \ 284 #define CONTYPE_METH_OR_GIVEN(meth, m, args, given) \
288 MAC_BEGIN \ 285 (HAS_CONTYPE_METH_P (meth, m) ? \
289 MAC_DECLARE (struct console_methods *, \ 286 CONTYPE_METH (meth, m, args) : (given))
290 MTcontype_meth_or_given, meth) \
291 HAS_CONTYPE_METH_P (MTcontype_meth_or_given, m) ? \
292 CONTYPE_METH (MTcontype_meth_or_given, m, args) : (given) \
293 MAC_END
294 287
295 /* Call an int-returning console method, if it exists; otherwise 288 /* Call an int-returning console method, if it exists; otherwise
296 return 0 */ 289 return 0 */
297 #define MAYBE_INT_CONTYPE_METH(meth, m, args) \ 290 #define MAYBE_INT_CONTYPE_METH(meth, m, args) \
298 CONTYPE_METH_OR_GIVEN (meth, m, args, 0) 291 CONTYPE_METH_OR_GIVEN (meth, m, args, 0)
392 #define CONSOLEP(x) RECORDP (x, console) 385 #define CONSOLEP(x) RECORDP (x, console)
393 #define GC_CONSOLEP(x) GC_RECORDP (x, console) 386 #define GC_CONSOLEP(x) GC_RECORDP (x, console)
394 #define CHECK_CONSOLE(x) CHECK_RECORD (x, console) 387 #define CHECK_CONSOLE(x) CHECK_RECORD (x, console)
395 #define CONCHECK_CONSOLE(x) CONCHECK_RECORD (x, console) 388 #define CONCHECK_CONSOLE(x) CONCHECK_RECORD (x, console)
396 389
397 #define CHECK_LIVE_CONSOLE(x) \ 390 #define CHECK_LIVE_CONSOLE(x) do { \
398 do { CHECK_CONSOLE (x); \ 391 CHECK_CONSOLE (x); \
399 if (! CONSOLEP (x) \ 392 if (! CONSOLE_LIVE_P (XCONSOLE (x))) \
400 || ! CONSOLE_LIVE_P (XCONSOLE (x))) \ 393 dead_wrong_type_argument (Qconsole_live_p, (x)); \
401 dead_wrong_type_argument (Qconsole_live_p, (x)); } while (0) 394 } while (0)
402 #define CONCHECK_LIVE_CONSOLE(x) \ 395 #define CONCHECK_LIVE_CONSOLE(x) do { \
403 do { CONCHECK_CONSOLE (x); \ 396 CONCHECK_CONSOLE (x); \
404 if (! CONSOLEP (x) \ 397 if (! CONSOLE_LIVE_P (XCONSOLE (x))) \
405 || ! CONSOLE_LIVE_P (XCONSOLE (x))) \ 398 x = wrong_type_argument (Qconsole_live_p, (x)); \
406 x = wrong_type_argument (Qconsole_live_p, (x)); } while (0) 399 } while (0)
407 400
408 #define CONSOLE_TYPE_P(con, type) EQ (CONSOLE_TYPE (con), Q##type) 401 #define CONSOLE_TYPE_P(con, type) EQ (CONSOLE_TYPE (con), Q##type)
409 402
410 #ifdef ERROR_CHECK_TYPECHECK 403 #ifdef ERROR_CHECK_TYPECHECK
411 MAC_DECLARE_EXTERN (struct console *, MTconsole_data) 404 INLINE struct console *
412 # define CONSOLE_TYPE_DATA(con, type) \ 405 error_check_console_type (struct console *con, Lisp_Object sym);
413 MAC_BEGIN \ 406 INLINE struct console *
414 MAC_DECLARE (struct console *, MTconsole_data, con) \ 407 error_check_console_type (struct console *con, Lisp_Object sym)
415 assert (CONSOLE_TYPE_P (MTconsole_data, type)) \ 408 {
416 MAC_SEP \ 409 assert (EQ (CONSOLE_TYPE (con), sym));
417 (struct type##_console *) MTconsole_data->console_data \ 410 return con;
418 MAC_END 411 }
412 # define CONSOLE_TYPE_DATA(con, type) \
413 (*(struct type##_console **) \
414 &(error_check_console_type (con, Q##type))->console_data)
419 #else 415 #else
420 # define CONSOLE_TYPE_DATA(con, type) \ 416 # define CONSOLE_TYPE_DATA(con, type) \
421 ((struct type##_console *) (con)->console_data) 417 (*(struct type##_console **) &((con)->console_data))
422 #endif 418 #endif
423 419
424 #define CHECK_CONSOLE_TYPE(x, type) \ 420 #define CHECK_CONSOLE_TYPE(x, type) do { \
425 do { \ 421 CHECK_CONSOLE (x); \
426 CHECK_CONSOLE (x); \ 422 if (! CONSOLE_TYPE_P (XCONSOLE (x), type)) \
427 if (!(CONSOLEP (x) && CONSOLE_TYPE_P (XCONSOLE (x), \ 423 dead_wrong_type_argument \
428 type))) \ 424 (type##_console_methods->predicate_symbol, x); \
429 dead_wrong_type_argument \ 425 } while (0)
430 (type##_console_methods->predicate_symbol, x); \ 426 #define CONCHECK_CONSOLE_TYPE(x, type) do { \
431 } while (0) 427 CONCHECK_CONSOLE (x); \
432 #define CONCHECK_CONSOLE_TYPE(x, type) \ 428 if (!(CONSOLEP (x) && \
433 do { \ 429 CONSOLE_TYPE_P (XCONSOLE (x), type))) \
434 CONCHECK_CONSOLE (x); \ 430 x = wrong_type_argument \
435 if (!(CONSOLEP (x) && CONSOLE_TYPE_P (XCONSOLE (x), \ 431 (type##_console_methods->predicate_symbol, x); \
436 type))) \ 432 } while (0)
437 x = wrong_type_argument \
438 (type##_console_methods->predicate_symbol, x); \
439 } while (0)
440 433
441 /* #### These should be in the console-*.h files but there are 434 /* #### These should be in the console-*.h files but there are
442 too many places where the abstraction is broken. Need to 435 too many places where the abstraction is broken. Need to
443 fix. */ 436 fix. */
444 437
478 #define CHECK_STREAM_CONSOLE(z) CHECK_CONSOLE_TYPE (z, stream) 471 #define CHECK_STREAM_CONSOLE(z) CHECK_CONSOLE_TYPE (z, stream)
479 #define CONCHECK_STREAM_CONSOLE(z) CONCHECK_CONSOLE_TYPE (z, stream) 472 #define CONCHECK_STREAM_CONSOLE(z) CONCHECK_CONSOLE_TYPE (z, stream)
480 473
481 #define CONSOLE_WIN_P(con) CONSOLE_TYPESYM_WIN_P (CONSOLE_TYPE (con)) 474 #define CONSOLE_WIN_P(con) CONSOLE_TYPESYM_WIN_P (CONSOLE_TYPE (con))
482 475
483 extern Lisp_Object Vconsole_list, Vselected_console, Vdefault_console; 476 EXFUN (Fconsole_disable_input, 1);
484 extern Lisp_Object Qconsole_live_p; 477 EXFUN (Fdelete_console, 2);
485 478 EXFUN (Fselect_console, 1);
486 /* This structure holds the default values of the console-local 479 EXFUN (Fselected_console, 0);
487 variables defined with DEFVAR_CONSOLE_LOCAL, that have special 480
488 slots in each console. The default value occupies the same slot 481 extern Lisp_Object Qcreate_console_hook, Qdelete_console_hook;
489 in this structure as an individual console's value occupies in 482 extern Lisp_Object Vconsole_defaults, Vconsole_type_list, Vselected_console;
490 that console. Setting the default value also goes through the
491 list of consoles and stores into each console that does not say
492 it has a local value. */
493
494 extern Lisp_Object Vconsole_defaults;
495 483
496 /* This structure marks which slots in a console have corresponding 484 /* This structure marks which slots in a console have corresponding
497 default values in console_defaults. 485 default values in console_defaults.
498 Each such slot has a nonzero value in this structure. 486 Each such slot has a nonzero value in this structure.
499 The value has only one nonzero bit. 487 The value has only one nonzero bit.
505 If a slot in this structure is zero, then even though there may 493 If a slot in this structure is zero, then even though there may
506 be a DEFVAR_CONSOLE_LOCAL for the slot, there is no default value for it; 494 be a DEFVAR_CONSOLE_LOCAL for the slot, there is no default value for it;
507 and the corresponding slot in console_defaults is not used. */ 495 and the corresponding slot in console_defaults is not used. */
508 496
509 extern struct console console_local_flags; 497 extern struct console console_local_flags;
510
511 extern Lisp_Object Vconsole_type_list;
512
513 extern Lisp_Object Qtty, Qstream, Qdead;
514 #ifdef HAVE_X_WINDOWS
515 extern Lisp_Object Qx;
516 #endif /* HAVE_X_WINDOWS */
517 #ifdef HAVE_MS_WINDOWS
518 extern Lisp_Object Qmswindows;
519 #endif /* HAVE_MS_WINDOWS */
520 498
521 int valid_console_type_p (Lisp_Object type); 499 int valid_console_type_p (Lisp_Object type);
522 500
523 #define CONSOLE_LIVE_P(con) (!EQ (CONSOLE_TYPE (con), Qdead)) 501 #define CONSOLE_LIVE_P(con) (!EQ (CONSOLE_TYPE (con), Qdead))
524 502