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

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

Issue 1455883003: bindings: Pass dictionaries to callback methods by const reference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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 # Pass containers and dictionaries to callback method by const reference rat her than by value
67 if raw_cpp_type.startswith(('Vector', 'HeapVector', 'WillBeHeapVector')) or idl_type.is_dictionary:
67 return 'const %s&' % raw_cpp_type 68 return 'const %s&' % raw_cpp_type
68 return raw_cpp_type 69 return raw_cpp_type
69 70
70 IdlTypeBase.callback_cpp_type = property(cpp_type) 71 IdlTypeBase.callback_cpp_type = property(cpp_type)
71 72
72 73
73 def callback_interface_context(callback_interface): 74 def callback_interface_context(callback_interface):
74 includes.clear() 75 includes.clear()
75 includes.update(CALLBACK_INTERFACE_CPP_INCLUDES) 76 includes.update(CALLBACK_INTERFACE_CPP_INCLUDES)
76 return { 77 return {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 123 }
123 124
124 argument_declarations = ['ScriptValue thisValue'] if call_with_this_handle e lse [] 125 argument_declarations = ['ScriptValue thisValue'] if call_with_this_handle e lse []
125 argument_declarations.extend( 126 argument_declarations.extend(
126 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) 127 '%s %s' % (argument.idl_type.callback_cpp_type, argument.name)
127 for argument in arguments) 128 for argument in arguments)
128 return { 129 return {
129 'argument_declarations': argument_declarations, 130 'argument_declarations': argument_declarations,
130 'arguments': [argument_context(argument) for argument in arguments], 131 'arguments': [argument_context(argument) for argument in arguments],
131 } 132 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698