This commit adds a new export annotation: @exportFunction. @exportFunction is to be used to declare functions that take an options object literal as their first arguments. @exportFunction is to regular functions as @exportClass is to constructors.
The usage of @exportFunction is as follows:
@exportFunction ol.control.defaults ol.control.DefaultsOptions ol.Collection
Note: the Function#export method uses a recursive function. This is to handle nested options.
Currently we have things like like in the generated externs file (types.js):
/**
* @type {ol.control.AttributionOptions|undefined}
*/
olx.control.DefaultsOptionsExtern.prototype.attributionOptions;
It doesn't make sense to have external object properties whose types are
internal (ol.control.AttributionOptions in the above example).
With this commit, the generate-exports.py script generates this:
/**
* @type {olx.control.AttributionOptionsExtern|undefined}
*/
olx.control.DefaultsOptionsExtern.prototype.attributionOptions;
Now that we correctly export the ol.animation.*, ol.easing.* and ol.coordinate.* symbols we can make the generate-exports.py script work for more cases.
This commit extends the generated Export constructors to support nested options objects. For example, this is now supported:
@exportObjectLiteralProperty ol.MapOptions.view ol.View|ol.View2DOptions|undefined
This specifies that the "view" property in the map options can reference an ol.View instance, an ol.View2DOptions literal object, or undefined. If the "view" property references an ol.View2DOptions literal object the ol.MapExport constructor will create an ol.View2DExport instance, and pass it to the parent constructor, ol.Map. In this way, extern types never cross the external/internal boundary. In other words, translations from non-renamed to renamed objects remain confined to the generated Export constructors.
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.