lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [1/4] git commit: refs/heads/master - Improve display of function declarations in man pages
Date Sun, 19 May 2013 15:44:21 GMT
Updated Branches:
  refs/heads/master 637d4e633 -> 94899bc38


Improve display of function declarations in man pages

* Put every parameter on a single line.
* Add incremented/decremented comments


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/b6db98a4
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/b6db98a4
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/b6db98a4

Branch: refs/heads/master
Commit: b6db98a4b286ea40ca1cde3f5c2e40f59421015e
Parents: 637d4e6
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sun May 19 14:21:04 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun May 19 14:21:04 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCCClass.c |   63 ++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/b6db98a4/clownfish/compiler/src/CFCCClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCCClass.c b/clownfish/compiler/src/CFCCClass.c
index 64484e3..259fd0f 100644
--- a/clownfish/compiler/src/CFCCClass.c
+++ b/clownfish/compiler/src/CFCCClass.c
@@ -26,6 +26,7 @@
 #include "CFCSymbol.h"
 #include "CFCType.h"
 #include "CFCUtil.h"
+#include "CFCVariable.h"
 
 static char*
 S_man_create_name(CFCClass *klass);
@@ -50,6 +51,9 @@ S_man_create_func(CFCClass *klass, CFCFunction *func, const char *short_sym,
                   const char *full_sym);
 
 static char*
+S_man_create_param_list(CFCFunction *func, const char *full_sym);
+
+static char*
 S_man_create_inheritance(CFCClass *klass);
 
 static char*
@@ -301,24 +305,28 @@ S_man_create_inherited_methods(CFCClass *klass) {
 static char*
 S_man_create_func(CFCClass *klass, CFCFunction *func, const char *short_sym,
                   const char *full_sym) {
-    CFCType *return_type
-        = CFCFunction_get_return_type(func);
+    CFCType    *return_type   = CFCFunction_get_return_type(func);
     const char *return_type_c = CFCType_to_c(return_type);
+    const char *incremented   = "";
+
+    if (CFCType_incremented(return_type)) {
+        incremented = " // incremented";
+    }
 
-    CFCParamList *param_list
-        = CFCFunction_get_param_list(func);
-    const char *param_list_c = CFCParamList_to_c(param_list);
+    char *param_list = S_man_create_param_list(func, full_sym);
 
     const char *pattern =
         ".TP\n"
         ".B %s\n"
         ".na\n"
-        "%s\n"
+        "%s%s\n"
         ".br\n"
-        ".BR \"%s\" \"(%s);\"\n"
+        "%s"
         ".ad\n";
-    char *result = CFCUtil_sprintf(pattern, short_sym, return_type_c, full_sym,
-                                   param_list_c);
+    char *result = CFCUtil_sprintf(pattern, short_sym, return_type_c,
+                                   incremented, param_list);
+
+    FREEMEM(param_list);
 
     // Get documentation, which may be inherited.
     CFCDocuComment *docucomment = CFCFunction_get_docucomment(func);
@@ -371,6 +379,43 @@ S_man_create_func(CFCClass *klass, CFCFunction *func, const char *short_sym,
 }
 
 static char*
+S_man_create_param_list(CFCFunction *func, const char *full_sym) {
+    CFCParamList  *param_list = CFCFunction_get_param_list(func);
+    CFCVariable  **variables  = CFCParamList_get_variables(param_list);
+
+    if (!variables[0]) {
+        return CFCUtil_sprintf(".BR %s (void);\n", full_sym);
+    }
+
+    char *result = CFCUtil_sprintf(".BR %s (", full_sym);
+
+    for (int i = 0; variables[i]; ++i) {
+        CFCVariable *variable = variables[i];
+        CFCType     *type     = CFCVariable_get_type(variable);
+        const char  *type_c   = CFCType_to_c(type);
+        const char  *name     = CFCVariable_micro_sym(variable);
+
+        result = CFCUtil_cat(result, "\n.br\n.RB \"    ", type_c, " \" ", name,
+                             NULL);
+
+        if (variables[i+1] || CFCType_decremented(type)) {
+            result = CFCUtil_cat(result, " \"", NULL);
+            if (variables[i+1]) {
+                result = CFCUtil_cat(result, ",", NULL);
+            }
+            else {
+                result = CFCUtil_cat(result, " // decremented", NULL);
+            }
+            result = CFCUtil_cat(result, "\"", NULL);
+        }
+    }
+
+    result = CFCUtil_cat(result, "\n.br\n);\n.br\n", NULL);
+
+    return result;
+}
+
+static char*
 S_man_create_inheritance(CFCClass *klass) {
     CFCClass *ancestor = CFCClass_get_parent(klass);
     char     *result   = CFCUtil_strdup("");


Mime
View raw message