[561] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r677 - / branches/par branches/par/perl/lib/BarnOwl

daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:07:26 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Fri, 23 Mar 2007 15:09:46 -0400 (EDT)

Author: nelhage
Date: 2007-03-23 15:09:45 -0400 (Fri, 23 Mar 2007)
New Revision: 677

Modified:
   /
   branches/par/perl/lib/BarnOwl/ModuleLoader.pm
   branches/par/perlwrap.pm
Log:
 r20640@phanatique:  nelhage | 2007-03-23 15:09:38 -0400
 Implement loading of unpacked modules, and module reloading.



Property changes on: 
___________________________________________________________________
Name: svk:merge
   - 6122c8b4-0e12-0410-9533-8bcd7c66c992:/local/dirty-owl-hacks:24493
6aa88b72-b502-0410-8cb4-a5dd0230fb79:/owl-local:1356
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/barnowl:20303
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/d-o-h:18636
   + 6122c8b4-0e12-0410-9533-8bcd7c66c992:/local/dirty-owl-hacks:24493
6aa88b72-b502-0410-8cb4-a5dd0230fb79:/owl-local:1356
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/barnowl:20640
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/d-o-h:18636

Modified: branches/par/perl/lib/BarnOwl/ModuleLoader.pm
===================================================================
--- branches/par/perl/lib/BarnOwl/ModuleLoader.pm	2007-03-22 15:30:13 UTC (rev 676)
+++ branches/par/perl/lib/BarnOwl/ModuleLoader.pm	2007-03-23 19:09:45 UTC (rev 677)
@@ -14,6 +14,15 @@
     for my $dir ( BarnOwl::get_data_dir() . "/modules",
                   $ENV{HOME} . "/.owl/modules" ) {
         opendir(my $dh, $dir) or next;
+        while(defined(my $f = readdir($dh))) {
+            next if $f =~ /^\./;
+            if(-f "$dir/$f" && $f =~ /^(.+)\.par$/) {
+                $modules{$1} = 1;
+            } elsif(-d "$dir/$f" && -d "$dir/$f/lib") {
+                push @INC, "$dir/$f/lib" unless grep m{^$dir/$f/lib$}, @INC;
+                $modules{$f} = 1;
+            }
+        }
         @modules = grep /\.par$/, readdir($dh);
         closedir($dh);
         for my $mod (@modules) {
@@ -29,4 +38,25 @@
     }
 }
 
+sub reload {
+    my $class = shift;
+    for my $m (keys %INC) {
+        delete $INC{$m} if $m =~ m{^BarnOwl/};
+    }
+    # Restore core modules from perlwrap.pm
+    $INC{$_} = 1 for (qw(BarnOwl.pm BarnOwl/Hooks.pm
+                         BarnOwl/Message.pm BarnOwl/Style.pm));
+
+    $BarnOwl::Hooks::startup->clear;
+    local $SIG{__WARN__} = \&squelch_redefine;
+    $class->load_all;
+    $BarnOwl::Hooks::startup->run(1);
+    BarnOwl::startup() if *BarnOwl::startup{CODE};
+}
+
+sub squelch_redefine {
+    my $warning = shift;
+    warn $warning unless $warning =~ /redefined/;
+}
+
 1;

Modified: branches/par/perlwrap.pm
===================================================================
--- branches/par/perlwrap.pm	2007-03-22 15:30:13 UTC (rev 676)
+++ branches/par/perlwrap.pm	2007-03-23 19:09:45 UTC (rev 677)
@@ -424,7 +424,7 @@
         BarnOwl::error("Can't load BarnOwl::ModuleLoader, loadable module support disabled:\n$@");
     }
     
-    $startup->run;
+    $startup->run(0);
     BarnOwl::startup() if *BarnOwl::startup{CODE};
 }
 


home help back first fref pref prev next nref lref last post