Generated C code could prettier
@murrayc
Submitted by Murray Cumming Link to original bug (#688447)
Description
Some thought about the generated code that seem fixable. This would make people feel better about knowing that they can switch to the C code one day, and make it easier to debug problems in the generated code.
- It would be nice if functions were laid out like in glib/gtk+ code:
static ReturnType
function_name()
rather than
static ReturnType function_name()
- There should be newlines between things such as functions, defines and enums. Right now it is all bunched up together like this:
void module_init (RygelPluginLoader* loader);
#define RYGEL_EXAMPLE_SERVER_PLUGIN_NAME "ExampleServerPluginC"
RygelExampleServerPlugin* rygel_example_server_plugin_new (void);
RygelExampleServerPlugin* rygel_example_server_plugin_construct (GType object_type);
GType rygel_example_server_plugin_get_type (void) G_GNUC_CONST;
enum {
RYGEL_EXAMPLE_SERVER_PLUGIN_DUMMY_PROPERTY
};
#define RYGEL_EXAMPLE_SERVER_PLUGIN_TITLE "Example Server Plugin C"
#define RYGEL_EXAMPLE_SERVER_PLUGIN_DESCRIPTION "An example Rygel server plugin implemented in vala."
RygelExampleRootContainer* rygel_example_root_container_new (const gchar* title);
RygelExampleRootContainer* rygel_example_root_container_construct (GType object_type, const gchar* title);
GType rygel_example_root_container_get_type (void) G_GNUC_CONST;
- Pointer type syntax could be like glib/GTK+. I don't like it (I like C++) but it's normal for C:
For instance, now I have:
RygelExampleServerPlugin * self = NULL;
RygelExampleRootContainer* _tmp0_;
(Notice the extra space on that first line). though this would be more normal:
RygelExampleServerPlugin *self = NULL;
RygelExampleRootContainer *_tmp0_;
-
There should be newlines between if() blocks and the following code.
-
There should be newlines between the initial variable declarations and the g_return_if*() checks, and then between those checks and the actual code.
-
This is harder to do right, but it would be nice if the lines were split, with an indent, at 80 (or so) columns.
Depends on
Edited by Rico Tzschichholz