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

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

Issue 14244017: Make length property return useful values for DOM bindings functions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Replace [Optional] by optional Created 7 years, 8 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
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 #
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 # Used to represent 'interface' blocks 43 # Used to represent 'interface' blocks
44 struct( domInterface => { 44 struct( domInterface => {
45 name => '$', # Class identifier 45 name => '$', # Class identifier
46 parents => '@', # List of strings 46 parents => '@', # List of strings
47 constants => '@', # List of 'domConstant' 47 constants => '@', # List of 'domConstant'
48 functions => '@', # List of 'domFunction' 48 functions => '@', # List of 'domFunction'
49 attributes => '@', # List of 'domAttribute' 49 attributes => '@', # List of 'domAttribute'
50 extendedAttributes => '$', # Extended attributes 50 extendedAttributes => '$', # Extended attributes
51 constructors => '@', # Constructors, list of 'domFunction' 51 constructors => '@', # Constructors, list of 'domFunction'
52 customConstructors => '@', # Custom constructors, list of 'domFunction'
52 isException => '$', # Used for exception interfaces 53 isException => '$', # Used for exception interfaces
53 }); 54 });
54 55
55 # Used to represent domInterface contents (name of method, signature) 56 # Used to represent domInterface contents (name of method, signature)
56 struct( domFunction => { 57 struct( domFunction => {
57 isStatic => '$', 58 isStatic => '$',
58 signature => '$', # Return type/Object name/extended attributes 59 signature => '$', # Return type/Object name/extended attributes
59 parameters => '@', # List of 'domSignature' 60 parameters => '@', # List of 'domSignature'
60 }); 61 });
61 62
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 foreach my $constant (@{$definition->constants}) { 367 foreach my $constant (@{$definition->constants}) {
367 if (exists $typedefs{$constant->type}) { 368 if (exists $typedefs{$constant->type}) {
368 my $typedef = $typedefs{$constant->type}; 369 my $typedef = $typedefs{$constant->type};
369 $self->assertNoExtendedAttributesInTypedef($constant->type, __LINE__); 370 $self->assertNoExtendedAttributesInTypedef($constant->type, __LINE__);
370 $constant->type($typedef->type); 371 $constant->type($typedef->type);
371 } 372 }
372 } 373 }
373 foreach my $attribute (@{$definition->attributes}) { 374 foreach my $attribute (@{$definition->attributes}) {
374 $self->applyTypedefsForSignature($attribute->signature); 375 $self->applyTypedefsForSignature($attribute->signature);
375 } 376 }
376 foreach my $function (@{$definition->functions}, @{$definition->cons tructors}) { 377 foreach my $function (@{$definition->functions}, @{$definition->cons tructors}, @{$definition->customConstructors}) {
377 $self->applyTypedefsForSignature($function->signature); 378 $self->applyTypedefsForSignature($function->signature);
378 foreach my $signature (@{$function->parameters}) { 379 foreach my $signature (@{$function->parameters}) {
379 $self->applyTypedefsForSignature($signature); 380 $self->applyTypedefsForSignature($signature);
380 } 381 }
381 } 382 }
382 } 383 }
383 } 384 }
384 } 385 }
385 386
386 sub applyTypedefsForSignature 387 sub applyTypedefsForSignature
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 $self->assertTokenValue($self->getToken(), "attribute", __LINE__); 1132 $self->assertTokenValue($self->getToken(), "attribute", __LINE__);
1132 $newDataNode->signature(domSignature->new()); 1133 $newDataNode->signature(domSignature->new());
1133 my $type = $self->parseType(); 1134 my $type = $self->parseType();
1134 $newDataNode->signature->isNullable(typeHasNullableSuffix($type)); 1135 $newDataNode->signature->isNullable(typeHasNullableSuffix($type));
1135 # Remove all "?" in the type declaration, e.g. "double?" -> "double". 1136 # Remove all "?" in the type declaration, e.g. "double?" -> "double".
1136 $newDataNode->signature->type(typeRemoveNullableSuffix($type)); 1137 $newDataNode->signature->type(typeRemoveNullableSuffix($type));
1137 my $token = $self->getToken(); 1138 my $token = $self->getToken();
1138 $self->assertTokenType($token, IdentifierToken); 1139 $self->assertTokenType($token, IdentifierToken);
1139 $newDataNode->signature->name($token->value()); 1140 $newDataNode->signature->name($token->value());
1140 $self->assertTokenValue($self->getToken(), ";", __LINE__); 1141 $self->assertTokenValue($self->getToken(), ";", __LINE__);
1142 # CustomConstructor may also be used on attributes.
1143 if (defined $extendedAttributeList->{"CustomConstructors"}) {
1144 delete $extendedAttributeList->{"CustomConstructors"};
1145 $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING";
1146 }
1141 $newDataNode->signature->extendedAttributes($extendedAttributeList); 1147 $newDataNode->signature->extendedAttributes($extendedAttributeList);
1142 return $newDataNode; 1148 return $newDataNode;
1143 } 1149 }
1144 $self->assertUnexpectedToken($next->value(), __LINE__); 1150 $self->assertUnexpectedToken($next->value(), __LINE__);
1145 } 1151 }
1146 1152
1147 sub parseInherit 1153 sub parseInherit
1148 { 1154 {
1149 my $self = shift; 1155 my $self = shift;
1150 my $next = $self->nextToken(); 1156 my $next = $self->nextToken();
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 my $attr = shift; 1496 my $attr = shift;
1491 1497
1492 for my $key (keys %{$attr}) { 1498 for my $key (keys %{$attr}) {
1493 if ($key eq "Constructor") { 1499 if ($key eq "Constructor") {
1494 push(@{$extendedAttributeList->{"Constructors"}}, $attr->{$key}); 1500 push(@{$extendedAttributeList->{"Constructors"}}, $attr->{$key});
1495 } elsif ($key eq "Constructors") { 1501 } elsif ($key eq "Constructors") {
1496 my @constructors = @{$attr->{$key}}; 1502 my @constructors = @{$attr->{$key}};
1497 foreach my $constructor (@constructors) { 1503 foreach my $constructor (@constructors) {
1498 push(@{$extendedAttributeList->{"Constructors"}}, $constructor); 1504 push(@{$extendedAttributeList->{"Constructors"}}, $constructor);
1499 } 1505 }
1506 } elsif ($key eq "CustomConstructor") {
1507 push(@{$extendedAttributeList->{"CustomConstructors"}}, $attr->{$key });
1508 } elsif ($key eq "CustomConstructors") {
1509 my @customConstructors = @{$attr->{$key}};
1510 foreach my $customConstructor (@customConstructors) {
1511 push(@{$extendedAttributeList->{"CustomConstructors"}}, $customC onstructor);
1512 }
1500 } else { 1513 } else {
1501 $extendedAttributeList->{$key} = $attr->{$key}; 1514 $extendedAttributeList->{$key} = $attr->{$key};
1502 } 1515 }
1503 } 1516 }
1504 } 1517 }
1505 1518
1506 sub parseExtendedAttributeList 1519 sub parseExtendedAttributeList
1507 { 1520 {
1508 my $self = shift; 1521 my $self = shift;
1509 my $next = $self->nextToken(); 1522 my $next = $self->nextToken();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 $attrs->{$name} = $self->parseArgumentList(); 1589 $attrs->{$name} = $self->parseArgumentList();
1577 $self->assertTokenValue($self->getToken(), ")", __LINE__); 1590 $self->assertTokenValue($self->getToken(), ")", __LINE__);
1578 return $attrs; 1591 return $attrs;
1579 } 1592 }
1580 if ($next->value() eq "=") { 1593 if ($next->value() eq "=") {
1581 $self->assertTokenValue($self->getToken(), "=", __LINE__); 1594 $self->assertTokenValue($self->getToken(), "=", __LINE__);
1582 $attrs->{$name} = $self->parseExtendedAttributeRest2(); 1595 $attrs->{$name} = $self->parseExtendedAttributeRest2();
1583 return $attrs; 1596 return $attrs;
1584 } 1597 }
1585 1598
1586 if ($name eq "Constructor") { 1599 if ($name eq "Constructor" || $name eq "CustomConstructor") {
1587 $attrs->{$name} = []; 1600 $attrs->{$name} = [];
1588 } else { 1601 } else {
1589 $attrs->{$name} = "VALUE_IS_MISSING"; 1602 $attrs->{$name} = "VALUE_IS_MISSING";
1590 } 1603 }
1591 return $attrs; 1604 return $attrs;
1592 } 1605 }
1593 1606
1594 sub parseExtendedAttributeRest2 1607 sub parseExtendedAttributeRest2
1595 { 1608 {
1596 my $self = shift; 1609 my $self = shift;
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 $newDataNode->signature(domSignature->new()); 2184 $newDataNode->signature(domSignature->new());
2172 $newDataNode->signature->name("NamedConstructor"); 2185 $newDataNode->signature->name("NamedConstructor");
2173 $newDataNode->signature->extendedAttributes($extendedAttributeList); 2186 $newDataNode->signature->extendedAttributes($extendedAttributeList);
2174 my %attributes = %{$extendedAttributeList->{"NamedConstructor"}}; 2187 my %attributes = %{$extendedAttributeList->{"NamedConstructor"}};
2175 my @attributeKeys = keys (%attributes); 2188 my @attributeKeys = keys (%attributes);
2176 my $constructorName = $attributeKeys[0]; 2189 my $constructorName = $attributeKeys[0];
2177 push(@{$newDataNode->parameters}, @{$attributes{$constructorName}}); 2190 push(@{$newDataNode->parameters}, @{$attributes{$constructorName}});
2178 $extendedAttributeList->{"NamedConstructor"} = $constructorName; 2191 $extendedAttributeList->{"NamedConstructor"} = $constructorName;
2179 push(@{$interface->constructors}, $newDataNode); 2192 push(@{$interface->constructors}, $newDataNode);
2180 } 2193 }
2194 if (defined $extendedAttributeList->{"CustomConstructors"}) {
2195 my @customConstructorParams = @{$extendedAttributeList->{"CustomConstruc tors"}};
2196 my $index = (@customConstructorParams == 1) ? 0 : 1;
2197 foreach my $param (@customConstructorParams) {
2198 my $customConstructor = domFunction->new();
2199 $customConstructor->signature(domSignature->new());
2200 $customConstructor->signature->name("CustomConstructor");
2201 $customConstructor->signature->extendedAttributes($extendedAttribute List);
2202 $customConstructor->parameters($param);
2203 $customConstructor->{overloadedIndex} = $index++;
2204 push(@{$interface->customConstructors}, $customConstructor);
2205 }
2206 delete $extendedAttributeList->{"CustomConstructors"};
2207 $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING";
2208 }
2181 $interface->extendedAttributes($extendedAttributeList); 2209 $interface->extendedAttributes($extendedAttributeList);
2182 } 2210 }
2183 2211
2184 1; 2212 1;
OLDNEW
« no previous file with comments | « Source/bindings/scripts/CodeGeneratorV8.pm ('k') | Source/bindings/tests/results/V8Float64Array.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698