Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/ml-nlffi-lib/Doc/manual/nlffi.tex
ViewVC logotype

Diff of /sml/trunk/src/ml-nlffi-lib/Doc/manual/nlffi.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1560, Fri Jul 23 23:23:09 2004 UTC revision 1564, Mon Jul 26 23:23:39 2004 UTC
# Line 99  Line 99 
99    
100  \subsubsection*{Examples}  \subsubsection*{Examples}
101    
102    \begin{small}
103  \begin{center}  \begin{center}
104  \begin{tabular}{c|c}  \begin{tabular}{c|c}
105  C declaration & signature of ML-side representation \\ \hline\hline  C declaration & signature of ML-side representation \\ \hline\hline
106  {\tt extern int i;}  \begin{minipage}{2in}
107    \begin{verbatim}
108    extern int i;
109    \end{verbatim}
110    \end{minipage}
111  &  &
112  \begin{minipage}{4in}  \begin{minipage}{4in}
113  \begin{verbatim}  \begin{verbatim}
# Line 117  Line 122 
122  \end{verbatim}  \end{verbatim}
123  \end{minipage}  \end{minipage}
124  \\ \hline  \\ \hline
125  {\tt extern const double d;}  \begin{minipage}{2in}
126    \begin{verbatim}
127    extern const double d;
128    \end{verbatim}
129    \end{minipage}
130  &  &
131  \begin{minipage}{4in}  \begin{minipage}{4in}
132  \begin{verbatim}  \begin{verbatim}
# Line 171  Line 180 
180  \end{minipage}  \end{minipage}
181  \end{tabular}  \end{tabular}
182  \end{center}  \end{center}
183    \end{small}
184    
185  %-------------------------------------------------------------------------  %-------------------------------------------------------------------------
186  \subsection{Functions}  \subsection{Functions}
# Line 425  Line 435 
435    
436  \subsection{Type definitions ({\tt typedef})}  \subsection{Type definitions ({\tt typedef})}
437    
438  ...  In C a {\tt typedef} declaration associates a type name $t$ with a
439    type $t_C$.  On the ML side, $t$ is represented by an ML structure
440    {\tt T\_$t$}.  This structure contains a type abbreviation {\tt t} for
441    the ML encoding of $t_C$ and, provided $t_C$ is not {\em incomplete},
442    a value {\tt typ} of type {\tt t C.T.typ} with run-time type
443    information regarding $t_C$.
444    
445    \subsubsection*{Examples}
446    
447    \begin{small}
448    \begin{center}
449    \begin{tabular}{c|c}
450    C declaration & signature of ML-side representation \\ \hline\hline
451    \begin{minipage}{2in}
452    \begin{verbatim}
453    typedef int t1;
454    \end{verbatim}
455    \end{minipage}
456    &
457    \begin{minipage}{4in}
458    \begin{verbatim}
459    
460    structure T_t1 : sig
461        type t   = C.sint
462        val typ  : t C.T.typ
463    end
464    
465    \end{verbatim}
466    \end{minipage}
467    \\ \hline
468    \begin{minipage}{2in}
469    \begin{verbatim}
470    typedef struct s t2;
471    /* s incomplete */
472    \end{verbatim}
473    \end{minipage}
474    &
475    \begin{minipage}{4in}
476    \begin{verbatim}
477    
478    structure T_t2 : sig
479        type t  = ST_s.tag C.su
480    end
481    
482    \end{verbatim}
483    \end{minipage}
484    \\ \hline
485    \begin{minipage}{2in}
486    \begin{verbatim}
487    typedef struct s *t3;
488    /* s incomplete */
489    \end{verbatim}
490    \end{minipage}
491    &
492    \begin{minipage}{4in}
493    \begin{verbatim}
494    
495    structure T_t3 : sig
496        type t  = (ST_s.tag, C.rw) C.su_obj C.ptr
497    end
498    
499    \end{verbatim}
500    \end{minipage}
501    \\ \hline
502    \begin{minipage}{2in}
503    \begin{verbatim}
504    typedef struct t t4;
505    /* t complete */
506    \end{verbatim}
507    \end{minipage}
508    &
509    \begin{minipage}{4in}
510    \begin{verbatim}
511    
512    structure T_t4 : sig
513        type t  = ST_t.tag C.su
514        val typ : t T.typ
515    end
516    
517    \end{verbatim}
518    \end{minipage}
519    \end{tabular}
520    \end{center}
521    \end{small}
522    
523  \subsection{{\tt struct} and {\tt union}}  \subsection{{\tt struct} and {\tt union}}
524    

Legend:
Removed from v.1560  
changed lines
  Added in v.1564

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0