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/08/14 20:06:09 UTC

[02/14] lucy-clownfish git commit: Implement Meth_Host_Name for Go.

Implement Meth_Host_Name for Go.

Takes Upper_Snake_Case and removes the underscores.


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

Branch: refs/heads/master
Commit: e68fe4bda0d30a7659f744e9dabab297e1fb180d
Parents: 172822e
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Fri Aug 7 17:53:14 2015 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sun Aug 9 19:00:35 2015 -0700

----------------------------------------------------------------------
 runtime/go/ext/clownfish.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e68fe4bd/runtime/go/ext/clownfish.c
----------------------------------------------------------------------
diff --git a/runtime/go/ext/clownfish.c b/runtime/go/ext/clownfish.c
index 7545388..27cd4a0 100644
--- a/runtime/go/ext/clownfish.c
+++ b/runtime/go/ext/clownfish.c
@@ -29,6 +29,7 @@
 #include "Clownfish/Blob.h"
 #include "Clownfish/Boolean.h"
 #include "Clownfish/ByteBuf.h"
+#include "Clownfish/CharBuf.h"
 #include "Clownfish/Class.h"
 #include "Clownfish/Err.h"
 #include "Clownfish/Hash.h"
@@ -186,7 +187,18 @@ Class_To_Host_IMP(Class *self) {
 
 String*
 Method_Host_Name_IMP(Method *self) {
-    return (String*)INCREF(self->name);
+    StringIterator *iter = StrIter_new(self->name, 0);
+    CharBuf *charbuf = CB_new(Str_Get_Size(self->name));
+    int32_t code_point;
+    while (STRITER_DONE != (code_point = StrIter_Next(iter))) {
+        if (code_point != '_') {
+            CB_Cat_Char(charbuf, code_point);
+        }
+    }
+    String *host_name = CB_Yield_String(charbuf);
+    DECREF(charbuf);
+    DECREF(iter);
+    return host_name;
 }
 
 /******************************** Err **************************************/