php-doc-en/reference/ffi/ffi.xml
2021-12-21 16:13:15 +01:00

86 lines
3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.ffi" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Main interface to C code and data</title>
<titleabbrev>FFI</titleabbrev>
<partintro>
<!-- {{{ FFI intro -->
<section xml:id="ffi.intro">
&reftitle.intro;
<para>
Objects of this class are created by the factory methods <methodname>FFI::cdef</methodname>,
<methodname>FFI::load</methodname> or <methodname>FFI::scope</methodname>. Defined C variables
are made available as properties of the FFI instance, and defined C functions are made available
as methods of the FFI instance. Declared C types can be used to create new C data structures
using <methodname>FFI::new</methodname> and <methodname>FFI::type</methodname>.
</para>
<para>
FFI definition parsing and shared library loading may take significant time. It is not useful
to do it on each HTTP request in a Web environment. However, it is possible to preload FFI definitions
and libraries at PHP startup, and to instantiate FFI objects when necessary. Header files
may be extended with special <literal>FFI_SCOPE</literal> defines (e.g. <code>#define FFI_SCOPE "foo"”"</code>;
the default scope is "C") and then loaded by <methodname>FFI::load</methodname> during preloading.
This leads to the creation of a persistent binding, that will be available to all the following
requests through <methodname>FFI::scope</methodname>.
Refer to the <link linkend="ffi.examples-complete">complete PHP/FFI/preloading example</link>
for details.
</para>
<para>
It is possible to preload more than one C header file into the same scope.
</para>
</section>
<!-- }}} -->
<section xml:id="ffi.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass>
<classname>FFI</classname>
</ooclass>
<classsynopsisinfo>
<ooclass>
<modifier>final</modifier>
<classname>FFI</classname>
</ooclass>
</classsynopsisinfo>
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.ffi')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])">
<xi:fallback/>
</xi:include>
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.ffi.entities.ffi;
</phpdoc:classref>
<!-- 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
-->