summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-11-12 15:02:18 -0600
committerJesse Luehrs <doy@tozt.net>2010-11-12 15:02:18 -0600
commitfca4ed0c33214a7710c5b4bd20858863d0be7ed4 (patch)
tree1e5361b3dd0999bc7c989ea42ab9524dc110fd21 /lib
parent301f570b58526c2263a537fefda6667aa73eacab (diff)
downloadpackage-stash-xs-fca4ed0c33214a7710c5b4bd20858863d0be7ed4.tar.gz
package-stash-xs-fca4ed0c33214a7710c5b4bd20858863d0be7ed4.zip
implement the rest of get_package_symbol
Diffstat (limited to 'lib')
-rw-r--r--lib/Package/Stash.pm111
1 files changed, 0 insertions, 111 deletions
diff --git a/lib/Package/Stash.pm b/lib/Package/Stash.pm
index 0cd0c95..be440a1 100644
--- a/lib/Package/Stash.pm
+++ b/lib/Package/Stash.pm
@@ -3,10 +3,6 @@ use strict;
use warnings;
# ABSTRACT: routines for manipulating stashes
-use Carp qw(confess);
-use Scalar::Util qw(reftype);
-use Symbol;
-
use XSLoader;
XSLoader::load(
__PACKAGE__,
@@ -18,10 +14,6 @@ XSLoader::load(
? ${ $Package::Stash::{VERSION} } : (),
);
-# before 5.12, assigning to the ISA glob would make it lose its magical ->isa
-# powers
-use constant BROKEN_ISA_ASSIGNMENT => ($] < 5.012);
-
=head1 SYNOPSIS
my $stash = Package::Stash->new('Foo');
@@ -53,38 +45,6 @@ Returns the name of the package that this object represents.
Returns the raw stash itself.
-=cut
-
-=pod
-
-{
- my %SIGIL_MAP = (
- '$' => 'SCALAR',
- '@' => 'ARRAY',
- '%' => 'HASH',
- '&' => 'CODE',
- '' => 'IO',
- );
-
- sub _deconstruct_variable_name {
- my ($self, $variable) = @_;
-
- (defined $variable && length $variable)
- || confess "You must pass a variable name";
-
- my $sigil = substr($variable, 0, 1, '');
-
- if (exists $SIGIL_MAP{$sigil}) {
- return ($variable, $sigil, $SIGIL_MAP{$sigil});
- }
- else {
- return ("${sigil}${variable}", '', $SIGIL_MAP{''});
- }
- }
-}
-
-=cut
-
=method add_package_symbol $variable $value %opts
Adds a new package symbol, for the symbol given as C<$variable>, and optionally
@@ -123,77 +83,6 @@ Returns whether or not the given package variable (including sigil) exists.
Returns the value of the given package variable (including sigil).
-=cut
-
-=pod
-
-sub get_package_symbol {
- my ($self, $variable, %opts) = @_;
-
- my ($name, $sigil, $type) = ref $variable eq 'HASH'
- ? @{$variable}{qw[name sigil type]}
- : $self->_deconstruct_variable_name($variable);
-
- my $namespace = $self->namespace;
-
- if (!exists $namespace->{$name}) {
- if ($opts{vivify}) {
- if ($type eq 'ARRAY') {
- if (BROKEN_ISA_ASSIGNMENT) {
- $self->add_package_symbol(
- $variable,
- $name eq 'ISA' ? () : ([])
- );
- }
- else {
- $self->add_package_symbol($variable, []);
- }
- }
- elsif ($type eq 'HASH') {
- $self->add_package_symbol($variable, {});
- }
- elsif ($type eq 'SCALAR') {
- $self->add_package_symbol($variable);
- }
- elsif ($type eq 'IO') {
- $self->add_package_symbol($variable, Symbol::geniosym);
- }
- elsif ($type eq 'CODE') {
- confess "Don't know how to vivify CODE variables";
- }
- else {
- confess "Unknown type $type in vivication";
- }
- }
- else {
- if ($type eq 'CODE') {
- # this effectively "de-vivifies" the code slot. if we don't do
- # this, referencing the coderef at the end of this function
- # will cause perl to auto-vivify a stub coderef in the slot,
- # which isn't what we want
- $self->add_package_symbol($variable);
- }
- }
- }
-
- my $entry_ref = \$namespace->{$name};
-
- if (ref($entry_ref) eq 'GLOB') {
- return *{$entry_ref}{$type};
- }
- else {
- if ($type eq 'CODE') {
- no strict 'refs';
- return \&{ $self->name . '::' . $name };
- }
- else {
- return undef;
- }
- }
-}
-
-=cut
-
=method get_or_add_package_symbol $variable
Like C<get_package_symbol>, except that it will return an empty hashref or