From 7b8523d2eae09918e038ab41344da0809fa11b0f Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Tue, 14 May 2024 05:23:00 -0700 Subject: [PATCH] chore(vm): clean up spelling and RC usage --- ic10emu/src/vm.rs | 26 +++++++++++++------------- ic10emu/src/vm/object/stationpedia.rs | 2 +- ic10emu/src/vm/object/templates.rs | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ic10emu/src/vm.rs b/ic10emu/src/vm.rs index 631628c..2e21495 100644 --- a/ic10emu/src/vm.rs +++ b/ic10emu/src/vm.rs @@ -11,7 +11,7 @@ use crate::{ enums::script_enums::{LogicBatchMethod, LogicSlotType, LogicType}, object::{ templates::ObjectTemplate, - traits::{Object, ParentSlotInfo}, + traits::ParentSlotInfo, ObjectID, VMObject, }, }, @@ -43,7 +43,7 @@ pub struct VM { } #[derive(Debug, Default)] -pub struct VMTransationNetwork { +pub struct VMTransactionNetwork { pub objects: Vec, pub power_only: Vec, } @@ -51,7 +51,7 @@ pub struct VMTransationNetwork { #[derive(Debug)] /// used as a temp structure to add objects in case /// there are errors on nested templates -pub struct VMTransation { +pub struct VMTransaction { pub objects: BTreeMap, pub circuit_holders: Vec, pub program_holders: Vec, @@ -59,7 +59,7 @@ pub struct VMTransation { pub wireless_transmitters: Vec, pub wireless_receivers: Vec, pub id_space: IdSpace, - pub networks: BTreeMap, + pub networks: BTreeMap, vm: Rc, } @@ -94,12 +94,12 @@ impl VM { self: &Rc, template: ObjectTemplate, ) -> Result { - let mut transaction = VMTransation::new(self); + let mut transaction = VMTransaction::new(self); let obj_id = transaction.add_device_from_template(template)?; - let transation_ids = transaction.id_space.in_use_ids(); - self.id_space.borrow_mut().use_new_ids(&transation_ids); + let transaction_ids = transaction.id_space.in_use_ids(); + self.id_space.borrow_mut().use_new_ids(&transaction_ids); self.objects.borrow_mut().extend(transaction.objects); self.wireless_transmitters @@ -120,7 +120,7 @@ impl VM { .borrow() .get(&net_id) .expect(&format!( - "desync between vm and transation networks: {net_id}" + "desync between vm and transaction networks: {net_id}" )) .borrow_mut() .as_mut_network() @@ -883,9 +883,9 @@ impl VM { } } -impl VMTransation { +impl VMTransaction { pub fn new(vm: &Rc) -> Self { - VMTransation { + VMTransaction { objects: BTreeMap::new(), circuit_holders: Vec::new(), program_holders: Vec::new(), @@ -897,7 +897,7 @@ impl VMTransation { .networks .borrow() .keys() - .map(|net_id| (*net_id, VMTransationNetwork::default())) + .map(|net_id| (*net_id, VMTransactionNetwork::default())) .collect(), vm: vm.clone() } @@ -920,7 +920,7 @@ impl VMTransation { self.id_space.next() }; - let obj = template.build(obj_id, self.vm); + let obj = template.build(obj_id, self.vm.clone()); if let Some(storage) = obj.borrow_mut().as_mut_storage() { for (slot_index, occupant_template) in @@ -962,7 +962,7 @@ impl VMTransation { _ => net.objects.push(obj_id), } } else { - return Err(VMError::InvalidNetwork(net_id)); + return Err(VMError::InvalidNetwork(*net_id)); } } } diff --git a/ic10emu/src/vm/object/stationpedia.rs b/ic10emu/src/vm/object/stationpedia.rs index f6b2b2d..6c1a9b9 100644 --- a/ic10emu/src/vm/object/stationpedia.rs +++ b/ic10emu/src/vm/object/stationpedia.rs @@ -9,7 +9,7 @@ use super::ObjectID; pub mod structs; #[allow(unused)] -pub fn object_from_prefab_template(template: &ObjectTemplate, id: ObjectID, vm: &Rc) -> Option { +pub fn object_from_prefab_template(template: &ObjectTemplate, id: ObjectID, vm: Rc) -> Option { let prefab = StationpediaPrefab::from_repr(template.prefab_info().prefab_hash); match prefab { // Some(StationpediaPrefab::ItemIntegratedCircuit10) => { diff --git a/ic10emu/src/vm/object/templates.rs b/ic10emu/src/vm/object/templates.rs index f564207..b1e93df 100644 --- a/ic10emu/src/vm/object/templates.rs +++ b/ic10emu/src/vm/object/templates.rs @@ -73,7 +73,7 @@ impl ObjectTemplate { } } - pub fn build(&self, id: ObjectID, vm: &Rc) -> VMObject { + pub fn build(&self, id: ObjectID, vm: Rc) -> VMObject { if let Some(obj) = stationpedia::object_from_prefab_template(&self, id, vm) { obj } else { @@ -195,7 +195,7 @@ impl ObjectTemplate { } } - fn build_generic(&self, id: ObjectID, vm: &Rc) -> VMObject { + fn build_generic(&self, id: ObjectID, vm: Rc) -> VMObject { use ObjectTemplate::*; match self { Structure(s) => VMObject::new(