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 10 matching lines...) Expand all Loading... |
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 """Generate template values for a callback interface. | 29 """Generate template values for a callback interface. |
30 | 30 |
31 Extends IdlType with property |callback_cpp_type|. | 31 Extends IdlTypeBase with property |callback_cpp_type|. |
32 | 32 |
33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
34 """ | 34 """ |
35 | 35 |
36 from idl_types import IdlType | 36 from idl_types import IdlTypeBase |
37 from v8_globals import includes | 37 from v8_globals import includes |
38 import v8_types | 38 import v8_types |
39 import v8_utilities | 39 import v8_utilities |
40 | 40 |
41 CALLBACK_INTERFACE_H_INCLUDES = frozenset([ | 41 CALLBACK_INTERFACE_H_INCLUDES = frozenset([ |
42 'bindings/core/v8/ActiveDOMCallback.h', | 42 'bindings/core/v8/ActiveDOMCallback.h', |
43 'bindings/core/v8/DOMWrapperWorld.h', | 43 'bindings/core/v8/DOMWrapperWorld.h', |
44 'bindings/core/v8/ScopedPersistent.h', | 44 'bindings/core/v8/ScopedPersistent.h', |
45 ]) | 45 ]) |
46 CALLBACK_INTERFACE_CPP_INCLUDES = frozenset([ | 46 CALLBACK_INTERFACE_CPP_INCLUDES = frozenset([ |
(...skipping 13 matching lines...) Expand all Loading... |
60 if idl_type_name == 'String': | 60 if idl_type_name == 'String': |
61 return 'const String&' | 61 return 'const String&' |
62 if idl_type_name == 'void': | 62 if idl_type_name == 'void': |
63 return 'void' | 63 return 'void' |
64 # Callbacks use raw pointers, so raw_type=True | 64 # Callbacks use raw pointers, so raw_type=True |
65 raw_cpp_type = idl_type.cpp_type_args(raw_type=True) | 65 raw_cpp_type = idl_type.cpp_type_args(raw_type=True) |
66 if raw_cpp_type.startswith(('Vector', 'HeapVector', 'WillBeHeapVector')): | 66 if raw_cpp_type.startswith(('Vector', 'HeapVector', 'WillBeHeapVector')): |
67 return 'const %s&' % raw_cpp_type | 67 return 'const %s&' % raw_cpp_type |
68 return raw_cpp_type | 68 return raw_cpp_type |
69 | 69 |
70 IdlType.callback_cpp_type = property(cpp_type) | 70 IdlTypeBase.callback_cpp_type = property(cpp_type) |
71 | 71 |
72 | 72 |
73 def callback_interface_context(callback_interface): | 73 def callback_interface_context(callback_interface): |
74 includes.clear() | 74 includes.clear() |
75 includes.update(CALLBACK_INTERFACE_CPP_INCLUDES) | 75 includes.update(CALLBACK_INTERFACE_CPP_INCLUDES) |
76 return { | 76 return { |
77 'conditional_string': v8_utilities.conditional_string(callback_interface
), | 77 'conditional_string': v8_utilities.conditional_string(callback_interface
), |
78 'cpp_class': callback_interface.name, | 78 'cpp_class': callback_interface.name, |
79 'v8_class': v8_utilities.v8_class_name(callback_interface), | 79 'v8_class': v8_utilities.v8_class_name(callback_interface), |
80 'header_includes': set(CALLBACK_INTERFACE_H_INCLUDES), | 80 'header_includes': set(CALLBACK_INTERFACE_H_INCLUDES), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 argument_declarations = ['ScriptValue thisValue'] if call_with_this_handle e
lse [] | 124 argument_declarations = ['ScriptValue thisValue'] if call_with_this_handle e
lse [] |
125 argument_declarations.extend( | 125 argument_declarations.extend( |
126 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) | 126 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) |
127 for argument in arguments) | 127 for argument in arguments) |
128 return { | 128 return { |
129 'argument_declarations': argument_declarations, | 129 'argument_declarations': argument_declarations, |
130 'arguments': [argument_context(argument) for argument in arguments], | 130 'arguments': [argument_context(argument) for argument in arguments], |
131 } | 131 } |
OLD | NEW |