| OLD | NEW |
| 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 17 matching lines...) Expand all Loading... |
| 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; |
| 33 use constant OtherToken => 4; | 33 use constant OtherToken => 4; |
| 34 use constant EmptyToken => 5; | 34 use constant EmptyToken => 5; |
| 35 | 35 |
| 36 # Used to represent a parsed IDL document | 36 # Used to represent a parsed IDL document |
| 37 struct( idlDocument => { | 37 struct( idlDocument => { |
| 38 fileName => '$', # file name |
| 39 callbackFunctions => '@', |
| 40 enumerations => '@', # All parsed enumerations |
| 38 interfaces => '@', # All parsed interfaces | 41 interfaces => '@', # All parsed interfaces |
| 39 enumerations => '@', # All parsed enumerations | 42 }); |
| 40 fileName => '$', # file name | 43 |
| 44 struct( callbackFunction => { |
| 45 name => '$', |
| 46 type => '$', |
| 47 parameters => '@', |
| 41 }); | 48 }); |
| 42 | 49 |
| 43 # Used to represent 'interface' blocks | 50 # Used to represent 'interface' blocks |
| 44 struct( domInterface => { | 51 struct( domInterface => { |
| 45 name => '$', # Class identifier | 52 name => '$', # Class identifier |
| 46 parents => '@', # List of strings | 53 parents => '@', # List of strings |
| 47 constants => '@', # List of 'domConstant' | 54 constants => '@', # List of 'domConstant' |
| 48 functions => '@', # List of 'domFunction' | 55 functions => '@', # List of 'domFunction' |
| 49 attributes => '@', # List of 'domAttribute' | 56 attributes => '@', # List of 'domAttribute' |
| 50 extendedAttributes => '$', # Extended attributes | 57 extendedAttributes => '$', # Extended attributes |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 }; | 209 }; |
| 203 die $@ . " in $fileName" if $@; | 210 die $@ . " in $fileName" if $@; |
| 204 | 211 |
| 205 my $document = idlDocument->new(); | 212 my $document = idlDocument->new(); |
| 206 $document->fileName($fileName); | 213 $document->fileName($fileName); |
| 207 foreach my $definition (@definitions) { | 214 foreach my $definition (@definitions) { |
| 208 if (ref($definition) eq "domInterface") { | 215 if (ref($definition) eq "domInterface") { |
| 209 push(@{$document->interfaces}, $definition); | 216 push(@{$document->interfaces}, $definition); |
| 210 } elsif (ref($definition) eq "domEnum") { | 217 } elsif (ref($definition) eq "domEnum") { |
| 211 push(@{$document->enumerations}, $definition); | 218 push(@{$document->enumerations}, $definition); |
| 219 } elsif (ref($definition) eq "callbackFunction") { |
| 220 push(@{$document->callbackFunctions}, $definition); |
| 212 } else { | 221 } else { |
| 213 die "Unrecognized IDL definition kind: \"" . ref($definition) . "\""
; | 222 die "Unrecognized IDL definition kind: \"" . ref($definition) . "\""
; |
| 214 } | 223 } |
| 215 } | 224 } |
| 216 return $document; | 225 return $document; |
| 217 } | 226 } |
| 218 | 227 |
| 219 sub nextToken | 228 sub nextToken |
| 220 { | 229 { |
| 221 my $self = shift; | 230 my $self = shift; |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 return \@values; # empty list (end of enumeration-values) | 813 return \@values; # empty list (end of enumeration-values) |
| 805 } | 814 } |
| 806 | 815 |
| 807 sub parseCallbackRest | 816 sub parseCallbackRest |
| 808 { | 817 { |
| 809 my $self = shift; | 818 my $self = shift; |
| 810 my $extendedAttributeList = shift; | 819 my $extendedAttributeList = shift; |
| 811 | 820 |
| 812 my $next = $self->nextToken(); | 821 my $next = $self->nextToken(); |
| 813 if ($next->type() == IdentifierToken) { | 822 if ($next->type() == IdentifierToken) { |
| 814 $self->assertTokenType($self->getToken(), IdentifierToken); | 823 my $callback = callbackFunction->new(); |
| 824 my $name = $self->getToken(); |
| 825 $self->assertTokenType($name, IdentifierToken); |
| 826 $callback->name($name->value()); |
| 815 $self->assertTokenValue($self->getToken(), "=", __LINE__); | 827 $self->assertTokenValue($self->getToken(), "=", __LINE__); |
| 816 $self->parseReturnType(); | 828 $callback->type($self->parseReturnType()); |
| 817 $self->assertTokenValue($self->getToken(), "(", __LINE__); | 829 $self->assertTokenValue($self->getToken(), "(", __LINE__); |
| 818 $self->parseArgumentList(); | 830 $callback->parameters($self->parseArgumentList()); |
| 819 $self->assertTokenValue($self->getToken(), ")", __LINE__); | 831 $self->assertTokenValue($self->getToken(), ")", __LINE__); |
| 820 $self->assertTokenValue($self->getToken(), ";", __LINE__); | 832 $self->assertTokenValue($self->getToken(), ";", __LINE__); |
| 821 return; | 833 return $callback; |
| 822 } | 834 } |
| 823 $self->assertUnexpectedToken($next->value(), __LINE__); | 835 $self->assertUnexpectedToken($next->value(), __LINE__); |
| 824 } | 836 } |
| 825 | 837 |
| 826 sub parseTypedef | 838 sub parseTypedef |
| 827 { | 839 { |
| 828 my $self = shift; | 840 my $self = shift; |
| 829 my $extendedAttributeList = shift; | 841 my $extendedAttributeList = shift; |
| 830 die "Extended attributes are not applicable to typedefs themselves: " . $sel
f->{Line} if %{$extendedAttributeList}; | 842 die "Extended attributes are not applicable to typedefs themselves: " . $sel
f->{Line} if %{$extendedAttributeList}; |
| 831 | 843 |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 { | 1344 { |
| 1333 my $self = shift; | 1345 my $self = shift; |
| 1334 my $extendedAttributeList = shift; | 1346 my $extendedAttributeList = shift; |
| 1335 | 1347 |
| 1336 my $next = $self->nextToken(); | 1348 my $next = $self->nextToken(); |
| 1337 if ($next->type() == IdentifierToken || $next->value() eq "(") { | 1349 if ($next->type() == IdentifierToken || $next->value() eq "(") { |
| 1338 my $newDataNode = domFunction->new(); | 1350 my $newDataNode = domFunction->new(); |
| 1339 $newDataNode->signature(domSignature->new()); | 1351 $newDataNode->signature(domSignature->new()); |
| 1340 my $name = $self->parseOptionalIdentifier(); | 1352 my $name = $self->parseOptionalIdentifier(); |
| 1341 $newDataNode->signature->name($name); | 1353 $newDataNode->signature->name($name); |
| 1342 $self->assertTokenValue($self->getToken(), "(", $name, __LINE__); | 1354 $self->assertTokenValue($self->getToken(), "(", __LINE__); |
| 1343 push(@{$newDataNode->parameters}, @{$self->parseArgumentList()}); | 1355 push(@{$newDataNode->parameters}, @{$self->parseArgumentList()}); |
| 1344 $self->assertTokenValue($self->getToken(), ")", __LINE__); | 1356 $self->assertTokenValue($self->getToken(), ")", __LINE__); |
| 1345 $self->assertTokenValue($self->getToken(), ";", __LINE__); | 1357 $self->assertTokenValue($self->getToken(), ";", __LINE__); |
| 1346 $newDataNode->signature->extendedAttributes($extendedAttributeList); | 1358 $newDataNode->signature->extendedAttributes($extendedAttributeList); |
| 1347 return $newDataNode; | 1359 return $newDataNode; |
| 1348 } | 1360 } |
| 1349 $self->assertUnexpectedToken($next->value(), __LINE__); | 1361 $self->assertUnexpectedToken($next->value(), __LINE__); |
| 1350 } | 1362 } |
| 1351 | 1363 |
| 1352 sub parseOptionalIdentifier | 1364 sub parseOptionalIdentifier |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 $customConstructor->overloadedIndex($index++); | 2238 $customConstructor->overloadedIndex($index++); |
| 2227 push(@{$interface->customConstructors}, $customConstructor); | 2239 push(@{$interface->customConstructors}, $customConstructor); |
| 2228 } | 2240 } |
| 2229 delete $extendedAttributeList->{"CustomConstructors"}; | 2241 delete $extendedAttributeList->{"CustomConstructors"}; |
| 2230 $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING"; | 2242 $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING"; |
| 2231 } | 2243 } |
| 2232 $interface->extendedAttributes($extendedAttributeList); | 2244 $interface->extendedAttributes($extendedAttributeList); |
| 2233 } | 2245 } |
| 2234 | 2246 |
| 2235 1; | 2247 1; |
| OLD | NEW |