Mercurial > hg > xemacs-beta
annotate src/number-mp.h @ 4906:6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
-------------------- ChangeLog entries follow: --------------------
lisp/ChangeLog addition:
2010-02-01 Ben Wing <ben@xemacs.org>
* cl-extra.el:
* cl-extra.el (cl-string-vector-equalp): Removed.
* cl-extra.el (cl-bit-vector-vector-equalp): Removed.
* cl-extra.el (cl-vector-array-equalp): Removed.
* cl-extra.el (cl-hash-table-contents-equalp): Removed.
* cl-extra.el (equalp): Removed.
* cl-extra.el (cl-mapcar-many):
Comment out the whole `equalp' implementation for the moment;
remove once we're sure the C implementation works.
* cl-macs.el:
* cl-macs.el (equalp):
Simplify the compiler-macro for `equalp' -- once it's in C,
we don't need to try so hard to expand it.
src/ChangeLog addition:
2010-02-01 Ben Wing <ben@xemacs.org>
* abbrev.c (abbrev_match_mapper):
* buffer.h (CANON_TABLE_OF):
* buffer.h:
* editfns.c (Fchar_equal):
* minibuf.c (scmp_1):
* text.c (qxestrcasecmp_i18n):
* text.c (qxestrncasecmp_i18n):
* text.c (qxetextcasecmp):
* text.c (qxetextcasecmp_matching):
Create new macro CANONCASE that converts to a canonical mapping
and use it to do caseless comparisons instead of DOWNCASE.
* alloc.c:
* alloc.c (cons_equal):
* alloc.c (vector_equal):
* alloc.c (string_equal):
* bytecode.c (compiled_function_equal):
* chartab.c (char_table_entry_equal):
* chartab.c (char_table_equal):
* data.c (weak_list_equal):
* data.c (weak_box_equal):
* data.c (ephemeron_equal):
* device-msw.c (equal_devmode):
* elhash.c (hash_table_equal):
* events.c (event_equal):
* extents.c (properties_equal):
* extents.c (extent_equal):
* faces.c:
* faces.c (face_equal):
* faces.c (face_hash):
* floatfns.c (float_equal):
* fns.c:
* fns.c (bit_vector_equal):
* fns.c (plists_differ):
* fns.c (Fplists_eq):
* fns.c (Fplists_equal):
* fns.c (Flax_plists_eq):
* fns.c (Flax_plists_equal):
* fns.c (internal_equal):
* fns.c (internal_equalp):
* fns.c (internal_equal_0):
* fns.c (syms_of_fns):
* glyphs.c (image_instance_equal):
* glyphs.c (glyph_equal):
* glyphs.c (glyph_hash):
* gui.c (gui_item_equal):
* lisp.h:
* lrecord.h (struct lrecord_implementation):
* marker.c (marker_equal):
* number.c (bignum_equal):
* number.c (ratio_equal):
* number.c (bigfloat_equal):
* objects.c (color_instance_equal):
* objects.c (font_instance_equal):
* opaque.c (equal_opaque):
* opaque.c (equal_opaque_ptr):
* rangetab.c (range_table_equal):
* specifier.c (specifier_equal):
Add a `foldcase' param to the equal() method and use it to implement
`equalp' comparisons. Also add to plists_differ(), although we
don't currently use it here.
Rewrite internal_equalp(). Implement cross-type vector comparisons.
Don't implement our own handling of numeric promotion -- just use
the `=' primitive.
Add internal_equal_0(), which takes a `foldcase' param and calls
either internal_equal() or internal_equalp().
* buffer.h:
When given a 0 for buffer (which is the norm when functions don't
have a specific buffer available), use the current buffer's table,
not `standard-case-table'; otherwise the current settings are
ignored.
* casetab.c:
* casetab.c (set_case_table):
When handling old-style vectors of 256 in `set-case-table' don't
overwrite the existing table! Instead create a new table and
populate.
* device-msw.c (sync_printer_with_devmode):
* lisp.h:
* text.c (lisp_strcasecmp_ascii):
Rename lisp_strcasecmp to lisp_strcasecmp_ascii and use
lisp_strcasecmp_i18n for caseless comparisons in some places.
* elhash.c:
Delete unused lisp_string_hash and lisp_string_equal().
* events.h:
* keymap-buttons.h:
* keymap.h:
* keymap.c (keymap_lookup_directly):
* keymap.c (keymap_store):
* keymap.c (FROB):
* keymap.c (key_desc_list_to_event):
* keymap.c (describe_map_mapper):
* keymap.c (INCLUDE_BUTTON_ZERO):
New file keymap-buttons.h; use to handle buttons 1-26 in place of
duplicating code 26 times.
* frame-gtk.c (allocate_gtk_frame_struct):
* frame-msw.c (mswindows_init_frame_1):
Fix some comments about internal_equal() in redisplay that don't
apply any more.
* keymap-slots.h:
* keymap.c:
New file keymap-slots.h. Use it to notate the slots in a keymap
structure, similar to frameslots.h or coding-system-slots.h.
* keymap.c (MARKED_SLOT):
* keymap.c (keymap_equal):
* keymap.c (keymap_hash):
Implement.
tests/ChangeLog addition:
2010-02-01 Ben Wing <ben@xemacs.org>
* automated/case-tests.el:
* automated/case-tests.el (uni-mappings):
* automated/search-tests.el:
Delete old pristine-case-table code. Rewrite the Unicode torture
test to take into account whether overlapping mappings exist for
more than one character, and not doing the upcase/downcase
comparisons in such cases.
* automated/lisp-tests.el (foo):
* automated/lisp-tests.el (string-variable):
* automated/lisp-tests.el (featurep):
Replace Assert (equal ... with Assert-equal; same for other types
of equality. Replace some awkward equivalents of Assert-equalp
with Assert-equalp. Add lots of equalp tests.
* automated/case-tests.el:
* automated/regexp-tests.el:
* automated/search-tests.el:
Fix up the comments at the top of the files. Move rules about where
to put tests into case-tests.el.
* automated/test-harness.el:
* automated/test-harness.el (test-harness-aborted-summary-template): New.
* automated/test-harness.el (test-harness-from-buffer):
* automated/test-harness.el (batch-test-emacs):
Fix Assert-test-not. Create Assert-not-equal and variants.
Delete the doc strings from all these convenience functions to avoid
excessive repetition; instead use one copy in a comment.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 01 Feb 2010 01:02:40 -0600 |
parents | 2fc0e2f18322 |
children | ba07c880114a |
rev | line source |
---|---|
1983 | 1 /* Definitions of numeric types for XEmacs using the MP library. |
2 Copyright (C) 2004 Jerry James. | |
3 | |
4 This file is part of XEmacs. | |
5 | |
6 XEmacs is free software; you can redistribute it and/or modify it | |
7 under the terms of the GNU General Public License as published by the | |
8 Free Software Foundation; either version 2, or (at your option) any | |
9 later version. | |
10 | |
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with XEmacs; see the file COPYING. If not, write to | |
4802
2fc0e2f18322
Don't create any bignums before pdumping. Add bignum, ratio, and bigfloat
Jerry James <james@xemacs.org>
parents:
1983
diff
changeset
|
18 the Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, |
2fc0e2f18322
Don't create any bignums before pdumping. Add bignum, ratio, and bigfloat
Jerry James <james@xemacs.org>
parents:
1983
diff
changeset
|
19 Boston, MA 02111-1301, USA. */ |
1983 | 20 |
21 /* Synched up with: Not in FSF. */ | |
22 | |
23 /* This library defines the following types: | |
24 bignum = MINT | |
25 | |
26 The MP library does not include support for ratios or bigfloats. | |
27 */ | |
28 | |
29 #ifndef INCLUDED_number_mp_h_ | |
30 #define INCLUDED_number_mp_h_ | |
31 | |
32 /* BSD MP libraries without MP_PREFIX define a function named pow in mp.h that | |
33 has a different prototype from the one in math.h. We don't use that | |
34 function anyway, so we do this for safety purposes. However, this means | |
35 that number-mp.h must always be included before math.h. */ | |
36 #define pow mp_pow | |
37 #include <mp.h> | |
38 #undef pow | |
39 | |
40 #ifdef MP_PREFIX | |
41 #define MP_GCD mp_gcd | |
42 #define MP_ITOM mp_itom | |
43 #define MP_MADD mp_madd | |
44 #define MP_MCMP mp_mcmp | |
45 #define MP_MDIV mp_mdiv | |
46 #define MP_MFREE mp_mfree | |
47 #define MP_MSUB mp_msub | |
48 #define MP_MULT mp_mult | |
49 #define MP_SDIV mp_sdiv | |
50 #ifdef HAVE_MP_MOVE | |
51 #define MP_MOVE(x,y) mp_move (x, y) | |
52 #else | |
53 #define MP_MOVE(x,y) mp_madd (x, bignum_zero, y) | |
54 #endif | |
55 #else | |
56 #define MP_GCD gcd | |
57 #define MP_ITOM itom | |
58 #define MP_MADD madd | |
59 #define MP_MCMP mcmp | |
60 #define MP_MDIV mdiv | |
61 #define MP_MFREE mfree | |
62 #define MP_MSUB msub | |
63 #define MP_MULT mult | |
64 #define MP_SDIV sdiv | |
65 #ifdef HAVE_MP_MOVE | |
66 #define MP_MOVE(x,y) move (x, y) | |
67 #else | |
68 #define MP_MOVE(x,y) madd (x, bignum_zero, y) | |
69 #endif | |
70 #endif | |
71 | |
72 typedef MINT *bignum; | |
73 | |
74 extern void init_number_mp(void); | |
75 | |
76 | |
77 /********************************* Bignums **********************************/ | |
78 | |
79 #define HAVE_BIGNUM 1 | |
80 | |
81 extern MINT *bignum_zero, *intern_bignum; | |
82 extern MINT *bignum_min_int, *bignum_max_int, *bignum_max_uint; | |
83 extern MINT *bignum_min_long, *bignum_max_long, *bignum_max_ulong; | |
84 extern short div_rem; | |
85 | |
86 /***** Bignum: basic functions *****/ | |
87 #define bignum_init(b) (b = MP_ITOM (0)) | |
88 #define bignum_fini(b) MP_MFREE (b) | |
89 #define bignum_hashcode(b) bignum_to_uint (b) | |
90 #define bignum_sign(b) MP_MCMP (b, bignum_zero) | |
91 #define bignum_evenp(b) (MP_SDIV (b, 2, intern_bignum, &div_rem), \ | |
92 div_rem == 0) | |
93 #define bignum_oddp(b) (MP_SDIV (b, 2, intern_bignum, &div_rem), \ | |
94 div_rem != 0) | |
95 | |
96 /***** Bignum: size *****/ | |
97 #define bignum_fits_int_p(b) (MP_MCMP (b, bignum_min_int) >= 0 && \ | |
98 MP_MCMP (b, bignum_max_int) <= 0) | |
99 #define bignum_fits_uint_p(b) (MP_MCMP (b, bignum_zero) >= 0 && \ | |
100 MP_MCMP (b, bignum_max_uint) <= 0) | |
101 #define bignum_fits_long_p(b) (MP_MCMP (b, bignum_min_long) >= 0 && \ | |
102 MP_MCMP (b, bignum_max_long) <= 0) | |
103 #define bignum_fits_ulong_p(b) (MP_MCMP (b, bignum_zero) >= 0 && \ | |
104 MP_MCMP (b, bignum_max_ulong) <= 0) | |
105 | |
106 /***** Bignum: conversions *****/ | |
107 extern char *bignum_to_string(bignum, int); | |
108 extern int bignum_to_int(bignum); | |
109 extern unsigned int bignum_to_uint(bignum); | |
110 extern long bignum_to_long(bignum); | |
111 extern unsigned long bignum_to_ulong(bignum); | |
112 extern double bignum_to_double(bignum); | |
113 | |
114 /***** Bignum: converting assignments *****/ | |
115 #define bignum_set(b1, b2) MP_MOVE (b2, b1) | |
116 extern int bignum_set_string(bignum, const char *, int); | |
117 extern void bignum_set_long(bignum, long); | |
118 extern void bignum_set_ulong(bignum, unsigned long); | |
119 extern void bignum_set_double(bignum, double); | |
120 | |
121 /***** Bignum: comparisons *****/ | |
122 #define bignum_cmp(b1,b2) MP_MCMP (b1, b2) | |
123 #define bignum_lt(b1,b2) (MP_MCMP (b1, b2) < 0) | |
124 #define bignum_le(b1,b2) (MP_MCMP (b1, b2) <= 0) | |
125 #define bignum_eql(b1,b2) (MP_MCMP (b1, b2) == 0) | |
126 #define bignum_ge(b1,b2) (MP_MCMP (b1, b2) >= 0) | |
127 #define bignum_gt(b1,b2) (MP_MCMP (b1, b2) > 0) | |
128 | |
129 /***** Bignum: arithmetic *****/ | |
130 #define bignum_neg(b,b2) MP_MSUB (bignum_zero, b2, b) | |
131 #define bignum_abs(b,b2) (MP_MCMP (b2, bignum_zero) < 0 \ | |
132 ? MP_MSUB (bignum_zero, b2, b) \ | |
133 : MP_MADD (bignum_zero, b2, b)) | |
134 #define bignum_add(b,b1,b2) MP_MADD (b1, b2, b) | |
135 #define bignum_sub(b,b1,b2) MP_MSUB (b1, b2, b) | |
136 #define bignum_mul(b,b1,b2) MP_MULT (b1, b2, b) | |
137 extern int bignum_divisible_p(bignum, bignum); | |
138 #define bignum_div(b,b1,b2) MP_MDIV (b1, b2, b, intern_bignum) | |
139 extern void bignum_ceil(bignum, bignum, bignum); | |
140 extern void bignum_floor(bignum, bignum, bignum); | |
141 #define bignum_mod(b,b1,b2) MP_MDIV (b1, b2, intern_bignum, b) | |
142 extern void bignum_pow(bignum, bignum, unsigned long); | |
143 #define bignum_gcd(res,b1,b2) MP_GCD (b1, b2, res) | |
144 extern void bignum_lcm(bignum, bignum, bignum); | |
145 | |
146 /***** Bignum: bit manipulations *****/ | |
147 extern void bignum_and(bignum, bignum, bignum); | |
148 extern void bignum_ior(bignum, bignum, bignum); | |
149 extern void bignum_xor(bignum, bignum, bignum); | |
150 extern void bignum_not(bignum, bignum); | |
151 extern void bignum_setbit(bignum, unsigned long); | |
152 extern void bignum_clrbit(bignum, unsigned long); | |
153 extern int bignum_testbit(bignum, unsigned long); | |
154 extern void bignum_lshift(bignum, bignum, unsigned long); | |
155 extern void bignum_rshift(bignum, bignum, unsigned long); | |
156 | |
157 /***** Bignum: random numbers *****/ | |
158 extern void bignum_random_seed(unsigned long); | |
159 extern void bignum_random(bignum, bignum); | |
160 | |
161 #endif /* INCLUDED_number_mp_h_ */ |