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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 | 185 |
| 186 contents.update({ | 186 contents.update({ |
| 187 'cpp_value': cpp_value, | 187 'cpp_value': cpp_value, |
| 188 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_ main_world=True), | 188 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_ main_world=True), |
| 189 'v8_set_return_value': v8_set_return_value_statement(), | 189 'v8_set_return_value': v8_set_return_value_statement(), |
| 190 }) | 190 }) |
| 191 | 191 |
| 192 | 192 |
| 193 def getter_expression(interface, attribute, contents): | 193 def getter_expression(interface, attribute, contents): |
| 194 arguments = [] | 194 arguments = [] |
| 195 this_getter_base_name = getter_base_name(attribute, arguments) | 195 this_getter_base_name = getter_base_name(interface, attribute, arguments) |
| 196 getter_name = v8_utilities.scoped_name(interface, attribute, this_getter_bas e_name) | 196 getter_name = v8_utilities.scoped_name(interface, attribute, this_getter_bas e_name) |
| 197 | 197 |
| 198 arguments.extend(v8_utilities.call_with_arguments(attribute)) | 198 arguments.extend(v8_utilities.call_with_arguments(attribute)) |
| 199 if ('ImplementedBy' in attribute.extended_attributes and | 199 if ('ImplementedBy' in attribute.extended_attributes and |
| 200 not attribute.is_static): | 200 not attribute.is_static): |
| 201 arguments.append('*imp') | 201 arguments.append('*imp') |
| 202 if attribute.is_nullable: | 202 if attribute.is_nullable: |
| 203 arguments.append('isNull') | 203 arguments.append('isNull') |
| 204 if contents['is_getter_raises_exception']: | 204 if contents['is_getter_raises_exception']: |
| 205 arguments.append('exceptionState') | 205 arguments.append('exceptionState') |
| 206 return '%s(%s)' % (getter_name, ', '.join(arguments)) | 206 return '%s(%s)' % (getter_name, ', '.join(arguments)) |
| 207 | 207 |
| 208 | 208 |
| 209 CONTENT_ATTRIBUTE_GETTER_NAMES = { | 209 CONTENT_ATTRIBUTE_GETTER_NAMES = { |
| 210 'boolean': 'fastHasAttribute', | 210 'boolean': 'fastHasAttribute', |
| 211 'long': 'getIntegralAttribute', | 211 'long': 'getIntegralAttribute', |
| 212 'unsigned long': 'getUnsignedIntegralAttribute', | 212 'unsigned long': 'getUnsignedIntegralAttribute', |
| 213 } | 213 } |
| 214 | 214 |
| 215 | 215 |
| 216 def getter_base_name(attribute, arguments): | 216 def getter_base_name(interface, attribute, arguments): |
| 217 extended_attributes = attribute.extended_attributes | 217 extended_attributes = attribute.extended_attributes |
| 218 if 'Reflect' not in extended_attributes: | 218 if 'Reflect' not in extended_attributes: |
| 219 return uncapitalize(cpp_name(attribute)) | 219 return uncapitalize(cpp_name(attribute)) |
| 220 | 220 |
| 221 content_attribute_name = extended_attributes['Reflect'] or attribute.name.lo wer() | 221 content_attribute_name = extended_attributes['Reflect'] or attribute.name.lo wer() |
| 222 if content_attribute_name in ['class', 'id', 'name']: | 222 if content_attribute_name in ['class', 'id', 'name']: |
| 223 # Special-case for performance optimization. | 223 # Special-case for performance optimization. |
| 224 return 'get%sAttribute' % content_attribute_name.capitalize() | 224 return 'get%sAttribute' % content_attribute_name.capitalize() |
| 225 | 225 |
| 226 arguments.append(scoped_content_attribute_name(attribute)) | 226 arguments.append(scoped_content_attribute_name(interface, attribute)) |
| 227 | 227 |
| 228 idl_type = attribute.idl_type | 228 idl_type = attribute.idl_type |
| 229 if idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES: | 229 if idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES: |
| 230 return CONTENT_ATTRIBUTE_GETTER_NAMES[idl_type] | 230 return CONTENT_ATTRIBUTE_GETTER_NAMES[idl_type] |
| 231 if 'URL' in attribute.extended_attributes: | 231 if 'URL' in attribute.extended_attributes: |
| 232 return 'getURLAttribute' | 232 return 'getURLAttribute' |
| 233 return 'fastGetAttribute' | 233 return 'fastGetAttribute' |
| 234 | 234 |
| 235 | 235 |
| 236 def is_keep_alive_for_gc(interface, attribute): | 236 def is_keep_alive_for_gc(interface, attribute): |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 'cpp_setter': setter_expression(interface, attribute, contents), | 282 'cpp_setter': setter_expression(interface, attribute, contents), |
| 283 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value( | 283 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value( |
| 284 attribute.idl_type, extended_attributes, 'jsValue', 'cppValue'), | 284 attribute.idl_type, extended_attributes, 'jsValue', 'cppValue'), |
| 285 }) | 285 }) |
| 286 | 286 |
| 287 | 287 |
| 288 def setter_expression(interface, attribute, contents): | 288 def setter_expression(interface, attribute, contents): |
| 289 extended_attributes = attribute.extended_attributes | 289 extended_attributes = attribute.extended_attributes |
| 290 arguments = v8_utilities.call_with_arguments(attribute, extended_attributes. get('SetterCallWith')) | 290 arguments = v8_utilities.call_with_arguments(attribute, extended_attributes. get('SetterCallWith')) |
| 291 | 291 |
| 292 this_setter_base_name = setter_base_name(attribute, arguments) | 292 this_setter_base_name = setter_base_name(interface, attribute, arguments) |
| 293 setter_name = v8_utilities.scoped_name(interface, attribute, this_setter_bas e_name) | 293 setter_name = v8_utilities.scoped_name(interface, attribute, this_setter_bas e_name) |
| 294 | 294 |
| 295 if ('ImplementedBy' in extended_attributes and | 295 if ('ImplementedBy' in extended_attributes and |
| 296 not attribute.is_static): | 296 not attribute.is_static): |
| 297 arguments.append('*imp') | 297 arguments.append('*imp') |
| 298 idl_type = attribute.idl_type | 298 idl_type = attribute.idl_type |
| 299 if idl_type == 'EventHandler': | 299 if idl_type == 'EventHandler': |
| 300 getter_name = v8_utilities.scoped_name(interface, attribute, cpp_name(at tribute)) | 300 getter_name = v8_utilities.scoped_name(interface, attribute, cpp_name(at tribute)) |
| 301 contents['event_handler_getter_expression'] = '%s(%s)' % ( | 301 contents['event_handler_getter_expression'] = '%s(%s)' % ( |
| 302 getter_name, ', '.join(arguments)) | 302 getter_name, ', '.join(arguments)) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 317 return '%s(%s)' % (setter_name, ', '.join(arguments)) | 317 return '%s(%s)' % (setter_name, ', '.join(arguments)) |
| 318 | 318 |
| 319 | 319 |
| 320 CONTENT_ATTRIBUTE_SETTER_NAMES = { | 320 CONTENT_ATTRIBUTE_SETTER_NAMES = { |
| 321 'boolean': 'setBooleanAttribute', | 321 'boolean': 'setBooleanAttribute', |
| 322 'long': 'setIntegralAttribute', | 322 'long': 'setIntegralAttribute', |
| 323 'unsigned long': 'setUnsignedIntegralAttribute', | 323 'unsigned long': 'setUnsignedIntegralAttribute', |
| 324 } | 324 } |
| 325 | 325 |
| 326 | 326 |
| 327 def setter_base_name(attribute, arguments): | 327 def setter_base_name(interface, attribute, arguments): |
| 328 if 'Reflect' not in attribute.extended_attributes: | 328 if 'Reflect' not in attribute.extended_attributes: |
| 329 return 'set%s' % capitalize(cpp_name(attribute)) | 329 return 'set%s' % capitalize(cpp_name(attribute)) |
| 330 arguments.append(scoped_content_attribute_name(attribute)) | 330 arguments.append(scoped_content_attribute_name(interface, attribute)) |
| 331 | 331 |
| 332 idl_type = attribute.idl_type | 332 idl_type = attribute.idl_type |
| 333 if idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: | 333 if idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES: |
| 334 return CONTENT_ATTRIBUTE_SETTER_NAMES[idl_type] | 334 return CONTENT_ATTRIBUTE_SETTER_NAMES[idl_type] |
| 335 return 'setAttribute' | 335 return 'setAttribute' |
| 336 | 336 |
| 337 | 337 |
| 338 def scoped_content_attribute_name(attribute): | 338 def scoped_content_attribute_name(interface, attribute): |
| 339 content_attribute_name = attribute.extended_attributes['Reflect'] or attribu te.name.lower() | 339 content_attribute_name = attribute.extended_attributes['Reflect'] or attribu te.name.lower() |
| 340 namespace = 'HTMLNames' # FIXME: can be SVG too | 340 namespace = 'SVGNames' if interface.name.startswith('SVG') else 'HTMLNames' |
|
kouhei (in TOK)
2014/02/24 07:24:25
What happens for XMLNames and XLinkNames?
Nils Barth (inactive)
2014/02/24 07:27:52
They don't occur in bindings:
only HTMLNames and (
haraken
2014/02/24 07:36:26
I guess we have a plan to remove the namespace dis
Nils Barth (inactive)
2014/02/24 07:37:40
I'll see if we can fix this during cleanup, or at
| |
| 341 includes.add('%s.h' % namespace) | 341 includes.add('%s.h' % namespace) |
| 342 return '%s::%sAttr' % (namespace, content_attribute_name) | 342 return '%s::%sAttr' % (namespace, content_attribute_name) |
| 343 | 343 |
| 344 | 344 |
| 345 ################################################################################ | 345 ################################################################################ |
| 346 # Attribute configuration | 346 # Attribute configuration |
| 347 ################################################################################ | 347 ################################################################################ |
| 348 | 348 |
| 349 # [Replaceable] | 349 # [Replaceable] |
| 350 def setter_callback_name(interface, attribute): | 350 def setter_callback_name(interface, attribute): |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 property_attributes_list.append('v8::DontDelete') | 389 property_attributes_list.append('v8::DontDelete') |
| 390 return property_attributes_list or ['v8::None'] | 390 return property_attributes_list or ['v8::None'] |
| 391 | 391 |
| 392 | 392 |
| 393 ################################################################################ | 393 ################################################################################ |
| 394 # Constructors | 394 # Constructors |
| 395 ################################################################################ | 395 ################################################################################ |
| 396 | 396 |
| 397 def is_constructor_attribute(attribute): | 397 def is_constructor_attribute(attribute): |
| 398 return attribute.idl_type.endswith('Constructor') | 398 return attribute.idl_type.endswith('Constructor') |
| OLD | NEW |