/[suikacvs]/messaging/manakai/lib/Message/DOM/Notation.pm
Suika

Contents of /messaging/manakai/lib/Message/DOM/Notation.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Sun Jul 8 05:42:37 2007 UTC (17 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.5: +23 -2 lines
++ manakai/t/ChangeLog	8 Jul 2007 05:42:31 -0000
2007-07-08  Wakaba  <wakaba@suika.fam.cx>

	* DOM-Document.t, DOM-Node.t, DOM-NodeList.t: Some tests are modified so
	that no |WRONG_DOCUMENT_ERR| is raised.

	* DOM-Node.t: Tests for |remove_child| are added.

++ manakai/lib/Message/DOM/ChangeLog	8 Jul 2007 05:41:27 -0000
2007-07-08  Wakaba  <wakaba@suika.fam.cx>

	* Attr.pm, AttributeDefinition.pm, DOMCharacterData.pm,
	DOMDocument.pm, DocumentType.pm, ElementTypeDefinition.pm,
	Node.pm, Notation.pm, ProcessingInstruction.pm (append_child,
	insert_before, replace_child): Implemented.

	* DOMException.pm (HIERARCHY_REQUEST_ERR, NOT_FOUND_ERR): Implemented.

	* Node.pm (remove_child): Implemented.

1 package Message::DOM::Notation;
2 use strict;
3 our $VERSION=do{my @r=(q$Revision: 1.5 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4 push our @ISA, 'Message::DOM::Node', 'Message::IF::Notation';
5 require Message::DOM::Node;
6
7 sub ____new ($$$) {
8 my $self = shift->SUPER::____new (shift);
9 $$self->{node_name} = $_[0];
10 return $self;
11 } # ____new
12
13 sub AUTOLOAD {
14 my $method_name = our $AUTOLOAD;
15 $method_name =~ s/.*:://;
16 return if $method_name eq 'DESTROY';
17
18 if ({
19 ## Read-only attributes (trivial accessors)
20 node_name => 1,
21 }->{$method_name}) {
22 no strict 'refs';
23 eval qq{
24 sub $method_name (\$) {
25 if (\@_ > 1) {
26 require Carp;
27 Carp::croak (qq<Can't modify read-only attribute>);
28 }
29 return \${\$_[0]}->{$method_name};
30 }
31 };
32 goto &{ $AUTOLOAD };
33 } elsif ({
34 ## Read-write attributes (DOMString, trivial accessors)
35 public_id => 1,
36 system_id => 1,
37 }->{$method_name}) {
38 no strict 'refs';
39 eval qq{
40 sub $method_name (\$;\$) {
41 if (\@_ > 1) {
42 if (\${\$_[0]}->{strict_error_checking} and
43 \${\$_[0]}->{manakai_read_only}) {
44 report Message::DOM::DOMException
45 -object => \$_[0],
46 -type => 'NO_MODIFICATION_ALLOWED_ERR',
47 -subtype => 'READ_ONLY_NODE_ERR';
48 }
49 if (defined \$_[1]) {
50 \${\$_[0]}->{$method_name} = ''.\$_[1];
51 } else {
52 delete \${\$_[0]}->{$method_name};
53 }
54 }
55 return \${\$_[0]}->{$method_name};
56 }
57 };
58 goto &{ $AUTOLOAD };
59 } else {
60 require Carp;
61 Carp::croak (qq<Can't locate method "$AUTOLOAD">);
62 }
63 } # AUTOLOAD
64
65 ## |Node| attributes
66
67 sub child_nodes ($) {
68 require Message::DOM::NodeList;
69 return bless \\($_[0]), 'Message::DOM::NodeList::EmptyNodeList';
70 } # child_nodes
71
72 sub node_name ($); # read-only trivial accessor
73
74 sub node_type () { 12 } # NOTATION_NODE
75
76 sub text_content () { undef }
77
78 ## |Node| methods
79
80 sub append_child ($$) {
81 report Message::DOM::DOMException
82 -object => $_[0],
83 -type => 'HIERARCHY_REQUEST_ERR',
84 -subtype => 'CHILD_NODE_TYPE_ERR';
85 } # append_child
86
87 sub manakai_append_text () { }
88
89 sub insert_before ($;$) {
90 report Message::DOM::DOMException
91 -object => $_[0],
92 -type => 'HIERARCHY_REQUEST_ERR',
93 -subtype => 'CHILD_NODE_TYPE_ERR';
94 } # insert_before
95
96 sub replace_child ($$) {
97 report Message::DOM::DOMException
98 -object => $_[0],
99 -type => 'HIERARCHY_REQUEST_ERR',
100 -subtype => 'CHILD_NODE_TYPE_ERR';
101 } # replace_child
102
103 ## |Notation| attributes
104
105 sub manakai_declaration_base_uri ($;$) {
106 ## NOTE: Same as |Notation|'s.
107
108 if (@_ > 1) {
109 if (${${$_[0]}->{owner_document}}->{strict_error_checking} and
110 ${$_[0]}->{manakai_read_only}) {
111 report Message::DOM::DOMException
112 -object => $_[0],
113 -type => 'NO_MODIFICATION_ALLOWED_ERR',
114 -subtype => 'READ_ONLY_NODE_ERR';
115 }
116 if (defined $_[1]) {
117 ${$_[0]}->{manakai_declaration_base_uri} = ''.$_[1];
118 } else {
119 delete ${$_[0]}->{manakai_declaration_base_uri};
120 }
121 }
122
123 if (defined wantarray) {
124 if (defined ${$_[0]}->{manakai_declaration_base_uri}) {
125 return ${$_[0]}->{manakai_declaration_base_uri};
126 } else {
127 local $Error::Depth = $Error::Depth + 1;
128 return $_[0]->base_uri;
129 }
130 }
131 } # manakai_declaration_base_uri
132
133 ## NOTE: Setter is a manakai extension.
134 sub public_id ($;$);
135
136 ## NOTE: Setter is a manakai extension.
137 sub system_id ($;$);
138
139 package Message::IF::Notation;
140
141 package Message::DOM::Document;
142
143 sub create_notation ($$) {
144 return Message::DOM::Notation->____new (@_[0, 1]);
145 } # create_notation
146
147 =head1 LICENSE
148
149 Copyright 2007 Wakaba <w@suika.fam.cx>
150
151 This program is free software; you can redistribute it and/or
152 modify it under the same terms as Perl itself.
153
154 =cut
155
156 1;
157 ## $Date: 2007/06/17 13:37:40 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24