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

Unified Diff: mojo/public/tools/bindings/generators/mojom_js_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
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_java_generator.py ('k') | mojo/public/tools/bindings/mojom.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/mojom_js_generator.py
diff --git a/mojo/public/tools/bindings/generators/mojom_js_generator.py b/mojo/public/tools/bindings/generators/mojom_js_generator.py
index 7ff6759c5077983841118cd0c6b3d8b6847a47e2..59933a9dd2c2022ba92166737e56f82afe4e955a 100644
--- a/mojo/public/tools/bindings/generators/mojom_js_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_js_generator.py
@@ -110,16 +110,20 @@ def CodecType(kind):
if mojom.IsArrayKind(kind):
array_type = "NullableArrayOf" if mojom.IsNullableKind(kind) else "ArrayOf"
array_length = "" if kind.length is None else ", %d" % kind.length
- element_type = "codec.PackedBool" if mojom.IsBoolKind(kind.kind) \
- else CodecType(kind.kind)
+ element_type = ElementCodecType(kind.kind)
return "new codec.%s(%s%s)" % (array_type, element_type, array_length)
if mojom.IsInterfaceKind(kind) or mojom.IsInterfaceRequestKind(kind):
return CodecType(mojom.MSGPIPE)
if mojom.IsEnumKind(kind):
return _kind_to_codec_type[mojom.INT32]
+ if mojom.IsMapKind(kind):
+ map_type = "NullableMapOf" if mojom.IsNullableKind(kind) else "MapOf"
+ key_type = ElementCodecType(kind.key_kind)
+ value_type = ElementCodecType(kind.value_kind)
+ return "new codec.%s(%s, %s)" % (map_type, key_type, value_type)
return kind
-def MapCodecType(kind):
+def ElementCodecType(kind):
return "codec.PackedBool" if mojom.IsBoolKind(kind) else CodecType(kind)
def JavaScriptDecodeSnippet(kind):
@@ -129,7 +133,7 @@ def JavaScriptDecodeSnippet(kind):
return "decodeStructPointer(%s)" % JavaScriptType(kind)
if mojom.IsMapKind(kind):
return "decodeMapPointer(%s, %s)" % \
- (MapCodecType(kind.key_kind), MapCodecType(kind.value_kind))
+ (ElementCodecType(kind.key_kind), ElementCodecType(kind.value_kind))
if mojom.IsArrayKind(kind) and mojom.IsBoolKind(kind.kind):
return "decodeArrayPointer(codec.PackedBool)"
if mojom.IsArrayKind(kind):
@@ -147,7 +151,7 @@ def JavaScriptEncodeSnippet(kind):
return "encodeStructPointer(%s, " % JavaScriptType(kind)
if mojom.IsMapKind(kind):
return "encodeMapPointer(%s, %s, " % \
- (MapCodecType(kind.key_kind), MapCodecType(kind.value_kind))
+ (ElementCodecType(kind.key_kind), ElementCodecType(kind.value_kind))
if mojom.IsArrayKind(kind) and mojom.IsBoolKind(kind.kind):
return "encodeArrayPointer(codec.PackedBool, ";
if mojom.IsArrayKind(kind):
@@ -184,8 +188,7 @@ def JavaScriptValidateArrayParams(packed_field):
element_size = pack.PackedField.GetSizeForKind(element_kind)
expected_dimension_sizes = GetArrayExpectedDimensionSizes(
packed_field.field.kind)
- element_type = "codec.PackedBool" if mojom.IsBoolKind(element_kind) \
- else CodecType(element_kind)
+ element_type = ElementCodecType(element_kind)
return "%s, %s, %s, %s, %s, 0" % \
(field_offset, element_size, element_type, nullable,
expected_dimension_sizes)
@@ -201,9 +204,9 @@ def JavaScriptValidateStructParams(packed_field):
def JavaScriptValidateMapParams(packed_field):
nullable = JavaScriptNullableParam(packed_field)
field_offset = JavaScriptFieldOffset(packed_field)
- keys_type = MapCodecType(packed_field.field.kind.key_kind)
+ keys_type = ElementCodecType(packed_field.field.kind.key_kind)
values_kind = packed_field.field.kind.value_kind;
- values_type = MapCodecType(values_kind)
+ values_type = ElementCodecType(values_kind)
values_nullable = "true" if mojom.IsNullableKind(values_kind) else "false"
return "%s, %s, %s, %s, %s" % \
(field_offset, nullable, keys_type, values_type, values_nullable)
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_java_generator.py ('k') | mojo/public/tools/bindings/mojom.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698