Commit 8153db63 authored by qsr's avatar qsr Committed by Commit bot

mojo: Refactor method name generation for java bindings.

R=ppi@chromium.org

Review URL: https://codereview.chromium.org/518703003

Cr-Commit-Position: refs/heads/master@{#292610}
parent acdf1c15
...@@ -149,25 +149,25 @@ def DecodeMethod(context, kind, offset, bit): ...@@ -149,25 +149,25 @@ def DecodeMethod(context, kind, offset, bit):
return "readServiceInterface" return "readServiceInterface"
return _spec_to_decode_method[kind.spec] return _spec_to_decode_method[kind.spec]
methodName = _DecodeMethodName(kind) methodName = _DecodeMethodName(kind)
additionalParams = '' params = [ str(offset) ]
if (kind == mojom.BOOL): if (kind == mojom.BOOL):
additionalParams = ', %d' % bit params.append(str(bit))
if mojom.IsInterfaceKind(kind): if mojom.IsInterfaceKind(kind):
additionalParams = ', %s.MANAGER' % GetJavaType(context, kind) params.append('%s.MANAGER' % GetJavaType(context, kind))
if mojom.IsAnyArrayKind(kind) and mojom.IsInterfaceKind(kind.kind): if mojom.IsAnyArrayKind(kind) and mojom.IsInterfaceKind(kind.kind):
additionalParams = ', %s.MANAGER' % GetJavaType(context, kind.kind) params.append('%s.MANAGER' % GetJavaType(context, kind.kind))
return '%s(%s%s)' % (methodName, offset, additionalParams) return '%s(%s)' % (methodName, ', '.join(params))
@contextfilter @contextfilter
def EncodeMethod(context, kind, variable, offset, bit): def EncodeMethod(context, kind, variable, offset, bit):
additionalParams = '' params = [ variable, str(offset) ]
if (kind == mojom.BOOL): if (kind == mojom.BOOL):
additionalParams = ', %d' % bit params.append(str(bit))
if mojom.IsInterfaceKind(kind): if mojom.IsInterfaceKind(kind):
additionalParams = ', %s.MANAGER' % GetJavaType(context, kind) params.append('%s.MANAGER' % GetJavaType(context, kind))
if mojom.IsAnyArrayKind(kind) and mojom.IsInterfaceKind(kind.kind): if mojom.IsAnyArrayKind(kind) and mojom.IsInterfaceKind(kind.kind):
additionalParams = ', %s.MANAGER' % GetJavaType(context, kind.kind) params.append('%s.MANAGER' % GetJavaType(context, kind.kind))
return 'encode(%s, %s%s)' % (variable, offset, additionalParams) return 'encode(%s)' % ', '.join(params)
def GetPackage(module): def GetPackage(module):
if 'JavaPackage' in module.attributes: if 'JavaPackage' in module.attributes:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment