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

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

Issue 12052076: Support overloaded constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
diff --git a/tools/dom/scripts/systemnative.py b/tools/dom/scripts/systemnative.py
index 9efdddb4ec74e57d1a1a4b137feac127ce3e85cc..661c693d59b5886f4468bedd46fc65dcc12a46ba 100644
--- a/tools/dom/scripts/systemnative.py
+++ b/tools/dom/scripts/systemnative.py
@@ -160,24 +160,31 @@ class DartiumBackend(HtmlDartGenerator):
CLASSNAME=self._interface_type_info.implementation_name(),
SUPERCONSTRUCTOR=super_constructor)
- def EmitStaticFactory(self, constructor_info):
- constructor_callback_id = self._interface.id + '_constructor_Callback'
+ def HasCustomFactory(self):
+ return False
+
+ def IsConstructorArgumentOptional(self, argument):
+ return False
+
+ def EmitStaticFactoryOverload(self, constructor_info, name, arguments):
+ constructor_callback_cpp_name = name + '_constructor_Callback'
+ constructor_callback_id = self._interface.id + constructor_callback_cpp_name
self._members_emitter.Emit(
- ' static $INTERFACE_NAME _create($PARAMETERS_DECLARATION) '
+ ' static $INTERFACE_NAME $NAME($PARAMETERS) '
'native "$CONSTRUCTOR_CALLBACK_ID";\n',
INTERFACE_NAME=self._interface_type_info.interface_name(),
- PARAMETERS_DECLARATION=constructor_info.ParametersDeclaration(
- self._DartType),
+ NAME=name,
+ # TODO: add types to parameters.
+ PARAMETERS=constructor_info.ParametersAsArgumentList(len(arguments)),
CONSTRUCTOR_CALLBACK_ID=constructor_callback_id)
- # TODO(antonm): currently we don't have information about number of arguments expected by
- # the constructor, so name only dispatch.
self._cpp_resolver_emitter.Emit(
' if (name == "$CONSTRUCTOR_CALLBACK_ID")\n'
- ' return Dart$(WEBKIT_INTERFACE_NAME)Internal::constructorCallback;\n',
+ ' return Dart$(WEBKIT_INTERFACE_NAME)Internal::$NAME;\n',
CONSTRUCTOR_CALLBACK_ID=constructor_callback_id,
- WEBKIT_INTERFACE_NAME=self._interface.id)
+ WEBKIT_INTERFACE_NAME=self._interface.id,
+ NAME=constructor_callback_cpp_name)
ext_attrs = self._interface.ext_attrs
@@ -185,7 +192,8 @@ class DartiumBackend(HtmlDartGenerator):
# We have a custom implementation for it.
self._cpp_declarations_emitter.Emit(
'\n'
- 'void constructorCallback(Dart_NativeArguments);\n')
+ 'void $NAME(Dart_NativeArguments);\n',
+ NAME=constructor_callback_cpp_name)
return
create_function = 'create'
@@ -193,11 +201,11 @@ class DartiumBackend(HtmlDartGenerator):
create_function = 'createForJSConstructor'
function_expression = '%s::%s' % (self._interface_type_info.native_type(), create_function)
self._GenerateNativeCallback(
- 'constructorCallback',
+ constructor_callback_cpp_name,
False,
function_expression,
self._interface,
- constructor_info.idl_args,
+ arguments,
self._interface.id,
'ConstructorRaisesException' in ext_attrs)

Powered by Google App Engine
This is Rietveld 408576698