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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Mon Sep 19 16:17:50 2005 UTC (19 years, 2 months ago) by wakaba
Branch: MAIN
Changes since 1.6: +2 -1 lines
File MIME type: text/plain
++ ./bin/ChangeLog	19 Sep 2005 12:05:15 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* mkdisdump.pl (progress_inc, progress_reset): New functions.

++ ./lib/Message/Util/ChangeLog	19 Sep 2005 12:14:55 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* DIS.dis: Parameter "databaseArg" added to various
	methods to support objects that have no associated
	database.
	(getNamespaceBindingList, getDefaultNamespaceURIRef): New
	methods.
	(NO_RDF_TYPE_ERR): New error type.
	(loadResource): Throws NO_RDF_TYPE_ERR if no rdf:type
	attribute specified for a resource definition.

++ ./lib/Message/Util/Error/ChangeLog	19 Sep 2005 12:21:57 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* Core.dis: Missing rdf:type attribute added to classes.

++ ./lib/Message/Util/DIS/ChangeLog	19 Sep 2005 12:23:54 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* Value.dis (sourceNodePath): New attribute.
	(DVNSValue, DVNSOrderedList): New interfaces and classes.

	* Perl.dis: Some alias definitions moved from ../DIS.dis.
	The "namespaceContext" parameters added to some methods.
	(plCodeFragment): Now Perl'ize new DISCore:Integer typed string.
	(plImplementation): Directly instantiates PCImplementation
	to reduce overheads to find an implementation by ImplementationRegistry.

++ ./lib/Message/DOM/ChangeLog	19 Sep 2005 12:08:55 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* DOMMain.dis (ManakaiDOM:DOMMethod, ManakaiDOM:DOMMethodReturn,
	ManakaiDOM:DOMAttribute, ManakaiDOM:DOMAttrGet,
	ManakaiDOM:DOMAttrSet, ManakaiDOM:DOMMethodParam): Removed.
	(ManakaiDOMTimeStamp): Removed.

	* DOMBoot.dis, DOMMetaImpl.dis, DOMMetaImpl.pm: Removed (they are no
	longer in use).

2005-09-18  Wakaba  <wakaba@suika.fam.cx>

	* DOMMain.dis (StringOutOfBoundsException): New exception.

++ ./lib/manakai/ChangeLog	19 Sep 2005 12:23:20 -0000
2005-09-19  Wakaba  <wakaba@suika.fam.cx>

	* DISCore.dis (DISCore:Boolean): New preferred name
	to dis:Boolean.
	(DISCore:Integer): New type.
	(dis:Value): Default type is changed to DISCore:String.

