diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-11-11 23:08:45 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-11-12 03:20:44 -0600 |
commit | 194acf4760e6124a8787c2f1c6b7b76015ad5e33 (patch) | |
tree | fca5d45859b2e488ef5308f3b7babc78410c6876 | |
parent | 59017825dd984a30f69bec25890d1ffceaf30e04 (diff) | |
download | package-stash-xs-194acf4760e6124a8787c2f1c6b7b76015ad5e33.tar.gz package-stash-xs-194acf4760e6124a8787c2f1c6b7b76015ad5e33.zip |
accessors
-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', |