Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: Source/bindings/scripts/v8_callback_interface.py

Issue 345893002: Implement an infrastructure of Blink-in-JS Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/scripts/scripts.gypi ('k') | Source/bindings/scripts/v8_interface.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 55
56 def cpp_type(idl_type): 56 def cpp_type(idl_type):
57 # FIXME: remove this function by making callback types consistent 57 # FIXME: remove this function by making callback types consistent
58 # (always use usual v8_types.cpp_type) 58 # (always use usual v8_types.cpp_type)
59 idl_type_name = idl_type.name 59 idl_type_name = idl_type.name
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 used_as_argument=True 64 # Callbacks use raw pointers, so used_as_raw_type=True
65 usual_cpp_type = idl_type.cpp_type_args(used_as_argument=True) 65 raw_cpp_type = idl_type.cpp_type_args(used_as_raw_type=True)
66 if usual_cpp_type.startswith(('Vector', 'HeapVector', 'WillBeHeapVector')): 66 if raw_cpp_type.startswith(('Vector', 'HeapVector', 'WillBeHeapVector')):
67 return 'const %s&' % usual_cpp_type 67 return 'const %s&' % raw_cpp_type
68 return usual_cpp_type 68 return raw_cpp_type
69 69
70 IdlType.callback_cpp_type = property(cpp_type) 70 IdlType.callback_cpp_type = property(cpp_type)
71 71
72 72
73 def generate_callback_interface(callback_interface): 73 def generate_callback_interface(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,
(...skipping 29 matching lines...) Expand all
108 'name': operation.name, 108 'name': operation.name,
109 } 109 }
110 contents.update(generate_arguments_contents(operation.arguments, call_with_t his_handle)) 110 contents.update(generate_arguments_contents(operation.arguments, call_with_t his_handle))
111 return contents 111 return contents
112 112
113 113
114 def generate_arguments_contents(arguments, call_with_this_handle): 114 def generate_arguments_contents(arguments, call_with_this_handle):
115 def generate_argument(argument): 115 def generate_argument(argument):
116 return { 116 return {
117 'handle': '%sHandle' % argument.name, 117 'handle': '%sHandle' % argument.name,
118 # FIXME: setting creation_context=v8::Handle<v8::Object>() is
119 # wrong, as toV8 then implicitly uses the current context, which
120 # causes leaks between isolated worlds if a different context is
121 # used.
122 'cpp_value_to_v8_value': argument.idl_type.cpp_value_to_v8_value( 118 'cpp_value_to_v8_value': argument.idl_type.cpp_value_to_v8_value(
123 argument.name, isolate='isolate', 119 argument.name, isolate='isolate',
124 creation_context='m_scriptState->context()->Global()'), 120 creation_context='m_scriptState->context()->Global()'),
125 } 121 }
126 122
127 argument_declarations = ['ScriptValue thisValue'] if call_with_this_handle e lse [] 123 argument_declarations = ['ScriptValue thisValue'] if call_with_this_handle e lse []
128 argument_declarations.extend( 124 argument_declarations.extend(
129 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) 125 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name)
130 for argument in arguments) 126 for argument in arguments)
131 return { 127 return {
132 'argument_declarations': argument_declarations, 128 'argument_declarations': argument_declarations,
133 'arguments': [generate_argument(argument) for argument in arguments], 129 'arguments': [generate_argument(argument) for argument in arguments],
134 } 130 }
OLDNEW
« no previous file with comments | « Source/bindings/scripts/scripts.gypi ('k') | Source/bindings/scripts/v8_interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698