Skip to content

Commit af33f57

Browse files
Add support for global types in the Python Matter codegen. (#1376)
1 parent b0d702c commit af33f57

File tree

1 file changed

+23
-0
lines changed
  • src-electron/generator/matter/app/zap-templates/templates/app

1 file changed

+23
-0
lines changed

src-electron/generator/matter/app/zap-templates/templates/app/helper.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,18 @@ async function _zapTypeToPythonClusterObjectType(type, options) {
820820
if (type.toLowerCase().match(/^enum\d+$/g)) {
821821
return 'uint';
822822
}
823+
824+
const enumObj = await zclQuery.selectEnumByName(
825+
this.global.db,
826+
type,
827+
pkgId
828+
);
829+
830+
if (enumObj.enumClusterCount == 0) {
831+
// This is a global enum.
832+
return `Globals.Enums.${type}`;
833+
}
834+
823835
return ns + '.Enums.' + type;
824836
}
825837

@@ -828,6 +840,17 @@ async function _zapTypeToPythonClusterObjectType(type, options) {
828840
}
829841

830842
if (await typeChecker('isStruct')) {
843+
const structObj = await zclQuery.selectStructByName(
844+
this.global.db,
845+
type,
846+
pkgId
847+
);
848+
849+
if (structObj.structClusterCount == 0) {
850+
// This is a global struct.
851+
return `Globals.Structs.${type}`;
852+
}
853+
831854
return ns + '.Structs.' + type;
832855
}
833856

0 commit comments

Comments
 (0)