OLD | NEW |
---|---|
(Empty) | |
1 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
2 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
3 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
4 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
5 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
6 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
7 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
8 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
9 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
10 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
11 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
Yuki
2016/09/08 10:45:25
The file header comment (of a new file) must be:
lkawai
2016/09/09 07:56:48
Done.
| |
12 | |
13 """Generate template values for a callback function. | |
14 | |
15 Extends IdlTypeBase with property |callback_cpp_type|. | |
Yuki
2016/09/08 10:45:25
This line no longer applies.
lkawai
2016/09/09 07:56:48
Done.
| |
16 | |
17 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | |
18 """ | |
19 | |
20 from v8_globals import includes | |
21 import v8_types | |
22 import v8_utilities | |
23 | |
24 CALLBACK_FUNCTION_H_INCLUDES = frozenset([ | |
25 'bindings/core/v8/ScopedPersistent.h', | |
26 'bindings/core/v8/ScriptValue.h', | |
Yuki
2016/09/08 10:45:25
See a below comment. Let's stop using ScriptValue
lkawai
2016/09/09 07:56:48
Done.
| |
27 'platform/heap/Handle.h', | |
28 ]) | |
29 CALLBACK_FUNCTION_CPP_INCLUDES = frozenset([ | |
30 'bindings/core/v8/ScriptState.h', | |
31 'bindings/core/v8/V8Binding.h', | |
32 'wtf/Assertions.h', | |
33 ]) | |
34 | |
35 | |
36 def callback_function_context(callback_function): | |
37 includes.clear() | |
38 includes.update(CALLBACK_FUNCTION_CPP_INCLUDES) | |
39 idl_type = callback_function.idl_type | |
40 idl_type_str = str(idl_type) | |
41 | |
42 def member_cpp_type(): | |
43 member_cpp_type = idl_type.cpp_type_args(used_in_cpp_sequence=True) | |
44 if idl_type.impl_should_use_nullable_container: | |
45 return v8_types.cpp_template_type('Nullable', member_cpp_type) | |
46 return member_cpp_type | |
47 context = { | |
48 'cpp_class': callback_function.name, | |
49 'v8_class': v8_utilities.v8_class_name(callback_function), | |
50 'header_includes': set(CALLBACK_FUNCTION_H_INCLUDES), | |
51 'cpp_includes': set(CALLBACK_FUNCTION_CPP_INCLUDES), | |
52 'rvalue_cpp_type': idl_type.callback_cpp_type, | |
53 'idl_type': idl_type_str, | |
54 'member_cpp_type': member_cpp_type(), | |
55 'v8_value_to_local_cpp_value_dict': idl_type.v8_value_to_local_cpp_value ( | |
56 callback_function.extended_attributes, 'currentValue', 'cppValue', b ailout_return_value="false"), | |
57 } | |
58 context.update(arguments_context(callback_function.arguments)) | |
59 return context | |
60 | |
61 | |
62 def arguments_context(arguments): | |
63 def argument_context(argument): | |
64 return { | |
65 'handle': '%sHandle' % argument.name, | |
66 'cpp_value_to_v8_value': argument.idl_type.cpp_value_to_v8_value( | |
67 argument.name, isolate='m_scriptState->isolate()', | |
68 creation_context='m_scriptState->context()->Global()'), | |
69 } | |
70 | |
71 argument_declarations = ['ScriptValue thisValue'] | |
Yuki
2016/09/08 10:45:25
I think we'd like to use ScriptWrappable* as |this
lkawai
2016/09/09 07:56:48
Done.
| |
72 argument_declarations.extend( | |
73 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) | |
74 for argument in arguments) | |
75 return { | |
76 'argument_declarations': argument_declarations, | |
77 'arguments': [argument_context(argument) for argument in arguments], | |
78 } | |
OLD | NEW |