From 194acf4760e6124a8787c2f1c6b7b76015ad5e33 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 11 Nov 2010 23:08:45 -0600 Subject: accessors --- Stash.xs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Stash.xs') diff --git a/Stash.xs b/Stash.xs index 879d7ac..9e4fdcd 100644 --- a/Stash.xs +++ b/Stash.xs @@ -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 -- cgit v1.2.3-54-g00ecf