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

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

Issue 799113004: Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add mojo's ply to checklicenses whitelist Created 6 years 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 19f4631a41d9649b28eccb6cc0cc76c1f5ce8009..276d5af0593b8ec9188a8549ba19432c668c7666 100644
--- a/mojo/public/tools/bindings/generators/mojom_java_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_java_generator.py
@@ -234,14 +234,14 @@ def GetNameForKind(context, kind):
elements += _GetNameHierachy(kind)
return '.'.join(elements)
-def GetBoxedJavaType(context, kind):
- unboxed_type = GetJavaType(context, kind, False)
+def GetBoxedJavaType(context, kind, with_generics=True):
+ unboxed_type = GetJavaType(context, kind, False, with_generics)
if unboxed_type in _java_primitive_to_boxed_type:
return _java_primitive_to_boxed_type[unboxed_type]
return unboxed_type
@contextfilter
-def GetJavaType(context, kind, boxed=False):
+def GetJavaType(context, kind, boxed=False, with_generics=True):
if boxed:
return GetBoxedJavaType(context, kind)
if mojom.IsStructKind(kind) or mojom.IsInterfaceKind(kind):
@@ -250,11 +250,14 @@ def GetJavaType(context, kind, boxed=False):
return ('org.chromium.mojo.bindings.InterfaceRequest<%s>' %
GetNameForKind(context, kind.kind))
if mojom.IsMapKind(kind):
- return 'java.util.Map<%s, %s>' % (
- GetBoxedJavaType(context, kind.key_kind),
- GetBoxedJavaType(context, kind.value_kind))
+ if with_generics:
+ return 'java.util.Map<%s, %s>' % (
+ GetBoxedJavaType(context, kind.key_kind),
+ GetBoxedJavaType(context, kind.value_kind))
+ else:
+ return 'java.util.Map'
if mojom.IsArrayKind(kind):
- return '%s[]' % GetJavaType(context, kind.kind)
+ return '%s[]' % GetJavaType(context, kind.kind, boxed, with_generics)
if mojom.IsEnumKind(kind):
return 'int'
return _spec_to_java_type[kind.spec]
@@ -279,7 +282,8 @@ def ConstantValue(context, constant):
def NewArray(context, kind, size):
if mojom.IsArrayKind(kind.kind):
return NewArray(context, kind.kind, size) + '[]'
- return 'new %s[%s]' % (GetJavaType(context, kind.kind), size)
+ return 'new %s[%s]' % (
+ GetJavaType(context, kind.kind, boxed=False, with_generics=False), size)
@contextfilter
def ExpressionToText(context, token, kind_spec=''):

Powered by Google App Engine
This is Rietveld 408576698