1
0
Fork 0

HACKING: Add note about object instance pointer naming

Mutter so far very rarely use the name `self`, so lets describe that in
the conventions document so that we can stay consistent.

Also mention how to deal with abstract/generic object instance pointers
vs sub type ones.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3297>
This commit is contained in:
Jonas Ådahl 2023-09-27 14:23:56 +08:00 committed by Marge Bot
parent da8f881551
commit a8aa7bae10

View file

@ -52,6 +52,39 @@ style][gnome-coding-style], with some additions described below.
* Initialize and assign floating point variables (i.e. `float` or
`double`) using the form `floating_point = 3.14159` or `ratio = 2.0`.
## Naming conventions
* For object instance pointers, use a descriptive name instead of `self`, e.g.
```c
G_DEFINE_TYPE (MetaPlaceholder, meta_placeholder, G_TYPE_OBJECT)
...
void
meta_placeholder_hold_place (MetaPlaceholder *placeholder)
{
...
}
```
* When object instance pointers are pointers to non-generic implementations of
a generalized type, the convention is to suffix the variable name with the
sub-type name. E.g.
```c
G_DEFINE_TYPE (MetaPlaceholderWayland, meta_placeholder_wayland,
META_TYPE_PLACEHOLDER)
...
void
meta_placeholder_wayland_get_waylandy (MetaPlaceholderWayland *placeholder_wayland)
{
...
}
```
## Header (.h) files
* The return type and `*` are separated by a space.