diff options
-rw-r--r-- | Stash.xs | 26 | ||||
-rw-r--r-- | lib/Package/Stash.pm | 12 |
2 files changed, 26 insertions, 12 deletions
@@ -24,3 +24,29 @@ new(class, package_name) RETVAL = sv_bless(newRV((SV*)instance), gv_stashpv(class, 0)); OUTPUT: RETVAL + +SV* +name(self) + SV *self + INIT: + SV **slot; + CODE: + if (!sv_isobject(self)) + croak("Can't call name as a class method"); + slot = hv_fetch((HV*)SvRV(self), "name", 4, 0); + RETVAL = slot ? SvREFCNT_inc(*slot) : &PL_sv_undef; + OUTPUT: + RETVAL + +SV* +namespace(self) + SV *self + INIT: + SV **slot; + CODE: + if (!sv_isobject(self)) + croak("Can't call namespace as a class method"); + slot = hv_fetch((HV*)SvRV(self), "namespace", 9, 0); + RETVAL = slot ? SvREFCNT_inc(*slot) : &PL_sv_undef; + OUTPUT: + RETVAL diff --git a/lib/Package/Stash.pm b/lib/Package/Stash.pm index 871889a..8e76abf 100644 --- a/lib/Package/Stash.pm +++ b/lib/Package/Stash.pm @@ -45,28 +45,16 @@ a sigil. If this sigil is absent, it is assumed to represent the IO slot. Creates a new C<Package::Stash> object, for the package given as the only argument. -=cut - =method name Returns the name of the package that this object represents. -=cut - -sub name { - return $_[0]->{name}; -} - =method namespace Returns the raw stash itself. =cut -sub namespace { - return $_[0]->{namespace}; -} - { my %SIGIL_MAP = ( '$' => 'SCALAR', |