comparison src/lisp.h @ 5128:7be849cb8828 ben-lisp-object

merge
author Ben Wing <ben@xemacs.org>
date Sun, 07 Mar 2010 02:09:59 -0600
parents a9c41067dd88 4a6b680a9577
children e5380fdaf8f1 f965e31a35f0
comparison
equal deleted inserted replaced
5127:a9c41067dd88 5128:7be849cb8828
82 assumption that Ibyte * text is composed of 1-byte units (e.g. UTF-16 82 assumption that Ibyte * text is composed of 1-byte units (e.g. UTF-16
83 is composed of 2-byte units and might be a possible format to consider 83 is composed of 2-byte units and might be a possible format to consider
84 for Ibyte * text). 84 for Ibyte * text).
85 85
86 %%#### marks places that need work for KKCC (the new garbage collector). 86 %%#### marks places that need work for KKCC (the new garbage collector).
87
88 @@#### marks places that need work to get Unicode-internal working,
89 i.e. using UTF-8 as the internal text format.
90
91 #### BILL! marks places that need work for GTK.
92
93 #### GEOM! marks places needing work to fix various bugs in the handling
94 of window and frame sizing and positioning. Often the root of the
95 problems is that the code was originally written before there was a
96 gutter and then not completely fixed up to accommodate the gutter.
87 97
88 */ 98 */
89 99
90 /************************************************************************/ 100 /************************************************************************/
91 /* include files */ 101 /* include files */
1227 and line of the inline function, which is not very useful. */ 1237 and line of the inline function, which is not very useful. */
1228 1238
1229 /* Highly dubious kludge */ 1239 /* Highly dubious kludge */
1230 /* (thanks, Jamie, I feel better now -- ben) */ 1240 /* (thanks, Jamie, I feel better now -- ben) */
1231 MODULE_API void assert_failed (const Ascbyte *, int, const Ascbyte *); 1241 MODULE_API void assert_failed (const Ascbyte *, int, const Ascbyte *);
1242 void assert_equal_failed (const Ascbyte *file, int line, EMACS_INT x,
1243 EMACS_INT y, const Ascbyte *exprx,
1244 const Ascbyte *expry);
1232 #define ABORT() assert_failed (__FILE__, __LINE__, "ABORT()") 1245 #define ABORT() assert_failed (__FILE__, __LINE__, "ABORT()")
1233 #define abort_with_message(msg) assert_failed (__FILE__, __LINE__, msg) 1246 #define abort_with_message(msg) assert_failed (__FILE__, __LINE__, msg)
1234 1247
1235 /* This used to be ((void) (0)) but that triggers lots of unused variable 1248 /* This used to be ((void) (0)) but that triggers lots of unused variable
1236 warnings -- furthermore, if `x' has any side effects, e.g. 1249 warnings -- furthermore, if `x' has any side effects, e.g.
1247 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x)) 1260 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x))
1248 # define assert_with_message(x, msg) \ 1261 # define assert_with_message(x, msg) \
1249 ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, msg)) 1262 ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, msg))
1250 # define assert_at_line(x, file, line) \ 1263 # define assert_at_line(x, file, line) \
1251 ((x) ? (void) 0 : assert_failed (file, line, #x)) 1264 ((x) ? (void) 0 : assert_failed (file, line, #x))
1265 # define assert_equal(x, y) \
1266 ((x) == (y) ? (void) 0 : \
1267 assert_equal_failed (__FILE__, __LINE__, (EMACS_INT) x, (EMACS_INT) y, \
1268 #x, #y))
1252 #else 1269 #else
1253 /* This used to be ((void) (0)) but that triggers lots of unused variable 1270 /* This used to be ((void) (0)) but that triggers lots of unused variable
1254 warnings. It's pointless to force all that code to be rewritten, with 1271 warnings. It's pointless to force all that code to be rewritten, with
1255 added ifdefs. Any reasonable compiler will eliminate an expression with 1272 added ifdefs. Any reasonable compiler will eliminate an expression with
1256 no effects. */ 1273 no effects. */
1257 # define assert(x) disabled_assert (x) 1274 # define assert(x) disabled_assert (x)
1258 # define assert_with_message(x, msg) disabled_assert_with_message (x, msg) 1275 # define assert_with_message(x, msg) disabled_assert_with_message (x, msg)
1259 # define assert_at_line(x, file, line) disabled_assert_at_line (x, file, line) 1276 # define assert_at_line(x, file, line) disabled_assert_at_line (x, file, line)
1277 # define assert_equal(x, y) disabled_assert ((x) == (y))
1260 #endif 1278 #endif
1261 1279
1262 /************************************************************************/ 1280 /************************************************************************/
1263 /** Memory allocation **/ 1281 /** Memory allocation **/
1264 /************************************************************************/ 1282 /************************************************************************/
1541 { 1559 {
1542 RUN_HOOKS_TO_COMPLETION, 1560 RUN_HOOKS_TO_COMPLETION,
1543 RUN_HOOKS_UNTIL_SUCCESS, 1561 RUN_HOOKS_UNTIL_SUCCESS,
1544 RUN_HOOKS_UNTIL_FAILURE 1562 RUN_HOOKS_UNTIL_FAILURE
1545 }; 1563 };
1546
1547 #ifdef HAVE_TOOLBARS
1548 enum toolbar_pos
1549 {
1550 TOP_TOOLBAR,
1551 BOTTOM_TOOLBAR,
1552 LEFT_TOOLBAR,
1553 RIGHT_TOOLBAR
1554 };
1555 #endif
1556 1564
1557 enum edge_style 1565 enum edge_style
1558 { 1566 {
1559 EDGE_ETCHED_IN, 1567 EDGE_ETCHED_IN,
1560 EDGE_ETCHED_OUT, 1568 EDGE_ETCHED_OUT,
3456 #define CONCHECK_NATNUM(x) do { \ 3464 #define CONCHECK_NATNUM(x) do { \
3457 if (!NATNUMP (x)) \ 3465 if (!NATNUMP (x)) \
3458 x = wrong_type_argument (Qnatnump, x); \ 3466 x = wrong_type_argument (Qnatnump, x); \
3459 } while (0) 3467 } while (0)
3460 3468
3469 END_C_DECLS
3470
3471 /* -------------- properties of internally-formatted text ------------- */
3472
3473 #include "text.h"
3474
3461 /*------------------------------- char ---------------------------------*/ 3475 /*------------------------------- char ---------------------------------*/
3476
3477 BEGIN_C_DECLS
3478
3479 #ifdef ERROR_CHECK_TYPES
3462 3480
3463 /* NOTE: There are basic functions for converting between a character and 3481 /* NOTE: There are basic functions for converting between a character and
3464 the string representation of a character in text.h, as well as lots of 3482 the string representation of a character in text.h, as well as lots of
3465 other character-related stuff. There are other functions/macros for 3483 other character-related stuff. There are other functions/macros for
3466 working with Ichars in charset.h, for retrieving the charset of an 3484 working with Ichars in charset.h, for retrieving the charset of an
3467 Ichar, the length of an Ichar when converted to text, etc. 3485 Ichar, the length of an Ichar when converted to text, etc.
3468 */ 3486 */
3469
3470 #ifdef MULE
3471
3472 MODULE_API int non_ascii_valid_ichar_p (Ichar ch);
3473
3474 /* Return whether the given Ichar is valid.
3475 */
3476
3477 DECLARE_INLINE_HEADER (
3478 int
3479 valid_ichar_p (Ichar ch)
3480 )
3481 {
3482 return (! (ch & ~0xFF)) || non_ascii_valid_ichar_p (ch);
3483 }
3484
3485 #else /* not MULE */
3486
3487 /* This works when CH is negative, and correctly returns non-zero only when CH
3488 is in the range [0, 255], inclusive. */
3489 #define valid_ichar_p(ch) (! (ch & ~0xFF))
3490
3491 #endif /* not MULE */
3492
3493 #ifdef ERROR_CHECK_TYPES
3494 3487
3495 DECLARE_INLINE_HEADER ( 3488 DECLARE_INLINE_HEADER (
3496 int 3489 int
3497 CHARP_1 (Lisp_Object obj, const Ascbyte *file, int line) 3490 CHARP_1 (Lisp_Object obj, const Ascbyte *file, int line)
3498 ) 3491 )
3835 /* The following two are only called by the garbage collector */ 3828 /* The following two are only called by the garbage collector */
3836 int finish_marking_weak_lists (void); 3829 int finish_marking_weak_lists (void);
3837 void prune_weak_lists (void); 3830 void prune_weak_lists (void);
3838 3831
3839 END_C_DECLS 3832 END_C_DECLS
3840
3841 /************************************************************************/
3842 /* Definitions related to the format of text and of characters */
3843 /************************************************************************/
3844
3845 /* Note:
3846
3847 "internally formatted text" and the term "internal format" in
3848 general are likely to refer to the format of text in buffers and
3849 strings; "externally formatted text" and the term "external format"
3850 refer to any text format used in the O.S. or elsewhere outside of
3851 XEmacs. The format of text and of a character are related and
3852 there must be a one-to-one relationship (hopefully through a
3853 relatively simple algorithmic means of conversion) between a string
3854 of text and an equivalent array of characters, but the conversion
3855 between the two is NOT necessarily trivial.
3856
3857 In a non-Mule XEmacs, allowed characters are numbered 0 through
3858 255, where no fixed meaning is assigned to them, but (when
3859 representing text, rather than bytes in a binary file) in practice
3860 the lower half represents ASCII and the upper half some other 8-bit
3861 character set (chosen by setting the font, case tables, syntax
3862 tables, etc. appropriately for the character set through ad-hoc
3863 means such as the `iso-8859-1' file and the
3864 `standard-display-european' function).
3865
3866 #### Finish this.
3867
3868 */
3869 #include "text.h"
3870
3871 3833
3872 /************************************************************************/ 3834 /************************************************************************/
3873 /* Definitions of primitive Lisp functions and variables */ 3835 /* Definitions of primitive Lisp functions and variables */
3874 /************************************************************************/ 3836 /************************************************************************/
3875 3837
4049 4011
4050 #define CHECK_FUNCTION(fun) do { \ 4012 #define CHECK_FUNCTION(fun) do { \
4051 while (NILP (Ffunctionp (fun))) \ 4013 while (NILP (Ffunctionp (fun))) \
4052 signal_invalid_function_error (fun); \ 4014 signal_invalid_function_error (fun); \
4053 } while (0) 4015 } while (0)
4016
4017 /************************************************************************/
4018 /* Parsing keyword arguments */
4019 /************************************************************************/
4020
4021 /* The C subr must have been declared with MANY as its max args, and this
4022 PARSE_KEYWORDS call must come before any statements.
4023
4024 FUNCTION is the name of the current function, as a symbol.
4025
4026 NARGS is the count of arguments supplied to FUNCTION.
4027
4028 ARGS is a pointer to the argument vector (not a Lisp vector) supplied to
4029 FUNCTION.
4030
4031 KEYWORDS_OFFSET is the offset into ARGS where the keyword arguments start.
4032
4033 KEYWORD_COUNT is the number of keywords FUNCTION is normally prepared to
4034 handle.
4035
4036 KEYWORDS is a parenthesised list of those keywords, without the initial
4037 Q_.
4038
4039 KEYWORD_DEFAULTS allows you to set non-nil defaults. Put (keywordname =
4040 initial_value) in this parameter, a collection of C statements surrounded
4041 by parentheses and separated by the comma operator. If you don't need
4042 this, supply NULL as KEYWORD_DEFAULTS.
4043
4044 ALLOW_OTHER_KEYS corresponds to the &allow-other-keys argument list
4045 entry in defun*; it is 1 if other keys are normally allowed, 0
4046 otherwise. This may be overridden in the caller by specifying
4047 :allow-other-keys t in the argument list.
4048
4049 For keywords which appear multiple times in the called argument list, the
4050 leftmost one overrides, as specified in section 7.1.1 of the CLHS.
4051
4052 If you want to check whether a given keyword argument was set (as in the
4053 SVAR argument to defun*), supply Qunbound as its default in
4054 KEYWORD_DEFAULTS, and examine it once PARSE_KEYWORDS is done. Lisp code
4055 cannot supply Qunbound as an argument, so if it is still Qunbound, it was
4056 not set.
4057
4058 There is no elegant way with this macro to have one name for the keyword
4059 and an unrelated name for the local variable, as is possible with the
4060 ((:keyword unrelated-var)) syntax in defun* and in Common Lisp. That
4061 shouldn't matter in practice. */
4062
4063 #define PARSE_KEYWORDS(function, nargs, args, keywords_offset, \
4064 keyword_count, keywords, keyword_defaults, \
4065 allow_other_keys) \
4066 DECLARE_N_KEYWORDS_##keyword_count keywords; \
4067 \
4068 do \
4069 { \
4070 Lisp_Object pk_key, pk_value; \
4071 Elemcount pk_i = nargs - 1; \
4072 Boolint pk_allow_other_keys = allow_other_keys; \
4073 \
4074 if ((nargs - keywords_offset) & 1) \
4075 { \
4076 if (!allow_other_keys \
4077 && !(pk_allow_other_keys \
4078 = non_nil_allow_other_keys_p (keywords_offset, \
4079 nargs, args))) \
4080 { \
4081 signal_wrong_number_of_arguments_error (function, nargs); \
4082 } \
4083 else \
4084 { \
4085 /* Ignore the trailing arg; so below always sees an even \
4086 number of arguments. */ \
4087 pk_i -= 1; \
4088 } \
4089 } \
4090 \
4091 (void)(keyword_defaults); \
4092 \
4093 /* Start from the end, because the leftmost element overrides. */ \
4094 while (pk_i > keywords_offset) \
4095 { \
4096 pk_value = args[pk_i--]; \
4097 pk_key = args[pk_i--]; \
4098 \
4099 if (0) {} \
4100 CHECK_N_KEYWORDS_##keyword_count keywords \
4101 else if (allow_other_keys || pk_allow_other_keys) \
4102 { \
4103 continue; \
4104 } \
4105 else if (!(pk_allow_other_keys \
4106 = non_nil_allow_other_keys_p (keywords_offset, \
4107 nargs, args))) \
4108 { \
4109 invalid_keyword_argument (function, pk_key); \
4110 } \
4111 } \
4112 } while (0)
4113
4114 #define DECLARE_N_KEYWORDS_1(a) \
4115 Lisp_Object a = Qnil
4116 #define DECLARE_N_KEYWORDS_2(a,b) \
4117 DECLARE_N_KEYWORDS_1(a), b = Qnil
4118 #define DECLARE_N_KEYWORDS_3(a,b,c) \
4119 DECLARE_N_KEYWORDS_2(a,b), c = Qnil
4120 #define DECLARE_N_KEYWORDS_4(a,b,c,d) \
4121 DECLARE_N_KEYWORDS_3(a,b,c), d = Qnil
4122 #define DECLARE_N_KEYWORDS_5(a,b,c,d,e) \
4123 DECLARE_N_KEYWORDS_4(a,b,c,d), e = Qnil
4124 #define DECLARE_N_KEYWORDS_6(a,b,c,d,e,f) \
4125 DECLARE_N_KEYWORDS_5(a,b,c,d,e), f = Qnil
4126 #define DECLARE_N_KEYWORDS_7(a,b,c,d,e,f,g) \
4127 DECLARE_N_KEYWORDS_6(a,b,c,d,e,f), g = Qnil
4128
4129 #define CHECK_N_KEYWORDS_1(a) \
4130 else if (EQ (pk_key, Q_##a)) { a = pk_value; }
4131 #define CHECK_N_KEYWORDS_2(a,b) CHECK_N_KEYWORDS_1(a) \
4132 else if (EQ (pk_key, Q_##b)) { b = pk_value; }
4133 #define CHECK_N_KEYWORDS_3(a,b,c) CHECK_N_KEYWORDS_2(a,b) \
4134 else if (EQ (pk_key, Q_##c)) { c = pk_value; }
4135 #define CHECK_N_KEYWORDS_4(a,b,c,d) CHECK_N_KEYWORDS_3(a,b,c) \
4136 else if (EQ (pk_key, Q_##d)) { d = pk_value; }
4137 #define CHECK_N_KEYWORDS_5(a,b,c,d,e) CHECK_N_KEYWORDS_4(a,b,c,d) \
4138 else if (EQ (pk_key, Q_##e)) { e = pk_value; }
4139 #define CHECK_N_KEYWORDS_6(a,b,c,d,e,f) CHECK_N_KEYWORDS_5(a,b,c,d,e) \
4140 else if (EQ (pk_key, Q_##f)) { f = pk_value; }
4141 #define CHECK_N_KEYWORDS_7(a,b,c,d,e,f,g) CHECK_N_KEYWORDS_6(a,b,c,d,e,f) \
4142 else if (EQ (pk_key, Q_##g)) { g = pk_value; }
4143
4144 Boolint non_nil_allow_other_keys_p (Elemcount offset, int nargs,
4145 Lisp_Object *args);
4054 4146
4055 4147
4056 /************************************************************************/ 4148 /************************************************************************/
4057 /* Checking for QUIT */ 4149 /* Checking for QUIT */
4058 /************************************************************************/ 4150 /************************************************************************/
4905 4997
4906 extern Lisp_Object Qarith_error, Qbeginning_of_buffer, Qbuffer_read_only, 4998 extern Lisp_Object Qarith_error, Qbeginning_of_buffer, Qbuffer_read_only,
4907 Qcircular_list, Qcircular_property_list, Qconversion_error, 4999 Qcircular_list, Qcircular_property_list, Qconversion_error,
4908 Qcyclic_variable_indirection, Qdomain_error, Qediting_error, 5000 Qcyclic_variable_indirection, Qdomain_error, Qediting_error,
4909 Qend_of_buffer, Qend_of_file, Qerror, Qfile_error, Qinternal_error, 5001 Qend_of_buffer, Qend_of_file, Qerror, Qfile_error, Qinternal_error,
4910 Qinvalid_change, Qinvalid_constant, Qinvalid_function, Qinvalid_operation, 5002 Qinvalid_change, Qinvalid_constant, Qinvalid_function,
5003 Qinvalid_keyword_argument, Qinvalid_operation,
4911 Qinvalid_read_syntax, Qinvalid_state, Qio_error, Qlist_formation_error, 5004 Qinvalid_read_syntax, Qinvalid_state, Qio_error, Qlist_formation_error,
4912 Qmalformed_list, Qmalformed_property_list, Qno_catch, Qout_of_memory, 5005 Qmalformed_list, Qmalformed_property_list, Qno_catch, Qout_of_memory,
4913 Qoverflow_error, Qprinting_unreadable_object, Qquit, Qrange_error, 5006 Qoverflow_error, Qprinting_unreadable_object, Qquit, Qrange_error,
4914 Qsetting_constant, Qsingularity_error, Qstack_overflow, 5007 Qsetting_constant, Qsingularity_error, Qstack_overflow,
4915 Qstructure_formation_error, Qtext_conversion_error, Qunderflow_error, 5008 Qstructure_formation_error, Qtext_conversion_error, Qunderflow_error,
5133 MODULE_API DECLARE_DOESNT_RETURN (invalid_argument_2 (const Ascbyte *reason, 5226 MODULE_API DECLARE_DOESNT_RETURN (invalid_argument_2 (const Ascbyte *reason,
5134 Lisp_Object frob1, 5227 Lisp_Object frob1,
5135 Lisp_Object frob2)); 5228 Lisp_Object frob2));
5136 void maybe_invalid_argument (const Ascbyte *, Lisp_Object, Lisp_Object, 5229 void maybe_invalid_argument (const Ascbyte *, Lisp_Object, Lisp_Object,
5137 Error_Behavior); 5230 Error_Behavior);
5231 MODULE_API DECLARE_DOESNT_RETURN (invalid_keyword_argument (Lisp_Object fun,
5232 Lisp_Object kw));
5138 MODULE_API DECLARE_DOESNT_RETURN (invalid_operation (const Ascbyte *reason, 5233 MODULE_API DECLARE_DOESNT_RETURN (invalid_operation (const Ascbyte *reason,
5139 Lisp_Object frob)); 5234 Lisp_Object frob));
5140 MODULE_API DECLARE_DOESNT_RETURN (invalid_operation_2 (const Ascbyte *reason, 5235 MODULE_API DECLARE_DOESNT_RETURN (invalid_operation_2 (const Ascbyte *reason,
5141 Lisp_Object frob1, 5236 Lisp_Object frob1,
5142 Lisp_Object frob2)); 5237 Lisp_Object frob2));
5526 MODULE_API EXFUN (Freverse, 1); 5621 MODULE_API EXFUN (Freverse, 1);
5527 EXFUN (Fsafe_length, 1); 5622 EXFUN (Fsafe_length, 1);
5528 EXFUN (Fsort, 2); 5623 EXFUN (Fsort, 2);
5529 EXFUN (Fstring_equal, 2); 5624 EXFUN (Fstring_equal, 2);
5530 EXFUN (Fstring_lessp, 2); 5625 EXFUN (Fstring_lessp, 2);
5531 EXFUN (Fsubstring, 3); 5626 EXFUN (Fsubseq, 3);
5532 EXFUN (Fvalid_plist_p, 1); 5627 EXFUN (Fvalid_plist_p, 1);
5533 5628
5534 Lisp_Object list_sort (Lisp_Object, Lisp_Object, 5629 Lisp_Object list_sort (Lisp_Object, Lisp_Object,
5535 int (*) (Lisp_Object, Lisp_Object, Lisp_Object)); 5630 int (*) (Lisp_Object, Lisp_Object, Lisp_Object));
5536 Lisp_Object merge (Lisp_Object, Lisp_Object, Lisp_Object); 5631 Lisp_Object merge (Lisp_Object, Lisp_Object, Lisp_Object);