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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1554 - (download) (as text) (annotate)
Tue Jul 20 17:59:03 2004 UTC (15 years, 7 months ago) by mblume
File size: 3530 byte(s)
template for a NLFFI manual added
% -*- latex -*-

\topmargin0pt\advance\topmargin by-\headheight\advance\topmargin by-\headsep


\author{Matthias Blume \\
Toyota Technological Institute at Chicago}

\title{{\bf NLFFI}\\
A new SML/NJ Foreign-Function Interface \\
{\it\small (for SML/NJ version \smlmj.\smlmn~and later)} \\
User Manual}

\setlength{\parskip}{6pt plus 3pt minus 2pt}

\newcommand{\nt}[1]{{\it #1}}
\newcommand{\tl}[1]{{\underline{\bf #1}}}
\newcommand{\ttl}[1]{{\underline{\tt #1}}}
\newcommand{\ar}{$\rightarrow$\ }









\section{The C Library}

The C library...

\section{Translation conventions}

The {\tt ml-nlffigen} tool generates one ML structure for each
exported C definition.  In particular, there is one structure per
external variable, function, {\tt typedef}, {\tt struct}, {\tt union},
and {\tt enum}.
Each generated ML structure contains the ML type and values necessary
to manipulate the corresponding C item.

\subsection{External variables}

An external C variable $v$ is represented by an ML structure {\tt
  G\_}$v$.  This structure contains one type and three values, all
with fixed names:

\item[{\tt type t}] is the witness type for the {\tt obj}
  value that represents $v$.
\item[{\tt val typ}] is the run-time type information corresponding to
  type {\tt t}.  The ML type of {\tt typ} is {\tt t C.T.typ}.
\item[{\tt val obj}] is a function that returns the ML value
  representing the C object (i.e., the memory location) referred to by
  $v$.  Depending on whether or not $v$ was declared {\tt const}, the
  type of {\tt obj} is either {\tt unit -> (t, C.ro) C.obj} or {\tt
    unit -> (t, C.rw) C.obj}.  The result of {\tt obj()} is
  ``heavy-weight,'' i.e., it implicitly carries run-time type
\item[{\tt val obj'}] is analogous to {\tt val obj}, the only
  difference being that its result is ``light-weight,'' i.e., without
  run-time type information.  The type of {\tt val obj'} is
  either {\tt unit -> (t, C.ro) C.obj} or {\tt unit -> (t, C.rw) C.obj}.


C declaration & signature of ML-side representation \\ \hline\hline
{\tt extern int i;}

structure G_i : sig
    type t   = C.sint
    val typ  : t C.T.typ
    val obj  : unit -> (t, C.rw) C.obj
    val obj' : unit -> (t, C.rw) C.obj'

\\ \hline
{\tt extern const double d;}

structure G_d : sig
    type t   = C.double
    val typ  : t C.T.typ
    val obj  : unit -> (t, C.ro) C.obj
    val obj' : unit -> (t, C.ro) C.obj'





ViewVC Help
Powered by ViewVC 1.0.0