From 29f46ee470e48929dc455caa27a345ad39bbddf6 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 3 Nov 2021 14:29:05 +0000 Subject: [PATCH] acpi_tables: aml: Implement Aml::append_aml_bytes() for If For now it still relies on Aml::to_aml_bytes() for the children as not all structures have been ported. Signed-off-by: Rob Bradford --- acpi_tables/src/aml.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/acpi_tables/src/aml.rs b/acpi_tables/src/aml.rs index 9829b6660..810447c4d 100644 --- a/acpi_tables/src/aml.rs +++ b/acpi_tables/src/aml.rs @@ -786,21 +786,18 @@ impl<'a> If<'a> { } impl<'a> Aml for If<'a> { - fn to_aml_bytes(&self) -> Vec { - let mut bytes = Vec::new(); - bytes.extend_from_slice(&self.predicate.to_aml_bytes()); + fn append_aml_bytes(&self, bytes: &mut Vec) { + let mut tmp = Vec::new(); + tmp.extend_from_slice(&self.predicate.to_aml_bytes()); for child in self.if_children.iter() { - bytes.extend_from_slice(&child.to_aml_bytes()); + tmp.extend_from_slice(&child.to_aml_bytes()); } - let mut pkg_length = create_pkg_length(&bytes, true); - pkg_length.reverse(); - for byte in pkg_length { - bytes.insert(0, byte); - } + let mut pkg_length = create_pkg_length(&tmp, true); - bytes.insert(0, 0xa0); /* IfOp */ - bytes + bytes.push(0xa0); /* IfOp */ + bytes.append(&mut pkg_length); + bytes.append(&mut tmp); } }