line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# Copyright (c) 1999-2017 Rob Fugina |
3
|
|
|
|
|
|
|
# Distributed under the terms of the GNU Public License, Version 3.0 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package X10::Macro; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
495
|
use X10::Event; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
294
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new |
13
|
|
|
|
|
|
|
{ |
14
|
0
|
|
|
0
|
0
|
|
my $type = shift; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my $self = bless { @_ }, $type; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub run |
23
|
|
|
|
|
|
|
{ |
24
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
return undef unless $self->{controller}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# send a list of events (specified by string) |
29
|
0
|
0
|
|
|
|
|
if (exists $self->{events}) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
$self->{controller}->send( |
32
|
0
|
|
|
|
|
|
map { new X10::Event($_) } @{$self->{events}} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
# send a list of events returned by a perl sub |
36
|
|
|
|
|
|
|
elsif (exists $self->{perleval}) |
37
|
|
|
|
|
|
|
{ |
38
|
0
|
|
|
|
|
|
$self->{controller}->send($self->{perleval}->()); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
# run a perl sub |
41
|
|
|
|
|
|
|
elsif (exists $self->{perlsub}) |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
|
|
|
$self->{perlsub}->(); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
|
|
|
|
|
return undef; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return 1; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub controller |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if (@_) |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
|
|
|
$self->{controller} = shift; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return $self->{controller}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub description |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
68
|
0
|
|
|
|
|
|
return $self->{description}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|