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

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

Issue 10741002: Replace 'NativeTraits' typedef with 'isNode', 'isActive', and 'isEventTarget' static boolean fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 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 255ec92ba5ff93c3f70623329c40454bc47aa805..116590da54fc332053ef71a1b753a3587c0be0b1 100644
--- a/lib/dom/scripts/systemnative.py
+++ b/lib/dom/scripts/systemnative.py
@@ -421,14 +421,22 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
INTERFACE=self._interface.id)
webcore_includes = _GenerateCPPIncludes(self._interface_type_info.webcore_includes())
- wrapper_type = _DOMWrapperType(self._database, self._interface)
+
+ is_node_checker = lambda interface: interface.id == 'Node'
Anton Muhin 2012/07/09 15:22:43 nit: _test instead of _checker?
podivilov 2012/07/10 10:51:13 Done.
+ is_active_checker = lambda interface: 'ActiveDOMObject' in interface.ext_attrs
+ is_event_target_checker = lambda interface: 'EventTarget' in interface.ext_attrs
+ def TypeCheckHelper(checker):
+ return 'true' if _FindInHierarchy(self._database, self._interface, checker) else 'false'
+
self._cpp_header_emitter.Emit(
self._system._templates.Load('cpp_header.template'),
INTERFACE=self._interface.id,
WEBCORE_INCLUDES=webcore_includes,
WEBCORE_CLASS_NAME=self._interface_type_info.native_type(),
DECLARATIONS=self._cpp_declarations_emitter.Fragments(),
- NATIVE_TRAITS_TYPE='DartDOMWrapper::%sTraits' % wrapper_type,
+ IS_NODE=TypeCheckHelper(is_node_checker),
+ IS_ACTIVE=TypeCheckHelper(is_active_checker),
+ IS_EVENT_TARGET=TypeCheckHelper(is_event_target_checker),
TO_NATIVE=to_native_emitter.Fragments(),
TO_DART=to_dart_emitter.Fragments())
@@ -942,28 +950,15 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
def _GenerateCPPIncludes(includes):
return ''.join(['#include %s\n' % include for include in sorted(includes)])
-def _DOMWrapperType(database, interface):
- if interface.id == 'MessagePort':
- return 'MessagePort'
-
- type = 'Object'
- def is_node(interface):
- return interface.id == 'Node'
- if is_node(interface) or _FindParent(interface, database, is_node):
- type = 'Node'
- if 'ActiveDOMObject' in interface.ext_attrs:
- type = 'Active%s' % type
- return type
-
-def _FindParent(interface, database, callback):
+def _FindInHierarchy(database, interface, checker):
Anton Muhin 2012/07/09 15:22:43 ditto for test
podivilov 2012/07/10 10:51:13 Done.
+ if checker(interface):
+ return interface
for parent in interface.parents:
parent_name = parent.type.id
if not database.HasInterface(parent.type.id):
continue
parent_interface = database.GetInterface(parent.type.id)
- if callback(parent_interface):
- return parent_interface
- parent_interface = _FindParent(parent_interface, database, callback)
+ parent_interface = _FindInHierarchy(database, parent_interface, checker)
if parent_interface:
return parent_interface
« 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