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

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

Issue 370563002: Remove PrivateScriptInterface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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/IDLExtendedAttributes.txt ('k') | Source/bindings/scripts/scripts.gypi » ('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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 # Insert at 1 so at front to override system libraries, and 68 # Insert at 1 so at front to override system libraries, and
69 # after path[0] == invoking script dir 69 # after path[0] == invoking script dir
70 sys.path.insert(1, third_party_dir) 70 sys.path.insert(1, third_party_dir)
71 import jinja2 71 import jinja2
72 72
73 import idl_types 73 import idl_types
74 from idl_types import IdlType 74 from idl_types import IdlType
75 import v8_callback_interface 75 import v8_callback_interface
76 from v8_globals import includes, interfaces 76 from v8_globals import includes, interfaces
77 import v8_interface 77 import v8_interface
78 import v8_private_script_interface
79 import v8_types 78 import v8_types
80 from v8_utilities import capitalize, cpp_name, conditional_string, v8_class_name 79 from v8_utilities import capitalize, cpp_name, conditional_string, v8_class_name
81 80
82 81
83 class CodeGeneratorV8(object): 82 class CodeGeneratorV8(object):
84 def __init__(self, interfaces_info, cache_dir): 83 def __init__(self, interfaces_info, cache_dir):
85 interfaces_info = interfaces_info or {} 84 interfaces_info = interfaces_info or {}
86 self.interfaces_info = interfaces_info 85 self.interfaces_info = interfaces_info
87 self.jinja_env = initialize_jinja_env(cache_dir) 86 self.jinja_env = initialize_jinja_env(cache_dir)
88 87
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 # Set local type info 123 # Set local type info
125 IdlType.set_callback_functions(definitions.callback_functions.keys()) 124 IdlType.set_callback_functions(definitions.callback_functions.keys())
126 IdlType.set_enums((enum.name, enum.values) 125 IdlType.set_enums((enum.name, enum.values)
127 for enum in definitions.enumerations.values()) 126 for enum in definitions.enumerations.values())
128 127
129 # Select appropriate Jinja template and contents function 128 # Select appropriate Jinja template and contents function
130 if interface.is_callback: 129 if interface.is_callback:
131 header_template_filename = 'callback_interface.h' 130 header_template_filename = 'callback_interface.h'
132 cpp_template_filename = 'callback_interface.cpp' 131 cpp_template_filename = 'callback_interface.cpp'
133 interface_context = v8_callback_interface.callback_interface_context 132 interface_context = v8_callback_interface.callback_interface_context
134 elif 'PrivateScriptInterface' in interface.extended_attributes:
135 # Currently private scripts don't have dependencies. Once private sc ripts have dependencies,
136 # we should add them to interface_info.
137 header_template_filename = 'private_script_interface.h'
138 cpp_template_filename = 'private_script_interface.cpp'
139 interface_context = v8_private_script_interface.private_script_inter face_context
140 else: 133 else:
141 header_template_filename = 'interface.h' 134 header_template_filename = 'interface.h'
142 cpp_template_filename = 'interface.cpp' 135 cpp_template_filename = 'interface.cpp'
143 interface_context = v8_interface.interface_context 136 interface_context = v8_interface.interface_context
144 header_template = self.jinja_env.get_template(header_template_filename) 137 header_template = self.jinja_env.get_template(header_template_filename)
145 cpp_template = self.jinja_env.get_template(cpp_template_filename) 138 cpp_template = self.jinja_env.get_template(cpp_template_filename)
146 139
147 # Compute context (input values for Jinja) 140 # Compute context (input values for Jinja)
148 template_context = interface_context(interface) 141 template_context = interface_context(interface)
149 template_context['code_generator'] = module_pyname 142 template_context['code_generator'] = module_pyname
150 143
151 # Add includes for interface itself and any dependencies 144 # Add includes for interface itself and any dependencies
152 interface_info = self.interfaces_info[interface_name] 145 interface_info = self.interfaces_info[interface_name]
153 if 'PrivateScriptInterface' not in interface.extended_attributes: 146 template_context['header_includes'].add(interface_info['include_path'])
154 template_context['header_includes'].add(interface_info['include_path '])
155 template_context['header_includes'] = sorted(template_context['header_in cludes']) 147 template_context['header_includes'] = sorted(template_context['header_in cludes'])
156 includes.update(interface_info.get('dependencies_include_paths', [])) 148 includes.update(interface_info.get('dependencies_include_paths', []))
157 template_context['cpp_includes'] = sorted(includes) 149 template_context['cpp_includes'] = sorted(includes)
158 150
159 # Render Jinja templates 151 # Render Jinja templates
160 header_text = header_template.render(template_context) 152 header_text = header_template.render(template_context)
161 cpp_text = cpp_template.render(template_context) 153 cpp_text = cpp_template.render(template_context)
162 return header_text, cpp_text 154 return header_text, cpp_text
163 155
164 156
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 213
222 # Create a dummy file as output for the build system, 214 # Create a dummy file as output for the build system,
223 # since filenames of individual cache files are unpredictable and opaque 215 # since filenames of individual cache files are unpredictable and opaque
224 # (they are hashes of the template path, which varies based on environment) 216 # (they are hashes of the template path, which varies based on environment)
225 with open(dummy_filename, 'w') as dummy_file: 217 with open(dummy_filename, 'w') as dummy_file:
226 pass # |open| creates or touches the file 218 pass # |open| creates or touches the file
227 219
228 220
229 if __name__ == '__main__': 221 if __name__ == '__main__':
230 sys.exit(main(sys.argv)) 222 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « Source/bindings/IDLExtendedAttributes.txt ('k') | Source/bindings/scripts/scripts.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698