convert remove_package_glob
Jesse Luehrs [Fri, 12 Nov 2010 06:07:54 +0000 (00:07 -0600)]
Stash.xs
lib/Package/Stash.pm

index 9e4fdcd..2ca99a0 100644 (file)
--- a/Stash.xs
+++ b/Stash.xs
@@ -2,6 +2,24 @@
 #include "perl.h"
 #include "XSUB.h"
 
+HV *_get_namespace(SV *self)
+{
+    dSP;
+    SV *ret;
+
+    PUSHMARK(SP);
+    XPUSHs(self);
+    PUTBACK;
+
+    call_method("namespace", G_SCALAR);
+
+    SPAGAIN;
+    ret = POPs;
+    PUTBACK;
+
+    return (HV*)SvRV(ret);
+}
+
 MODULE = Package::Stash  PACKAGE = Package::Stash
 
 SV*
@@ -50,3 +68,12 @@ namespace(self)
     RETVAL = slot ? SvREFCNT_inc(*slot) : &PL_sv_undef;
   OUTPUT:
     RETVAL
+
+void
+remove_package_glob(self, name)
+    SV *self
+    char *name
+  INIT:
+    HV *namespace;
+  CODE:
+    hv_delete(_get_namespace(self), name, strlen(name), G_DISCARD);
index 8e76abf..59b2c29 100644 (file)
@@ -159,16 +159,6 @@ sub add_package_symbol {
 
 Removes all package variables with the given name, regardless of sigil.
 
-=cut
-
-sub remove_package_glob {
-    my ($self, $name) = @_;
-    no strict 'refs';
-    delete ${$self->name . '::'}{$name};
-}
-
-# ... these functions deal with stuff on the namespace level
-
 =method has_package_symbol $variable
 
 Returns whether or not the given package variable (including sigil) exists.