Skip to content

Commit

Permalink
Reformat generated Java code to make it more readable.
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Oct 22, 2023
1 parent d870e8c commit 4fbebf8
Show file tree
Hide file tree
Showing 2 changed files with 8,889 additions and 10,522 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
{{encodable.boxed_java_type}}
{%- endif -%}
{%- endmacro -%}

/*
*
* Copyright (c) 2023 Project CHIP Authors
Expand Down Expand Up @@ -164,7 +165,7 @@ public class ChipClusters {
@Override
public native long initWithDevice(long devicePtr, int endpointId);

{% for command in cluster.commands | sort(attribute='code') -%}
{%- for command in cluster.commands | sort(attribute='code') -%}
{%- set callbackName = command | javaCommandCallbackName() -%}
{%- if not command.is_timed_invoke %}
public void {{command.name | lowfirst_except_acronym}}({{callbackName}}Callback callback
Expand Down Expand Up @@ -226,10 +227,9 @@ public class ChipClusters {
{%- if loop.index0 < loop.length - 1 -%}{{", "}}{%- endif -%}
{%- endfor -%}
);

void onError(Exception error);
}
{%- if already_handled_command.append(callbackName) -%}
{% if already_handled_command.append(callbackName) -%}
{#- This block does nothing, it only exists to append to already_handled_command. -#}
{%- endif -%}
{%- endif -%}
Expand All @@ -245,11 +245,11 @@ public class ChipClusters {
void onError(Exception ex);
default void onSubscriptionEstablished(long subscriptionId) {}
}
{%- if already_handled_attribute.append(interfaceName) -%}
{% if already_handled_attribute.append(interfaceName) -%}
{#- This block does nothing, it only exists to append to already_handled_attribute. -#}
{%- endif -%}
{%- endif -%}
{% endfor %}
{% endfor -%}
{% for attribute in cluster.attributes | sort(attribute='code') %}
public void read{{attribute.definition.name | upfirst}}Attribute(
{{attribute | javaAttributeCallbackName(typeLookup) }} callback) {
Expand All @@ -259,7 +259,7 @@ public class ChipClusters {
{%- endif -%}
);
}
{%- if attribute | isFabricScopedList(typeLookup) %}
{% if attribute | isFabricScopedList(typeLookup) %}
public void read{{attribute.definition.name | upfirst}}AttributeWithFabricFilter(
{{attribute | javaAttributeCallbackName(typeLookup) }} callback, boolean isFabricFiltered) {
read{{attribute.definition.name | upfirst}}Attribute(chipClusterPtr, callback, isFabricFiltered);
Expand All @@ -273,23 +273,20 @@ public class ChipClusters {
public void write{{attribute.definition.name | upfirst}}Attribute(DefaultClusterCallback callback, {{encode_value_without_optional_nullable(cluster, encodable, 0)}} value) {
write{{attribute.definition.name | upfirst}}Attribute(chipClusterPtr, callback, value, null);
}

{% endif %}
public void write{{attribute.definition.name | upfirst}}Attribute(DefaultClusterCallback callback, {{encode_value_without_optional_nullable(cluster, encodable2, 0)}} value, int timedWriteTimeoutMs) {
write{{attribute.definition.name | upfirst}}Attribute(chipClusterPtr, callback, value, timedWriteTimeoutMs);
}

{% endif %}
{% if attribute.is_subscribable %}
{%- if attribute.is_subscribable %}
public void subscribe{{attribute.definition.name | upfirst}}Attribute(
{{attribute | javaAttributeCallbackName(typeLookup) }} callback, int minInterval, int maxInterval) {
subscribe{{attribute.definition.name | upfirst}}Attribute(chipClusterPtr, callback, minInterval, maxInterval);
}
{% endif -%}
{%- endfor %}
{% for attribute in cluster.attributes %}
private native void read{{attribute.definition.name | upfirst}}Attribute(long chipClusterPtr
, {{attribute | javaAttributeCallbackName(typeLookup) }} callback
{%- for attribute in cluster.attributes %}
private native void read{{attribute.definition.name | upfirst}}Attribute(long chipClusterPtr, {{attribute | javaAttributeCallbackName(typeLookup) }} callback
{%- if attribute | isFabricScopedList(typeLookup) -%}
, boolean isFabricFiltered
{%- endif -%}
Expand All @@ -299,10 +296,9 @@ public class ChipClusters {
private native void write{{attribute.definition.name | upfirst}}Attribute(long chipClusterPtr, DefaultClusterCallback callback, {{encode_value_without_optional_nullable(cluster, encodable, 0)}} value, @Nullable Integer timedWriteTimeoutMs);
{% endif -%}
{% if attribute.is_subscribable %}
private native void subscribe{{attribute.definition.name | upfirst}}Attribute(long chipClusterPtr
, {{attribute | javaAttributeCallbackName(typeLookup) }} callback, int minInterval, int maxInterval);
{%- endif -%}
private native void subscribe{{attribute.definition.name | upfirst}}Attribute(long chipClusterPtr, {{attribute | javaAttributeCallbackName(typeLookup) }} callback, int minInterval, int maxInterval);
{% endif -%}
{% endfor %}
}
{%- endfor %}
{% endfor %}
}
Loading

0 comments on commit 4fbebf8

Please sign in to comment.