comparison src/lisp.h @ 5191:71ee43b8a74d

Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API tests/ChangeLog addition: 2010-04-05 Aidan Kehoe <kehoea@parhasard.net> * automated/hash-table-tests.el: Test the new built-in #'equalp hash table test. Test #'define-hash-table-test. * automated/lisp-tests.el: When asserting that two objects are #'equalp, also assert that their #'equalp-hash is identical. man/ChangeLog addition: 2010-04-03 Aidan Kehoe <kehoea@parhasard.net> * lispref/hash-tables.texi (Introduction to Hash Tables): Document that we now support #'equalp as a hash table test by default, and mention #'define-hash-table-test. (Working With Hash Tables): Document #'define-hash-table-test. src/ChangeLog addition: 2010-04-05 Aidan Kehoe <kehoea@parhasard.net> * elhash.h: * elhash.c (struct Hash_Table_Test, lisp_object_eql_equal) (lisp_object_eql_hash, lisp_object_equal_equal) (lisp_object_equal_hash, lisp_object_equalp_hash) (lisp_object_equalp_equal, lisp_object_general_hash) (lisp_object_general_equal, Feq_hash, Feql_hash, Fequal_hash) (Fequalp_hash, define_hash_table_test, Fdefine_hash_table_test) (init_elhash_once_early, mark_hash_table_tests, string_equalp_hash): * glyphs.c (vars_of_glyphs): Add a new hash table test in C, #'equalp. Make it possible to specify new hash table tests with functions define_hash_table_test, #'define-hash-table-test. Use define_hash_table_test() in glyphs.c. Expose the hash functions (besides that used for #'equal) to Lisp, for people writing functions to be used with #'define-hash-table-test. Call define_hash_table_test() very early in temacs, to create the built-in hash table tests. * ui-gtk.c (emacs_gtk_boxed_hash): * specifier.h (struct specifier_methods): * specifier.c (specifier_hash): * rangetab.c (range_table_entry_hash, range_table_hash): * number.c (bignum_hash, ratio_hash, bigfloat_hash): * marker.c (marker_hash): * lrecord.h (struct lrecord_implementation): * keymap.c (keymap_hash): * gui.c (gui_item_id_hash, gui_item_hash): * glyphs.c (image_instance_hash, glyph_hash): * glyphs-x.c (x_image_instance_hash): * glyphs-msw.c (mswindows_image_instance_hash): * glyphs-gtk.c (gtk_image_instance_hash): * frame-msw.c (mswindows_set_title_from_ibyte): * fontcolor.c (color_instance_hash, font_instance_hash): * fontcolor-x.c (x_color_instance_hash): * fontcolor-tty.c (tty_color_instance_hash): * fontcolor-msw.c (mswindows_color_instance_hash): * fontcolor-gtk.c (gtk_color_instance_hash): * fns.c (bit_vector_hash): * floatfns.c (float_hash): * faces.c (face_hash): * extents.c (extent_hash): * events.c (event_hash): * data.c (weak_list_hash, weak_box_hash): * chartab.c (char_table_entry_hash, char_table_hash): * bytecode.c (compiled_function_hash): * alloc.c (vector_hash): Change the various object hash methods to take a new EQUALP parameter, hashing appropriately for #'equalp if it is true.
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 05 Apr 2010 13:03:35 +0100
parents 1c1d8843de5e
children 70ed8a0d8da8
comparison
equal deleted inserted replaced
5190:1c1d8843de5e 5191:71ee43b8a74d
117 #include <ctype.h> 117 #include <ctype.h>
118 #include <stdarg.h> 118 #include <stdarg.h>
119 #include <stddef.h> /* offsetof */ 119 #include <stddef.h> /* offsetof */
120 #include <sys/types.h> 120 #include <sys/types.h>
121 #include <limits.h> 121 #include <limits.h>
122 #include <math.h>
122 #ifdef __cplusplus 123 #ifdef __cplusplus
123 #include <limits> /* necessary for max()/min() under G++ 4 */ 124 #include <limits> /* necessary for max()/min() under G++ 4 */
124 #endif 125 #endif
125 126
126 127
2902 2903
2903 #endif /* (not) ERROR_CHECK_TYPES */ 2904 #endif /* (not) ERROR_CHECK_TYPES */
2904 2905
2905 #define CHECK_INT(x) do { \ 2906 #define CHECK_INT(x) do { \
2906 if (!INTP (x)) \ 2907 if (!INTP (x)) \
2907 dead_wrong_type_argument (Qintegerp, x); \ 2908 dead_wrong_type_argument (Qfixnump, x); \
2908 } while (0) 2909 } while (0)
2909 2910
2910 #define CONCHECK_INT(x) do { \ 2911 #define CONCHECK_INT(x) do { \
2911 if (!INTP (x)) \ 2912 if (!INTP (x)) \
2912 x = wrong_type_argument (Qintegerp, x); \ 2913 x = wrong_type_argument (Qfixnump, x); \
2913 } while (0) 2914 } while (0)
2914 2915
2915 /* NOTE NOTE NOTE! This definition of "natural number" is mathematically 2916 /* NOTE NOTE NOTE! This definition of "natural number" is mathematically
2916 wrong. Mathematically, a natural number is a positive integer; 0 2917 wrong. Mathematically, a natural number is a positive integer; 0
2917 isn't included. This would be better called NONNEGINT(). */ 2918 isn't included. This would be better called NONNEGINT(). */
3127 if (!INT_OR_FLOATP (x)) \ 3128 if (!INT_OR_FLOATP (x)) \
3128 x = wrong_type_argument (Qnumberp, x); \ 3129 x = wrong_type_argument (Qnumberp, x); \
3129 } while (0) 3130 } while (0)
3130 3131
3131 # define INT_OR_FLOATP(x) (INTP (x) || FLOATP (x)) 3132 # define INT_OR_FLOATP(x) (INTP (x) || FLOATP (x))
3133
3134 /* #### change for 64-bit machines */
3135 #define FLOAT_HASHCODE_FROM_DOUBLE(dbl) \
3136 (unsigned long)(fmod (dbl, 4e9))
3132 3137
3133 /*--------------------------- readonly objects -------------------------*/ 3138 /*--------------------------- readonly objects -------------------------*/
3134 3139
3135 #ifndef NEW_GC 3140 #ifndef NEW_GC
3136 #define CHECK_C_WRITEABLE(obj) \ 3141 #define CHECK_C_WRITEABLE(obj) \
3703 #define HASH8(a,b,c,d,e,f,g,h) (GOOD_HASH * HASH7 (a,b,c,d,e,f,g) + (h)) 3708 #define HASH8(a,b,c,d,e,f,g,h) (GOOD_HASH * HASH7 (a,b,c,d,e,f,g) + (h))
3704 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i)) 3709 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i))
3705 3710
3706 #define LISP_HASH(obj) ((unsigned long) STORE_LISP_IN_VOID (obj)) 3711 #define LISP_HASH(obj) ((unsigned long) STORE_LISP_IN_VOID (obj))
3707 Hashcode memory_hash (const void *xv, Bytecount size); 3712 Hashcode memory_hash (const void *xv, Bytecount size);
3708 Hashcode internal_hash (Lisp_Object obj, int depth); 3713 Hashcode internal_hash (Lisp_Object obj, int depth, Boolint equalp);
3709 Hashcode internal_array_hash (Lisp_Object *arr, int size, int depth); 3714 Hashcode internal_array_hash (Lisp_Object *arr, int size, int depth,
3715 Boolint equalp);
3710 3716
3711 3717
3712 /************************************************************************/ 3718 /************************************************************************/
3713 /* String translation */ 3719 /* String translation */
3714 /************************************************************************/ 3720 /************************************************************************/
5253 #undef SYMBOL 5259 #undef SYMBOL
5254 #undef SYMBOL_MODULE_API 5260 #undef SYMBOL_MODULE_API
5255 #undef SYMBOL_KEYWORD 5261 #undef SYMBOL_KEYWORD
5256 #undef SYMBOL_GENERAL 5262 #undef SYMBOL_GENERAL
5257 5263
5264 extern Lisp_Object Qeq;
5265 extern Lisp_Object Qeql;
5266 extern Lisp_Object Qequal;
5267 extern Lisp_Object Qequalp;
5268
5258 /* Defined in glyphs.c */ 5269 /* Defined in glyphs.c */
5259 EXFUN (Fmake_glyph_internal, 1); 5270 EXFUN (Fmake_glyph_internal, 1);
5260 5271
5261 Error_Behavior decode_error_behavior_flag (Lisp_Object); 5272 Error_Behavior decode_error_behavior_flag (Lisp_Object);
5262 Lisp_Object encode_error_behavior_flag (Error_Behavior); 5273 Lisp_Object encode_error_behavior_flag (Error_Behavior);