1 |
wakaba |
1.1 |
use lib qw[../..]; |
2 |
|
|
|
3 |
|
|
#!/usr/bin/perl -w |
4 |
|
|
use strict; |
5 |
|
|
|
6 |
|
|
=head1 NAME |
7 |
|
|
|
8 |
|
|
cdis2pm - Generating Perl Module from a Compiled "dis" |
9 |
|
|
|
10 |
|
|
=head1 SYNOPSIS |
11 |
|
|
|
12 |
|
|
perl path/to/cdis2pm.pl input.cdis \ |
13 |
|
|
{--module-name=ModuleName | --module-uri=module-uri} \ |
14 |
|
|
[--for=for-uri] [options] > ModuleName.pm |
15 |
|
|
perl path/to/cdis2pm.pl --help |
16 |
|
|
|
17 |
|
|
=head1 DESCRIPTION |
18 |
|
|
|
19 |
|
|
The C<cdis2pm> script generates a Perl module from a compiled "dis" |
20 |
|
|
("cdis") file. It is intended to be used to generate a manakai |
21 |
|
|
DOM Perl module files, although it might be useful for other purpose. |
22 |
|
|
|
23 |
|
|
This script is part of manakai. |
24 |
|
|
|
25 |
|
|
=cut |
26 |
|
|
|
27 |
|
|
use Message::DOM::DOMHTML; |
28 |
|
|
use Message::DOM::DOMLS; |
29 |
|
|
use Message::Util::DIS::DISDump; |
30 |
|
|
use Message::Util::QName::Filter { |
31 |
wakaba |
1.3 |
ddel => q<http://suika.fam.cx/~wakaba/archive/2005/disdoc#>, |
32 |
wakaba |
1.1 |
ddoct => q<http://suika.fam.cx/~wakaba/archive/2005/8/disdump-xslt#>, |
33 |
|
|
DIS => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#>, |
34 |
|
|
dis => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis-->, |
35 |
|
|
dis2pm => q<http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#>, |
36 |
|
|
DISCore => q<http://suika.fam.cx/~wakaba/archive/2004/dis/Core#>, |
37 |
|
|
DISLang => q<http://suika.fam.cx/~wakaba/archive/2004/dis/Lang#>, |
38 |
|
|
DISPerl => q<http://suika.fam.cx/~wakaba/archive/2004/dis/Perl#>, |
39 |
|
|
disPerl => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--Perl-->, |
40 |
|
|
DOMCore => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#>, |
41 |
|
|
DOMEvents => q<http://suika.fam.cx/~wakaba/archive/2004/dom/events#>, |
42 |
|
|
DOMLS => q<http://suika.fam.cx/~wakaba/archive/2004/dom/ls#>, |
43 |
|
|
DOMMain => q<http://suika.fam.cx/~wakaba/archive/2004/dom/main#>, |
44 |
|
|
DOMXML => q<http://suika.fam.cx/~wakaba/archive/2004/dom/xml#>, |
45 |
|
|
dump => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#DISDump/>, |
46 |
|
|
DX => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#>, |
47 |
|
|
html5 => q<http://www.w3.org/1999/xhtml>, |
48 |
wakaba |
1.3 |
infoset => q<http://www.w3.org/2001/04/infoset#>, |
49 |
wakaba |
1.1 |
lang => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#>, |
50 |
|
|
Perl => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl-->, |
51 |
|
|
license => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/license#>, |
52 |
|
|
ManakaiDOM => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#>, |
53 |
|
|
Markup => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#>, |
54 |
|
|
MDOMX => q<http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#>, |
55 |
|
|
owl => q<http://www.w3.org/2002/07/owl#>, |
56 |
|
|
pc => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/PerlCode#>, |
57 |
|
|
rdf => q<http://www.w3.org/1999/02/22-rdf-syntax-ns#>, |
58 |
|
|
rdfs => q<http://www.w3.org/2000/01/rdf-schema#>, |
59 |
|
|
swcfg21 => q<http://suika.fam.cx/~wakaba/archive/2005/swcfg21#>, |
60 |
|
|
TreeCore => q<>, |
61 |
|
|
Util => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/>, |
62 |
|
|
xhtml1 => q<http://www.w3.org/1999/xhtml>, |
63 |
|
|
xhtml2 => q<http://www.w3.org/2002/06/xhtml2>, |
64 |
|
|
xml => q<http://www.w3.org/XML/1998/namespace>, |
65 |
wakaba |
1.3 |
xmlns => q<http://www.w3.org/2000/xmlns/>, |
66 |
wakaba |
1.1 |
}; |
67 |
|
|
|
68 |
|
|
=head1 OPTIONS |
69 |
|
|
|
70 |
|
|
=over 4 |
71 |
|
|
|
72 |
|
|
=item --enable-assertion / --noenable-assertion (default) |
73 |
|
|
|
74 |
|
|
Whether assertion codes should be outputed or not. |
75 |
|
|
|
76 |
|
|
=item --for=I<for-uri> (Optional) |
77 |
|
|
|
78 |
|
|
Specifies the "For" URI reference for which the outputed module is. |
79 |
|
|
If this parameter is ommitted, the default "For" URI reference |
80 |
|
|
for the module, if any, or the C<ManakaiDOM:all> is assumed. |
81 |
|
|
|
82 |
|
|
=item --help |
83 |
|
|
|
84 |
|
|
Shows the help message. |
85 |
|
|
|
86 |
|
|
=item --module-name=I<ModuleName> |
87 |
|
|
|
88 |
|
|
The name of module to output. It is the local name part of |
89 |
|
|
the C<Module> C<QName> in the source "dis" file. Either |
90 |
|
|
C<--module-name> or C<--module-uri> is required. |
91 |
|
|
|
92 |
|
|
=item --module-uri=I<module-uri> |
93 |
|
|
|
94 |
|
|
A URI reference that identifies a module to output. Either |
95 |
|
|
C<--module-name> or C<--module-uri> is required. |
96 |
|
|
|
97 |
|
|
=item --output-file-path=I<perl-module-file-path> (default: C<STDOUT>) |
98 |
|
|
|
99 |
|
|
A platform-dependent file name path for the output. |
100 |
|
|
If it is not specified, then the generated Perl module |
101 |
|
|
content is outputed to the standard output. |
102 |
|
|
|
103 |
|
|
=item --output-module-version (default) / --nooutput-module-version |
104 |
|
|
|
105 |
|
|
Whether the C<$VERSION> special variable should be generated or not. |
106 |
|
|
|
107 |
|
|
=item --verbose / --noverbose (default) |
108 |
|
|
|
109 |
|
|
Whether a verbose message mode should be selected or not. |
110 |
|
|
|
111 |
|
|
=back |
112 |
|
|
|
113 |
|
|
=cut |
114 |
|
|
|
115 |
|
|
use Getopt::Long; |
116 |
|
|
use Pod::Usage; |
117 |
|
|
use Storable; |
118 |
|
|
use Message::Util::Error; |
119 |
|
|
my %Opt; |
120 |
|
|
GetOptions ( |
121 |
|
|
'for=s' => \$Opt{For}, |
122 |
|
|
'help' => \$Opt{help}, |
123 |
|
|
'module-uri=s' => \$Opt{module_uri}, |
124 |
|
|
'output-file-path=s' => \$Opt{output_file_name}, |
125 |
|
|
) or pod2usage (2); |
126 |
|
|
pod2usage ({-exitval => 0, -verbose => 1}) if $Opt{help}; |
127 |
|
|
$Opt{file_name} = shift; |
128 |
|
|
pod2usage ({-exitval => 2, -verbose => 0}) unless $Opt{file_name}; |
129 |
|
|
pod2usage (2) unless $Opt{module_uri}; |
130 |
|
|
|
131 |
|
|
sub status_msg ($) { |
132 |
|
|
my $s = shift; |
133 |
|
|
$s .= "\n" unless $s =~ /\n$/; |
134 |
|
|
print STDERR $s; |
135 |
|
|
} |
136 |
|
|
|
137 |
|
|
sub status_msg_ ($) { |
138 |
|
|
my $s = shift; |
139 |
|
|
print STDERR $s; |
140 |
|
|
} |
141 |
|
|
|
142 |
|
|
sub verbose_msg ($) { |
143 |
|
|
my $s = shift; |
144 |
|
|
$s .= "\n" unless $s =~ /\n$/; |
145 |
|
|
print STDERR $s; |
146 |
|
|
} |
147 |
|
|
|
148 |
|
|
sub verbose_msg_ ($) { |
149 |
|
|
my $s = shift; |
150 |
|
|
print STDERR $s; |
151 |
|
|
} |
152 |
|
|
|
153 |
|
|
my $impl = $Message::DOM::DOMImplementationRegistry->get_dom_implementation |
154 |
|
|
({ |
155 |
|
|
ExpandedURI q<ManakaiDOM:Minimum> => '3.0', |
156 |
|
|
# ExpandedURI q<ManakaiDOM:HTML> => '', # 3.0 |
157 |
|
|
'+' . ExpandedURI q<DOMLS:LS> => '3.0', |
158 |
|
|
'+' . ExpandedURI q<DIS:Doc> => '2.0', |
159 |
|
|
ExpandedURI q<DIS:Dump> => '1.0', |
160 |
|
|
}); |
161 |
|
|
|
162 |
|
|
## -- Load input dac database file |
163 |
|
|
status_msg_ qq<Opening dac file "$Opt{file_name}"...>; |
164 |
|
|
my $db = $impl->get_feature (ExpandedURI q<DIS:Core> => '1.0') |
165 |
|
|
->pl_load_dis_database ($Opt{file_name}); |
166 |
|
|
status_msg qq<done\n>; |
167 |
|
|
|
168 |
|
|
## -- Load requested module |
169 |
|
|
my $mod = $db->get_module ($Opt{module_uri}, for_arg => $Opt{For}); |
170 |
|
|
unless ($Opt{For}) { |
171 |
|
|
my $el = $mod->source_element; |
172 |
|
|
if ($el) { |
173 |
|
|
$Opt{For} = $el->default_for_uri; |
174 |
|
|
$mod = $db->get_module ($Opt{module_uri}, for_arg => $Opt{For}); |
175 |
|
|
} |
176 |
|
|
} |
177 |
|
|
unless ($mod->is_defined) { |
178 |
|
|
die qq<$0: Module <$Opt{module_uri}> for <$Opt{For}> is not defined>; |
179 |
|
|
} |
180 |
|
|
|
181 |
|
|
status_msg qq<Module <$Opt{module_uri}> for <$Opt{For}>...>; |
182 |
|
|
|
183 |
wakaba |
1.2 |
our %ReferredResource; |
184 |
|
|
|
185 |
wakaba |
1.1 |
sub append_module_documentation (%) { |
186 |
|
|
my %opt = @_; |
187 |
|
|
my $section = $opt{result_parent}->create_module ($opt{source_resource}->uri); |
188 |
wakaba |
1.2 |
|
189 |
|
|
add_uri ($opt{source_resource} => $section); |
190 |
wakaba |
1.1 |
|
191 |
|
|
my $pl_full_name = $opt{source_resource}->pl_fully_qualified_name; |
192 |
|
|
if (defined $pl_full_name) { |
193 |
|
|
$section->perl_package_name ($pl_full_name); |
194 |
|
|
my $path = $pl_full_name; |
195 |
|
|
$path =~ s#::#/#g; |
196 |
|
|
$section->resource_file_path_stem ($path); |
197 |
|
|
$section->set_attribute_ns |
198 |
|
|
(ExpandedURI q<ddoct:>, 'ddoct:basePath', '../' x ($path =~ tr#/#/#)); |
199 |
wakaba |
1.2 |
$pl_full_name =~ s/.*:://g; |
200 |
|
|
$section->perl_name ($pl_full_name); |
201 |
wakaba |
1.1 |
} |
202 |
|
|
|
203 |
|
|
$section->resource_file_name_stem ($opt{source_resource}->pl_file_name_stem); |
204 |
|
|
|
205 |
|
|
append_description (source_resource => $opt{source_resource}, |
206 |
|
|
result_parent => $section); |
207 |
|
|
|
208 |
wakaba |
1.2 |
if ($opt{is_partial}) { |
209 |
|
|
$section->resource_is_partial (1); |
210 |
|
|
return; |
211 |
|
|
} |
212 |
|
|
|
213 |
wakaba |
1.1 |
for my $rres (@{$opt{source_resource}->get_property_resource_list |
214 |
|
|
(ExpandedURI q<DIS:resource>)}) { |
215 |
|
|
if ($rres->owner_module eq $opt{source_resource}) { ## Defined in this module |
216 |
|
|
## TODO: Modification required to support modplans |
217 |
wakaba |
1.2 |
status_msg_ "*"; |
218 |
wakaba |
1.1 |
if ($rres->is_type_uri (ExpandedURI q<ManakaiDOM:Class>)) { |
219 |
|
|
append_class_documentation |
220 |
|
|
(result_parent => $section, |
221 |
|
|
source_resource => $rres); |
222 |
|
|
} elsif ($rres->is_type_uri (ExpandedURI q<ManakaiDOM:IF>)) { |
223 |
|
|
append_interface_documentation |
224 |
|
|
(result_parent => $section, |
225 |
|
|
source_resource => $rres); |
226 |
wakaba |
1.3 |
} elsif ($rres->is_type_uri (ExpandedURI q<DISCore:AbstractDataType>)) { |
227 |
|
|
append_datatype_documentation |
228 |
|
|
(result_parent => $section, |
229 |
|
|
source_resource => $rres); |
230 |
wakaba |
1.1 |
} |
231 |
|
|
} else { ## Aliases |
232 |
|
|
# |
233 |
|
|
} |
234 |
|
|
} |
235 |
wakaba |
1.2 |
status_msg ""; |
236 |
wakaba |
1.1 |
} # append_module_documentation |
237 |
|
|
|
238 |
wakaba |
1.3 |
sub append_datatype_documentation (%) { |
239 |
|
|
my %opt = @_; |
240 |
|
|
my $section = $opt{result_parent}->create_data_type |
241 |
|
|
($opt{source_resource}->uri); |
242 |
|
|
|
243 |
|
|
add_uri ($opt{source_resource} => $section); |
244 |
|
|
|
245 |
|
|
my $uri = $opt{source_resource}->name_uri || |
246 |
|
|
$opt{source_resource}->uri; |
247 |
|
|
my @file = map {s/[^\w]/_/g; $_} split m{[/:#?]+}, $uri; |
248 |
|
|
|
249 |
|
|
$section->resource_file_name_stem ($file[-1]); |
250 |
|
|
$section->resource_file_path_stem (join '/', @file); |
251 |
|
|
|
252 |
|
|
my $docr = $opt{source_resource}->get_feature (ExpandedURI q<DIS:Doc>, '2.0'); |
253 |
|
|
my $label = $docr->get_label ($section->owner_document); |
254 |
|
|
if ($label) { |
255 |
|
|
$section->create_label->append_child (transform_disdoc_tree ($label)); |
256 |
|
|
} |
257 |
|
|
|
258 |
|
|
append_description (source_resource => $opt{source_resource}, |
259 |
|
|
result_parent => $section); |
260 |
|
|
|
261 |
|
|
if ($opt{is_partial}) { |
262 |
|
|
$section->resource_is_partial (1); |
263 |
|
|
return; |
264 |
|
|
} |
265 |
|
|
|
266 |
|
|
## Inheritance |
267 |
|
|
append_inheritance (source_resource => $opt{source_resource}, |
268 |
|
|
result_parent => $section); |
269 |
|
|
} # append_datatype_documentation |
270 |
|
|
|
271 |
wakaba |
1.1 |
sub append_interface_documentation (%) { |
272 |
|
|
my %opt = @_; |
273 |
|
|
my $section = $opt{result_parent}->create_interface |
274 |
|
|
($opt{source_resource}->uri); |
275 |
wakaba |
1.2 |
|
276 |
|
|
add_uri ($opt{source_resource} => $section); |
277 |
wakaba |
1.1 |
|
278 |
|
|
my $pl_full_name = $opt{source_resource}->pl_fully_qualified_name; |
279 |
|
|
if (defined $pl_full_name) { |
280 |
|
|
$section->perl_package_name ($pl_full_name); |
281 |
|
|
my $path = $pl_full_name; |
282 |
|
|
$path =~ s#::#/#g; |
283 |
|
|
$section->resource_file_path_stem ($path); |
284 |
|
|
$section->set_attribute_ns |
285 |
|
|
(ExpandedURI q<ddoct:>, 'ddoct:basePath', |
286 |
|
|
join '', '../' x ($path =~ tr#/#/#)); |
287 |
wakaba |
1.2 |
$pl_full_name =~ s/.*:://g; |
288 |
|
|
$section->perl_name ($pl_full_name); |
289 |
wakaba |
1.1 |
} |
290 |
|
|
|
291 |
|
|
$section->resource_file_name_stem ($opt{source_resource}->pl_file_name_stem); |
292 |
|
|
|
293 |
|
|
$section->is_exception_interface (1) |
294 |
|
|
if $opt{source_resource}->is_type_uri |
295 |
|
|
(ExpandedURI q<ManakaiDOM:ExceptionIF>); |
296 |
|
|
|
297 |
|
|
append_description (source_resource => $opt{source_resource}, |
298 |
|
|
result_parent => $section); |
299 |
|
|
|
300 |
wakaba |
1.2 |
if ($opt{is_partial}) { |
301 |
|
|
$section->resource_is_partial (1); |
302 |
|
|
return; |
303 |
|
|
} |
304 |
|
|
|
305 |
wakaba |
1.1 |
## Inheritance |
306 |
|
|
append_inheritance (source_resource => $opt{source_resource}, |
307 |
|
|
result_parent => $section); |
308 |
|
|
|
309 |
|
|
for my $memres (@{$opt{source_resource}->get_property_resource_list |
310 |
|
|
(ExpandedURI q<DIS:childResource>)}) { |
311 |
|
|
if ($memres->is_type_uri (ExpandedURI q<DISLang:Method>)) { |
312 |
|
|
append_method_documentation (source_resource => $memres, |
313 |
|
|
result_parent => $section); |
314 |
|
|
} elsif ($memres->is_type_uri (ExpandedURI q<DISLang:Attribute>)) { |
315 |
|
|
append_attr_documentation (source_resource => $memres, |
316 |
|
|
result_parent => $section); |
317 |
|
|
} elsif ($memres->is_type_uri (ExpandedURI q<ManakaiDOM:ConstGroup>)) { |
318 |
wakaba |
1.3 |
append_constgroup_documentation (source_resource => $memres, |
319 |
|
|
result_parent => $section); |
320 |
wakaba |
1.1 |
} |
321 |
|
|
} |
322 |
|
|
} # append_interface_documentation |
323 |
|
|
|
324 |
|
|
sub append_class_documentation (%) { |
325 |
|
|
my %opt = @_; |
326 |
|
|
my $section = $opt{result_parent}->create_class ($opt{source_resource}->uri); |
327 |
wakaba |
1.2 |
|
328 |
|
|
add_uri ($opt{source_resource} => $section); |
329 |
wakaba |
1.1 |
|
330 |
|
|
my $pl_full_name = $opt{source_resource}->pl_fully_qualified_name; |
331 |
|
|
if (defined $pl_full_name) { |
332 |
|
|
$section->perl_package_name ($pl_full_name); |
333 |
|
|
my $path = $pl_full_name; |
334 |
|
|
$path =~ s#::#/#g; |
335 |
|
|
$section->resource_file_path_stem ($path); |
336 |
|
|
$section->set_attribute_ns |
337 |
|
|
(ExpandedURI q<ddoct:>, 'ddoct:basePath', '../' x ($path =~ tr#/#/#)); |
338 |
wakaba |
1.2 |
$pl_full_name =~ s/.*:://g; |
339 |
|
|
$section->perl_name ($pl_full_name); |
340 |
wakaba |
1.1 |
} |
341 |
|
|
|
342 |
|
|
$section->resource_file_name_stem ($opt{source_resource}->pl_file_name_stem); |
343 |
|
|
|
344 |
|
|
append_description (source_resource => $opt{source_resource}, |
345 |
|
|
result_parent => $section); |
346 |
|
|
|
347 |
wakaba |
1.2 |
if ($opt{is_partial}) { |
348 |
|
|
$section->resource_is_partial (1); |
349 |
|
|
return; |
350 |
|
|
} |
351 |
|
|
|
352 |
wakaba |
1.1 |
## Inheritance |
353 |
|
|
append_inheritance (source_resource => $opt{source_resource}, |
354 |
|
|
result_parent => $section, |
355 |
|
|
append_implements => 1); |
356 |
|
|
|
357 |
|
|
for my $memres (@{$opt{source_resource}->get_property_resource_list |
358 |
|
|
(ExpandedURI q<DIS:childResource>)}) { |
359 |
|
|
if ($memres->is_type_uri (ExpandedURI q<DISLang:Method>)) { |
360 |
|
|
append_method_documentation (source_resource => $memres, |
361 |
|
|
result_parent => $section); |
362 |
|
|
} elsif ($memres->is_type_uri (ExpandedURI q<DISLang:Attribute>)) { |
363 |
|
|
append_attr_documentation (source_resource => $memres, |
364 |
|
|
result_parent => $section); |
365 |
|
|
} elsif ($memres->is_type_uri (ExpandedURI q<ManakaiDOM:ConstGroup>)) { |
366 |
wakaba |
1.3 |
append_constgroup_documentation |
367 |
|
|
(source_resource => $memres, |
368 |
|
|
result_parent => $section); |
369 |
wakaba |
1.1 |
} |
370 |
|
|
} |
371 |
|
|
} # append_class_documentation |
372 |
|
|
|
373 |
|
|
sub append_method_documentation (%) { |
374 |
|
|
my %opt = @_; |
375 |
|
|
my $perl_name = $opt{source_resource}->pl_name; |
376 |
|
|
my $m; |
377 |
|
|
if (defined $perl_name) { |
378 |
|
|
$m = $opt{result_parent}->create_method ($perl_name); |
379 |
|
|
|
380 |
|
|
} else { ## Anonymous |
381 |
|
|
## TODO |
382 |
|
|
return; |
383 |
|
|
} |
384 |
wakaba |
1.2 |
|
385 |
|
|
add_uri ($opt{source_resource} => $m); |
386 |
wakaba |
1.1 |
|
387 |
|
|
append_description (source_resource => $opt{source_resource}, |
388 |
|
|
result_parent => $m); |
389 |
|
|
|
390 |
|
|
my $ret = $opt{source_resource}->get_child_resource_by_type |
391 |
|
|
(ExpandedURI q<DISLang:MethodReturn>); |
392 |
|
|
if ($ret) { |
393 |
|
|
my $r = $m->dis_return; |
394 |
|
|
|
395 |
|
|
try { |
396 |
wakaba |
1.2 |
$r->resource_data_type (my $u = $ret->dis_data_type_resource->uri); |
397 |
|
|
$ReferredResource{$u} ||= 1; |
398 |
|
|
$r->resource_actual_data_type |
399 |
|
|
($u = $ret->dis_actual_data_type_resource->uri); |
400 |
|
|
$ReferredResource{$u} ||= 1; |
401 |
|
|
|
402 |
wakaba |
1.1 |
append_description (source_resource => $ret, |
403 |
|
|
result_parent => $r, |
404 |
|
|
has_case => 1); |
405 |
|
|
|
406 |
|
|
## TODO: Exceptions |
407 |
|
|
} catch Message::Util::DIS::ManakaiDISException with { |
408 |
|
|
|
409 |
|
|
}; |
410 |
|
|
} |
411 |
|
|
|
412 |
|
|
for my $cr (@{$opt{source_resource}->get_property_resource_list |
413 |
|
|
(ExpandedURI q<DIS:childResource>)}) { |
414 |
|
|
if ($cr->is_type_uri (ExpandedURI q<DISLang:MethodParameter>)) { |
415 |
|
|
append_param_documentation (source_resource => $cr, |
416 |
|
|
result_parent => $m); |
417 |
|
|
} |
418 |
|
|
} |
419 |
|
|
|
420 |
|
|
## TODO: raises |
421 |
|
|
|
422 |
|
|
$m->resource_access ('private') |
423 |
|
|
if $opt{source_resource}->get_property_boolean |
424 |
|
|
(ExpandedURI q<ManakaiDOM:isForInternal>, 0); |
425 |
|
|
} # append_method_documentation |
426 |
|
|
|
427 |
|
|
sub append_attr_documentation (%) { |
428 |
|
|
my %opt = @_; |
429 |
|
|
my $perl_name = $opt{source_resource}->pl_name; |
430 |
|
|
my $m; |
431 |
|
|
if (defined $perl_name) { |
432 |
|
|
$m = $opt{result_parent}->create_attribute ($perl_name); |
433 |
|
|
|
434 |
|
|
} else { ## Anonymous |
435 |
|
|
## TODO |
436 |
|
|
return; |
437 |
|
|
} |
438 |
wakaba |
1.2 |
|
439 |
|
|
add_uri ($opt{source_resource} => $m); |
440 |
wakaba |
1.1 |
|
441 |
|
|
append_description (source_resource => $opt{source_resource}, |
442 |
|
|
result_parent => $m, |
443 |
|
|
has_case => 1); |
444 |
|
|
|
445 |
|
|
my $ret = $opt{source_resource}->get_child_resource_by_type |
446 |
|
|
(ExpandedURI q<DISLang:AttributeGet>); |
447 |
|
|
if ($ret) { |
448 |
|
|
my $r = $m->dis_get; |
449 |
|
|
|
450 |
wakaba |
1.2 |
$r->resource_data_type (my $u = $ret->dis_data_type_resource->uri); |
451 |
|
|
$ReferredResource{$u} ||= 1; |
452 |
|
|
$r->resource_actual_data_type |
453 |
|
|
($u = $ret->dis_actual_data_type_resource->uri); |
454 |
|
|
$ReferredResource{$u} ||= 1; |
455 |
|
|
|
456 |
wakaba |
1.1 |
append_description (source_resource => $ret, |
457 |
|
|
result_parent => $r, |
458 |
|
|
has_case => 1); |
459 |
|
|
|
460 |
|
|
## TODO: Exceptions |
461 |
|
|
} |
462 |
|
|
|
463 |
|
|
my $set = $opt{source_resource}->get_child_resource_by_type |
464 |
|
|
(ExpandedURI q<DISLang:AttributeSet>); |
465 |
|
|
if ($set) { |
466 |
|
|
my $r = $m->dis_set; |
467 |
|
|
|
468 |
wakaba |
1.2 |
$r->resource_data_type (my $u = $set->dis_data_type_resource->uri); |
469 |
|
|
$ReferredResource{$u} ||= 1; |
470 |
wakaba |
1.1 |
$r->resource_actual_data_type ($set->dis_actual_data_type_resource->uri); |
471 |
wakaba |
1.2 |
$ReferredResource{$u} ||= 1; |
472 |
wakaba |
1.1 |
|
473 |
|
|
append_description (source_resource => $set, |
474 |
|
|
result_parent => $r, |
475 |
|
|
has_case => 1); |
476 |
|
|
|
477 |
|
|
## TODO: InCase, Exceptions |
478 |
|
|
} else { |
479 |
|
|
$m->is_read_only_attribute (1); |
480 |
|
|
} |
481 |
|
|
|
482 |
|
|
$m->resource_access ('private') |
483 |
|
|
if $opt{source_resource}->get_property_boolean |
484 |
|
|
(ExpandedURI q<ManakaiDOM:isForInternal>, 0); |
485 |
|
|
} # append_attr_documentation |
486 |
|
|
|
487 |
wakaba |
1.3 |
sub append_constgroup_documentation (%) { |
488 |
|
|
my %opt = @_; |
489 |
|
|
my $perl_name = $opt{source_resource}->pl_name; |
490 |
|
|
my $m = $opt{result_parent}->create_const_group ($perl_name); |
491 |
|
|
|
492 |
|
|
add_uri ($opt{source_resource} => $m); |
493 |
|
|
|
494 |
|
|
append_description (source_resource => $opt{source_resource}, |
495 |
|
|
result_parent => $m); |
496 |
|
|
|
497 |
|
|
$m->resource_data_type |
498 |
|
|
(my $u = $opt{source_resource}->dis_data_type_resource->uri); |
499 |
|
|
$ReferredResource{$u} ||= 1; |
500 |
|
|
$m->resource_actual_data_type |
501 |
|
|
($u = $opt{source_resource}->dis_actual_data_type_resource->uri); |
502 |
|
|
$ReferredResource{$u} ||= 1; |
503 |
|
|
|
504 |
|
|
|
505 |
|
|
for my $cr (@{$opt{source_resource}->get_property_resource_list |
506 |
|
|
(ExpandedURI q<DIS:childResource>)}) { |
507 |
|
|
if ($cr->is_type_uri (ExpandedURI q<ManakaiDOM:Const>)) { |
508 |
|
|
append_const_documentation (source_resource => $cr, |
509 |
|
|
result_parent => $m); |
510 |
|
|
} |
511 |
|
|
} |
512 |
|
|
} # append_constgroup_documentation |
513 |
|
|
|
514 |
|
|
sub append_const_documentation (%) { |
515 |
|
|
my %opt = @_; |
516 |
|
|
my $perl_name = $opt{source_resource}->pl_name; |
517 |
|
|
my $m = $opt{result_parent}->create_const ($perl_name); |
518 |
|
|
|
519 |
|
|
add_uri ($opt{source_resource} => $m); |
520 |
|
|
|
521 |
|
|
append_description (source_resource => $opt{source_resource}, |
522 |
|
|
result_parent => $m); |
523 |
|
|
|
524 |
|
|
$m->resource_data_type |
525 |
|
|
(my $u = $opt{source_resource}->dis_data_type_resource->uri); |
526 |
|
|
$ReferredResource{$u} ||= 1; |
527 |
|
|
$m->resource_actual_data_type |
528 |
|
|
($u = $opt{source_resource}->dis_actual_data_type_resource->uri); |
529 |
|
|
$ReferredResource{$u} ||= 1; |
530 |
|
|
|
531 |
|
|
my $value = $opt{source_resource}->pl_code_fragment; |
532 |
|
|
if ($value) { |
533 |
|
|
$m->create_value->text_content ($value->stringify); |
534 |
|
|
} |
535 |
|
|
|
536 |
|
|
for my $cr (@{$opt{source_resource}->get_property_resource_list |
537 |
|
|
(ExpandedURI q<DIS:childResource>)}) { |
538 |
|
|
if ($cr->is_type_uri (ExpandedURI q<ManakaiDOM:ExceptionOrWarningSubType>)) { |
539 |
|
|
append_xsubtype_documentation (source_resource => $cr, |
540 |
|
|
result_parent => $m); |
541 |
|
|
} |
542 |
|
|
} |
543 |
|
|
## TODO: xparam |
544 |
|
|
} # append_const_documentation |
545 |
|
|
|
546 |
|
|
sub append_xsubtype_documentation (%) { |
547 |
|
|
my %opt = @_; |
548 |
|
|
my $m = $opt{result_parent}->create_exception_sub_code |
549 |
|
|
($opt{source_resource}->uri); |
550 |
|
|
add_uri ($opt{source_resource} => $m); |
551 |
|
|
|
552 |
|
|
append_description (source_resource => $opt{source_resource}, |
553 |
|
|
result_parent => $m); |
554 |
|
|
|
555 |
|
|
## TODO: xparam |
556 |
|
|
} # append_xsubtype_documentation |
557 |
|
|
|
558 |
wakaba |
1.1 |
sub append_param_documentation (%) { |
559 |
|
|
my %opt = @_; |
560 |
|
|
|
561 |
|
|
my $is_named_param = $opt{source_resource}->get_property_boolean |
562 |
|
|
(ExpandedURI q<DISPerl:isNamedParameter>, 0); |
563 |
|
|
|
564 |
|
|
my $perl_name = $is_named_param |
565 |
|
|
? $opt{source_resource}->pl_name |
566 |
|
|
: $opt{source_resource}->pl_variable_name; |
567 |
|
|
|
568 |
|
|
my $p = $opt{result_parent}->create_parameter ($perl_name, $is_named_param); |
569 |
|
|
|
570 |
wakaba |
1.2 |
add_uri ($opt{source_resource} => $p); |
571 |
|
|
|
572 |
wakaba |
1.1 |
$p->is_nullable_parameter ($opt{source_resource}->pl_is_nullable); |
573 |
wakaba |
1.2 |
$p->resource_data_type |
574 |
|
|
(my $u = $opt{source_resource}->dis_data_type_resource->uri); |
575 |
|
|
$ReferredResource{$u} ||= 1; |
576 |
wakaba |
1.1 |
$p->resource_actual_data_type |
577 |
wakaba |
1.2 |
($u = $opt{source_resource}->dis_actual_data_type_resource->uri); |
578 |
|
|
$ReferredResource{$u} ||= 1; |
579 |
wakaba |
1.1 |
|
580 |
|
|
append_description (source_resource => $opt{source_resource}, |
581 |
|
|
result_parent => $p, |
582 |
|
|
has_case => 1); |
583 |
|
|
} # append_param_documentation |
584 |
|
|
|
585 |
|
|
sub append_description (%) { |
586 |
|
|
my %opt = @_; |
587 |
wakaba |
1.2 |
|
588 |
wakaba |
1.1 |
my $od = $opt{result_parent}->owner_document; |
589 |
|
|
my $resd = $opt{source_resource}->get_feature (ExpandedURI q<DIS:Doc>, '2.0'); |
590 |
wakaba |
1.3 |
my $doc = transform_disdoc_tree ($resd->get_description ($od)); |
591 |
wakaba |
1.1 |
$opt{result_parent}->create_description->append_child ($doc); |
592 |
|
|
## TODO: Negotiation |
593 |
|
|
|
594 |
wakaba |
1.3 |
my $fn = $resd->get_full_name ($od); |
595 |
|
|
if ($fn) { |
596 |
|
|
$opt{result_parent}->create_full_name |
597 |
|
|
->append_child (transform_disdoc_tree ($fn)); |
598 |
|
|
} |
599 |
|
|
|
600 |
wakaba |
1.1 |
if ($opt{has_case}) { |
601 |
|
|
for my $caser (@{$opt{source_resource}->get_property_resource_list |
602 |
|
|
(ExpandedURI q<DIS:childResource>)}) { |
603 |
|
|
if ($caser->is_type_uri (ExpandedURI q<ManakaiDOM:InCase>)) { |
604 |
|
|
my $case = $opt{result_parent}->append_case; |
605 |
|
|
my $cased = $caser->get_feature (ExpandedURI q<DIS:Doc>, '2.0'); |
606 |
|
|
my $label = $cased->get_label ($od); |
607 |
|
|
if ($label) { |
608 |
wakaba |
1.3 |
$case->create_label->append_child (transform_disdoc_tree ($label)); |
609 |
wakaba |
1.1 |
} |
610 |
|
|
my $value = $caser->pl_code_fragment; |
611 |
|
|
if ($value) { |
612 |
|
|
$case->create_value->text_content ($value->stringify); |
613 |
|
|
} |
614 |
wakaba |
1.3 |
$case->resource_data_type |
615 |
|
|
(my $u = $caser->dis_data_type_resource->uri); |
616 |
|
|
$ReferredResource{$u} ||= 1; |
617 |
|
|
$case->resource_actual_data_type |
618 |
|
|
($u = $caser->dis_actual_data_type_resource->uri); |
619 |
|
|
$ReferredResource{$u} ||= 1; |
620 |
|
|
|
621 |
wakaba |
1.1 |
append_description (source_resource => $caser, |
622 |
|
|
result_parent => $case); |
623 |
|
|
} |
624 |
|
|
} |
625 |
|
|
} |
626 |
|
|
} # append_description |
627 |
|
|
|
628 |
wakaba |
1.3 |
sub transform_disdoc_tree ($;%) { |
629 |
|
|
my ($el, %opt) = @_; |
630 |
|
|
my @el = ($el); |
631 |
|
|
EL: while (defined (my $el = shift @el)) { |
632 |
|
|
if ($el->node_type == $el->ELEMENT_NODE and |
633 |
|
|
defined $el->namespace_uri) { |
634 |
|
|
my $mmParsed = $el->get_attribute_ns (ExpandedURI q<ddel:>, 'mmParsed'); |
635 |
|
|
if ($mmParsed) { |
636 |
|
|
my $lextype = $el->get_attribute_ns (ExpandedURI q<ddel:>, 'lexType'); |
637 |
|
|
if ($lextype eq ExpandedURI q<dis:TFQNames>) { |
638 |
|
|
my $turi = dd_get_qname_uri ($el->get_elements_by_tag_name_ns |
639 |
|
|
(ExpandedURI q<ddel:>, 'nameQName')->[0]); |
640 |
|
|
my $furi = dd_get_qname_uri ($el->get_elements_by_tag_name_ns |
641 |
|
|
(ExpandedURI q<ddel:>, 'forQName')->[0]); |
642 |
|
|
my $uri = tfuris2uri ($turi, $furi); |
643 |
|
|
$el->set_attribute_ns (ExpandedURI q<dump:>, 'dump:uri', $uri); |
644 |
|
|
$ReferredResource{$uri} ||= 1; |
645 |
|
|
next EL; |
646 |
|
|
} |
647 |
|
|
} |
648 |
|
|
push @el, children_of ($el); |
649 |
|
|
} elsif ($el->node_type == $el->DOCUMENT_FRAGMENT_NODE or |
650 |
|
|
$el->node_type == $el->DOCUMENT_NODE) { |
651 |
|
|
push @el, children_of ($el); |
652 |
|
|
} |
653 |
|
|
} # EL |
654 |
|
|
$el; |
655 |
|
|
} # transform_disdoc_tree |
656 |
|
|
|
657 |
|
|
sub children_of ($) { |
658 |
|
|
my $cn = $_[0]->child_nodes; |
659 |
|
|
my $len = $cn->length; |
660 |
|
|
my @r; |
661 |
|
|
for (my $i = 0; $i < $len; $i++) { |
662 |
|
|
push @r, my $l = $cn->item ($i); |
663 |
|
|
} |
664 |
|
|
@r; |
665 |
|
|
} |
666 |
|
|
|
667 |
|
|
sub dd_get_qname_uri ($;%) { |
668 |
|
|
my ($el, %opt) = @_; |
669 |
|
|
return '' unless $el; |
670 |
|
|
my $plel = $el->get_elements_by_tag_name_ns |
671 |
|
|
(ExpandedURI q<ddel:>, 'prefix')->[0]; |
672 |
|
|
my $lnel = $el->get_elements_by_tag_name_ns |
673 |
|
|
(ExpandedURI q<ddel:>, 'localName')->[0]; |
674 |
|
|
my $nsuri = ($plel ? $plel : $el)->lookup_namespace_uri |
675 |
|
|
($plel ? $plel->text_content : undef); |
676 |
|
|
$nsuri = '' unless defined $nsuri; |
677 |
|
|
if ($plel and $nsuri eq '') { |
678 |
|
|
$plel->remove_attribute_ns |
679 |
|
|
(ExpandedURI q<xmlns:>, 'xmlns:'.$plel->text_content); |
680 |
|
|
} |
681 |
|
|
$el->set_attribute_ns (ExpandedURI q<dump:>, 'dump:namespaceURI', $nsuri); |
682 |
|
|
if ($lnel) { |
683 |
|
|
$nsuri . $lnel->text_content; |
684 |
|
|
} else { |
685 |
|
|
$el->get_attribute_ns (ExpandedURI q<ddel:>, 'defaultURI'); |
686 |
|
|
} |
687 |
|
|
} # dd_get_qname_uri |
688 |
|
|
|
689 |
|
|
sub tfuris2uri ($$) { |
690 |
|
|
my ($turi, $furi) = @_; |
691 |
|
|
my $uri; |
692 |
|
|
if ($furi eq <Q::ManakaiDOM:all>) { |
693 |
|
|
$uri = $turi; |
694 |
|
|
} else { |
695 |
|
|
my $__turi = $turi; |
696 |
|
|
my $__furi = $furi; |
697 |
|
|
for my $__uri ($__turi, $__furi) { |
698 |
|
|
$__uri =~ s{([^0-9A-Za-z:;?=_./-])}{sprintf '%%%02X', ord $1}ge; |
699 |
|
|
} |
700 |
|
|
$uri = qq<data:,200411tf#xmlns(t=data:,200411tf%23)>. |
701 |
|
|
qq<t:tf($__turi,$__furi)>; |
702 |
|
|
} |
703 |
|
|
$uri; |
704 |
|
|
} # tfuris2uri |
705 |
|
|
|
706 |
wakaba |
1.1 |
sub append_inheritance (%) { |
707 |
|
|
my %opt = @_; |
708 |
|
|
if (($opt{depth} ||= 0) == 100) { |
709 |
|
|
warn "<".$opt{source_resource}->uri.">: Loop in inheritance"; |
710 |
|
|
return; |
711 |
|
|
} |
712 |
|
|
|
713 |
|
|
for my $isa (@{$opt{source_resource}->get_property_resource_list |
714 |
|
|
(ExpandedURI q<dis:ISA>, |
715 |
|
|
default_media_type => ExpandedURI q<dis:TFQNames>)}) { |
716 |
|
|
append_inheritance |
717 |
|
|
(source_resource => $isa, |
718 |
|
|
result_parent => $opt{result_parent}->append_new_extends ($isa->uri), |
719 |
|
|
depth => $opt{depth} + 1); |
720 |
wakaba |
1.2 |
$ReferredResource{$isa->uri} ||= 1; |
721 |
wakaba |
1.1 |
} |
722 |
|
|
|
723 |
|
|
if ($opt{append_implements}) { |
724 |
|
|
for my $impl (@{$opt{source_resource}->get_property_resource_list |
725 |
|
|
(ExpandedURI q<dis:Implement>, |
726 |
|
|
default_media_type => ExpandedURI q<dis:TFQNames>, |
727 |
|
|
recursive_isa => 1)}) { |
728 |
|
|
append_inheritance |
729 |
|
|
(source_resource => $impl, |
730 |
|
|
result_parent => $opt{result_parent}->append_new_implements |
731 |
|
|
($impl->uri), |
732 |
|
|
depth => $opt{depth}); |
733 |
wakaba |
1.2 |
$ReferredResource{$impl->uri} ||= 1; |
734 |
wakaba |
1.1 |
} |
735 |
|
|
} |
736 |
|
|
} # append_inheritance |
737 |
|
|
|
738 |
wakaba |
1.2 |
sub add_uri ($$;%) { |
739 |
|
|
my ($res, $el, %opt) = @_; |
740 |
|
|
my $canon_uri = $res->uri; |
741 |
|
|
for my $uri (@{$res->uris}) { |
742 |
|
|
$el->add_uri ($uri, $canon_uri eq $uri ? 0 : 1); |
743 |
|
|
$ReferredResource{$uri} = -1; |
744 |
|
|
} |
745 |
wakaba |
1.3 |
|
746 |
|
|
my $nsuri = $res->namespace_uri; |
747 |
|
|
$el->resource_namespace_uri ($nsuri) if defined $nsuri; |
748 |
|
|
my $lname = $res->local_name; |
749 |
|
|
$el->resource_local_name ($lname) if defined $lname; |
750 |
wakaba |
1.2 |
} # add_uri |
751 |
|
|
|
752 |
wakaba |
1.1 |
my $doc = $impl->create_disdump_document; |
753 |
|
|
|
754 |
|
|
my $body = $doc->document_element; |
755 |
|
|
|
756 |
|
|
append_module_documentation |
757 |
|
|
(result_parent => $body, |
758 |
|
|
source_resource => $mod); |
759 |
|
|
|
760 |
wakaba |
1.2 |
|
761 |
|
|
while (my @ruri = grep {$ReferredResource{$_} > 0} keys %ReferredResource) { |
762 |
|
|
U: while (defined (my $uri = shift @ruri)) { |
763 |
|
|
next U if $ReferredResource{$uri} < 0; ## Already done |
764 |
|
|
my $res = $db->get_resource ($uri); |
765 |
|
|
unless ($res->is_defined) { |
766 |
|
|
$res = $db->get_module ($uri); |
767 |
|
|
unless ($res->is_defined) { |
768 |
|
|
$ReferredResource{$uri} = -1; |
769 |
|
|
next U; |
770 |
|
|
} |
771 |
|
|
append_module_documentation |
772 |
|
|
(result_parent => $body, |
773 |
|
|
source_resource => $res, |
774 |
|
|
is_partial => 1); |
775 |
|
|
} elsif ($res->is_type_uri (ExpandedURI q<ManakaiDOM:Class>)) { |
776 |
|
|
my $mod = $res->owner_module; |
777 |
|
|
unless ($ReferredResource{$mod->uri} < 0) { |
778 |
|
|
unshift @ruri, $uri; |
779 |
|
|
unshift @ruri, $mod->uri; |
780 |
|
|
next U; |
781 |
|
|
} |
782 |
|
|
append_class_documentation |
783 |
|
|
(result_parent => $body->create_module ($mod->uri), |
784 |
|
|
source_resource => $res, |
785 |
|
|
is_partial => 1); |
786 |
|
|
} elsif ($res->is_type_uri (ExpandedURI q<ManakaiDOM:IF>)) { |
787 |
|
|
my $mod = $res->owner_module; |
788 |
|
|
unless ($mod->is_defined) { |
789 |
|
|
$ReferredResource{$uri} = -1; |
790 |
|
|
next U; |
791 |
|
|
} elsif (not ($ReferredResource{$mod->uri} < 0)) { |
792 |
|
|
unshift @ruri, $uri; |
793 |
|
|
unshift @ruri, $mod->uri; |
794 |
|
|
next U; |
795 |
|
|
} |
796 |
|
|
append_interface_documentation |
797 |
|
|
(result_parent => $body->create_module ($mod->uri), |
798 |
|
|
source_resource => $res, |
799 |
|
|
is_partial => 1); |
800 |
wakaba |
1.3 |
} elsif ($res->is_type_uri (ExpandedURI q<DISCore:AbstractDataType>)) { |
801 |
|
|
my $mod = $res->owner_module; |
802 |
|
|
unless ($mod->is_defined) { |
803 |
|
|
$ReferredResource{$uri} = -1; |
804 |
|
|
next U; |
805 |
|
|
} elsif (not ($ReferredResource{$mod->uri} < 0)) { |
806 |
|
|
unshift @ruri, $uri; |
807 |
|
|
unshift @ruri, $mod->uri; |
808 |
|
|
next U; |
809 |
|
|
} |
810 |
|
|
append_datatype_documentation |
811 |
|
|
(result_parent => $body->create_module ($mod->uri), |
812 |
|
|
source_resource => $res); |
813 |
|
|
} elsif ($res->is_type_uri (ExpandedURI q<DISLang:AnyMethod>) or |
814 |
|
|
$res->is_type_uri (ExpandedURI q<ManakaiDOM:ConstGroup>)) { |
815 |
wakaba |
1.2 |
my $cls = $res->get_property_resource |
816 |
|
|
(ExpandedURI q<dis2pm:parentResource>); |
817 |
|
|
if (not ($ReferredResource{$cls->uri} < 0) and |
818 |
|
|
($cls->is_type_uri (ExpandedURI q<ManakaiDOM:Class>) or |
819 |
|
|
$cls->is_type_uri (ExpandedURI q<ManakaiDOM:IF>))) { |
820 |
|
|
unshift @ruri, $uri; |
821 |
|
|
unshift @ruri, $cls->uri; |
822 |
|
|
next U; |
823 |
|
|
} |
824 |
|
|
my $model = $body->create_module ($cls->owner_module->uri); |
825 |
|
|
my $clsel = $cls->is_type_uri (ExpandedURI q<ManakaiDOM:Class>) |
826 |
|
|
? $model->create_class ($cls->uri) |
827 |
|
|
: $model->create_interface ($cls->uri); |
828 |
|
|
if ($res->is_type_uri (ExpandedURI q<DISLang:Method>)) { |
829 |
|
|
append_method_documentation |
830 |
|
|
(result_parent => $clsel, |
831 |
|
|
source_resource => $res); |
832 |
wakaba |
1.3 |
} elsif ($res->is_type_uri (ExpandedURI q<DISLang:Attribute>)) { |
833 |
wakaba |
1.2 |
append_attr_documentation |
834 |
wakaba |
1.3 |
(result_parent => $clsel, |
835 |
|
|
source_resource => $res); |
836 |
|
|
} elsif ($res->is_type_uri (ExpandedURI q<ManakaiDOM:ConstGroup>)) { |
837 |
|
|
append_constgroup_documentation |
838 |
|
|
(result_parent => $clsel, |
839 |
wakaba |
1.2 |
source_resource => $res); |
840 |
|
|
} |
841 |
|
|
} elsif ($res->is_type_uri (ExpandedURI q<DISLang:MethodParameter>)) { |
842 |
|
|
my $m = $res->get_property_resource |
843 |
|
|
(ExpandedURI q<dis2pm:parentResource>); |
844 |
|
|
if (not ($ReferredResource{$m->uri} < 0) and |
845 |
|
|
$m->is_type_uri (ExpandedURI q<DISLang:Method>)) { |
846 |
|
|
unshift @ruri, $m->uri; |
847 |
|
|
next U; |
848 |
|
|
} |
849 |
wakaba |
1.3 |
} elsif ($res->is_type_uri (ExpandedURI q<ManakaiDOM:Const>)) { |
850 |
|
|
my $m = $res->get_property_resource |
851 |
|
|
(ExpandedURI q<dis2pm:parentResource>); |
852 |
|
|
if (not ($ReferredResource{$m->uri} < 0) and |
853 |
|
|
$m->is_type_uri (ExpandedURI q<ManakaiDOM:ConstGroup>)) { |
854 |
|
|
unshift @ruri, $m->uri; |
855 |
|
|
next U; |
856 |
|
|
} |
857 |
|
|
} elsif ($res->is_type_uri |
858 |
|
|
(ExpandedURI q<ManakaiDOM:ExceptionOrWarningSubType>)) { |
859 |
|
|
my $m = $res->get_property_resource |
860 |
|
|
(ExpandedURI q<dis2pm:parentResource>); |
861 |
|
|
if (not ($ReferredResource{$m->uri} < 0) and |
862 |
|
|
$m->is_type_uri (ExpandedURI q<ManakaiDOM:Const>)) { |
863 |
|
|
unshift @ruri, $m->uri; |
864 |
|
|
next U; |
865 |
|
|
} |
866 |
wakaba |
1.2 |
} else { ## Unsupported type |
867 |
|
|
$ReferredResource{$uri} = -1; |
868 |
|
|
} |
869 |
|
|
} # U |
870 |
|
|
} |
871 |
|
|
|
872 |
wakaba |
1.1 |
my $lsimpl = $impl->get_feature (ExpandedURI q<DOMLS:LS> => '3.0'); |
873 |
|
|
|
874 |
|
|
status_msg_ qq<Writing file ""...>; |
875 |
|
|
|
876 |
|
|
use Encode; |
877 |
|
|
my $serializer = $lsimpl->create_mls_serializer |
878 |
|
|
({ExpandedURI q<DOMLS:SerializeDocumentInstance> => ''}); |
879 |
|
|
print Encode::encode ('utf8', $serializer->write_to_string ($doc)); |
880 |
|
|
|
881 |
|
|
status_msg qq<done>; |
882 |
|
|
|
883 |
|
|
verbose_msg_ qq<Checking undefined resources...>; |
884 |
|
|
|
885 |
|
|
$db->check_undefined_resource; |
886 |
|
|
|
887 |
|
|
verbose_msg qq<done>; |
888 |
|
|
|
889 |
|
|
verbose_msg_ qq<Closing database...>; |
890 |
|
|
undef $db; |
891 |
|
|
verbose_msg qq<done>; |
892 |
|
|
|
893 |
|
|
=head1 SEE ALSO |
894 |
|
|
|
895 |
|
|
L<lib/manakai/dis.pl> and L<bin/cdis2pm.pl> - Old version of |
896 |
|
|
this script. |
897 |
|
|
|
898 |
|
|
L<lib/Message/Util/DIS.dis> - The <QUOTE::dis> object implementation. |
899 |
|
|
|
900 |
|
|
L<lib/Message/Util/PerlCode.dis> - The Perl code generator. |
901 |
|
|
|
902 |
|
|
L<lib/manakai/DISCore.dis> - The definition for the "dis" format. |
903 |
|
|
|
904 |
|
|
L<lib/manakai/DISPerl.dis> - The definition for the "dis" Perl-specific |
905 |
|
|
vocabulary. |
906 |
|
|
|
907 |
|
|
=head1 LICENSE |
908 |
|
|
|
909 |
|
|
Copyright 2004-2005 Wakaba <w@suika.fam.cx>. All rights reserved. |
910 |
|
|
|
911 |
|
|
This program is free software; you can redistribute it and/or |
912 |
|
|
modify it under the same terms as Perl itself. |
913 |
|
|
|
914 |
|
|
=cut |
915 |
|
|
|
916 |
wakaba |
1.3 |
1; # $Date: 2005/08/31 13:02:46 $ |