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

Unified Diff: lib/dom/scripts/systemnative.py

Issue 9977015: Add support for DOM node vs DOM object separation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | « no previous file | lib/dom/templates/dom/native/cpp_header.template » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/scripts/systemnative.py
diff --git a/lib/dom/scripts/systemnative.py b/lib/dom/scripts/systemnative.py
index 1cedf1b46ed8685361ae78a6d4af5731eba415a2..2f1a6d5161447d6b6f69ede77db2f3a6c5091f5f 100644
--- a/lib/dom/scripts/systemnative.py
+++ b/lib/dom/scripts/systemnative.py
@@ -46,7 +46,7 @@ class NativeImplementationSystem(System):
cpp_impl_path = self._FilePathForCppImplementation(interface_name)
self._cpp_impl_files.append(cpp_impl_path)
- return NativeImplementationGenerator(self, interface, super_interface_name,
+ return NativeImplementationGenerator(self, interface,
self._emitters.FileEmitter(dart_impl_path),
self._emitters.FileEmitter(cpp_header_path),
self._emitters.FileEmitter(cpp_impl_path),
@@ -195,7 +195,7 @@ class NativeImplementationSystem(System):
class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
"""Generates Dart implementation for one DOM IDL interface."""
- def __init__(self, system, interface, super_interface,
+ def __init__(self, system, interface,
dart_impl_emitter, cpp_header_emitter, cpp_impl_emitter,
base_members, templates):
"""Generates Dart and C++ code for the given interface.
@@ -205,8 +205,6 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
interface: an IDLInterface instance. It is assumed that all types have
been converted to Dart types (e.g. int, String), unless they are in
the same package as the interface.
- super_interface: A string or None, the name of the common interface that
- this interface implements, if any.
dart_impl_emitter: an Emitter for the file containing the Dart
implementation class.
cpp_header_emitter: an Emitter for the file containing the C++ header.
@@ -217,7 +215,6 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
"""
self._system = system
self._interface = interface
- self._super_interface = super_interface
self._dart_impl_emitter = dart_impl_emitter
self._cpp_header_emitter = cpp_header_emitter
self._cpp_impl_emitter = cpp_impl_emitter
@@ -390,13 +387,16 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
INTERFACE=self._interface.id,
WEBCORE_CLASS_NAME=self._interface_type_info.native_type())
+
+ wrapper_type = _DOMWrapperType(self._system._database, self._interface)
self._cpp_header_emitter.Emit(
self._templates.Load('cpp_header.template'),
INTERFACE=self._interface.id,
WEBCORE_INCLUDES=webcore_includes,
WEBCORE_CLASS_NAME=self._interface_type_info.native_type(),
TO_DART_VALUE=to_dart_value_emitter.Fragments(),
- DECLARATIONS=self._cpp_declarations_emitter.Fragments())
+ DECLARATIONS=self._cpp_declarations_emitter.Fragments(),
+ NATIVE_TRAITS_TYPE='DartDOMWrapper::%sTraits' % wrapper_type)
def _GenerateCallWithHandling(self, node, parameter_definitions_emitter, arguments):
if 'CallWith' not in node.ext_attrs:
@@ -838,3 +838,19 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
def _GenerateCPPIncludes(includes):
return ''.join(['#include %s\n' % include for include in includes])
+
+def _DOMWrapperType(database, idl_type):
+ if _IsNodeSubType(database, idl_type):
Anton Muhin 2012/04/04 18:41:56 will it return true for Node itself?
podivilov 2012/04/04 18:50:25 Done.
+ return 'DOMNode'
+ return 'DOMObject'
+
+def _IsNodeSubType(database, idl_type):
Anton Muhin 2012/04/04 18:41:56 is it possible to restructure it like: def _INST(
podivilov 2012/04/04 18:50:25 Done.
+ for parent in idl_type.parents:
+ type_name = parent.type.id
+ if type_name == 'Node':
+ return True
+ if database.HasInterface(type_name):
+ parent_idl_type = database.GetInterface(type_name)
Anton Muhin 2012/04/04 18:41:56 is it possible to combine Has and Get Interface?
podivilov 2012/04/04 18:50:25 It might be a good idea, but refactoring of databa
+ if _IsNodeSubType(database, parent_idl_type):
+ return True
+ return False
« no previous file with comments | « no previous file | lib/dom/templates/dom/native/cpp_header.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698