Skip to content

Commit

Permalink
Reformat generated Java code to make it more readable. (#29899)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca authored and pull[bot] committed Oct 31, 2023
1 parent f2bb06d commit f854ab4
Show file tree
Hide file tree
Showing 3 changed files with 14,203 additions and 15,857 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 @@ -163,7 +164,6 @@ public class ChipClusters {

@Override
public native long initWithDevice(long devicePtr, int endpointId);

{% for command in cluster.commands | sort(attribute='code') -%}
{%- set callbackName = command | javaCommandCallbackName() -%}
{%- if not command.is_timed_invoke %}
Expand Down Expand Up @@ -226,10 +226,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 +244,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 +258,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 +272,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 +295,10 @@ 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 -%}
{% endfor %}
}
{%- endfor %}
private native void subscribe{{attribute.definition.name | upfirst}}Attribute(long chipClusterPtr, {{attribute | javaAttributeCallbackName(typeLookup) }} callback, int minInterval, int maxInterval);
{% endif -%}
{% endfor -%}
{% raw %} }
{% endraw %}
{%- endfor -%}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,37 +125,31 @@ public FirstCluster(long devicePtr, int endpointId) {
@Override
public native long initWithDevice(long devicePtr, int endpointId);



public void readSomeIntegerAttribute(
IntegerAttributeCallback callback) {
readSomeIntegerAttribute(chipClusterPtr, callback);
}

public void writeSomeIntegerAttribute(DefaultClusterCallback callback, Integer value) {
writeSomeIntegerAttribute(chipClusterPtr, callback, value, null);
}


public void writeSomeIntegerAttribute(DefaultClusterCallback callback, Integer value, int timedWriteTimeoutMs) {
writeSomeIntegerAttribute(chipClusterPtr, callback, value, timedWriteTimeoutMs);
}



public void subscribeSomeIntegerAttribute(
IntegerAttributeCallback callback, int minInterval, int maxInterval) {
subscribeSomeIntegerAttribute(chipClusterPtr, callback, minInterval, maxInterval);
}


private native void readSomeIntegerAttribute(long chipClusterPtr
, IntegerAttributeCallback callback);
private native void readSomeIntegerAttribute(long chipClusterPtr, IntegerAttributeCallback callback);

private native void writeSomeIntegerAttribute(long chipClusterPtr, DefaultClusterCallback callback, Integer value, @Nullable Integer timedWriteTimeoutMs);

private native void subscribeSomeIntegerAttribute(long chipClusterPtr
, IntegerAttributeCallback callback, int minInterval, int maxInterval);
private native void subscribeSomeIntegerAttribute(long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval);
}

