Expose Parcel fetching from Go.

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

Branch: refs/heads/master
Commit: fbd9d5425720ee4ad270f065e034c6f5d039f698
Parents: fcf9dcf
Author: Marvin Humphrey <[email protected]>
Authored: Sun Mar 15 10:42:55 2015 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Mon Apr 6 09:08:19 2015 -0700

----------------------------------------------------------------------
 compiler/go/cfc/cfc.go | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/fbd9d542/compiler/go/cfc/cfc.go
----------------------------------------------------------------------
diff --git a/compiler/go/cfc/cfc.go b/compiler/go/cfc/cfc.go
index 2a1e44f..930aba8 100644
--- a/compiler/go/cfc/cfc.go
+++ b/compiler/go/cfc/cfc.go
@@ -67,6 +67,10 @@ func DoStuff() {
        hierarchy.Build()
 }
 
+type Parcel struct {
+       ref *C.CFCParcel
+}
+
 type Hierarchy struct {
        ref *C.CFCHierarchy
 }
@@ -79,6 +83,22 @@ type BindC struct {
        ref *C.CFCC
 }
 
+func FetchParcel(name string) *Parcel {
+       nameC := C.CString(name)
+       defer C.free(unsafe.Pointer(nameC))
+       parcelC := C.CFCParcel_fetch(nameC)
+       if parcelC == nil {
+               return nil
+       }
+       obj := &Parcel{parcelC}
+       runtime.SetFinalizer(obj, (*Parcel).finalize)
+       return obj
+}
+
+func (obj *Parcel) finalize() {
+       C.CFCBase_decref((*C.CFCBase)(unsafe.Pointer(obj.ref)))
+}
+
 func NewHierarchy(dest string) *Hierarchy {
        destCString := C.CString(dest)
        defer C.free(unsafe.Pointer(destCString))

Reply via email to