ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/MakeMaker.pm
Revision: 1.10
Committed: Mon Apr 7 13:34:05 2008 UTC (16 years, 1 month ago) by root
Branch: MAIN
CVS Tags: rel-3_51, rel-3_31, rel-3_33, rel-3_53, rel-3_52, EV-rel-4_22, EV-rel-4_20, EV-rel-4_21, rel-3_7, rel-3_6, rel-3_4, rel-3_3, rel-4_01, rel-4_00, rel-4_03, rel-4_02, rel-3_9, rel-3_8, rel-3_49, rel-3_44, rel-3_41, rel-3_42, rel-3_43, rel-3_48, EV_rel-4_11, EV_rel-4_10, EV-rel-4_15, rel-3_431, EV_rel-4_17, EV_rel-4_16, EV-rel-4_18
Changes since 1.9: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 package EV::MakeMaker;
2    
3     BEGIN { eval { require warnings } && warnings->unimport ("uninitialized") }
4    
5     use Config;
6     use base 'Exporter';
7    
8     @EXPORT_OK = qw(&ev_args $installsitearch);
9    
10     my %opt;
11    
12     for my $opt (split /:+/, $ENV{PERL_MM_OPT}) {
13     my ($k,$v) = split /=/, $opt;
14     $opt{$k} = $v;
15     }
16    
17     my $extra = $Config{sitearch};
18    
19     $extra =~ s/$Config{prefix}/$opt{PREFIX}/ if
20     exists $opt{PREFIX};
21    
22     for my $d ($extra, @INC) {
23     if (-e "$d/EV/EVAPI.h") {
24     $installsitearch = $d;
25     last;
26     }
27     }
28    
29     sub ev_args {
30     my %arg = @_;
31 root 1.2 $arg{INC} .= " -I$installsitearch/EV -I$installsitearch";
32 root 1.1 %arg;
33     }
34    
35     1;
36     __END__
37    
38     =head1 NAME
39    
40     EV::MakeMaker - MakeMaker glue for the C-level EV API
41    
42     =head1 SYNOPSIS
43    
44     This allows you to access some libevent functionality from other perl
45     modules.
46    
47     =head1 DESCRIPTION
48    
49     For optimal performance, hook into EV at the C-level. You'll need
50     to make changes to your C<Makefile.PL> and add code to your C<xs> /
51     C<c> file(s).
52    
53     =head1 HOW TO
54    
55     =head2 Makefile.PL
56    
57     use EV::MakeMaker qw(ev_args);
58    
59     # ... set up %args ...
60    
61     WriteMakefile (ev_args (%args));
62    
63     =head2 XS
64    
65     #include "EVAPI.h"
66    
67     BOOT:
68     I_EV_API ("YourModule");
69    
70 root 1.4 =head1 API
71 root 1.1
72 root 1.9 See the L<EVAPI.h|http://cvs.schmorp.de/EV/EV/EVAPI.h> header, which you should include instead
73     of F<ev.h>.
74 root 1.1
75 root 1.3 In short, all the functions and macros from F<ev.h> should work, except
76     that the trailing underscore macros (C<EV_A_>, C<EV_DEFAULT_>) are not
77     available (except C<EV_P_> :).
78    
79     Multiplicity is enabled.
80    
81     The C<data> member in each watcher is of type C<SV *> and not C<void *>
82     (this might change at some point).
83    
84 root 1.4 =head1 EXAMPLE
85 root 1.3
86 root 1.10 The L<EV::Glib>, L<EV::ADNS> and L<Glib::EV> modules all give nice
87     examples on how to use this module.
88 root 1.3
89     Here are some F<.xs> fragments taken from EV::ADNS that should get you
90     going:
91    
92 root 1.8 #include "EVAPI.h"
93 root 1.3
94     static ev_prepare pw;
95     static ev_idle iw;
96    
97     static void
98     idle_cb (EV_P_ ev_idle *w, int revents)
99     {
100     ev_idle_stop (EV_A, w);
101     }
102    
103     MODULE = ...
104    
105     BOOT:
106     {
107     I_EV_API ("EV::ADNS");
108     ev_prepare_init (&pw, prepare_cb);
109     ev_init (&iw, idle_cb); ev_set_priority (&iw, EV_MINPRI);
110     ev_idle_start (EV_DEFAULT, &iw);
111     }
112    
113 root 1.1 =cut
114 root 1.3