comparison src/rangetab.c @ 5133:444a448b2f53

Merge branch ben-lisp-object into default branch
author Ben Wing <ben@xemacs.org>
date Sun, 07 Mar 2010 06:47:37 -0600
parents a9c41067dd88
children f965e31a35f0
comparison
equal deleted inserted replaced
5113:b2dcf6a6d8ab 5133:444a448b2f53
218 { XD_BLOCK_PTR, offsetof (Lisp_Range_Table, entries), 1, 218 { XD_BLOCK_PTR, offsetof (Lisp_Range_Table, entries), 1,
219 { &rted_description } }, 219 { &rted_description } },
220 { XD_END } 220 { XD_END }
221 }; 221 };
222 222
223 DEFINE_LRECORD_IMPLEMENTATION ("range-table", range_table, 223 DEFINE_DUMPABLE_LISP_OBJECT ("range-table", range_table,
224 1, /*dumpable-flag*/ 224 mark_range_table, print_range_table, 0,
225 mark_range_table, print_range_table, 0, 225 range_table_equal, range_table_hash,
226 range_table_equal, range_table_hash, 226 range_table_description,
227 range_table_description, 227 Lisp_Range_Table);
228 Lisp_Range_Table);
229 228
230 /************************************************************************/ 229 /************************************************************************/
231 /* Range table operations */ 230 /* Range table operations */
232 /************************************************************************/ 231 /************************************************************************/
233 232
330 there would be eight days. Similarly, there are 15 (= 20 - 5) elements in 329 there would be eight days. Similarly, there are 15 (= 20 - 5) elements in
331 the range [5, 20), but 16 in the range [5, 20]. 330 the range [5, 20), but 16 in the range [5, 20].
332 */ 331 */
333 (type)) 332 (type))
334 { 333 {
335 Lisp_Range_Table *rt = ALLOC_LCRECORD_TYPE (Lisp_Range_Table, 334 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (range_table);
336 &lrecord_range_table); 335 Lisp_Range_Table *rt = XRANGE_TABLE (obj);
337 rt->entries = Dynarr_new (range_table_entry); 336 rt->entries = Dynarr_new (range_table_entry);
338 rt->type = range_table_symbol_to_type (type); 337 rt->type = range_table_symbol_to_type (type);
339 return wrap_range_table (rt); 338 return obj;
340 } 339 }
341 340
342 DEFUN ("copy-range-table", Fcopy_range_table, 1, 1, 0, /* 341 DEFUN ("copy-range-table", Fcopy_range_table, 1, 1, 0, /*
343 Return a new range table which is a copy of RANGE-TABLE. 342 Return a new range table which is a copy of RANGE-TABLE.
344 It will contain the same values for the same ranges as RANGE-TABLE. 343 It will contain the same values for the same ranges as RANGE-TABLE.
345 The values will not themselves be copied. 344 The values will not themselves be copied.
346 */ 345 */
347 (range_table)) 346 (range_table))
348 { 347 {
349 Lisp_Range_Table *rt, *rtnew; 348 Lisp_Range_Table *rt, *rtnew;
349 Lisp_Object obj;
350 350
351 CHECK_RANGE_TABLE (range_table); 351 CHECK_RANGE_TABLE (range_table);
352 rt = XRANGE_TABLE (range_table); 352 rt = XRANGE_TABLE (range_table);
353 353
354 rtnew = ALLOC_LCRECORD_TYPE (Lisp_Range_Table, &lrecord_range_table); 354 obj = ALLOC_NORMAL_LISP_OBJECT (range_table);
355 rtnew = XRANGE_TABLE (obj);
355 rtnew->entries = Dynarr_new (range_table_entry); 356 rtnew->entries = Dynarr_new (range_table_entry);
356 rtnew->type = rt->type; 357 rtnew->type = rt->type;
357 358
358 Dynarr_add_many (rtnew->entries, Dynarr_begin (rt->entries), 359 Dynarr_add_many (rtnew->entries, Dynarr_begin (rt->entries),
359 Dynarr_length (rt->entries)); 360 Dynarr_length (rt->entries));
360 return wrap_range_table (rtnew); 361 return obj;
361 } 362 }
362 363
363 DEFUN ("get-range-table", Fget_range_table, 2, 3, 0, /* 364 DEFUN ("get-range-table", Fget_range_table, 2, 3, 0, /*
364 Find value for position POS in RANGE-TABLE. 365 Find value for position POS in RANGE-TABLE.
365 If there is no corresponding value, return DEFAULT (defaults to nil). 366 If there is no corresponding value, return DEFAULT (defaults to nil).
900 /************************************************************************/ 901 /************************************************************************/
901 902
902 void 903 void
903 syms_of_rangetab (void) 904 syms_of_rangetab (void)
904 { 905 {
905 INIT_LRECORD_IMPLEMENTATION (range_table); 906 INIT_LISP_OBJECT (range_table);
906 907
907 DEFSYMBOL_MULTIWORD_PREDICATE (Qrange_tablep); 908 DEFSYMBOL_MULTIWORD_PREDICATE (Qrange_tablep);
908 DEFSYMBOL (Qrange_table); 909 DEFSYMBOL (Qrange_table);
909 910
910 DEFSYMBOL (Qstart_closed_end_open); 911 DEFSYMBOL (Qstart_closed_end_open);