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

Side by Side Diff: Source/bindings/scripts/unstable/v8_interface.py

Issue 140693016: IDL compiler: interface and integer types for special operations (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/templates/interface.cpp » ('j') | 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 21 matching lines...) Expand all
32 This is a rewrite of the Perl IDL compiler in Python, but is not complete. 32 This is a rewrite of the Perl IDL compiler in Python, but is not complete.
33 Once it is complete, we will switch all IDL files over to Python at once. 33 Once it is complete, we will switch all IDL files over to Python at once.
34 Until then, please work on the Perl IDL compiler. 34 Until then, please work on the Perl IDL compiler.
35 For details, see bug http://crbug.com/239771 35 For details, see bug http://crbug.com/239771
36 """ 36 """
37 37
38 import v8_attributes 38 import v8_attributes
39 from v8_globals import includes 39 from v8_globals import includes
40 import v8_methods 40 import v8_methods
41 import v8_types 41 import v8_types
42 from v8_types import inherits_interface 42 from v8_types import inherits_interface, is_interface_type
43 import v8_utilities 43 import v8_utilities
44 from v8_utilities import capitalize, conditional_string, cpp_name, has_extended_ attribute_value, runtime_enabled_function_name 44 from v8_utilities import capitalize, conditional_string, cpp_name, has_extended_ attribute_value, runtime_enabled_function_name
45 45
46 46
47 INTERFACE_H_INCLUDES = set([ 47 INTERFACE_H_INCLUDES = set([
48 'bindings/v8/V8Binding.h', 48 'bindings/v8/V8Binding.h',
49 'bindings/v8/V8DOMWrapper.h', 49 'bindings/v8/V8DOMWrapper.h',
50 'bindings/v8/WrapperTypeInfo.h', 50 'bindings/v8/WrapperTypeInfo.h',
51 ]) 51 ])
52 INTERFACE_CPP_INCLUDES = set([ 52 INTERFACE_CPP_INCLUDES = set([
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 if v8_types.array_or_sequence_type(idl_type): 375 if v8_types.array_or_sequence_type(idl_type):
376 return '%s->IsArray()' % cpp_value 376 return '%s->IsArray()' % cpp_value
377 if v8_types.is_callback_interface(idl_type): 377 if v8_types.is_callback_interface(idl_type):
378 return ' || '.join(['%s->IsNull()' % cpp_value, 378 return ' || '.join(['%s->IsNull()' % cpp_value,
379 '%s->IsFunction()' % cpp_value]) 379 '%s->IsFunction()' % cpp_value])
380 if v8_types.is_wrapper_type(idl_type): 380 if v8_types.is_wrapper_type(idl_type):
381 type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate())' .format(idl_type=idl_type, cpp_value=cpp_value) 381 type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate())' .format(idl_type=idl_type, cpp_value=cpp_value)
382 if argument['is_nullable']: 382 if argument['is_nullable']:
383 type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) 383 type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check])
384 return type_check 384 return type_check
385 if v8_types.is_interface_type(idl_type): 385 if is_interface_type(idl_type):
386 # Non-wrapper types are just objects: we don't distinguish type 386 # Non-wrapper types are just objects: we don't distinguish type
387 type_check = '%s->IsObject()' % cpp_value 387 type_check = '%s->IsObject()' % cpp_value
388 if argument['is_nullable']: 388 if argument['is_nullable']:
389 type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) 389 type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check])
390 return type_check 390 return type_check
391 return None 391 return None
392 392
393 393
394 ################################################################################ 394 ################################################################################
395 # Constructors 395 # Constructors
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 484
485 ################################################################################ 485 ################################################################################
486 # Special operations (methods) 486 # Special operations (methods)
487 # http://heycam.github.io/webidl/#idl-special-operations 487 # http://heycam.github.io/webidl/#idl-special-operations
488 ################################################################################ 488 ################################################################################
489 489
490 def property_getter(getter): 490 def property_getter(getter):
491 def is_null_expression(idl_type): 491 def is_null_expression(idl_type):
492 if idl_type == 'DOMString': 492 if idl_type == 'DOMString':
493 return 'element.isNull()' 493 return 'element.isNull()'
494 return None 494 if is_interface_type(idl_type):
495 return '!element'
496 return ''
495 497
496 idl_type = getter.idl_type 498 idl_type = getter.idl_type
497 extended_attributes = getter.extended_attributes 499 extended_attributes = getter.extended_attributes
500 element = 'element.release()' if is_interface_type(idl_type) else 'element'
501
498 return { 502 return {
499 'cpp_type': v8_types.cpp_type(idl_type), 503 'cpp_type': v8_types.cpp_type(idl_type),
500 'is_custom': 504 'is_custom':
501 'Custom' in extended_attributes and 505 'Custom' in extended_attributes and
502 (not extended_attributes['Custom'] or 506 (not extended_attributes['Custom'] or
503 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), 507 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')),
504 'is_custom_property_enumerator': has_extended_attribute_value( 508 'is_custom_property_enumerator': has_extended_attribute_value(
505 getter, 'Custom', 'PropertyEnumerator'), 509 getter, 'Custom', 'PropertyEnumerator'),
506 'is_custom_property_query': has_extended_attribute_value( 510 'is_custom_property_query': has_extended_attribute_value(
507 getter, 'Custom', 'PropertyQuery'), 511 getter, 'Custom', 'PropertyQuery'),
508 'is_enumerable': 'NotEnumerable' not in extended_attributes, 512 'is_enumerable': 'NotEnumerable' not in extended_attributes,
509 'is_null_expression': is_null_expression(idl_type), 513 'is_null_expression': is_null_expression(idl_type),
510 'is_raises_exception': 'RaisesException' in extended_attributes, 514 'is_raises_exception': 'RaisesException' in extended_attributes,
511 'name': cpp_name(getter), 515 'name': cpp_name(getter),
512 'v8_set_return_value': v8_types.v8_set_return_value(idl_type, 'element', extended_attributes=extended_attributes, script_wrappable='collection'), 516 'v8_set_return_value': v8_types.v8_set_return_value(idl_type, element, e xtended_attributes=extended_attributes, script_wrappable='collection'),
513 } 517 }
514 518
515 519
516 def property_setter(setter): 520 def property_setter(setter):
517 idl_type = setter.arguments[1].idl_type 521 idl_type = setter.arguments[1].idl_type
518 extended_attributes = setter.extended_attributes 522 extended_attributes = setter.extended_attributes
523 is_raises_exception = 'RaisesException' in extended_attributes
519 return { 524 return {
520 'is_custom': 'Custom' in extended_attributes, 525 'is_custom': 'Custom' in extended_attributes,
521 'is_raises_exception': 'RaisesException' in extended_attributes, 526 'has_exception_state': is_raises_exception or
527 v8_types.is_integer_type(idl_type),
haraken 2014/01/30 10:55:25 Let me confirm: Did we decide that we should impli
Nils Barth (inactive) 2014/01/30 11:00:50 Yes, we raise exceptions for integer setters (for
528 'is_raises_exception': is_raises_exception,
522 'name': cpp_name(setter), 529 'name': cpp_name(setter),
523 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value( 530 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value(
524 idl_type, extended_attributes, 'jsValue', 'propertyValue'), 531 idl_type, extended_attributes, 'jsValue', 'propertyValue'),
525 } 532 }
526 533
527 534
528 def property_deleter(deleter): 535 def property_deleter(deleter):
529 idl_type = deleter.idl_type 536 idl_type = deleter.idl_type
530 if idl_type != 'boolean': 537 if idl_type != 'boolean':
531 raise Exception( 538 raise Exception(
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 deleter = next( 643 deleter = next(
637 method 644 method
638 for method in interface.operations 645 for method in interface.operations
639 if ('deleter' in method.specials and 646 if ('deleter' in method.specials and
640 len(method.arguments) == 1 and 647 len(method.arguments) == 1 and
641 method.arguments[0].idl_type == 'DOMString')) 648 method.arguments[0].idl_type == 'DOMString'))
642 except StopIteration: 649 except StopIteration:
643 return None 650 return None
644 651
645 return property_deleter(deleter) 652 return property_deleter(deleter)
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/templates/interface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698