From 803c42eced13a35d9a0b470aef88cd5804579f48 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 21 Mar 2023 09:22:21 -0400 Subject: [PATCH] Fix integer/long detection for codegen (#25757) * Fix integer/long detection for codegen * Remove duplicate import --- .../matter_idl/generators/java/__init__.py | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/scripts/py_matter_idl/matter_idl/generators/java/__init__.py b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py index ed47f7137d06d4..02dda6997c5eef 100644 --- a/scripts/py_matter_idl/matter_idl/generators/java/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py @@ -241,7 +241,8 @@ def boxed_java_type(self): else: raise Exception("Unknown fundamental type") elif type(t) == BasicInteger: - if t.byte_count >= 4: + # the >= 3 will include int24_t to be considered "long" + if t.byte_count >= 3: return "Long" else: return "Integer" @@ -251,9 +252,15 @@ def boxed_java_type(self): else: return "String" elif type(t) == IdlEnumType: - return "Integer" + if t.base_type.byte_count >= 3: + return "Long" + else: + return "Integer" elif type(t) == IdlBitmapType: - return "Integer" + if t.base_type.byte_count >= 3: + return "Long" + else: + return "Integer" else: return "Object" @@ -278,7 +285,7 @@ def boxed_java_signature(self): else: raise Exception("Unknown fundamental type") elif type(t) == BasicInteger: - if t.byte_count >= 4: + if t.byte_count >= 3: return "Ljava/lang/Long;" else: return "Ljava/lang/Integer;" @@ -288,9 +295,15 @@ def boxed_java_signature(self): else: return "Ljava/lang/String;" elif type(t) == IdlEnumType: - return "Ljava/lang/Integer;" + if t.base_type.byte_count >= 3: + return "Ljava/lang/Long;" + else: + return "Ljava/lang/Integer;" elif type(t) == IdlBitmapType: - return "Ljava/lang/Integer;" + if t.base_type.byte_count >= 3: + return "Ljava/lang/Long;" + else: + return "Ljava/lang/Integer;" else: return "Lchip/devicecontroller/ChipStructs${}Cluster{};".format(self.context.cluster.name, self.data_type.name) @@ -369,6 +382,7 @@ def internal_render_all(self): """ Renders .CPP files required for JNI support. """ + # Every cluster has its own impl, to avoid # very large compilations (running out of RAM) for cluster in self.idl.clusters: