Skip to content

Commit

Permalink
[IDL] use IDL-based codegen (at build time) for java reads (#13832)
Browse files Browse the repository at this point in the history
* A start of an IDL generator.

Fixes nullable attribute support in our IDL.
Is able to generate 1:1 output for java JNI readable data when compared
to ZAP.

* Generate JNI code only on Android

* Add license and help text to codegen.py

* Remove odd path for idl file naming in the build.gn file

* Adding generator unit tests to catch regressions or changes in code generation logic

Unit tests serve as both regression detectors and samples
to understand generator output.

* Better test case output diffs in case of failure

* Fix generator output - remove bad logging line
  • Loading branch information
andy31415 authored and pull[bot] committed Oct 23, 2023
1 parent bc8812b commit 8f1ae92
Show file tree
Hide file tree
Showing 36 changed files with 1,180 additions and 22,041 deletions.
1 change: 1 addition & 0 deletions .restyled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ exclude:
- "third_party/android_deps/gradlew" # gradle wrapper generated file
- "src/controller/python/chip/clusters/Objects.py" # generated file, no point to restyle
- "src/controller/python/chip/clusters/CHIPClusters.py" # generated file, no point to restyle
- "scripts/idl/tests/outputs/**/*" # Matches generated output 1:1


changed_paths:
Expand Down
110 changes: 55 additions & 55 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,10 @@ server cluster DoorLock = 257 {
nullable INT16U dataIndex = 6;
}

readonly attribute DlLockState lockState = 0;
readonly attribute nullable DlLockState lockState = 0;
readonly attribute DlLockType lockType = 1;
readonly attribute boolean actuatorEnabled = 2;
readonly attribute DlDoorState doorState = 3;
readonly attribute nullable DlDoorState doorState = 3;
attribute int32u doorOpenEvents = 4;
attribute int32u doorClosedEvents = 5;
attribute int16u openPeriod = 6;
Expand Down Expand Up @@ -1498,11 +1498,11 @@ server cluster IlluminanceMeasurement = 1024 {
kCmos = 1;
}

readonly attribute int16u measuredValue = 0;
readonly attribute int16u minMeasuredValue = 1;
readonly attribute int16u maxMeasuredValue = 2;
readonly attribute nullable int16u measuredValue = 0;
readonly attribute nullable int16u minMeasuredValue = 1;
readonly attribute nullable int16u maxMeasuredValue = 2;
readonly attribute int16u tolerance = 3;
readonly attribute enum8 lightSensorType = 4;
readonly attribute nullable enum8 lightSensorType = 4;
readonly global attribute int16u clusterRevision = 65533;
}

Expand Down Expand Up @@ -1625,11 +1625,11 @@ server cluster LevelControl = 8 {
readonly attribute int16u maxFrequency = 6;
attribute bitmap8 options = 15;
attribute int16u onOffTransitionTime = 16;
attribute int8u onLevel = 17;
attribute int16u onTransitionTime = 18;
attribute int16u offTransitionTime = 19;
attribute int8u defaultMoveRate = 20;
attribute int8u startUpCurrentLevel = 16384;
attribute nullable int8u onLevel = 17;
attribute nullable int16u onTransitionTime = 18;
attribute nullable int16u offTransitionTime = 19;
attribute nullable int8u defaultMoveRate = 20;
attribute nullable int8u startUpCurrentLevel = 16384;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down Expand Up @@ -2001,7 +2001,7 @@ server cluster OtaSoftwareUpdateRequestor = 42 {
attribute ProviderLocation defaultOtaProviders[] = 0;
readonly attribute boolean updatePossible = 1;
readonly attribute OTAUpdateStateEnum updateState = 2;
readonly attribute int8u updateStateProgress = 3;
readonly attribute nullable int8u updateStateProgress = 3;
readonly global attribute int16u clusterRevision = 65533;

request struct AnnounceOtaProviderRequest {
Expand Down Expand Up @@ -2292,9 +2292,9 @@ server cluster PumpConfigurationAndControl = 512 {
readonly attribute enum8 effectiveControlMode = 18;
readonly attribute int16s capacity = 19;
readonly attribute int16u speed = 20;
attribute int24u lifetimeRunningHours = 21;
attribute nullable int24u lifetimeRunningHours = 21;
readonly attribute int24u power = 22;
attribute int32u lifetimeEnergyConsumed = 23;
attribute nullable int32u lifetimeEnergyConsumed = 23;
attribute enum8 operationMode = 32;
attribute enum8 controlMode = 33;
readonly attribute bitmap16 alarmMask = 34;
Expand Down Expand Up @@ -2609,39 +2609,39 @@ server cluster TestCluster = 1295 {
readonly attribute LONG_OCTET_STRING listLongOctetString[] = 42;
readonly attribute TestFabricScoped listFabricScoped[] = 43;
attribute boolean timedWriteBoolean = 48;
attribute boolean nullableBoolean = 32768;
attribute bitmap8 nullableBitmap8 = 32769;
attribute bitmap16 nullableBitmap16 = 32770;
attribute bitmap32 nullableBitmap32 = 32771;
attribute bitmap64 nullableBitmap64 = 32772;
attribute int8u nullableInt8u = 32773;
attribute int16u nullableInt16u = 32774;
attribute int24u nullableInt24u = 32775;
attribute int32u nullableInt32u = 32776;
attribute int40u nullableInt40u = 32777;
attribute int48u nullableInt48u = 32778;
attribute int56u nullableInt56u = 32779;
attribute int64u nullableInt64u = 32780;
attribute int8s nullableInt8s = 32781;
attribute int16s nullableInt16s = 32782;
attribute int24s nullableInt24s = 32783;
attribute int32s nullableInt32s = 32784;
attribute int40s nullableInt40s = 32785;
attribute int48s nullableInt48s = 32786;
attribute int56s nullableInt56s = 32787;
attribute int64s nullableInt64s = 32788;
attribute enum8 nullableEnum8 = 32789;
attribute enum16 nullableEnum16 = 32790;
attribute single nullableFloatSingle = 32791;
attribute double nullableFloatDouble = 32792;
attribute octet_string<10> nullableOctetString = 32793;
attribute char_string<10> nullableCharString = 32798;
attribute SimpleEnum nullableEnumAttr = 32804;
attribute SimpleStruct nullableStruct = 32805;
attribute int8u nullableRangeRestrictedInt8u = 32806;
attribute int8s nullableRangeRestrictedInt8s = 32807;
attribute int16u nullableRangeRestrictedInt16u = 32808;
attribute int16s nullableRangeRestrictedInt16s = 32809;
attribute nullable boolean nullableBoolean = 32768;
attribute nullable bitmap8 nullableBitmap8 = 32769;
attribute nullable bitmap16 nullableBitmap16 = 32770;
attribute nullable bitmap32 nullableBitmap32 = 32771;
attribute nullable bitmap64 nullableBitmap64 = 32772;
attribute nullable int8u nullableInt8u = 32773;
attribute nullable int16u nullableInt16u = 32774;
attribute nullable int24u nullableInt24u = 32775;
attribute nullable int32u nullableInt32u = 32776;
attribute nullable int40u nullableInt40u = 32777;
attribute nullable int48u nullableInt48u = 32778;
attribute nullable int56u nullableInt56u = 32779;
attribute nullable int64u nullableInt64u = 32780;
attribute nullable int8s nullableInt8s = 32781;
attribute nullable int16s nullableInt16s = 32782;
attribute nullable int24s nullableInt24s = 32783;
attribute nullable int32s nullableInt32s = 32784;
attribute nullable int40s nullableInt40s = 32785;
attribute nullable int48s nullableInt48s = 32786;
attribute nullable int56s nullableInt56s = 32787;
attribute nullable int64s nullableInt64s = 32788;
attribute nullable enum8 nullableEnum8 = 32789;
attribute nullable enum16 nullableEnum16 = 32790;
attribute nullable single nullableFloatSingle = 32791;
attribute nullable double nullableFloatDouble = 32792;
attribute nullable octet_string<10> nullableOctetString = 32793;
attribute nullable char_string<10> nullableCharString = 32798;
attribute nullable SimpleEnum nullableEnumAttr = 32804;
attribute nullable SimpleStruct nullableStruct = 32805;
attribute nullable int8u nullableRangeRestrictedInt8u = 32806;
attribute nullable int8s nullableRangeRestrictedInt8s = 32807;
attribute nullable int16u nullableRangeRestrictedInt16u = 32808;
attribute nullable int16s nullableRangeRestrictedInt16s = 32809;
readonly global attribute int16u clusterRevision = 65533;

request struct SimpleStructEchoRequestRequest {
Expand Down Expand Up @@ -3034,17 +3034,17 @@ server cluster WiFiNetworkDiagnostics = 54 {

server cluster WindowCovering = 258 {
readonly attribute enum8 type = 0;
readonly attribute int16u currentPositionLift = 3;
readonly attribute int16u currentPositionTilt = 4;
readonly attribute nullable int16u currentPositionLift = 3;
readonly attribute nullable int16u currentPositionTilt = 4;
readonly attribute bitmap8 configStatus = 7;
readonly attribute Percent currentPositionLiftPercentage = 8;
readonly attribute Percent currentPositionTiltPercentage = 9;
readonly attribute nullable Percent currentPositionLiftPercentage = 8;
readonly attribute nullable Percent currentPositionTiltPercentage = 9;
readonly attribute bitmap8 operationalStatus = 10;
readonly attribute Percent100ths targetPositionLiftPercent100ths = 11;
readonly attribute Percent100ths targetPositionTiltPercent100ths = 12;
readonly attribute nullable Percent100ths targetPositionLiftPercent100ths = 11;
readonly attribute nullable Percent100ths targetPositionTiltPercent100ths = 12;
readonly attribute enum8 endProductType = 13;
readonly attribute Percent100ths currentPositionLiftPercent100ths = 14;
readonly attribute Percent100ths currentPositionTiltPercent100ths = 15;
readonly attribute nullable Percent100ths currentPositionLiftPercent100ths = 14;
readonly attribute nullable Percent100ths currentPositionTiltPercent100ths = 15;
readonly attribute int16u installedOpenLimitLift = 16;
readonly attribute int16u installedClosedLimitLift = 17;
readonly attribute int16u installedOpenLimitTilt = 18;
Expand Down
10 changes: 5 additions & 5 deletions examples/bridge-app/bridge-common/bridge-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,11 @@ server cluster LevelControl = 8 {
readonly attribute int16u maxFrequency = 6;
attribute bitmap8 options = 15;
attribute int16u onOffTransitionTime = 16;
attribute int8u onLevel = 17;
attribute int16u onTransitionTime = 18;
attribute int16u offTransitionTime = 19;
attribute int8u defaultMoveRate = 20;
attribute int8u startUpCurrentLevel = 16384;
attribute nullable int8u onLevel = 17;
attribute nullable int16u onTransitionTime = 18;
attribute nullable int16u offTransitionTime = 19;
attribute nullable int8u defaultMoveRate = 20;
attribute nullable int8u startUpCurrentLevel = 16384;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
4 changes: 2 additions & 2 deletions examples/door-lock-app/door-lock-common/door-lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ server cluster DoorLock = 257 {
nullable INT16U dataIndex = 6;
}

readonly attribute DlLockState lockState = 0;
readonly attribute nullable DlLockState lockState = 0;
readonly attribute DlLockType lockType = 1;
readonly attribute boolean actuatorEnabled = 2;
readonly attribute DlDoorState doorState = 3;
readonly attribute nullable DlDoorState doorState = 3;
readonly attribute int16u numberOfTotalUsersSupported = 17;
readonly attribute int16u numberOfPINUsersSupported = 18;
readonly attribute int8u maxPINCodeLength = 23;
Expand Down
12 changes: 6 additions & 6 deletions examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,11 @@ server cluster LevelControl = 8 {
readonly attribute int16u maxFrequency = 6;
attribute bitmap8 options = 15;
attribute int16u onOffTransitionTime = 16;
attribute int8u onLevel = 17;
attribute int16u onTransitionTime = 18;
attribute int16u offTransitionTime = 19;
attribute int8u defaultMoveRate = 20;
attribute int8u startUpCurrentLevel = 16384;
attribute nullable int8u onLevel = 17;
attribute nullable int16u onTransitionTime = 18;
attribute nullable int16u offTransitionTime = 19;
attribute nullable int8u defaultMoveRate = 20;
attribute nullable int8u startUpCurrentLevel = 16384;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down Expand Up @@ -913,7 +913,7 @@ server cluster OtaSoftwareUpdateRequestor = 42 {
attribute ProviderLocation defaultOtaProviders[] = 0;
readonly attribute boolean updatePossible = 1;
readonly attribute OTAUpdateStateEnum updateState = 2;
readonly attribute int8u updateStateProgress = 3;
readonly attribute nullable int8u updateStateProgress = 3;
readonly global attribute int16u clusterRevision = 65533;

request struct AnnounceOtaProviderRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ server cluster OtaSoftwareUpdateRequestor = 42 {
attribute ProviderLocation defaultOtaProviders[] = 0;
readonly attribute boolean updatePossible = 1;
readonly attribute OTAUpdateStateEnum updateState = 2;
readonly attribute int8u updateStateProgress = 3;
readonly attribute nullable int8u updateStateProgress = 3;
readonly global attribute int16u clusterRevision = 65533;

request struct AnnounceOtaProviderRequest {
Expand Down
4 changes: 2 additions & 2 deletions examples/pump-app/pump-common/pump-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,9 @@ server cluster PumpConfigurationAndControl = 512 {
readonly attribute enum8 effectiveControlMode = 18;
readonly attribute int16s capacity = 19;
readonly attribute int16u speed = 20;
attribute int24u lifetimeRunningHours = 21;
attribute nullable int24u lifetimeRunningHours = 21;
readonly attribute int24u power = 22;
attribute int32u lifetimeEnergyConsumed = 23;
attribute nullable int32u lifetimeEnergyConsumed = 23;
attribute enum8 operationMode = 32;
attribute enum8 controlMode = 33;
readonly attribute bitmap16 alarmMask = 34;
Expand Down
10 changes: 5 additions & 5 deletions examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,11 @@ server cluster LevelControl = 8 {
readonly attribute int16u maxFrequency = 6;
attribute bitmap8 options = 15;
attribute int16u onOffTransitionTime = 16;
attribute int8u onLevel = 17;
attribute int16u onTransitionTime = 18;
attribute int16u offTransitionTime = 19;
attribute int8u defaultMoveRate = 20;
attribute int8u startUpCurrentLevel = 16384;
attribute nullable int8u onLevel = 17;
attribute nullable int16u onTransitionTime = 18;
attribute nullable int16u offTransitionTime = 19;
attribute nullable int8u defaultMoveRate = 20;
attribute nullable int8u startUpCurrentLevel = 16384;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

Expand Down
30 changes: 15 additions & 15 deletions examples/tv-casting-app/tv-casting-common/tv-casting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -879,10 +879,10 @@ server cluster DoorLock = 257 {
nullable INT16U dataIndex = 6;
}

readonly attribute DlLockState lockState = 0;
readonly attribute nullable DlLockState lockState = 0;
readonly attribute DlLockType lockType = 1;
readonly attribute boolean actuatorEnabled = 2;
readonly attribute DlDoorState doorState = 3;
readonly attribute nullable DlDoorState doorState = 3;
attribute int32u doorOpenEvents = 4;
attribute int32u doorClosedEvents = 5;
attribute int16u openPeriod = 6;
Expand Down Expand Up @@ -1468,11 +1468,11 @@ server cluster LevelControl = 8 {
readonly attribute int16u maxFrequency = 6;
attribute bitmap8 options = 15;
attribute int16u onOffTransitionTime = 16;
attribute int8u onLevel = 17;
attribute int16u onTransitionTime = 18;
attribute int16u offTransitionTime = 19;
attribute int8u defaultMoveRate = 20;
attribute int8u startUpCurrentLevel = 16384;
attribute nullable int8u onLevel = 17;
attribute nullable int16u onTransitionTime = 18;
attribute nullable int16u offTransitionTime = 19;
attribute nullable int8u defaultMoveRate = 20;
attribute nullable int8u startUpCurrentLevel = 16384;
readonly global attribute int16u clusterRevision = 65533;

request struct MoveRequest {
Expand Down Expand Up @@ -2472,17 +2472,17 @@ server cluster WiFiNetworkDiagnostics = 54 {

server cluster WindowCovering = 258 {
readonly attribute enum8 type = 0;
readonly attribute int16u currentPositionLift = 3;
readonly attribute int16u currentPositionTilt = 4;
readonly attribute nullable int16u currentPositionLift = 3;
readonly attribute nullable int16u currentPositionTilt = 4;
readonly attribute bitmap8 configStatus = 7;
readonly attribute Percent currentPositionLiftPercentage = 8;
readonly attribute Percent currentPositionTiltPercentage = 9;
readonly attribute nullable Percent currentPositionLiftPercentage = 8;
readonly attribute nullable Percent currentPositionTiltPercentage = 9;
readonly attribute bitmap8 operationalStatus = 10;
readonly attribute Percent100ths targetPositionLiftPercent100ths = 11;
readonly attribute Percent100ths targetPositionTiltPercent100ths = 12;
readonly attribute nullable Percent100ths targetPositionLiftPercent100ths = 11;
readonly attribute nullable Percent100ths targetPositionTiltPercent100ths = 12;
readonly attribute enum8 endProductType = 13;
readonly attribute Percent100ths currentPositionLiftPercent100ths = 14;
readonly attribute Percent100ths currentPositionTiltPercent100ths = 15;
readonly attribute nullable Percent100ths currentPositionLiftPercent100ths = 14;
readonly attribute nullable Percent100ths currentPositionTiltPercent100ths = 15;
readonly attribute int16u installedOpenLimitLift = 16;
readonly attribute int16u installedClosedLimitLift = 17;
readonly attribute int16u installedOpenLimitTilt = 18;
Expand Down
16 changes: 8 additions & 8 deletions examples/window-app/common/window-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -823,17 +823,17 @@ server cluster WiFiNetworkDiagnostics = 54 {

server cluster WindowCovering = 258 {
readonly attribute enum8 type = 0;
readonly attribute int16u currentPositionLift = 3;
readonly attribute int16u currentPositionTilt = 4;
readonly attribute nullable int16u currentPositionLift = 3;
readonly attribute nullable int16u currentPositionTilt = 4;
readonly attribute bitmap8 configStatus = 7;
readonly attribute Percent currentPositionLiftPercentage = 8;
readonly attribute Percent currentPositionTiltPercentage = 9;
readonly attribute nullable Percent currentPositionLiftPercentage = 8;
readonly attribute nullable Percent currentPositionTiltPercentage = 9;
readonly attribute bitmap8 operationalStatus = 10;
readonly attribute Percent100ths targetPositionLiftPercent100ths = 11;
readonly attribute Percent100ths targetPositionTiltPercent100ths = 12;
readonly attribute nullable Percent100ths targetPositionLiftPercent100ths = 11;
readonly attribute nullable Percent100ths targetPositionTiltPercent100ths = 12;
readonly attribute enum8 endProductType = 13;
readonly attribute Percent100ths currentPositionLiftPercent100ths = 14;
readonly attribute Percent100ths currentPositionTiltPercent100ths = 15;
readonly attribute nullable Percent100ths currentPositionLiftPercent100ths = 14;
readonly attribute nullable Percent100ths currentPositionTiltPercent100ths = 15;
readonly attribute int16u installedOpenLimitLift = 16;
readonly attribute int16u installedClosedLimitLift = 17;
readonly attribute int16u installedOpenLimitTilt = 18;
Expand Down
Loading

0 comments on commit 8f1ae92

Please sign in to comment.