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 2014/11/30 06:09:11 UTC

[14/20] lucy-clownfish git commit: Use struct pointers for Clownfish Go host objects.

Use struct pointers for Clownfish Go host objects.

Be consistent about passing around Clownfish Go host objects by
reference rather than by value.


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

Branch: refs/heads/go_bindings_2
Commit: 28c63650151f284d599849824b60a8cbfe7dd455
Parents: 20fa9e7
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Wed Nov 12 17:23:34 2014 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sat Nov 29 21:07:53 2014 -0800

----------------------------------------------------------------------
 compiler/go/cfc/cfc.go            | 34 +++++++++++++++++-----------------
 runtime/go/clownfish/clownfish.go |  6 +++---
 2 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/28c63650/compiler/go/cfc/cfc.go
----------------------------------------------------------------------
diff --git a/compiler/go/cfc/cfc.go b/compiler/go/cfc/cfc.go
index fb38bfb..92f0094 100644
--- a/compiler/go/cfc/cfc.go
+++ b/compiler/go/cfc/cfc.go
@@ -79,12 +79,12 @@ type BindC struct {
 	ref *C.CFCC
 }
 
-func NewHierarchy(dest string) Hierarchy {
+func NewHierarchy(dest string) *Hierarchy {
 	destCString := C.CString(dest)
 	defer C.free(unsafe.Pointer(destCString))
-	obj := Hierarchy{C.CFCHierarchy_new(destCString)}
+	obj := &Hierarchy{C.CFCHierarchy_new(destCString)}
 	obj.AddIncludeDir(mainIncDir)
-	runtime.SetFinalizer(&obj, (*Hierarchy).RunDecRef)
+	runtime.SetFinalizer(obj, (*Hierarchy).RunDecRef)
 	return obj
 }
 
@@ -96,39 +96,39 @@ func (obj *Hierarchy) Build() {
 	C.CFCHierarchy_build(obj.ref)
 }
 
-func (obj Hierarchy) AddSourceDir(dir string) {
+func (obj *Hierarchy) AddSourceDir(dir string) {
 	dirCString := C.CString(dir)
 	defer C.free(unsafe.Pointer(dirCString))
 	C.CFCHierarchy_add_source_dir(obj.ref, dirCString)
 }
 
-func (obj Hierarchy) AddIncludeDir(dir string) {
+func (obj *Hierarchy) AddIncludeDir(dir string) {
 	dirCString := C.CString(dir)
 	defer C.free(unsafe.Pointer(dirCString))
 	C.CFCHierarchy_add_include_dir(obj.ref, dirCString)
 }
 
-func (obj Hierarchy) WriteLog() {
+func (obj *Hierarchy) WriteLog() {
 	C.CFCHierarchy_write_log(obj.ref)
 }
 
-func NewBindCore(hierarchy Hierarchy, header string, footer string) BindCore {
+func NewBindCore(hierarchy *Hierarchy, header string, footer string) *BindCore {
 	headerCString := C.CString(header)
 	footerCString := C.CString(footer)
 	defer C.free(unsafe.Pointer(headerCString))
 	defer C.free(unsafe.Pointer(footerCString))
-	obj := BindCore{
+	obj := &BindCore{
 		C.CFCBindCore_new(hierarchy.ref, headerCString, footerCString),
 	}
-	runtime.SetFinalizer(&obj, (*BindCore).RunDecRef)
+	runtime.SetFinalizer(obj, (*BindCore).RunDecRef)
 	return obj
 }
 
-func (obj BindCore) RunDecRef() {
+func (obj *BindCore) RunDecRef() {
 	C.CFCBase_decref((*C.CFCBase)(unsafe.Pointer(obj.ref)))
 }
 
-func (obj BindCore) WriteAllModified(modified bool) bool {
+func (obj *BindCore) WriteAllModified(modified bool) bool {
 	var mod C.int = 0
 	if modified {
 		mod = 1
@@ -136,26 +136,26 @@ func (obj BindCore) WriteAllModified(modified bool) bool {
 	return C.CFCBindCore_write_all_modified(obj.ref, mod) != 0
 }
 
-func NewBindC(hierarchy Hierarchy, header string, footer string) BindC {
+func NewBindC(hierarchy *Hierarchy, header string, footer string) *BindC {
 	headerCString := C.CString(header)
 	footerCString := C.CString(footer)
 	defer C.free(unsafe.Pointer(headerCString))
 	defer C.free(unsafe.Pointer(footerCString))
-	obj := BindC{
+	obj := &BindC{
 		C.CFCC_new(hierarchy.ref, headerCString, footerCString),
 	}
-	runtime.SetFinalizer(&obj, (*BindC).RunDecRef)
+	runtime.SetFinalizer(obj, (*BindC).RunDecRef)
 	return obj
 }
 
-func (obj BindC) RunDecRef() {
+func (obj *BindC) RunDecRef() {
 	C.CFCBase_decref((*C.CFCBase)(unsafe.Pointer(obj.ref)))
 }
 
-func (obj BindC) WriteCallbacks() {
+func (obj *BindC) WriteCallbacks() {
 	C.CFCC_write_callbacks(obj.ref)
 }
 
-func (obj BindC) WriteHostDefs() {
+func (obj *BindC) WriteHostDefs() {
 	C.CFCC_write_hostdefs(obj.ref)
 }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/28c63650/runtime/go/clownfish/clownfish.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/clownfish.go b/runtime/go/clownfish/clownfish.go
index 7f4db15..aee0f8e 100644
--- a/runtime/go/clownfish/clownfish.go
+++ b/runtime/go/clownfish/clownfish.go
@@ -76,13 +76,13 @@ type LockFreeRegistry struct {
 	ref *C.cfish_LockFreeRegistry
 }
 
-func NewString(goString string) String {
+func NewString(goString string) *String {
 	str := C.CString(goString)
 	len := C.size_t(len(goString))
-	obj := String{
+	obj := &String{
 		C.cfish_Str_new_steal_utf8(str, len),
 	}
-	runtime.SetFinalizer(&obj, (*String).callDecRef)
+	runtime.SetFinalizer(obj, (*String).callDecRef)
 	return obj
 }