… | |
… | |
34 | |
34 | |
35 | The import tag to use is named C<event=xyz>, e.g. C<event=Event>, |
35 | The import tag to use is named C<event=xyz>, e.g. C<event=Event>, |
36 | C<event=Glib> etc. |
36 | C<event=Glib> etc. |
37 | |
37 | |
38 | You should specify the event module to use only in the main program. |
38 | You should specify the event module to use only in the main program. |
|
|
39 | |
|
|
40 | If no event model has been specified, FCP tries to autodetect it on first |
|
|
41 | use (e.g. first transaction), in this order: Coro, Event, Glib, Tk. |
39 | |
42 | |
40 | =head2 FREENET BASICS |
43 | =head2 FREENET BASICS |
41 | |
44 | |
42 | Ok, this section will not explain any freenet basics to you, just some |
45 | Ok, this section will not explain any freenet basics to you, just some |
43 | problems I found that you might want to avoid: |
46 | problems I found that you might want to avoid: |
… | |
… | |
74 | $VERSION = 0.08; |
77 | $VERSION = 0.08; |
75 | |
78 | |
76 | no warnings; |
79 | no warnings; |
77 | |
80 | |
78 | our $EVENT = Net::FCP::Event::Auto::; |
81 | our $EVENT = Net::FCP::Event::Auto::; |
79 | $EVENT = Net::FCP::Event::Event;#d# |
|
|
80 | |
82 | |
81 | sub import { |
83 | sub import { |
82 | shift; |
84 | shift; |
83 | |
85 | |
84 | for (@_) { |
86 | for (@_) { |
85 | if (/^event=(\w+)$/) { |
87 | if (/^event=(\w+)$/) { |
86 | $EVENT = "Net::FCP::Event::$1"; |
88 | $EVENT = "Net::FCP::Event::$1"; |
|
|
89 | eval "require $EVENT"; |
87 | } |
90 | } |
88 | } |
91 | } |
89 | eval "require $EVENT"; |
|
|
90 | die $@ if $@; |
92 | die $@ if $@; |
91 | } |
93 | } |
92 | |
94 | |
93 | sub touc($) { |
95 | sub touc($) { |
94 | local $_ = shift; |
96 | local $_ = shift; |
… | |
… | |
889 | Marc Lehmann <pcg@goof.com> |
891 | Marc Lehmann <pcg@goof.com> |
890 | http://www.goof.com/pcg/marc/ |
892 | http://www.goof.com/pcg/marc/ |
891 | |
893 | |
892 | =cut |
894 | =cut |
893 | |
895 | |
|
|
896 | package Net::FCP::Event::Auto; |
|
|
897 | |
|
|
898 | my @models = ( |
|
|
899 | [Coro => Coro::Event:: ], |
|
|
900 | [Event => Event::], |
|
|
901 | [Glib => Glib:: ], |
|
|
902 | [Tk => Tk::], |
|
|
903 | ); |
|
|
904 | |
|
|
905 | sub AUTOLOAD { |
|
|
906 | $AUTOLOAD =~ s/.*://; |
|
|
907 | |
|
|
908 | for (@models) { |
|
|
909 | my ($model, $package) = @$_; |
|
|
910 | if (defined ${"$package\::VERSION"}) { |
|
|
911 | $EVENT = "Net::FCP::Event::$model"; |
|
|
912 | eval "require $EVENT"; die if $@; |
|
|
913 | goto &{"$EVENT\::$AUTOLOAD"}; |
|
|
914 | } |
|
|
915 | } |
|
|
916 | |
|
|
917 | for (@models) { |
|
|
918 | my ($model, $package) = @$_; |
|
|
919 | $EVENT = "Net::FCP::Event::$model"; |
|
|
920 | if (eval "require $EVENT") { |
|
|
921 | goto &{"$EVENT\::$AUTOLOAD"}; |
|
|
922 | } |
|
|
923 | } |
|
|
924 | |
|
|
925 | die "No event module selected for Net::FCP and autodetect failed. Install any of these: Coro, Event, Glib or Tk."; |
|
|
926 | } |
|
|
927 | |
894 | 1; |
928 | 1; |
895 | |
929 | |