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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/dom/scripts/generator.py ('k') | tools/dom/src/native_DOMImplementation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/systemnative.py
===================================================================
--- tools/dom/scripts/systemnative.py (revision 28728)
+++ tools/dom/scripts/systemnative.py (working copy)
@@ -224,7 +224,7 @@
return template
def RootClassName(self):
- return 'NativeFieldWrapperClass1'
+ return 'NativeFieldWrapperClass2'
def NativeSpec(self):
return ''
@@ -1184,6 +1184,95 @@
' return func;\n',
CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
+ def EmitClassIdTable(self, database, output_dir, type_registry, renamer):
+ 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
+ e = self._emitters.FileEmitter(path)
vsm 2013/10/17 18:52:42 We could factor this out as a template to make it
+ e.Emit('// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file\n');
+ e.Emit('// for details. All rights reserved. Use of this source code is governed by a\n');
+ e.Emit('// BSD-style license that can be found in the LICENSE file.\n');
+ e.Emit('// WARNING: Do not edit - generated code.\n');
+ e.Emit('// See dart/tools/dom/scripts/systemnative.py\n');
+ e.Emit('\n');
+ e.Emit('#ifndef DartWebkitClassIds_h\n');
+ e.Emit('#define DartWebkitClassIds_h\n');
+ e.Emit('\n');
+ e.Emit('namespace WebCore {\n');
+ e.Emit('\n');
+ e.Emit('enum {\n');
+ e.Emit(' _HistoryCrossFrameClassId = 0,\n');
+ e.Emit(' _LocationCrossFrameClassId,\n');
+ e.Emit(' _DOMWindowCrossFrameClassId,\n');
+ e.Emit(' _DateTimeClassId,\n');
+ e.Emit(' // New types that are not auto-generated should be added here.\n');
+ e.Emit('\n');
+ for interface in database.GetInterfaces():
+ interface_name = interface.id
+ e.Emit(' %sClassId,\n' % interface_name)
+ e.Emit(' NumWebkitClassIds\n');
+ e.Emit('};\n');
+
+ e.Emit('typedef struct {\n');
+ e.Emit(' const char* class_name;\n');
+ e.Emit(' int library_id;\n');
+ e.Emit(' int base_class_id;\n');
+ e.Emit(' bool is_node;\n');
+ e.Emit(' bool is_active;\n');
+ e.Emit(' bool is_event;\n');
+ e.Emit('} _Classinfo;\n');
+ e.Emit('typedef _Classinfo _DartWebkitClassInfo[NumWebkitClassIds];\n');
+ e.Emit('\n');
+ e.Emit('extern _DartWebkitClassInfo DartWebkitClassInfo;\n');
+ e.Emit('\n');
+ e.Emit('} // namespace WebCore\n');
+ e.Emit('#endif // DartWebkitClassIds_h\n');
+ self._emitters.Flush()
+
+ path = os.path.join(output_dir, 'DartWebkitClassIds.cpp')
+ e = self._emitters.FileEmitter(path)
+ e.Emit('// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file\n');
+ e.Emit('// for details. All rights reserved. Use of this source code is governed by a\n');
+ e.Emit('// BSD-style license that can be found in the LICENSE file.\n');
+ e.Emit('// WARNING: Do not edit - generated code.\n');
+ e.Emit('// See dart/tools/dom/scripts/systemnative.py\n');
+ e.Emit('\n');
+ e.Emit('#include "DartWebkitClassIds.h"\n');
+ e.Emit('\n');
+ e.Emit('#include "bindings/dart/DartLibraryIds.h"\n');
+ e.Emit('\n');
+ e.Emit('namespace WebCore {\n');
+ e.Emit('\n');
+ e.Emit("_DartWebkitClassInfo DartWebkitClassInfo = {\n");
+ e.Emit(' { "_HistoryCrossFrame", DartHtmlLibraryId, -1, false, false, false },\n');
+ e.Emit(' { "_LocationCrossFrame", DartHtmlLibraryId, -1, false, false, false },\n');
+ e.Emit(' { "_DOMWindowCrossFrame", DartHtmlLibraryId, -1, false, false, true },\n');
+ e.Emit(' { "DateTime", DartCoreLibraryId, -1, false, false, false },\n');
+ e.Emit(' // New types that are not auto-generated should be added here.\n');
+ e.Emit('\n');
+ is_node_test = lambda interface: interface.id == 'Node'
+ is_active_test = lambda interface: 'ActiveDOMObject' in interface.ext_attrs
+ is_event_target_test = lambda interface: 'EventTarget' in interface.ext_attrs
+ def TypeCheckHelper(test):
+ return 'true' if any(map(test, database.Hierarchy(interface))) else 'false'
+ for interface in database.GetInterfaces():
+ e.Emit(" {")
+ type_info = type_registry.TypeInfo(interface.id)
+ type_info.native_type().replace('<', '_').replace('>', '_'),
+ e.Emit(' "%s",' % type_info.implementation_name())
+ e.Emit(' Dart%sLibraryId,' % renamer.GetLibraryId(interface))
+ if interface.parents:
+ supertype = interface.parents[0].type.id
+ e.Emit(' %sClassId,\n' % supertype)
+ else:
+ e.Emit(' -1,')
+ e.Emit(" %s," % TypeCheckHelper(is_node_test))
+ e.Emit(" %s," % TypeCheckHelper(is_active_test))
+ e.Emit(" %s," % TypeCheckHelper(is_event_target_test))
+ e.Emit(" },\n")
+ e.Emit("};\n");
+ e.Emit('\n');
+ e.Emit('} // namespace WebCore\n');
+ self._emitters.Flush()
+
def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
return (
interface.id.endswith('Event') and
« 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