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

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

Issue 522653004: mojo: Validate fixed size array for the mojo java bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Follow review 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
« no previous file with comments | « mojo/public/tools/bindings/generators/java_templates/struct_definition.tmpl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1827ed90c773953d207858ba10473679ca822bde..7cbfe543bcb905200edac992fc2b8d112e427111 100644
--- a/mojo/public/tools/bindings/generators/mojom_java_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_java_generator.py
@@ -152,6 +152,12 @@ def DecodeMethod(context, kind, offset, bit):
params = [ str(offset) ]
if (kind == mojom.BOOL):
params.append(str(bit))
+ if mojom.IsAnyArrayKind(kind):
+ if mojom.IsFixedArrayKind(kind):
+ params.append(str(kind.length))
+ else:
+ params.append(
+ "org.chromium.mojo.bindings.BindingsHelper.UNSPECIFIED_ARRAY_LENGTH");
if mojom.IsInterfaceKind(kind):
params.append('%s.MANAGER' % GetJavaType(context, kind))
if mojom.IsAnyArrayKind(kind) and mojom.IsInterfaceKind(kind.kind):
@@ -163,6 +169,12 @@ def EncodeMethod(context, kind, variable, offset, bit):
params = [ variable, str(offset) ]
if (kind == mojom.BOOL):
params.append(str(bit))
+ if mojom.IsAnyArrayKind(kind):
+ if mojom.IsFixedArrayKind(kind):
+ params.append(str(kind.length))
+ else:
+ params.append(
+ "org.chromium.mojo.bindings.BindingsHelper.UNSPECIFIED_ARRAY_LENGTH");
yzshen1 2014/08/29 16:32:24 One nit: Other bindings use 0 as "unspecified leng
qsr 2014/09/01 09:07:00 Not sure to understand exactly what to do here. Th
if mojom.IsInterfaceKind(kind):
params.append('%s.MANAGER' % GetJavaType(context, kind))
if mojom.IsAnyArrayKind(kind) and mojom.IsInterfaceKind(kind.kind):
@@ -323,6 +335,7 @@ class Generator(generator.Generator):
"encode_method": EncodeMethod,
"has_method_with_response": HasMethodWithResponse,
"has_method_without_response": HasMethodWithoutResponse,
+ "is_fixed_array_kind": mojom.IsFixedArrayKind,
"is_handle": mojom.IsNonInterfaceHandleKind,
"is_pointer_array_kind": IsPointerArrayKind,
"is_struct_kind": mojom.IsStructKind,
« no previous file with comments | « mojo/public/tools/bindings/generators/java_templates/struct_definition.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698