From 3fd56b4dfb4975434ec1e29248961e53cf89de26 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 12 Nov 2010 00:07:54 -0600 Subject: convert remove_package_glob --- Stash.xs | 27 +++++++++++++++++++++++++++ lib/Package/Stash.pm | 10 ---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Stash.xs b/Stash.xs index 9e4fdcd..2ca99a0 100644 --- 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); 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. -- cgit v1.2.3-54-g00ecf