Sophie

Sophie

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

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>with-foreign-object</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="rn03re57.html" title="free-foreign-object"><link rel="next" href="rn03re59.html" title="size-of-foreign-type"></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">with-foreign-object</code></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="rn03re57.html">Prev</a>&#160;</td><th width="60%" align="center">Objects</th><td width="20%" align="right">&#160;<a accesskey="n" href="rn03re59.html">Next</a></td></tr></table><hr></div><div class="refentry" title="with-foreign-object"><a name="uffi.with-foreign-object"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p><code class="function">with-foreign-object</code> &#8212; Wraps the allocation of a foreign object around a body of code.
    </p></div><div class="refsynopsisdiv" title="Macro"><h2>Macro</h2><div class="funcsynopsis"><p><code class="funcdef">(with-foreign-object</code> <var class="pdparam">(var type)</var>) &#8658; <var class="pdparam">&amp;body</var>) &#8658; <var class="pdparam">body</var>)</p></div></div><div class="refsect1" title="Arguments and Values"><a name="id689761"></a><h2>Arguments and Values</h2><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>var</code></em></span></p></td><td><p>The variable name to bind.</p></td></tr><tr><td><p><span class="term"><em class="parameter"><code>type</code></em></span></p></td><td><p>The type of foreign object to allocate. This parameter is evaluated.</p></td></tr><tr><td><p><span class="term">returns</span></p></td><td><p>The result of evaluating the <em class="parameter"><code>body</code></em>.</p></td></tr></tbody></table></div></div><div class="refsect1" title="Description"><a name="id689824"></a><h2>Description</h2><p> This function wraps the allocation,
    binding, and destruction of a foreign object.  On <span class="application">CMUCL</span> and <span class="application">Lispworks</span>
    platforms the object is stack allocated for efficiency. Benchmarks show
    that <span class="application">AllegroCL</span> performs much better with static allocation.</p></div><div class="refsect1" title="Examples"><a name="id689854"></a><h2>Examples</h2><pre class="screen">
     (defun gethostname2 ()
     "Returns the hostname"
     (uffi:with-foreign-object (name '(:array :unsigned-char 256))
     (if (zerop (c-gethostname (uffi:char-array-to-pointer name) 256))
     (uffi:convert-from-foreign-string name)
     (error "gethostname() failed."))))</pre></div><div class="refsect1" title="Side Effects"><a name="id689868"></a><h2>Side Effects</h2><p>None.</p></div><div class="refsect1" title="Affected by"><a name="id689879"></a><h2>Affected by</h2><p>None.</p></div><div class="refsect1" title="Exceptional Situations"><a name="id689889"></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="rn03re57.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="rn03re59.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><code class="function">free-foreign-object</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;<code class="function">size-of-foreign-type</code></td></tr></table></div></body></html>