[libadwaita] hacking: Describe how to style function prototypes
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita] hacking: Describe how to style function prototypes
- Date: Tue, 25 May 2021 13:35:01 +0000 (UTC)
commit ceb2c870dc1bbb164683ad394d6b444e99550c0c
Author: Adrien Plazas <kekun plazas laposte net>
Date: Tue May 25 14:21:55 2021 +0200
hacking: Describe how to style function prototypes
Currently they are all over the place.
HACKING.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
---
diff --git a/HACKING.md b/HACKING.md
index ef3dd7b8..73725775 100644
--- a/HACKING.md
+++ b/HACKING.md
@@ -48,6 +48,59 @@ static gboolean
key_press_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
```
+### Function Prototypes
+
+Function prototypes should be grouped together in logical groups, e.g. all
+constructors, or all accessords to a given property.
+There should be no empty line in a group, and groups should be separated from
+each other by an empty line.
+
+The function's attributes and returned type should be on the same line as the
+function's name.
+Have only one parameter per line.
+If a function takes no parameters, explicit it by using `void` as the parameter.
+
+In a group, align function names, the opening parentheses, and parameter names
+together.
+Use the least possible amount of spaces while preserving alignment.
+Asterisks from the returned type should be stuck to the function's name.
+Similarly, asterisks from a parameter's type should be stuck to the parameter's
+name.
+
+Getters should come before setters.
+
+In public headers, set the function's availability or deprecation state in a
+line preceding its prototype.
+
+*Good*:
+
+```c
+ADW_AVAILABLE_IN_ALL
+AdwFoo *adw_foo_new (void) G_GNUC_WARN_UNUSED_RESULT;
+
+ADW_AVAILABLE_IN_ALL
+AdwBar *adw_foo_get_bar (AdwFoo *self);
+ADW_AVAILABLE_IN_ALL
+void adw_foo_set_bar (AdwFoo *self,
+ AdwBar *bar);
+
+ADW_AVAILABLE_IN_ALL
+gboolean adw_foo_get_bit (AdwFoo *self);
+ADW_AVAILABLE_IN_ALL
+void adw_foo_set_bit (AdwFoo *self,
+ gboolean bit);
+
+ADW_AVAILABLE_IN_ALL
+void adw_foo_add_baz (AdwFoo *self,
+ AdwBaz *baz);
+ADW_AVAILABLE_IN_ALL
+void adw_foo_remove_baz (AdwFoo *self,
+ AdwBaz *baz);
+
+ADW_AVAILABLE_IN_ALL
+void adw_foo_frobnicate (AdwFoo *self);
+```
+
### Braces
Everything besides functions and structs have the opening curly brace on the same line.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]