1 #!/usr/bin/perl -w
2 use strict;
3
4 =head1 NAME
5
6 dac2pm - Generating Perl Module from "dac" File
7
8 =head1 SYNOPSIS
9
10 perl path/to/dac2pm.pl input.dac \
11 --module-uri=module-uri [--for=for-uri] [options] > ModuleName.pm
12 perl path/to/dac2pm.pl input.dac \
13 --module-uri=module-uri [--for=for-uri] [options] \
14 --output-file-path=ModuleName.pm
15 perl path/to/dac2pm.pl --help
16
17 =head1 DESCRIPTION
18
19 The C<dac2pm> script generates a Perl module from a "dac" file.
20
21 This script is part of manakai.
22
23 =cut
24
25 use strict;
26 use Message::Util::DIS;
27 use Message::Util::QName::Filter {
28 DIS => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/DIS#>,
29 dis => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis-->,
30 dis2pm => q<http://suika.fam.cx/~wakaba/archive/2004/11/8/dis2pm#>,
31 DISCore => q<http://suika.fam.cx/~wakaba/archive/2004/dis/Core#>,
32 DISLang => q<http://suika.fam.cx/~wakaba/archive/2004/dis/Lang#>,
33 DISPerl => q<http://suika.fam.cx/~wakaba/archive/2004/dis/Perl#>,
34 disPerl => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis--Perl-->,
35 DOMCore => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#>,
36 DOMEvents => q<http://suika.fam.cx/~wakaba/archive/2004/dom/events#>,
37 DOMMain => q<http://suika.fam.cx/~wakaba/archive/2004/dom/main#>,
38 DOMXML => q<http://suika.fam.cx/~wakaba/archive/2004/dom/xml#>,
39 DX => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#>,
40 lang => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#>,
41 Perl => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#Perl-->,
42 license => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/license#>,
43 ManakaiDOM => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#>,
44 Markup => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Markup#>,
45 MDOMX => q<http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#>,
46 owl => q<http://www.w3.org/2002/07/owl#>,
47 pc => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/PerlCode#>,
48 rdf => q<http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
49 rdfs => q<http://www.w3.org/2000/01/rdf-schema#>,
50 swcfg21 => q<http://suika.fam.cx/~wakaba/archive/2005/swcfg21#>,
51 TreeCore => q<>,
52 Util => q<http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/>,
53 };
54
55 =head1 OPTIONS
56
57 =over 4
58
59 =item --enable-assertion / --noenable-assertion (default)
60
61 Whether assertion codes should be outputed or not.
62
63 =item --for=I<for-uri> (Optional)
64
65 Specifies the "For" URI reference for which the outputed module is.
66 If this parameter is ommitted, the default "For" URI reference
67 for the module specified by the C<dis:DefaultFor> attribute
68 of the C<dis:Module> element, if any, or C<ManakaiDOM:all> is assumed.
69
70 =item --help
71
72 Shows the help message.
73
74 =item --module-uri=I<module-uri>
75
76 A URI reference that identifies a module from which a Perl
77 module file is generated. This argument is I<required>.
78
79 =item --output-file-path=I<perl-module-file-path> (default: the standard output)
80
81 A platform-dependent file path to which the Perl module
82 is written down.
83
84 =item --verbose / --noverbose (default)
85
86 Whether a verbose message mode should be selected or not.
87
88 =back
89
90 =cut
91
92 use Getopt::Long;
93 use Pod::Usage;
94 my %Opt;
95 GetOptions (
96 'enable-assertion!' => \$Opt{outputAssertion},
97 'for=s' => \$Opt{For},
98 'help' => \$Opt{help},
99 'module-uri=s' => \$Opt{module_uri},
100 'output-file-path=s' => \$Opt{output_file_name},
101 'verbose!' => $Opt{verbose},
102 ) or pod2usage (2);
103 pod2usage ({-exitval => 0, -verbose => 1}) if $Opt{help};
104 $Opt{file_name} = shift;
105 pod2usage ({-exitval => 2, -verbose => 0}) unless $Opt{file_name};
106 pod2usage (2) unless $Opt{module_uri};
107
108 ## TODO: Assertion control
109
110 ## TODO: Verbose mode
111
112 my $impl = $Message::DOM::ImplementationRegistry->get_implementation
113 ({
114 ExpandedURI q<ManakaiDOM:Minimum> => '3.0',
115 '+' . ExpandedURI q<DIS:Core> => '1.0',
116 '+' . ExpandedURI q<Util:PerlCode> => '1.0',
117 });
118 my $pc = $impl->get_feature (ExpandedURI q<Util:PerlCode> => '1.0');
119 my $di = $impl->get_feature (ExpandedURI q<DIS:Core> => '1.0');
120
121 print STDERR qq<Loading the database "$Opt{file_name}"...>;
122 my $db = $di->pl_load_dis_database ($Opt{file_name});
123 print STDERR "done\n";
124
125 my $mod = $db->get_module ($Opt{module_uri}, for_arg => $Opt{For});
126 unless ($Opt{For}) {
127 $Opt{For} = $mod->get_property_text (ExpandedURI q<dis:DefaultFor>, undef);
128 if (defined $Opt{For}) {
129 $mod = $db->get_module ($Opt{module_uri}, for_arg => $Opt{For});
130 } else {
131 my $el = $mod->source_element;
132 if ($el) {
133 $Opt{For} = $el->default_for_uri;
134 $mod = $db->get_module ($Opt{module_uri}, for_arg => $Opt{For});
135 }
136 }
137 }
138 unless ($mod->is_defined) {
139 die qq<$0: Module <$Opt{module_uri}> for <$Opt{For}> is not defined>;
140 }
141
142 my $pl = $mod->pl_generate_perl_module_file;
143
144 my $output;
145 defined $Opt{output_file_name}
146 ? (open $output, '>', $Opt{output_file_name}
147 or die "$0: $Opt{output_file_name}: $!")
148 : ($output = \*STDOUT);
149
150 printf STDERR qq<Writing file "%s"...>,
151 defined $Opt{output_file_name} ? $Opt{output_file_name} : '';
152 print $output $pl->stringify;
153 close $output;
154 print STDERR "done\n";
155
156 print STDERR "Checking undefined resources...";
157 $db->check_undefined_resource;
158 print STDERR "done\n";
159
160 print STDERR "Closing the database...";
161 $db->free;
162 undef $db;
163 print STDERR "done\n";
164
165 =head1 SEE ALSO
166
167 L<lib/Message/Util/DIS.dis> - The <QUOTE::dis> object implementation.
168
169 L<lib/Message/Util/PerlCode.dis> - The Perl code generator.
170
171 L<lib/manakai/DISCore.dis> - The definition for the "dis" format.
172
173 L<lib/manakai/DISPerl.dis> - The definition for the "dis" Perl-specific
174 vocabulary.
175
176 L<bin/dac.pl> - The "dac" database generator.
177
178 =head1 LICENSE
179
180 Copyright 2004-2005 Wakaba <w@suika.fam.cx>. All rights reserved.
181
182 This program is free software; you can redistribute it and/or
183 modify it under the same terms as Perl itself.
184
185 =cut
186
187 1; # $Date: 2005/09/17 15:03:02 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24