[vala/staging] ccode: Reformat function declaration and definition for better readability
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] ccode: Reformat function declaration and definition for better readability
- Date: Sun, 19 Nov 2017 13:06:47 +0000 (UTC)
commit 3019b67eaf8da1a0df1519a4728eed1165b12c33
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Mar 9 13:39:10 2017 +0100
ccode: Reformat function declaration and definition for better readability
https://bugzilla.gnome.org/show_bug.cgi?id=688447
ccode/valaccodefunction.vala | 10 +++++++++-
ccode/valaccodewriter.vala | 7 +++++++
2 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/ccode/valaccodefunction.vala b/ccode/valaccodefunction.vala
index 91addcd..8ef10bb 100644
--- a/ccode/valaccodefunction.vala
+++ b/ccode/valaccodefunction.vala
@@ -118,9 +118,14 @@ public class Vala.CCodeFunction : CCodeNode {
writer.write_string ("inline ");
}
writer.write_string (return_type);
- writer.write_string (" ");
+ if (is_declaration) {
+ writer.write_string (" ");
+ } else {
+ writer.write_newline ();
+ }
writer.write_string (name);
writer.write_string (" (");
+ int param_pos_begin = (is_declaration ? return_type.char_count () + 1 : 0 ) + name.char_count
() + 2;
bool has_args = (CCodeModifiers.PRINTF in modifiers || CCodeModifiers.SCANF in modifiers);
int i = 0;
@@ -129,6 +134,8 @@ public class Vala.CCodeFunction : CCodeNode {
foreach (CCodeParameter param in parameters) {
if (i > 0) {
writer.write_string (", ");
+ writer.write_newline ();
+ writer.write_nspaces (param_pos_begin);
}
param.write (writer);
if (CCodeModifiers.FORMAT_ARG in param.modifiers) {
@@ -177,6 +184,7 @@ public class Vala.CCodeFunction : CCodeNode {
writer.write_string (";");
} else {
+ writer.write_newline ();
block.write (writer);
writer.write_newline ();
}
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala
index 2e58a41..0215e75 100644
--- a/ccode/valaccodewriter.vala
+++ b/ccode/valaccodewriter.vala
@@ -175,6 +175,13 @@ public class Vala.CCodeWriter {
}
/**
+ * Writes n spaces.
+ */
+ public void write_nspaces (uint n) {
+ stream.puts (string.nfill (n, ' '));
+ }
+
+ /**
* Writes the specified string.
*
* @param s a string
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]