[Spice-devel] Different styles

Victor Toso lists at victortoso.com
Wed May 25 14:12:25 UTC 2016


Hi!

On Wed, May 25, 2016 at 08:31:45AM -0400, Frediano Ziglio wrote:
> Hi,
>   I was reading the style document and I found some different styles in the code
>
> The structures for GObject differs from the rest of the code, they are
>
> struct DispatcherClass
> {
>     GObjectClass parent_class;
> };
>
> instead of
>
> struct DispatcherClass {
>     GObjectClass parent_class;
> };
>
> (all other structure follow this schema)
>
>
> There is a chapter "Vertical indentation" which state that there is no
> vertical indentation quoting even some example of functions however
> there are some code, like
>
> void red_qxl_on_ic_change(QXLInstance *qxl, SpiceImageCompression ic);
> void red_qxl_on_sv_change(QXLInstance *qxl, int sv);
> void red_qxl_set_mouse_mode(QXLInstance *qxl, uint32_t mode);
> void red_qxl_attach_worker(QXLInstance *qxl);
>
> that follow these specification while others
>
> void                       display_channel_draw                      (DisplayChannel *display,
>                                                                       const SpiceRect *area,
>                                                                       int surface_id);
> void                       display_channel_draw_until                (DisplayChannel *display,
>                                                                       const SpiceRect *area,
>                                                                       int surface_id,
>                                                                       Drawable *last);
> void                       display_channel_update                    (DisplayChannel *display,
>                                                                       uint32_t surface_id,
>                                                                       const QXLRect *area,
>
> that clearly use vertical indentation.
>
> I personally find that vertical indentation tend to cause long lines and
> it's hard to maintain when new declarations are added (like requiring
> new indentation)

I personally like it with struct members or function arguments. As you
put some samples above, why not:

struct TosoClass {
    gchar       *name;
    guint8       age;

    BigStructureHere    *ptr;
    SmallerSt            abc;
};

static void multiple_arg_fn(const gchar         *name,
                            guint8               age,
                            BigStructureHere   **pp,
                            SmallerSt           *edf)
{

:-)

> but the main argument is that I'd like to follow same
> rules or define exceptions with rules (like structure declarations for
> GObject have bracket on first column).
>
> Frediano


More information about the Spice-devel mailing list