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

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

Issue 10155027: Support custom to native conversions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | « lib/dom/scripts/generator.py ('k') | 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 a1de7b5b35683a6d4e8a94ee4de3b18c90c479f2..48d78d44580468130067f7ce1f5046d6747d768f 100644
--- a/lib/dom/scripts/systemnative.py
+++ b/lib/dom/scripts/systemnative.py
@@ -380,35 +380,43 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
RESOLVER=self._cpp_resolver_emitter.Fragments())
def _GenerateCppHeader(self):
- webcore_includes = _GenerateCPPIncludes(self._interface_type_info.webcore_includes())
+ to_native_template = ' static PassRefPtr<NativeType> toNative(Dart_Handle handle, Dart_Handle& exception)'
+ if self._interface_type_info.custom_to_native():
+ to_native_template += ';\n'
+ else:
+ to_native_template += (
+ '\n'
+ ' {\n'
+ ' return DartDOMWrapper::unwrapDartWrapper<Dart$INTERFACE>(handle, exception);\n'
+ ' }\n')
if ('CustomToJS' in self._interface.ext_attrs or
'CustomToJSObject' in self._interface.ext_attrs or
'PureInterface' in self._interface.ext_attrs or
'CPPPureInterface' in self._interface.ext_attrs or
self._interface_type_info.custom_to_dart()):
- to_dart_value_template = (
+ to_dart_template = (
'Dart_Handle toDartValue($(WEBCORE_CLASS_NAME)* value);\n')
else:
- to_dart_value_template = (
+ to_dart_template = (
'inline Dart_Handle toDartValue($(WEBCORE_CLASS_NAME)* value)\n'
'{\n'
' return DartDOMWrapper::toDart<Dart$(INTERFACE)>(value);\n'
'}\n')
- to_dart_value_emitter = emitter.Emitter()
- to_dart_value_emitter.Emit(
- to_dart_value_template,
- INTERFACE=self._interface.id,
- WEBCORE_CLASS_NAME=self._interface_type_info.native_type())
+ intermediate_emitter = emitter.Emitter()
Anton Muhin 2012/04/24 14:05:51 this two level emitting might be too much. Maybe
podivilov 2012/04/24 14:30:33 Done.
+ intermediate_emitter.Emit(
+ self._templates.Load('cpp_header.template'),
+ TO_NATIVE=to_native_template,
+ TO_DART=to_dart_template)
+ webcore_includes = _GenerateCPPIncludes(self._interface_type_info.webcore_includes())
wrapper_type = _DOMWrapperType(self._system._database, self._interface)
self._cpp_header_emitter.Emit(
- self._templates.Load('cpp_header.template'),
+ ''.join(intermediate_emitter.Fragments()),
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(),
NATIVE_TRAITS_TYPE='DartDOMWrapper::%sTraits' % wrapper_type)
« no previous file with comments | « lib/dom/scripts/generator.py ('k') | lib/dom/templates/dom/native/cpp_header.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698