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

Unified Diff: mojo/public/java/bindings/src/org/chromium/mojo/bindings/BindingsHelper.java

Issue 514293002: Mojo: validate nullability in Java bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix line length in mojom_java_generator in a way that works. Created 6 years, 4 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/java/bindings/src/org/chromium/mojo/bindings/BindingsHelper.java
diff --git a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/BindingsHelper.java b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/BindingsHelper.java
index d94796831b0e28de4c8995435671adbba586b5a1..ef4d0e96642d10e18c479763708ea2d81b387c30 100644
--- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/BindingsHelper.java
+++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/BindingsHelper.java
@@ -36,6 +36,29 @@ public class BindingsHelper {
}
/**
+ * Passed as |arrayNullability| when neither the array nor its elements are nullable.
+ */
+ public static final int NOTHING_NULLABLE = 0;
+
+ /**
+ * "Array bit" of |arrayNullability| is set iff the array itself is nullable.
+ */
+ public static final int ARRAY_NULLABLE = (1 << 0);
+
+ /**
+ * "Element bit" of |arrayNullability| is set iff the array elements are nullable.
+ */
+ public static final int ELEMENT_NULLABLE = (1 << 1);
+
+ public static boolean isArrayNullable(int arrayNullability) {
+ return (arrayNullability & ARRAY_NULLABLE) > 0;
+ }
+
+ public static boolean isElementNullable(int arrayNullability) {
+ return (arrayNullability & ELEMENT_NULLABLE) > 0;
+ }
+
+ /**
* Compute the size in bytes of the given string encoded as utf8.
*/
public static int utf8StringSizeInBytes(String s) {

Powered by Google App Engine
This is Rietveld 408576698