-
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.
Move ClusterWriteMapping.java to be generated from matter.idl (#25773)
* Some initial changes * Parser support for timed writes * Small doc update * Matter idl support for timed write * Fix indent and codegen all * Remove extra line from readme * Some fixes * Fix conditional in requires_timed_write * Most codegen looks ok. Java boxing logic is suspect still * More updates, output idential EXCEPT types for boxing * Increase 1000 to 10000 to match original template * Fix byte count comparison when long starts to take effect * Fix length of underlying bitmap type sizing * Fixed files, they are IDENTICAL * Integrate java-jni and java-class since build rules are different between cpp and java files * Fix python syntax * Switch default to not have underscore * Add java codegen via jinja to zap_regen_all * Restyle, fix restyle logic * Fix duplicated generation target * Do not attempt to zap-generate Cluster write mapping * Add golden image unit test for java codegen * Add prettyfy for java output ... makes the input/output files more obviously identical * Remove unused variable * Fix upper/lowercase of acronyms, to be fully backwards compatible * Add license blurb since we checkin generated file (and maybe jinja files should also have licenses * Restyle * Fix unit test --------- Co-authored-by: Andrei Litvin <[email protected]>
- Loading branch information
1 parent
82af6b5
commit 31e31cc
Showing
20 changed files
with
358 additions
and
82 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
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
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
67 changes: 67 additions & 0 deletions
67
scripts/py_matter_idl/matter_idl/generators/java/ClusterWriteMapping.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,67 @@ | ||
/* | ||
* | ||
* 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 chip.devicecontroller.ChipClusters.DefaultClusterCallback; | ||
import java.util.HashMap; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
public class ClusterWriteMapping { | ||
public Map<String, Map<String, InteractionInfo>> getWriteAttributeMap() { | ||
Map<String, Map<String, InteractionInfo>> writeAttributeMap = new HashMap<>(); | ||
|
||
{%- for cluster in clientClusters | sort(attribute='code') %} | ||
{%- set typeLookup = idl | createLookupContext(cluster) %} | ||
Map<String, InteractionInfo> write{{cluster.name}}InteractionInfo = new LinkedHashMap<>(); | ||
{%- for attribute in cluster.attributes | sort(attribute='name') | attributesWithCallback(typeLookup) %} | ||
{#- TODO: add support for struct-typed attributes -#} | ||
{% if not attribute.definition.is_list and attribute.is_writable %} | ||
Map<String, CommandParameterInfo> write{{cluster.name}}{{attribute.definition.name | upfirst}}CommandParams = new LinkedHashMap<String, CommandParameterInfo>(); | ||
{%- set encodable = attribute.definition | asEncodable(typeLookup) %} | ||
CommandParameterInfo {{cluster.name | lowfirst_except_acronym}}{{attribute.definition.name | lowfirst_except_acronym}}CommandParameterInfo = | ||
new CommandParameterInfo( | ||
"value", | ||
{{ encodable.boxed_java_type }}.class, {# {{asJavaType type null parent.parent.name removeGenericType=true}}.class, #} | ||
{{ encodable.boxed_java_type }}.class {# {{asJavaType type null parent.parent.name underlyingType=true}}.class #} | ||
); | ||
write{{cluster.name}}{{attribute.definition.name | upfirst}}CommandParams.put( | ||
"value", | ||
{{cluster.name | lowfirst_except_acronym}}{{attribute.definition.name | lowfirst_except_acronym}}CommandParameterInfo | ||
); | ||
InteractionInfo write{{cluster.name}}{{attribute.definition.name | upfirst}}AttributeInteractionInfo = new InteractionInfo( | ||
(cluster, callback, commandArguments) -> { | ||
((ChipClusters.{{cluster.name}}Cluster) cluster).write{{attribute.definition.name | upfirst}}Attribute( | ||
(DefaultClusterCallback) callback, | ||
({{ encodable.boxed_java_type }}) commandArguments.get("value") | ||
{%- if attribute.requires_timed_write -%}, 10000 {% endif %} | ||
); | ||
}, | ||
() -> new ClusterInfoMapping.DelegatedDefaultClusterCallback(), | ||
write{{cluster.name}}{{attribute.definition.name | upfirst}}CommandParams | ||
); | ||
write{{cluster.name}}InteractionInfo.put("write{{attribute.definition.name | upfirst}}Attribute", write{{cluster.name}}{{attribute.definition.name | upfirst}}AttributeInteractionInfo); | ||
{%- endif %} | ||
{%- endfor %} | ||
writeAttributeMap.put("{{cluster.name | lowfirst_except_acronym}}", write{{cluster.name}}InteractionInfo); | ||
{%- endfor -%} | ||
|
||
return writeAttributeMap; | ||
} | ||
} |
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
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
Oops, something went wrong.