[Bio] / FigKernelPackages / FIGAttributes.pm Repository:
ViewVC logotype

View of /FigKernelPackages/FIGAttributes.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Mon Aug 1 22:22:13 2005 UTC (14 years, 10 months ago) by parrello
Branch: MAIN
CVS Tags: caBIG-dataload-0, caBIG-00-00-00
Changes since 1.1: +5 -5 lines
Changed attributes to capital-case in order to prevent the avalanche of compile-time warnings.

package FIGAttributes;

require v5.6.0;

use Exporter;
use base 'Exporter';
@EXPORT = qw(%_FunctionAttributes);

use strict;

no warnings 'redefine';


#
# We use the methods below to process the subroutine attributes.
#
# See
#	http://www.perldoc.com/perl5.8.4/pod/perlsub.html
#	http://www.perldoc.com/perl5.8.4/lib/attributes.html
#	http://www.perldoc.com/perl5.8.4/lib/Attribute/Handlers.html
#
# for details.
#
# We take action on the following attributes:
#
#   Remote  Allow remote access to this function.
#   Scalar  Function returns a scalar.
#   List    Function returns a list.
#	method	This function is actually a method, and expects $self as the first arg.
#
# If an attribute is set for a function in some package, we
# will update a table %Package::_FunctionAttributes which is
# keyed on the (string) for the coderef, and which has value
# of a list of attribute values.
#

sub MODIFY_CODE_ATTRIBUTES
{
    my($pkg, $sub, @attrs) = @_;

    for my $attr (@attrs)
    {
	set_code_attribute($pkg, $sub, $attr);
    }
    return ();
}

sub set_code_attribute
{
    my($package, $coderef, $attr, $data) = @_;

#    print "Set code attr for $package $coderef $attr d=$data\n";
    my $str = "package $package;\n";
    $str .= <<'EOE';
$_FunctionAttributes{$coderef}->{$attr} = $data;
#print "in set_code_attribute: \n", Dumper(\%_FunctionAttributes);
EOE
    eval $str;
    if ($@ ne "")
    {
	warn "EVAL failed: $@\n";
    }
}

1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3