[41021] trunk/dports/perl/p5-mac-osa-simple

ricci at macports.org ricci at macports.org
Mon Oct 20 19:32:16 PDT 2008


Revision: 41021
          http://trac.macports.org/changeset/41021
Author:   ricci at macports.org
Date:     2008-10-20 19:32:15 -0700 (Mon, 20 Oct 2008)
Log Message:
-----------
Add a patch that (vastly) improves the error handling (though there is more to do...)
bump revision
strip domain from maintainer email

Modified Paths:
--------------
    trunk/dports/perl/p5-mac-osa-simple/Portfile

Added Paths:
-----------
    trunk/dports/perl/p5-mac-osa-simple/files/
    trunk/dports/perl/p5-mac-osa-simple/files/patch-Simple.pm.diff

Modified: trunk/dports/perl/p5-mac-osa-simple/Portfile
===================================================================
--- trunk/dports/perl/p5-mac-osa-simple/Portfile	2008-10-21 01:31:01 UTC (rev 41020)
+++ trunk/dports/perl/p5-mac-osa-simple/Portfile	2008-10-21 02:32:15 UTC (rev 41021)
@@ -3,8 +3,8 @@
 PortSystem			1.0
 PortGroup			perl5 1.0
 perl5.setup			Mac-OSA-Simple 1.09
-revision			0
-maintainers			ricci at macports.org
+revision			1
+maintainers			ricci
 description			Simple interface to Mac::OSA
 long_description \
 	This is Mac::OSA::Simple, a module for simple access to OSA scripting \
@@ -20,4 +20,6 @@
 					port:p5-mac-appleevents-simple \
 					port:p5-test-pod
 
+patchfiles			patch-Simple.pm.diff
+
 ## vi:set noai ts=4:

