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

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

Issue 47023015: IDL compiler: [Default] arguments (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revised 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 | « Source/bindings/scripts/code_generator_v8.pm ('k') | Source/bindings/templates/methods.cpp » ('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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return contents 58 return contents
59 59
60 60
61 def generate_argument(method, argument, index): 61 def generate_argument(method, argument, index):
62 extended_attributes = argument.extended_attributes 62 extended_attributes = argument.extended_attributes
63 idl_type = argument.idl_type 63 idl_type = argument.idl_type
64 return { 64 return {
65 'cpp_method': cpp_method(method, index), 65 'cpp_method': cpp_method(method, index),
66 'cpp_type': v8_types.cpp_type(idl_type), 66 'cpp_type': v8_types.cpp_type(idl_type),
67 'enum_validation_expression': v8_utilities.enum_validation_expression(id l_type), 67 'enum_validation_expression': v8_utilities.enum_validation_expression(id l_type),
68 'has_default': 'Default' in extended_attributes,
68 'idl_type': argument.idl_type, 69 'idl_type': argument.idl_type,
69 'index': index, 70 'index': index,
70 'is_clamp': 'Clamp' in extended_attributes, 71 'is_clamp': 'Clamp' in extended_attributes,
71 'is_optional': argument.is_optional, 72 'is_optional': argument.is_optional,
72 'is_variadic_wrapper_type': argument.is_variadic and v8_types.is_wrapper _type(idl_type), 73 'is_variadic_wrapper_type': argument.is_variadic and v8_types.is_wrapper _type(idl_type),
73 'name': argument.name, 74 'name': argument.name,
74 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex), 75 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex),
75 } 76 }
76 77
77 78
(...skipping 19 matching lines...) Expand all
97 def argument_template(argument): 98 def argument_template(argument):
98 idl_type = argument.idl_type 99 idl_type = argument.idl_type
99 if (v8_types.is_wrapper_type(idl_type) and 100 if (v8_types.is_wrapper_type(idl_type) and
100 not v8_types.is_typed_array_type(idl_type) and 101 not v8_types.is_typed_array_type(idl_type) and
101 # Compatibility: all other browsers accepts a callable for 102 # Compatibility: all other browsers accepts a callable for
102 # XPathNSResolver, despite it being against spec. 103 # XPathNSResolver, despite it being against spec.
103 not idl_type == 'XPathNSResolver'): 104 not idl_type == 'XPathNSResolver'):
104 return 'V8PerIsolateData::from(isolate)->rawTemplate(&V8{idl_type}:: wrapperTypeInfo, currentWorldType)'.format(idl_type=idl_type) 105 return 'V8PerIsolateData::from(isolate)->rawTemplate(&V8{idl_type}:: wrapperTypeInfo, currentWorldType)'.format(idl_type=idl_type)
105 return 'v8::Handle<v8::FunctionTemplate>()' 106 return 'v8::Handle<v8::FunctionTemplate>()'
106 107
107 if (any(argument.is_optional for argument in arguments) or 108 if (any(argument.is_optional and
109 'Default' not in argument.extended_attributes
110 for argument in arguments) or
108 all(not v8_types.is_wrapper_type(argument.idl_type) 111 all(not v8_types.is_wrapper_type(argument.idl_type)
109 for argument in arguments)): 112 for argument in arguments)):
110 return None 113 return None
111 return ', '.join([argument_template(argument) for argument in arguments]) 114 return ', '.join([argument_template(argument) for argument in arguments])
112 115
113 116
114 def v8_value_to_local_cpp_value(argument, index): 117 def v8_value_to_local_cpp_value(argument, index):
118 extended_attributes = argument.extended_attributes
115 idl_type = argument.idl_type 119 idl_type = argument.idl_type
116 name = argument.name 120 name = argument.name
117 if argument.is_variadic: 121 if argument.is_variadic:
118 return 'V8TRYCATCH_VOID(Vector<{cpp_type}>, {name}, toNativeArguments<{c pp_type}>(args, {index}))'.format( 122 return 'V8TRYCATCH_VOID(Vector<{cpp_type}>, {name}, toNativeArguments<{c pp_type}>(args, {index}))'.format(
119 cpp_type=v8_types.cpp_type(idl_type), name=name, index=index) 123 cpp_type=v8_types.cpp_type(idl_type), name=name, index=index)
124 if (argument.is_optional and idl_type == 'DOMString' and
125 extended_attributes.get('Default') == 'NullString'):
126 v8_value = 'argumentOrNull(args, %s)' % index
127 else:
128 v8_value = 'args[%s]' % index
120 return v8_types.v8_value_to_local_cpp_value( 129 return v8_types.v8_value_to_local_cpp_value(
121 idl_type, argument.extended_attributes, 130 idl_type, argument.extended_attributes, v8_value, name,
122 'args[%s]' % index, name, 'args.GetIsolate()', index=index) 131 'args.GetIsolate()', index=index)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/code_generator_v8.pm ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698