| 1 | package JE::Undefined; | ||
| 2 | |||
| 3 | 100 | our $VERSION = '0.066'; | |
| 4 | |||
| 5 | 100 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 100 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 100 | ▶ | use overload fallback => 1, |
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||
| 9 | '""' => 'typeof', | ||
| 10 | # cmp => sub { "$_[0]" cmp $_[1] }, | ||
| 11 | bool => \&value, | ||
| 12 | 0 | ▶ | '0+' => sub { sin 9**9**9 }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||
| 13 | |||
| 14 | # ~~~ How should this numify? | ||
| 15 | |||
| 16 | 100 | require JE::String; | |
| 17 | 100 | require JE::Boolean; | |
| 18 | |||
| 19 | |||
| 20 | =head1 NAME | ||
| 21 | |||
| 22 | JE::Undefined - JavaScript undefined value | ||
| 23 | |||
| 24 | =head1 SYNOPSIS | ||
| 25 | |||
| 26 | use JE; | ||
| 27 | |||
| 28 | $j = new JE; | ||
| 29 | |||
| 30 | $js_undefined = $j->undef; | ||
| 31 | |||
| 32 | $js_undefined->value; # undef | ||
| 33 | |||
| 34 | =head1 DESCRIPTION | ||
| 35 | |||
| 36 | This class implements the JavaScript "undefined" type. There really | ||
| 37 | isn't much to it. | ||
| 38 | |||
| 39 | Undefined stringifies to 'undefined', and is false as a boolean. | ||
| 40 | |||
| 41 | =cut | ||
| 42 | |||
| 43 | # A JE::Undefined object is a reference to a global object. | ||
| 44 | |||
| 45 | 107 | ▶ | sub new { bless \do{my $thing = $_[1]}, $_[0] } |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 46 | 3 | ▶ | sub value { undef } |
|
Subroutine
value: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 47 | 100 | *TO_JSON=*value; | |
| 48 | 230 | ▶ | sub typeof { 'undefined' } |
|
Subroutine
typeof: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 49 | 176 | ▶ | sub id { 'undef' } |
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 50 | 17 | ▶ | sub primitive { 1 } |
|
Subroutine
primitive: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 51 | 133 | ▶ | sub to_primitive { $_[0] } |
|
Subroutine
to_primitive: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 52 | 61 | ▶ | sub to_boolean { JE::Boolean->new(${+shift}, 0) } |
|
Subroutine
to_boolean: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 53 | 156 | ▶ | sub to_string { JE::String->_new(${+shift}, 'undefined') }; |
|
Subroutine
to_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 54 | 234 | ▶ | sub to_number { JE::Number->new(${+shift}, 'NaN') } |
|
Subroutine
to_number: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 55 | 2 | ▶ | sub global { ${$_[0]} } |
|
Subroutine
global: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 56 | |||
| 57 | 100 | return "undef"; | |
| 58 | __END__ | ||