Mercurial > hg > xemacs-beta
comparison src/keymap.c @ 5581:56144c8593a8
Mechanically change INT to FIXNUM in our sources.
src/ChangeLog addition:
2011-10-09 Aidan Kehoe <kehoea@parhasard.net>
[...]
Mechanically change INT (where it refers to non-bignum Lisp
integers) to FIXNUM in our sources. Done for the following
functions, enums, and macros: Lisp_Type_Int_Even,
Lisp_Type_Int_Odd, INT_GCBITS, INT_VALBITS, make_int(), INTP(),
XINT(), CHECK_INT(), XREALINT(), INT_PLUS(), INT_MINUS(),
EMACS_INT_MAX (to MOST_POSITIVE_FIXNUM), EMACS_INT_MIN (to
MOST_NEGATIVE_FIXNUM), NUMBER_FITS_IN_AN_EMACS_INT() to
NUMBER_FITS_IN_A_FIXNUM(), XFLOATINT, XCHAR_OR_INT, INT_OR_FLOAT.
The EMACS_INT typedef was not changed, it does not describe
non-bignum Lisp integers.
Script that did the change available in
http://mid.gmane.org/20067.17650.181273.12014@parhasard.net .
modules/ChangeLog addition:
2011-10-09 Aidan Kehoe <kehoea@parhasard.net>
[...]
Mechanically change INT to FIXNUM, where the usage describes non-bignum
Lisp integers. See the src/ChangeLog entry for more details.
man/ChangeLog addition:
2011-10-09 Aidan Kehoe <kehoea@parhasard.net>
* internals/internals.texi (How Lisp Objects Are Represented in C):
* internals/internals.texi (Integers and Characters):
Mechanically change INT to FIXNUM, where the usage describes non-bignum
Lisp integers.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 09 Oct 2011 09:51:57 +0100 |
parents | 0af042a0c116 |
children | a81a739181dc |
comparison
equal
deleted
inserted
replaced
5580:a0e81357194e | 5581:56144c8593a8 |
---|---|
149 NORMAL_LISP_OBJECT_HEADER header; | 149 NORMAL_LISP_OBJECT_HEADER header; |
150 #define MARKED_SLOT(x) Lisp_Object x; | 150 #define MARKED_SLOT(x) Lisp_Object x; |
151 #include "keymap-slots.h" | 151 #include "keymap-slots.h" |
152 }; | 152 }; |
153 | 153 |
154 #define MAKE_MODIFIER_HASH_KEY(modifier) make_int (modifier) | 154 #define MAKE_MODIFIER_HASH_KEY(modifier) make_fixnum (modifier) |
155 #define MODIFIER_HASH_KEY_BITS(x) (INTP (x) ? XINT (x) : 0) | 155 #define MODIFIER_HASH_KEY_BITS(x) (FIXNUMP (x) ? XFIXNUM (x) : 0) |
156 | 156 |
157 | 157 |
158 | 158 |
159 /* Actually allocate storage for these variables */ | 159 /* Actually allocate storage for these variables */ |
160 | 160 |
287 if (!NILP (keymap->name)) | 287 if (!NILP (keymap->name)) |
288 { | 288 { |
289 write_fmt_string_lisp (printcharfun, "%S ", 1, keymap->name); | 289 write_fmt_string_lisp (printcharfun, "%S ", 1, keymap->name); |
290 } | 290 } |
291 write_fmt_string (printcharfun, "size %ld 0x%x>", | 291 write_fmt_string (printcharfun, "size %ld 0x%x>", |
292 (long) XINT (Fkeymap_fullness (obj)), | 292 (long) XFIXNUM (Fkeymap_fullness (obj)), |
293 LISP_OBJECT_UID (obj)); | 293 LISP_OBJECT_UID (obj)); |
294 } | 294 } |
295 | 295 |
296 static const struct memory_description keymap_description[] = { | 296 static const struct memory_description keymap_description[] = { |
297 #define MARKED_SLOT(x) { XD_LISP_OBJECT, offsetof (Lisp_Keymap, x) }, | 297 #define MARKED_SLOT(x) { XD_LISP_OBJECT, offsetof (Lisp_Keymap, x) }, |
1079 indirection.modifiers = XEVENT_KEY_MODIFIERS (event); | 1079 indirection.modifiers = XEVENT_KEY_MODIFIERS (event); |
1080 UNGCPRO; | 1080 UNGCPRO; |
1081 } | 1081 } |
1082 else if (CONSP (idx)) | 1082 else if (CONSP (idx)) |
1083 { | 1083 { |
1084 if (!INTP (XCDR (idx))) | 1084 if (!FIXNUMP (XCDR (idx))) |
1085 return Qnil; | 1085 return Qnil; |
1086 indirection.keysym = XCAR (idx); | 1086 indirection.keysym = XCAR (idx); |
1087 indirection.modifiers = (unsigned char) XINT (XCDR (idx)); | 1087 indirection.modifiers = (unsigned char) XFIXNUM (XCDR (idx)); |
1088 } | 1088 } |
1089 else if (SYMBOLP (idx)) | 1089 else if (SYMBOLP (idx)) |
1090 { | 1090 { |
1091 indirection.keysym = idx; | 1091 indirection.keysym = idx; |
1092 SET_KEY_DATA_MODIFIERS (&indirection, XINT (XCDR (idx))); | 1092 SET_KEY_DATA_MODIFIERS (&indirection, XFIXNUM (XCDR (idx))); |
1093 } | 1093 } |
1094 else | 1094 else |
1095 { | 1095 { |
1096 /* Random junk */ | 1096 /* Random junk */ |
1097 return Qnil; | 1097 return Qnil; |
1235 int fullness; | 1235 int fullness; |
1236 Lisp_Object sub_maps; | 1236 Lisp_Object sub_maps; |
1237 struct gcpro gcpro1, gcpro2; | 1237 struct gcpro gcpro1, gcpro2; |
1238 | 1238 |
1239 keymap = get_keymap (keymap, 1, 1); | 1239 keymap = get_keymap (keymap, 1, 1); |
1240 fullness = XINT (Fhash_table_count (XKEYMAP (keymap)->table)); | 1240 fullness = XFIXNUM (Fhash_table_count (XKEYMAP (keymap)->table)); |
1241 GCPRO2 (keymap, sub_maps); | 1241 GCPRO2 (keymap, sub_maps); |
1242 for (sub_maps = keymap_submaps (keymap); | 1242 for (sub_maps = keymap_submaps (keymap); |
1243 !NILP (sub_maps); | 1243 !NILP (sub_maps); |
1244 sub_maps = XCDR (sub_maps)) | 1244 sub_maps = XCDR (sub_maps)) |
1245 { | 1245 { |
1258 Return the number of bindings in the keymap. | 1258 Return the number of bindings in the keymap. |
1259 */ | 1259 */ |
1260 (keymap)) | 1260 (keymap)) |
1261 { | 1261 { |
1262 /* This function can GC */ | 1262 /* This function can GC */ |
1263 return make_int (keymap_fullness (get_keymap (keymap, 1, 1))); | 1263 return make_fixnum (keymap_fullness (get_keymap (keymap, 1, 1))); |
1264 } | 1264 } |
1265 | 1265 |
1266 | 1266 |
1267 /************************************************************************/ | 1267 /************************************************************************/ |
1268 /* Defining keys in keymaps */ | 1268 /* Defining keys in keymaps */ |
1554 Lisp_Object event2 = Qnil; | 1554 Lisp_Object event2 = Qnil; |
1555 int retval; | 1555 int retval; |
1556 struct gcpro gcpro1; | 1556 struct gcpro gcpro1; |
1557 | 1557 |
1558 if (XEVENT_TYPE (event) != key_press_event || NILP (key_specifier) || | 1558 if (XEVENT_TYPE (event) != key_press_event || NILP (key_specifier) || |
1559 (INTP (key_specifier) && !CHAR_INTP (key_specifier))) | 1559 (FIXNUMP (key_specifier) && !CHAR_INTP (key_specifier))) |
1560 return 0; | 1560 return 0; |
1561 | 1561 |
1562 /* if the specifier is an integer such as 27, then it should match | 1562 /* if the specifier is an integer such as 27, then it should match |
1563 both of the events `escape' and `control ['. Calling | 1563 both of the events `escape' and `control ['. Calling |
1564 Fcharacter_to_event() will only match `escape'. */ | 1564 Fcharacter_to_event() will only match `escape'. */ |
1720 Lisp_Object new_keys; | 1720 Lisp_Object new_keys; |
1721 int i; | 1721 int i; |
1722 Lisp_Object mpc_binding; | 1722 Lisp_Object mpc_binding; |
1723 Lisp_Key_Data meta_key; | 1723 Lisp_Key_Data meta_key; |
1724 if (NILP (Vmeta_prefix_char) || | 1724 if (NILP (Vmeta_prefix_char) || |
1725 (INTP (Vmeta_prefix_char) && !CHAR_INTP (Vmeta_prefix_char))) | 1725 (FIXNUMP (Vmeta_prefix_char) && !CHAR_INTP (Vmeta_prefix_char))) |
1726 return; | 1726 return; |
1727 | 1727 |
1728 define_key_parser (Vmeta_prefix_char, &meta_key); | 1728 define_key_parser (Vmeta_prefix_char, &meta_key); |
1729 mpc_binding = keymap_lookup_1 (keymap, &meta_key, 0); | 1729 mpc_binding = keymap_lookup_1 (keymap, &meta_key, 0); |
1730 if (NILP (mpc_binding) || !NILP (Fkeymapp (mpc_binding))) | 1730 if (NILP (mpc_binding) || !NILP (Fkeymapp (mpc_binding))) |
1731 return; | 1731 return; |
1732 | 1732 |
1733 if (indx == 0) | 1733 if (indx == 0) |
1734 new_keys = keys; | 1734 new_keys = keys; |
1735 else if (STRINGP (keys)) | 1735 else if (STRINGP (keys)) |
1736 new_keys = Fsubseq (keys, Qzero, make_int (indx)); | 1736 new_keys = Fsubseq (keys, Qzero, make_fixnum (indx)); |
1737 else if (VECTORP (keys)) | 1737 else if (VECTORP (keys)) |
1738 { | 1738 { |
1739 new_keys = make_vector (indx, Qnil); | 1739 new_keys = make_vector (indx, Qnil); |
1740 for (i = 0; i < indx; i++) | 1740 for (i = 0; i < indx; i++) |
1741 XVECTOR_DATA (new_keys) [i] = XVECTOR_DATA (keys) [i]; | 1741 XVECTOR_DATA (new_keys) [i] = XVECTOR_DATA (keys) [i]; |
1907 keys = make_vector (1, keys); /* this is kinda sleazy. */ | 1907 keys = make_vector (1, keys); /* this is kinda sleazy. */ |
1908 } | 1908 } |
1909 else | 1909 else |
1910 { | 1910 { |
1911 keys = wrong_type_argument (Qsequencep, keys); | 1911 keys = wrong_type_argument (Qsequencep, keys); |
1912 len = XINT (Flength (keys)); | 1912 len = XFIXNUM (Flength (keys)); |
1913 } | 1913 } |
1914 if (len == 0) | 1914 if (len == 0) |
1915 return Qnil; | 1915 return Qnil; |
1916 | 1916 |
1917 GCPRO3 (keymap, keys, def); | 1917 GCPRO3 (keymap, keys, def); |
2098 ; | 2098 ; |
2099 else if (NILP (Fkeymapp (cmd))) | 2099 else if (NILP (Fkeymapp (cmd))) |
2100 /* Didn't find a keymap, and we have more keys. | 2100 /* Didn't find a keymap, and we have more keys. |
2101 * Return a fixnum to indicate that keys were too long. | 2101 * Return a fixnum to indicate that keys were too long. |
2102 */ | 2102 */ |
2103 cmd = make_int (keys_so_far + 1); | 2103 cmd = make_fixnum (keys_so_far + 1); |
2104 else | 2104 else |
2105 cmd = raw_lookup_key (cmd, raw_keys + 1, remaining, | 2105 cmd = raw_lookup_key (cmd, raw_keys + 1, remaining, |
2106 keys_so_far + 1, accept_default); | 2106 keys_so_far + 1, accept_default); |
2107 } | 2107 } |
2108 else | 2108 else |
2218 * on somebody else somewhere (obarray) having a pointer to all keysyms. */ | 2218 * on somebody else somewhere (obarray) having a pointer to all keysyms. */ |
2219 for (iii = 0; iii < nmaps; iii++) | 2219 for (iii = 0; iii < nmaps; iii++) |
2220 { | 2220 { |
2221 tem = raw_lookup_key (keymaps[iii], raw_keys, nkeys, 0, | 2221 tem = raw_lookup_key (keymaps[iii], raw_keys, nkeys, 0, |
2222 accept_default); | 2222 accept_default); |
2223 if (INTP (tem)) | 2223 if (FIXNUMP (tem)) |
2224 { | 2224 { |
2225 /* Too long in some local map means don't look at global map */ | 2225 /* Too long in some local map means don't look at global map */ |
2226 tem = Qnil; | 2226 tem = Qnil; |
2227 break; | 2227 break; |
2228 } | 2228 } |
2375 /* The terminal element of the lookup may be nil or a keysym. | 2375 /* The terminal element of the lookup may be nil or a keysym. |
2376 In those cases we don't want to check for an extent | 2376 In those cases we don't want to check for an extent |
2377 keymap. */ | 2377 keymap. */ |
2378 if (EVENTP (terminal)) | 2378 if (EVENTP (terminal)) |
2379 { | 2379 { |
2380 get_relevant_extent_keymaps (make_int (BUF_PT (current_buffer)), | 2380 get_relevant_extent_keymaps (make_fixnum (BUF_PT (current_buffer)), |
2381 tem, Qnil, &closure); | 2381 tem, Qnil, &closure); |
2382 } | 2382 } |
2383 get_relevant_minor_maps (tem, &closure); | 2383 get_relevant_minor_maps (tem, &closure); |
2384 | 2384 |
2385 tem = current_buffer->keymap; | 2385 tem = current_buffer->keymap; |
2668 | 2668 |
2669 for (i = 0; i < nmaps; i++) | 2669 for (i = 0; i < nmaps; i++) |
2670 { | 2670 { |
2671 Lisp_Object tem = Flookup_key (maps[i], keys, | 2671 Lisp_Object tem = Flookup_key (maps[i], keys, |
2672 accept_default); | 2672 accept_default); |
2673 if (INTP (tem)) | 2673 if (FIXNUMP (tem)) |
2674 { | 2674 { |
2675 /* Too long in some local map means don't look at global map */ | 2675 /* Too long in some local map means don't look at global map */ |
2676 return Qnil; | 2676 return Qnil; |
2677 } | 2677 } |
2678 else if (!NILP (tem)) | 2678 else if (!NILP (tem)) |
2979 { | 2979 { |
2980 /* This function can GC */ | 2980 /* This function can GC */ |
2981 struct gcpro gcpro1; | 2981 struct gcpro gcpro1; |
2982 Lisp_Object contents = Qnil; | 2982 Lisp_Object contents = Qnil; |
2983 | 2983 |
2984 if (XINT (Fhash_table_count (keymap_table)) == 0) | 2984 if (XFIXNUM (Fhash_table_count (keymap_table)) == 0) |
2985 return; | 2985 return; |
2986 | 2986 |
2987 GCPRO1 (contents); | 2987 GCPRO1 (contents); |
2988 | 2988 |
2989 { | 2989 { |
3191 { | 3191 { |
3192 prefix = make_vector (0, Qnil); | 3192 prefix = make_vector (0, Qnil); |
3193 } | 3193 } |
3194 else if (VECTORP (prefix) || STRINGP (prefix)) | 3194 else if (VECTORP (prefix) || STRINGP (prefix)) |
3195 { | 3195 { |
3196 int len = XINT (Flength (prefix)); | 3196 int len = XFIXNUM (Flength (prefix)); |
3197 Lisp_Object def; | 3197 Lisp_Object def; |
3198 Lisp_Object p; | 3198 Lisp_Object p; |
3199 int iii; | 3199 int iii; |
3200 struct gcpro ngcpro1; | 3200 struct gcpro ngcpro1; |
3201 | 3201 |
3214 p = make_vector (len, Qnil); | 3214 p = make_vector (len, Qnil); |
3215 NGCPRO1 (p); | 3215 NGCPRO1 (p); |
3216 for (iii = 0; iii < len; iii++) | 3216 for (iii = 0; iii < len; iii++) |
3217 { | 3217 { |
3218 Lisp_Key_Data key; | 3218 Lisp_Key_Data key; |
3219 define_key_parser (Faref (prefix, make_int (iii)), &key); | 3219 define_key_parser (Faref (prefix, make_fixnum (iii)), &key); |
3220 XVECTOR_DATA (p)[iii] = make_key_description (&key, 1); | 3220 XVECTOR_DATA (p)[iii] = make_key_description (&key, 1); |
3221 } | 3221 } |
3222 NUNGCPRO; | 3222 NUNGCPRO; |
3223 prefix = p; | 3223 prefix = p; |
3224 } | 3224 } |
3268 else if (VECTORP (keys) || | 3268 else if (VECTORP (keys) || |
3269 STRINGP (keys)) | 3269 STRINGP (keys)) |
3270 { | 3270 { |
3271 Lisp_Object string = Qnil; | 3271 Lisp_Object string = Qnil; |
3272 /* Lisp_Object sep = Qnil; */ | 3272 /* Lisp_Object sep = Qnil; */ |
3273 int size = XINT (Flength (keys)); | 3273 int size = XFIXNUM (Flength (keys)); |
3274 int i; | 3274 int i; |
3275 | 3275 |
3276 for (i = 0; i < size; i++) | 3276 for (i = 0; i < size; i++) |
3277 { | 3277 { |
3278 Lisp_Object s2 = Fsingle_key_description | 3278 Lisp_Object s2 = Fsingle_key_description |
3494 else if (CONSP (keymaps)) | 3494 else if (CONSP (keymaps)) |
3495 { | 3495 { |
3496 Lisp_Object rest; | 3496 Lisp_Object rest; |
3497 int i; | 3497 int i; |
3498 | 3498 |
3499 nmaps = XINT (Flength (keymaps)); | 3499 nmaps = XFIXNUM (Flength (keymaps)); |
3500 if (nmaps > countof (maps)) | 3500 if (nmaps > countof (maps)) |
3501 { | 3501 { |
3502 gubbish = alloca_array (Lisp_Object, nmaps); | 3502 gubbish = alloca_array (Lisp_Object, nmaps); |
3503 } | 3503 } |
3504 for (rest = keymaps, i = 0; !NILP (rest); | 3504 for (rest = keymaps, i = 0; !NILP (rest); |
3664 /* OK, the key is for real */ | 3664 /* OK, the key is for real */ |
3665 if (target_buffer) | 3665 if (target_buffer) |
3666 { | 3666 { |
3667 assert (firstonly); | 3667 assert (firstonly); |
3668 format_raw_keys (so_far, keys_count + 1, target_buffer); | 3668 format_raw_keys (so_far, keys_count + 1, target_buffer); |
3669 return make_int (1); | 3669 return make_fixnum (1); |
3670 } | 3670 } |
3671 else if (firstonly) | 3671 else if (firstonly) |
3672 return raw_keys_to_keys (so_far, keys_count + 1); | 3672 return raw_keys_to_keys (so_far, keys_count + 1); |
3673 else | 3673 else |
3674 result = Fcons (raw_keys_to_keys (so_far, keys_count + 1), | 3674 result = Fcons (raw_keys_to_keys (so_far, keys_count + 1), |
3870 { | 3870 { |
3871 Lisp_Object sub_shadow = Qnil; | 3871 Lisp_Object sub_shadow = Qnil; |
3872 Lisp_Object elt = Fcar (maps); | 3872 Lisp_Object elt = Fcar (maps); |
3873 Lisp_Object tail; | 3873 Lisp_Object tail; |
3874 int no_prefix = (VECTORP (Fcar (elt)) | 3874 int no_prefix = (VECTORP (Fcar (elt)) |
3875 && XINT (Flength (Fcar (elt))) == 0); | 3875 && XFIXNUM (Flength (Fcar (elt))) == 0); |
3876 struct gcpro ngcpro1, ngcpro2, ngcpro3; | 3876 struct gcpro ngcpro1, ngcpro2, ngcpro3; |
3877 NGCPRO3 (sub_shadow, elt, tail); | 3877 NGCPRO3 (sub_shadow, elt, tail); |
3878 | 3878 |
3879 for (tail = shadow; CONSP (tail); tail = XCDR (tail)) | 3879 for (tail = shadow; CONSP (tail); tail = XCDR (tail)) |
3880 { | 3880 { |
3933 /* This function can GC */ | 3933 /* This function can GC */ |
3934 int keymapp = !NILP (Fkeymapp (definition)); | 3934 int keymapp = !NILP (Fkeymapp (definition)); |
3935 struct gcpro gcpro1; | 3935 struct gcpro gcpro1; |
3936 GCPRO1 (definition); | 3936 GCPRO1 (definition); |
3937 | 3937 |
3938 Findent_to (make_int (16), make_int (3), buffer); | 3938 Findent_to (make_fixnum (16), make_fixnum (3), buffer); |
3939 if (keymapp) | 3939 if (keymapp) |
3940 buffer_insert_ascstring (XBUFFER (buffer), "<< "); | 3940 buffer_insert_ascstring (XBUFFER (buffer), "<< "); |
3941 | 3941 |
3942 if (SYMBOLP (definition)) | 3942 if (SYMBOLP (definition)) |
3943 { | 3943 { |
4076 if (!NILP (sh) && !ZEROP (sh)) | 4076 if (!NILP (sh) && !ZEROP (sh)) |
4077 return; | 4077 return; |
4078 } | 4078 } |
4079 | 4079 |
4080 /* Otherwise add it to the list to be sorted. */ | 4080 /* Otherwise add it to the list to be sorted. */ |
4081 *(closure->list) = Fcons (Fcons (Fcons (keysym, make_int (modifiers)), | 4081 *(closure->list) = Fcons (Fcons (Fcons (keysym, make_fixnum (modifiers)), |
4082 binding), | 4082 binding), |
4083 *(closure->list)); | 4083 *(closure->list)); |
4084 } | 4084 } |
4085 | 4085 |
4086 static Boolint | 4086 static Boolint |
4093 keysym and modifiers are used, binding is ignored. | 4093 keysym and modifiers are used, binding is ignored. |
4094 */ | 4094 */ |
4095 int bit1, bit2; | 4095 int bit1, bit2; |
4096 obj1 = XCAR (obj1); | 4096 obj1 = XCAR (obj1); |
4097 obj2 = XCAR (obj2); | 4097 obj2 = XCAR (obj2); |
4098 bit1 = XINT (XCDR (obj1)); | 4098 bit1 = XFIXNUM (XCDR (obj1)); |
4099 bit2 = XINT (XCDR (obj2)); | 4099 bit2 = XFIXNUM (XCDR (obj2)); |
4100 if (bit1 != bit2) | 4100 if (bit1 != bit2) |
4101 return bit1 < bit2; | 4101 return bit1 < bit2; |
4102 else | 4102 else |
4103 return map_keymap_sort_predicate (pred, key_func, obj1, obj2); | 4103 return map_keymap_sort_predicate (pred, key_func, obj1, obj2); |
4104 } | 4104 } |
4212 buffer_insert_ascstring (buf, "\n"); | 4212 buffer_insert_ascstring (buf, "\n"); |
4213 while (!NILP (list)) | 4213 while (!NILP (list)) |
4214 { | 4214 { |
4215 Lisp_Object elt = XCAR (XCAR (list)); | 4215 Lisp_Object elt = XCAR (XCAR (list)); |
4216 Lisp_Object keysym = XCAR (elt); | 4216 Lisp_Object keysym = XCAR (elt); |
4217 int modifiers = XINT (XCDR (elt)); | 4217 int modifiers = XFIXNUM (XCDR (elt)); |
4218 | 4218 |
4219 if (!NILP (elt_prefix)) | 4219 if (!NILP (elt_prefix)) |
4220 buffer_insert_lisp_string (buf, elt_prefix); | 4220 buffer_insert_lisp_string (buf, elt_prefix); |
4221 | 4221 |
4222 if (modifiers & XEMACS_MOD_META) | 4222 if (modifiers & XEMACS_MOD_META) |