You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2015/05/07 00:18:30 UTC

[04/23] lucy-clownfish git commit: Determine Go package from Clownfish parcel.

Determine Go package from Clownfish parcel.


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

Branch: refs/heads/master
Commit: 9bbfad46ef61715abfe0245c5ea1fe1bf5f06a67
Parents: f26da1e
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Sun Mar 29 15:02:38 2015 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Wed May 6 14:25:26 2015 -0700

----------------------------------------------------------------------
 compiler/src/CFCGoTypeMap.c | 20 ++++++++++++++++++++
 compiler/src/CFCGoTypeMap.h |  5 +++++
 2 files changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/9bbfad46/compiler/src/CFCGoTypeMap.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoTypeMap.c b/compiler/src/CFCGoTypeMap.c
index f5b689f..516f42b 100644
--- a/compiler/src/CFCGoTypeMap.c
+++ b/compiler/src/CFCGoTypeMap.c
@@ -124,3 +124,23 @@ CFCGoTypeMap_go_type_name(CFCType *type, CFCParcel *current_parcel) {
     return NULL;
 }
 
+char*
+CFCGoTypeMap_go_short_package(CFCParcel *parcel) {
+    // The Go short package name is the last component of the dot-separated
+    // Clownfish parcel name.
+    const char *parcel_frag = strrchr(CFCParcel_get_name(parcel), '.');
+    if (parcel_frag) {
+        parcel_frag += 1;
+    }
+    else {
+        parcel_frag = CFCParcel_get_name(parcel);
+    }
+    // TODO: Don't downcase package name once caps are forbidden in Clownfish
+    // parcel names.
+    char *go_short_package = CFCUtil_strdup(parcel_frag);
+    for (int i = 0; go_short_package[i] != '\0'; i++) {
+        go_short_package[i] = tolower(go_short_package[i]);
+    }
+    return go_short_package;
+}
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/9bbfad46/compiler/src/CFCGoTypeMap.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoTypeMap.h b/compiler/src/CFCGoTypeMap.h
index 3af6137..f0b3929 100644
--- a/compiler/src/CFCGoTypeMap.h
+++ b/compiler/src/CFCGoTypeMap.h
@@ -28,6 +28,11 @@ char*
 CFCGoTypeMap_go_type_name(struct CFCType *type,
                           struct CFCParcel *current_parcel);
 
+/** Return the Go package name associated with a Clownfish parcel.
+ */
+char*
+CFCGoTypeMap_go_short_package(struct CFCParcel *parcel);
+
 #ifdef __cplusplus
 }
 #endif