| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 def cpp_method(method, number_of_arguments): | 75 def cpp_method(method, number_of_arguments): |
| 76 argument_names = [argument.name for argument in method.arguments] | 76 argument_names = [argument.name for argument in method.arguments] |
| 77 # Truncate omitted optional arguments | 77 # Truncate omitted optional arguments |
| 78 argument_names = argument_names[:number_of_arguments] | 78 argument_names = argument_names[:number_of_arguments] |
| 79 cpp_value = 'imp->%s(%s)' % (method.name, ', '.join(argument_names)) | 79 cpp_value = 'imp->%s(%s)' % (method.name, ', '.join(argument_names)) |
| 80 | 80 |
| 81 idl_type = method.idl_type | 81 idl_type = method.idl_type |
| 82 if idl_type == 'void': | 82 if idl_type == 'void': |
| 83 return cpp_value | 83 return cpp_value |
| 84 return v8_types.v8_set_return_value(idl_type, cpp_value, callback_info='args
', creation_context='args.Holder()', isolate='args.GetIsolate()') | 84 return v8_types.v8_set_return_value(idl_type, cpp_value, callback_info='args
', isolate='args.GetIsolate()') |
| 85 | 85 |
| 86 | 86 |
| 87 def custom_signature(arguments): | 87 def custom_signature(arguments): |
| 88 def argument_template(argument): | 88 def argument_template(argument): |
| 89 idl_type = argument.idl_type | 89 idl_type = argument.idl_type |
| 90 if v8_types.is_wrapper_type(idl_type): | 90 if v8_types.is_wrapper_type(idl_type): |
| 91 return 'V8PerIsolateData::from(isolate)->rawTemplate(&V8{idl_type}::
wrapperTypeInfo, currentWorldType)'.format(idl_type=idl_type) | 91 return 'V8PerIsolateData::from(isolate)->rawTemplate(&V8{idl_type}::
wrapperTypeInfo, currentWorldType)'.format(idl_type=idl_type) |
| 92 return 'v8::Handle<v8::FunctionTemplate>()' | 92 return 'v8::Handle<v8::FunctionTemplate>()' |
| 93 | 93 |
| 94 if (any(argument.is_optional for argument in arguments) or | 94 if (any(argument.is_optional for argument in arguments) or |
| 95 all(not v8_types.is_wrapper_type(argument.idl_type) | 95 all(not v8_types.is_wrapper_type(argument.idl_type) |
| 96 for argument in arguments)): | 96 for argument in arguments)): |
| 97 return None | 97 return None |
| 98 return ', '.join([argument_template(argument) for argument in arguments]) | 98 return ', '.join([argument_template(argument) for argument in arguments]) |
| 99 | 99 |
| 100 | 100 |
| 101 def v8_value_to_local_cpp_value(argument, index): | 101 def v8_value_to_local_cpp_value(argument, index): |
| 102 idl_type = argument.idl_type | 102 idl_type = argument.idl_type |
| 103 name = argument.name | 103 name = argument.name |
| 104 if argument.is_variadic: | 104 if argument.is_variadic: |
| 105 return 'V8TRYCATCH_VOID(Vector<{cpp_type}>, {name}, toNativeArguments<{c
pp_type}>(args, {index}))'.format( | 105 return 'V8TRYCATCH_VOID(Vector<{cpp_type}>, {name}, toNativeArguments<{c
pp_type}>(args, {index}))'.format( |
| 106 cpp_type=v8_types.cpp_type(idl_type), name=name, index=index) | 106 cpp_type=v8_types.cpp_type(idl_type), name=name, index=index) |
| 107 return v8_types.v8_value_to_local_cpp_value( | 107 return v8_types.v8_value_to_local_cpp_value( |
| 108 idl_type, argument.extended_attributes, | 108 idl_type, argument.extended_attributes, |
| 109 'args[%s]' % index, name, 'args.GetIsolate()') | 109 'args[%s]' % index, name, 'args.GetIsolate()') |
| OLD | NEW |