| OLD | NEW |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 'core/dom/Document.h', | 58 'core/dom/Document.h', |
| 59 'platform/TraceEvent.h', | 59 'platform/TraceEvent.h', |
| 60 'wtf/UnusedParam.h', | 60 'wtf/UnusedParam.h', |
| 61 ]) | 61 ]) |
| 62 | 62 |
| 63 | 63 |
| 64 def generate_interface(interface): | 64 def generate_interface(interface): |
| 65 includes.clear() | 65 includes.clear() |
| 66 includes.update(INTERFACE_CPP_INCLUDES) | 66 includes.update(INTERFACE_CPP_INCLUDES) |
| 67 extended_attributes = interface.extended_attributes | 67 extended_attributes = interface.extended_attributes |
| 68 v8_class_name = v8_utilities.v8_class_name(interface) | |
| 69 | 68 |
| 70 # [CheckSecurity] | 69 # [CheckSecurity] |
| 71 is_check_security = 'CheckSecurity' in extended_attributes | 70 is_check_security = 'CheckSecurity' in extended_attributes |
| 72 if is_check_security: | 71 if is_check_security: |
| 73 includes.update(['bindings/v8/BindingSecurity.h', | 72 includes.update(['bindings/v8/BindingSecurity.h', |
| 74 'bindings/v8/ExceptionMessages.h', | 73 'bindings/v8/ExceptionMessages.h', |
| 75 'bindings/v8/ExceptionState.h']) | 74 'bindings/v8/ExceptionState.h']) |
| 76 | 75 |
| 77 # [GenerateVisitDOMWrapper] | 76 # [GenerateVisitDOMWrapper] |
| 78 generate_visit_dom_wrapper_function = extended_attributes.get('GenerateVisit
DOMWrapper') | 77 generate_visit_dom_wrapper_function = extended_attributes.get('GenerateVisit
DOMWrapper') |
| 79 if generate_visit_dom_wrapper_function: | 78 if generate_visit_dom_wrapper_function: |
| 80 includes.update(['bindings/v8/V8GCController.h', | 79 includes.update(['bindings/v8/V8GCController.h', |
| 81 'core/dom/Element.h']) | 80 'core/dom/Element.h']) |
| 82 | 81 |
| 83 template_contents = { | 82 template_contents = { |
| 84 'conditional_string': conditional_string(interface), # [Conditional] | 83 'conditional_string': conditional_string(interface), # [Conditional] |
| 85 'cpp_class_name': cpp_name(interface), | 84 'cpp_class': cpp_name(interface), |
| 86 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi
on, | 85 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi
on, |
| 87 'has_custom_legacy_call': 'CustomLegacyCall' in extended_attributes, #
[CustomLegacyCall] | 86 'has_custom_legacy_call': 'CustomLegacyCall' in extended_attributes, #
[CustomLegacyCall] |
| 88 'has_custom_wrap': 'CustomWrap' in extended_attributes, # [CustomWrap] | 87 'has_custom_wrap': 'CustomWrap' in extended_attributes, # [CustomWrap] |
| 89 'has_visit_dom_wrapper': has_extended_attribute(interface, | 88 'has_visit_dom_wrapper': has_extended_attribute(interface, |
| 90 ['CustomVisitDOMWrapper', 'GenerateVisitDOMWrapper']), | 89 ['CustomVisitDOMWrapper', 'GenerateVisitDOMWrapper']), |
| 91 'header_includes': INTERFACE_H_INCLUDES, | 90 'header_includes': INTERFACE_H_INCLUDES, |
| 92 'interface_name': interface.name, | 91 'interface_name': interface.name, |
| 93 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [Ac
tiveDOMObject] | 92 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [Ac
tiveDOMObject] |
| 94 'is_check_security': is_check_security, | 93 'is_check_security': is_check_security, |
| 95 'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, #
[DependentLifetime] | 94 'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, #
[DependentLifetime] |
| 96 'v8_class_name': v8_class_name, | 95 'v8_class': v8_utilities.v8_class_name(interface), |
| 97 } | 96 } |
| 98 | 97 |
| 99 template_contents.update({ | 98 template_contents.update({ |
| 100 'constants': [generate_constant(constant) for constant in interface.cons
tants], | 99 'constants': [generate_constant(constant) for constant in interface.cons
tants], |
| 101 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, | 100 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, |
| 102 }) | 101 }) |
| 103 | 102 |
| 104 attributes = [v8_attributes.generate_attribute(interface, attribute) | 103 attributes = [v8_attributes.generate_attribute(interface, attribute) |
| 105 for attribute in interface.attributes] | 104 for attribute in interface.attributes] |
| 106 template_contents.update({ | 105 template_contents.update({ |
| 107 'attributes': attributes, | 106 'attributes': attributes, |
| 108 'has_accessors': any(attribute['is_expose_js_accessors'] for attribute i
n attributes), | 107 'has_accessors': any(attribute['is_expose_js_accessors'] for attribute i
n attributes), |
| 109 'has_constructor_attributes': any(attribute['constructor_type'] for attr
ibute in attributes), | 108 'has_constructor_attributes': any(attribute['constructor_type'] for attr
ibute in attributes), |
| 110 'has_per_context_enabled_attributes': any(attribute['per_context_enabled
_function_name'] for attribute in attributes), | 109 'has_per_context_enabled_attributes': any(attribute['per_context_enabled
_function'] for attribute in attributes), |
| 111 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib
ute in attributes), | 110 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib
ute in attributes), |
| 112 }) | 111 }) |
| 113 | 112 |
| 114 methods = [v8_methods.generate_method(interface, method) | 113 methods = [v8_methods.generate_method(interface, method) |
| 115 for method in interface.operations] | 114 for method in interface.operations] |
| 116 generate_overloads(methods) | 115 generate_overloads(methods) |
| 117 for method in methods: | 116 for method in methods: |
| 118 method['do_generate_method_configuration'] = ( | 117 method['do_generate_method_configuration'] = ( |
| 119 method['do_not_check_signature'] and | 118 method['do_not_check_signature'] and |
| 120 not method['per_context_enabled_function_name'] and | 119 not method['per_context_enabled_function'] and |
| 121 # For overloaded methods, only generate one accessor | 120 # For overloaded methods, only generate one accessor |
| 122 ('overload_index' not in method or method['overload_index'] == 1)) | 121 ('overload_index' not in method or method['overload_index'] == 1)) |
| 123 | 122 |
| 124 template_contents.update({ | 123 template_contents.update({ |
| 125 'has_origin_safe_method_setter': any( | 124 'has_origin_safe_method_setter': any( |
| 126 method['is_check_security_for_frame'] and not method['is_read_only'] | 125 method['is_check_security_for_frame'] and not method['is_read_only'] |
| 127 for method in methods), | 126 for method in methods), |
| 128 'has_method_configuration': any(method['do_generate_method_configuration
'] for method in methods), | 127 'has_method_configuration': any(method['do_generate_method_configuration
'] for method in methods), |
| 129 'has_per_context_enabled_methods': any(method['per_context_enabled_funct
ion_name'] for method in methods), | 128 'has_per_context_enabled_methods': any(method['per_context_enabled_funct
ion'] for method in methods), |
| 130 'methods': methods, | 129 'methods': methods, |
| 131 }) | 130 }) |
| 132 | 131 |
| 133 return template_contents | 132 return template_contents |
| 134 | 133 |
| 135 | 134 |
| 136 # [DeprecateAs], [Reflect], [RuntimeEnabled] | 135 # [DeprecateAs], [Reflect], [RuntimeEnabled] |
| 137 def generate_constant(constant): | 136 def generate_constant(constant): |
| 138 # (Blink-only) string literals are unquoted in tokenizer, must be re-quoted | 137 # (Blink-only) string literals are unquoted in tokenizer, must be re-quoted |
| 139 # in C++. | 138 # in C++. |
| 140 if constant.idl_type == 'DOMString': | 139 if constant.idl_type == 'DOMString': |
| 141 value = '"%s"' % constant.value | 140 value = '"%s"' % constant.value |
| 142 else: | 141 else: |
| 143 value = constant.value | 142 value = constant.value |
| 144 | 143 |
| 145 constant_parameter = { | 144 constant_parameter = { |
| 146 'name': constant.name, | 145 'name': constant.name, |
| 147 # FIXME: use 'reflected_name' as correct 'name' | 146 # FIXME: use 'reflected_name' as correct 'name' |
| 148 'reflected_name': constant.extended_attributes.get('Reflect', constant.n
ame), | 147 'reflected_name': constant.extended_attributes.get('Reflect', constant.n
ame), |
| 149 'runtime_enabled_function_name': runtime_enabled_function_name(constant)
, | 148 'runtime_enabled_function': runtime_enabled_function_name(constant), |
| 150 'value': value, | 149 'value': value, |
| 151 } | 150 } |
| 152 return constant_parameter | 151 return constant_parameter |
| 153 | 152 |
| 154 | 153 |
| 155 def generate_overloads(methods): | 154 def generate_overloads(methods): |
| 156 generate_overloads_by_type(methods, is_static=False) # Regular methods | 155 generate_overloads_by_type(methods, is_static=False) # Regular methods |
| 157 generate_overloads_by_type(methods, is_static=True) | 156 generate_overloads_by_type(methods, is_static=True) |
| 158 | 157 |
| 159 | 158 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 '%s->IsString()' % cpp_value, | 251 '%s->IsString()' % cpp_value, |
| 253 '%s->IsObject()' % cpp_value]) | 252 '%s->IsObject()' % cpp_value]) |
| 254 if v8_types.array_or_sequence_type(idl_type): | 253 if v8_types.array_or_sequence_type(idl_type): |
| 255 return '%s->IsArray()' % cpp_value | 254 return '%s->IsArray()' % cpp_value |
| 256 if v8_types.is_wrapper_type(idl_type): | 255 if v8_types.is_wrapper_type(idl_type): |
| 257 type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate(),
worldType(info.GetIsolate()))'.format(idl_type=idl_type, cpp_value=cpp_value) | 256 type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate(),
worldType(info.GetIsolate()))'.format(idl_type=idl_type, cpp_value=cpp_value) |
| 258 if argument['is_nullable']: | 257 if argument['is_nullable']: |
| 259 type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) | 258 type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) |
| 260 return type_check | 259 return type_check |
| 261 return None | 260 return None |
| OLD | NEW |