aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorLaurens Van Houtven <_@lvh.cc>2014-06-23 14:08:27 +0200
committerLaurens Van Houtven <_@lvh.cc>2014-06-23 14:08:27 +0200
commit220a98ddfee87e049ddb91229b05e6f9c82a5ddf (patch)
tree40d288e98985fe6fd34ea5909b1d94f32e9fa24e /docs
parent0a1d9e17858f0ab5465d3455970f6525607096ba (diff)
downloadcryptography-220a98ddfee87e049ddb91229b05e6f9c82a5ddf.tar.gz
cryptography-220a98ddfee87e049ddb91229b05e6f9c82a5ddf.tar.bz2
cryptography-220a98ddfee87e049ddb91229b05e6f9c82a5ddf.zip
Move C bindings style guide to C bindings document
Diffstat (limited to 'docs')
-rw-r--r--docs/development/c-bindings.rst72
-rw-r--r--docs/development/submitting-patches.rst72
2 files changed, 72 insertions, 72 deletions
diff --git a/docs/development/c-bindings.rst b/docs/development/c-bindings.rst
index 910f4d3d..1349af73 100644
--- a/docs/development/c-bindings.rst
+++ b/docs/development/c-bindings.rst
@@ -7,6 +7,78 @@ C bindings are bindings to C libraries, using cffi_ whenever possible.
Bindings live in :py:mod:`cryptography.hazmat.bindings`.
+Style guide
+-----------
+
+Don't name parameters:
+
+.. code-block:: c
+
+ /* Good */
+ long f(long);
+ /* Bad */
+ long f(long x);
+
+...unless they're inside a struct:
+
+.. code-block:: c
+
+ struct my_struct {
+ char *name;
+ int number;
+ ...;
+ };
+
+Include ``void`` if the function takes no arguments:
+
+.. code-block:: c
+
+ /* Good */
+ long f(void);
+ /* Bad */
+ long f();
+
+Wrap lines at 80 characters like so:
+
+.. code-block:: c
+
+ /* Pretend this went to 80 characters */
+ long f(long, long,
+ int *)
+
+Include a space after commas between parameters:
+
+.. code-block:: c
+
+ /* Good */
+ long f(int, char *)
+ /* Bad */
+ long f(int,char *)
+
+Use C-style ``/* */`` comments instead of C++-style ``//``:
+
+.. code-block:: c
+
+ // Bad
+ /* Good */
+
+Values set by ``#define`` should be assigned the appropriate type. If you see
+this:
+
+.. code-block:: c
+
+ #define SOME_INTEGER_LITERAL 0x0;
+ #define SOME_UNSIGNED_INTEGER_LITERAL 0x0001U;
+ #define SOME_STRING_LITERAL "hello";
+
+...it should be added to the bindings like so:
+
+.. code-block:: c
+
+ static const int SOME_INTEGER_LITERAL;
+ static const unsigned int SOME_UNSIGNED_INTEGER_LITERAL;
+ static const char *const SOME_STRING_LITERAL;
+
Adding constant, types, functions...
------------------------------------
diff --git a/docs/development/submitting-patches.rst b/docs/development/submitting-patches.rst
index f8c8093c..fe2df431 100644
--- a/docs/development/submitting-patches.rst
+++ b/docs/development/submitting-patches.rst
@@ -78,78 +78,6 @@ C bindings
More information on C bindings can be found in :doc:`the dedicated
section of the documentation <c-bindings>`.
-When binding C code with ``cffi`` we have our own style guide, it's pretty
-simple.
-
-Don't name parameters:
-
-.. code-block:: c
-
- /* Good */
- long f(long);
- /* Bad */
- long f(long x);
-
-...unless they're inside a struct:
-
-.. code-block:: c
-
- struct my_struct {
- char *name;
- int number;
- ...;
- };
-
-Include ``void`` if the function takes no arguments:
-
-.. code-block:: c
-
- /* Good */
- long f(void);
- /* Bad */
- long f();
-
-Wrap lines at 80 characters like so:
-
-.. code-block:: c
-
- /* Pretend this went to 80 characters */
- long f(long, long,
- int *)
-
-Include a space after commas between parameters:
-
-.. code-block:: c
-
- /* Good */
- long f(int, char *)
- /* Bad */
- long f(int,char *)
-
-Use C-style ``/* */`` comments instead of C++-style ``//``:
-
-.. code-block:: c
-
- // Bad
- /* Good */
-
-Values set by ``#define`` should be assigned the appropriate type. If you see
-this:
-
-.. code-block:: c
-
- #define SOME_INTEGER_LITERAL 0x0;
- #define SOME_UNSIGNED_INTEGER_LITERAL 0x0001U;
- #define SOME_STRING_LITERAL "hello";
-
-...it should be added to the bindings like so:
-
-.. code-block:: c
-
- static const int SOME_INTEGER_LITERAL;
- static const unsigned int SOME_UNSIGNED_INTEGER_LITERAL;
- static const char *const SOME_STRING_LITERAL;
-
Tests
-----