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

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

Issue 9480001: Support named ctors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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 | client/dom/src/native_FactoryProvidersImplementation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/scripts/systemnative.py
diff --git a/client/dom/scripts/systemnative.py b/client/dom/scripts/systemnative.py
index 7e8116719f029427e71b41d2701330fb6224162c..9235f9ed8eccdc7b37817c1433d45a51a89af1e0 100644
--- a/client/dom/scripts/systemnative.py
+++ b/client/dom/scripts/systemnative.py
@@ -279,6 +279,18 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
type_info = GetIDLTypeInfo(self._interface)
arguments = []
parameter_definitions_emitter = emitter.Emitter()
+ create_function = 'create'
+ if 'NamedConstructor' in self._interface.ext_attrs:
+ raises_dart_exceptions = True
+ parameter_definitions_emitter.Emit(
+ ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIsolate();\n'
+ ' if (!domWindow) {\n'
+ ' exception = Dart_NewString("Failed to fetch domWindow");\n'
+ ' goto fail;\n'
+ ' }\n'
+ ' Document* document = domWindow->document();\n')
podivilov 2012/02/27 15:53:48 Our constructors seems to be very simple comparing
antonm 2012/02/27 15:59:36 I am not sure. For example, I am not sure they re
+ arguments.append('document')
+ create_function = 'createForJSConstructor'
if 'CallWith' in self._interface.ext_attrs:
call_with = self._interface.ext_attrs['CallWith']
if call_with == 'ScriptExecutionContext':
@@ -302,7 +314,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
callback_name='constructorCallback',
idl_node=self._interface,
parameter_definitions=parameter_definitions_emitter.Fragments(),
- needs_receiver=False, function_name='%s::create' % type_info.native_type(),
+ needs_receiver=False, function_name='%s::%s' % (type_info.native_type(), create_function),
arguments=arguments,
idl_return_type=self._interface,
raises_dart_exceptions=raises_dart_exceptions,
@@ -314,8 +326,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
def _IsConstructable(self):
# FIXME: support ConstructorTemplate.
- # FIXME: support NamedConstructor.
- return set(['CustomConstructor', 'V8CustomConstructor', 'Constructor']) & set(self._interface.ext_attrs)
+ return set(['CustomConstructor', 'V8CustomConstructor', 'Constructor', 'NamedConstructor']) & set(self._interface.ext_attrs)
def FinishInterface(self):
base = self._BaseClassName(self._interface)
@@ -736,7 +747,7 @@ class NativeImplementationGenerator(systemwrapping.WrappingInterfaceGenerator):
if include_name:
self._cpp_impl_includes[include_name] = 1
flags = ''
- if idl_argument.ext_attrs.get('Optionial') == 'DefaultIsNullString':
+ if idl_argument.ext_attrs.get('Optional') == 'DefaultIsNullString':
podivilov 2012/02/27 15:53:48 This code is not actually used, do we really want
antonm 2012/02/27 15:59:36 Why it's not used? It's need, e.g., to make (most
podivilov 2012/02/27 16:59:49 Ok, seems like it is used for constructor paramete
flags = ', DartUtilities::ConvertNullToEmptyString'
emitter.Emit(
'\n'
« no previous file with comments | « no previous file | client/dom/src/native_FactoryProvidersImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698