Skip to content

Commit

Permalink
Fix accessor signatures for string/octstr attributes.
Browse files Browse the repository at this point in the history
See project-chip/connectedhomeip#28357: we are not
mutating the actual value the caller will observe.
  • Loading branch information
bzbarsky-apple committed Sep 1, 2023
1 parent a75c922 commit 36247e4
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ function canHaveSimpleAccessors(attr) {
async function accessorGetterType(attr) {
let type;
let mayNeedPointer = false;
let mayNeedReference = false;
if (StringHelper.isCharString(attr.type)) {
type = 'chip::MutableCharSpan';
mayNeedReference = true;
} else if (StringHelper.isOctetString(attr.type)) {
type = 'chip::MutableByteSpan';
mayNeedReference = true;
} else {
mayNeedPointer = true;
const options = {
Expand All @@ -76,6 +79,8 @@ async function accessorGetterType(attr) {
type = `DataModel::Nullable<${type}> &`;
} else if (mayNeedPointer) {
type = `${type} *`;
} else if (mayNeedReference) {
type = `${type} &`;
}

return type;
Expand Down

0 comments on commit 36247e4

Please sign in to comment.