%%% -*-latex-*-
%%%
%%% Translation-time metaobjects
%%%
%%% (c) 2015 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.

\chapter{Translation-time metaobjects} \label{ch:meta}

%%%--------------------------------------------------------------------------
\section{Base metaobject classes} \label{sec:meta.classes}

\begin{describe}{cls}
    {sod-class () \\ \ind
      \&key \=:name :nick :location :pset \+ \\
              :superclasses :link :metaclass \\
              :slots :instance-initializers :class-initializers \\
              :messages :methods}
\end{describe}

\begin{describe*}
    {\dhead{gf}{sod-class-name @<class> @> @<string>}
     \dhead{gf}{sod-class-nickname @<class> @> @<string>}
     \dhead{gf}{sod-class-direct-superclasses @<class> @> @<list>}
     \dhead{gf}{sod-class-chain-link @<class> @> @<class-or-nil>}
     \dhead{gf}{sod-class-metaclass @<class> @> @<metaclass>}
     \dhead{gf}{sod-class-slots @<class> @> @<list>}
     \dhead{gf}{setf (sod-class-slots @<class>) @<list>}
     \dhead{gf}{sod-class-instance-initializers @<class> @> @<list>}
     \dhead{gf}{setf (sod-class-instance-initializers @<class>) @<list>}
     \dhead{gf}{sod-class-class-initializers @<class> @> @<list>}
     \dhead{gf}{setf (sod-class-class-initializers @<class>) @<list>}
     \dhead{gf}{sod-class-messages @<class> @> @<list>}
     \dhead{gf}{setf (sod-class-messages @<class>) @<list>}
     \dhead{gf}{sod-class-methods @<class> @> @<list>}
     \dhead{gf}{setf (sod-class-methods @<class>) @<list>}}
\end{describe*}

\begin{describe}{fun}
    {make-sod-class @<name> @<superclasses> @<pset> \&optional @<floc>
      @> @<class>}
\end{describe}

\begin{describe}{mac}
    {define-sod-class @<name> (@<superclass>^*) \\ \ind
      @{ @<keyword> @<value> @}^* \\
      @<declaration>^* \\
      @<form>^*}
\end{describe}

\begin{describe*}
    {\dhead{lmac}{slot @<name> @<type> @{ @<keyword> @<value> @}^*}
     \dhead{lmac}{instance-initializer @<nick> @<name>
                                       @<value-kind> @<value-form>
                                       @{ @<keyword> @<value> @}^*}
     \dhead{lmac}{class-initializer @<nick> @<name>
                                    @<value-kind> @<value-form>
                                    @{ @<keyword> @<value> @}^*}
     \dhead{lmac}{message @<name> @<type> @{ @<keyword> @<value> @}^*}
     \dhead{lmac}{method @<nick> @<name> @<type> @<body>
                         @{ @<keyword> @<value> @}^*}}
\end{describe*}

\begin{describe}{fun}
    {find-superclass-by-nick @<class> @<nick> @> @<superclass>}
\end{describe}

\begin{describe}{fun}
    {sod-subclass-p @<class-a> @<class-b> @> @<generalized-boolean>}
\end{describe}

\begin{describe}{fun}{valid-name-p @<name> @> @<generalized-boolean>}
\end{describe}

\begin{describe}{fun}{find-root-superclass @<class> @> @<superclass>}
\end{describe}

\begin{describe}{fun}{find-root-metaclass @<class> @> @<metaclass>}
\end{describe}

\begin{describe}{cls}{sod-slot () \&key :name :location :pset :class :type}
\end{describe}

\begin{describe*}
    {\dhead{gf}{sod-slot-name @<slot> @> @<string>}
     \dhead{gf}{sod-slot-class @<slot> @> @<class>}
     \dhead{gf}{sod-slot-type @<slot> @> @<c-type>}}
\end{describe*}

\begin{describe}{gf}
    {make-sod-slot @<class> @<name> @<type> @<pset> \&optional @<floc>
      @> @<slot>}
\end{describe}

\begin{describe*}
    {\dhead{fun}
      {find-instance-slot-by-name @<class> @<super-nick> @<slot-name>
        @> @<slot>}
     \dhead{fun}
      {find-class-slot-by-name @<class> @<super-nick> @<slot-name>
        @> @<slot>}}
\end{describe*}

\begin{describe}{fun}
    {find-instance-slot-by-name @<class> @<super-nick> @<slot-name>
      @> @<slot>}
\end{describe}

\begin{describe}{cls}
    {sod-class-slot (sod-slot) \\ \ind
      \&key :name :location :pset :class :type
            :initializer-function :prepare-function}
\end{describe}

\begin{describe*}
    {\dhead{gf}{sod-slot-initializer-function @<slot> @> @<function>}
     \dhead{gf}{sod-slot-prepare-function @<slot> @> @<function>}}
\end{describe*}

\begin{describe*}
    {\dhead{cls}{sod-initializer ()
       \&key :slot :location :class :value-kind :value-form}
     \dhead{cls}{sod-instance-initializer (sod-initializer)
       \&key :slot :location :class :value-kind :value-form}
     \dhead{cls}{sod-class-initializer (sod-initializer)
       \&key :slot :location :class :value-kind :value-form}}
