Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: Source/bindings/scripts/deprecated_idl_parser.pm

Issue 18190004: Add Python flow to bindings generation, move dummy-generating IDL files over (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revised Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # 1 #
2 # KDOM IDL parser 2 # KDOM IDL parser
3 # 3 #
4 # Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org> 4 # Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org>
5 # 5 #
6 # This library is free software; you can redistribute it and/or 6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Library General Public 7 # modify it under the terms of the GNU Library General Public
8 # License as published by the Free Software Foundation; either 8 # License as published by the Free Software Foundation; either
9 # version 2 of the License, or (at your option) any later version. 9 # version 2 of the License, or (at your option) any later version.
10 # 10 #
11 # This library is distributed in the hope that it will be useful, 11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Library General Public License for more details. 14 # Library General Public License for more details.
15 # 15 #
16 # You should have received a copy of the GNU Library General Public License 16 # You should have received a copy of the GNU Library General Public License
17 # along with this library; see the file COPYING.LIB. If not, write to 17 # along with this library; see the file COPYING.LIB. If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 # Boston, MA 02110-1301, USA. 19 # Boston, MA 02110-1301, USA.
20 # 20 #
21 21
22 package IDLParser; 22 package deprecated_idl_parser;
23 23
24 use strict; 24 use strict;
25 25
26 use preprocessor; 26 use preprocessor;
27 use Class::Struct; 27 use Class::Struct;
28 28
29 use constant StringToken => 0; 29 use constant StringToken => 0;
30 use constant IntegerToken => 1; 30 use constant IntegerToken => 1;
31 use constant FloatToken => 2; 31 use constant FloatToken => 2;
32 use constant IdentifierToken => 3; 32 use constant IdentifierToken => 3;
(...skipping 13 matching lines...) Expand all
46 type => '$', 46 type => '$',
47 parameters => '@', 47 parameters => '@',
48 }); 48 });
49 49
50 # Used to represent 'interface' blocks 50 # Used to represent 'interface' blocks
51 struct( domInterface => { 51 struct( domInterface => {
52 name => '$', # Class identifier 52 name => '$', # Class identifier
53 parent => '$', # Parent class identifier 53 parent => '$', # Parent class identifier
54 constants => '@', # List of 'domConstant' 54 constants => '@', # List of 'domConstant'
55 functions => '@', # List of 'domFunction' 55 functions => '@', # List of 'domFunction'
56 attributes => '@', # List of 'domAttribute' 56 attributes => '@', # List of 'domAttribute'
57 extendedAttributes => '$', # Extended attributes 57 extendedAttributes => '$', # Extended attributes
58 constructors => '@', # Constructors, list of 'domFunction' 58 constructors => '@', # Constructors, list of 'domFunction'
59 customConstructors => '@', # Custom constructors, list of 'domFunction' 59 customConstructors => '@', # Custom constructors, list of 'domFunction'
60 isException => '$', # Used for exception interfaces 60 isException => '$', # Used for exception interfaces
61 isCallback => '$', # Used for callback interfaces 61 isCallback => '$', # Used for callback interfaces
62 isPartial => '$', # Used for partial interfaces 62 isPartial => '$', # Used for partial interfaces
63 }); 63 });
64 64
65 # Used to represent domInterface contents 65 # Used to represent domInterface contents
66 struct( domFunction => { 66 struct( domFunction => {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 145 }
146 146
147 sub assertTokenValue 147 sub assertTokenValue
148 { 148 {
149 my $self = shift; 149 my $self = shift;
150 my $token = shift; 150 my $token = shift;
151 my $value = shift; 151 my $value = shift;
152 my $line = shift; 152 my $line = shift;
153 my $msg = "Next token should be " . $value . ", but " . $token->value() . " at " . $self->{Line}; 153 my $msg = "Next token should be " . $value . ", but " . $token->value() . " at " . $self->{Line};
154 if (defined ($line)) { 154 if (defined ($line)) {
155 $msg .= " IDLParser.pm:" . $line; 155 $msg .= " deprecated_idl_parser.pm:" . $line;
156 } 156 }
157 die $msg unless $token->value() eq $value; 157 die $msg unless $token->value() eq $value;
158 } 158 }
159 159
160 sub assertTokenType 160 sub assertTokenType
161 { 161 {
162 my $self = shift; 162 my $self = shift;
163 my $token = shift; 163 my $token = shift;
164 my $type = shift; 164 my $type = shift;
165 die "Next token's type should be " . $type . ", but " . $token->type() . " a t " . $self->{Line} unless $token->type() eq $type; 165 die "Next token's type should be " . $type . ", but " . $token->type() . " a t " . $self->{Line} unless $token->type() eq $type;
166 } 166 }
167 167
168 sub assertUnexpectedToken 168 sub assertUnexpectedToken
169 { 169 {
170 my $self = shift; 170 my $self = shift;
171 my $token = shift; 171 my $token = shift;
172 my $line = shift; 172 my $line = shift;
173 my $msg = "Unexpected token " . $token . " at " . $self->{Line}; 173 my $msg = "Unexpected token " . $token . " at " . $self->{Line};
174 if (defined ($line)) { 174 if (defined ($line)) {
175 $msg .= " IDLParser.pm:" . $line; 175 $msg .= " deprecated_idl_parser.pm:" . $line;
176 } 176 }
177 die $msg; 177 die $msg;
178 } 178 }
179 179
180 sub assertNoExtendedAttributesInTypedef 180 sub assertNoExtendedAttributesInTypedef
181 { 181 {
182 my $self = shift; 182 my $self = shift;
183 my $name = shift; 183 my $name = shift;
184 my $line = shift; 184 my $line = shift;
185 my $typedef = $typedefs{$name}; 185 my $typedef = $typedefs{$name};
186 my $msg = "Unexpected extendedAttributeList in typedef \"$name\" at " . $sel f->{Line}; 186 my $msg = "Unexpected extendedAttributeList in typedef \"$name\" at " . $sel f->{Line};
187 if (defined ($line)) { 187 if (defined ($line)) {
188 $msg .= " IDLParser.pm:" . $line; 188 $msg .= " deprecated_idl_parser.pm:" . $line;
189 } 189 }
190 die $msg if %{$typedef->extendedAttributes}; 190 die $msg if %{$typedef->extendedAttributes};
191 } 191 }
192 192
193 sub Parse 193 sub Parse
194 { 194 {
195 my $self = shift; 195 my $self = shift;
196 my $fileName = shift; 196 my $fileName = shift;
197 my $defines = shift;
198 my $preprocessor = shift; 197 my $preprocessor = shift;
198 my $defines = "";
199 199
200 my @definitions = (); 200 my @definitions = ();
201 201
202 my @lines = applyPreprocessor($fileName, $defines, $preprocessor); 202 my @lines = applyPreprocessor($fileName, $defines, $preprocessor);
203 $self->{Line} = $lines[0]; 203 $self->{Line} = $lines[0];
204 $self->{DocumentContent} = join(' ', @lines); 204 $self->{DocumentContent} = join(' ', @lines);
205 205
206 $self->getToken(); 206 $self->getToken();
207 eval { 207 eval {
208 my $result = $self->parseDefinitions(); 208 my $result = $self->parseDefinitions();
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 374 }
375 } 375 }
376 $self->applyTypedefs(\@definitions); 376 $self->applyTypedefs(\@definitions);
377 return \@definitions; 377 return \@definitions;
378 } 378 }
379 379
380 sub applyTypedefs 380 sub applyTypedefs
381 { 381 {
382 my $self = shift; 382 my $self = shift;
383 my $definitions = shift; 383 my $definitions = shift;
384 384
385 if (!%typedefs) { 385 if (!%typedefs) {
386 return; 386 return;
387 } 387 }
388 foreach my $definition (@$definitions) { 388 foreach my $definition (@$definitions) {
389 if (ref($definition) eq "domInterface") { 389 if (ref($definition) eq "domInterface") {
390 foreach my $constant (@{$definition->constants}) { 390 foreach my $constant (@{$definition->constants}) {
391 if (exists $typedefs{$constant->type}) { 391 if (exists $typedefs{$constant->type}) {
392 my $typedef = $typedefs{$constant->type}; 392 my $typedef = $typedefs{$constant->type};
393 $self->assertNoExtendedAttributesInTypedef($constant->type, __LINE__); 393 $self->assertNoExtendedAttributesInTypedef($constant->type, __LINE__);
394 $constant->type($typedef->type); 394 $constant->type($typedef->type);
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 $customConstructor->overloadedIndex($index++); 2230 $customConstructor->overloadedIndex($index++);
2231 push(@{$interface->customConstructors}, $customConstructor); 2231 push(@{$interface->customConstructors}, $customConstructor);
2232 } 2232 }
2233 delete $extendedAttributeList->{"CustomConstructors"}; 2233 delete $extendedAttributeList->{"CustomConstructors"};
2234 $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING"; 2234 $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING";
2235 } 2235 }
2236 $interface->extendedAttributes($extendedAttributeList); 2236 $interface->extendedAttributes($extendedAttributeList);
2237 } 2237 }
2238 2238
2239 1; 2239 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698