Added: trunk/dports/perl/p5-mac-osa-simple/files/patch-Simple.pm.diff
===================================================================
--- trunk/dports/perl/p5-mac-osa-simple/files/patch-Simple.pm.diff	                        (rev 0)
+++ trunk/dports/perl/p5-mac-osa-simple/files/patch-Simple.pm.diff	2008-10-21 02:32:15 UTC (rev 41021)
@@ -0,0 +1,287 @@
+--- work/Mac-OSA-Simple-1.09/Simple.pm	2005-06-01 22:44:09.000000000 -0700
++++ Simple.pm	2008-10-20 18:22:42.000000000 -0700
+@@ -47,17 +47,20 @@
+ 	my($self) = @_;
+ 	my $value = my $return = '';
+ 
+-	$value = OSAExecute($self->{COMP}, $self->{ID}, 0, 0)
+-		or _mydie() && return;
++	eval {$value = OSAExecute($self->{COMP}, $self->{ID}, 0, 0);};
++	if ($@) {
++		confess "ERROR: Failed to execute, err = \"$@\"";
++	}
+ 
+ 	if ($value) {
+-		$return = OSADisplay($self->{COMP}, $value, typeChar, 0)
+-			or _mydie() && return;
++		eval {$return = OSADisplay($self->{COMP}, $value, typeChar, 0);};
++		if ($@) {
++			confess "ERROR: Failed to display for value \"$value\", err = \"$@\"";
++		}
+ 		OSADispose($self->{COMP}, $value);
+ 	}
+ 
+-	$self->{RETURN} = $return && $return->isa('AEDesc')
+-        	? $return->get : 1;
++	$self->{RETURN} = $return && $return->isa('AEDesc') ? $return->get : 1;
+ 
+ 	AEDisposeDesc($return) if $return;
+ 
+@@ -85,10 +88,11 @@
+ 
+ 	my $event = build_event($cid, $eid, $target, "'----':$format", @$args);
+ 
+-	$event->{REP} = OSADoEvent(
+-		$self->{COMP}, $event->{EVT}, $self->{ID}, $mode
+-	) or _mydie() && return;
+-
++	eval {$event->{REP} = OSADoEvent($self->{COMP}, $event->{EVT}, $self->{ID}, $mode);};
++	if ($@) {
++		die "ERROR: Failed OSADoEvent, err = \"$@\"";
++	}
++	
+ 	return $event->get;
+ }
+ }
+@@ -113,7 +117,12 @@
+ sub save {
+ 	my($self, $file, $resid, $name) = @_;
+ 
+-	my $scpt = $self->compiled or _mydie() && return;
++	my $scpt = undef;
++	
++	eval {$scpt = $self->compiled;};
++	if ($@) {
++		die "ERROR: Failed to see if we're compiled or not, err = \"$@\"";
++	}
+ 	$self->{FILETYPE} ||= $^O eq 'MacOS' ? 'rsrc' : 'data';
+ 
+ 	my $res;
+@@ -122,19 +131,33 @@
+ 		$name  = defined($name)  ? $name  : 'MacPerl Script';
+ 
+ 		unless ($res = FSpOpenResFile($file, 0)) {
+-			FSpCreateResFile($file, 'ToyS', 'osas', 0) or _mydie() && return;
+-			$res = FSpOpenResFile($file, 0) or _mydie() && return;
++			eval {FSpCreateResFile($file, 'ToyS', 'osas', 0);};
++			if ($@) {
++				die "ERROR: Failed in FSpCreateResFile, err = \"$@\"";
++			}
++			eval {$res = FSpOpenResFile($file, 0);};
++			if ($@) {
++				die "ERROR: Failed in FSpOpenResFile, err = \"$@\"";
++			}
+ 		}
+ 
+ 		my $foo = Get1Resource(kOSAScriptResourceType, $resid);
+ 		if (defined $foo) {
+-			RemoveResource($foo) or _mydie() && return;
++			eval {RemoveResource($foo);};
++			if ($@) {
++				die "ERROR: Failed to remove resource, err = \"$@\"";
++			}
+ 		}
+ 
+-		AddResource($scpt, kOSAScriptResourceType, $resid, $name)
+-			or _mydie() && return;
++		eval {AddResource($scpt, kOSAScriptResourceType, $resid, $name);};
++		if ($@) {
++			die "ERROR: Failed to add resource, err = \"$@\"";
++		}
+ 
+-		UpdateResFile($res) or _mydie() && return;
++		eval {UpdateResFile($res);};
++		if ($@) {
++			die "ERROR: Failed to update res file, err = \"$@\"";
++		}
+ 		CloseResFile($res);
+ 
+ 	} else {
+@@ -151,11 +174,12 @@
+ sub source {
+ 	my($self, $source, $text) = @_;
+     
+-	$source = OSAGetSource($self->{COMP}, $self->{ID}, typeChar)
+-		or _mydie() && return;
++	eval {$source = OSAGetSource($self->{COMP}, $self->{ID}, typeChar);};
++	if ($@) {
++		die "ERROR: Failed in OSAGetSource, err = \"$@\"";
++	}
+ 
+-	$self->{SOURCE} = $source && $source->isa('AEDesc')
+-        	? $source->get : '';
++	$self->{SOURCE} = $source && $source->isa('AEDesc') ? $source->get : '';
+ 
+ 	AEDisposeDesc($source);
+ 
+@@ -166,9 +190,10 @@
+ sub compiled {
+ 	my($self, $script) = @_;
+ 
+-	$script = OSAStore($self->{COMP}, $self->{ID},
+-		typeOSAGenericStorage, 0)
+-		or _mydie() && return;
++	eval {$script = OSAStore($self->{COMP}, $self->{ID}, typeOSAGenericStorage, 0);};
++	if ($@) {
++		die "ERROR: Failed in OSAStore, err = \"$@\"";
++	}
+ 
+ 	push @{$self->{AEDESC}}, $script;
+ 
+@@ -177,10 +202,20 @@
+ 
+ sub _doscript {
+ 	my($c, $text) = @_;
+-
+-	my $self = _compile_script($c, $text) or _mydie() && return;
+-	my $return = $self->execute;
+-	_mydie() && return unless defined $return;
++	my $self = undef;
++	my $return = undef;
++	
++	eval {$self = _compile_script($c, $text);};
++	if ($@) {
++		die "ERROR: Failed to compile the script, err = \"$@\"";
++	}
++	eval {$return = $self->execute;};
++	if ($@) {
++		die "ERROR: Failed to execute, err = \"$@\"";
++	}
++	if (!defined($return)) {
++		die "ERROR: Failed to execute, return is undef";
++	}
+ 	$self->dispose;
+ 
+ 	return $return;
+@@ -204,16 +239,17 @@
+ 		my $file = $scpt;
+ 		undef $scpt;
+ 
+-		if ($^O eq 'MacOS') {
+-			$res = FSpOpenResFile($file, 0) or _mydie() && return;
+-			$scpt = Get1Resource(kOSAScriptResourceType, $resid)
+-				or _mydie() && return;
+-		} else {
+-			$res = FSpOpenResFile($file, 0);
+-			$scpt = Get1Resource(kOSAScriptResourceType, $resid) if $res;
+-
++		eval {$res = FSpOpenResFile($file, 0);};
++		if ($@) {
++			die "ERROR: Failed in FSpOpenResFile, err = \"$@\"";
++		}
++		eval {$scpt = Get1Resource(kOSAScriptResourceType, $resid);};
++		if ($@) {
++			die "ERROR: Failed in Get1Resource, err = \"$@\"";
++		}
++		if ($^O ne 'MacOS') {
+ 			if (!$scpt) {
+-				open my $fh, '<', $file or _mydie() && return;
++				open my $fh, '<', $file or die "ERROR: Failed to open file \"$file\", err = \"$@\"";
+ 				$scpt = new Handle do {
+ 					local $/;
+ 					<$fh>;
+@@ -230,11 +266,16 @@
+ 		}
+ 	}
+ 
+-	my $desc = AECreateDesc(typeOSAGenericStorage, $scpt->get)
+-		or _mydie() && return;
++	my $desc = undef;
++	eval {$desc = AECreateDesc(typeOSAGenericStorage, $scpt->get);};
++	if ($@) {
++		die "ERROR: Failed in AECreateDesc, err = \"$@\"";
++	}
+ 
+-	$self->{ID} = OSALoad($self->{COMP}, $desc, 0)
+-		or _mydie() && return;
++	eval {$self->{ID} = OSALoad($self->{COMP}, $desc, 0);};
++	if ($@) {
++		die "ERROR: Failed in OSALoad, err = \"$@\"";
++	}
+ 
+ 	AEDisposeDesc($desc) if $desc;
+ 	CloseResFile($res) if $res;
+@@ -244,32 +285,56 @@
+ 
+ sub _compile_script {
+ 	my($c, $text) = @_;
++	my $comp = undef;
++	my $self = undef;
+ 
+-	my $comp = $ScriptComponents{$c} or return;
++	$comp = $ScriptComponents{$c};
++	if (!defined($comp)) {
++		## XYZZY: is this an error??
++		return;
++	}
+ 
+-	my $self = bless {
++	$self = bless {
+ 		COMP   => $comp,
+-        	SOURCE => $text,
+-        	TYPE   => $c
+-        }, __PACKAGE__;
++		SOURCE => $text,
++		TYPE   => $c
++	}, __PACKAGE__;
+ 
+ 	return $self->_compile;
+ }
+ 
+ sub _compile {
+ 	my($self) = @_;
++	my $id = undef;
++	my $script = undef;
+ 
+-	$self->{SCRIPT} = AECreateDesc(typeChar, $self->{SOURCE})
+-		or _mydie() && return;
+-
+-	$self->{ID} = OSACompile($self->{COMP}, $self->{SCRIPT}, kOSAModeCompileIntoContext)
+-		or _mydie() && return;
++	eval {$script = AECreateDesc(typeChar, $self->{SOURCE});};
++	if ($@) {
++		die "ERROR: Failed AECreateDesc(typeChar, self->{SOURCE}), err = \"$@\""
++	}
++	if (!defined($script) || "" eq $script) {
++		die "ERROR: AECreateDesc returned nothingness";
++	}
++	$self->{SCRIPT} = $script;
+ 
++	eval {$id = OSACompile($self->{COMP}, $self->{SCRIPT}, kOSAModeCompileIntoContext);};
++	if ($@) {
++		die "ERROR: Failed to compile script, err = \"$@\"";
++	}
++	if ($^E) {
++		die "ERROR: Failed to compile script, err = \"$^E\"";
++	}
++	if (!defined($id) || "" eq $id) {
++		die "ERROR: OSACompile returned nothingness";
++	}
++	$self->{ID} = $id;
++	
+ 	return $self;
+ }
+ 
+ sub _mydie {
+ 	# maybe do something here some day
++	confess("ERROR: landed in _mydie");
+ 	1;
+ }
+ 
+@@ -331,9 +396,13 @@
+ 	}
+ 
+ 	if (!$self->{$c}) {
+-		my $comp = OpenDefaultComponent(kOSAComponentType, $comp)
+-			or Mac::OSA::Simple::_mydie() && return;
+-		$self->{$c} = $comp;
++		eval {
++			my $comp = OpenDefaultComponent(kOSAComponentType, $comp);
++			$self->{$c} = $comp;
++		};
++		if ($@) {
++			die "ERROR: Failed to OpenDefaultComponent(), err = \"$@\"";
++		}
+ 	}
+ 	$self->{$c};
+ }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20081020/780de0de/attachment-0001.html 


More information about the macports-changes mailing list