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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1037 for constructor in constructors) | 1037 for constructor in constructors) |
1038 | 1038 |
1039 | 1039 |
1040 ################################################################################ | 1040 ################################################################################ |
1041 # Special operations (methods) | 1041 # Special operations (methods) |
1042 # http://heycam.github.io/webidl/#idl-special-operations | 1042 # http://heycam.github.io/webidl/#idl-special-operations |
1043 ################################################################################ | 1043 ################################################################################ |
1044 | 1044 |
1045 def property_getter(getter, cpp_arguments): | 1045 def property_getter(getter, cpp_arguments): |
1046 def is_null_expression(idl_type): | 1046 def is_null_expression(idl_type): |
1047 if idl_type.is_union_type: | 1047 if idl_type.is_union_type: |
haraken
2014/10/29 04:59:30
Don't we need to check idl_type.is_dictionary_type
bashi
2014/10/29 09:57:36
Done. (Though I'm not sure we already support dict
| |
1048 notnull = ' || '.join([ | 1048 return 'result.isNull()' |
1049 member_argument['null_check_value'] | |
1050 for member_argument in idl_type.union_arguments]) | |
1051 return '!(%s)' % notnull | |
1052 if idl_type.name == 'String': | 1049 if idl_type.name == 'String': |
1053 return 'result.isNull()' | 1050 return 'result.isNull()' |
1054 if idl_type.is_interface_type: | 1051 if idl_type.is_interface_type: |
1055 return '!result' | 1052 return '!result' |
1056 return '' | 1053 return '' |
1057 | 1054 |
1058 idl_type = getter.idl_type | 1055 idl_type = getter.idl_type |
1059 extended_attributes = getter.extended_attributes | 1056 extended_attributes = getter.extended_attributes |
1060 is_raises_exception = 'RaisesException' in extended_attributes | 1057 is_raises_exception = 'RaisesException' in extended_attributes |
1061 | 1058 |
1062 # FIXME: make more generic, so can use v8_methods.cpp_value | 1059 # FIXME: make more generic, so can use v8_methods.cpp_value |
1063 cpp_method_name = 'impl->%s' % cpp_name(getter) | 1060 cpp_method_name = 'impl->%s' % cpp_name(getter) |
1064 | 1061 |
1065 if is_raises_exception: | 1062 if is_raises_exception: |
1066 cpp_arguments.append('exceptionState') | 1063 cpp_arguments.append('exceptionState') |
1067 union_arguments = idl_type.union_arguments | 1064 if idl_type.is_union_type: |
haraken
2014/10/29 04:59:30
Ditto.
bashi
2014/10/29 09:57:36
Done.
| |
1068 if union_arguments: | 1065 cpp_arguments.append('result') |
1069 cpp_arguments.extend([member_argument['cpp_value'] | |
1070 for member_argument in union_arguments]) | |
1071 | 1066 |
1072 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) | 1067 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) |
1073 | 1068 |
1074 return { | 1069 return { |
1075 'cpp_type': idl_type.cpp_type, | 1070 'cpp_type': idl_type.cpp_type, |
1076 'cpp_value': cpp_value, | 1071 'cpp_value': cpp_value, |
1077 'is_custom': | 1072 'is_custom': |
1078 'Custom' in extended_attributes and | 1073 'Custom' in extended_attributes and |
1079 (not extended_attributes['Custom'] or | 1074 (not extended_attributes['Custom'] or |
1080 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), | 1075 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), |
1081 'is_custom_property_enumerator': has_extended_attribute_value( | 1076 'is_custom_property_enumerator': has_extended_attribute_value( |
1082 getter, 'Custom', 'PropertyEnumerator'), | 1077 getter, 'Custom', 'PropertyEnumerator'), |
1083 'is_custom_property_query': has_extended_attribute_value( | 1078 'is_custom_property_query': has_extended_attribute_value( |
1084 getter, 'Custom', 'PropertyQuery'), | 1079 getter, 'Custom', 'PropertyQuery'), |
1085 'is_enumerable': 'NotEnumerable' not in extended_attributes, | 1080 'is_enumerable': 'NotEnumerable' not in extended_attributes, |
1086 'is_null_expression': is_null_expression(idl_type), | 1081 'is_null_expression': is_null_expression(idl_type), |
1087 'is_raises_exception': is_raises_exception, | 1082 'is_raises_exception': is_raises_exception, |
1088 'name': cpp_name(getter), | 1083 'name': cpp_name(getter), |
1089 'union_arguments': union_arguments, | 1084 'use_output_parameter_for_result': v8_methods.use_output_parameter_for_r esult(idl_type), |
1090 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a ttributes=extended_attributes, script_wrappable='impl', release=idl_type.release ), | 1085 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a ttributes=extended_attributes, script_wrappable='impl', release=idl_type.release ), |
1091 } | 1086 } |
1092 | 1087 |
1093 | 1088 |
1094 def property_setter(setter): | 1089 def property_setter(setter): |
1095 idl_type = setter.arguments[1].idl_type | 1090 idl_type = setter.arguments[1].idl_type |
1096 extended_attributes = setter.extended_attributes | 1091 extended_attributes = setter.extended_attributes |
1097 is_raises_exception = 'RaisesException' in extended_attributes | 1092 is_raises_exception = 'RaisesException' in extended_attributes |
1098 return { | 1093 return { |
1099 'has_type_checking_interface': | 1094 'has_type_checking_interface': |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1222 deleter = next( | 1217 deleter = next( |
1223 method | 1218 method |
1224 for method in interface.operations | 1219 for method in interface.operations |
1225 if ('deleter' in method.specials and | 1220 if ('deleter' in method.specials and |
1226 len(method.arguments) == 1 and | 1221 len(method.arguments) == 1 and |
1227 str(method.arguments[0].idl_type) == 'DOMString')) | 1222 str(method.arguments[0].idl_type) == 'DOMString')) |
1228 except StopIteration: | 1223 except StopIteration: |
1229 return None | 1224 return None |
1230 | 1225 |
1231 return property_deleter(deleter) | 1226 return property_deleter(deleter) |
OLD | NEW |