Skip to content

Commit

Permalink
Fix Darwin to handle renames of Color Control data types. (#35135)
Browse files Browse the repository at this point in the history
project-chip/connectedhomeip#33612 made the following changes to the Color Control cluster:

1) Renamed HueDirection to DirectionEnum
2) Renamed the ShortestDistance and LongestDistance values of DirectionEnum to
   Shortest and Longest, respectively.
3) Renamed HueMoveMode to MoveModeEnum.
4) Renamed HueStepMode to StepModeEnum.
5) Removed SaturationMoveMode in favor of MoveModeEnum.
6) Removed SaturationStepMode in favor of StepModeEnum.
7) Renamed ColorMode to ColorModeEnum.
8) Renamed the ColorTemperature value to ColorTemperatureMireds
8) Renamed ColorCapabilities to ColorCapabilitiesBitmap.
9) Renamed various fields of ColorCapabilitiesBitmap.
10) Renamed ColorLoopUpdateFlags to UpdateFlagsBitmap.
11) Renamed ColorLoopAction to ColorLoopActionEnum.
12) Added OptionsBitmap, EnhancedColorModeEnum, DriftCompensationEnum.
13) Renamed ColorLoopDirection to ColorLoopDirectionEnum.
14) Renamed the DecrementHue and IncrementHue values of ColorLoopDirectionEnum
    to Decrement and Increment, respectively.

This change adds the right renamed/introduced/deprecated annotations for the
above changes, and adds manual shims for the enums that got removed.
  • Loading branch information
bzbarsky-apple authored and ArekBalysNordic committed Nov 28, 2024
1 parent 7c2c373 commit 8772ea5
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 53 deletions.
29 changes: 29 additions & 0 deletions src/darwin/Framework/CHIP/MTRBackwardsCompatShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,33 @@ typedef NS_ENUM(uint8_t, MTROTASoftwareUpdateRequestorOTAUpdateState) {
= 0x08,
} MTR_DEPRECATED("Please use MTROTASoftwareUpdateRequestorUpdateState", ios(16.4, 17.2), macos(13.3, 14.2), watchos(9.4, 10.2), tvos(16.4, 17.2));

/**
* ColorControl used to have HueMoveMode/SaturationMoveMode and HueStepMode/SaturationStepMode that had
* identical values. Those got replaced with MoveModeEnum and StepModeEnum respectively. We codegen
* HueMoveMode and HueStepMode as aliases of MoveModeEnum and StepModeEnum, but we need manual shims for
* SaturationMoveMode and SaturationStepMode.
*/
typedef NS_ENUM(uint8_t, MTRColorControlSaturationMoveMode) {
MTRColorControlSaturationMoveModeStop MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveModeStop")
= 0x00,
MTRColorControlSaturationMoveModeUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveModeUp")
= 0x01,
MTRColorControlSaturationMoveModeDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveModeDown")
= 0x03,
} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
MTR_NEWLY_DEPRECATED("Please use MTRColorControlMoveMode");

typedef NS_ENUM(uint8_t, MTRColorControlSaturationStepMode) {
MTRColorControlSaturationStepModeUp MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
MTR_NEWLY_DEPRECATED("Please use MTRColorControlStepModeUp")
= 0x01,
MTRColorControlSaturationStepModeDown MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
MTR_NEWLY_DEPRECATED("Please use MTRColorControlStepModeDown")
= 0x03,
} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
MTR_NEWLY_DEPRECATED("Please use MTRColorControlStepMode");

NS_ASSUME_NONNULL_END
143 changes: 137 additions & 6 deletions src/darwin/Framework/CHIP/templates/availability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3237,9 +3237,15 @@
- FanModeSequenceType
- FanModeType
ColorControl:
- ColorLoopAction
- ColorLoopDirection
- ColorMode
# ColorLoopActionEnum, ColorLoopDirectionEnum and ColorModeEnum
# were originally named ColorLoopAction, ColorLoopDirection, and
# ColorMode, but we generate the same API for the names
# with/without "Enum" at the end and the cluster name
# present/absent at the beginning, so the names can just change
# here.
- ColorLoopActionEnum
- ColorLoopDirectionEnum
- ColorModeEnum
- HueDirection
- HueMoveMode
- HueStepMode
Expand Down Expand Up @@ -3980,14 +3986,20 @@
- Auto
- Smart
ColorControl:
ColorLoopAction:
# ColorLoopActionEnum, ColorLoopDirectionEnum and ColorModeEnum
# were originally named ColorLoopAction, ColorLoopDirection, and
# ColorMode, but we generate the same API for the names
# with/without "Enum" at the end and the cluster name
# present/absent at the beginning, so the names can just change
# here.
ColorLoopActionEnum:
- Deactivate
- ActivateFromColorLoopStartEnhancedHue
- ActivateFromEnhancedCurrentHue
ColorLoopDirection:
ColorLoopDirectionEnum:
- DecrementHue
- IncrementHue
ColorMode:
ColorModeEnum:
- CurrentHueAndCurrentSaturation
- CurrentXAndCurrentY
- ColorTemperature
Expand Down Expand Up @@ -9682,6 +9694,64 @@

- release: "Future"
versions: "future"
introduced:
enums:
ColorControl:
- DirectionEnum
- DriftCompensationEnum
- EnhancedColorModeEnum
- MoveModeEnum
- StepModeEnum
enum values:
ColorControl:
ColorLoopDirectionEnum:
- Decrement
- Increment
ColorModeEnum:
- ColorTemperatureMireds
DirectionEnum:
- Shortest
- Longest
- Up
- Down
DriftCompensationEnum:
- None
- OtherOrUnknown
- TemperatureMonitoring
- OpticalLuminanceMonitoringAndFeedback
- OpticalColorMonitoringAndFeedback
EnhancedColorModeEnum:
- CurrentHueAndCurrentSaturation
- CurrentXAndCurrentY
- ColorTemperatureMireds
- EnhancedCurrentHueAndCurrentSaturation
MoveModeEnum:
- Stop
- Up
- Down
StepModeEnum:
- Up
- Down
bitmaps:
ColorControl:
- ColorCapabilitiesBitmap
- OptionsBitmap
- UpdateFlagsBitmap
bitmap values:
ColorControl:
ColorCapabilitiesBitmap:
- HueSaturation
- EnhancedHue
- ColorLoop
- XY
- ColorTemperature
OptionsBitmap:
- ExecuteIfOff
UpdateFlagsBitmap:
- UpdateAction
- UpdateDirection
- UpdateTime
- UpdateStartHue
provisional:
clusters:
# Targeting 1.4
Expand Down Expand Up @@ -9820,3 +9890,64 @@
Feature:
# Targeting 1.4
- ActionSwitch
renames:
enums:
ColorControl:
DirectionEnum: HueDirection
MoveModeEnum: HueMoveMode
StepModeEnum: HueStepMode
enum values:
ColorControl:
ColorLoopDirectionEnum:
Decrement: DecrementHue
Increment: IncrementHue
ColorModeEnum:
ColorTemperatureMireds: ColorTemperature
HueDirection:
Shortest: ShortestDistance
Longest: LongestDistance
bitmaps:
ColorControl:
ColorCapabilitiesBitmap: ColorCapabilities
UpdateFlagsBitmap: ColorLoopUpdateFlags
bitmap values:
ColorControl:
ColorCapabilities:
HueSaturation: HueSaturationSupported
EnhancedHue: EnhancedHueSupported
ColorLoop: ColorLoopSupported
XY: XYAttributesSupported
ColorTemperature: ColorTemperatureSupported
deprecated:
enums:
ColorControl:
- HueDirection
- HueMoveMode
- HueStepMode
enum values:
ColorControl:
ColorLoopDirectionEnum:
- DecrementHue
- IncrementHue
ColorModeEnum:
- ColorTemperature
bitmaps:
ColorControl:
- ColorCapabilities
- ColorLoopUpdateFlags
removed:
enum values:
ColorControl:
# Don't expose the new value names on the old enum names
HueDirection:
- Shortest
- Longest
bitmap values:
ColorControl:
# Don't expose the new field names on the old bitmap names
ColorCapabilities:
- HueSaturation
- EnhancedHue
- ColorLoop
- XY
- ColorTemperature
Loading

0 comments on commit 8772ea5

Please sign in to comment.