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

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

Issue 23681014: - Modify toDart to first do a simple lookup in the appropriate table before going down the templati… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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
Index: tools/dom/scripts/systemnative.py
===================================================================
--- tools/dom/scripts/systemnative.py (revision 27632)
+++ tools/dom/scripts/systemnative.py (working copy)
@@ -411,17 +411,39 @@
ext_attrs = self._interface.ext_attrs
+ to_dart_emitter.Emit(
+ ' static Dart_Handle toDart(NativeType* value)\n'
+ ' {\n'
+ ' if (!value)\n'
+ ' return Dart_Null();\n'
+ ' Dart_WeakPersistentHandle result = DartDOMWrapper::lookupWrapper(isNode, value);\n'
+ ' if (result)\n'
+ ' return Dart_HandleFromWeakPersistent(result);\n'
+ ' return createWrapper(value);\n'
+ ' }\n'
+ ' static void returnToDart(Dart_NativeArguments args, NativeType* value)\n'
+ ' {\n'
+ ' if (value) {\n'
+ ' Dart_WeakPersistentHandle result = DartDOMWrapper::lookupWrapper(isNode, value);\n'
+ ' if (result)\n'
+ ' Dart_SetWeakHandleReturnValue(args, result);\n'
+ ' else\n'
+ ' Dart_SetReturnValue(args, createWrapper(value));\n'
+ ' }\n'
+ ' }\n',
+ )
+
if ('CustomToV8' in ext_attrs or
'PureInterface' in ext_attrs or
'CPPPureInterface' in ext_attrs or
self._interface_type_info.custom_to_dart()):
to_dart_emitter.Emit(
- ' static Dart_Handle toDart(NativeType* value);\n')
+ ' static Dart_Handle createWrapper(NativeType* value);\n')
else:
to_dart_emitter.Emit(
- ' static Dart_Handle toDart(NativeType* value)\n'
+ ' static Dart_Handle createWrapper(NativeType* value)\n'
' {\n'
- ' return DartDOMWrapper::toDart<Dart$(INTERFACE)>(value);\n'
+ ' return DartDOMWrapper::createWrapper<Dart$(INTERFACE)>(value);\n'
' }\n',
INTERFACE=self._interface.id)
@@ -431,6 +453,7 @@
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, self._database.Hierarchy(self._interface))) else 'false'
@@ -1005,9 +1028,11 @@
set_return_value = 'DartUtilities::setDartStringReturnValueWithNullCheck(args, %s)' % (value_expression)
else:
set_return_value = 'DartUtilities::setDartStringReturnValue(args, %s)' % (value_expression)
+ elif return_type_info.dart_type() == 'num' and return_type_info.native_type() == 'double':
+ set_return_value = 'Dart_SetDoubleReturnValue(args, %s)' % (value_expression)
else:
- to_dart_conversion = return_type_info.to_dart_conversion(value_expression, self._interface.id, ext_attrs)
- set_return_value = 'Dart_SetReturnValue(args, %s)' % (to_dart_conversion)
+ return_to_dart_conversion = return_type_info.return_to_dart_conversion(value_expression, self._interface.id, ext_attrs)
+ set_return_value = '%s' % (return_to_dart_conversion)
invocation_emitter.Emit(
' $RETURN_VALUE;\n',
RETURN_VALUE=set_return_value)

Powered by Google App Engine
This is Rietveld 408576698