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 | 39 from v8_utilities import v8_class_name, has_extended_attribute_value |
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/ScriptExecutionContext.h', | 47 'core/dom/ScriptExecutionContext.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 contents = { | 98 contents = { |
98 'name': operation.name, | 99 'name': operation.name, |
99 'return_cpp_type': cpp_type(operation.data_type, 'RefPtr'), | 100 'return_cpp_type': cpp_type(operation.data_type, 'RefPtr'), |
100 'custom': 'Custom' in operation.extended_attributes, | 101 'custom': 'Custom' in operation.extended_attributes, |
| 102 'call_with_this_handle': call_with_this_handle, |
101 } | 103 } |
102 contents.update(generate_arguments_contents(operation.arguments)) | 104 contents.update(generate_arguments_contents(operation.arguments, call_with_t
his_handle)) |
103 return contents | 105 return contents |
104 | 106 |
105 | 107 |
106 def generate_arguments_contents(arguments): | 108 def generate_arguments_contents(arguments, call_with_this_handle): |
107 def argument_declaration(argument): | 109 def argument_declaration(argument): |
108 return '%s %s' % (cpp_type(argument.data_type), argument.name) | 110 return '%s %s' % (cpp_type(argument.data_type), argument.name) |
109 | 111 |
110 def generate_argument(argument): | 112 def generate_argument(argument): |
111 return { | 113 return { |
112 'name': argument.name, | 114 'name': argument.name, |
113 'cpp_to_v8_conversion': cpp_to_v8_conversion(argument.data_type, arg
ument.name), | 115 'cpp_to_v8_conversion': cpp_to_v8_conversion(argument.data_type, arg
ument.name), |
114 } | 116 } |
115 | 117 |
| 118 argument_declarations = [argument_declaration(argument) for argument in argu
ments] |
| 119 if call_with_this_handle: |
| 120 argument_declarations.insert(0, 'ScriptValue thisValue') |
116 return { | 121 return { |
117 'argument_declarations': [argument_declaration(argument) for argument in
arguments], | 122 'argument_declarations': argument_declarations, |
118 'arguments': [generate_argument(argument) for argument in arguments], | 123 'arguments': [generate_argument(argument) for argument in arguments], |
119 'handles': ['%sHandle' % argument.name for argument in arguments], | 124 'handles': ['%sHandle' % argument.name for argument in arguments], |
120 } | 125 } |
OLD | NEW |