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 2014/07/29 00:45:44 UTC

git commit: Define Perl alias for Destroy method via bindings

Repository: lucy-clownfish
Updated Branches:
  refs/heads/overridden_aliases 5c4f9187a -> 95b19db23


Define Perl alias for Destroy method via bindings

Now it should be possible to override the destructor from Perl.


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

Branch: refs/heads/overridden_aliases
Commit: 95b19db23f0b2708df51f54abed4b08aba6b94ba
Parents: 5c4f918
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Jul 29 00:33:31 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Jul 29 00:43:35 2014 +0200

----------------------------------------------------------------------
 compiler/src/CFCPerlMethod.c                     | 16 ++++------------
 runtime/perl/buildlib/Clownfish/Build/Binding.pm |  4 ++++
 2 files changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/95b19db2/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index 9f33065..20a82e6 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -142,19 +142,11 @@ CFCPerlMethod_perl_name(CFCMethod *method) {
         return CFCUtil_strdup(alias);
     }
 
-    char       *perl_name = NULL;
+    // Derive Perl name by lowercasing.
     const char *name      = CFCMethod_get_macro_sym(method);
-
-    if (strcmp(name, "Destroy") == 0) {
-        // The Clownfish destructor needs to be spelled DESTROY for Perl.
-        perl_name = CFCUtil_strdup("DESTROY");
-    }
-    else {
-        // Derive Perl name by lowercasing.
-        perl_name = CFCUtil_strdup(name);
-        for (size_t i = 0; perl_name[i] != '\0'; i++) {
-            perl_name[i] = tolower(perl_name[i]);
-        }
+    char       *perl_name = CFCUtil_strdup(name);
+    for (size_t i = 0; perl_name[i] != '\0'; i++) {
+        perl_name[i] = tolower(perl_name[i]);
     }
 
     return perl_name;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/95b19db2/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build/Binding.pm b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
index fba3def..ccfaeca 100644
--- a/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -477,6 +477,10 @@ END_XS_CODE
         parcel     => "Clownfish",
         class_name => "Clownfish::Obj",
     );
+    $binding->bind_method(
+        alias  => 'DESTROY',
+        method => 'Destroy',
+    );
     $binding->exclude_method($_) for @hand_rolled;
     $binding->append_xs($xs_code);
     $binding->set_pod_spec($pod_spec);