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 17 matching lines...) Expand all Loading... | |
| 28 | 28 |
| 29 """Generate Blink V8 bindings (.h and .cpp files). | 29 """Generate Blink V8 bindings (.h and .cpp files). |
| 30 | 30 |
| 31 Input: An object of class IdlDefinitions, containing an IDL interface X | 31 Input: An object of class IdlDefinitions, containing an IDL interface X |
| 32 Output: V8X.h and V8X.cpp | 32 Output: V8X.h and V8X.cpp |
| 33 """ | 33 """ |
| 34 | 34 |
| 35 import os | 35 import os |
| 36 import posixpath | 36 import posixpath |
| 37 import re | 37 import re |
| 38 import struct | |
| 38 import sys | 39 import sys |
| 39 | 40 |
| 40 # jinja2 is in chromium's third_party directory. | 41 # jinja2 is in chromium's third_party directory. |
| 41 module_path, module_name = os.path.split(__file__) | 42 module_path, module_name = os.path.split(__file__) |
| 42 third_party = os.path.join(module_path, os.pardir, os.pardir, os.pardir, os.pard ir) | 43 third_party = os.path.join(module_path, os.pardir, os.pardir, os.pardir, os.pard ir) |
| 43 sys.path.append(third_party) | 44 sys.path.append(third_party) |
| 44 import jinja2 | 45 import jinja2 |
| 45 | 46 |
| 46 | 47 |
| 48 ACRONYMS = ['CSS', 'HTML', 'IME', 'JS', 'SVG', 'URL', 'XML', 'XSLT'] | |
| 47 CALLBACK_INTERFACE_CPP_INCLUDES = set([ | 49 CALLBACK_INTERFACE_CPP_INCLUDES = set([ |
| 48 'core/dom/ScriptExecutionContext.h', | 50 'core/dom/ScriptExecutionContext.h', |
| 49 'bindings/v8/V8Binding.h', | 51 'bindings/v8/V8Binding.h', |
| 50 'bindings/v8/V8Callback.h', | 52 'bindings/v8/V8Callback.h', |
| 51 'wtf/Assertions.h', | 53 'wtf/Assertions.h', |
| 52 ]) | 54 ]) |
| 53 | |
| 54 | |
| 55 CALLBACK_INTERFACE_H_INCLUDES = set([ | 55 CALLBACK_INTERFACE_H_INCLUDES = set([ |
| 56 'bindings/v8/ActiveDOMCallback.h', | 56 'bindings/v8/ActiveDOMCallback.h', |
| 57 'bindings/v8/DOMWrapperWorld.h', | 57 'bindings/v8/DOMWrapperWorld.h', |
| 58 'bindings/v8/ScopedPersistent.h', | 58 'bindings/v8/ScopedPersistent.h', |
| 59 ]) | 59 ]) |
| 60 | |
| 61 | |
| 62 INTERFACE_CPP_INCLUDES = set([ | 60 INTERFACE_CPP_INCLUDES = set([ |
| 63 'RuntimeEnabledFeatures.h', | 61 'RuntimeEnabledFeatures.h', |
| 64 'bindings/v8/ScriptController.h', | 62 'bindings/v8/ScriptController.h', |
| 65 'bindings/v8/V8Binding.h', | 63 'bindings/v8/V8Binding.h', |
| 64 'bindings/v8/V8DOMWrapper.h', | |
| 65 'bindings/v8/V8DOMConfiguration.h', | |
| 66 'core/dom/ContextFeatures.h', | 66 'core/dom/ContextFeatures.h', |
| 67 'core/dom/Document.h', | 67 'core/dom/Document.h', |
| 68 'core/page/Frame.h', | 68 'core/page/Frame.h', |
| 69 'core/platform/chromium/TraceEvent.h', | 69 'core/platform/chromium/TraceEvent.h', |
| 70 'wtf/UnusedParam.h', | 70 'wtf/UnusedParam.h', |
| 71 ]) | 71 ]) |
| 72 | |
| 73 | |
| 74 INTERFACE_H_INCLUDES = set([ | 72 INTERFACE_H_INCLUDES = set([ |
| 75 'bindings/v8/V8Binding.h', | 73 'bindings/v8/V8Binding.h', |
| 74 'bindings/v8/V8DOMWrapper.h', | |
| 75 'bindings/v8/WrapperTypeInfo.h', | |
| 76 ]) | 76 ]) |
| 77 | |
| 78 | |
| 79 CPP_TYPE_SPECIAL_CONVERSION_RULES = { | 77 CPP_TYPE_SPECIAL_CONVERSION_RULES = { |
| 80 'float': 'float', | 78 'float': 'float', |
| 81 'double': 'double', | 79 'double': 'double', |
| 82 'long long': 'long long', | 80 'long long': 'long long', |
| 83 'unsigned long long': 'unsigned long long', | 81 'unsigned long long': 'unsigned long long', |
| 84 'long': 'int', | 82 'long': 'int', |
| 85 'short': 'int', | 83 'short': 'int', |
| 86 'byte': 'int', | 84 'byte': 'int', |
| 87 'boolean': 'bool', | 85 'boolean': 'bool', |
| 88 'DOMString': 'const String&', | 86 'DOMString': 'const String&', |
| 89 } | 87 } |
| 90 | 88 CPP_UNSIGNED_TYPES = set([ |
| 91 | 89 'octet', |
| 90 'unsigned int', | |
| 91 'unsigned long', | |
| 92 'unsigned short', | |
| 93 ]) | |
| 92 PRIMITIVE_TYPES = set([ | 94 PRIMITIVE_TYPES = set([ |
| 93 'boolean', | 95 'boolean', |
| 94 'void', | 96 'void', |
| 95 'Date', | 97 'Date', |
| 96 'byte', | 98 'byte', |
| 97 'octet', | 99 'octet', |
| 98 'short', | 100 'short', |
| 99 'long', | 101 'long', |
| 100 'long long', | 102 'long long', |
| 101 'unsigned short', | 103 'unsigned short', |
| 102 'unsigned long', | 104 'unsigned long', |
| 103 'unsigned long long', | 105 'unsigned long long', |
| 104 'float', | 106 'float', |
| 105 'double', | 107 'double', |
| 106 ]) | 108 ]) |
| 109 CPP_VALUE_TO_JS_VALUE_RETURN_DICT = { | |
|
haraken
2013/08/22 07:31:33
JS_VALUE => V8_VALUE
We're mixing "js" and "v8".
Nils Barth (inactive)
2013/08/22 09:08:13
Got it; changed throughout.
| |
| 110 'unsigned': 'v8SetReturnValueUnsigned({callback_info}, {cpp_value});', | |
| 111 } | |
| 107 | 112 |
| 108 | 113 |
| 109 def apply_template(path_to_template, contents): | 114 def apply_template(path_to_template, contents): |
| 110 dirname, basename = os.path.split(path_to_template) | 115 dirname, basename = os.path.split(path_to_template) |
| 111 jinja_env = jinja2.Environment(trim_blocks=True, loader=jinja2.FileSystemLoa der([dirname])) | 116 jinja_env = jinja2.Environment(trim_blocks=True, loader=jinja2.FileSystemLoa der([dirname])) |
| 112 template = jinja_env.get_template(basename) | 117 template = jinja_env.get_template(basename) |
| 113 return template.render(contents) | 118 return template.render(contents) |
| 114 | 119 |
| 115 | 120 |
| 116 def cpp_value_to_js_value(data_type, cpp_value, isolate, creation_context=''): | 121 def cpp_value_to_js_value(data_type, cpp_value, isolate, creation_context=''): |
| 117 """Returns a expression that represent JS value corresponding to a C++ value .""" | 122 """Returns a expression that represent JS value corresponding to a C++ value .""" |
| 118 if data_type == 'boolean': | 123 if data_type == 'boolean': |
| 119 return 'v8Boolean(%s, %s)' % (cpp_value, isolate) | 124 return 'v8Boolean(%s, %s)' % (cpp_value, isolate) |
| 120 if data_type in ['long long', 'unsigned long long', 'DOMTimeStamp']: | 125 if data_type in ['long long', 'unsigned long long', 'DOMTimeStamp']: |
| 121 # long long and unsigned long long are not representable in ECMAScript. | 126 # long long and unsigned long long are not representable in ECMAScript. |
| 122 return 'v8::Number::New(static_cast<double>(%s))' % cpp_value | 127 return 'v8::Number::New(static_cast<double>(%s))' % cpp_value |
| 123 if primitive_type(data_type): | 128 if primitive_type(data_type): |
| 124 if data_type not in ['float', 'double']: | 129 if data_type not in ['float', 'double']: |
| 125 raise Exception('unexpected data_type %s' % data_type) | 130 raise Exception('unexpected data_type %s' % data_type) |
| 126 return 'v8::Number::New(%s)' % cpp_value | 131 return 'v8::Number::New(%s)' % cpp_value |
| 127 if data_type == 'DOMString': | 132 if data_type == 'DOMString': |
| 128 return 'v8String(%s, %s)' % (cpp_value, isolate) | 133 return 'v8String(%s, %s)' % (cpp_value, isolate) |
| 129 if array_or_sequence_type(data_type): | 134 if array_or_sequence_type(data_type): |
| 130 return 'v8Array(%s, %s)' % (cpp_value, isolate) | 135 return 'v8Array(%s, %s)' % (cpp_value, isolate) |
| 131 return 'toV8(%s, %s, %s)' % (cpp_value, creation_context, isolate) | 136 return 'toV8(%s, %s, %s)' % (cpp_value, creation_context, isolate) |
| 132 | 137 |
| 133 | 138 |
| 139 def cpp_value_to_js_value_return(data_type, cpp_value, callback_info=''): | |
|
haraken
2013/08/22 07:31:33
Why don't you simply call this cpp_value_v8_value
Nils Barth (inactive)
2013/08/22 09:08:13
cpp_value_v8_value and cpp_value_v8_value_return a
haraken
2013/08/22 11:05:28
Makes sense. Then set_v8_return_value ?
Nils Barth (inactive)
2013/08/23 01:50:05
Good point; actually, v8_set_return_value seems ev
| |
| 140 """Return an expression converting a C++ value to a JS value, as a return va lue.""" | |
| 141 this_cpp_type = cpp_type(data_type) | |
| 142 if this_cpp_type in CPP_VALUE_TO_JS_VALUE_RETURN_DICT: | |
| 143 expression_format_string = CPP_VALUE_TO_JS_VALUE_RETURN_DICT[this_cpp_ty pe] | |
| 144 else: | |
| 145 raise Exception('unexpected data_type %s' % data_type) | |
| 146 return expression_format_string.format(callback_info=callback_info, cpp_valu e=cpp_value) | |
| 147 | |
| 148 | |
| 134 def generate_conditional_string(interface_or_attribute_or_operation): | 149 def generate_conditional_string(interface_or_attribute_or_operation): |
| 135 if 'Conditional' not in interface_or_attribute_or_operation.extended_attribu tes: | 150 if 'Conditional' not in interface_or_attribute_or_operation.extended_attribu tes: |
| 136 return '' | 151 return '' |
| 137 conditional = interface_or_attribute_or_operation.extended_attributes['Condi tional'] | 152 conditional = interface_or_attribute_or_operation.extended_attributes['Condi tional'] |
| 138 for operator in ['&', '|']: | 153 for operator in ['&', '|']: |
| 139 if operator in conditional: | 154 if operator in conditional: |
| 140 conditions = set(conditional.split(operator)) | 155 conditions = set(conditional.split(operator)) |
| 141 operator_separator = ' %s%s ' % (operator, operator) | 156 operator_separator = ' %s%s ' % (operator, operator) |
| 142 return operator_separator.join(['ENABLE(%s)' % expression for expres sion in sorted(conditions)]) | 157 return operator_separator.join(['ENABLE(%s)' % expression for expres sion in sorted(conditions)]) |
| 143 return 'ENABLE(%s)' % conditional | 158 return 'ENABLE(%s)' % conditional |
| 144 | 159 |
| 145 | 160 |
| 161 def generate_constants(interface): | |
| 162 return [generate_constant(constant) for constant in interface.constants] | |
| 163 | |
| 164 | |
| 165 def generate_constant(constant): | |
| 166 # Extended Attributes: Conditional, DeprecateAs, EnabledAtRuntime, Reflect | |
| 167 # FIXME: Conditional and DeprecateAs are only used in tests, so remove | |
| 168 name = constant.extended_attributes.get('Reflect', constant.name) | |
|
haraken
2013/08/22 07:31:33
name => reflected_name
Nils Barth (inactive)
2013/08/22 09:08:13
Done.
| |
| 169 value_raw = constant.value | |
| 170 # If the value we're dealing with is a hex literal, statically cast it to a | |
| 171 # signed integer here, rather than dynamically casting via | |
| 172 # static_cast<signed int> in the generated code. | |
| 173 # FIXME: why are we casting to signed? | |
| 174 # NodeFilter has unsigned 0xFFFFFFFF, which is converted to -1. | |
| 175 # FIXME: is this necessary? Hex literals are valid C. | |
| 176 # (only semantic difference is casting to signed) | |
| 177 # FIXME: what about octal? decimal? | |
| 178 # FIXME: what if we have a negative literal? | |
| 179 # FIXME: BUG: Perl only checks '0x', not '0X', | |
| 180 # but we have a test case using 0X. | |
| 181 if value_raw.startswith('0x'): | |
| 182 value = struct.unpack('i', struct.pack('I', int(value_raw, 16)))[0] | |
| 183 else: | |
| 184 value = value_raw | |
|
haraken
2013/08/22 07:31:33
I don't fully understand why this is needed. Can w
Nils Barth (inactive)
2013/08/22 09:08:13
I have no idea why this is needed either, hence al
haraken
2013/08/22 11:05:28
OK, then let's fix it in a follow-up CL.
Nils Barth (inactive)
2013/08/23 01:50:05
Got it!
| |
| 185 | |
| 186 constant_parameter = { | |
| 187 'name': constant.name, | |
| 188 'name_reflect': name, # FIXME: use name_reflect as correct 'name' | |
|
haraken
2013/08/22 07:31:33
name_reflect => reflected_name
Nils Barth (inactive)
2013/08/22 09:08:13
Done.
| |
| 189 'value': value, | |
| 190 'value_raw': value_raw, | |
| 191 # FIXME: remove conditional: only used in tests | |
| 192 'conditional_string': generate_conditional_string(constant), | |
| 193 'enabled_at_runtime': 'EnabledAtRuntime' in constant.extended_attributes , | |
| 194 'enable_function': runtime_enable_function_name(constant), | |
| 195 } | |
| 196 return constant_parameter | |
| 197 | |
| 198 | |
| 199 def getter_expression(interface, attribute): | |
|
haraken
2013/08/22 07:31:33
getter_expression => attribute_getter_name ?
You
Nils Barth (inactive)
2013/08/22 09:08:13
attribute_getter is redundant; good point about na
haraken
2013/08/22 11:05:28
If this function is going to be used by other gett
Nils Barth (inactive)
2013/08/23 01:50:05
Looking at this more, at this point there's no nee
| |
| 200 # FIXME: very incomplete | |
| 201 return 'imp->%s()' % uncapitalize(attribute.name) | |
| 202 | |
| 203 | |
| 204 def runtime_enable_function_name(definition_or_member): | |
| 205 """Return the name of the RuntimeEnabledFeatures function. | |
| 206 | |
| 207 The returned function checks if a method/attribute is enabled. | |
| 208 If a parameter is given (e.g. 'EnabledAtRuntime=FeatureName'), return: | |
| 209 RuntimeEnabledFeatures::{featureName}Enabled | |
| 210 Otherwise return: | |
| 211 RuntimeEnabledFeatures::{methodName}Enabled | |
| 212 """ | |
| 213 name = definition_or_member.extended_attributes.get('EnabledAtRuntime') or d efinition_or_member.name | |
| 214 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(name) | |
| 215 | |
| 216 | |
| 217 def uncapitalize(name): | |
| 218 """Uncapitalize first letter or initial acronym (* with some exceptions). | |
| 219 | |
| 220 E.g., 'SetURL' becomes 'setURL', but 'URLFoo' becomes 'urlFoo'. | |
| 221 Used in method names; exceptions differ from capitalize(). | |
| 222 """ | |
| 223 for acronym in ACRONYMS: | |
| 224 if name.startswith(acronym): | |
| 225 name.replace(acronym, acronym.lower()) | |
| 226 return name | |
| 227 return name[0].lower() + name[1:] | |
| 228 | |
| 229 | |
| 146 def includes_for_type(data_type): | 230 def includes_for_type(data_type): |
| 147 if primitive_type(data_type) or data_type == 'DOMString': | 231 if primitive_type(data_type) or data_type == 'DOMString': |
| 148 return set() | 232 return set() |
| 149 if array_or_sequence_type(data_type): | 233 if array_or_sequence_type(data_type): |
| 150 return includes_for_type(array_or_sequence_type(data_type)) | 234 return includes_for_type(array_or_sequence_type(data_type)) |
| 151 return set(['V8%s.h' % data_type]) | 235 return set(['V8%s.h' % data_type]) |
| 152 | 236 |
| 153 | 237 |
| 154 def includes_for_cpp_class(class_name, relative_dir_posix): | 238 def includes_for_cpp_class(class_name, relative_dir_posix): |
| 155 return set([posixpath.join('bindings', relative_dir_posix, class_name + '.h' )]) | 239 return set([posixpath.join('bindings', relative_dir_posix, class_name + '.h' )]) |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 176 def array_type(data_type): | 260 def array_type(data_type): |
| 177 matched = re.match(r'([\w\d_\s]+)\[\]', data_type) | 261 matched = re.match(r'([\w\d_\s]+)\[\]', data_type) |
| 178 if not matched: | 262 if not matched: |
| 179 return None | 263 return None |
| 180 return matched.group(1) | 264 return matched.group(1) |
| 181 | 265 |
| 182 | 266 |
| 183 def array_or_sequence_type(data_type): | 267 def array_or_sequence_type(data_type): |
| 184 return array_type(data_type) or sequence_type(data_type) | 268 return array_type(data_type) or sequence_type(data_type) |
| 185 | 269 |
| 186 def cpp_type(data_type, pointer_type): | 270 |
| 271 def cpp_type(data_type, pointer_type=None): | |
| 187 """Returns the C++ type corresponding to the IDL type. | 272 """Returns the C++ type corresponding to the IDL type. |
| 188 | 273 |
| 189 Args: | 274 Args: |
| 190 pointer_type: | 275 pointer_type: |
|
kouhei (in TOK)
2013/08/22 06:14:32
add doc for None?
None: return raw value form (e.g
Nils Barth (inactive)
2013/08/22 06:33:48
Good point!
Fixed (in more detail).
I made this op
| |
| 191 'raw': return raw pointer form (e.g. Foo*) | 276 'raw': return raw pointer form (e.g. Foo*) |
| 192 'RefPtr': return RefPtr form (e.g. RefPtr<Foo>) | 277 'RefPtr': return RefPtr form (e.g. RefPtr<Foo>) |
| 193 'PassRefPtr': return PassRefPtr form (e.g. RefPtr<Foo>) | 278 'PassRefPtr': return PassRefPtr form (e.g. RefPtr<Foo>) |
| 194 """ | 279 """ |
| 195 if data_type in CPP_TYPE_SPECIAL_CONVERSION_RULES: | 280 if data_type in CPP_TYPE_SPECIAL_CONVERSION_RULES: |
| 196 return CPP_TYPE_SPECIAL_CONVERSION_RULES[data_type] | 281 return CPP_TYPE_SPECIAL_CONVERSION_RULES[data_type] |
| 282 if data_type in CPP_UNSIGNED_TYPES: | |
| 283 return 'unsigned' | |
| 197 if array_or_sequence_type(data_type): | 284 if array_or_sequence_type(data_type): |
| 198 return 'const Vector<%s >&' % cpp_type(array_or_sequence_type(data_type) , 'RefPtr') | 285 return 'const Vector<%s >&' % cpp_type(array_or_sequence_type(data_type) , 'RefPtr') |
| 199 if pointer_type == 'raw': | 286 if pointer_type == 'raw': |
| 200 return data_type + '*' | 287 return data_type + '*' |
| 201 if pointer_type in ['RefPtr', 'PassRefPtr']: | 288 if pointer_type in ['RefPtr', 'PassRefPtr']: |
| 202 return '%s<%s>' % (pointer_type, data_type) | 289 return '%s<%s>' % (pointer_type, data_type) |
| 203 raise Exception('Unrecognized pointer type: "%s"' % pointer_type) | 290 raise Exception('Unrecognized pointer type: "%s"' % pointer_type) |
| 204 | 291 |
| 205 | 292 |
| 206 def v8_type(data_type): | 293 def v8_type(data_type): |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 header_filename = os.path.join(self.output_directory, header_basename) | 368 header_filename = os.path.join(self.output_directory, header_basename) |
| 282 with open(header_filename, 'w') as header_file: | 369 with open(header_filename, 'w') as header_file: |
| 283 header_file.write(header_file_text) | 370 header_file.write(header_file_text) |
| 284 | 371 |
| 285 def write_cpp_code(self, cpp_basename, cpp_file_text): | 372 def write_cpp_code(self, cpp_basename, cpp_file_text): |
| 286 cpp_filename = os.path.join(self.output_directory, cpp_basename) | 373 cpp_filename = os.path.join(self.output_directory, cpp_basename) |
| 287 with open(cpp_filename, 'w') as cpp_file: | 374 with open(cpp_filename, 'w') as cpp_file: |
| 288 cpp_file.write(cpp_file_text) | 375 cpp_file.write(cpp_file_text) |
| 289 | 376 |
| 290 def generate_attribute(self, attribute): | 377 def generate_attribute(self, attribute): |
| 291 self.cpp_includes |= includes_for_type(attribute.data_type) | 378 data_type = attribute.data_type |
| 379 # FIXME: need to check should_keep_attribute_alive, but for now | |
| 380 # sufficient to check if primitive. | |
| 381 should_keep_attribute_alive = not primitive_type(data_type) | |
| 382 # FIXME: eliminate should_keep_attribute_alive | |
|
haraken
2013/08/22 07:31:33
Remove the FIXME. We will need should_keep_attribu
Nils Barth (inactive)
2013/08/22 09:08:13
Got it!
(There was a FIXME asking to remove it, bu
| |
| 383 if should_keep_attribute_alive: | |
| 384 return_js_value_statement = None # unused | |
| 385 self.cpp_includes |= includes_for_type(data_type) | |
| 386 self.cpp_includes.add('bindings/v8/V8HiddenPropertyName.h') | |
| 387 else: | |
| 388 cpp_value = getter_expression(self.interface, attribute) | |
| 389 return_js_value_statement = cpp_value_to_js_value_return(data_type, cpp_value, callback_info='info') | |
| 292 return { | 390 return { |
| 293 'name': attribute.name, | 391 'name': attribute.name, |
| 294 'conditional_string': generate_conditional_string(attribute), | 392 'conditional_string': generate_conditional_string(attribute), |
| 295 'cpp_method_name': cpp_method_name(attribute), | 393 'cpp_method_name': cpp_method_name(attribute), |
| 296 'cpp_type': cpp_type(attribute.data_type, pointer_type='RefPtr'), | 394 'cpp_type': cpp_type(data_type, pointer_type='RefPtr'), |
| 297 'v8_type': v8_type(attribute.data_type), | 395 'should_keep_attribute_alive': should_keep_attribute_alive, |
| 396 'return_js_value_statement': return_js_value_statement, | |
| 397 'v8_type': v8_type(data_type), | |
| 298 } | 398 } |
| 299 | 399 |
| 300 def generate_interface(self): | 400 def generate_interface(self): |
| 301 self.header_includes = INTERFACE_H_INCLUDES | 401 self.header_includes = INTERFACE_H_INCLUDES |
| 302 self.header_includes |= includes_for_cpp_class(cpp_class_name(self.inter face), self.relative_dir_posix) | 402 self.header_includes |= includes_for_cpp_class(cpp_class_name(self.inter face), self.relative_dir_posix) |
| 303 self.cpp_includes = INTERFACE_CPP_INCLUDES | 403 self.cpp_includes = INTERFACE_CPP_INCLUDES |
| 304 | 404 |
| 305 template_contents = { | 405 template_contents = { |
| 306 'interface_name': self.interface.name, | 406 'interface_name': self.interface.name, |
| 307 'cpp_class_name': cpp_class_name(self.interface), | 407 'cpp_class_name': cpp_class_name(self.interface), |
| 308 'v8_class_name': v8_class_name(self.interface), | 408 'v8_class_name': v8_class_name(self.interface), |
| 309 'attributes': [self.generate_attribute(attribute) for attribute in s elf.interface.attributes], | 409 'attributes': [self.generate_attribute(attribute) for attribute in s elf.interface.attributes], |
| 310 # Size 0 constant array is not allowed in VC++ | 410 # Size 0 constant array is not allowed in VC++ |
| 311 'number_of_attributes': 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class_ name(self.interface) if self.interface.attributes else '0', | 411 'number_of_attributes': 'WTF_ARRAY_LENGTH(%sAttrs)' % v8_class_name( self.interface) if self.interface.attributes else '0', |
| 312 'attribute_templates': v8_class_name(self.interface) + 'Attributes' if self.interface.attributes else '0', | 412 'attribute_templates': v8_class_name(self.interface) + 'Attrs' if se lf.interface.attributes else '0', |
| 313 } | 413 } |
| 414 template_contents['constants'] = generate_constants(self.interface) | |
| 314 # Add includes afterwards, as they are modified by generate_attribute et c. | 415 # Add includes afterwards, as they are modified by generate_attribute et c. |
| 315 template_contents['header_includes'] = sorted(list(self.header_includes) ) | 416 template_contents['header_includes'] = sorted(list(self.header_includes) ) |
| 316 template_contents['cpp_includes'] = sorted(list(self.cpp_includes)) | 417 template_contents['cpp_includes'] = sorted(list(self.cpp_includes)) |
| 317 return template_contents | 418 return template_contents |
| 318 | 419 |
| 319 def generate_callback_interface(self): | 420 def generate_callback_interface(self): |
| 320 self.header_includes = CALLBACK_INTERFACE_H_INCLUDES | 421 self.header_includes = CALLBACK_INTERFACE_H_INCLUDES |
| 321 self.header_includes |= includes_for_cpp_class(cpp_class_name(self.inter face), self.relative_dir_posix) | 422 self.header_includes |= includes_for_cpp_class(cpp_class_name(self.inter face), self.relative_dir_posix) |
| 322 self.cpp_includes = CALLBACK_INTERFACE_CPP_INCLUDES | 423 self.cpp_includes = CALLBACK_INTERFACE_CPP_INCLUDES |
| 323 | 424 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 352 | 453 |
| 353 methods = [generate_method(operation) for operation in self.interface.op erations] | 454 methods = [generate_method(operation) for operation in self.interface.op erations] |
| 354 template_contents = { | 455 template_contents = { |
| 355 'cpp_class_name': self.interface.name, | 456 'cpp_class_name': self.interface.name, |
| 356 'v8_class_name': v8_class_name(self.interface), | 457 'v8_class_name': v8_class_name(self.interface), |
| 357 'cpp_includes': sorted(list(self.cpp_includes)), | 458 'cpp_includes': sorted(list(self.cpp_includes)), |
| 358 'header_includes': sorted(list(self.header_includes)), | 459 'header_includes': sorted(list(self.header_includes)), |
| 359 'methods': methods, | 460 'methods': methods, |
| 360 } | 461 } |
| 361 return template_contents | 462 return template_contents |
| OLD | NEW |