You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2016/03/19 18:27:15 UTC

[05/14] lucy-clownfish git commit: Implement dtors for Class and Method

Implement dtors for Class and Method

Only for internal use. Destructors of immortal types won't be invoked
via DECREF, so they must be called directly.


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

Branch: refs/heads/master
Commit: dc56c144cace1d9faa70e857ae98596cfee2329d
Parents: 20eef8f
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Mar 10 15:11:36 2016 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu Mar 10 21:22:42 2016 +0100

----------------------------------------------------------------------
 runtime/core/Clownfish/Class.c  | 11 ++++++++++-
 runtime/core/Clownfish/Method.c |  7 ++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/dc56c144/runtime/core/Clownfish/Class.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Class.c b/runtime/core/Clownfish/Class.c
index 68258c6..1ab7523 100644
--- a/runtime/core/Clownfish/Class.c
+++ b/runtime/core/Clownfish/Class.c
@@ -224,7 +224,16 @@ Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs,
 
 void
 Class_Destroy_IMP(Class *self) {
-    THROW(ERR, "Insane attempt to destroy Class for class '%o'", self->name);
+    for (size_t i = 0; self->methods[i]; i++) {
+        // Call Destroy directly instead of going through DECREF.
+        Method_Destroy(self->methods[i]);
+    }
+    FREEMEM(self->methods);
+
+    DECREF(self->name);
+    DECREF(self->name_internal);
+
+    SUPER_DESTROY(self, CLASS);
 }
 
 void

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/dc56c144/runtime/core/Clownfish/Method.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Method.c b/runtime/core/Clownfish/Method.c
index a044f35..44bcdb4 100644
--- a/runtime/core/Clownfish/Method.c
+++ b/runtime/core/Clownfish/Method.c
@@ -54,7 +54,12 @@ Method_init(Method *self, String *name, cfish_method_t callback_func,
 
 void
 Method_Destroy_IMP(Method *self) {
-    THROW(ERR, "Insane attempt to destroy Method '%o'", self->name);
+    DECREF(self->name);
+    DECREF(self->name_internal);
+    DECREF(self->host_alias);
+    DECREF(self->host_alias_internal);
+
+    SUPER_DESTROY(self, METHOD);
 }
 
 String*