EVOLUTION-MANAGER
Edit File: index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>CFFI documentation — CFFI 1.6.0 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '1.6.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="top" title="CFFI 1.6.0 documentation" href="#" /> <link rel="next" title="What’s New" href="whatsnew.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="whatsnew.html" title="What’s New" accesskey="N">next</a> |</li> <li><a href="#">CFFI 1.6.0 documentation</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="cffi-documentation"> <h1>CFFI documentation<a class="headerlink" href="#cffi-documentation" title="Permalink to this headline">¶</a></h1> <p>C Foreign Function Interface for Python. Interact with almost any C code from Python, based on C-like declarations that you can often copy-paste from header files or documentation.</p> <ul class="simple"> <li><a class="reference internal" href="#goals">Goals</a><ul> <li><a class="reference internal" href="#comments-and-bugs">Comments and bugs</a></li> </ul> </li> </ul> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="whatsnew.html">What’s New</a><ul> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-6">v1.6</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-5-2">v1.5.2</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-5-1">v1.5.1</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-5-0">v1.5.0</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-4-2">v1.4.2</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-4-1">v1.4.1</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-4-0">v1.4.0</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-3-1">v1.3.1</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-3-0">v1.3.0</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-2-1">v1.2.1</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-2-0">v1.2.0</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-1-2">v1.1.2</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-1-1">v1.1.1</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-1-0">v1.1.0</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-0-3">v1.0.3</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-0-2">v1.0.2</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-0-1">v1.0.1</a></li> <li class="toctree-l2"><a class="reference internal" href="whatsnew.html#v1-0-0">v1.0.0</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="installation.html">Installation and Status</a><ul> <li class="toctree-l2"><a class="reference internal" href="installation.html#platform-specific-instructions">Platform-specific instructions</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="overview.html">Overview</a><ul> <li class="toctree-l2"><a class="reference internal" href="overview.html#simple-example-abi-level-in-line">Simple example (ABI level, in-line)</a></li> <li class="toctree-l2"><a class="reference internal" href="overview.html#out-of-line-example-abi-level-out-of-line">Out-of-line example (ABI level, out-of-line)</a></li> <li class="toctree-l2"><a class="reference internal" href="overview.html#real-example-api-level-out-of-line">Real example (API level, out-of-line)</a></li> <li class="toctree-l2"><a class="reference internal" href="overview.html#struct-array-example-minimal-in-line">Struct/Array Example (minimal, in-line)</a></li> <li class="toctree-l2"><a class="reference internal" href="overview.html#purely-for-performance-api-level-out-of-line">Purely for performance (API level, out-of-line)</a></li> <li class="toctree-l2"><a class="reference internal" href="overview.html#embedding">Embedding</a></li> <li class="toctree-l2"><a class="reference internal" href="overview.html#what-actually-happened">What actually happened?</a></li> <li class="toctree-l2"><a class="reference internal" href="overview.html#abi-versus-api">ABI versus API</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="using.html">Using the ffi/lib objects</a><ul> <li class="toctree-l2"><a class="reference internal" href="using.html#working-with-pointers-structures-and-arrays">Working with pointers, structures and arrays</a></li> <li class="toctree-l2"><a class="reference internal" href="using.html#python-3-support">Python 3 support</a></li> <li class="toctree-l2"><a class="reference internal" href="using.html#an-example-of-calling-a-main-like-thing">An example of calling a main-like thing</a></li> <li class="toctree-l2"><a class="reference internal" href="using.html#function-calls">Function calls</a></li> <li class="toctree-l2"><a class="reference internal" href="using.html#variadic-function-calls">Variadic function calls</a></li> <li class="toctree-l2"><a class="reference internal" href="using.html#extern-python-new-style-callbacks">Extern “Python” (new-style callbacks)</a></li> <li class="toctree-l2"><a class="reference internal" href="using.html#callbacks-old-style">Callbacks (old style)</a></li> <li class="toctree-l2"><a class="reference internal" href="using.html#windows-calling-conventions">Windows: calling conventions</a></li> <li class="toctree-l2"><a class="reference internal" href="using.html#ffi-interface">FFI Interface</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="ref.html">CFFI Reference</a><ul> <li class="toctree-l2"><a class="reference internal" href="ref.html#ffi-interface">FFI Interface</a></li> <li class="toctree-l2"><a class="reference internal" href="ref.html#conversions">Conversions</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="cdef.html">Preparing and Distributing modules</a><ul> <li class="toctree-l2"><a class="reference internal" href="cdef.html#ffi-cdef-declaring-types-and-functions">ffi.cdef(): declaring types and functions</a></li> <li class="toctree-l2"><a class="reference internal" href="cdef.html#ffi-dlopen-loading-libraries-in-abi-mode">ffi.dlopen(): loading libraries in ABI mode</a></li> <li class="toctree-l2"><a class="reference internal" href="cdef.html#ffi-set-source-preparing-out-of-line-modules">ffi.set_source(): preparing out-of-line modules</a></li> <li class="toctree-l2"><a class="reference internal" href="cdef.html#letting-the-c-compiler-fill-the-gaps">Letting the C compiler fill the gaps</a></li> <li class="toctree-l2"><a class="reference internal" href="cdef.html#ffi-compile-etc-compiling-out-of-line-modules">ffi.compile() etc.: compiling out-of-line modules</a></li> <li class="toctree-l2"><a class="reference internal" href="cdef.html#ffi-include-combining-multiple-cffi-interfaces">ffi.include(): combining multiple CFFI interfaces</a></li> <li class="toctree-l2"><a class="reference internal" href="cdef.html#ffi-cdef-limitations">ffi.cdef() limitations</a></li> <li class="toctree-l2"><a class="reference internal" href="cdef.html#debugging-dlopen-ed-c-libraries">Debugging dlopen’ed C libraries</a></li> <li class="toctree-l2"><a class="reference internal" href="cdef.html#ffi-verify-in-line-api-mode">ffi.verify(): in-line API-mode</a></li> <li class="toctree-l2"><a class="reference internal" href="cdef.html#upgrading-from-cffi-0-9-to-cffi-1-0">Upgrading from CFFI 0.9 to CFFI 1.0</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="embedding.html">Using CFFI for embedding</a><ul> <li class="toctree-l2"><a class="reference internal" href="embedding.html#usage">Usage</a></li> <li class="toctree-l2"><a class="reference internal" href="embedding.html#more-reading">More reading</a></li> <li class="toctree-l2"><a class="reference internal" href="embedding.html#troubleshooting">Troubleshooting</a></li> <li class="toctree-l2"><a class="reference internal" href="embedding.html#issues-about-using-the-so">Issues about using the .so</a></li> <li class="toctree-l2"><a class="reference internal" href="embedding.html#using-multiple-cffi-made-dlls">Using multiple CFFI-made DLLs</a></li> <li class="toctree-l2"><a class="reference internal" href="embedding.html#multithreading">Multithreading</a></li> <li class="toctree-l2"><a class="reference internal" href="embedding.html#testing">Testing</a></li> <li class="toctree-l2"><a class="reference internal" href="embedding.html#embedding-and-extending">Embedding and Extending</a></li> </ul> </li> </ul> </div> <div class="section" id="goals"> <h2>Goals<a class="headerlink" href="#goals" title="Permalink to this headline">¶</a></h2> <p>The interface is based on <a class="reference external" href="http://luajit.org/ext_ffi.html">LuaJIT’s FFI</a>, and follows a few principles:</p> <ul class="simple"> <li>The goal is to call C code from Python without learning a 3rd language: existing alternatives require users to learn domain specific language (<a class="reference external" href="http://www.cython.org">Cython</a>, <a class="reference external" href="http://www.swig.org/">SWIG</a>) or API (<a class="reference external" href="http://docs.python.org/library/ctypes.html">ctypes</a>). The CFFI design requires users to know only C and Python, minimizing the extra bits of API that need to be learned.</li> <li>Keep all the Python-related logic in Python so that you don’t need to write much C code (unlike <a class="reference external" href="http://docs.python.org/extending/extending.html">CPython native C extensions</a>).</li> <li>The preferred way is to work at the level of the API (Application Programming Interface): the C compiler is called from the declarations you write to validate and link to the C language constructs. Alternatively, it is also possible to work at the ABI level (Application Binary Interface), the way <a class="reference external" href="http://docs.python.org/library/ctypes.html">ctypes</a> work. However, on non-Windows platforms, C libraries typically have a specified C API but not an ABI (e.g. they may document a “struct” as having at least these fields, but maybe more).</li> <li>Try to be complete. For now some C99 constructs are not supported, but all C89 should be, including macros (and including macro “abuses”, which you can <a class="reference external" href="overview.html#abi-versus-api">manually wrap</a> in saner-looking C functions).</li> <li>Attempt to support both PyPy and CPython, with a reasonable path for other Python implementations like IronPython and Jython.</li> <li>Note that this project is <strong>not</strong> about embedding executable C code in Python, unlike <a class="reference external" href="http://wiki.scipy.org/Weave">Weave</a>. This is about calling existing C libraries from Python.</li> </ul> <p>Get started by reading <a class="reference external" href="overview.html">the overview</a>.</p> </div> <div class="section" id="comments-and-bugs"> <h2>Comments and bugs<a class="headerlink" href="#comments-and-bugs" title="Permalink to this headline">¶</a></h2> <p>The best way to contact us is on the IRC <tt class="docutils literal"><span class="pre">#pypy</span></tt> channel of <tt class="docutils literal"><span class="pre">irc.freenode.net</span></tt>. Feel free to discuss matters either there or in the <a class="reference external" href="https://groups.google.com/forum/#!forum/python-cffi">mailing list</a>. Please report to the <a class="reference external" href="https://bitbucket.org/cffi/cffi/issues">issue tracker</a> any bugs.</p> <p>As a general rule, when there is a design issue to resolve, we pick the solution that is the “most C-like”. We hope that this module has got everything you need to access C code and nothing more.</p> <p>— the authors, Armin Rigo and Maciej Fijalkowski</p> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="#">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">CFFI documentation</a><ul> <li><a class="reference internal" href="#goals">Goals</a></li> <li><a class="reference internal" href="#comments-and-bugs">Comments and bugs</a></li> </ul> </li> </ul> <h4>Next topic</h4> <p class="topless"><a href="whatsnew.html" title="next chapter">What’s New</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/index.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="whatsnew.html" title="What’s New" >next</a> |</li> <li><a href="#">CFFI 1.6.0 documentation</a> »</li> </ul> </div> <div class="footer"> © Copyright 2012-2015, Armin Rigo, Maciej Fijalkowski. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>