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

Side by Side Diff: Source/build/scripts/name_macros.py

Issue 221233005: Remove remaining Dart-specific perl code in Dartium (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/1847
Patch Set: Remove msvs setting Created 6 years, 8 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/dart/gyp/scripts/xxd.pl ('k') | Source/core/core_generated.gyp » ('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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 65
66 class Writer(in_generator.Writer): 66 class Writer(in_generator.Writer):
67 def __init__(self, in_file_path): 67 def __init__(self, in_file_path):
68 super(Writer, self).__init__(in_file_path) 68 super(Writer, self).__init__(in_file_path)
69 self.namespace = self.in_file.parameters['namespace'].strip('"') 69 self.namespace = self.in_file.parameters['namespace'].strip('"')
70 self._entries_by_conditional = {} 70 self._entries_by_conditional = {}
71 self._unconditional_entries = [] 71 self._unconditional_entries = []
72 self._validate_entries() 72 self._validate_entries()
73 self._sort_entries_by_conditional() 73 self._sort_entries_by_conditional()
74 self._outputs = {(self.namespace + "Headers.h"): self.generate_headers_h eader, 74 self._outputs = {(self.namespace + "Headers.h"): self.generate_v8_header s_header,
75 ('Dart' + self.namespace + "Headers.h"): self.generate_ dart_headers_header,
75 (self.namespace + "Interfaces.h"): self.generate_interf aces_header, 76 (self.namespace + "Interfaces.h"): self.generate_interf aces_header,
76 } 77 }
77 78
78 def _validate_entries(self): 79 def _validate_entries(self):
79 # If there is more than one entry with the same script name, only the fi rst one will ever 80 # If there is more than one entry with the same script name, only the fi rst one will ever
80 # be hit in practice, and so we'll silently ignore any properties reques ted for the second 81 # be hit in practice, and so we'll silently ignore any properties reques ted for the second
81 # (like RuntimeEnabled - see crbug.com/332588). 82 # (like RuntimeEnabled - see crbug.com/332588).
82 entries_by_script_name = dict() 83 entries_by_script_name = dict()
83 for entry in self.in_file.name_dictionaries: 84 for entry in self.in_file.name_dictionaries:
84 script_name = name_utilities.script_name(entry) 85 script_name = name_utilities.script_name(entry)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 def _headers_header_include_path(self, entry): 117 def _headers_header_include_path(self, entry):
117 if entry['ImplementedAs']: 118 if entry['ImplementedAs']:
118 path = os.path.dirname(entry['name']) 119 path = os.path.dirname(entry['name'])
119 if len(path): 120 if len(path):
120 path += '/' 121 path += '/'
121 path += entry['ImplementedAs'] 122 path += entry['ImplementedAs']
122 else: 123 else:
123 path = entry['name'] 124 path = entry['name']
124 return path + '.h' 125 return path + '.h'
125 126
126 def _headers_header_includes(self, entries): 127 def _headers_header_includes(self, entries, engine):
127 includes = dict() 128 includes = dict()
128 for entry in entries: 129 for entry in entries:
129 cpp_name = name_utilities.cpp_name(entry) 130 cpp_name = name_utilities.cpp_name(entry)
130 # Avoid duplicate includes. 131 # Avoid duplicate includes.
131 if cpp_name in includes: 132 if cpp_name in includes:
132 continue 133 continue
133 include = '#include "%(path)s"\n#include "V8%(script_name)s.h"' % { 134 include = '#include "%(path)s"\n#include "%(engine)s%(script_name)s. h"' % {
134 'path': self._headers_header_include_path(entry), 135 'path': self._headers_header_include_path(entry),
135 'script_name': name_utilities.script_name(entry), 136 'script_name': name_utilities.script_name(entry),
137 'engine': engine,
136 } 138 }
137 includes[cpp_name] = self.wrap_with_condition(include, entry['Condit ional']) 139 includes[cpp_name] = self.wrap_with_condition(include, entry['Condit ional'])
138 return includes.values() 140 return includes.values()
139 141
140 def generate_headers_header(self): 142 def _generate_headers_header(self, engine):
141 return HEADER_TEMPLATE % { 143 return HEADER_TEMPLATE % {
142 'license': license.license_for_generated_cpp(), 144 'license': license.license_for_generated_cpp(),
143 'namespace': self.namespace, 145 'namespace': self.namespace,
144 'includes': '\n'.join(self._headers_header_includes(self.in_file.nam e_dictionaries)), 146 'includes': '\n'.join(self._headers_header_includes(self.in_file.nam e_dictionaries, engine)),
145 } 147 }
146 148
149 def generate_dart_headers_header(self):
150 return self._generate_headers_header('Dart')
151
152 def generate_v8_headers_header(self):
153 return self._generate_headers_header('V8')
154
147 def _declare_one_conditional_macro(self, conditional, entries): 155 def _declare_one_conditional_macro(self, conditional, entries):
148 macro_name = '%(macro_style_name)s_INTERFACES_FOR_EACH_%(conditional)s' % { 156 macro_name = '%(macro_style_name)s_INTERFACES_FOR_EACH_%(conditional)s' % {
149 'macro_style_name': name_utilities.to_macro_style(self.namespace), 157 'macro_style_name': name_utilities.to_macro_style(self.namespace),
150 'conditional': conditional, 158 'conditional': conditional,
151 } 159 }
152 return self.wrap_with_condition("""#define %(macro_name)s(macro) \\ 160 return self.wrap_with_condition("""#define %(macro_name)s(macro) \\
153 %(declarations)s 161 %(declarations)s
154 162
155 #else 163 #else
156 #define %(macro_name)s(macro)""" % { 164 #define %(macro_name)s(macro)""" % {
(...skipping 19 matching lines...) Expand all
176 184
177 def generate_interfaces_header(self): 185 def generate_interfaces_header(self):
178 return INTERFACES_HEADER_TEMPLATE % { 186 return INTERFACES_HEADER_TEMPLATE % {
179 'license': license.license_for_generated_cpp(), 187 'license': license.license_for_generated_cpp(),
180 'namespace': self.namespace, 188 'namespace': self.namespace,
181 'macro_style_name': name_utilities.to_macro_style(self.namespace), 189 'macro_style_name': name_utilities.to_macro_style(self.namespace),
182 'declare_conditional_macros': self._declare_conditional_macros(), 190 'declare_conditional_macros': self._declare_conditional_macros(),
183 'unconditional_macros': '\n'.join(sorted(set(map(self._unconditional _macro, self._unconditional_entries)))), 191 'unconditional_macros': '\n'.join(sorted(set(map(self._unconditional _macro, self._unconditional_entries)))),
184 'conditional_macros': '\n'.join(map(self._conditional_macros, self._ entries_by_conditional.keys())), 192 'conditional_macros': '\n'.join(map(self._conditional_macros, self._ entries_by_conditional.keys())),
185 } 193 }
OLDNEW
« no previous file with comments | « Source/bindings/dart/gyp/scripts/xxd.pl ('k') | Source/core/core_generated.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698