[glib-networking/mcatanzaro/hacking] Add HACKING.md to document code style rules



commit 5c255873b4073dff0706895559c537aa82901858
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon Jun 24 20:19:22 2019 -0500

    Add HACKING.md to document code style rules
    
    This is very very basic as of yet, but maybe we will add more rules over
    time.

 HACKING.md | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
---
diff --git a/HACKING.md b/HACKING.md
new file mode 100644
index 0000000..a6f9af0
--- /dev/null
+++ b/HACKING.md
@@ -0,0 +1,37 @@
+# Code Style
+
+In order to keep the code nice and clean we have a few requirements you'll
+need to stick to in order to get your patch accepted:
+
+ * Use GNU-style indentation:
+
+   ```
+   if (condition)
+     {
+       // body
+     }
+   ```
+
+ * No braces for one line control clauses except when another clause in the
+   chain contains more than one line.
+
+ * Callback functions have a suffix _cb.
+
+ * Use `char`/`int`/`double`/…, not `gchar`/`gint`/`gdouble`/… types, except
+   when implementing GLib vfuncs that use these types.
+
+ * All implementation files must include first `"config.h"`, followed by
+   the primary header, followed by a blank line, followed by all the
+   local headers sorted alphabetically, followed by a blank line,
+   followed by all the system headers sorted alphabetically. Headers
+   should follow the same pattern excluding the config.h and
+   self file section, for obvious reasons.
+
+ * There's no space between a type cast and the variable name:  Right:
+   `(int *)foo`. Wrong: `(int*) foo`.
+
+ * Avoid explicit comparisons against TRUE, FALSE, and NULL. Right:
+   `if (!condition)`, `if (!pointer)`, `if (integer == 0)`. Wrong:
+   `if (condition == FALSE)`, `if (pointer == NULL)`, `if (!integer)`.
+   Exception: `pointer != NULL` may be used to convert to gboolean since some
+   developers find this more natural than `!!pointer`.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]