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

Unified Diff: mojo/public/tools/bindings/mojom.gni

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/mojom.gni
diff --git a/mojo/public/tools/bindings/mojom.gni b/mojo/public/tools/bindings/mojom.gni
index b0bcce8058d8371dc59e7b0d279d535dec454b51..081636afa9e1941c87f5a217e96281f0d4b3ed4e 100644
--- a/mojo/public/tools/bindings/mojom.gni
+++ b/mojo/public/tools/bindings/mojom.gni
@@ -158,6 +158,15 @@ if (enable_mojom_typemapping) {
# TODO(yzshen): Convert all users to use new JS bindings and remove the
# old mode.
#
+# js_bindings_mode (optional)
+# |js_bindings_mode| and |use_new_js_bindings| are mutually exclusive. You
+# can only specify at most one of them.
+# - "new" (default): generate only the new-style JS bindings;
+# - "both": generate both the old- and new-style JS bindings;
+# - "old": generate only the old-style JS bindings.
+# TODO(yzshen): Convert all users to use new JS bindings and remove the
+# old mode.
+#
# component_output_prefix (optional)
# The prefix to use for the output_name of any component library emitted
# for generated C++ bindings. If this is omitted, C++ bindings targets are
@@ -212,6 +221,12 @@ template("mojom") {
defined(invoker.sources) || defined(invoker.deps) ||
defined(invoker.public_deps),
"\"sources\" or \"deps\" must be defined for the $target_name template.")
+
+ assert(!defined(invoker.use_new_js_bindings) ||
+ !defined(invoker.js_bindings_mode),
+ "You shouldn't specify both \"use_new_js_bindings\" and " +
+ "\"js_bindings_mode\".")
+
if (defined(invoker.export_class_attribute) ||
defined(invoker.export_define) || defined(invoker.export_header)) {
assert(defined(invoker.export_class_attribute))
@@ -238,10 +253,16 @@ template("mojom") {
assert(defined(invoker.component_deps_blink))
}
- if (defined(invoker.use_new_js_bindings)) {
- assert(invoker.use_new_js_bindings || !invoker.use_new_js_bindings,
- "Surpress unused variable error when JS bindings are not needed.")
+ js_bindings_mode = "new"
+ if (defined(invoker.js_bindings_mode)) {
+ js_bindings_mode = invoker.js_bindings_mode
}
+ if (defined(invoker.use_new_js_bindings) && !invoker.use_new_js_bindings) {
+ js_bindings_mode = "old"
+ }
+ assert(js_bindings_mode == "new" || js_bindings_mode == "both" ||
+ js_bindings_mode == "old",
+ "Invalid js_bindings_mode value.")
all_deps = []
if (defined(invoker.deps)) {
@@ -877,10 +898,10 @@ template("mojom") {
"javascript",
]
- if (!defined(invoker.use_new_js_bindings) ||
- invoker.use_new_js_bindings) {
- args += [ "--use_new_js_bindings" ]
- }
+ args += [
+ "--js_bindings_mode",
+ js_bindings_mode,
+ ]
}
}
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_js_generator.py ('k') | mojo/public/tools/bindings/mojom_bindings_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698