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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 294 |
295 return '%s(%s)' % (macro, ', '.join(macro_args)) | 295 return '%s(%s)' % (macro, ', '.join(macro_args)) |
296 | 296 |
297 | 297 |
298 def v8_value_to_local_cpp_value(argument, index): | 298 def v8_value_to_local_cpp_value(argument, index): |
299 extended_attributes = argument.extended_attributes | 299 extended_attributes = argument.extended_attributes |
300 idl_type = argument.idl_type | 300 idl_type = argument.idl_type |
301 name = argument.name | 301 name = argument.name |
302 if argument.is_variadic: | 302 if argument.is_variadic: |
303 return v8_value_to_local_cpp_variadic_value(argument, index) | 303 return v8_value_to_local_cpp_variadic_value(argument, index) |
304 # FIXME: This special way of handling string arguments with null defaults | 304 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]'
% index, |
305 # can go away once we fully support default values. | |
306 if (argument.is_optional and idl_type.name in ('String', 'ByteString') and | |
307 argument.default_value and argument.default_value.is_null): | |
308 v8_value = 'argumentOrNull(info, %s)' % index | |
309 else: | |
310 v8_value = 'info[%s]' % index | |
311 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, | |
312 name, index=index, declare_varia
ble=False) | 305 name, index=index, declare_varia
ble=False) |
313 | 306 |
314 | 307 |
315 ################################################################################ | 308 ################################################################################ |
316 # Auxiliary functions | 309 # Auxiliary functions |
317 ################################################################################ | 310 ################################################################################ |
318 | 311 |
319 # [NotEnumerable] | 312 # [NotEnumerable] |
320 def property_attributes(method): | 313 def property_attributes(method): |
321 extended_attributes = method.extended_attributes | 314 extended_attributes = method.extended_attributes |
322 property_attributes_list = [] | 315 property_attributes_list = [] |
323 if 'NotEnumerable' in extended_attributes: | 316 if 'NotEnumerable' in extended_attributes: |
324 property_attributes_list.append('v8::DontEnum') | 317 property_attributes_list.append('v8::DontEnum') |
325 if 'ReadOnly' in extended_attributes: | 318 if 'ReadOnly' in extended_attributes: |
326 property_attributes_list.append('v8::ReadOnly') | 319 property_attributes_list.append('v8::ReadOnly') |
327 if property_attributes_list: | 320 if property_attributes_list: |
328 property_attributes_list.insert(0, 'v8::DontDelete') | 321 property_attributes_list.insert(0, 'v8::DontDelete') |
329 return property_attributes_list | 322 return property_attributes_list |
330 | 323 |
331 | 324 |
332 def union_arguments(idl_type): | 325 def union_arguments(idl_type): |
333 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" | 326 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" |
334 return [arg | 327 return [arg |
335 for i in range(len(idl_type.member_types)) | 328 for i in range(len(idl_type.member_types)) |
336 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 329 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
337 | 330 |
338 IdlType.union_arguments = property(lambda self: None) | 331 IdlType.union_arguments = property(lambda self: None) |
339 IdlUnionType.union_arguments = property(union_arguments) | 332 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |