;;; -*-lisp-*- ;;; ;;; Class finalization protocol ;;; ;;; (c) 2009 Straylight/Edgeware ;;; ;;;----- Licensing notice --------------------------------------------------- ;;; ;;; 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 ;;; the Free Software Foundation; either version 2 of the License, or ;;; (at your option) any later version. ;;; ;;; SOD is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with SOD; if not, write to the Free Software Foundation, ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. (cl:in-package #:sod) ;;;-------------------------------------------------------------------------- ;;; Protocol definition. (export 'compute-cpl) (defgeneric compute-cpl (class) (:documentation "Returns the class precedence list for CLASS.")) (export 'compute-chains) (defgeneric compute-chains (class) (:documentation "Compute the layout chains for CLASS. Returns the following three values. * the head of the class's primary chain; * the class's primary chain as a list, most- to least-specific; and * the complete collection of chains, as a list of lists, each most- to least-specific, with the primary chain first. These values will be stored in the CHAIN-HEAD, CHAIN and CHAINS slots. If the chains are ill-formed (i.e., not distinct) then an error is signalled.")) (export 'guess-metaclass) (defgeneric guess-metaclass (class) (:documentation "Determine a suitable metaclass for the CLASS. The default behaviour is to choose the most specific metaclass of any of the direct superclasses of CLASS, or to signal an error if that failed.")) (export 'check-sod-class) (defgeneric check-sod-class (class) (:documentation "Check the CLASS for validity. This is done as part of class finalization. The checks performed are as follows. * The class name and nickname, and the names of messages, obey the rules (see VALID-NAME-P). * The messages and slots have distinct names. * The classes in the class-precedence-list have distinct nicknames. * The chain-link is actually a proper (though not necessarily direct) superclass. * The chosen metaclass is actually a subclass of all of the superclasses' metaclasses. Returns true if all is well; false (and signals errors) if anything was wrong.")) (export 'finalize-sod-class) (defgeneric finalize-sod-class (class) (:documentation "Computes all of the gory details about a class. Once one has stopped inserting methods and slots and so on into a class, one needs to finalize it to determine the layout structure and the class precedence list and so on. More precisely that gets done is this: * Related classes (i.e., direct superclasses and the metaclass) are finalized if they haven't been already. * If you've been naughty and failed to store a list of slots or whatever, then an empty list is inserted. * The class precedence list is computed and stored. * The class is checked for compiance with the well-formedness rules. * The layout chains are computed.")) ;;;----- That's all, folks --------------------------------------------------