X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/54fa3df9560fe739b5fe20ca561749092cef0fd5..a142609c5dc2a7c3df02497235881beaf47088bf:/doc/runtime.tex diff --git a/doc/runtime.tex b/doc/runtime.tex index 0a44f91..6a1941d 100644 --- a/doc/runtime.tex +++ b/doc/runtime.tex @@ -732,10 +732,42 @@ instance. The following macros and functions manage the standard steps along an instance's lifecycle. +\subsubsection{Low-level operations} +The following macros and functions are agnostic with respect to storage +allocation strategies. They don't concern themselves with allocation or +deallocation, and applications are free to use any suitable mechanism. + +\begin{describe*} + {\dhead[SOD_INIT]{mac} + {@ *SOD_INIT(@, void *@

, @);} + \dhead[sod_init]{fun} + {void *sod_init(const SodClass *@, void *@

, \dots);} + \dhead[sod_initv]{fun} + {void *sod_initv(const SodClass *@, void *@

, va_list @);}} + Imprints and initializes an instance of a class @ in the storage + starting at address~@

. + + The direct class for the new instance is specified as a class name to + @|SOD_INIT|, or a pointer to a class object to the functions. + + Keyword arguments for the initialization message may be provided. The + @|SOD_INIT| macro expects a single preprocessor-time argument which is + a use of one of \descref{KWARGS}{mac} or \descref{NO_KWARGS}{mac}; the + @|sod_init| function expects the keywords as a variable-length argument + tail; and @|sod_initv| expects the keywords to be passed indirectly, + through the captured argument-tail cursor @. + + The return value is an instance pointer for the class @; the + @|SOD_INIT| macro will have converted it to the correct type, so it should + probably be used where possible. In fact, this is guaranteed to be equal + to @

by the layout rules described in + \xref{sec:structures.layout.instance}. +\end{describe*} + \subsubsection{Automatic storage duration} The following macro constructs an instance with automatic storage duration. -\begin{describe}[SOD_DECL]{mac}{SOD_DECL(@, @);} +\begin{describe}[SOD_DECL]{mac}{SOD_DECL(@, @, @);} Declares and initializes an instance with automatic storage duration. Given a class name @ and an identifier @, @|SOD_DECL| declares @@ -744,6 +776,10 @@ The following macro constructs an instance with automatic storage duration. up, and slots for which initializers are defined are set to the appropriate initial values. + Keyword arguments for the initialization message may be provided. The + macro expects a single preprocessor-time argument which is a use of one of + \descref{KWARGS}{mac} or \descref{NO_KWARGS}{mac}. + The instance has automatic storage duration: pointers to it will become invalid when control exits the scope of the declaration. \end{describe}