Date:   Sunday June 9, 2002 @ 23:21
Author: matt

Update of /home/cvs/AxKit-XSP-Exception
In directory ted.sergeant.org:/home/matt/Perl/AxKit-XSP-Exception

Modified Files:
        Exception.pm 
Log Message:
Attempt at fixing exceptions problem with wierd extra nodes (untested)
Log:
PR:

Index: Exception.pm
===================================================================
RCS file: /home/cvs/AxKit-XSP-Exception/Exception.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -b -u -r1.5 -r1.6
--- Exception.pm        2001/08/06 10:36:20     1.5
+++ Exception.pm        2002/06/09 22:21:40     1.6
@@ -1,4 +1,4 @@
-# $Id: Exception.pm,v 1.5 2001/08/06 10:36:20 matt Exp $
+# $Id: Exception.pm,v 1.6 2002/06/09 22:21:40 matt Exp $
 
 package AxKit::XSP::Exception;
 
@@ -10,7 +10,7 @@
 @ISA = ('Apache::AxKit::Language::XSP');
 $NS = 'http://axkit.org/NS/xsp/exception/v1';
 
-$VERSION = "1.4";
+$VERSION = "1.6";
 
 sub start_document{
        my ($e) = shift;
@@ -23,37 +23,45 @@
     return '';
 }
 
+my $sort_nodes = ' $real_parent->appendChild($parent->removeChild($_)) for 
+$parent->childNodes(); ';
+
 sub parse_start {
     my ($e, $tag, %attribs) = @_;
      
     if ($tag eq 'try') {
          $e->manage_text(0);
          push(@E_state, "try");
-         return 'eval { ';
+          return 'eval { my $real_parent = $parent; $parent = 
+$document->createElement("psuedo-parent"); '. "\n";
          
-    } elsif ($tag eq 'catch') {
+    }
+    elsif ($tag eq 'catch') {
          $e->manage_text(0);
          my $state = pop(@E_state);
          if($state eq 'try') {
                if(my $class = $attribs{'class'}) {  
                    push(@E_state, 'catch');
-                   return '}; if($@) { my $exception = $@; if($@->isa("'.$class.'")) 
{ ';
-               } else {
+                return "$sort_nodes\n };\n".' if($@) { my $exception = $@; 
+if($@->isa("'.$class.'")) { ';
+            }
+            else {
                    push(@E_state, 'catchall');
-                   return '}; if($@) { my $exception = $@; ';
+                return "$sort_nodes\n };\n".' if($@) { my $exception = $@; ';
+            }
              }
-        } elsif($state eq 'catch') {
+        elsif($state eq 'catch') {
                if(my $class = $attribs{'class'}) {
                    push(@E_state, 'catch');
                  return '} elsif($@->isa("'.$class.'")) { ';
-             } else {
+            }
+            else {
                    push(@E_state, 'catchelse');
                    return '} else { ';
                }
-        } else {
+        }
+        else {
                die "catch can only be called after a try tag";
         } 
-    } elsif ($tag eq 'message') {
+    }
+    elsif ($tag eq 'message') {
         $e->start_expr($tag);
        return '';
     }
@@ -67,12 +75,15 @@
     if ($tag eq 'try') {
          my $state = pop(@E_state);
          if($state eq 'try') {
-            return '}; if($@) { die($@) }; ';            # No if($@) block
-        } elsif($state eq 'catch') { 
+            return $sort_nodes.'}; if($@) { die($@) }; ';     # No if($@) block
+        }
+        elsif($state eq 'catch') { 
                return '} else { die($@) } }; undef($@); '; # if($@) { block 
--propogate die
-        } elsif($state eq 'catchall') {
-               return '}; undef($@); ';                          # if($@) { block -- 
don't propogate die
-        } elsif($state eq 'catchelse') {
+        }
+        elsif($state eq 'catchall') {
+            return $sort_nodes.'}; undef($@); ';              # if($@) { block -- 
+don't propogate die
+        }
+        elsif($state eq 'catchelse') {
                return '}} undef($@); ';                          #if($@) {} else { 
block -- don't propogate die
         }
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to