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

Side by Side Diff: Source/bindings/scripts/v8_utilities.py

Issue 469243002: IDL: Prefer to extend IdlTypeBase instead of IdlType (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: drop import of IdlType Created 6 years, 4 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
« no previous file with comments | « Source/bindings/scripts/v8_types.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 10 matching lines...) Expand all
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 """Functions shared by various parts of the code generator. 29 """Functions shared by various parts of the code generator.
30 30
31 Extends IdlType and IdlUnion type with |enum_validation_expression| property. 31 Extends IdlTypeBase type with |enum_validation_expression| property.
32 32
33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler 33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
34 """ 34 """
35 35
36 import re 36 import re
37 37
38 from idl_types import IdlType, IdlUnionType 38 from idl_types import IdlTypeBase
39 import idl_types 39 import idl_types
40 from v8_globals import includes 40 from v8_globals import includes
41 import v8_types 41 import v8_types
42 42
43 ACRONYMS = [ 43 ACRONYMS = [
44 'CSSOM', # must come *before* CSS to match full acronym 44 'CSSOM', # must come *before* CSS to match full acronym
45 'CSS', 45 'CSS',
46 'HTML', 46 'HTML',
47 'IME', 47 'IME',
48 'JS', 48 'JS',
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 ################################################################################ 115 ################################################################################
116 # C++ 116 # C++
117 ################################################################################ 117 ################################################################################
118 118
119 def enum_validation_expression(idl_type): 119 def enum_validation_expression(idl_type):
120 # FIXME: Add IdlEnumType, move property to derived type, and remove this che ck 120 # FIXME: Add IdlEnumType, move property to derived type, and remove this che ck
121 if not idl_type.is_enum: 121 if not idl_type.is_enum:
122 return None 122 return None
123 return ' || '.join(['string == "%s"' % enum_value 123 return ' || '.join(['string == "%s"' % enum_value
124 for enum_value in idl_type.enum_values]) 124 for enum_value in idl_type.enum_values])
125 IdlType.enum_validation_expression = property(enum_validation_expression) 125 IdlTypeBase.enum_validation_expression = property(enum_validation_expression)
126 126
127 127
128 def scoped_name(interface, definition, base_name): 128 def scoped_name(interface, definition, base_name):
129 if 'ImplementedInPrivateScript' in definition.extended_attributes: 129 if 'ImplementedInPrivateScript' in definition.extended_attributes:
130 return '%s::PrivateScript::%s' % (v8_class_name(interface), base_name) 130 return '%s::PrivateScript::%s' % (v8_class_name(interface), base_name)
131 # partial interfaces are implemented as separate classes, with their members 131 # partial interfaces are implemented as separate classes, with their members
132 # implemented as static member functions 132 # implemented as static member functions
133 partial_interface_implemented_as = definition.extended_attributes.get('Parti alInterfaceImplementedAs') 133 partial_interface_implemented_as = definition.extended_attributes.get('Parti alInterfaceImplementedAs')
134 if partial_interface_implemented_as: 134 if partial_interface_implemented_as:
135 return '%s::%s' % (partial_interface_implemented_as, base_name) 135 return '%s::%s' % (partial_interface_implemented_as, base_name)
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 324
325 The returned function checks if a method/attribute is enabled. 325 The returned function checks if a method/attribute is enabled.
326 Given extended attribute RuntimeEnabled=FeatureName, return: 326 Given extended attribute RuntimeEnabled=FeatureName, return:
327 RuntimeEnabledFeatures::{featureName}Enabled 327 RuntimeEnabledFeatures::{featureName}Enabled
328 """ 328 """
329 extended_attributes = definition_or_member.extended_attributes 329 extended_attributes = definition_or_member.extended_attributes
330 if 'RuntimeEnabled' not in extended_attributes: 330 if 'RuntimeEnabled' not in extended_attributes:
331 return None 331 return None
332 feature_name = extended_attributes['RuntimeEnabled'] 332 feature_name = extended_attributes['RuntimeEnabled']
333 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) 333 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_types.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698