From: Jesse Luehrs Date: Fri, 12 Nov 2010 06:07:54 +0000 (-0600) Subject: convert remove_package_glob X-Git-Tag: 0.14~63 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3fd56b4dfb4975434ec1e29248961e53cf89de26;p=gitmo%2FPackage-Stash-XS.git convert remove_package_glob --- 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.