Custom Go binding for Class_Make_Obj.

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

Branch: refs/heads/master
Commit: 0ca01dd52e68e14271e891add1b312249ea1549e
Parents: b42dfa9
Author: Marvin Humphrey <[email protected]>
Authored: Mon Aug 10 14:27:18 2015 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Mon Aug 10 15:11:57 2015 -0700

----------------------------------------------------------------------
 runtime/go/build.go                | 1 +
 runtime/go/clownfish/class_test.go | 8 ++++++++
 runtime/go/clownfish/clownfish.go  | 6 ++++++
 3 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0ca01dd5/runtime/go/build.go
----------------------------------------------------------------------
diff --git a/runtime/go/build.go b/runtime/go/build.go
index 3807d87..951d846 100644
--- a/runtime/go/build.go
+++ b/runtime/go/build.go
@@ -146,6 +146,7 @@ func specMethods(parcel *cfc.Parcel) {
 
        classBinding := cfc.NewGoClass(parcel, "Clownfish::Class")
        classBinding.SpecMethod("Get_Methods", "GetMethods() []Method")
+       classBinding.SpecMethod("Make_Obj", "MakeObj() Obj")
        classBinding.Register()
 
        stringBinding := cfc.NewGoClass(parcel, "Clownfish::String")

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0ca01dd5/runtime/go/clownfish/class_test.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/class_test.go 
b/runtime/go/clownfish/class_test.go
index 81f3e2e..3b1bd5c 100644
--- a/runtime/go/clownfish/class_test.go
+++ b/runtime/go/clownfish/class_test.go
@@ -41,3 +41,11 @@ func TestClassGetObjAllocSize(t *testing.T) {
                t.Error("Unexpected result for GetObjAllocSize")
        }
 }
+
+func TestMakeObj(t *testing.T) {
+       intClass := FetchClass("Clownfish::Integer")
+       o := intClass.MakeObj()
+       if _, ok := o.(Integer); !ok {
+               t.Error("MakeObj for Integer class didn't yield an Integer")
+       }
+}

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0ca01dd5/runtime/go/clownfish/clownfish.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/clownfish.go 
b/runtime/go/clownfish/clownfish.go
index 065c9d0..1d0f40c 100644
--- a/runtime/go/clownfish/clownfish.go
+++ b/runtime/go/clownfish/clownfish.go
@@ -142,6 +142,12 @@ func (c *ClassIMP) GetMethods() []Method {
        return meths
 }
 
+func (c *ClassIMP) MakeObj() Obj {
+       self := (*C.cfish_Class)(unsafe.Pointer(c.TOPTR()))
+       retvalCF := C.CFISH_Class_Make_Obj_IMP(self)
+       return WRAPAny(unsafe.Pointer(retvalCF))
+}
+
 func NewMethod(name string, callbackFunc unsafe.Pointer, offset uint32) Method 
{
        nameCF := (*C.cfish_String)(GoToString(name))
        defer C.cfish_decref(unsafe.Pointer(nameCF))

Reply via email to