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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 return $type =~ /\?$/; | 324 return $type =~ /\?$/; |
325 } | 325 } |
326 | 326 |
327 sub typeRemoveNullableSuffix | 327 sub typeRemoveNullableSuffix |
328 { | 328 { |
329 my $type = shift; | 329 my $type = shift; |
330 $type =~ s/\?$//g; | 330 $type =~ s/\?$//g; |
331 return $type; | 331 return $type; |
332 } | 332 } |
333 | 333 |
| 334 # Promise is not yet in the Web IDL spec but is going to be speced |
| 335 # as primitive types in the future. |
334 my $nextAttribute_1 = '^(attribute|inherit|readonly)$'; | 336 my $nextAttribute_1 = '^(attribute|inherit|readonly)$'; |
335 my $nextPrimitiveType_1 = '^(int|long|short|unsigned)$'; | 337 my $nextPrimitiveType_1 = '^(int|long|short|unsigned)$'; |
336 my $nextPrimitiveType_2 = '^(double|float|unrestricted)$'; | 338 my $nextPrimitiveType_2 = '^(double|float|unrestricted)$'; |
337 my $nextArgumentList_1 = '^(\(|::|ByteString|DOMString|Date|\[|any|boolean|byte|
double|float|in|int|long|object|octet|optional|sequence|short|unrestricted|unsig
ned)$'; | 339 my $nextArgumentList_1 = '^(\(|::|ByteString|DOMString|Promise|Date|\[|any|boole
an|byte|double|float|in|int|long|object|octet|optional|sequence|short|unrestrict
ed|unsigned)$'; |
338 my $nextNonAnyType_1 = '^(boolean|byte|double|float|int|long|octet|short|unrestr
icted|unsigned)$'; | 340 my $nextNonAnyType_1 = '^(boolean|byte|double|float|int|long|octet|short|unrestr
icted|unsigned)$'; |
339 my $nextInterfaceMember_1 = '^(\(|::|ByteString|DOMString|Date|any|attribute|boo
lean|byte|creator|deleter|double|float|getter|inherit|int|legacycaller|long|obje
ct|octet|readonly|sequence|serializer|setter|short|static|stringifier|unrestrict
ed|unsigned|void)$'; | 341 my $nextInterfaceMember_1 = '^(\(|::|ByteString|DOMString|Promise|Date|any|attri
bute|boolean|byte|creator|deleter|double|float|getter|inherit|int|legacycaller|l
ong|object|octet|readonly|sequence|serializer|setter|short|static|stringifier|un
restricted|unsigned|void)$'; |
340 my $nextOptionalIteratorInterfaceOrObject_1 = '^(;|=)$'; | 342 my $nextOptionalIteratorInterfaceOrObject_1 = '^(;|=)$'; |
341 my $nextAttributeOrOperationOrIterator_1 = '^(static|stringifier)$'; | 343 my $nextAttributeOrOperationOrIterator_1 = '^(static|stringifier)$'; |
342 my $nextAttributeOrOperationOrIterator_2 = '^(\(|::|ByteString|DOMString|Date|an
y|boolean|byte|creator|deleter|double|float|getter|int|legacycaller|long|object|
octet|sequence|setter|short|unrestricted|unsigned|void)$'; | 344 my $nextAttributeOrOperationOrIterator_2 = '^(\(|::|ByteString|DOMString|Promise
|Date|any|boolean|byte|creator|deleter|double|float|getter|int|legacycaller|long
|object|octet|sequence|setter|short|unrestricted|unsigned|void)$'; |
343 my $nextUnrestrictedFloatType_1 = '^(double|float)$'; | 345 my $nextUnrestrictedFloatType_1 = '^(double|float)$'; |
344 my $nextExtendedAttributeRest3_1 = '^(\,|::|\])$'; | 346 my $nextExtendedAttributeRest3_1 = '^(\,|::|\])$'; |
345 my $nextExceptionField_1 = '^(\(|::|ByteString|DOMString|Date|any|boolean|byte|d
ouble|float|int|long|object|octet|sequence|short|unrestricted|unsigned)$'; | 347 my $nextExceptionField_1 = '^(\(|::|ByteString|DOMString|Promise|Date|any|boolea
n|byte|double|float|int|long|object|octet|sequence|short|unrestricted|unsigned)$
'; |
346 my $nextType_1 = '^(::|ByteString|DOMString|Date|any|boolean|byte|double|float|i
nt|long|object|octet|sequence|short|unrestricted|unsigned)$'; | 348 my $nextType_1 = '^(::|ByteString|DOMString|Promise|Date|any|boolean|byte|double
|float|int|long|object|octet|sequence|short|unrestricted|unsigned)$'; |
347 my $nextSpecials_1 = '^(creator|deleter|getter|legacycaller|setter)$'; | 349 my $nextSpecials_1 = '^(creator|deleter|getter|legacycaller|setter)$'; |
348 my $nextDefinitions_1 = '^(::|callback|dictionary|enum|exception|interface|parti
al|typedef)$'; | 350 my $nextDefinitions_1 = '^(::|callback|dictionary|enum|exception|interface|parti
al|typedef)$'; |
349 my $nextExceptionMembers_1 = '^(\(|::|ByteString|DOMString|Date|\[|any|boolean|b
yte|const|double|float|int|long|object|octet|optional|sequence|short|unrestricte
d|unsigned)$'; | 351 my $nextExceptionMembers_1 = '^(\(|::|ByteString|DOMString|Promise|Date|\[|any|b
oolean|byte|const|double|float|int|long|object|octet|optional|sequence|short|unr
estricted|unsigned)$'; |
350 my $nextAttributeRest_1 = '^(attribute|readonly)$'; | 352 my $nextAttributeRest_1 = '^(attribute|readonly)$'; |
351 my $nextInterfaceMembers_1 = '^(\(|::|ByteString|DOMString|Date|any|attribute|bo
olean|byte|const|creator|deleter|double|float|getter|inherit|int|legacycaller|lo
ng|object|octet|readonly|sequence|serializer|setter|short|static|stringifier|unr
estricted|unsigned|void)$'; | 353 my $nextInterfaceMembers_1 = '^(\(|::|ByteString|DOMString|Promise|Date|any|attr
ibute|boolean|byte|const|creator|deleter|double|float|getter|inherit|int|legacyc
aller|long|object|octet|readonly|sequence|serializer|setter|short|static|stringi
fier|unrestricted|unsigned|void)$'; |
352 my $nextSingleType_1 = '^(::|ByteString|DOMString|Date|boolean|byte|double|float
|int|long|object|octet|sequence|short|unrestricted|unsigned)$'; | 354 my $nextSingleType_1 = '^(::|ByteString|DOMString|Promise|Date|boolean|byte|doub
le|float|int|long|object|octet|sequence|short|unrestricted|unsigned)$'; |
353 my $nextArgumentName_1 = '^(attribute|callback|const|creator|deleter|dictionary|
enum|exception|getter|implements|inherit|interface|legacycaller|partial|serializ
er|setter|static|stringifier|typedef|unrestricted)$'; | 355 my $nextArgumentName_1 = '^(attribute|callback|const|creator|deleter|dictionary|
enum|exception|getter|implements|inherit|interface|legacycaller|partial|serializ
er|setter|static|stringifier|typedef|unrestricted)$'; |
354 my $nextConstValue_1 = '^(false|true)$'; | 356 my $nextConstValue_1 = '^(false|true)$'; |
355 my $nextConstValue_2 = '^(-|Infinity|NaN)$'; | 357 my $nextConstValue_2 = '^(-|Infinity|NaN)$'; |
356 my $nextDefinition_1 = '^(callback|interface)$'; | 358 my $nextDefinition_1 = '^(callback|interface)$'; |
357 my $nextAttributeOrOperationRest_1 = '^(\(|::|ByteString|DOMString|Date|any|bool
ean|byte|double|float|int|long|object|octet|sequence|short|unrestricted|unsigned
|void)$'; | 359 my $nextAttributeOrOperationRest_1 = '^(\(|::|ByteString|DOMString|Promise|Date|
any|boolean|byte|double|float|int|long|object|octet|sequence|short|unrestricted|
unsigned|void)$'; |
358 my $nextUnsignedIntegerType_1 = '^(int|long|short)$'; | 360 my $nextUnsignedIntegerType_1 = '^(int|long|short)$'; |
359 my $nextDefaultValue_1 = '^(-|Infinity|NaN|false|null|true)$'; | 361 my $nextDefaultValue_1 = '^(-|Infinity|NaN|false|null|true)$'; |
360 | 362 |
361 | 363 |
362 sub parseDefinitions | 364 sub parseDefinitions |
363 { | 365 { |
364 my $self = shift; | 366 my $self = shift; |
365 my @definitions = (); | 367 my @definitions = (); |
366 | 368 |
367 while (1) { | 369 while (1) { |
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 return $self->parsePrimitiveType() . $self->parseTypeSuffix(); | 1857 return $self->parsePrimitiveType() . $self->parseTypeSuffix(); |
1856 } | 1858 } |
1857 if ($next->value() eq "ByteString") { | 1859 if ($next->value() eq "ByteString") { |
1858 $self->assertTokenValue($self->getToken(), "ByteString", __LINE__); | 1860 $self->assertTokenValue($self->getToken(), "ByteString", __LINE__); |
1859 return "ByteString" . $self->parseTypeSuffix(); | 1861 return "ByteString" . $self->parseTypeSuffix(); |
1860 } | 1862 } |
1861 if ($next->value() eq "DOMString") { | 1863 if ($next->value() eq "DOMString") { |
1862 $self->assertTokenValue($self->getToken(), "DOMString", __LINE__); | 1864 $self->assertTokenValue($self->getToken(), "DOMString", __LINE__); |
1863 return "DOMString" . $self->parseTypeSuffix(); | 1865 return "DOMString" . $self->parseTypeSuffix(); |
1864 } | 1866 } |
| 1867 if ($next->value() eq "Promise") { |
| 1868 $self->assertTokenValue($self->getToken(), "Promise", __LINE__); |
| 1869 return "Promise" . $self->parseTypeSuffix(); |
| 1870 } |
1865 if ($next->value() eq "sequence") { | 1871 if ($next->value() eq "sequence") { |
1866 $self->assertTokenValue($self->getToken(), "sequence", __LINE__); | 1872 $self->assertTokenValue($self->getToken(), "sequence", __LINE__); |
1867 $self->assertTokenValue($self->getToken(), "<", __LINE__); | 1873 $self->assertTokenValue($self->getToken(), "<", __LINE__); |
1868 my $type = $self->parseType(); | 1874 my $type = $self->parseType(); |
1869 $self->assertTokenValue($self->getToken(), ">", __LINE__); | 1875 $self->assertTokenValue($self->getToken(), ">", __LINE__); |
1870 return "sequence<" . $type . ">" . $self->parseNull(); | 1876 return "sequence<" . $type . ">" . $self->parseNull(); |
1871 } | 1877 } |
1872 if ($next->value() eq "object") { | 1878 if ($next->value() eq "object") { |
1873 $self->assertTokenValue($self->getToken(), "object", __LINE__); | 1879 $self->assertTokenValue($self->getToken(), "object", __LINE__); |
1874 return "object" . $self->parseTypeSuffix(); | 1880 return "object" . $self->parseTypeSuffix(); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 $customConstructor->overloadedIndex($index++); | 2240 $customConstructor->overloadedIndex($index++); |
2235 push(@{$interface->customConstructors}, $customConstructor); | 2241 push(@{$interface->customConstructors}, $customConstructor); |
2236 } | 2242 } |
2237 delete $extendedAttributeList->{"CustomConstructors"}; | 2243 delete $extendedAttributeList->{"CustomConstructors"}; |
2238 $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING"; | 2244 $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING"; |
2239 } | 2245 } |
2240 $interface->extendedAttributes($extendedAttributeList); | 2246 $interface->extendedAttributes($extendedAttributeList); |
2241 } | 2247 } |
2242 | 2248 |
2243 1; | 2249 1; |
OLD | NEW |