| 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 18 matching lines...) Expand all Loading... |
| 29 """Generate template values for a callback interface. | 29 """Generate template values for a callback interface. |
| 30 | 30 |
| 31 FIXME: Not currently used in build. | 31 FIXME: Not currently used in build. |
| 32 This is a rewrite of the Perl IDL compiler in Python, but is not complete. | 32 This is a rewrite of the Perl IDL compiler in Python, but is not complete. |
| 33 Once it is complete, we will switch all IDL files over to Python at once. | 33 Once it is complete, we will switch all IDL files over to Python at once. |
| 34 Until then, please work on the Perl IDL compiler. | 34 Until then, please work on the Perl IDL compiler. |
| 35 For details, see bug http://crbug.com/239771 | 35 For details, see bug http://crbug.com/239771 |
| 36 """ | 36 """ |
| 37 | 37 |
| 38 from v8_types import cpp_type, cpp_value_to_v8_value, includes_for_type | 38 from v8_types import cpp_type, cpp_value_to_v8_value, includes_for_type |
| 39 from v8_utilities import v8_class_name, has_extended_attribute_value | 39 from v8_utilities import v8_class_name, extended_attribute_value_contains |
| 40 | 40 |
| 41 CALLBACK_INTERFACE_H_INCLUDES = set([ | 41 CALLBACK_INTERFACE_H_INCLUDES = set([ |
| 42 'bindings/v8/ActiveDOMCallback.h', | 42 'bindings/v8/ActiveDOMCallback.h', |
| 43 'bindings/v8/DOMWrapperWorld.h', | 43 'bindings/v8/DOMWrapperWorld.h', |
| 44 'bindings/v8/ScopedPersistent.h', | 44 'bindings/v8/ScopedPersistent.h', |
| 45 ]) | 45 ]) |
| 46 CALLBACK_INTERFACE_CPP_INCLUDES = set([ | 46 CALLBACK_INTERFACE_CPP_INCLUDES = set([ |
| 47 'core/dom/ExecutionContext.h', | 47 'core/dom/ExecutionContext.h', |
| 48 'bindings/v8/V8Binding.h', | 48 'bindings/v8/V8Binding.h', |
| 49 'bindings/v8/V8Callback.h', | 49 'bindings/v8/V8Callback.h', |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 | 88 |
| 89 def includes_for_operation(operation): | 89 def includes_for_operation(operation): |
| 90 includes = includes_for_type(operation.data_type) | 90 includes = includes_for_type(operation.data_type) |
| 91 for argument in operation.arguments: | 91 for argument in operation.arguments: |
| 92 includes.update(includes_for_type(argument.data_type)) | 92 includes.update(includes_for_type(argument.data_type)) |
| 93 return includes | 93 return includes |
| 94 | 94 |
| 95 | 95 |
| 96 def generate_method_contents(operation): | 96 def generate_method_contents(operation): |
| 97 call_with_this_handle = has_extended_attribute_value(operation.extended_attr
ibutes, 'CallWith', 'ThisValue') | 97 extended_attributes = operation.extended_attributes |
| 98 call_with = extended_attributes.get('CallWith') |
| 98 contents = { | 99 contents = { |
| 99 'name': operation.name, | 100 'name': operation.name, |
| 100 'return_cpp_type': cpp_type(operation.data_type, 'RefPtr'), | 101 'return_cpp_type': cpp_type(operation.data_type, 'RefPtr'), |
| 101 'custom': 'Custom' in operation.extended_attributes, | 102 'custom': 'Custom' in extended_attributes, |
| 102 'call_with_this_handle': call_with_this_handle, | 103 'call_with_this_handle': extended_attribute_value_contains(call_with, 'T
hisValue'), |
| 103 } | 104 } |
| 104 contents.update(generate_arguments_contents(operation.arguments, call_with_t
his_handle)) | 105 contents.update(generate_arguments_contents(operation.arguments, call_with_t
his_handle)) |
| 105 return contents | 106 return contents |
| 106 | 107 |
| 107 | 108 |
| 108 def generate_arguments_contents(arguments, call_with_this_handle): | 109 def generate_arguments_contents(arguments, call_with_this_handle): |
| 109 def argument_declaration(argument): | 110 def argument_declaration(argument): |
| 110 return '%s %s' % (cpp_type(argument.data_type), argument.name) | 111 return '%s %s' % (cpp_type(argument.data_type), argument.name) |
| 111 | 112 |
| 112 def generate_argument(argument): | 113 def generate_argument(argument): |
| 113 return { | 114 return { |
| 114 'name': argument.name, | 115 'name': argument.name, |
| 115 'cpp_to_v8_conversion': cpp_to_v8_conversion(argument.data_type, arg
ument.name), | 116 'cpp_to_v8_conversion': cpp_to_v8_conversion(argument.data_type, arg
ument.name), |
| 116 } | 117 } |
| 117 | 118 |
| 118 argument_declarations = [argument_declaration(argument) for argument in argu
ments] | 119 argument_declarations = [argument_declaration(argument) for argument in argu
ments] |
| 119 if call_with_this_handle: | 120 if call_with_this_handle: |
| 120 argument_declarations.insert(0, 'ScriptValue thisValue') | 121 argument_declarations.insert(0, 'ScriptValue thisValue') |
| 121 return { | 122 return { |
| 122 'argument_declarations': argument_declarations, | 123 'argument_declarations': argument_declarations, |
| 123 'arguments': [generate_argument(argument) for argument in arguments], | 124 'arguments': [generate_argument(argument) for argument in arguments], |
| 124 'handles': ['%sHandle' % argument.name for argument in arguments], | 125 'handles': ['%sHandle' % argument.name for argument in arguments], |
| 125 } | 126 } |
| OLD | NEW |