line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2010-2015 Martin Becker. All rights reserved. |
2
|
|
|
|
|
|
|
# This package is free software; you can redistribute it and/or modify it |
3
|
|
|
|
|
|
|
# under the same terms as Perl itself. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# $Id: Event.pm 60 2015-05-18 08:47:12Z demetri $ |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Math::ModInt::Event; |
8
|
|
|
|
|
|
|
|
9
|
11
|
|
|
11
|
|
196
|
use 5.006; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
373
|
|
10
|
11
|
|
|
11
|
|
40
|
use strict; |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
262
|
|
11
|
11
|
|
|
11
|
|
43
|
use warnings; |
|
11
|
|
|
|
|
12
|
|
|
11
|
|
|
|
|
296
|
|
12
|
11
|
|
|
11
|
|
49
|
use Carp qw(croak); |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
605
|
|
13
|
11
|
|
|
11
|
|
4662
|
use Math::ModInt::Event::Trap; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
876
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ----- class data ----- |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BEGIN { |
18
|
11
|
|
|
11
|
|
69
|
require Exporter; |
19
|
11
|
|
|
|
|
105
|
our @ISA = qw(Exporter); |
20
|
11
|
|
|
|
|
29
|
our @EXPORT_OK = qw( |
21
|
|
|
|
|
|
|
AnyEvent Unrecoverable Recoverable UsageError Nonexistent |
22
|
|
|
|
|
|
|
LoadingFailure UndefinedResult DifferentModuli |
23
|
|
|
|
|
|
|
); |
24
|
11
|
|
|
|
|
16
|
our @CARP_NOT = qw(Math::ModInt); |
25
|
11
|
|
|
|
|
238
|
our $VERSION = '0.011'; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Math::ModInt::Event=ARRAY(...) |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# ............ index ............ # ............ value ............ |
31
|
11
|
|
|
11
|
|
37
|
use constant F_DESCRIPTION => 0; # a short event description string |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
488
|
|
32
|
11
|
|
|
11
|
|
46
|
use constant NFIELDS => 1; |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
1744
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# ----- private subroutines ----- |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# create a new event subclass and return a singleton instance of that class |
37
|
|
|
|
|
|
|
# - description string is made of the words in the camel-case class name |
38
|
|
|
|
|
|
|
# - parent class is taken from optional parent object or defaults to Event. |
39
|
|
|
|
|
|
|
sub _make { |
40
|
88
|
|
|
88
|
|
130
|
my ($class, $parent) = @_; |
41
|
88
|
|
|
|
|
475
|
my $description = lc join q[ ], split /(?<=[a-z])(?=[A-Z])/, $class; |
42
|
88
|
|
|
|
|
164
|
$class = join '::', __PACKAGE__, $class; |
43
|
88
|
|
100
|
|
|
5695
|
eval join '', '@', $class, '::ISA = qw(', ref $parent || __PACKAGE__, ')'; |
44
|
88
|
|
|
|
|
7740
|
return bless [$description], $class; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# ----- public methods ----- |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# singleton event constructors: |
50
|
|
|
|
|
|
|
|
51
|
11
|
|
|
11
|
|
73
|
use constant AnyEvent => _make('AnyEvent'); |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
37
|
|
52
|
11
|
|
|
11
|
|
51
|
use constant Unrecoverable => _make('Unrecoverable', AnyEvent); |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
33
|
|
53
|
11
|
|
|
11
|
|
56
|
use constant UsageError => _make('UsageError', Unrecoverable); |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
24
|
|
54
|
11
|
|
|
11
|
|
54
|
use constant Nonexistent => _make('Nonexistent', Unrecoverable); |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
22
|
|
55
|
11
|
|
|
11
|
|
53
|
use constant LoadingFailure => _make('LoadingFailure', Unrecoverable); |
|
11
|
|
|
|
|
130
|
|
|
11
|
|
|
|
|
27
|
|
56
|
11
|
|
|
11
|
|
53
|
use constant Recoverable => _make('Recoverable', AnyEvent); |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
23
|
|
57
|
11
|
|
|
11
|
|
57
|
use constant UndefinedResult => _make('UndefinedResult', Recoverable); |
|
11
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
30
|
|
58
|
11
|
|
|
11
|
|
51
|
use constant DifferentModuli => _make('DifferentModuli', Recoverable); |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
32
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub description { |
61
|
39
|
|
|
39
|
1
|
47
|
my ($this) = @_; |
62
|
39
|
|
|
|
|
7672
|
return $this->[F_DESCRIPTION]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
36
|
|
|
36
|
1
|
104
|
sub is_recoverable { 0 } |
66
|
74
|
|
|
74
|
|
190
|
sub Math::ModInt::Event::Recoverable::is_recoverable { 1 } |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub trap { |
69
|
15
|
|
|
15
|
1
|
623
|
my ($this, $handler) = @_; |
70
|
15
|
|
|
|
|
38
|
return Math::ModInt::Event::Trap->new($this, $handler); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub raise { |
74
|
114
|
|
|
114
|
1
|
190
|
my ($this, @details) = @_; |
75
|
114
|
|
|
|
|
406
|
Math::ModInt::Event::Trap->broadcast($this, @details); |
76
|
74
|
|
|
|
|
109
|
return $this; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |