comparison src/data.c @ 5117:3742ea8250b5 ben-lisp-object ben-lisp-object-final-ws-year-2005

Checking in final CVS version of workspace 'ben-lisp-object'
author Ben Wing <ben@xemacs.org>
date Sat, 26 Dec 2009 00:20:27 -0600
parents 1e7cc382eb16
children e0db3c197671
comparison
equal deleted inserted replaced
5116:e56f73345619 5117:3742ea8250b5
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
2573 } 2573 }
2574 2574
2575 Lisp_Object 2575 Lisp_Object
2576 make_weak_list (enum weak_list_type type) 2576 make_weak_list (enum weak_list_type type)
2577 { 2577 {
2578 Lisp_Object result; 2578 Lisp_Object result = ALLOC_LISP_OBJECT (weak_list);
2579 struct weak_list *wl = 2579 struct weak_list *wl = XWEAK_LIST (result);
2580 ALLOC_LCRECORD_TYPE (struct weak_list, &lrecord_weak_list);
2581 2580
2582 wl->list = Qnil; 2581 wl->list = Qnil;
2583 wl->type = type; 2582 wl->type = type;
2584 result = wrap_weak_list (wl);
2585 wl->next_weak = Vall_weak_lists; 2583 wl->next_weak = Vall_weak_lists;
2586 Vall_weak_lists = result; 2584 Vall_weak_lists = result;
2587 return result; 2585 return result;
2588 } 2586 }
2589 2587
2593 { XD_LO_LINK, offsetof (struct weak_list, next_weak), 2591 { XD_LO_LINK, offsetof (struct weak_list, next_weak),
2594 0, { 0 }, XD_FLAG_NO_KKCC }, 2592 0, { 0 }, XD_FLAG_NO_KKCC },
2595 { XD_END } 2593 { XD_END }
2596 }; 2594 };
2597 2595
2598 DEFINE_LRECORD_IMPLEMENTATION ("weak-list", weak_list, 2596 DEFINE_LISP_OBJECT ("weak-list", weak_list,
2599 1, /*dumpable-flag*/
2600 mark_weak_list, print_weak_list, 2597 mark_weak_list, print_weak_list,
2601 0, weak_list_equal, weak_list_hash, 2598 0, weak_list_equal, weak_list_hash,
2602 weak_list_description, 2599 weak_list_description,
2603 struct weak_list); 2600 struct weak_list);
2604 /* 2601 /*
3047 } 3044 }
3048 3045
3049 Lisp_Object 3046 Lisp_Object
3050 make_weak_box (Lisp_Object value) 3047 make_weak_box (Lisp_Object value)
3051 { 3048 {
3052 Lisp_Object result; 3049 Lisp_Object result = ALLOC_LISP_OBJECT (weak_box);
3053 3050 struct weak_box *wb = XWEAK_BOX (result);
3054 struct weak_box *wb =
3055 ALLOC_LCRECORD_TYPE (struct weak_box, &lrecord_weak_box);
3056 3051
3057 wb->value = value; 3052 wb->value = value;
3058 result = wrap_weak_box (wb); 3053 result = wrap_weak_box (wb);
3059 wb->next_weak_box = Vall_weak_boxes; 3054 wb->next_weak_box = Vall_weak_boxes;
3060 Vall_weak_boxes = result; 3055 Vall_weak_boxes = result;
3064 static const struct memory_description weak_box_description[] = { 3059 static const struct memory_description weak_box_description[] = {
3065 { XD_LO_LINK, offsetof (struct weak_box, value) }, 3060 { XD_LO_LINK, offsetof (struct weak_box, value) },
3066 { XD_END} 3061 { XD_END}
3067 }; 3062 };
3068 3063
3069 DEFINE_LRECORD_IMPLEMENTATION ("weak_box", weak_box, 3064 DEFINE_NONDUMPABLE_LISP_OBJECT ("weak-box", weak_box, mark_weak_box,
3070 0, /*dumpable-flag*/ 3065 print_weak_box, 0, weak_box_equal,
3071 mark_weak_box, print_weak_box, 3066 weak_box_hash, weak_box_description,
3072 0, weak_box_equal, weak_box_hash, 3067 struct weak_box);
3073 weak_box_description,
3074 struct weak_box);
3075 3068
3076 DEFUN ("make-weak-box", Fmake_weak_box, 1, 1, 0, /* 3069 DEFUN ("make-weak-box", Fmake_weak_box, 1, 1, 0, /*
3077 Return a new weak box from value CONTENTS. 3070 Return a new weak box from value CONTENTS.
3078 The weak box is a reference to CONTENTS which may be extracted with 3071 The weak box is a reference to CONTENTS which may be extracted with
3079 `weak-box-ref'. However, the weak box does not contribute to the 3072 `weak-box-ref'. However, the weak box does not contribute to the
3267 { 3260 {
3268 return internal_hash (XEPHEMERON_REF (obj), depth + 1); 3261 return internal_hash (XEPHEMERON_REF (obj), depth + 1);
3269 } 3262 }
3270 3263
3271 Lisp_Object 3264 Lisp_Object
3272 make_ephemeron(Lisp_Object key, Lisp_Object value, Lisp_Object finalizer) 3265 make_ephemeron (Lisp_Object key, Lisp_Object value, Lisp_Object finalizer)
3273 { 3266 {
3274 Lisp_Object result, temp = Qnil; 3267 Lisp_Object temp = Qnil;
3275 struct gcpro gcpro1, gcpro2; 3268 struct gcpro gcpro1, gcpro2;
3276 3269 Lisp_Object result = ALLOC_LISP_OBJECT (ephemeron);
3277 struct ephemeron *eph = 3270 struct ephemeron *eph = XEPHEMERON (result);
3278 ALLOC_LCRECORD_TYPE (struct ephemeron, &lrecord_ephemeron);
3279 3271
3280 eph->key = Qnil; 3272 eph->key = Qnil;
3281 eph->cons_chain = Qnil; 3273 eph->cons_chain = Qnil;
3282 eph->value = Qnil; 3274 eph->value = Qnil;
3283 3275
3284 result = wrap_ephemeron(eph); 3276 result = wrap_ephemeron (eph);
3285 GCPRO2 (result, temp); 3277 GCPRO2 (result, temp);
3286 3278
3287 eph->key = key; 3279 eph->key = key;
3288 temp = Fcons(value, finalizer); 3280 temp = Fcons (value, finalizer);
3289 eph->cons_chain = Fcons(temp, Vall_ephemerons); 3281 eph->cons_chain = Fcons (temp, Vall_ephemerons);
3290 eph->value = value; 3282 eph->value = value;
3291 3283
3292 Vall_ephemerons = result; 3284 Vall_ephemerons = result;
3293 3285
3294 UNGCPRO; 3286 UNGCPRO;
3305 { XD_LISP_OBJECT, offsetof(struct ephemeron, value), 3297 { XD_LISP_OBJECT, offsetof(struct ephemeron, value),
3306 0, { 0 }, XD_FLAG_NO_KKCC }, 3298 0, { 0 }, XD_FLAG_NO_KKCC },
3307 { XD_END } 3299 { XD_END }
3308 }; 3300 };
3309 3301
3310 DEFINE_LRECORD_IMPLEMENTATION ("ephemeron", ephemeron, 3302 DEFINE_NONDUMPABLE_LISP_OBJECT ("ephemeron", ephemeron,
3311 0, /*dumpable-flag*/ 3303 mark_ephemeron, print_ephemeron,
3312 mark_ephemeron, print_ephemeron, 3304 0, ephemeron_equal, ephemeron_hash,
3313 0, ephemeron_equal, ephemeron_hash, 3305 ephemeron_description,
3314 ephemeron_description, 3306 struct ephemeron);
3315 struct ephemeron);
3316 3307
3317 DEFUN ("make-ephemeron", Fmake_ephemeron, 2, 3, 0, /* 3308 DEFUN ("make-ephemeron", Fmake_ephemeron, 2, 3, 0, /*
3318 Return a new ephemeron with key KEY, value VALUE, and finalizer FINALIZER. 3309 Return a new ephemeron with key KEY, value VALUE, and finalizer FINALIZER.
3319 The ephemeron is a reference to VALUE which may be extracted with 3310 The ephemeron is a reference to VALUE which may be extracted with
3320 `ephemeron-ref'. VALUE is only reachable through the ephemeron as 3311 `ephemeron-ref'. VALUE is only reachable through the ephemeron as
3448 } 3439 }
3449 3440
3450 void 3441 void
3451 syms_of_data (void) 3442 syms_of_data (void)
3452 { 3443 {
3453 INIT_LRECORD_IMPLEMENTATION (weak_list); 3444 INIT_LISP_OBJECT (weak_list);
3454 INIT_LRECORD_IMPLEMENTATION (ephemeron); 3445 INIT_LISP_OBJECT (ephemeron);
3455 INIT_LRECORD_IMPLEMENTATION (weak_box); 3446 INIT_LISP_OBJECT (weak_box);
3456 3447
3457 DEFSYMBOL (Qquote); 3448 DEFSYMBOL (Qquote);
3458 DEFSYMBOL (Qlambda); 3449 DEFSYMBOL (Qlambda);
3459 DEFSYMBOL (Qlistp); 3450 DEFSYMBOL (Qlistp);
3460 DEFSYMBOL (Qtrue_list_p); 3451 DEFSYMBOL (Qtrue_list_p);