Skip to content

Commit

Permalink
Add support for global types in the Python Matter codegen.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Jul 26, 2024
1 parent b0d702c commit c9f907e
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,18 @@ async function _zapTypeToPythonClusterObjectType(type, options) {
if (type.toLowerCase().match(/^enum\d+$/g)) {
return 'uint';
}

const enumObj = await zclQuery.selectEnumByName(
this.global.db,
type,
pkgId
);

if (enumObj.enumClusterCount == 0) {
// This is a global enum.
return `Globals.Enums.${type}`;
}

return ns + '.Enums.' + type;
}

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

if (await typeChecker('isStruct')) {
const structObj = await zclQuery.selectStructByName(
this.global.db,
type,
pkgId
);

if (structObj.structClusterCount == 0) {
// This is a global struct.
return `Globals.Structs.${type}`;
}

return ns + '.Structs.' + type;
}

Expand Down

0 comments on commit c9f907e

Please sign in to comment.