Skip to content

Commit

Permalink
Clarify nested records. (modelica#3130)
Browse files Browse the repository at this point in the history
* Clarify nested records.
Closes modelica#3128
* Apply suggestions from code review
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
  • Loading branch information
HansOlsson committed Apr 26, 2022
1 parent c968870 commit f267082
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions chapters/functions.tex
Expand Up @@ -2215,17 +2215,16 @@ \subsubsection{Arrays}\label{arrays-1}

\subsubsection{Records}\label{records}

Mapping of record types is only supported for C. A Modelica record class
that contains simple types, other record elements, is mapped as follows:
Mapping of record types is only supported for C.
A Modelica record class is mapped as follows:
\begin{itemize}
\item
The record class is represented by a struct in C.
\item
Each element of the Modelica record is mapped to its corresponding C
representation.
Each component of the Modelica record is mapped to its corresponding C representation.
A nested record component is mapped to a nested struct component.
\item
The elements of the Modelica record class are declared in the same
order in the C struct.
The components of the Modelica record class are declared in the same order in the C struct.
\item
Arrays cannot be mapped.
\end{itemize}
Expand All @@ -2235,16 +2234,24 @@ \subsubsection{Records}\label{records}

\begin{example}
\begin{lstlisting}[language=modelica]
record A
Integer b;
end A;
record R
Real x;
Real z;
A a1, a2;
end R;
\end{lstlisting}
is mapped to:
\begin{lstlisting}[language=C]
struct A {
int b;
};
struct R {
double x;
double z;
struct A a1, b2;
};
\end{lstlisting}
\end{example}
Expand Down

0 comments on commit f267082

Please sign in to comment.