Author: Armin Rigo <[email protected]>
Branch:
Changeset: r2067:548abe58b822
Date: 2015-05-20 18:04 +0200
http://bitbucket.org/cffi/cffi/changeset/548abe58b822/
Log: tweak tweak the docs
diff --git a/doc/source/cdef.rst b/doc/source/cdef.rst
--- a/doc/source/cdef.rst
+++ b/doc/source/cdef.rst
@@ -300,6 +300,7 @@
like definitions for custom "wrapper" C functions. The goal is that
the .c file can be generated like this::
+ // C file "module_name.c"
#include <Python.h>
...c_header_source...
@@ -320,7 +321,7 @@
least ``libraries=['foo']`` in order to link with ``libfoo.so`` or
``libfoo.so.X.Y``, or ``foo.dll`` on Windows. The ``sources`` is a
list of extra .c files compiled and linked together (the file
-``module_name.c`` is always generated and automatically added as the
+``module_name.c`` shown above is always generated and automatically added as
the
first argument to ``sources``). See the distutils documentations for
`more information about the other arguments`__.
diff --git a/doc/source/overview.rst b/doc/source/overview.rst
--- a/doc/source/overview.rst
+++ b/doc/source/overview.rst
@@ -258,12 +258,20 @@
errors, as usual e.g. if you misdeclare some function's signature.
Note that the ``C header`` part can contain arbitrary C code. You can
-use it to declare some more helpers written in C. To export these
-helpers to Python, put their signature in the ``cdef()`` too. This
-can be used for example to wrap "crazy" macros into more standard C
-functions. (If all you need is to call "non-crazy" macros, then you
-can directly declare them in the ``cdef()`` as if they were
-functions.)
+use it to declare some more helper functions written in C. To export
+these helpers to Python, put their signature in the ``cdef()`` too.
+(You can use the ``static`` C keyword, as in ``static int
+myhelper(int x) { real_code_here; }``, because these helpers are only
+referenced from the "magic" C code that is generated afterwards in the
+same C file.)
+
+This can be used for example to wrap "crazy" macros into more standard
+C functions. The extra layer of C can be useful for other reasons
+too, like calling functions that expect some complicated argument
+structures that you prefer to build in C rather than in Python. On
+the other hand, if all you need is to call "function-like" macros,
+then you can directly declare them in the ``cdef()`` as if they were
+functions.
The generated piece of C code should be the same independently on the
platform on which you run it, so in simple cases you can simply
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit