comparison src/data.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 7be849cb8828
children f965e31a35f0
comparison
equal deleted inserted replaced
5113:b2dcf6a6d8ab 5133:444a448b2f53
1 /* Primitive operations on Lisp data types for XEmacs Lisp interpreter. 1 /* Primitive operations on Lisp data types for XEmacs Lisp interpreter.
2 Copyright (C) 1985, 1986, 1988, 1992, 1993, 1994, 1995 2 Copyright (C) 1985, 1986, 1988, 1992, 1993, 1994, 1995
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Copyright (C) 2000, 2001, 2002, 2003 Ben Wing. 4 Copyright (C) 2000, 2001, 2002, 2003, 2005 Ben Wing.
5 5
6 This file is part of XEmacs. 6 This file is part of XEmacs.
7 7
8 XEmacs is free software; you can redistribute it and/or modify it 8 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the 9 under the terms of the GNU General Public License as published by the
2641 } 2641 }
2642 2642
2643 Lisp_Object 2643 Lisp_Object
2644 make_weak_list (enum weak_list_type type) 2644 make_weak_list (enum weak_list_type type)
2645 { 2645 {
2646 Lisp_Object result; 2646 Lisp_Object result = ALLOC_NORMAL_LISP_OBJECT (weak_list);
2647 struct weak_list *wl = 2647 struct weak_list *wl = XWEAK_LIST (result);
2648 ALLOC_LCRECORD_TYPE (struct weak_list, &lrecord_weak_list);
2649 2648
2650 wl->list = Qnil; 2649 wl->list = Qnil;
2651 wl->type = type; 2650 wl->type = type;
2652 result = wrap_weak_list (wl);
2653 wl->next_weak = Vall_weak_lists; 2651 wl->next_weak = Vall_weak_lists;
2654 Vall_weak_lists = result; 2652 Vall_weak_lists = result;
2655 return result; 2653 return result;
2656 } 2654 }
2657 2655
2661 { XD_LO_LINK, offsetof (struct weak_list, next_weak), 2659 { XD_LO_LINK, offsetof (struct weak_list, next_weak),
2662 0, { 0 }, XD_FLAG_NO_KKCC }, 2660 0, { 0 }, XD_FLAG_NO_KKCC },
2663 { XD_END } 2661 { XD_END }
2664 }; 2662 };
2665 2663
2666 DEFINE_LRECORD_IMPLEMENTATION ("weak-list", weak_list, 2664 DEFINE_DUMPABLE_LISP_OBJECT ("weak-list", weak_list,
2667 1, /*dumpable-flag*/ 2665 mark_weak_list, print_weak_list,
2668 mark_weak_list, print_weak_list, 2666 0, weak_list_equal, weak_list_hash,
2669 0, weak_list_equal, weak_list_hash, 2667 weak_list_description,
2670 weak_list_description, 2668 struct weak_list);
2671 struct weak_list);
2672 /* 2669 /*
2673 -- we do not mark the list elements (either the elements themselves 2670 -- we do not mark the list elements (either the elements themselves
2674 or the cons cells that hold them) in the normal marking phase. 2671 or the cons cells that hold them) in the normal marking phase.
2675 -- at the end of marking, we go through all weak lists that are 2672 -- at the end of marking, we go through all weak lists that are
2676 marked, and mark the cons cells that hold all marked 2673 marked, and mark the cons cells that hold all marked
3115 } 3112 }
3116 3113
3117 Lisp_Object 3114 Lisp_Object
3118 make_weak_box (Lisp_Object value) 3115 make_weak_box (Lisp_Object value)
3119 { 3116 {
3120 Lisp_Object result; 3117 Lisp_Object result = ALLOC_NORMAL_LISP_OBJECT (weak_box);
3121 3118 struct weak_box *wb = XWEAK_BOX (result);
3122 struct weak_box *wb =
3123 ALLOC_LCRECORD_TYPE (struct weak_box, &lrecord_weak_box);
3124 3119
3125 wb->value = value; 3120 wb->value = value;
3126 result = wrap_weak_box (wb); 3121 result = wrap_weak_box (wb);
3127 wb->next_weak_box = Vall_weak_boxes; 3122 wb->next_weak_box = Vall_weak_boxes;
3128 Vall_weak_boxes = result; 3123 Vall_weak_boxes = result;
3132 static const struct memory_description weak_box_description[] = { 3127 static const struct memory_description weak_box_description[] = {
3133 { XD_LO_LINK, offsetof (struct weak_box, value) }, 3128 { XD_LO_LINK, offsetof (struct weak_box, value) },
3134 { XD_END} 3129 { XD_END}
3135 }; 3130 };
3136 3131
3137 DEFINE_LRECORD_IMPLEMENTATION ("weak_box", weak_box, 3132 DEFINE_NODUMP_LISP_OBJECT ("weak-box", weak_box, mark_weak_box,
3138 0, /*dumpable-flag*/ 3133 print_weak_box, 0, weak_box_equal,
3139 mark_weak_box, print_weak_box, 3134 weak_box_hash, weak_box_description,
3140 0, weak_box_equal, weak_box_hash, 3135 struct weak_box);
3141 weak_box_description,
3142 struct weak_box);
3143 3136
3144 DEFUN ("make-weak-box", Fmake_weak_box, 1, 1, 0, /* 3137 DEFUN ("make-weak-box", Fmake_weak_box, 1, 1, 0, /*
3145 Return a new weak box from value CONTENTS. 3138 Return a new weak box from value CONTENTS.
3146 The weak box is a reference to CONTENTS which may be extracted with 3139 The weak box is a reference to CONTENTS which may be extracted with
3147 `weak-box-ref'. However, the weak box does not contribute to the 3140 `weak-box-ref'. However, the weak box does not contribute to the
3336 { 3329 {
3337 return internal_hash (XEPHEMERON_REF (obj), depth + 1); 3330 return internal_hash (XEPHEMERON_REF (obj), depth + 1);
3338 } 3331 }
3339 3332
3340 Lisp_Object 3333 Lisp_Object
3341 make_ephemeron(Lisp_Object key, Lisp_Object value, Lisp_Object finalizer) 3334 make_ephemeron (Lisp_Object key, Lisp_Object value, Lisp_Object finalizer)
3342 { 3335 {
3343 Lisp_Object result, temp = Qnil; 3336 Lisp_Object temp = Qnil;
3344 struct gcpro gcpro1, gcpro2; 3337 struct gcpro gcpro1, gcpro2;
3345 3338 Lisp_Object result = ALLOC_NORMAL_LISP_OBJECT (ephemeron);
3346 struct ephemeron *eph = 3339 struct ephemeron *eph = XEPHEMERON (result);
3347 ALLOC_LCRECORD_TYPE (struct ephemeron, &lrecord_ephemeron);
3348 3340
3349 eph->key = Qnil; 3341 eph->key = Qnil;
3350 eph->cons_chain = Qnil; 3342 eph->cons_chain = Qnil;
3351 eph->value = Qnil; 3343 eph->value = Qnil;
3352 3344
3353 result = wrap_ephemeron(eph); 3345 result = wrap_ephemeron (eph);
3354 GCPRO2 (result, temp); 3346 GCPRO2 (result, temp);
3355 3347
3356 eph->key = key; 3348 eph->key = key;
3357 temp = Fcons(value, finalizer); 3349 temp = Fcons (value, finalizer);
3358 eph->cons_chain = Fcons(temp, Vall_ephemerons); 3350 eph->cons_chain = Fcons (temp, Vall_ephemerons);
3359 eph->value = value; 3351 eph->value = value;
3360 3352
3361 Vall_ephemerons = result; 3353 Vall_ephemerons = result;
3362 3354
3363 UNGCPRO; 3355 UNGCPRO;
3374 { XD_LISP_OBJECT, offsetof(struct ephemeron, value), 3366 { XD_LISP_OBJECT, offsetof(struct ephemeron, value),
3375 0, { 0 }, XD_FLAG_NO_KKCC }, 3367 0, { 0 }, XD_FLAG_NO_KKCC },
3376 { XD_END } 3368 { XD_END }
3377 }; 3369 };
3378 3370
3379 DEFINE_LRECORD_IMPLEMENTATION ("ephemeron", ephemeron, 3371 DEFINE_NODUMP_LISP_OBJECT ("ephemeron", ephemeron,
3380 0, /*dumpable-flag*/ 3372 mark_ephemeron, print_ephemeron,
3381 mark_ephemeron, print_ephemeron, 3373 0, ephemeron_equal, ephemeron_hash,
3382 0, ephemeron_equal, ephemeron_hash, 3374 ephemeron_description,
3383 ephemeron_description, 3375 struct ephemeron);
3384 struct ephemeron);
3385 3376
3386 DEFUN ("make-ephemeron", Fmake_ephemeron, 2, 3, 0, /* 3377 DEFUN ("make-ephemeron", Fmake_ephemeron, 2, 3, 0, /*
3387 Return a new ephemeron with key KEY, value VALUE, and finalizer FINALIZER. 3378 Return a new ephemeron with key KEY, value VALUE, and finalizer FINALIZER.
3388 The ephemeron is a reference to VALUE which may be extracted with 3379 The ephemeron is a reference to VALUE which may be extracted with
3389 `ephemeron-ref'. VALUE is only reachable through the ephemeron as 3380 `ephemeron-ref'. VALUE is only reachable through the ephemeron as
3518 } 3509 }
3519 3510
3520 void 3511 void
3521 syms_of_data (void) 3512 syms_of_data (void)
3522 { 3513 {
3523 INIT_LRECORD_IMPLEMENTATION (weak_list); 3514 INIT_LISP_OBJECT (weak_list);
3524 INIT_LRECORD_IMPLEMENTATION (ephemeron); 3515 INIT_LISP_OBJECT (ephemeron);
3525 INIT_LRECORD_IMPLEMENTATION (weak_box); 3516 INIT_LISP_OBJECT (weak_box);
3526 3517
3527 DEFSYMBOL (Qquote); 3518 DEFSYMBOL (Qquote);
3528 DEFSYMBOL (Qlambda); 3519 DEFSYMBOL (Qlambda);
3529 DEFSYMBOL (Qlistp); 3520 DEFSYMBOL (Qlistp);
3530 DEFSYMBOL (Qtrue_list_p); 3521 DEFSYMBOL (Qtrue_list_p);