#define SCM_OUT_PCLASS_INDEX SCM_I_MAX_PORT_TYPE_COUNT
#define SCM_INOUT_PCLASS_INDEX (2 * SCM_I_MAX_PORT_TYPE_COUNT)
-#define SCM_GOOPS_UNBOUND SCM_UNBOUND
-#define SCM_GOOPS_UNBOUNDP(x) (scm_is_eq (x, SCM_GOOPS_UNBOUND))
-
/* Objects have identity, so references to classes and instances are by
value, not by reference. Redefinition of a class or modification of
an instance causes in-place update; you can think of GOOPS as
SCM scm_module_goops;
-static SCM scm_make_unbound (void);
-static SCM scm_unbound_p (SCM obj);
static SCM scm_sys_make_vtable_vtable (SCM layout);
static SCM scm_sys_init_layout_x (SCM class, SCM layout);
-static SCM scm_sys_clear_fields_x (SCM obj);
+static SCM scm_sys_clear_fields_x (SCM obj, SCM unbound);
static SCM scm_sys_goops_early_init (void);
static SCM scm_sys_goops_loaded (void);
\f
-SCM_DEFINE (scm_make_unbound, "make-unbound", 0, 0, 0,
- (),
- "Return the unbound value.")
-#define FUNC_NAME s_scm_make_unbound
-{
- return SCM_GOOPS_UNBOUND;
-}
-#undef FUNC_NAME
-
-SCM_DEFINE (scm_unbound_p, "unbound?", 1, 0, 0,
- (SCM obj),
- "Return @code{#t} if @var{obj} is unbound.")
-#define FUNC_NAME s_scm_unbound_p
-{
- return SCM_GOOPS_UNBOUNDP (obj) ? SCM_BOOL_T : SCM_BOOL_F;
-}
-#undef FUNC_NAME
-
-
-\f
-
SCM
scm_slot_ref (SCM obj, SCM slot_name)
{
\f
-SCM_DEFINE (scm_sys_clear_fields_x, "%clear-fields!", 1, 0, 0,
- (SCM obj),
+SCM_DEFINE (scm_sys_clear_fields_x, "%clear-fields!", 2, 0, 0,
+ (SCM obj, SCM unbound),
"")
#define FUNC_NAME s_scm_sys_clear_fields_x
{
/* Set all SCM-holding slots to the GOOPS unbound value. */
for (i = 0; i < n; i++)
if (scm_i_symbol_ref (layout, i*2) == 'p')
- SCM_STRUCT_SLOT_SET (obj, i, SCM_GOOPS_UNBOUND);
+ SCM_STRUCT_SLOT_SET (obj, i, unbound);
return SCM_UNSPECIFIED;
}
-/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
{
/* This value may become dead as a result of GC,
so we can't just leave it on the stack. */
- *sp = SCM_UNBOUND;
+ *sp = SCM_UNSPECIFIED;
continue;
}
}
;;; ECMAScript for Guile
-;; Copyright (C) 2009, 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2013, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
new-object new))
-(define *undefined* ((@@ (oop goops) make-unbound)))
+(define-class <undefined> ())
+
+(define *undefined* (make <undefined>))
(define *this* (make-fluid))
(define-class <js-object> ()
(scm-error 'wrong-type-arg #f "Not a keyword: ~S" (list kw) #f))
(if (eq? kw key) arg (lp l))))))
+(define *unbound* (list 'unbound))
+
+(define-inlinable (unbound? x)
+ (eq? x *unbound*))
+
(define (%allocate-instance class)
(let ((obj (allocate-struct class (struct-ref class class-index-nfields))))
- (%clear-fields! obj)
+ (%clear-fields! obj *unbound*)
obj))
(define (make class . args)
head
(find-duplicate tail)))))
- (let* ((name (get-keyword #:name options (make-unbound)))
+ (let* ((name (get-keyword #:name options *unbound*))
(supers (if (not (or-map (lambda (class)
(memq <object>
(class-precedence-list class)))
(define (slot-definition-init-value s)
;; can be #f, so we can't use #f as non-value
- (get-keyword #:init-value (cdr s) (make-unbound)))
+ (get-keyword #:init-value (cdr s) *unbound*))
(define (slot-definition-init-form s)
- (get-keyword #:init-form (cdr s) (make-unbound)))
+ (get-keyword #:init-form (cdr s) *unbound*))
(define (slot-definition-init-thunk s)
(get-keyword #:init-thunk (cdr s) #f))
;;; {Initialize}
;;;
-(define *unbound* (make-unbound))
-
;; FIXME: This could be much more efficient.
(define (%initialize-object obj initargs)
"Initialize the object @var{obj} with the given arguments
(after-ref (get-keyword #:after-slot-ref s #f))
(before-set! (get-keyword #:before-slot-set! s #f))
(after-set! (get-keyword #:after-slot-set! s #f))
- (unbound (make-unbound)))
+ (unbound *unbound*))
(slot-set! class 'nfields (+ index 1))
(list (lambda (o)
(if before-ref
(let ((res (struct-ref o index)))
(and after-ref (not (eqv? res unbound)) (after-ref o))
res)
- (make-unbound))
+ *unbound*)
(let ((res (struct-ref o index)))
(and after-ref (not (eqv? res unbound)) (after-ref o))
res)))
(define-module (oop goops save)
:use-module (oop goops internal)
- :re-export (make-unbound)
- :export (save-objects load-objects restore
+ :export (make-unbound save-objects load-objects restore
enumerate! enumerate-component!
write-readably write-component write-component-procedure
literal? readable make-readable))
+(define (make-unbound)
+ *unbound*)
+
;;;
;;; save-objects ALIST PORT [EXCLUDED] [USES]
;;;