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

Unified Diff: mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl

Issue 2965803003: Mojo JS bindings: add support to generate "dual-mode" code. (Closed)
Patch Set: . Created 3 years, 5 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: mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
diff --git a/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl b/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
index 8772a404d8568fd54bb6c9588c870b23fe8415b8..7772b207030a7ffbbc24455842521a6ccac3b965 100644
--- a/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
+++ b/mojo/public/tools/bindings/generators/js_templates/module.amd.tmpl
@@ -2,10 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-{%- if use_new_js_bindings %}
+{%- if js_bindings_mode == "both" or js_bindings_mode == "new" %}
+{{"new"|set_current_mode}}
'use strict';
+{%- if js_bindings_mode == "both" %}
+if ((typeof mojo !== 'undefined') && mojo.internal && mojo.config) {
+{%- endif %}
+
(function() {
var mojomId = '{{module.path}}';
if (mojo.internal.isMojomLoaded(mojomId)) {
@@ -21,6 +26,8 @@
var codec = mojo.internal;
var validator = mojo.internal;
+ var exports = mojo.internal.exposeNamespace('{{module.namespace}}');
+
{%- for import in imports %}
var {{import.unique_name}} =
mojo.internal.exposeNamespace('{{import.namespace}}');
@@ -35,7 +42,18 @@
{% include "module_definition.tmpl" %}
})();
-{%- else %}
+{%- if js_bindings_mode == "both" %}
+}
+{%- endif %}
+
+{%- endif %}
+
+{%- if js_bindings_mode == "both" or js_bindings_mode == "old" %}
+{{"old"|set_current_mode}}
+
+{%- if js_bindings_mode == "both" %}
+if ((typeof mojo === 'undefined') || !mojo.internal || !mojo.config) {
+{%- endif %}
define("{{module.path}}", [
{%- if module.path !=
@@ -62,10 +80,15 @@ codec, core, validator
, {{import.unique_name}}
{%- endfor -%}
) {
+ var exports = {};
{%- include "module_definition.tmpl" %}
return exports;
});
+{%- if js_bindings_mode == "both" %}
+}
+{%- endif %}
+
{%- endif %}

Powered by Google App Engine
This is Rietveld 408576698