/[suikacvs]/messaging/manakai/bin/mkdisdump.pl
Suika

Contents of /messaging/manakai/bin/mkdisdump.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Wed Aug 31 13:02:46 2005 UTC (19 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +147 -16 lines
File MIME type: text/plain
mkdisdump.pl: Outputs referenced resources in another modules

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     ddoct => q<http://suika.fam.cx/~wakaba/archive/2005/8/disdump-xslt#>,
32     DIS => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#>,
33     dis => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis-->,
34     dis2pm => q<http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#>,
35     DISCore => q<http://suika.fam.cx/~wakaba/archive/2004/dis/Core#>,
36     DISLang => q<http://suika.fam.cx/~wakaba/archive/2004/dis/Lang#>,
37     DISPerl => q<http://suika.fam.cx/~wakaba/archive/2004/dis/Perl#>,
38     disPerl => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--Perl-->,
39     DOMCore => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#>,
40     DOMEvents => q<http://suika.fam.cx/~wakaba/archive/2004/dom/events#>,
41     DOMLS => q<http://suika.fam.cx/~wakaba/archive/2004/dom/ls#>,
42     DOMMain => q<http://suika.fam.cx/~wakaba/archive/2004/dom/main#>,
43     DOMXML => q<http://suika.fam.cx/~wakaba/archive/2004/dom/xml#>,
44     dump => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#DISDump/>,
45     DX => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#>,
46     html5 => q<http://www.w3.org/1999/xhtml>,
47     lang => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#>,
48     Perl => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl-->,
49     license => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/license#>,
50     ManakaiDOM => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#>,
51     Markup => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#>,
52     MDOMX => q<http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#>,
53     owl => q<http://www.w3.org/2002/07/owl#>,
54     pc => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/PerlCode#>,
55     rdf => q<http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
56     rdfs => q<http://www.w3.org/2000/01/rdf-schema#>,
57     swcfg21 => q<http://suika.fam.cx/~wakaba/archive/2005/swcfg21#>,
58     TreeCore => q<>,
59     Util => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/>,
60     xhtml1 => q<http://www.w3.org/1999/xhtml>,
61     xhtml2 => q<http://www.w3.org/2002/06/xhtml2>,
62     xml => q<http://www.w3.org/XML/1998/namespace>,
63     };
64    
65     =head1 OPTIONS
66    
67     =over 4
68    
69     =item --enable-assertion / --noenable-assertion (default)
70    
71     Whether assertion codes should be outputed or not.
72    
73     =item --for=I<for-uri> (Optional)
74    
75     Specifies the "For" URI reference for which the outputed module is.
76     If this parameter is ommitted, the default "For" URI reference
77     for the module, if any, or the C<ManakaiDOM:all> is assumed.
78    
79     =item --help
80    
81     Shows the help message.
82    
83     =item --module-name=I<ModuleName>
84    
85     The name of module to output. It is the local name part of
86     the C<Module> C<QName> in the source "dis" file. Either
87     C<--module-name> or C<--module-uri> is required.
88    
89     =item --module-uri=I<module-uri>
90    
91     A URI reference that identifies a module to output. Either
92     C<--module-name> or C<--module-uri> is required.
93    
94     =item --output-file-path=I<perl-module-file-path> (default: C<STDOUT>)
95    
96     A platform-dependent file name path for the output.
97     If it is not specified, then the generated Perl module
98     content is outputed to the standard output.
99    
100     =item --output-module-version (default) / --nooutput-module-version
101    
102     Whether the C<$VERSION> special variable should be generated or not.
103    
104     =item --verbose / --noverbose (default)
105    
106     Whether a verbose message mode should be selected or not.
107    
108     =back
109    
110     =cut
111    
112     use Getopt::Long;
113     use Pod::Usage;
114     use Storable;
115     use Message::Util::Error;
116     my %Opt;
117     GetOptions (
118     'for=s' => \$Opt{For},
119     'help' => \$Opt{help},
120     'module-uri=s' => \$Opt{module_uri},
121     'output-file-path=s' => \$Opt{output_file_name},
122     ) or pod2usage (2);
123     pod2usage ({-exitval => 0, -verbose => 1}) if $Opt{help};
124     $Opt{file_name} = shift;
125     pod2usage ({-exitval => 2, -verbose => 0}) unless $Opt{file_name};
126     pod2usage (2) unless $Opt{module_uri};
127    
128     sub status_msg ($) {
129     my $s = shift;
130     $s .= "\n" unless $s =~ /\n$/;
131     print STDERR $s;
132     }
133    
134     sub status_msg_ ($) {
135     my $s = shift;
136     print STDERR $s;
137     }
138    
139     sub verbose_msg ($) {
140     my $s = shift;
141     $s .= "\n" unless $s =~ /\n$/;
142     print STDERR $s;
143     }
144    
145     sub verbose_msg_ ($) {
146     my $s = shift;
147     print STDERR $s;
148     }
149    
150     my $impl = $Message::DOM::DOMImplementationRegistry->get_dom_implementation
151     ({
152     ExpandedURI q<ManakaiDOM:Minimum> => '3.0',
153     # ExpandedURI q<ManakaiDOM:HTML> => '', # 3.0
154     '+' . ExpandedURI q<DOMLS:LS> => '3.0',
155     '+' . ExpandedURI q<DIS:Doc> => '2.0',
156     ExpandedURI q<DIS:Dump> => '1.0',
157     });
158    
159     ## -- Load input dac database file
160     status_msg_ qq<Opening dac file "$Opt{file_name}"...>;
161     my $db = $impl->get_feature (ExpandedURI q<DIS:Core> => '1.0')
162     ->pl_load_dis_database ($Opt{file_name});
163     status_msg qq<done\n>;
164    
165     ## -- Load requested module
166     my $mod = $db->get_module ($Opt{module_uri}, for_arg => $Opt{For});
167     unless ($Opt{For}) {
168     my $el = $mod->source_element;
169     if ($el) {
170     $Opt{For} = $el->default_for_uri;
171     $mod = $db->get_module ($Opt{module_uri}, for_arg => $Opt{For});
172     }
173     }
174     unless ($mod->is_defined) {
175     die qq<$0: Module <$Opt{module_uri}> for <$Opt{For}> is not defined>;
176     }
177    
178     status_msg qq<Module <$Opt{module_uri}> for <$Opt{For}>...>;
179    
180 wakaba 1.2 our %ReferredResource;
181    
182 wakaba 1.1 sub append_module_documentation (%) {
183     my %opt = @_;
184     my $section = $opt{result_parent}->create_module ($opt{source_resource}->uri);
185 wakaba 1.2
186     add_uri ($opt{source_resource} => $section);
187 wakaba 1.1
188     my $pl_full_name = $opt{source_resource}->pl_fully_qualified_name;
189     if (defined $pl_full_name) {
190     $section->perl_package_name ($pl_full_name);
191     my $path = $pl_full_name;
192     $path =~ s#::#/#g;
193     $section->resource_file_path_stem ($path);
194     $section->set_attribute_ns
195     (ExpandedURI q<ddoct:>, 'ddoct:basePath', '../' x ($path =~ tr#/#/#));
196 wakaba 1.2 $pl_full_name =~ s/.*:://g;
197     $section->perl_name ($pl_full_name);
198 wakaba 1.1 }
199    
200     $section->resource_file_name_stem ($opt{source_resource}->pl_file_name_stem);
201    
202     append_description (source_resource => $opt{source_resource},
203     result_parent => $section);
204    
205 wakaba 1.2 if ($opt{is_partial}) {
206     $section->resource_is_partial (1);
207     return;
208     }
209    
210 wakaba 1.1 for my $rres (@{$opt{source_resource}->get_property_resource_list
211     (ExpandedURI q<DIS:resource>)}) {
212     if ($rres->owner_module eq $opt{source_resource}) { ## Defined in this module
213     ## TODO: Modification required to support modplans
214 wakaba 1.2 status_msg_ "*";
215 wakaba 1.1 if ($rres->is_type_uri (ExpandedURI q<ManakaiDOM:Class>)) {
216     append_class_documentation
217     (result_parent => $section,
218     source_resource => $rres);
219     } elsif ($rres->is_type_uri (ExpandedURI q<ManakaiDOM:IF>)) {
220     append_interface_documentation
221     (result_parent => $section,
222     source_resource => $rres);
223     }
224     } else { ## Aliases
225     #
226     }
227     }
228 wakaba 1.2 status_msg "";
229 wakaba 1.1 } # append_module_documentation
230    
231     sub append_interface_documentation (%) {
232     my %opt = @_;
233     my $section = $opt{result_parent}->create_interface
234     ($opt{source_resource}->uri);
235 wakaba 1.2
236     add_uri ($opt{source_resource} => $section);
237 wakaba 1.1
238     my $pl_full_name = $opt{source_resource}->pl_fully_qualified_name;
239     if (defined $pl_full_name) {
240     $section->perl_package_name ($pl_full_name);
241     my $path = $pl_full_name;
242     $path =~ s#::#/#g;
243     $section->resource_file_path_stem ($path);
244     $section->set_attribute_ns
245     (ExpandedURI q<ddoct:>, 'ddoct:basePath',
246     join '', '../' x ($path =~ tr#/#/#));
247 wakaba 1.2 $pl_full_name =~ s/.*:://g;
248     $section->perl_name ($pl_full_name);
249 wakaba 1.1 }
250    
251     $section->resource_file_name_stem ($opt{source_resource}->pl_file_name_stem);
252    
253     $section->is_exception_interface (1)
254     if $opt{source_resource}->is_type_uri
255     (ExpandedURI q<ManakaiDOM:ExceptionIF>);
256    
257     append_description (source_resource => $opt{source_resource},
258     result_parent => $section);
259    
260 wakaba 1.2 if ($opt{is_partial}) {
261     $section->resource_is_partial (1);
262     return;
263     }
264    
265 wakaba 1.1 ## Inheritance
266     append_inheritance (source_resource => $opt{source_resource},
267     result_parent => $section);
268    
269     for my $memres (@{$opt{source_resource}->get_property_resource_list
270     (ExpandedURI q<DIS:childResource>)}) {
271     if ($memres->is_type_uri (ExpandedURI q<DISLang:Method>)) {
272     append_method_documentation (source_resource => $memres,
273     result_parent => $section);
274     } elsif ($memres->is_type_uri (ExpandedURI q<DISLang:Attribute>)) {
275     append_attr_documentation (source_resource => $memres,
276     result_parent => $section);
277     } elsif ($memres->is_type_uri (ExpandedURI q<ManakaiDOM:ConstGroup>)) {
278    
279     }
280     }
281     } # append_interface_documentation
282    
283     sub append_class_documentation (%) {
284     my %opt = @_;
285     my $section = $opt{result_parent}->create_class ($opt{source_resource}->uri);
286 wakaba 1.2
287     add_uri ($opt{source_resource} => $section);
288 wakaba 1.1
289     my $pl_full_name = $opt{source_resource}->pl_fully_qualified_name;
290     if (defined $pl_full_name) {
291     $section->perl_package_name ($pl_full_name);
292     my $path = $pl_full_name;
293     $path =~ s#::#/#g;
294     $section->resource_file_path_stem ($path);
295     $section->set_attribute_ns
296     (ExpandedURI q<ddoct:>, 'ddoct:basePath', '../' x ($path =~ tr#/#/#));
297 wakaba 1.2 $pl_full_name =~ s/.*:://g;
298     $section->perl_name ($pl_full_name);
299 wakaba 1.1 }
300    
301     $section->resource_file_name_stem ($opt{source_resource}->pl_file_name_stem);
302    
303     append_description (source_resource => $opt{source_resource},
304     result_parent => $section);
305    
306 wakaba 1.2 if ($opt{is_partial}) {
307     $section->resource_is_partial (1);
308     return;
309     }
310    
311 wakaba 1.1 ## Inheritance
312     append_inheritance (source_resource => $opt{source_resource},
313     result_parent => $section,
314     append_implements => 1);
315    
316     for my $memres (@{$opt{source_resource}->get_property_resource_list
317     (ExpandedURI q<DIS:childResource>)}) {
318     if ($memres->is_type_uri (ExpandedURI q<DISLang:Method>)) {
319     append_method_documentation (source_resource => $memres,
320     result_parent => $section);
321     } elsif ($memres->is_type_uri (ExpandedURI q<DISLang:Attribute>)) {
322     append_attr_documentation (source_resource => $memres,
323     result_parent => $section);
324     } elsif ($memres->is_type_uri (ExpandedURI q<ManakaiDOM:Const>)) {
325    
326     } elsif ($memres->is_type_uri (ExpandedURI q<ManakaiDOM:ConstGroup>)) {
327    
328     }
329     }
330     } # append_class_documentation
331    
332     sub append_method_documentation (%) {
333     my %opt = @_;
334     my $perl_name = $opt{source_resource}->pl_name;
335     my $m;
336     if (defined $perl_name) {
337     $m = $opt{result_parent}->create_method ($perl_name);
338    
339     } else { ## Anonymous
340     ## TODO
341     return;
342     }
343 wakaba 1.2
344     add_uri ($opt{source_resource} => $m);
345 wakaba 1.1
346     append_description (source_resource => $opt{source_resource},
347     result_parent => $m);
348    
349     my $ret = $opt{source_resource}->get_child_resource_by_type
350     (ExpandedURI q<DISLang:MethodReturn>);
351     if ($ret) {
352     my $r = $m->dis_return;
353    
354     try {
355 wakaba 1.2 $r->resource_data_type (my $u = $ret->dis_data_type_resource->uri);
356     $ReferredResource{$u} ||= 1;
357     $r->resource_actual_data_type
358     ($u = $ret->dis_actual_data_type_resource->uri);
359     $ReferredResource{$u} ||= 1;
360    
361 wakaba 1.1 append_description (source_resource => $ret,
362     result_parent => $r,
363     has_case => 1);
364    
365     ## TODO: Exceptions
366     } catch Message::Util::DIS::ManakaiDISException with {
367    
368     };
369     }
370    
371     for my $cr (@{$opt{source_resource}->get_property_resource_list
372     (ExpandedURI q<DIS:childResource>)}) {
373     if ($cr->is_type_uri (ExpandedURI q<DISLang:MethodParameter>)) {
374     append_param_documentation (source_resource => $cr,
375     result_parent => $m);
376     }
377     }
378    
379     ## TODO: raises
380    
381     $m->resource_access ('private')
382     if $opt{source_resource}->get_property_boolean
383     (ExpandedURI q<ManakaiDOM:isForInternal>, 0);
384     } # append_method_documentation
385    
386     sub append_attr_documentation (%) {
387     my %opt = @_;
388     my $perl_name = $opt{source_resource}->pl_name;
389     my $m;
390     if (defined $perl_name) {
391     $m = $opt{result_parent}->create_attribute ($perl_name);
392    
393     } else { ## Anonymous
394     ## TODO
395     return;
396     }
397 wakaba 1.2
398     add_uri ($opt{source_resource} => $m);
399 wakaba 1.1
400     append_description (source_resource => $opt{source_resource},
401     result_parent => $m,
402     has_case => 1);
403    
404     my $ret = $opt{source_resource}->get_child_resource_by_type
405     (ExpandedURI q<DISLang:AttributeGet>);
406     if ($ret) {
407     my $r = $m->dis_get;
408    
409 wakaba 1.2 $r->resource_data_type (my $u = $ret->dis_data_type_resource->uri);
410     $ReferredResource{$u} ||= 1;
411     $r->resource_actual_data_type
412     ($u = $ret->dis_actual_data_type_resource->uri);
413     $ReferredResource{$u} ||= 1;
414    
415 wakaba 1.1 append_description (source_resource => $ret,
416     result_parent => $r,
417     has_case => 1);
418    
419     ## TODO: Exceptions
420     }
421    
422     my $set = $opt{source_resource}->get_child_resource_by_type
423     (ExpandedURI q<DISLang:AttributeSet>);
424     if ($set) {
425     my $r = $m->dis_set;
426    
427 wakaba 1.2 $r->resource_data_type (my $u = $set->dis_data_type_resource->uri);
428     $ReferredResource{$u} ||= 1;
429 wakaba 1.1 $r->resource_actual_data_type ($set->dis_actual_data_type_resource->uri);
430 wakaba 1.2 $ReferredResource{$u} ||= 1;
431 wakaba 1.1
432     append_description (source_resource => $set,
433     result_parent => $r,
434     has_case => 1);
435    
436     ## TODO: InCase, Exceptions
437     } else {
438     $m->is_read_only_attribute (1);
439     }
440    
441     $m->resource_access ('private')
442     if $opt{source_resource}->get_property_boolean
443     (ExpandedURI q<ManakaiDOM:isForInternal>, 0);
444     } # append_attr_documentation
445    
446     sub append_param_documentation (%) {
447     my %opt = @_;
448    
449     my $is_named_param = $opt{source_resource}->get_property_boolean
450     (ExpandedURI q<DISPerl:isNamedParameter>, 0);
451    
452     my $perl_name = $is_named_param
453     ? $opt{source_resource}->pl_name
454     : $opt{source_resource}->pl_variable_name;
455    
456     my $p = $opt{result_parent}->create_parameter ($perl_name, $is_named_param);
457    
458 wakaba 1.2 add_uri ($opt{source_resource} => $p);
459    
460 wakaba 1.1 $p->is_nullable_parameter ($opt{source_resource}->pl_is_nullable);
461 wakaba 1.2 $p->resource_data_type
462     (my $u = $opt{source_resource}->dis_data_type_resource->uri);
463     $ReferredResource{$u} ||= 1;
464 wakaba 1.1 $p->resource_actual_data_type
465 wakaba 1.2 ($u = $opt{source_resource}->dis_actual_data_type_resource->uri);
466     $ReferredResource{$u} ||= 1;
467 wakaba 1.1
468     append_description (source_resource => $opt{source_resource},
469     result_parent => $p,
470     has_case => 1);
471     } # append_param_documentation
472    
473     sub append_description (%) {
474     my %opt = @_;
475 wakaba 1.2
476 wakaba 1.1 my $od = $opt{result_parent}->owner_document;
477     my $resd = $opt{source_resource}->get_feature (ExpandedURI q<DIS:Doc>, '2.0');
478     my $doc = $resd->get_description ($od);
479     $opt{result_parent}->create_description->append_child ($doc);
480     ## TODO: Negotiation
481    
482     if ($opt{has_case}) {
483     for my $caser (@{$opt{source_resource}->get_property_resource_list
484     (ExpandedURI q<DIS:childResource>)}) {
485     if ($caser->is_type_uri (ExpandedURI q<ManakaiDOM:InCase>)) {
486     my $case = $opt{result_parent}->append_case;
487     my $cased = $caser->get_feature (ExpandedURI q<DIS:Doc>, '2.0');
488     my $label = $cased->get_label ($od);
489     if ($label) {
490     $case->create_label->append_child ($label);
491     }
492     my $value = $caser->pl_code_fragment;
493     if ($value) {
494     $case->create_value->text_content ($value->stringify);
495     }
496     append_description (source_resource => $caser,
497     result_parent => $case);
498     }
499     }
500     }
501     } # append_description
502    
503     sub append_inheritance (%) {
504     my %opt = @_;
505     if (($opt{depth} ||= 0) == 100) {
506     warn "<".$opt{source_resource}->uri.">: Loop in inheritance";
507     return;
508     }
509    
510     for my $isa (@{$opt{source_resource}->get_property_resource_list
511     (ExpandedURI q<dis:ISA>,
512     default_media_type => ExpandedURI q<dis:TFQNames>)}) {
513     append_inheritance
514     (source_resource => $isa,
515     result_parent => $opt{result_parent}->append_new_extends ($isa->uri),
516     depth => $opt{depth} + 1);
517 wakaba 1.2 $ReferredResource{$isa->uri} ||= 1;
518 wakaba 1.1 }
519    
520     if ($opt{append_implements}) {
521     for my $impl (@{$opt{source_resource}->get_property_resource_list
522     (ExpandedURI q<dis:Implement>,
523     default_media_type => ExpandedURI q<dis:TFQNames>,
524     recursive_isa => 1)}) {
525     append_inheritance
526     (source_resource => $impl,
527     result_parent => $opt{result_parent}->append_new_implements
528     ($impl->uri),
529     depth => $opt{depth});
530 wakaba 1.2 $ReferredResource{$impl->uri} ||= 1;
531 wakaba 1.1 }
532     }
533     } # append_inheritance
534    
535 wakaba 1.2 sub add_uri ($$;%) {
536     my ($res, $el, %opt) = @_;
537     my $canon_uri = $res->uri;
538     for my $uri (@{$res->uris}) {
539     $el->add_uri ($uri, $canon_uri eq $uri ? 0 : 1);
540     $ReferredResource{$uri} = -1;
541     }
542     } # add_uri
543    
544 wakaba 1.1 my $doc = $impl->create_disdump_document;
545    
546     my $body = $doc->document_element;
547    
548     append_module_documentation
549     (result_parent => $body,
550     source_resource => $mod);
551    
552 wakaba 1.2
553     while (my @ruri = grep {$ReferredResource{$_} > 0} keys %ReferredResource) {
554     U: while (defined (my $uri = shift @ruri)) {
555     next U if $ReferredResource{$uri} < 0; ## Already done
556     my $res = $db->get_resource ($uri);
557     unless ($res->is_defined) {
558     $res = $db->get_module ($uri);
559     unless ($res->is_defined) {
560     $ReferredResource{$uri} = -1;
561     next U;
562     }
563     append_module_documentation
564     (result_parent => $body,
565     source_resource => $res,
566     is_partial => 1);
567     } elsif ($res->is_type_uri (ExpandedURI q<ManakaiDOM:Class>)) {
568     my $mod = $res->owner_module;
569     unless ($ReferredResource{$mod->uri} < 0) {
570     unshift @ruri, $uri;
571     unshift @ruri, $mod->uri;
572     next U;
573     }
574     append_class_documentation
575     (result_parent => $body->create_module ($mod->uri),
576     source_resource => $res,
577     is_partial => 1);
578     } elsif ($res->is_type_uri (ExpandedURI q<ManakaiDOM:IF>)) {
579     my $mod = $res->owner_module;
580     unless ($mod->is_defined) {
581     $ReferredResource{$uri} = -1;
582     next U;
583     } elsif (not ($ReferredResource{$mod->uri} < 0)) {
584     unshift @ruri, $uri;
585     unshift @ruri, $mod->uri;
586     next U;
587     }
588     append_interface_documentation
589     (result_parent => $body->create_module ($mod->uri),
590     source_resource => $res,
591     is_partial => 1);
592     } elsif ($res->is_type_uri (ExpandedURI q<DISLang:AnyMethod>)) {
593     my $cls = $res->get_property_resource
594     (ExpandedURI q<dis2pm:parentResource>);
595     if (not ($ReferredResource{$cls->uri} < 0) and
596     ($cls->is_type_uri (ExpandedURI q<ManakaiDOM:Class>) or
597     $cls->is_type_uri (ExpandedURI q<ManakaiDOM:IF>))) {
598     unshift @ruri, $uri;
599     unshift @ruri, $cls->uri;
600     next U;
601     }
602     my $model = $body->create_module ($cls->owner_module->uri);
603     my $clsel = $cls->is_type_uri (ExpandedURI q<ManakaiDOM:Class>)
604     ? $model->create_class ($cls->uri)
605     : $model->create_interface ($cls->uri);
606     if ($res->is_type_uri (ExpandedURI q<DISLang:Method>)) {
607     append_method_documentation
608     (result_parent => $clsel,
609     source_resource => $res);
610     } else { ## Attribute
611     append_attr_documentation
612     (resource_parent => $clsel,
613     source_resource => $res);
614     }
615     } elsif ($res->is_type_uri (ExpandedURI q<DISLang:MethodParameter>)) {
616     my $m = $res->get_property_resource
617     (ExpandedURI q<dis2pm:parentResource>);
618     if (not ($ReferredResource{$m->uri} < 0) and
619     $m->is_type_uri (ExpandedURI q<DISLang:Method>)) {
620     unshift @ruri, $m->uri;
621     next U;
622     }
623     } else { ## Unsupported type
624     $ReferredResource{$uri} = -1;
625     }
626     } # U
627     }
628    
629 wakaba 1.1 my $lsimpl = $impl->get_feature (ExpandedURI q<DOMLS:LS> => '3.0');
630    
631     status_msg_ qq<Writing file ""...>;
632    
633     use Encode;
634     my $serializer = $lsimpl->create_mls_serializer
635     ({ExpandedURI q<DOMLS:SerializeDocumentInstance> => ''});
636     print Encode::encode ('utf8', $serializer->write_to_string ($doc));
637    
638     status_msg qq<done>;
639    
640     verbose_msg_ qq<Checking undefined resources...>;
641    
642     $db->check_undefined_resource;
643    
644     verbose_msg qq<done>;
645    
646     verbose_msg_ qq<Closing database...>;
647     undef $db;
648     verbose_msg qq<done>;
649    
650     =head1 SEE ALSO
651    
652     L<lib/manakai/dis.pl> and L<bin/cdis2pm.pl> - Old version of
653     this script.
654    
655     L<lib/Message/Util/DIS.dis> - The <QUOTE::dis> object implementation.
656    
657     L<lib/Message/Util/PerlCode.dis> - The Perl code generator.
658    
659     L<lib/manakai/DISCore.dis> - The definition for the "dis" format.
660    
661     L<lib/manakai/DISPerl.dis> - The definition for the "dis" Perl-specific
662     vocabulary.
663    
664     =head1 LICENSE
665    
666     Copyright 2004-2005 Wakaba <w@suika.fam.cx>. All rights reserved.
667    
668     This program is free software; you can redistribute it and/or
669     modify it under the same terms as Perl itself.
670    
671     =cut
672    
673 wakaba 1.2 1; # $Date: 2005/08/30 12:30:45 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24