Fix operator overloading under Perl 5.8.x

Only turn it on when the class that the object belongs to actually
has overloading.


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

Branch: refs/heads/master
Commit: 74c1a3d6c2d51f4b5843d671d0f19d9b26b18703
Parents: f049e48
Author: Nick Wellnhofer <[email protected]>
Authored: Mon May 18 13:07:30 2015 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Mon May 18 21:25:33 2015 +0200

----------------------------------------------------------------------
 runtime/perl/xs/XSBind.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/74c1a3d6/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/runtime/perl/xs/XSBind.c b/runtime/perl/xs/XSBind.c
index ba9af78..26a5f45 100644
--- a/runtime/perl/xs/XSBind.c
+++ b/runtime/perl/xs/XSBind.c
@@ -766,10 +766,15 @@ CFISH_Obj_To_Host_IMP(cfish_Obj *self) {
     else {
         perl_obj = newRV_inc((SV*)self->ref.host_obj);
     }
+
+    // Enable overloading for Perl 5.8.x
 #if PERL_VERSION <= 8
-    // Enable overloading.
-    SvAMAGIC_on(perl_obj);
+    HV *stash = SvSTASH((SV*)self->ref.host_obj);
+    if (Gv_AMG(stash)) {
+        SvAMAGIC_on(perl_obj);
+    }
 #endif
+
     return perl_obj;
 }
 

Reply via email to