Use `finalize` for finalizers. * Be consistent about defaulting to non-exported name. * Finalizers may do more than decref, so RunDecRef is misleading.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/0efb7721 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/0efb7721 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/0efb7721 Branch: refs/heads/master Commit: 0efb7721b3ae24038e583b5225649b6427ec59e1 Parents: c320f1f Author: Marvin Humphrey <[email protected]> Authored: Sun Nov 16 21:18:36 2014 -0800 Committer: Marvin Humphrey <[email protected]> Committed: Sun Mar 15 19:02:11 2015 -0700 ---------------------------------------------------------------------- compiler/go/cfc/cfc.go | 12 ++++++------ runtime/go/clownfish/clownfish.go | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0efb7721/compiler/go/cfc/cfc.go ---------------------------------------------------------------------- diff --git a/compiler/go/cfc/cfc.go b/compiler/go/cfc/cfc.go index 92f0094..7c12a6c 100644 --- a/compiler/go/cfc/cfc.go +++ b/compiler/go/cfc/cfc.go @@ -84,11 +84,11 @@ func NewHierarchy(dest string) *Hierarchy { defer C.free(unsafe.Pointer(destCString)) obj := &Hierarchy{C.CFCHierarchy_new(destCString)} obj.AddIncludeDir(mainIncDir) - runtime.SetFinalizer(obj, (*Hierarchy).RunDecRef) + runtime.SetFinalizer(obj, (*Hierarchy).finalize) return obj } -func (obj *Hierarchy) RunDecRef() { +func (obj *Hierarchy) finalize() { C.CFCBase_decref((*C.CFCBase)(unsafe.Pointer(obj.ref))) } @@ -120,11 +120,11 @@ func NewBindCore(hierarchy *Hierarchy, header string, footer string) *BindCore { obj := &BindCore{ C.CFCBindCore_new(hierarchy.ref, headerCString, footerCString), } - runtime.SetFinalizer(obj, (*BindCore).RunDecRef) + runtime.SetFinalizer(obj, (*BindCore).finalize) return obj } -func (obj *BindCore) RunDecRef() { +func (obj *BindCore) finalize() { C.CFCBase_decref((*C.CFCBase)(unsafe.Pointer(obj.ref))) } @@ -144,11 +144,11 @@ func NewBindC(hierarchy *Hierarchy, header string, footer string) *BindC { obj := &BindC{ C.CFCC_new(hierarchy.ref, headerCString, footerCString), } - runtime.SetFinalizer(obj, (*BindC).RunDecRef) + runtime.SetFinalizer(obj, (*BindC).finalize) return obj } -func (obj *BindC) RunDecRef() { +func (obj *BindC) finalize() { C.CFCBase_decref((*C.CFCBase)(unsafe.Pointer(obj.ref))) } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0efb7721/runtime/go/clownfish/clownfish.go ---------------------------------------------------------------------- diff --git a/runtime/go/clownfish/clownfish.go b/runtime/go/clownfish/clownfish.go index 5b9b515..fe68e49 100644 --- a/runtime/go/clownfish/clownfish.go +++ b/runtime/go/clownfish/clownfish.go @@ -110,11 +110,11 @@ func NewString(goString string) *String { obj := &String{ C.cfish_Str_new_steal_utf8(str, len), } - runtime.SetFinalizer(obj, (*String).callDecRef) + runtime.SetFinalizer(obj, (*String).finalize) return obj } -func (obj *String) callDecRef() { +func (obj *String) finalize() { C.cfish_dec_refcount(unsafe.Pointer(obj.ref)) obj.ref = nil } @@ -143,11 +143,11 @@ func NewError(mess string) error { len := C.size_t(len(mess)) messC := C.cfish_Str_new_steal_utf8(str, len) obj := &Err{C.cfish_Err_new(messC)} - runtime.SetFinalizer(obj, (*Err).callDecRef) + runtime.SetFinalizer(obj, (*Err).finalize) return obj } -func (obj *Err) callDecRef() { +func (obj *Err) finalize() { C.cfish_dec_refcount(unsafe.Pointer(obj.ref)) obj.ref = nil } @@ -160,7 +160,7 @@ func (obj *Err) Error() string { func GoCfish_PanicErr_internal(cfErr *C.cfish_Err) { goErr := &Err{cfErr} C.cfish_inc_refcount(unsafe.Pointer(cfErr)) - runtime.SetFinalizer(goErr, (*Err).callDecRef) + runtime.SetFinalizer(goErr, (*Err).finalize) panic(goErr) }