\end{describe*}

\begin{describe*}
    {\dhead{gf}{sod-initializer-slot @<init> @> @<slot>}
     \dhead{gf}{sod-initializer-value-kind @<init> @> @<kind>}
     \dhead{gf}{sod-initializer-value-form @<init> @> @<fragment>}}
\end{describe*}

\begin{describe*}
    {\dhead{gf}
      {make-slot-instance-initializer \=@<class> @<nick> @<name>
                                        @<value-kind> @<value-form> \+ \\
                                        @<pset> \&optional @<floc> \-
        \nlret @<init>}
     \dhead{gf}
      {make-slot-class-initializer \=@<class> @<nick> @<name>
                                     @<value-kind> @<value-form> \+ \\
                                     @<pset> \&optional @<floc> \-
        \nlret @<init>}}
\end{describe*}

\begin{describe}{gf}
    {make-sod-initializer-using-slot \=@<class> @<slot> @<init-class>
                                       @<value-kind> @<value-form> \+ \\
                                       @<pset> \&optional @<floc> \-
      \nlret @<init>}
\end{describe}

\begin{describe}{cls}{sod-message () \&key :name :location :class :type}
\end{describe}

\begin{describe*}
    {\dhead{gf}{sod-message-name @<message> @> @<string>}
     \dhead{gf}{sod-message-class @<message> @> @<class>}
     \dhead{gf}{sod-message-type @<message> @> @<c-type>}}
\end{describe*}

\begin{describe}{gf}
    {make-sod-message @<class> @<name> @<type> @<pset> \&optional @<floc>
      @> @<message>}
\end{describe}

\begin{describe}{gf}{check-message-type @<message> @<type>}
\end{describe}

\begin{describe}{fun}
    {find-message-by-name @<class> @<super-nick> @<message-name>
      @> @<message>}
\end{describe}

\begin{describe}{cls}
    {sod-method () \&key :message :location :class :type :body}
\end{describe}

\begin{describe*}
    {\dhead{gf}{sod-method-message @<method> @> @<message>}
     \dhead{gf}{sod-method-class @<method> @> @<class>}
     \dhead{gf}{sod-method-type @<method> @> @<c-type>}
     \dhead{gf}{sod-method-body @<method> @> @<fragment-or-nil>}}
\end{describe*}

\begin{describe}{gf}
    {make-sod-method \=@<class> @<nick> @<name> @<type> @<body> \+ \\
                       @<pset> \&optional @<floc> \-
      \nlret @<method>}
\end{describe}

\begin{describe}{gf}
    {make-sod-method-using-message \=@<message> @<class>
                                     @<type> @<body> \+ \\
                                     @<pset> \&optional @<floc> \-
      \nlret @<method>}
\end{describe}

\begin{describe}{gf}
    {sod-message-method-class @<message> @<class> @<pset> @> @<method-class>}
\end{describe}

\begin{describe}{gf}{check-method-type @<method> @<message> @<type>}
\end{describe}

\begin{describe}{fun}
    {argument-lists-compatible-p @<message-args> @<method-args>
      @> @<generalized-boolean>}
\end{describe}

%%%--------------------------------------------------------------------------
\section{Class finalization protocol} \label{sec:meta.finalization}

\begin{describe*}
    {\dhead{gf}{sod-class-precedence-list <class> @> @<list>}
     \dhead{gf}{sod-class-type @<class> @> @<c-type>}
     \dhead{gf}{sod-class-chain-head @<class> @> @<class>}
     \dhead{gf}{sod-class-chain @<class> @> @<list>}
     \dhead{gf}{sod-class-chains @<class> @> @<list>}
     \dhead{gf}{sod-class-state @<class> @> @<state>}}
\end{describe*}

\begin{describe}{gf}{compute-cpl @<class> @> @<list>}
\end{describe}

\begin{describe}{gf}{compute-chains @<class> @> @<list>}
\end{describe}

\begin{describe}{gf}{guess-metaclass @<class> @> @<metaclass>}
\end{describe}

\begin{describe}{gf}{check-sod-class @<class>}
\end{describe}

\begin{describe}{gf}{finalize-sod-class @<class>}
\end{describe}

\begin{describe}{fun}{clos-cpl @<class> @> @<list>}
\end{describe}

\begin{describe}{fun}{dylan-cpl @<class> @> @<list>}
\end{describe}

\begin{describe}{fun}{c3-cpl @<class> @> @<list>}
\end{describe}

\begin{describe}{fun}{flavors-cpl @<class> @> @<list>}
\end{describe}

\begin{describe}{fun}{python-cpl @<class> @> @<list>}
\end{describe}

\begin{describe}{fun}{l*loops-cpl @<class> @> @<list>}
\end{describe}

%%%----- That's all, folks --------------------------------------------------

%%% Local variables:
%%% mode: LaTeX
%%% TeX-master: "sod.tex"
%%% TeX-PDF-mode: t
%%% End:
