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

Unified Diff: mojo/public/tools/bindings/generators/mojom_java_generator.py

Issue 514293002: Mojo: validate nullability in Java bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/tools/bindings/generators/mojom_java_generator.py
diff --git a/mojo/public/tools/bindings/generators/mojom_java_generator.py b/mojo/public/tools/bindings/generators/mojom_java_generator.py
index aa692f15fa66a7a786270289275b6bbf42c50b42..63de4408273f1f4d8103aaaf9842762836dbeeb5 100644
--- a/mojo/public/tools/bindings/generators/mojom_java_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_java_generator.py
@@ -136,6 +136,9 @@ def ParseStringAttribute(attribute):
assert isinstance(attribute, basestring)
return attribute
+def GetJavaTrueFalse(value):
+ return "true" if value else "false"
+
@contextfilter
def DecodeMethod(context, kind, offset, bit):
def _DecodeMethodName(kind):
@@ -152,10 +155,12 @@ def DecodeMethod(context, kind, offset, bit):
additionalParams = ''
if (kind == mojom.BOOL):
additionalParams = ', %d' % bit
+ if mojom.IsReferenceKind(kind):
+ additionalParams = ', %s' % GetJavaTrueFalse(mojom.IsNullableKind(kind))
if mojom.IsInterfaceKind(kind):
- additionalParams = ', %s.MANAGER' % GetJavaType(context, kind)
+ additionalParams += ', %s.MANAGER' % GetJavaType(context, kind)
if mojom.IsAnyArrayKind(kind) and mojom.IsInterfaceKind(kind.kind):
- additionalParams = ', %s.MANAGER' % GetJavaType(context, kind.kind)
+ additionalParams += ', %s.MANAGER' % GetJavaType(context, kind.kind)
return '%s(%s%s)' % (methodName, offset, additionalParams)
@contextfilter
@@ -324,9 +329,11 @@ class Generator(generator.Generator):
"has_method_with_response": HasMethodWithResponse,
"has_method_without_response": HasMethodWithoutResponse,
"is_handle": mojom.IsNonInterfaceHandleKind,
+ "is_nullable_kind": mojom.IsNullableKind,
qsr 2014/08/29 07:56:20 The java_filters is only there to make method avai
ppi 2014/08/29 14:03:34 I do use both of them in macro decode of struct_de
"is_pointer_array_kind": IsPointerArrayKind,
"is_struct_kind": mojom.IsStructKind,
"java_type": GetJavaType,
+ "java_true_false": GetJavaTrueFalse,
"method_ordinal_name": GetMethodOrdinalName,
"name": GetNameForElement,
"new_array": NewArray,

Powered by Google App Engine
This is Rietveld 408576698