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

Side by Side Diff: Source/bindings/scripts/unstable/v8_methods.py

Issue 64763004: IDL compiler: [Unforgeable] methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: FIXME Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/tests/idls/TestObjectPython.idl » ('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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 def generate_method(interface, method): 44 def generate_method(interface, method):
45 arguments = method.arguments 45 arguments = method.arguments
46 extended_attributes = method.extended_attributes 46 extended_attributes = method.extended_attributes
47 idl_type = method.idl_type 47 idl_type = method.idl_type
48 is_static = method.is_static 48 is_static = method.is_static
49 name = method.name 49 name = method.name
50 50
51 this_cpp_value = cpp_value(interface, method, len(arguments)) 51 this_cpp_value = cpp_value(interface, method, len(arguments))
52 this_custom_signature = custom_signature(arguments) 52 this_custom_signature = custom_signature(arguments)
53 if this_custom_signature: 53
54 signature = name + 'Signature' 54 def function_template():
55 elif is_static or 'DoNotCheckSignature' in extended_attributes: 55 # FIXME: Rename as follows:
56 signature = 'v8::Local<v8::Signature>()' 56 # desc => functionTemplate
57 else: 57 # instance => instanceTemplate
58 signature = 'defaultSignature' 58 # proto => prototypeTemplate
haraken 2013/11/08 07:44:11 Please do the same rename in V8DOMConfituration.
Nils Barth (inactive) 2013/11/08 10:20:13 Will do, updated FIXME.
59 if is_static:
60 return 'desc'
61 if 'Unforgeable' in extended_attributes:
62 return 'instance'
63 return 'proto'
64
65 def signature():
66 if this_custom_signature:
67 return name + 'Signature'
68 if is_static or 'DoNotCheckSignature' in extended_attributes:
69 return 'v8::Local<v8::Signature>()'
70 return 'defaultSignature'
59 71
60 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi th', 'ScriptArguments') 72 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi th', 'ScriptArguments')
61 if is_call_with_script_arguments: 73 if is_call_with_script_arguments:
62 includes.update(['bindings/v8/ScriptCallStackFactory.h', 74 includes.update(['bindings/v8/ScriptCallStackFactory.h',
63 'core/inspector/ScriptArguments.h']) 75 'core/inspector/ScriptArguments.h'])
64 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState') 76 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
65 if is_call_with_script_state: 77 if is_call_with_script_state:
66 includes.add('bindings/v8/ScriptState.h') 78 includes.add('bindings/v8/ScriptState.h')
67 is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes 79 is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes
68 if is_check_security_for_node: 80 if is_check_security_for_node:
(...skipping 10 matching lines...) Expand all
79 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging] 91 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging]
80 'arguments': [generate_argument(interface, method, argument, index) 92 'arguments': [generate_argument(interface, method, argument, index)
81 for index, argument in enumerate(arguments)], 93 for index, argument in enumerate(arguments)],
82 'conditional_string': v8_utilities.conditional_string(method), 94 'conditional_string': v8_utilities.conditional_string(method),
83 'cpp_type': v8_types.cpp_type(idl_type), 95 'cpp_type': v8_types.cpp_type(idl_type),
84 'cpp_value': this_cpp_value, 96 'cpp_value': this_cpp_value,
85 'custom_signature': this_custom_signature, 97 'custom_signature': this_custom_signature,
86 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] 98 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs]
87 'do_not_check_signature': not(this_custom_signature or is_static or 99 'do_not_check_signature': not(this_custom_signature or is_static or
88 v8_utilities.has_extended_attribute(method, 100 v8_utilities.has_extended_attribute(method,
89 ['DoNotCheckSignature', 'NotEnumerable', 'ReadOnly'])), 101 ['DoNotCheckSignature', 'NotEnumerable', 'ReadOnly',
90 'function_template': 'desc' if method.is_static else 'proto', 102 'Unforgeable'])),
103 'function_template': function_template(),
91 'idl_type': idl_type, 104 'idl_type': idl_type,
92 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'), 105 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'),
93 'is_call_with_script_arguments': is_call_with_script_arguments, 106 'is_call_with_script_arguments': is_call_with_script_arguments,
94 'is_call_with_script_state': is_call_with_script_state, 107 'is_call_with_script_state': is_call_with_script_state,
95 'is_check_security_for_node': is_check_security_for_node, 108 'is_check_security_for_node': is_check_security_for_node,
96 'is_custom': 'Custom' in extended_attributes, 109 'is_custom': 'Custom' in extended_attributes,
97 'is_custom_element_callbacks': is_custom_element_callbacks, 110 'is_custom_element_callbacks': is_custom_element_callbacks,
98 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, 111 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
99 'is_raises_exception': is_raises_exception, 112 'is_raises_exception': is_raises_exception,
100 'is_static': is_static, 113 'is_static': is_static,
101 'measure_as': v8_utilities.measure_as(method), # [MeasureAs] 114 'measure_as': v8_utilities.measure_as(method), # [MeasureAs]
102 'name': name, 115 'name': name,
103 'number_of_arguments': len(arguments), 116 'number_of_arguments': len(arguments),
104 'number_of_required_arguments': len([ 117 'number_of_required_arguments': len([
105 argument for argument in arguments 118 argument for argument in arguments
106 if not (argument.is_optional or argument.is_variadic)]), 119 if not (argument.is_optional or argument.is_variadic)]),
107 'number_of_required_or_variadic_arguments': len([ 120 'number_of_required_or_variadic_arguments': len([
108 argument for argument in arguments 121 argument for argument in arguments
109 if not argument.is_optional]), 122 if not argument.is_optional]),
110 'per_context_enabled_function_name': v8_utilities.per_context_enabled_fu nction_name(method), # [PerContextEnabled] 123 'per_context_enabled_function_name': v8_utilities.per_context_enabled_fu nction_name(method), # [PerContextEnabled]
111 'property_attributes': property_attributes(method), 124 'property_attributes': property_attributes(method),
112 'signature': signature, 125 'signature': signature(),
113 'v8_set_return_value': v8_set_return_value(method, this_cpp_value), 126 'v8_set_return_value': v8_set_return_value(method, this_cpp_value),
114 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings] 127 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings]
115 } 128 }
116 return contents 129 return contents
117 130
118 131
119 def generate_argument(interface, method, argument, index): 132 def generate_argument(interface, method, argument, index):
120 extended_attributes = argument.extended_attributes 133 extended_attributes = argument.extended_attributes
121 idl_type = argument.idl_type 134 idl_type = argument.idl_type
122 this_cpp_value = cpp_value(interface, method, index) 135 this_cpp_value = cpp_value(interface, method, index)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return 'V8TRYCATCH_VOID(Vector<{cpp_type}>, {name}, toNativeArguments<{c pp_type}>(info, {index}))'.format( 218 return 'V8TRYCATCH_VOID(Vector<{cpp_type}>, {name}, toNativeArguments<{c pp_type}>(info, {index}))'.format(
206 cpp_type=v8_types.cpp_type(idl_type), name=name, index=index) 219 cpp_type=v8_types.cpp_type(idl_type), name=name, index=index)
207 # [Default=NullString] 220 # [Default=NullString]
208 if (argument.is_optional and idl_type == 'DOMString' and 221 if (argument.is_optional and idl_type == 'DOMString' and
209 extended_attributes.get('Default') == 'NullString'): 222 extended_attributes.get('Default') == 'NullString'):
210 v8_value = 'argumentOrNull(info, %s)' % index 223 v8_value = 'argumentOrNull(info, %s)' % index
211 else: 224 else:
212 v8_value = 'info[%s]' % index 225 v8_value = 'info[%s]' % index
213 return v8_types.v8_value_to_local_cpp_value( 226 return v8_types.v8_value_to_local_cpp_value(
214 idl_type, argument.extended_attributes, v8_value, name, index=index) 227 idl_type, argument.extended_attributes, v8_value, name, index=index)
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/idls/TestObjectPython.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698