-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MigrateClusterReadMapping.java to jinja codegen (#25786)
* Fix comment * Some initial move (no codege) so that I can see codegen deltas * Start some codegen (but obviously incomplete * Codegen actually works and is fully backwards compatible * Remove old zap file * Fix unit tests * Updated doccomments ... unfortunately we have a few very similar names in our codegen * Remove trailing whitespace
- Loading branch information
Showing
11 changed files
with
185 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
scripts/py_matter_idl/matter_idl/generators/java/ClusterReadMapping.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package chip.devicecontroller; | ||
|
||
import chip.clusterinfo.CommandParameterInfo; | ||
import chip.clusterinfo.InteractionInfo; | ||
import java.util.HashMap; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
public class ClusterReadMapping { | ||
public Map<String, Map<String, InteractionInfo>> getReadAttributeMap() { | ||
Map<String, Map<String, InteractionInfo>> readAttributeMap = new HashMap<>(); | ||
|
||
{%- for cluster in clientClusters | sort(attribute='code') %} | ||
{%- set typeLookup = idl | createLookupContext(cluster) %} | ||
Map<String, InteractionInfo> read{{cluster.name}}InteractionInfo = new LinkedHashMap<>(); | ||
{%- for attribute in cluster.attributes | sort(attribute='name') | attributesWithCallback(typeLookup) %} | ||
{#- TODO: add support for struct-typed attributes -#} | ||
Map<String, CommandParameterInfo> read{{cluster.name}}{{attribute.definition.name | upfirst}}CommandParams = new LinkedHashMap<String, CommandParameterInfo>(); | ||
InteractionInfo read{{cluster.name}}{{attribute.definition.name | upfirst}}AttributeInteractionInfo = new InteractionInfo( | ||
(cluster, callback, commandArguments) -> { | ||
((ChipClusters.{{cluster.name}}Cluster) cluster).read{{attribute.definition.name | upfirst}}Attribute( | ||
({{ attribute | chipClustersCallbackName(typeLookup) }}) callback | ||
); | ||
}, | ||
() -> new ClusterInfoMapping.{{ attribute | delegatedCallbackName(typeLookup)}}(), | ||
read{{cluster.name}}{{attribute.definition.name | upfirst}}CommandParams | ||
); | ||
read{{cluster.name}}InteractionInfo.put("read{{attribute.definition.name | upfirst}}Attribute", read{{cluster.name}}{{attribute.definition.name | upfirst}}AttributeInteractionInfo); | ||
{%- endfor %} | ||
readAttributeMap.put("{{cluster.name | lowfirst_except_acronym}}", read{{cluster.name}}InteractionInfo); | ||
{%- endfor -%} | ||
return readAttributeMap; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/java/ClusterReadMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package chip.devicecontroller; | ||
|
||
import chip.clusterinfo.CommandParameterInfo; | ||
import chip.clusterinfo.InteractionInfo; | ||
import java.util.HashMap; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
public class ClusterReadMapping { | ||
public Map<String, Map<String, InteractionInfo>> getReadAttributeMap() { | ||
Map<String, Map<String, InteractionInfo>> readAttributeMap = new HashMap<>(); | ||
Map<String, InteractionInfo> readFirstInteractionInfo = new LinkedHashMap<>();Map<String, CommandParameterInfo> readFirstSomeIntegerCommandParams = new LinkedHashMap<String, CommandParameterInfo>(); | ||
InteractionInfo readFirstSomeIntegerAttributeInteractionInfo = new InteractionInfo( | ||
(cluster, callback, commandArguments) -> { | ||
((ChipClusters.FirstCluster) cluster).readSomeIntegerAttribute( | ||
(ChipClusters.IntegerAttributeCallback) callback | ||
); | ||
}, | ||
() -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), | ||
readFirstSomeIntegerCommandParams | ||
); | ||
readFirstInteractionInfo.put("readSomeIntegerAttribute", readFirstSomeIntegerAttributeInteractionInfo); | ||
readAttributeMap.put("first", readFirstInteractionInfo); | ||
Map<String, InteractionInfo> readSecondInteractionInfo = new LinkedHashMap<>();Map<String, CommandParameterInfo> readSecondSomeBytesCommandParams = new LinkedHashMap<String, CommandParameterInfo>(); | ||
InteractionInfo readSecondSomeBytesAttributeInteractionInfo = new InteractionInfo( | ||
(cluster, callback, commandArguments) -> { | ||
((ChipClusters.SecondCluster) cluster).readSomeBytesAttribute( | ||
(ChipClusters.OctetStringAttributeCallback) callback | ||
); | ||
}, | ||
() -> new ClusterInfoMapping.DelegatedOctetStringAttributeCallback(), | ||
readSecondSomeBytesCommandParams | ||
); | ||
readSecondInteractionInfo.put("readSomeBytesAttribute", readSecondSomeBytesAttributeInteractionInfo); | ||
readAttributeMap.put("second", readSecondInteractionInfo); | ||
Map<String, InteractionInfo> readThirdInteractionInfo = new LinkedHashMap<>();Map<String, CommandParameterInfo> readThirdSomeEnumCommandParams = new LinkedHashMap<String, CommandParameterInfo>(); | ||
InteractionInfo readThirdSomeEnumAttributeInteractionInfo = new InteractionInfo( | ||
(cluster, callback, commandArguments) -> { | ||
((ChipClusters.ThirdCluster) cluster).readSomeEnumAttribute( | ||
(ChipClusters.IntegerAttributeCallback) callback | ||
); | ||
}, | ||
() -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), | ||
readThirdSomeEnumCommandParams | ||
); | ||
readThirdInteractionInfo.put("readSomeEnumAttribute", readThirdSomeEnumAttributeInteractionInfo);Map<String, CommandParameterInfo> readThirdOptionsCommandParams = new LinkedHashMap<String, CommandParameterInfo>(); | ||
InteractionInfo readThirdOptionsAttributeInteractionInfo = new InteractionInfo( | ||
(cluster, callback, commandArguments) -> { | ||
((ChipClusters.ThirdCluster) cluster).readOptionsAttribute( | ||
(ChipClusters.IntegerAttributeCallback) callback | ||
); | ||
}, | ||
() -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), | ||
readThirdOptionsCommandParams | ||
); | ||
readThirdInteractionInfo.put("readOptionsAttribute", readThirdOptionsAttributeInteractionInfo); | ||
readAttributeMap.put("third", readThirdInteractionInfo);return readAttributeMap; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
src/controller/java/templates/ClusterInfo-read-interaction.zapt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters