Add Go bindings for Boolean and Blob constructors.

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

Branch: refs/heads/master
Commit: bd8b54b08aac4710dbbc61bab70bdc760558fcd5
Parents: ad3282d
Author: Marvin Humphrey <[email protected]>
Authored: Fri Jul 24 14:16:18 2015 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Thu Jul 30 10:45:12 2015 -0700

----------------------------------------------------------------------
 runtime/go/clownfish/clownfish.go | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/bd8b54b0/runtime/go/clownfish/clownfish.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/clownfish.go 
b/runtime/go/clownfish/clownfish.go
index 9a13cff..2c5f40e 100644
--- a/runtime/go/clownfish/clownfish.go
+++ b/runtime/go/clownfish/clownfish.go
@@ -24,9 +24,10 @@ package clownfish
 #include "Clownfish/Err.h"
 #include "Clownfish/Class.h"
 #include "Clownfish/String.h"
+#include "Clownfish/Blob.h"
 #include "Clownfish/Hash.h"
 #include "Clownfish/Vector.h"
-#include "Clownfish/String.h"
+#include "Clownfish/Boolean.h"
 #include "Clownfish/Util/Memory.h"
 #include "Clownfish/Method.h"
 
@@ -165,3 +166,21 @@ func (s *StringIMP) SwapChars(match, replacement rune) 
string {
        defer C.cfish_dec_refcount(unsafe.Pointer(retvalCF))
        return CFStringToGo(unsafe.Pointer(retvalCF))
 }
+
+func NewBoolean(val bool) Boolean {
+       if val {
+               return 
WRAPBoolean(unsafe.Pointer(C.cfish_inc_refcount(unsafe.Pointer(C.CFISH_TRUE))))
+       } else {
+               return 
WRAPBoolean(unsafe.Pointer(C.cfish_inc_refcount(unsafe.Pointer(C.CFISH_FALSE))))
+       }
+}
+
+func NewBlob(content []byte) Blob {
+       size := C.size_t(len(content))
+       var buf *C.char = nil
+       if size > 0 {
+               buf = ((*C.char)(unsafe.Pointer(&content[0])))
+       }
+       obj := C.cfish_Blob_new(buf, size)
+       return WRAPBlob(unsafe.Pointer(obj))
+}

Reply via email to