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

Side by Side Diff: tools/dom/scripts/systemnative.py

Issue 27358002: Generate a class table of all the IDL classes in the database. This table is used (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | « tools/dom/scripts/generator.py ('k') | tools/dom/src/native_DOMImplementation.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This module provides shared functionality for the systems to generate 6 """This module provides shared functionality for the systems to generate
7 native binding from the IDL database.""" 7 native binding from the IDL database."""
8 8
9 import emitter 9 import emitter
10 import os 10 import os
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 template = None 217 template = None
218 interface_name = self._interface.doc_js_name 218 interface_name = self._interface.doc_js_name
219 if interface_name == self._interface.id or not self._database.HasInterface(i nterface_name): 219 if interface_name == self._interface.id or not self._database.HasInterface(i nterface_name):
220 template_file = 'impl_%s.darttemplate' % interface_name 220 template_file = 'impl_%s.darttemplate' % interface_name
221 template = self._template_loader.TryLoad(template_file) 221 template = self._template_loader.TryLoad(template_file)
222 if not template: 222 if not template:
223 template = self._template_loader.Load('dart_implementation.darttemplate') 223 template = self._template_loader.Load('dart_implementation.darttemplate')
224 return template 224 return template
225 225
226 def RootClassName(self): 226 def RootClassName(self):
227 return 'NativeFieldWrapperClass1' 227 return 'NativeFieldWrapperClass2'
228 228
229 def NativeSpec(self): 229 def NativeSpec(self):
230 return '' 230 return ''
231 231
232 def StartInterface(self, members_emitter): 232 def StartInterface(self, members_emitter):
233 # Create emitters for c++ implementation. 233 # Create emitters for c++ implementation.
234 if not IsPureInterface(self._interface.id) and not IsCustomType(self._interf ace.id): 234 if not IsPureInterface(self._interface.id) and not IsCustomType(self._interf ace.id):
235 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter( 235 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter(
236 self._interface.id, 236 self._interface.id,
237 self._renamer.GetLibraryName(self._interface)) 237 self._renamer.GetLibraryName(self._interface))
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 1177
1178 headers = self._library_headers[library_name] 1178 headers = self._library_headers[library_name]
1179 for header_file in headers: 1179 for header_file in headers:
1180 path = os.path.relpath(header_file, output_dir) 1180 path = os.path.relpath(header_file, output_dir)
1181 includes_emitter.Emit('#include "$PATH"\n', PATH=path) 1181 includes_emitter.Emit('#include "$PATH"\n', PATH=path)
1182 body_emitter.Emit( 1182 body_emitter.Emit(
1183 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' 1183 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n'
1184 ' return func;\n', 1184 ' return func;\n',
1185 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 1185 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
1186 1186
1187 def EmitClassIdTable(self, database, output_dir, type_registry, renamer):
1188 path = os.path.join(output_dir, 'DartWebkitClassIds.h')
blois 2013/10/18 17:31:39 Are there any gyp changes that are needed for this
siva 2013/10/19 00:06:45 No, no gyp changes are needed for this. The DartWe
1189 e = self._emitters.FileEmitter(path)
vsm 2013/10/17 18:52:42 We could factor this out as a template to make it
1190 e.Emit('// Copyright (c) 2013, the Dart project authors. Please see the AUT HORS file\n');
1191 e.Emit('// for details. All rights reserved. Use of this source code is gove rned by a\n');
1192 e.Emit('// BSD-style license that can be found in the LICENSE file.\n');
1193 e.Emit('// WARNING: Do not edit - generated code.\n');
1194 e.Emit('// See dart/tools/dom/scripts/systemnative.py\n');
1195 e.Emit('\n');
1196 e.Emit('#ifndef DartWebkitClassIds_h\n');
1197 e.Emit('#define DartWebkitClassIds_h\n');
1198 e.Emit('\n');
1199 e.Emit('namespace WebCore {\n');
1200 e.Emit('\n');
1201 e.Emit('enum {\n');
1202 e.Emit(' _HistoryCrossFrameClassId = 0,\n');
1203 e.Emit(' _LocationCrossFrameClassId,\n');
1204 e.Emit(' _DOMWindowCrossFrameClassId,\n');
1205 e.Emit(' _DateTimeClassId,\n');
1206 e.Emit(' // New types that are not auto-generated should be added here.\n ');
1207 e.Emit('\n');
1208 for interface in database.GetInterfaces():
1209 interface_name = interface.id
1210 e.Emit(' %sClassId,\n' % interface_name)
1211 e.Emit(' NumWebkitClassIds\n');
1212 e.Emit('};\n');
1213
1214 e.Emit('typedef struct {\n');
1215 e.Emit(' const char* class_name;\n');
1216 e.Emit(' int library_id;\n');
1217 e.Emit(' int base_class_id;\n');
1218 e.Emit(' bool is_node;\n');
1219 e.Emit(' bool is_active;\n');
1220 e.Emit(' bool is_event;\n');
1221 e.Emit('} _Classinfo;\n');
1222 e.Emit('typedef _Classinfo _DartWebkitClassInfo[NumWebkitClassIds];\n');
1223 e.Emit('\n');
1224 e.Emit('extern _DartWebkitClassInfo DartWebkitClassInfo;\n');
1225 e.Emit('\n');
1226 e.Emit('} // namespace WebCore\n');
1227 e.Emit('#endif // DartWebkitClassIds_h\n');
1228 self._emitters.Flush()
1229
1230 path = os.path.join(output_dir, 'DartWebkitClassIds.cpp')
1231 e = self._emitters.FileEmitter(path)
1232 e.Emit('// Copyright (c) 2013, the Dart project authors. Please see the AUT HORS file\n');
1233 e.Emit('// for details. All rights reserved. Use of this source code is gove rned by a\n');
1234 e.Emit('// BSD-style license that can be found in the LICENSE file.\n');
1235 e.Emit('// WARNING: Do not edit - generated code.\n');
1236 e.Emit('// See dart/tools/dom/scripts/systemnative.py\n');
1237 e.Emit('\n');
1238 e.Emit('#include "DartWebkitClassIds.h"\n');
1239 e.Emit('\n');
1240 e.Emit('#include "bindings/dart/DartLibraryIds.h"\n');
1241 e.Emit('\n');
1242 e.Emit('namespace WebCore {\n');
1243 e.Emit('\n');
1244 e.Emit("_DartWebkitClassInfo DartWebkitClassInfo = {\n");
1245 e.Emit(' { "_HistoryCrossFrame", DartHtmlLibraryId, -1, false, false, fal se },\n');
1246 e.Emit(' { "_LocationCrossFrame", DartHtmlLibraryId, -1, false, false, fa lse },\n');
1247 e.Emit(' { "_DOMWindowCrossFrame", DartHtmlLibraryId, -1, false, false, t rue },\n');
1248 e.Emit(' { "DateTime", DartCoreLibraryId, -1, false, false, false },\n');
1249 e.Emit(' // New types that are not auto-generated should be added here.\n ');
1250 e.Emit('\n');
1251 is_node_test = lambda interface: interface.id == 'Node'
1252 is_active_test = lambda interface: 'ActiveDOMObject' in interface.ext_attrs
1253 is_event_target_test = lambda interface: 'EventTarget' in interface.ext_attr s
1254 def TypeCheckHelper(test):
1255 return 'true' if any(map(test, database.Hierarchy(interface))) else 'false '
1256 for interface in database.GetInterfaces():
1257 e.Emit(" {")
1258 type_info = type_registry.TypeInfo(interface.id)
1259 type_info.native_type().replace('<', '_').replace('>', '_'),
1260 e.Emit(' "%s",' % type_info.implementation_name())
1261 e.Emit(' Dart%sLibraryId,' % renamer.GetLibraryId(interface))
1262 if interface.parents:
1263 supertype = interface.parents[0].type.id
1264 e.Emit(' %sClassId,\n' % supertype)
1265 else:
1266 e.Emit(' -1,')
1267 e.Emit(" %s," % TypeCheckHelper(is_node_test))
1268 e.Emit(" %s," % TypeCheckHelper(is_active_test))
1269 e.Emit(" %s," % TypeCheckHelper(is_event_target_test))
1270 e.Emit(" },\n")
1271 e.Emit("};\n");
1272 e.Emit('\n');
1273 e.Emit('} // namespace WebCore\n');
1274 self._emitters.Flush()
1275
1187 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 1276 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
1188 return ( 1277 return (
1189 interface.id.endswith('Event') and 1278 interface.id.endswith('Event') and
1190 operation.id.startswith('init') and 1279 operation.id.startswith('init') and
1191 argument.ext_attrs.get('Default') == 'Undefined' and 1280 argument.ext_attrs.get('Default') == 'Undefined' and
1192 argument.type.id == 'DOMString') 1281 argument.type.id == 'DOMString')
OLDNEW
« no previous file with comments | « tools/dom/scripts/generator.py ('k') | tools/dom/src/native_DOMImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698