public static class SecondCluster extends BaseChipCluster {
public static final long CLUSTER_ID = 2L;

Expand All @@ -166,7 +160,6 @@ public SecondCluster(long devicePtr, int endpointId) {
@Override
public native long initWithDevice(long devicePtr, int endpointId);


public interface FabricsAttributeCallback {
void onSuccess(List<ChipStructs.SecondClusterFabricDescriptorStruct> value);
void onError(Exception ex);
Expand All @@ -177,13 +170,13 @@ public void readFabricsAttribute(
FabricsAttributeCallback callback) {
readFabricsAttribute(chipClusterPtr, callback, true);
}

public void readFabricsAttributeWithFabricFilter(
FabricsAttributeCallback callback, boolean isFabricFiltered) {
readFabricsAttribute(chipClusterPtr, callback, isFabricFiltered);
}



public void subscribeFabricsAttribute(
FabricsAttributeCallback callback, int minInterval, int maxInterval) {
subscribeFabricsAttribute(chipClusterPtr, callback, minInterval, maxInterval);
Expand All @@ -199,18 +192,15 @@ public void subscribeSomeBytesAttribute(
subscribeSomeBytesAttribute(chipClusterPtr, callback, minInterval, maxInterval);
}

private native void readFabricsAttribute(long chipClusterPtr, FabricsAttributeCallback callback, boolean isFabricFiltered);

private native void readFabricsAttribute(long chipClusterPtr
, FabricsAttributeCallback callback, boolean isFabricFiltered);
private native void subscribeFabricsAttribute(long chipClusterPtr, FabricsAttributeCallback callback, int minInterval, int maxInterval);

private native void subscribeFabricsAttribute(long chipClusterPtr
, FabricsAttributeCallback callback, int minInterval, int maxInterval);
private native void readSomeBytesAttribute(long chipClusterPtr
, OctetStringAttributeCallback callback);
private native void readSomeBytesAttribute(long chipClusterPtr, OctetStringAttributeCallback callback);

private native void subscribeSomeBytesAttribute(long chipClusterPtr
, OctetStringAttributeCallback callback, int minInterval, int maxInterval);
private native void subscribeSomeBytesAttribute(long chipClusterPtr, OctetStringAttributeCallback callback, int minInterval, int maxInterval);
}

public static class ThirdCluster extends BaseChipCluster {
public static final long CLUSTER_ID = 3L;

Expand All @@ -221,23 +211,19 @@ public ThirdCluster(long devicePtr, int endpointId) {
@Override
public native long initWithDevice(long devicePtr, int endpointId);



public void readSomeEnumAttribute(
IntegerAttributeCallback callback) {
readSomeEnumAttribute(chipClusterPtr, callback);
}

public void writeSomeEnumAttribute(DefaultClusterCallback callback, Integer value) {
writeSomeEnumAttribute(chipClusterPtr, callback, value, null);
}


public void writeSomeEnumAttribute(DefaultClusterCallback callback, Integer value, int timedWriteTimeoutMs) {
writeSomeEnumAttribute(chipClusterPtr, callback, value, timedWriteTimeoutMs);
}



public void subscribeSomeEnumAttribute(
IntegerAttributeCallback callback, int minInterval, int maxInterval) {
subscribeSomeEnumAttribute(chipClusterPtr, callback, minInterval, maxInterval);
Expand All @@ -247,36 +233,30 @@ public void readOptionsAttribute(
IntegerAttributeCallback callback) {
readOptionsAttribute(chipClusterPtr, callback);
}

public void writeOptionsAttribute(DefaultClusterCallback callback, Integer value) {
writeOptionsAttribute(chipClusterPtr, callback, value, null);
}


public void writeOptionsAttribute(DefaultClusterCallback callback, Integer value, int timedWriteTimeoutMs) {
writeOptionsAttribute(chipClusterPtr, callback, value, timedWriteTimeoutMs);
}



public void subscribeOptionsAttribute(
IntegerAttributeCallback callback, int minInterval, int maxInterval) {
subscribeOptionsAttribute(chipClusterPtr, callback, minInterval, maxInterval);
}


private native void readSomeEnumAttribute(long chipClusterPtr
, IntegerAttributeCallback callback);
private native void readSomeEnumAttribute(long chipClusterPtr, IntegerAttributeCallback callback);

private native void writeSomeEnumAttribute(long chipClusterPtr, DefaultClusterCallback callback, Integer value, @Nullable Integer timedWriteTimeoutMs);

private native void subscribeSomeEnumAttribute(long chipClusterPtr
, IntegerAttributeCallback callback, int minInterval, int maxInterval);
private native void readOptionsAttribute(long chipClusterPtr
, IntegerAttributeCallback callback);
private native void subscribeSomeEnumAttribute(long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval);

private native void readOptionsAttribute(long chipClusterPtr, IntegerAttributeCallback callback);

private native void writeOptionsAttribute(long chipClusterPtr, DefaultClusterCallback callback, Integer value, @Nullable Integer timedWriteTimeoutMs);

private native void subscribeOptionsAttribute(long chipClusterPtr
, IntegerAttributeCallback callback, int minInterval, int maxInterval);
private native void subscribeOptionsAttribute(long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval);
}
}
Loading

0 comments on commit f854ab4

Please sign in to comment.