[1158] in BarnOwl Developers

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

[D-O-H] r1105 - in trunk/owl: . perl/lib/BarnOwl perl/modules/IRC/lib/BarnOwl/Module perl/modules/Jabber/lib/BarnOwl/Module

daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:13:36 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
X-Original-To: nelhage@nelhage.com
To: dirty-owl-hackers@MIT.EDU
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Wed, 20 Aug 2008 02:16:43 -0400 (EDT)

Author: nelhage
Date: 2008-08-20 02:16:43 -0400 (Wed, 20 Aug 2008)
New Revision: 1105

Modified:
   trunk/owl/perl/lib/BarnOwl/ModuleLoader.pm
   trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
   trunk/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
   trunk/owl/perlwrap.pm
Log:
Support string hook entries.
perlwrap.pm: Support calling and adding string hook entries in BarnOwl::Hook
IRC.pm: Switch our hooks to use string entries
Jabber.pm: Switch our hooks to use string entries
ModuleLoader.pm: No longer clear all hooks on reload

This should have the net effect that we can safely reload single
modules.


Modified: trunk/owl/perl/lib/BarnOwl/ModuleLoader.pm
===================================================================
--- trunk/owl/perl/lib/BarnOwl/ModuleLoader.pm	2008-08-20 06:16:36 UTC (rev 1104)
+++ trunk/owl/perl/lib/BarnOwl/ModuleLoader.pm	2008-08-20 06:16:43 UTC (rev 1105)
@@ -102,11 +102,6 @@
     $INC{$_} = 1 for (qw(BarnOwl.pm BarnOwl/Hooks.pm
                          BarnOwl/Message.pm BarnOwl/Style.pm));
 
-    $BarnOwl::Hooks::startup->clear;
-    $BarnOwl::Hooks::getBuddyList->clear;
-    $BarnOwl::Hooks::mainLoop->clear;
-    $BarnOwl::Hooks::shutdown->clear;
-    $BarnOwl::Hooks::receiveMessage->clear;
     local $SIG{__WARN__} = \&squelch_redefine;
     $class->load_all;
     $BarnOwl::Hooks::startup->run(1);

Modified: trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
===================================================================
--- trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm	2008-08-20 06:16:36 UTC (rev 1104)
+++ trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm	2008-08-20 06:16:43 UTC (rev 1105)
@@ -119,9 +119,8 @@
     BarnOwl::new_command('irc-topic'      => \&cmd_topic);
 }
 
-$BarnOwl::Hooks::startup->add(\&startup);
-$BarnOwl::Hooks::shutdown->add(\&shutdown);
-#$BarnOwl::Hooks::mainLoop->add(\&mainloop_hook);
+$BarnOwl::Hooks::startup->add('BarnOwl::Module::IRC::startup');
+$BarnOwl::Hooks::shutdown->add('BarnOwl::Module::IRC::shutdown');
 
 ################################################################################
 ######################## Owl command handlers ##################################

Modified: trunk/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
===================================================================
--- trunk/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm	2008-08-20 06:16:36 UTC (rev 1104)
+++ trunk/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm	2008-08-20 06:16:43 UTC (rev 1105)
@@ -67,8 +67,8 @@
         register_owl_commands();
         register_keybindings();
         register_filters();
-        $BarnOwl::Hooks::mainLoop->add(\&onMainLoop);
-        $BarnOwl::Hooks::getBuddyList->add(\&onGetBuddyList);
+        $BarnOwl::Hooks::mainLoop->add("BarnOwl::Module::Jabber::onMainLoop");
+        $BarnOwl::Hooks::getBuddyList->add("BarnOwl::Module::Jabber::onGetBuddyList");
         $vars{show} = '';
 	BarnOwl::new_variable_bool("jabber:show_offline_buddies",
 				   { default => 1,
@@ -91,7 +91,7 @@
     }
 }
 
-$BarnOwl::Hooks::startup->add(\&onStart);
+$BarnOwl::Hooks::startup->add("BarnOwl::Module::Jabber::onStart");
 
 sub onMainLoop {
     return if ( !$conn->connected() );

Modified: trunk/owl/perlwrap.pm
===================================================================
--- trunk/owl/perlwrap.pm	2008-08-20 06:16:36 UTC (rev 1104)
+++ trunk/owl/perlwrap.pm	2008-08-20 06:16:43 UTC (rev 1105)
@@ -602,9 +602,17 @@
 sub run {
     my $self = shift;
     my @args = @_;
-    return map {$_->(@args)} @$self;
+    return map {$self->_run($_,@args)} @$self;
 }
 
+sub _run {
+    my $self = shift;
+    my $fn = shift;
+    my @args = @_;
+    no strict 'refs';
+    return $fn->(@args);
+}
+
 =head2 add SUBREF
 
 Registers a given subroutine with this hook
@@ -614,7 +622,8 @@
 sub add {
     my $self = shift;
     my $func = shift;
-    die("Not a coderef!") unless ref($func) eq 'CODE';
+    die("Not a coderef!") unless ref($func) eq 'CODE' || !ref($func);
+    return if grep {$_ eq $func} @$self;
     push @$self, $func;
 }
 


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