;;;----- Licensing notice ---------------------------------------------------
;;;
-;;; This file is part of the Sensble Object Design, an object system for C.
+;;; This file is part of the Sensible Object Design, an object system for C.
;;;
;;; SOD is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
:key #'sod-initializer-slot))
(sod-class-precedence-list class)))
+(defmethod find-slot-initargs ((class sod-class) (slot sod-slot))
+ (mappend (lambda (super)
+ (remove-if-not (lambda (initarg)
+ (and (typep initarg 'sod-slot-initarg)
+ (eq (sod-initarg-slot initarg) slot)))
+ (sod-class-initargs super)))
+ (sod-class-precedence-list class)))
+
(defmethod compute-effective-slot ((class sod-class) (slot sod-slot))
(make-instance 'effective-slot
:slot slot
:class class
- :initializer (find-slot-initializer class slot)))
+ :initializer (find-slot-initializer class slot)
+ :initargs (find-slot-initargs class slot)))
+
+(defmethod find-class-initializer ((slot effective-slot) (class sod-class))
+ (let ((dslot (effective-slot-direct-slot slot)))
+ (or (some (lambda (super)
+ (find dslot (sod-class-class-initializers super)
+ :key #'sod-initializer-slot))
+ (sod-class-precedence-list class))
+ (effective-slot-initializer slot))))
;;;--------------------------------------------------------------------------
;;; Special-purpose slot objects.
(default-slot (slot 'prepare-function)
(get-property pset :prepare-function :func nil)))
-(export 'sod-class-effective-slot)
+(export '(sod-class-effective-slot
+ effective-slot-initializer-function
+ effective-slot-prepare-function))
(defclass sod-class-effective-slot (effective-slot)
((initializer-function :initarg :initializer-function
:type (or symbol function)
(sod-class-nickname (method-entry-chain-head entry))
(method-entry-role entry))))
+(defmethod sod-message-applicable-methods
+ ((message sod-message) (class sod-class))
+ (mappend (lambda (super)
+ (remove message
+ (sod-class-methods super)
+ :key #'sod-method-message
+ :test-not #'eql))
+ (sod-class-precedence-list class)))
+
(defmethod compute-sod-effective-method
((message sod-message) (class sod-class))
- (let ((direct-methods (mappend (lambda (super)
- (remove message
- (sod-class-methods super)
- :key #'sod-method-message
- :test-not #'eql))
- (sod-class-precedence-list class))))
+ (let ((direct-methods (sod-message-applicable-methods message class)))
(make-instance (sod-message-effective-method-class message)
:message message
:class class
(compute-vtable class (reverse chain)))
(sod-class-chains class)))
+;;;--------------------------------------------------------------------------
+;;; Layout interface.
+
+;; Just arrange to populate the necessary slots on demand.
+(flet ((check-class-is-finalized (class)
+ (unless (eq (sod-class-state class) :finalized)
+ (error "Class ~S is not finalized" class))))
+ (macrolet ((define-layout-slot (slot (class) &body body)
+ `(define-on-demand-slot sod-class ,slot (,class)
+ (check-class-is-finalized ,class)
+ ,@body)))
+ (define-layout-slot %ilayout (class)
+ (compute-ilayout class))
+ (define-layout-slot effective-methods (class)
+ (compute-effective-methods class))
+ (define-layout-slot vtables (class)
+ (compute-vtables class))))
+
;;;----- That's all, folks --------------------------------------------------