Skip to content

Commit 5decd01

Browse files
authored
Matter add copy to Path (#21674)
1 parent 40fb8fa commit 5decd01

File tree

2 files changed

+56
-9
lines changed

2 files changed

+56
-9
lines changed

lib/libesp32/berry_matter/src/embedded/Matter_Path_0.be

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ class Matter_Path
3636
var log # any string that needs to be logged (used to show significant parameters for commands)
3737
var msg # reference of the original message
3838

39+
# copy from an aobject that has also endpoint/cluster/attribute variables
40+
def copy(c)
41+
self.reset()
42+
self.endpoint = c.endpoint
43+
self.cluster = c.cluster
44+
self.attribute = c.attribute
45+
end
46+
3947
# reset the object, allows reuse of the same object
4048
def reset()
4149
var n = nil # it's actually more compact code to load `nil` into a register and assign all members

lib/libesp32/berry_matter/src/solidify/solidified_Matter_Path_0.h

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,44 @@ be_local_closure(class_Matter_Path_tostring, /* name */
123123
/*******************************************************************/
124124

125125

126+
/********************************************************************
127+
** Solidified function: copy
128+
********************************************************************/
129+
extern const bclass be_class_Matter_Path;
130+
be_local_closure(class_Matter_Path_copy, /* name */
131+
be_nested_proto(
132+
4, /* nstack */
133+
2, /* argc */
134+
2, /* varg */
135+
0, /* has upvals */
136+
NULL, /* no upvals */
137+
0, /* has sup protos */
138+
&be_class_Matter_Path,
139+
1, /* has constants */
140+
( &(const bvalue[ 4]) { /* constants */
141+
/* K0 */ be_nested_str_weak(reset),
142+
/* K1 */ be_nested_str_weak(endpoint),
143+
/* K2 */ be_nested_str_weak(cluster),
144+
/* K3 */ be_nested_str_weak(attribute),
145+
}),
146+
be_str_weak(copy),
147+
&be_const_str_solidified,
148+
( &(const binstruction[ 9]) { /* code */
149+
0x8C080100, // 0000 GETMET R2 R0 K0
150+
0x7C080200, // 0001 CALL R2 1
151+
0x88080301, // 0002 GETMBR R2 R1 K1
152+
0x90020202, // 0003 SETMBR R0 K1 R2
153+
0x88080302, // 0004 GETMBR R2 R1 K2
154+
0x90020402, // 0005 SETMBR R0 K2 R2
155+
0x88080303, // 0006 GETMBR R2 R1 K3
156+
0x90020602, // 0007 SETMBR R0 K3 R2
157+
0x80000000, // 0008 RET 0
158+
})
159+
)
160+
);
161+
/*******************************************************************/
162+
163+
126164
/********************************************************************
127165
** Solidified function: reset
128166
********************************************************************/
@@ -172,18 +210,19 @@ be_local_closure(class_Matter_Path_reset, /* name */
172210
be_local_class(Matter_Path,
173211
8,
174212
NULL,
175-
be_nested_map(10,
213+
be_nested_map(11,
176214
( (struct bmapnode*) &(const bmapnode[]) {
177-
{ be_const_key_weak(attribute, -1), be_const_var(2) },
178-
{ be_const_key_weak(log, 0), be_const_var(6) },
179-
{ be_const_key_weak(fabric_filtered, 6), be_const_var(3) },
180215
{ be_const_key_weak(command, -1), be_const_var(4) },
181-
{ be_const_key_weak(msg, -1), be_const_var(7) },
182-
{ be_const_key_weak(tostring, -1), be_const_closure(class_Matter_Path_tostring_closure) },
216+
{ be_const_key_weak(cluster, 5), be_const_var(1) },
217+
{ be_const_key_weak(attribute, -1), be_const_var(2) },
218+
{ be_const_key_weak(tostring, 9), be_const_closure(class_Matter_Path_tostring_closure) },
219+
{ be_const_key_weak(log, -1), be_const_var(6) },
220+
{ be_const_key_weak(status, 2), be_const_var(5) },
221+
{ be_const_key_weak(endpoint, -1), be_const_var(0) },
222+
{ be_const_key_weak(msg, 6), be_const_var(7) },
223+
{ be_const_key_weak(fabric_filtered, -1), be_const_var(3) },
224+
{ be_const_key_weak(copy, -1), be_const_closure(class_Matter_Path_copy_closure) },
183225
{ be_const_key_weak(reset, -1), be_const_closure(class_Matter_Path_reset_closure) },
184-
{ be_const_key_weak(cluster, -1), be_const_var(1) },
185-
{ be_const_key_weak(endpoint, 3), be_const_var(0) },
186-
{ be_const_key_weak(status, -1), be_const_var(5) },
187226
})),
188227
be_str_weak(Matter_Path)
189228
);

0 commit comments

Comments
 (0)