| OLD | NEW |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # coding=utf-8 | 2 # coding=utf-8 |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 | 927 |
| 928 | 928 |
| 929 ################################################################################ | 929 ################################################################################ |
| 930 # Special operations (methods) | 930 # Special operations (methods) |
| 931 # http://heycam.github.io/webidl/#idl-special-operations | 931 # http://heycam.github.io/webidl/#idl-special-operations |
| 932 ################################################################################ | 932 ################################################################################ |
| 933 | 933 |
| 934 def property_getter(getter, cpp_arguments): | 934 def property_getter(getter, cpp_arguments): |
| 935 def is_null_expression(idl_type): | 935 def is_null_expression(idl_type): |
| 936 if idl_type.is_union_type: | 936 if idl_type.is_union_type: |
| 937 return ' && '.join('!result%sEnabled' % i | 937 return ' && '.join('result%s.isNull()' % i |
| 938 for i, _ in enumerate(idl_type.member_types)) | 938 for i, _ in enumerate(idl_type.member_types)) |
| 939 if idl_type.name == 'String': | 939 if idl_type.name == 'String': |
| 940 return 'result.isNull()' | 940 return 'result.isNull()' |
| 941 if idl_type.is_interface_type: | 941 if idl_type.is_interface_type: |
| 942 return '!result' | 942 return '!result' |
| 943 return '' | 943 return '' |
| 944 | 944 |
| 945 idl_type = getter.idl_type | 945 idl_type = getter.idl_type |
| 946 extended_attributes = getter.extended_attributes | 946 extended_attributes = getter.extended_attributes |
| 947 is_raises_exception = 'RaisesException' in extended_attributes | 947 is_raises_exception = 'RaisesException' in extended_attributes |
| 948 | 948 |
| 949 # FIXME: make more generic, so can use v8_methods.cpp_value | 949 # FIXME: make more generic, so can use v8_methods.cpp_value |
| 950 cpp_method_name = 'impl->%s' % cpp_name(getter) | 950 cpp_method_name = 'impl->%s' % cpp_name(getter) |
| 951 | 951 |
| 952 if is_raises_exception: | 952 if is_raises_exception: |
| 953 cpp_arguments.append('exceptionState') | 953 cpp_arguments.append('exceptionState') |
| 954 union_arguments = idl_type.union_arguments | 954 union_arguments = idl_type.union_arguments |
| 955 if union_arguments: | 955 if union_arguments: |
| 956 cpp_arguments.extend(union_arguments) | 956 cpp_arguments.extend(union_arguments) |
| 957 | 957 |
| 958 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) | 958 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) |
| 959 | 959 |
| 960 cpp_return_value = 'result' if not idl_type.is_union_type else 'result{index
}.get()' |
| 961 |
| 960 return { | 962 return { |
| 961 'cpp_type': idl_type.cpp_type, | 963 'cpp_type': idl_type.cpp_type, |
| 962 'cpp_value': cpp_value, | 964 'cpp_value': cpp_value, |
| 963 'is_custom': | 965 'is_custom': |
| 964 'Custom' in extended_attributes and | 966 'Custom' in extended_attributes and |
| 965 (not extended_attributes['Custom'] or | 967 (not extended_attributes['Custom'] or |
| 966 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), | 968 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), |
| 967 'is_custom_property_enumerator': has_extended_attribute_value( | 969 'is_custom_property_enumerator': has_extended_attribute_value( |
| 968 getter, 'Custom', 'PropertyEnumerator'), | 970 getter, 'Custom', 'PropertyEnumerator'), |
| 969 'is_custom_property_query': has_extended_attribute_value( | 971 'is_custom_property_query': has_extended_attribute_value( |
| 970 getter, 'Custom', 'PropertyQuery'), | 972 getter, 'Custom', 'PropertyQuery'), |
| 971 'is_enumerable': 'NotEnumerable' not in extended_attributes, | 973 'is_enumerable': 'NotEnumerable' not in extended_attributes, |
| 972 'is_null_expression': is_null_expression(idl_type), | 974 'is_null_expression': is_null_expression(idl_type), |
| 973 'is_raises_exception': is_raises_exception, | 975 'is_raises_exception': is_raises_exception, |
| 974 'name': cpp_name(getter), | 976 'name': cpp_name(getter), |
| 975 'union_arguments': union_arguments, | 977 'union_arguments': union_arguments, |
| 976 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a
ttributes=extended_attributes, script_wrappable='impl', release=idl_type.release
), | 978 'v8_set_return_value': idl_type.v8_set_return_value(cpp_return_value, ex
tended_attributes=extended_attributes, script_wrappable='impl', release=idl_type
.release), |
| 977 } | 979 } |
| 978 | 980 |
| 979 | 981 |
| 980 def property_setter(setter): | 982 def property_setter(setter): |
| 981 idl_type = setter.arguments[1].idl_type | 983 idl_type = setter.arguments[1].idl_type |
| 982 extended_attributes = setter.extended_attributes | 984 extended_attributes = setter.extended_attributes |
| 983 is_raises_exception = 'RaisesException' in extended_attributes | 985 is_raises_exception = 'RaisesException' in extended_attributes |
| 984 return { | 986 return { |
| 985 'has_type_checking_interface': | 987 'has_type_checking_interface': |
| 986 has_extended_attribute_value(setter, 'TypeChecking', 'Interface') an
d | 988 has_extended_attribute_value(setter, 'TypeChecking', 'Interface') an
d |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 deleter = next( | 1110 deleter = next( |
| 1109 method | 1111 method |
| 1110 for method in interface.operations | 1112 for method in interface.operations |
| 1111 if ('deleter' in method.specials and | 1113 if ('deleter' in method.specials and |
| 1112 len(method.arguments) == 1 and | 1114 len(method.arguments) == 1 and |
| 1113 str(method.arguments[0].idl_type) == 'DOMString')) | 1115 str(method.arguments[0].idl_type) == 'DOMString')) |
| 1114 except StopIteration: | 1116 except StopIteration: |
| 1115 return None | 1117 return None |
| 1116 | 1118 |
| 1117 return property_deleter(deleter) | 1119 return property_deleter(deleter) |
| OLD | NEW |