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

View of /FigKernelPackages/FIGAttributes.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Tue Jun 8 15:01:39 2004 UTC (15 years, 11 months ago) by olson
Branch: MAIN
CVS Tags: merge-trunktag-bobdev_news-2, Root-bobdev_news, merge-bobdev_news-1, merge-trunktag-bobdev_news-1, merge-bodev_news-3, merge-bobdev_news-2, merge-trunktag-bodev_news-3
Branch point for: Branch-bobdev_news
Code to support annotation of FIG API.

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