diff options
-rw-r--r-- | Stash.xs | 27 | ||||
-rw-r--r-- | lib/Package/Stash.pm | 10 |
2 files changed, 27 insertions, 10 deletions
@@ -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); diff --git a/lib/Package/Stash.pm b/lib/Package/Stash.pm index 8e76abf..59b2c29 100644 --- a/lib/Package/Stash.pm +++ b/lib/Package/Stash.pm @@ -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. |