diff --git a/crates/fj-core/src/objects/mod.rs b/crates/fj-core/src/objects/mod.rs index a34ee7d7b..9878df6b7 100644 --- a/crates/fj-core/src/objects/mod.rs +++ b/crates/fj-core/src/objects/mod.rs @@ -59,7 +59,7 @@ pub use self::{ surface::Surface, vertex::Vertex, }, - object::{Bare, BehindHandle, Form, Object, WithHandle}, + object::{AnyObject, Bare, BehindHandle, Form, WithHandle}, object_set::ObjectSet, stores::{Objects, Surfaces}, }; diff --git a/crates/fj-core/src/objects/object.rs b/crates/fj-core/src/objects/object.rs index c303532c9..e290bf9b5 100644 --- a/crates/fj-core/src/objects/object.rs +++ b/crates/fj-core/src/objects/object.rs @@ -7,22 +7,22 @@ use crate::{ validate::{Validate, ValidationConfig, ValidationError}, }; -macro_rules! object { +macro_rules! any_object { ($($ty:ident, $name:expr, $store:ident;)*) => { - /// An object + /// An enum that can hold object /// /// This enum is generic over the form that the object takes. An - /// `Object` contains bare objects, like `Curve`. An - /// `Object` contains handles, like `Handle`. + /// `AnyObject` contains bare objects, like `Curve`. An + /// `AnyObject` contains handles, like `Handle`. #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] - pub enum Object { + pub enum AnyObject { $( #[doc = concat!("A ", $name)] $ty(F::Form<$ty>), )* } - impl Object { + impl AnyObject { /// Access the ID of the object pub fn id(&self) -> ObjectId { match self { @@ -51,9 +51,11 @@ macro_rules! object { } } - impl Object { + impl AnyObject { /// Insert the object into its respective store - pub fn insert(self, objects: &mut Objects) -> Object { + pub fn insert(self, objects: &mut Objects) -> + AnyObject + { match self { $( Self::$ty((handle, object)) => { @@ -67,30 +69,30 @@ macro_rules! object { } } - impl From> for Object { - fn from(object: Object) -> Self { + impl From> for AnyObject { + fn from(object: AnyObject) -> Self { match object { $( - Object::$ty((handle, _)) => Self::$ty(handle.into()), + AnyObject::$ty((handle, _)) => Self::$ty(handle.into()), )* } } } $( - impl From<$ty> for Object { + impl From<$ty> for AnyObject { fn from(object: $ty) -> Self { Self::$ty(object) } } - impl From> for Object { + impl From> for AnyObject { fn from(object: Handle<$ty>) -> Self { Self::$ty(object.into()) } } - impl From<(Handle<$ty>, $ty)> for Object { + impl From<(Handle<$ty>, $ty)> for AnyObject { fn from((handle, object): (Handle<$ty>, $ty)) -> Self { Self::$ty((handle.into(), object)) } @@ -99,7 +101,7 @@ macro_rules! object { }; } -object!( +any_object!( Curve, "curve", curves; Cycle, "cycle", cycles; Face, "face", faces; diff --git a/crates/fj-core/src/services/mod.rs b/crates/fj-core/src/services/mod.rs index 0bdf554b9..8cab4b943 100644 --- a/crates/fj-core/src/services/mod.rs +++ b/crates/fj-core/src/services/mod.rs @@ -7,7 +7,7 @@ mod service; mod validation; use crate::{ - objects::{Object, Objects, WithHandle}, + objects::{AnyObject, Objects, WithHandle}, validate::{ValidationConfig, ValidationErrors}, }; @@ -54,7 +54,7 @@ impl Services { } /// Insert an object into the stores - pub fn insert_object(&mut self, object: Object) { + pub fn insert_object(&mut self, object: AnyObject) { let mut object_events = Vec::new(); self.objects .execute(Operation::InsertObject { object }, &mut object_events); diff --git a/crates/fj-core/src/services/objects.rs b/crates/fj-core/src/services/objects.rs index d7b387fed..924444ad5 100644 --- a/crates/fj-core/src/services/objects.rs +++ b/crates/fj-core/src/services/objects.rs @@ -1,4 +1,4 @@ -use crate::objects::{Object, Objects, WithHandle}; +use crate::objects::{AnyObject, Objects, WithHandle}; use super::State; @@ -25,7 +25,7 @@ pub enum Operation { /// upon. InsertObject { /// The object to insert - object: Object, + object: AnyObject, }, } @@ -33,5 +33,5 @@ pub enum Operation { #[derive(Clone, Debug)] pub struct InsertObject { /// The object to insert - pub object: Object, + pub object: AnyObject, } diff --git a/crates/fj-core/src/services/validation.rs b/crates/fj-core/src/services/validation.rs index a8cc20e58..b3860e25f 100644 --- a/crates/fj-core/src/services/validation.rs +++ b/crates/fj-core/src/services/validation.rs @@ -1,7 +1,7 @@ use std::{collections::BTreeMap, error::Error, thread}; use crate::{ - objects::{BehindHandle, Object}, + objects::{AnyObject, BehindHandle}, storage::ObjectId, validate::{ValidationConfig, ValidationError}, }; @@ -97,7 +97,7 @@ pub enum ValidationCommand { /// Validate the provided object ValidateObject { /// The object to validate - object: Object, + object: AnyObject, }, } @@ -107,7 +107,7 @@ pub enum ValidationEvent { /// Validation of an object failed ValidationFailed { /// The object for which validation failed - object: Object, + object: AnyObject, /// The validation error err: ValidationError,