r129 - in packages: . libperl6-export-perl libperl6-export-perl/branches libperl6-export-perl/branches/upstream libperl6-export-perl/branches/upstream/current libperl6-export-perl/branches/upstream/current/t libperl6-export-perl/branches/upstream/current/t/lib

Allard Hoeve hoeve-guest@haydn.debian.org
Thu, 10 Jun 2004 08:15:56 -0600


Author: hoeve-guest
Date: 2004-06-10 08:15:51 -0600 (Thu, 10 Jun 2004)
New Revision: 129

Added:
   packages/libperl6-export-perl/
   packages/libperl6-export-perl/branches/
   packages/libperl6-export-perl/branches/upstream/
   packages/libperl6-export-perl/branches/upstream/current/
   packages/libperl6-export-perl/branches/upstream/current/Changes
   packages/libperl6-export-perl/branches/upstream/current/Export.pm
   packages/libperl6-export-perl/branches/upstream/current/MANIFEST
   packages/libperl6-export-perl/branches/upstream/current/Makefile.PL
   packages/libperl6-export-perl/branches/upstream/current/README
   packages/libperl6-export-perl/branches/upstream/current/t/
   packages/libperl6-export-perl/branches/upstream/current/t/1.t
   packages/libperl6-export-perl/branches/upstream/current/t/lib/
   packages/libperl6-export-perl/branches/upstream/current/t/lib/TestModule.pm
   packages/libperl6-export-perl/tags/
Log:
[svn-inject] Installing original source of libperl6-export-perl

Added: packages/libperl6-export-perl/branches/upstream/current/Changes
===================================================================
--- packages/libperl6-export-perl/branches/upstream/current/Changes	2004-06-10 14:14:44 UTC (rev 128)
+++ packages/libperl6-export-perl/branches/upstream/current/Changes	2004-06-10 14:15:51 UTC (rev 129)
@@ -0,0 +1,37 @@
+Revision history for Perl extension Perl6::Export.
+
+0.01  Sat Oct 11 23:28:24 2003
+	- original version; created by h2xs 1.22 with options
+		-A -P -X -f -n Perl6::Export
+
+
+
+0.02	Thu Nov 20 04:54:30 2003
+
+
+
+0.03	Tue Dec 16 11:54:34 2003
+
+	- Improved handling of tags
+
+	- Added ALWAYS tag
+
+
+0.05	Fri Feb 27 04:10:29 2004
+
+	- Changed groups and ALWAYS to require prefix colon
+	  (as is likely in Perl 6)
+
+
+0.05	Fri Feb 27 04:17:49 2004
+
+
+
+0.06	Tue Mar  9 02:55:46 2004
+
+	- Changed interface in line with Larry's recent design decisions
+
+
+0.07	Tue Mar  9 02:58:16 2004
+
+	- Minor doc bug fix


