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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 'is_nullable': idl_type.is_nullable, | 166 'is_nullable': idl_type.is_nullable, |
167 'is_optional': argument.is_optional, | 167 'is_optional': argument.is_optional, |
168 'is_strict_type_checking': 'StrictTypeChecking' in extended_attributes, | 168 'is_strict_type_checking': 'StrictTypeChecking' in extended_attributes, |
169 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 169 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
170 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type), | 170 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type), |
171 'is_wrapper_type': idl_type.is_wrapper_type, | 171 'is_wrapper_type': idl_type.is_wrapper_type, |
172 'name': argument.name, | 172 'name': argument.name, |
173 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), | 173 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), |
174 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), | 174 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), |
175 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex), | 175 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex), |
176 'v8_value_to_local_cpp_value_async': v8_value_to_local_cpp_value_async(a rgument, index), | |
176 } | 177 } |
177 | 178 |
178 | 179 |
179 ################################################################################ | 180 ################################################################################ |
180 # Value handling | 181 # Value handling |
181 ################################################################################ | 182 ################################################################################ |
182 | 183 |
183 def cpp_value(interface, method, number_of_arguments): | 184 def cpp_value(interface, method, number_of_arguments): |
184 def cpp_argument(argument): | 185 def cpp_argument(argument): |
185 idl_type = argument.idl_type | 186 idl_type = argument.idl_type |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 # [Default=NullString] | 256 # [Default=NullString] |
256 if (argument.is_optional and idl_type.name == 'String' and | 257 if (argument.is_optional and idl_type.name == 'String' and |
257 extended_attributes.get('Default') == 'NullString'): | 258 extended_attributes.get('Default') == 'NullString'): |
258 v8_value = 'argumentOrNull(info, %s)' % index | 259 v8_value = 'argumentOrNull(info, %s)' % index |
259 else: | 260 else: |
260 v8_value = 'info[%s]' % index | 261 v8_value = 'info[%s]' % index |
261 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, | 262 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, |
262 name, index=index) | 263 name, index=index) |
263 | 264 |
264 | 265 |
266 def v8_value_to_local_cpp_value_async(argument, index): | |
Nils Barth (inactive)
2014/04/11 10:26:39
Could you merge this with above, only adding an as
yhirano
2014/04/11 10:54:22
Done. I split the variadic case to another functio
| |
267 extended_attributes = argument.extended_attributes | |
268 idl_type = argument.idl_type | |
269 name = argument.name | |
270 if argument.is_variadic: | |
271 vector_type = v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc_ type) | |
272 return 'TONATIVE_VOID_ASYNC({vector_type}<{cpp_type}>, {name}, toNativeA rguments<{cpp_type}>(info, {index}), info)'.format( | |
273 vector_type=vector_type, cpp_type=idl_type.cpp_type, name=name, | |
274 index=index) | |
275 # [Default=NullString] | |
276 if (argument.is_optional and idl_type.name == 'String' and | |
277 extended_attributes.get('Default') == 'NullString'): | |
278 v8_value = 'argumentOrNull(info, %s)' % index | |
279 else: | |
280 v8_value = 'info[%s]' % index | |
281 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, | |
282 name, index=index, async=True) | |
283 | |
284 | |
265 ################################################################################ | 285 ################################################################################ |
266 # Auxiliary functions | 286 # Auxiliary functions |
267 ################################################################################ | 287 ################################################################################ |
268 | 288 |
269 # [NotEnumerable] | 289 # [NotEnumerable] |
270 def property_attributes(method): | 290 def property_attributes(method): |
271 extended_attributes = method.extended_attributes | 291 extended_attributes = method.extended_attributes |
272 property_attributes_list = [] | 292 property_attributes_list = [] |
273 if 'NotEnumerable' in extended_attributes: | 293 if 'NotEnumerable' in extended_attributes: |
274 property_attributes_list.append('v8::DontEnum') | 294 property_attributes_list.append('v8::DontEnum') |
275 if 'ReadOnly' in extended_attributes: | 295 if 'ReadOnly' in extended_attributes: |
276 property_attributes_list.append('v8::ReadOnly') | 296 property_attributes_list.append('v8::ReadOnly') |
277 if property_attributes_list: | 297 if property_attributes_list: |
278 property_attributes_list.insert(0, 'v8::DontDelete') | 298 property_attributes_list.insert(0, 'v8::DontDelete') |
279 return property_attributes_list | 299 return property_attributes_list |
280 | 300 |
281 | 301 |
282 def union_arguments(idl_type): | 302 def union_arguments(idl_type): |
283 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" | 303 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" |
284 return [arg | 304 return [arg |
285 for i in range(len(idl_type.member_types)) | 305 for i in range(len(idl_type.member_types)) |
286 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 306 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
287 | 307 |
288 IdlType.union_arguments = property(lambda self: None) | 308 IdlType.union_arguments = property(lambda self: None) |
289 IdlUnionType.union_arguments = property(union_arguments) | 309 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |