Fix the issue that Web Audio test case fails on PR3.
[framework/web/webkit-efl.git] / Source / WebCore / bindings / scripts / IDLStructure.pm
1
2 # KDOM IDL parser
3 #
4 # Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org>
5
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Library General Public
8 # License as published by the Free Software Foundation; either
9 # version 2 of the License, or (at your option) any later version.
10
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Library General Public License for more details.
15
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
18 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 # Boston, MA 02110-1301, USA.
20
21
22 package IDLStructure;
23
24 use strict;
25
26 use Class::Struct;
27
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 });
34
35 # Used to represent 'interface' 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     constructor => '$', # Constructor
44     isException => '$', # Used for exception interfaces
45 });
46
47 # Used to represent domClass contents (name of method, signature)
48 struct( domFunction => {
49     isStatic => '$',
50     signature => '$',    # Return type/Object name/extended attributes
51     parameters => '@',    # List of 'domSignature'
52     raisesExceptions => '@',  # Possibly raised exceptions.
53 });
54
55 # Used to represent domClass contents (name of attribute, signature)
56 struct( domAttribute => {
57     type => '$',              # Attribute type (including namespace)
58     isStatic => '$',
59     signature => '$',         # Attribute signature
60     getterExceptions => '@',  # Possibly raised exceptions.
61     setterExceptions => '@',  # Possibly raised exceptions.
62 });
63
64 # Used to represent a map of 'variable name' <-> 'variable type'
65 struct( domSignature => {
66     direction => '$', # Variable direction (in or out)
67     name => '$',      # Variable name
68     type => '$',      # Variable type
69     extendedAttributes => '$', # Extended attributes
70     isNullable => '$' # Is variable type Nullable (T?)
71 });
72
73 # Used to represent string constants
74 struct( domConstant => {
75     name => '$',      # DOM Constant identifier
76     type => '$',      # Type of data
77     value => '$',      # Constant value
78     extendedAttributes => '$', # Extended attributes
79 });
80
81 # Helpers
82 our $idlId = '[a-zA-Z0-9]';        # Generic identifier
83 our $idlIdNs = '[a-zA-Z0-9:]';      # Generic identifier including namespace
84 our $idlIdNsList = '[a-zA-Z0-9:,\ ]';  # List of Generic identifiers including namespace
85
86 our $idlType = '[a-zA-Z0-9_]';      # Generic type/"value string" identifier
87 # Match a string value, a hexadecimal number, or an integral number.
88 # Note: some of the characters that are allowed in the string value may not be allowed by
89 # interfaceSelector.
90 our $constValue = '("[^"\r\n]*")|(0[xX][a-fA-F0-9]+)|(-?[0-9]*)';
91 our $idlDataType = '[a-zA-Z0-9\ ]';   # Generic data type identifier
92
93 # Magic IDL parsing regular expressions
94 my $supportedTypes = "((?:(?:unsigned )?(?:int|short|(?:long )?long)|(?:$idlIdNs*))(?:\\[\\]|<(?:$idlIdNsList*)>)?)";
95 my $supportedTypeSuffix = "(\\?)?";
96
97 # Special IDL notations. This regular expression extracts the string between the first [ and its corresponding ].
98 our $extendedAttributeSyntax = qr/\[[^\[\]]*(?:(??{$IDLStructure::extendedAttributeSyntax})[^\[\]]*)*\]/x; # Used for extended attributes
99
100 # Regular expression based IDL 'syntactical tokenizer' used in the IDLParser
101 our $moduleSelector = 'module\s*(' . $idlId . '*)\s*{';
102 our $moduleNSSelector = 'module\s*(' . $idlId . '*)\s*\[ns\s*(' . $idlIdNs . '*)\s*(' . $idlIdNs . '*)\]\s*;';
103 our $constantSelector = '(' . $extendedAttributeSyntax . ' )?const\s+' . $supportedTypes . '\s*(' . $idlType . '*)\s*=\s*(' . $constValue . ')';
104 our $raisesSelector = 'raises\s*\((' . $idlIdNsList . '*)\s*\)';
105 our $getterRaisesSelector = '\bgetter\s+raises\s*\((' . $idlIdNsList . '*)\s*\)';
106 our $setterRaisesSelector = '\bsetter\s+raises\s*\((' . $idlIdNsList . '*)\s*\)';
107
108 our $typeNamespaceSelector = '((?:' . $idlId . '*::)*)\s*(' . $idlDataType . '*)';
109
110 our $interfaceSelector = '(interface|exception)\s*((?:' . $extendedAttributeSyntax . ' )?)(' . $idlIdNs . '*)\s*(?::(\s*[^{]*))?{([-a-zA-Z0-9_"=\s(),;:\[\]<>&\|?]*)';
111 our $interfaceMethodSelector = '\s*((?:' . $extendedAttributeSyntax . ' )?)(static\s+)?' . $supportedTypes . '\s*(' . $idlIdNs . '*)\s*\(\s*([a-zA-Z0-9:\s,=\[\]<>?]*)';
112 our $interfaceParameterSelector = '(in|out)\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . $supportedTypeSuffix . '\s*(' . $idlIdNs . '*)';
113
114 our $interfaceAttributeSelector = '\s*(static\s+)?(readonly attribute|attribute)\s*(' . $extendedAttributeSyntax . ' )?' . $supportedTypes . '\s*(' . $idlType . '*)';
115
116 1;