Property changes on: packages/libperl6-export-perl/branches/upstream/current/Changes
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-export-perl/branches/upstream/current/Export.pm
===================================================================
--- packages/libperl6-export-perl/branches/upstream/current/Export.pm	2004-06-10 14:14:44 UTC (rev 128)
+++ packages/libperl6-export-perl/branches/upstream/current/Export.pm	2004-06-10 14:15:51 UTC (rev 129)
@@ -0,0 +1,184 @@
+package Perl6::Export;
+our $VERSION = '0.07';
+
+my $ident   = qr{ [^\W\d] \w* }x;
+my $arg     = qr{ : $ident \s* ,? \s* }x;
+my $args    = qr{ \s* \( $arg* \) | (?# NOTHING) }x;
+my $defargs = qr{ \s* \( $arg* :DEFAULT $arg* \) }x;
+my $proto   = qr{ \s* (?: \( [^)]* \) | (?# NOTHING) ) }x;
+
+sub add_to {
+	my ($EXPORT, $symbol, $args, $decl) = @_;
+	$args = "()" unless $args =~ /\S/;
+	$args =~ tr/://d;
+	return qq[BEGIN{no strict 'refs';]
+	     . qq[push\@$EXPORT,'$symbol';\$EXPORT{'$symbol'}=1;]
+	     . qq[push\@{\$EXPORT_TAGS\{\$_}},'$symbol' for ('ALL',qw$args)}$decl];
+}
+
+sub false_import_sub {
+	my $import_sub = q{
+		use base 'Exporter';
+		sub import {
+			my @exports;
+			for (my $i=1; $i<@_; $i++) {
+				for ($_[$i]) {
+					if (!ref && /^[:\$&%\@]?(\w+)$/ && 
+						( exists $EXPORT{$1} || exists $EXPORT_TAGS{$1}) ) {
+						push @exports, splice @_, $i, 1;
+						$i--;
+					}
+				}
+			}
+			@exports = ":DEFAULT" unless @exports;
+			__PACKAGE__->export_to_level(1, $_[0], ':MANDATORY', @exports);	
+			goto &REAL_IMPORT;
+		}
+	};
+	$import_sub =~ s/\n/ /g;
+	$import_sub =~ s/REAL_IMPORT/$_[0]/g;
+	return $import_sub;
+}
+
+my $MANDATORY = q[BEGIN{$EXPORT_TAGS{MANDATORY}||=[]}];
+
+use Filter::Simple;
+use Digest::MD5 'md5_hex';
+
+FILTER {
+	return unless /\S/;
+	my $real_import_name = '_import_'.md5_hex($_);
+	my $false_import_sub = false_import_sub($real_import_name);
+	my $real_import_sub = "";
+	s/ \b sub \s+ import \s* ([({]) /sub $real_import_name$1/x 
+		 or $real_import_sub = "sub $real_import_name {}";
+	s{( \b sub \s+ ($ident) $proto) \s+ is \s+ export ($defargs) }
+	 { add_to('EXPORT',$2,$3,$1) }gex;
+	s{( \b our \s+ ([\$\@\%]$ident) $proto) \s+ is \s+ exported ($defargs) }
+	 { add_to('EXPORT',$2,$3,$1) }gex;
+	s{( \b sub \s+ ($ident) $proto ) \s+ is \s+ export ($args) }
+	 { add_to('EXPORT_OK',$2,$3,$1) }gex;
+	s{( \b our \s+ ([\$\@\%]$ident) ) \s+ is \s+ export ($args) }
+	 { add_to('EXPORT_OK',$2,$3,$1) }gex;
+	$_ = $real_import_sub . $false_import_sub . $MANDATORY . $_;
+}
+
+__END__
+
+=head1 NAME
+
+Perl6::Export - Implements the Perl 6 'is export(...)' trait
+
+
+=head1 SYNOPSIS
+
+	# Perl 5 code...
+
+	package Some::Module;
+    use Perl6::Export;
+
+	# Export &foo by default, when explicitly requested,
+	# or when the ':ALL' export set is requested...
+
+	sub foo is export(:DEFAULT) {
+		print "phooo!";
+	}
+
+
+	# Export &var by default, when explicitly requested,
+	# or when the ':bees', ':pubs', or ':ALL' export set is requested...
+	# the parens after 'is export' are like the parens of a qw(...)
+
+	sub bar is export(:DEFAULT :bees :pubs) {
+		print "baaa!";
+	}
+
+
+	# Export &baz when explicitly requested
+	# or when the ':bees' or ':ALL' export set is requested...
+
+	sub baz is export(:bees) {
+		print "baassss!";
+	}
+
+
+	# Always export &qux 
+	# (no matter what else is explicitly or implicitly requested)
+
+	sub qux is export(:MANDATORY) {
+		print "quuuuuuuuux!";
+	}
+
+
+	sub import {
+		# This subroutine is called when the module is used (as usual),
+		# but it is called after any export requests have been handled.
+		# Those requests will have been stripped from its argument list
+	}
+
+
+=head1 DESCRIPTION
+
+Implements what I hope the Perl 6 symbol export mechanism might look like.
+
+It's very straightforward:
+
+=over
+
+=item *
+
+If you want a subroutine to be capable of being exported (when
+explicitly requested in the C<use> arguments), you mark it
+with the C<is export> trait.
+
+=item *
+
+If you want a subroutine to be automatically exported when the module is
+used (without specific overriding arguments), you mark it with
+the C<is export(:DEFAULT)> trait.
+
+=item *
+
+If you want a subroutine to be automatically exported when the module is
+used (even if the user specifies overriding arguments), you mark it with
+the C<is export(:MANDATORY)> trait.
+
+=item * 
+
+If the subroutine should also be exported when particular export groups
+are requested, you add the names of those export groups to the trait's
+argument list.
+
+=back
+
+That's it.
+
+
+=head1 WARNING
+
+The syntax and semantics of Perl 6 is still being finalized
+and consequently is at any time subject to change. That means the
+same caveat applies to this module.
+
+
+=head1 DEPENDENCIES
+
+Requires Filter::Simple
+
+=head1 AUTHOR
+
+Damian Conway (damian@conway.org)
+
+
+=head1 BUGS AND IRRITATIONS
+
+Does not yet handle the export of variables.
+
+Comments, suggestions, and patches welcome.
+
+
+=head1 COPYRIGHT
+
+ Copyright (c) 2003, Damian Conway. All Rights Reserved.
+ This module is free software. It may be used, redistributed
+    and/or modified under the same terms as Perl itself.


Property changes on: packages/libperl6-export-perl/branches/upstream/current/Export.pm
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-export-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libperl6-export-perl/branches/upstream/current/MANIFEST	2004-06-10 14:14:44 UTC (rev 128)
+++ packages/libperl6-export-perl/branches/upstream/current/MANIFEST	2004-06-10 14:15:51 UTC (rev 129)
@@ -0,0 +1,7 @@
+Changes
+Export.pm
+Makefile.PL
+MANIFEST
+README
+t/1.t
+t/lib/TestModule.pm


Property changes on: packages/libperl6-export-perl/branches/upstream/current/MANIFEST
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-export-perl/branches/upstream/current/Makefile.PL
===================================================================
--- packages/libperl6-export-perl/branches/upstream/current/Makefile.PL	2004-06-10 14:14:44 UTC (rev 128)
+++ packages/libperl6-export-perl/branches/upstream/current/Makefile.PL	2004-06-10 14:15:51 UTC (rev 129)
@@ -0,0 +1,9 @@
+
+use ExtUtils::MakeMaker;
+WriteMakefile(
+		NAME	=> q[Perl6::Export],
+		VERSION => q[0.07],
+        AUTHOR     => 'Damian Conway',
+		PREREQ_PM  => { Filter::Simple=>0 },
+
+	     );


Property changes on: packages/libperl6-export-perl/branches/upstream/current/Makefile.PL
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-export-perl/branches/upstream/current/README
===================================================================
--- packages/libperl6-export-perl/branches/upstream/current/README	2004-06-10 14:14:44 UTC (rev 128)
+++ packages/libperl6-export-perl/branches/upstream/current/README	2004-06-10 14:15:51 UTC (rev 129)
@@ -0,0 +1,65 @@
+==============================================================================
+                   Release of version 0.07 of Perl6::Export
+==============================================================================
+
+
+Perl6/Export version 0.01
+=========================
+
+This module prototypes the Perl 6 'exported' and 'exportable' traits
+in Perl 5.
+
+Instead of messing around with @EXPORT arrays, you just declare which subs
+are to be exported (or are exportable on request) as part of those subs.
+
+For example:
+
+	sub foo is exported {		# by default
+		...
+	}
+
+	sub bar is exportable {		# on request
+		...
+	}
+
+
+INSTALLATION
+
+To install this module type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+  Filter::Simple
+
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2003 Damian Conway
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself. 
+
+
+
+==============================================================================
+
+CHANGES IN VERSION 0.07
+
+
+	- Minor doc bug fix
+
+
+==============================================================================
+
+AVAILABILITY
+
+Perl6::Export has been uploaded to the CPAN
+
+==============================================================================


Property changes on: packages/libperl6-export-perl/branches/upstream/current/README
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-export-perl/branches/upstream/current/t/1.t
===================================================================
--- packages/libperl6-export-perl/branches/upstream/current/t/1.t	2004-06-10 14:14:44 UTC (rev 128)
+++ packages/libperl6-export-perl/branches/upstream/current/t/1.t	2004-06-10 14:15:51 UTC (rev 129)
@@ -0,0 +1,20 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl 1.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use lib 't/lib';
+use Test::More tests=>5;
+use TestModule qw(:Q bar other);
+
+ok(foo, "Exported &foo (always)");
+ok(bar, "Exported requested &bar");
+ok(qux, "Exported grouped &qux");
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+


Property changes on: packages/libperl6-export-perl/branches/upstream/current/t/1.t
___________________________________________________________________
Name: svn:executable
   + 

Added: packages/libperl6-export-perl/branches/upstream/current/t/lib/TestModule.pm
===================================================================
--- packages/libperl6-export-perl/branches/upstream/current/t/lib/TestModule.pm	2004-06-10 14:14:44 UTC (rev 128)
+++ packages/libperl6-export-perl/branches/upstream/current/t/lib/TestModule.pm	2004-06-10 14:15:51 UTC (rev 129)
@@ -0,0 +1,23 @@
+package TestModule;
+
+use Perl6::Export;
+
+sub foo is export(:MANDATORY) {
+	return 1;
+}
+
+sub bar is export {
+	return 1;
+}
+
+sub qux is export(:Q) {
+	return 1;
+}
+
+sub import {
+	Test::More::ok(1, "Invoked Module::import");
+	Test::More::ok("@_" eq "TestModule other",
+					  "Module::import received correct args");
+}
+
+1;


Property changes on: packages/libperl6-export-perl/branches/upstream/current/t/lib/TestModule.pm
___________________________________________________________________
Name: svn:executable
   +