Skip to content

Commit

Permalink
Fix integer/long detection for codegen (#25757)
Browse files Browse the repository at this point in the history
* Fix integer/long detection for codegen

* Remove duplicate import
  • Loading branch information
andy31415 authored and pull[bot] committed Sep 14, 2023
1 parent e9b881c commit 803c42e
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions scripts/py_matter_idl/matter_idl/generators/java/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand All @@ -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;"
Expand All @@ -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)

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 803c42e

Please sign in to comment.