<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="ffi.cast" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>FFI::cast</refname>
  <refpurpose>Performs a C type cast</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis role="FFI">
   <modifier>public</modifier> <modifier>static</modifier> <type class="union"><type>FFI\CData</type><type>null</type></type><methodname>FFI::cast</methodname>
   <methodparam><type class="union"><type>FFI\CType</type><type>string</type></type><parameter>type</parameter></methodparam>
   <methodparam><type class="union"><type>FFI\CData</type><type>int</type><type>float</type><type>bool</type><type>null</type></type><parameter role="reference">ptr</parameter></methodparam>
  </methodsynopsis>
  <methodsynopsis role="FFI">
   <modifier>public</modifier> <type class="union"><type>FFI\CData</type><type>null</type></type><methodname>FFI::cast</methodname>
   <methodparam><type class="union"><type>FFI\CType</type><type>string</type></type><parameter>type</parameter></methodparam>
   <methodparam><type class="union"><type>FFI\CData</type><type>int</type><type>float</type><type>bool</type><type>null</type></type><parameter role="reference">ptr</parameter></methodparam>
  </methodsynopsis>
  <para>
   <methodname>FFI::cast</methodname> creates a new <classname>FFI\CData</classname>
   object, that references the same C data structure, but is associated with a different type.
   The resulting object does not own the C data, and the source <parameter>ptr</parameter>
   must survive the result. The C type may be specified as a <type>string</type> with any
   valid C type declaration or as <classname>FFI\CType</classname> object, created before.
   If this method is called statically, it must only use predefined C type names (e.g.
   <literal>int</literal>, <literal>char</literal>, etc.); if the method is called as
   instance method, any type declared for the instance is allowed.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>type</parameter></term>
    <listitem>
     <para>
      A valid C declaration as <type>string</type>, or an instance of <classname>FFI\CType</classname>
      which has already been created.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>ptr</parameter></term>
    <listitem>
     <para>
      The handle of the pointer to a C data structure.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns the freshly created <classname>FFI\CData</classname> object.
  </para>
 </refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
