Index: tools/dom/scripts/htmldartgenerator.py |
diff --git a/tools/dom/scripts/htmldartgenerator.py b/tools/dom/scripts/htmldartgenerator.py |
index d22b6cd74297a383336f0611ec6b6039ebdc8c07..b003d3f561da8d6a0eb2334ff08121cdc13d20f7 100644 |
--- a/tools/dom/scripts/htmldartgenerator.py |
+++ b/tools/dom/scripts/htmldartgenerator.py |
@@ -235,13 +235,13 @@ class HtmlDartGenerator(object): |
parameter_name = parameter_names[i] |
test_type = self._DartType(argument.type.id) |
if test_type in ['dynamic', 'Object']: |
- checks.append('?%s' % parameter_name) |
+ checks.append('%s != null' % parameter_name) |
elif not can_omit_type_check(test_type, i): |
checks.append('(%s is %s || %s == null)' % ( |
parameter_name, test_type, parameter_name)) |
# There can be multiple presence checks. We need them all since a later |
# optional argument could have been passed by name, leaving 'holes'. |
- checks.extend(['!?%s' % name for name in parameter_names[argument_count:]]) |
+ checks.extend(['%s == null' % name for name in parameter_names[argument_count:]]) |
blois
2013/05/09 22:35:22
line length
Anton Muhin
2013/05/14 14:48:23
BTW, another potential source of semantic differen
|
GenerateCall(signature_index, argument_count, checks) |
@@ -279,7 +279,7 @@ class HtmlDartGenerator(object): |
argument_count = len(signature) |
for argument_position, argument in list(enumerate(signature))[::-1]: |
if is_optional(0, argument): |
- check = '?%s' % parameter_names[argument_position] |
+ check = '%s != null' % parameter_names[argument_position] |
# argument_count instead of argument_position + 1 is used here to cover one |
# complicated case with the effectively optional argument in the middle. |
# Consider foo(x, optional y, [Default=NullString] optional z) |
@@ -362,10 +362,8 @@ class HtmlDartGenerator(object): |
if not factory_constructor_name: |
factory_constructor_name = '_create' |
factory_parameters = constructor_info.ParametersAsArgumentList() |
- has_factory_provider = True |
else: |
factory_parameters = ', '.join(constructor_info.factory_parameters) |
- has_factory_provider = False |
if constructor_info.pure_dart_constructor: |
# TODO(antonm): use common dispatcher generation for this case as well. |
@@ -384,46 +382,23 @@ class HtmlDartGenerator(object): |
CTOR_FACTORY_NAME=factory_constructor_name, |
FACTORY_PARAMS=factory_parameters) |
else: |
- if has_factory_provider: |
- dispatcher_emitter = self._members_emitter.Emit( |
- '\n $(METADATA)' |
- 'factory $CTOR($PARAMS) {\n' |
- '$!DISPATCHER' |
- ' return $FACTORY._create($FACTORY_PARAMS);\n' |
- ' }\n', |
- CTOR=constructor_info._ConstructorFullName(self._DartType), |
- PARAMS=constructor_info.ParametersDeclaration(self._DartType), |
- FACTORY=factory_name, |
- METADATA=metadata, |
- FACTORY_PARAMS=constructor_info.ParametersAsArgumentList()) |
- |
- for index, param_info in enumerate(constructor_info.param_infos): |
- if param_info.is_optional: |
- dispatcher_emitter.Emit( |
- ' if ($OPT_PARAM_NAME == null) {\n' |
- ' return $FACTORY._create($FACTORY_PARAMS);\n' |
- ' }\n', |
- OPT_PARAM_NAME=param_info.name, |
- FACTORY=factory_name, |
- FACTORY_PARAMS=constructor_info.ParametersAsArgumentList(index)) |
- else: |
- inits = self._members_emitter.Emit( |
- '\n $(METADATA)' |
- 'factory $CONSTRUCTOR($PARAMS) {\n' |
- ' var e = $FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n' |
- '$!INITS' |
- ' return e;\n' |
- ' }\n', |
- CONSTRUCTOR=constructor_info._ConstructorFullName(self._DartType), |
- METADATA=metadata, |
- FACTORY=factory_name, |
- CTOR_FACTORY_NAME=factory_constructor_name, |
- PARAMS=constructor_info.ParametersDeclaration(self._DartType), |
- FACTORY_PARAMS=factory_parameters) |
- |
- for index, param_info in enumerate(constructor_info.param_infos): |
- if param_info.is_optional: |
- inits.Emit(' if ($E != null) e.$E = $E;\n', E=param_info.name) |
+ inits = self._members_emitter.Emit( |
Anton Muhin
2013/05/14 14:48:23
please, a separate change or rebase if not too lat
|
+ '\n $(METADATA)' |
+ 'factory $CONSTRUCTOR($PARAMS) {\n' |
+ ' var e = $FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n' |
+ '$!INITS' |
+ ' return e;\n' |
+ ' }\n', |
+ CONSTRUCTOR=constructor_info._ConstructorFullName(self._DartType), |
+ METADATA=metadata, |
+ FACTORY=factory_name, |
+ CTOR_FACTORY_NAME=factory_constructor_name, |
+ PARAMS=constructor_info.ParametersDeclaration(self._DartType), |
+ FACTORY_PARAMS=factory_parameters) |
+ |
+ for index, param_info in enumerate(constructor_info.param_infos): |
+ if param_info.is_optional: |
+ inits.Emit(' if ($E != null) e.$E = $E;\n', E=param_info.name) |
else: |
def GenerateCall( |
stmts_emitter, call_emitter, |