Sophie

Sophie

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

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-cast-pointer</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="rn03re66.html" title="+null-cstring-pointer+"><link rel="next" href="rn03re68.html" title="def-foreign-var"></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-cast-pointer</code></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="rn03re66.html">Prev</a>&#160;</td><th width="60%" align="center">Objects</th><td width="20%" align="right">&#160;<a accesskey="n" href="rn03re68.html">Next</a></td></tr></table><hr></div><div class="refentry" title="with-cast-pointer"><a name="uffi.with-cast-pointer"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p><code class="function">with-cast-pointer</code> &#8212; Wraps a body of code with a pointer cast to a new type.
    </p></div><div class="refsynopsisdiv" title="Macro"><h2>Macro</h2><div class="funcsynopsis"><p><code class="funcdef">(with-cast-pointer</code> (<var class="pdparam">binding-name ptr type</var>)) &#8658; &amp;body) &#8658; <var class="pdparam">body</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>binding-name</code></em></span></p></td><td><p>A symbol which will be bound to the casted object.</p></td></tr><tr><td><p><span class="term"><em class="parameter"><code>ptr</code></em></span></p></td><td><p>A pointer to a foreign object.</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 object being pointed to.</p></td></tr><tr><td><p><span class="term">returns</span></p></td><td><p>The value of the object where the pointer points.</p></td></tr></tbody></table></div></div><div class="refsect1" title="Description"><a name="id691042"></a><h2>Description</h2><p>
     Executes BODY with POINTER cast to be a pointer to type TYPE.
     BINDING-NAME is will be bound to this value during the execution of
     BODY.

     This is a no-op in AllegroCL but will wrap BODY in a LET form if
     BINDING-NAME is provided.

     This macro is meant to be used in conjunction with DEREF-POINTER or
     DEREF-ARRAY. In Allegro CL the "cast" will actually take place in
     DEREF-POINTER or DEREF-ARRAY.</p></div><div class="refsect1" title="Examples"><a name="id691056"></a><h2>Examples</h2><pre class="screen">
     (with-foreign-object (size :int)
     ;; FOO is a foreign function returning a :POINTER-VOID
     (let ((memory (foo size)))
     (when (mumble)
     ;; at this point we know for some reason that MEMORY points
     ;; to an array of unsigned bytes
     (with-cast-pointer (memory :unsigned-byte)
     (dotimes (i (deref-pointer size :int))
     (do-something-with
     (deref-array memory '(:array :unsigned-byte) i)))))))</pre></div><div class="refsect1" title="Side Effects"><a name="id691072"></a><h2>Side Effects</h2><p>None.</p></div><div class="refsect1" title="Affected by"><a name="id691082"></a><h2>Affected by</h2><p>None.</p></div><div class="refsect1" title="Exceptional Situations"><a name="id691092"></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="rn03re66.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="rn03re68.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><code class="varname">+null-cstring-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;<code class="function">def-foreign-var</code></td></tr></table></div></body></html>