fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / khtml / bindings / scripts / IDLStructure.pm
blob4d413501fa8cc5b90f77dc87e49d436a72d1191e
1 #
2 # KDOM IDL parser
4 # Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org>
5 #
6 # This file is part of the KDE project
7 #
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Library General Public
10 # License as published by the Free Software Foundation; either
11 # version 2 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Library General Public License for more details.
18 # You should have received a copy of the GNU Library General Public License
19 # aint with this library; see the file COPYING.LIB. If not, write to
20 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 # Boston, MA 02110-1301, USA.
24 package IDLStructure;
26 use Class::Struct;
28 # Used to represent a parsed IDL document
29 struct( idlDocument => {
30 module => '$', # Module identifier
31 classes => '@', # All parsed interfaces
32 fileName => '$' # file name
33 });
35 # Used to represent 'interface' / 'exception' blocks
36 struct( domClass => {
37 name => '$', # Class identifier (without module)
38 parents => '@', # List of strings
39 constants => '@', # List of 'domConstant'
40 functions => '@', # List of 'domFunction'
41 attributes => '@', # List of 'domAttribute'
42 extendedAttributes => '$', # Extended attributes
43 });
45 # Used to represent domClass contents (name of method, signature)
46 struct( domFunction => {
47 signature => '$', # Return type/Object name/extended attributes
48 parameters => '@', # List of 'domSignature'
49 raisesExceptions => '@', # Possibly raised exceptions.
50 });
52 # Used to represent domClass contents (name of attribute, signature)
53 struct( domAttribute => {
54 type => '$', # Attribute type (including namespace)
55 signature => '$', # Attribute signature
56 getterExceptions => '@', # Possibly raised exceptions.
57 setterExceptions => '@', # Possibly raised exceptions.
58 });
60 # Used to represent a map of 'variable name' <-> 'variable type'
61 struct( domSignature => {
62 name => '$', # Variable name
63 type => '$', # Variable type
64 extendedAttributes => '$' # Extended attributes
65 });
67 # Used to represent string constants
68 struct( domConstant => {
69 name => '$', # DOM Constant identifier
70 type => '$', # Type of data
71 value => '$', # Constant value
72 });
74 # Helpers
75 $idlId = '[a-zA-Z0-9]'; # Generic identifier
76 $idlIdNs = '[a-zA-Z0-9:]'; # Generic identifier including namespace
77 $idlIdNsList = '[a-zA-Z0-9:,\ ]'; # List of Generic identifiers including namespace
79 $idlType = '[a-zA-Z0-9_]'; # Generic type/"value string" identifier
80 $idlDataType = '[a-zA-Z0-9\ ]'; # Generic data type identifier
82 # Magic IDL parsing regular expressions
83 my $supportedTypes = "((?:unsigned )?(?:int|short|long)|(?:$idlIdNs*))";
85 # Special IDL notations
86 $extendedAttributeSyntax = '\[[^]]*\]'; # Used for extended attributes
88 # Regular expression based IDL 'syntactical tokenizer' used in the IDLParser
89 $moduleSelector = 'module\s*(' . $idlId . '*)\s*{';
90 $moduleNSSelector = 'module\s*(' . $idlId . '*)\s*\[ns\s*(' . $idlIdNs . '*)\s*(' . $idlIdNs . '*)\]\s*;';
91 $constantSelector = 'const\s*' . $supportedTypes . '\s*(' . $idlType . '*)\s*=\s*(' . $idlType . '*)';
92 $raisesSelector = 'raises\s*\((' . $idlIdNsList . '*)\s*\)';
93 $getterRaisesSelector = '\bgetter\s+raises\s*\((' . $idlIdNsList . '*)\s*\)';
94 $setterRaisesSelector = '\bsetter\s+raises\s*\((' . $idlIdNsList . '*)\s*\)';
96 $typeNamespaceSelector = '((?:' . $idlId . '*::)*)\s*(' . $idlDataType . '*)';
98 $exceptionSelector = 'exception\s*(' . $idlIdNs . '*)\s*([a-zA-Z\s{;]*};)';
99 $exceptionSubSelector = '{\s*' . $supportedTypes . '\s*(' . $idlType . '*)\s*;\s*}';
101 $interfaceSelector = 'interface\s*((?:' . $extendedAttributeSyntax . ' )?)(' . $idlIdNs . '*)\s*(?::(\s*[^{]*))?{([a-zA-Z0-9_=\s(),;:\[\]]*)';
102 $interfaceMethodSelector = '\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)\s*\(\s*([a-zA-Z0-9:\s,=\[\]]*)';
103 $interfaceParameterSelector = 'in\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)';
105 $interfaceAttributeSelector = '\s*(readonly attribute|attribute)\s*(' . $extendedAttributeSyntax . ' )?' . $supportedTypes . '\s*(' . $idlType . '*)';