From f86dfc32126474f1b955f44024c64dba79b38446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 15 Mar 2013 17:56:14 +0100 Subject: [PATCH 1/3] Remove ol.source.SourceOptions typedef The ol.source.SourceOptions type is already declared in objectliteral.exports, so it should not be declared in the ol/source/source.js file. --- src/ol/source/source.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/ol/source/source.js b/src/ol/source/source.js index 89954b54db..84dcbee6bd 100644 --- a/src/ol/source/source.js +++ b/src/ol/source/source.js @@ -8,14 +8,6 @@ goog.require('ol.Extent'); goog.require('ol.projection'); -/** - * @typedef {{attributions: (Array.|undefined), - * extent: (ol.Extent|undefined), - * projection: ol.ProjectionLike}} - */ -ol.source.SourceOptions; - - /** * @constructor From 6eaad6a837afea0e70b5b159be941bde4bc73ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 15 Mar 2013 17:58:54 +0100 Subject: [PATCH 2/3] Source option "projection" is a ProjectionLike --- src/objectliterals.exports | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objectliterals.exports b/src/objectliterals.exports index 65508a2711..2ea572d8f7 100644 --- a/src/objectliterals.exports +++ b/src/objectliterals.exports @@ -129,7 +129,7 @@ @exportObjectLiteral ol.source.SourceOptions @exportObjectLiteralProperty ol.source.SourceOptions.attributions Array.|undefined @exportObjectLiteralProperty ol.source.SourceOptions.extent ol.Extent|undefined -@exportObjectLiteralProperty ol.source.SourceOptions.projection ol.Projection|undefined +@exportObjectLiteralProperty ol.source.SourceOptions.projection ol.ProjectionLike @exportObjectLiteral ol.source.StamenOptions @exportObjectLiteralProperty ol.source.StamenOptions.layer string From 1f641c5933cca75a2a7021a8045207d88c1855c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 15 Mar 2013 18:01:53 +0100 Subject: [PATCH 3/3] Make the generated Export classes accept undefined We have constructors, like ol.View2D and ol.control.Attribution, whose "options" argument is optional (opt_options). But currently, we cannot do "new ol.View2D()" in uncompiled code that uses an ol3 build compiled in advanced mode. This commit fixes that by changing the generated Export constructors. --- bin/generate-exports.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/generate-exports.py b/bin/generate-exports.py index 28d7ad6e3d..6e98035ee2 100755 --- a/bin/generate-exports.py +++ b/bin/generate-exports.py @@ -52,9 +52,16 @@ class Class(Exportable): lines.append(' * @param {%s} options Options.\n' % (self.object_literal.extern_name(),)) lines.append(' */\n') lines.append('%sExport = function(options) {\n' % (self.name,)) - lines.append(' goog.base(this, {') - lines.extend(','.join('\n %s: options.%s' % (key, key) for key in sorted(self.object_literal.prop_types.keys()))) - lines.append('\n });\n') + lines.append(' /** @type {%s} */\n' % (self.object_literal.name,)) + lines.append(' var arg;\n'); + lines.append(' if (goog.isDefAndNotNull(options)) {\n') + lines.append(' arg = {') + lines.extend(','.join('\n %s: options.%s' % (key, key) for key in sorted(self.object_literal.prop_types.keys()))) + lines.append('\n };\n') + lines.append(' } else {\n') + lines.append(' arg = /** @type {%s} */ (options);\n' % (self.object_literal.name,)) + lines.append(' }\n') + lines.append(' goog.base(this, arg);\n') lines.append('};\n') lines.append('goog.inherits(%sExport, %s);\n' % (self.name, self.name)) lines.append('goog.exportSymbol(\n')