Chromium Code Reviews| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) | 68 v8_class_name = v8_utilities.v8_class_name(interface) |
| 69 | 69 |
| 70 is_check_security = 'CheckSecurity' in extended_attributes | |
| 71 if is_check_security: | |
| 72 includes.update(['bindings/v8/BindingSecurity.h', | |
| 73 'bindings/v8/ExceptionMessages.h', | |
| 74 'bindings/v8/ExceptionState.h']) | |
| 75 | |
| 70 template_contents = { | 76 template_contents = { |
| 71 'cpp_class_name': cpp_name(interface), | 77 'cpp_class_name': cpp_name(interface), |
| 72 'header_includes': INTERFACE_H_INCLUDES, | 78 'header_includes': INTERFACE_H_INCLUDES, |
| 73 'interface_name': interface.name, | 79 'interface_name': interface.name, |
| 74 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, | 80 'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, |
| 81 'is_check_security': is_check_security, | |
| 75 'v8_class_name': v8_class_name, | 82 'v8_class_name': v8_class_name, |
| 76 } | 83 } |
| 77 | 84 |
| 78 template_contents.update({ | 85 template_contents.update({ |
| 79 'constants': [generate_constant(constant) for constant in interface.cons tants], | 86 'constants': [generate_constant(constant) for constant in interface.cons tants], |
| 80 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, | 87 'do_not_check_constants': 'DoNotCheckConstants' in extended_attributes, |
| 81 }) | 88 }) |
| 82 | 89 |
| 83 attributes = [v8_attributes.generate_attribute(interface, attribute) | 90 attributes = [v8_attributes.generate_attribute(interface, attribute) |
| 84 for attribute in interface.attributes] | 91 for attribute in interface.attributes] |
| 85 template_contents.update({ | 92 template_contents.update({ |
| 86 'attributes': attributes, | 93 'attributes': attributes, |
| 87 'has_accessors': any(attribute['is_expose_js_accessors'] for attribute i n attributes), | 94 'has_accessors': any(attribute['is_expose_js_accessors'] for attribute i n attributes), |
| 88 'has_constructor_attributes': any(attribute['constructor_type'] for attr ibute in attributes), | 95 'has_constructor_attributes': any(attribute['constructor_type'] for attr ibute in attributes), |
| 89 'has_per_context_enabled_attributes': any(attribute['per_context_enabled _function_name'] for attribute in attributes), | 96 'has_per_context_enabled_attributes': any(attribute['per_context_enabled _function_name'] for attribute in attributes), |
| 90 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib ute in attributes), | 97 'has_replaceable_attributes': any(attribute['is_replaceable'] for attrib ute in attributes), |
| 91 }) | 98 }) |
| 92 | 99 |
| 93 methods = [v8_methods.generate_method(interface, method) | 100 methods = [v8_methods.generate_method(interface, method) |
| 94 for method in interface.operations] | 101 for method in interface.operations] |
| 95 generate_overloads(methods) | 102 generate_overloads(methods) |
| 96 template_contents.update({ | 103 template_contents.update({ |
| 97 'has_per_context_enabled_methods': any(method['per_context_enabled_funct ion_name'] for method in methods), | 104 'has_per_context_enabled_methods': any(method['per_context_enabled_funct ion_name'] for method in methods), |
| 98 'methods': methods, | 105 'methods': methods, |
| 106 'standard_methods': | |
|
Nils Barth (inactive)
2013/11/19 06:56:06
Moved from templates to here b/c need to do an ove
haraken
2013/11/19 07:05:06
standard_methods => has_standard_method ?
BTW, wo
Nils Barth (inactive)
2013/11/19 08:10:09
Rearranged to compute a value for each method,
so
haraken
2013/11/19 08:52:47
It's OK in this CL, but the core issue is we have
haraken
2013/11/19 08:58:05
Supporting indexed/named properties will also add
Nils Barth (inactive)
2013/11/20 06:36:23
The full check is in v8_methods.py:
'do_not_check_
Nils Barth (inactive)
2013/11/20 06:36:23
Got it; let's do it then!
| |
| 107 [method for method in methods if | |
| 108 method['do_not_check_signature'] and | |
| 109 not method['per_context_enabled_function_name'] and | |
| 110 # For overloaded methods, only generate one accessor | |
| 111 ('overload_index' not in method or method['overload_index'] == 1)], | |
| 99 }) | 112 }) |
| 100 | 113 |
| 101 return template_contents | 114 return template_contents |
| 102 | 115 |
| 103 | 116 |
| 104 # [DeprecateAs], [Reflect], [RuntimeEnabled] | 117 # [DeprecateAs], [Reflect], [RuntimeEnabled] |
| 105 def generate_constant(constant): | 118 def generate_constant(constant): |
| 106 # (Blink-only) string literals are unquoted in tokenizer, must be re-quoted | 119 # (Blink-only) string literals are unquoted in tokenizer, must be re-quoted |
| 107 # in C++. | 120 # in C++. |
| 108 if constant.idl_type == 'DOMString': | 121 if constant.idl_type == 'DOMString': |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 '%s->IsString()' % cpp_value, | 233 '%s->IsString()' % cpp_value, |
| 221 '%s->IsObject()' % cpp_value]) | 234 '%s->IsObject()' % cpp_value]) |
| 222 if v8_types.array_or_sequence_type(idl_type): | 235 if v8_types.array_or_sequence_type(idl_type): |
| 223 return '%s->IsArray()' % cpp_value | 236 return '%s->IsArray()' % cpp_value |
| 224 if v8_types.is_wrapper_type(idl_type): | 237 if v8_types.is_wrapper_type(idl_type): |
| 225 type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate(), worldType(info.GetIsolate()))'.format(idl_type=idl_type, cpp_value=cpp_value) | 238 type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate(), worldType(info.GetIsolate()))'.format(idl_type=idl_type, cpp_value=cpp_value) |
| 226 if argument['is_nullable']: | 239 if argument['is_nullable']: |
| 227 type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) | 240 type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) |
| 228 return type_check | 241 return type_check |
| 229 return None | 242 return None |
| OLD | NEW |