X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/blobdiff_plain/8b8a885a8072a8e840bf99f83ef78b769121dc4a..e4ea29d8e1853f8ae36ee0e65b9f5913303042d2:/doc/concepts.tex?ds=sidebyside diff --git a/doc/concepts.tex b/doc/concepts.tex index 8067739..64f6320 100644 --- a/doc/concepts.tex +++ b/doc/concepts.tex @@ -270,7 +270,7 @@ slots. If you want to hide implementation details, the best approach is to stash them in a dynamically allocated private structure, and leave a pointer to it in a slot. (This will also help preserve binary compatibility, because the private structure can grow more members as needed. See -\xref{sec:fixme.compatibility} for more details. +\xref{sec:fixme.compatibility} for more details.) \subsubsection{Vtables} @@ -291,8 +291,8 @@ doesn't define any messages, so it doesn't have any methods. In Sod, a class slot containing a function pointer is not at all the same thing as a method.) \subsubsection{Conversions} -Suppose one has a value of type pointer to class type of some class~$C$, and -wants to convert it to a pointer to class type of some other class~$B$. +Suppose one has a value of type pointer-to-class-type for some class~$C$, and +wants to convert it to a pointer-to-class-type for some other class~$B$. There are three main cases to distinguish. \begin{itemize} \item If $B$ is a superclass of~$C$, in the same chain, then the conversion @@ -308,13 +308,13 @@ There are three main cases to distinguish. pointer. The conversion can be performed using the appropriate generated upcast macro (see below); the general case is handled by the macro \descref{SOD_XCHAIN}{mac}. -\item If $B$ is a subclass of~$C$ then the conversion is an \emph{upcast}; +\item If $B$ is a subclass of~$C$ then the conversion is a \emph{downcast}; otherwise the conversion is a~\emph{cross-cast}. In either case, the conversion can fail: the object in question might not be an instance of~$B$ - at all. The macro \descref{SOD_CONVERT}{mac} and the function + after all. The macro \descref{SOD_CONVERT}{mac} and the function \descref{sod_convert}{fun} perform general conversions. They return a null pointer if the conversion fails. (There are therefore your analogue to the - \Cplusplus @|dynamic_cast<>| operator.) + \Cplusplus\ @|dynamic_cast<>| operator.) \end{itemize} The Sod translator generates macros for performing both in-chain and cross-chain upcasts. For each class~$C$, and each proper superclass~$B$