Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > e3d62627d1d1aab7ab1be2dd7f65a872 > files > 402

ecl-10.4.1-1.fc14.x86_64.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>def-foreign-var</title><link rel="stylesheet" href="ecl.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="The ECL manual"><link rel="up" href="rn03.html" title="Objects"><link rel="prev" href="rn03re67.html" title="with-cast-pointer"><link rel="next" href="rn04.html" title="Strings"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><code class="function">def-foreign-var</code></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="rn03re67.html">Prev</a>&#160;</td><th width="60%" align="center">Objects</th><td width="20%" align="right">&#160;<a accesskey="n" href="rn04.html">Next</a></td></tr></table><hr></div><div class="refentry" title="def-foreign-var"><a name="uffi.def-foreign-var"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p><code class="function">def-foreign-var</code> &#8212; 
     Defines a symbol macro to access a variable in foreign code
    </p></div><div class="refsynopsisdiv" title="Macro"><h2>Macro</h2><div class="funcsynopsis"><p><code class="funcdef">(def-foreign-var</code> <var class="pdparam">name</var>) &#8658; <var class="pdparam">type</var>) &#8658; <var class="pdparam">module</var>)</p></div><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>name</code></em></span></p></td><td><p>     
	A string or list specificying the symbol macro's name. If it is a
	string, that names the foreign variable. A Lisp name is created
	by translating #\_ to #\- and by converting to upper-case in
	case-insensitive Lisp implementations. If it is a list, the first
	item is a string specifying the foreign variable name and the
	second it is a symbol stating the Lisp name.</p></td></tr><tr><td><p><span class="term"><em class="parameter"><code>type</code></em></span></p></td><td><p>A foreign type of the foreign variable.</p></td></tr><tr><td><p><span class="term"><span class="returnvalue">module</span></span></p></td><td><p>
	A string specifying the module (or library) the foreign variable
	resides in. (Required by Lispworks)</p></td></tr></tbody></table></div></div><div class="refsect1" title="Description"><a name="id691214"></a><h2>Description</h2><p>
     Defines a symbol macro which can be used to access (get and set) the
     value of a variable in foreign code.</p></div><div class="refsect1" title="Examples"><a name="id691225"></a><h2>Examples</h2><div class="refsect2" title="C code"><a name="id691231"></a><h3>C code</h3><pre class="screen">
      int baz = 3;

      typedef struct {
      int x;
      double y;
      } foo_struct;

      foo_struct the_struct = { 42, 3.2 };

      int foo () {
      return baz;
      }</pre></div><div class="refsect2" title="Lisp code"><a name="id691245"></a><h3>Lisp code</h3><pre class="screen">
      (uffi:def-struct foo-struct
      (x :int)
      (y :double))

      (uffi:def-function ("foo" foo)
      ()
      :returning :int
      :module "foo")

      (uffi:def-foreign-var ("baz" *baz*) :int "foo")
      (uffi:def-foreign-var ("the_struct" *the-struct*) foo-struct "foo")


      *baz*
      =&gt; 3

      (incf *baz*)
      =&gt; 4

      (foo)
      =&gt; 4</pre></div></div><div class="refsect1" title="Side Effects"><a name="id691261"></a><h2>Side Effects</h2><p>None.</p></div><div class="refsect1" title="Affected by"><a name="id691271"></a><h2>Affected by</h2><p>None.</p></div><div class="refsect1" title="Exceptional Situations"><a name="id691281"></a><h2>Exceptional Situations</h2><p>None.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="rn03re67.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="rn03.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="rn04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><code class="function">with-cast-pointer</code>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Strings</td></tr></table></div></body></html>