| 1 | #!/usr/bin/perl -w | ||||||||||
| 2 | # | ||||||||||
| 3 | # $Id: Null.pm,v 1.1.1.1 2003/10/28 16:04:37 andy Exp $ | ||||||||||
| 4 | # | ||||||||||
| 5 | # This code is copyright 1999-2000 by Scott Guelich <scott@scripted.com> | ||||||||||
| 6 | # and is distributed according to the same conditions as Perl itself | ||||||||||
| 7 | # Please visit http://www.scripted.com/wddx/ for more information | ||||||||||
| 8 | # | ||||||||||
| 9 | |||||||||||
| 10 | package WDDX::Null; | ||||||||||
| 11 | |||||||||||
| 12 | # Auto-inserted by build scripts | ||||||||||
| 13 | $VERSION = "1.01"; | ||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | require WDDX; | ||||||||||
| 19 | |||||||||||
| 20 | { my $i_hate_the_w_flag_sometimes = [ | ||||||||||
| 21 | $WDDX::PACKET_HEADER, | ||||||||||
| 22 | $WDDX::PACKET_FOOTER, | ||||||||||
| 23 | $WDDX::Null::VERSION | ||||||||||
| 24 | ] } | ||||||||||
| 25 | |||||||||||
| 26 | 1; | ||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | #/----------------------------------------------------------------------- | ||||||||||
| 30 | # Public Methods | ||||||||||
| 31 | # | ||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||
| 34 | 0 | return bless { value => undef }, shift; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub type { | ||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
| |||||||||||
| 39 | 0 | return "null"; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub as_packet { | ||||||||
|
Subroutine
as_packet: not called CC=1 SCAR=6.9
| |||||||||||
| 44 | 0 | my( $self ) = @_; | |||||||||
| 45 | 0 | my $output = $WDDX::PACKET_HEADER . | |||||||||
| 46 | $self->_serialize . | ||||||||||
| 47 | $WDDX::PACKET_FOOTER; | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | sub as_scalar { | ||||||||
|
Subroutine
as_scalar: not called CC=1 SCAR=6.9
| |||||||||||
| 52 | 0 | my( $self ) = @_; | |||||||||
| 53 | 0 | return $self->_deserialize; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | sub as_javascript { | ||||||||
|
Subroutine
as_javascript: not called CC=1 SCAR=6.9
| |||||||||||
| 58 | 0 | my( $self, $js_var ) = @_; | |||||||||
| 59 | 0 | return "$js_var=null;"; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | |||||||||||
| 63 | #/----------------------------------------------------------------------- | ||||||||||
| 64 | # Private Methods | ||||||||||
| 65 | # | ||||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | sub is_parser { | ||||||||
|
Subroutine
is_parser: not called CC=1 SCAR=6.9
| |||||||||||
| 68 | 0 | return 0; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | sub _serialize { | ||||||||
|
Subroutine
_serialize: not called CC=1 SCAR=6.9
| |||||||||||
| 73 | 0 | return "<null/>"; | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub _deserialize { | ||||||||
|
Subroutine
_deserialize: not called CC=1 SCAR=6.9
| |||||||||||
| 78 | 0 | return undef; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | #/----------------------------------------------------------------------- | ||||||||||
| 83 | # Parsing Code | ||||||||||
| 84 | # | ||||||||||
| 85 | |||||||||||
| 86 | package WDDX::Null::Parser; | ||||||||||
| 87 | |||||||||||
| 88 | |||||||||||
| 89 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||
| 90 | 0 | return bless { value => undef }, shift; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | |||||||||||
| 94 | 0 | ▶ | sub start_tag { | ||||||||
|
Subroutine
start_tag: not called CC=2 SCAR=17.9
| |||||||||||
| 95 | 0 | my( $self, $element, $attribs ) = @_; | |||||||||
| 96 | |||||||||||
| 97 | 0 | ▶ | die "<$element> not allowed within <null> element\n" unless $element eq "null"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | 0 | return $self; | |||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | |||||||||||
| 102 | 0 | ▶ | sub end_tag { | ||||||||
|
Subroutine
end_tag: not called CC=2 SCAR=17.9
| |||||||||||
| 103 | 0 | my( $self, $element ) = @_; | |||||||||
| 104 | |||||||||||
| 105 | 0 | ▶ | if ( $element eq "null" ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 106 | 0 | $self = new WDDX::Null(); | |||||||||
| 107 | } | ||||||||||
| 108 | else { | ||||||||||
| 109 | 0 | die "</$element> not allowed within <null> element\n"; | |||||||||
| 110 | } | ||||||||||
| 111 | 0 | return $self; | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | |||||||||||
| 115 | 0 | ▶ | sub append_data { | ||||||||
|
Subroutine
append_data: not called CC=2 SCAR=17.9
| |||||||||||
| 116 | 0 | my( $self, $data ) = @_; | |||||||||
| 117 | 0 | ▶ | die "No data is allowed between <null> tags\n" if $data =~ /\S/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | |||||||||||
| 121 | 0 | ▶ | sub is_parser { | ||||||||
|
Subroutine
is_parser: not called CC=1 SCAR=6.9
| |||||||||||
| 122 | 0 | return 1; | |||||||||
| 123 | } | ||||||||||
| 124 | |||||||||||