Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 32e2701aa -> 7c80fb818


Use Python refcounting.

In our Python bindings, Clownfish objects are Python objects, so use
Python's refcounting.


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

Branch: refs/heads/master
Commit: 7910ca91a9005798ae8d6537f5fb55e01d07a17a
Parents: 32e2701
Author: Marvin Humphrey <[email protected]>
Authored: Wed Jan 20 16:25:02 2016 -0800
Committer: Marvin Humphrey <[email protected]>
Committed: Tue Feb 23 18:22:01 2016 -0800

----------------------------------------------------------------------
 runtime/python/cfext/CFBind.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7910ca91/runtime/python/cfext/CFBind.c
----------------------------------------------------------------------
diff --git a/runtime/python/cfext/CFBind.c b/runtime/python/cfext/CFBind.c
index a386e4c..6b13120 100644
--- a/runtime/python/cfext/CFBind.c
+++ b/runtime/python/cfext/CFBind.c
@@ -40,23 +40,20 @@
 
 uint32_t
 cfish_get_refcount(void *vself) {
-    CFISH_UNUSED_VAR(vself);
-    CFISH_THROW(CFISH_ERR, "TODO");
-    CFISH_UNREACHABLE_RETURN(uint32_t);
+    return Py_REFCNT(vself);
 }
 
 cfish_Obj*
 cfish_inc_refcount(void *vself) {
-    CFISH_UNUSED_VAR(vself);
-    CFISH_THROW(CFISH_ERR, "TODO");
-    CFISH_UNREACHABLE_RETURN(cfish_Obj*);
+    Py_INCREF(vself);
+    return (cfish_Obj*)vself;
 }
 
 uint32_t
 cfish_dec_refcount(void *vself) {
-    CFISH_UNUSED_VAR(vself);
-    CFISH_THROW(CFISH_ERR, "TODO");
-    CFISH_UNREACHABLE_RETURN(uint32_t);
+    uint32_t modified_refcount = Py_REFCNT(vself);
+    Py_DECREF(vself);
+    return modified_refcount;
 }
 
 /**** Obj ******************************************************************/

Reply via email to