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

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

Issue 548343005: mojo: Specialize native type arrays. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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_python_generator.py
diff --git a/mojo/public/tools/bindings/generators/mojom_python_generator.py b/mojo/public/tools/bindings/generators/mojom_python_generator.py
index 9417298d4b3cf5d01f8b098658b4379ebe3090de..a60ee15b6aaceae5350e85316f1525e3fe38606a 100644
--- a/mojo/public/tools/bindings/generators/mojom_python_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_python_generator.py
@@ -37,6 +37,18 @@ _kind_to_type = {
mojom.NULLABLE_SHAREDBUFFER: "_descriptor.TYPE_NULLABLE_HANDLE",
}
+# int64 integers are not handled by array.array
Chris Masone 2014/09/09 14:20:26 Hm. That's a bit of an issue, as many CrOS platfor
qsr 2014/09/09 14:30:20 Hum... Not sure to understand why this is an issue
sdefresne 2014/09/10 08:40:00 Maybe expand the comment to say that int64/uint64
qsr 2014/09/10 09:23:38 Done.
+_kind_to_typecode = {
+ mojom.INT8: "'b'",
+ mojom.UINT8: "'B'",
+ mojom.INT16: "'h'",
+ mojom.UINT16: "'H'",
+ mojom.INT32: "'i'",
+ mojom.UINT32: "'I'",
+ mojom.FLOAT: "'f'",
+ mojom.DOUBLE: "'d'",
+}
+
def NameToComponent(name):
# insert '_' between anything and a Title name (e.g, HTTPEntry2FooBar ->
@@ -99,12 +111,18 @@ def GetStructClass(kind):
def GetFieldType(kind, field=None):
if mojom.IsAnyArrayKind(kind):
- arguments = [ GetFieldType(kind.kind) ]
+ if kind.kind in _kind_to_typecode:
+ arguments = [ _kind_to_typecode[kind.kind] ]
+ else:
+ arguments = [ GetFieldType(kind.kind) ]
if mojom.IsNullableKind(kind):
arguments.append("nullable=True")
if mojom.IsFixedArrayKind(kind):
arguments.append("length=%d" % kind.length)
- return "_descriptor.ArrayType(%s)" % ", ".join(arguments)
+ if kind.kind in _kind_to_typecode:
+ return "_descriptor.NativeArrayType(%s)" % ", ".join(arguments)
+ else:
+ return "_descriptor.PointerArrayType(%s)" % ", ".join(arguments)
if mojom.IsStructKind(kind):
arguments = [ GetStructClass(kind) ]

Powered by Google App Engine
This is Rietveld 408576698