Skip to content

Commit

Permalink
deeper down that darn hole we journey
Browse files Browse the repository at this point in the history
  • Loading branch information
uberFoo committed Nov 29, 2023
1 parent 81db975 commit e4a6aa9
Show file tree
Hide file tree
Showing 71 changed files with 5,907 additions and 1,233 deletions.
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sarzak"
version = "2.8.0"
version = "2.11.0"
edition = "2021"
authors = ["Keith T. Star <[email protected]>"]
categories = ["compilers", "memory-management"]
Expand Down Expand Up @@ -52,13 +52,15 @@ env_logger = "0.10.0"
pretty_env_logger = "0.5.0"

[features]
default = ["lu-dog-vec", "sarzak_single"]
default = ["lu-dog-vec", "sarzak-rwlock"]
lu-dog-vec = []
lu-dog-vec-tracy = []
lu-dog-rwlock-vec = []
lu-dog-ndrwlock-vec = []
lu-dog-rc = []
lu-dog-rwlock = []
lu-dog-async-vec = []
sarzak_single = []
sarzak_rwlock = []
sarzak-single = []
sarzak-rwlock = []
woog-single = []
woog-rwLock = []
25 changes: 24 additions & 1 deletion sarzak.toml
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ is_meta_model = true
is_sarzak = true
persist = true
persist_timestamps = true
uber_store = "Single"
uber_store = "Disabled"
target = "domain"

#
Expand All @@ -323,3 +323,26 @@ persist = true
persist_timestamps = true
uber_store = "StdRwLock"
target = "domain"

#
# Woog Single
#
[modules."v2/woog_single"]
model = "models/woog.json"

[[modules."v2/woog_single".compiler]]
always_process = true
compiler = "grace"
derive = ["Clone", "Debug", "Deserialize", "PartialEq", "Serialize"]
imported_domains = ["crate/v2/sarzak"]
use_paths = ["serde::{Deserialize, Serialize}"]
tracy = false

[modules."v2/woog_single".compiler.target]
optimization_level = "None"
is_meta_model = true
is_sarzak = false
persist = true
persist_timestamps = true
uber_store = "Disabled"
target = "domain"
13 changes: 10 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");

pub use v2::drawing;
pub use v2::merlin;
pub use v2::woog;

cfg_if::cfg_if! {
if #[cfg(feature = "sarzak_rwlock")] {
if #[cfg(feature = "sarzak-rwlock")] {
pub use v2::sarzak;
} else if #[cfg(feature = "sarzak_single")] {
} else if #[cfg(feature = "sarzak-single")] {
pub use v2::sarzak_single as sarzak;
}
}

cfg_if::cfg_if! {
if #[cfg(feature = "woog-rwlock")] {
pub use v2::woog;
} else if #[cfg(feature = "woog-single")] {
pub use v2::woog_single as woog;
}
}

cfg_if::cfg_if! {
if #[cfg(feature = "lu-dog-rc")] {
pub use v2::lu_dog;
Expand Down
1 change: 1 addition & 0 deletions src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ pub mod merlin;
pub mod sarzak;
pub mod sarzak_single;
pub mod woog;
pub mod woog_single;
8 changes: 7 additions & 1 deletion src/v2/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ use uuid::Uuid;
use crate::v1::domain::Domain as DomainV1;
use crate::v2::{
drawing::store::ObjectStore as DrawingStore, merlin::store::ObjectStore as MerlinStore,
sarzak::store::ObjectStore as SarzakStore,
};

#[cfg(feature = "sarzak_multi")]
use crate::v2::sarzak::store::ObjectStore as SarzakStore;

#[cfg(feature = "sarzak_single")]
use crate::v2::sarzak_single::store::ObjectStore as SarzakStore;

use crate::VERSION;

#[derive(Clone, Debug, Deserialize, Serialize)]
Expand Down
11 changes: 7 additions & 4 deletions src/v2/drawing/types/binary_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ use uuid::Uuid;

use crate::v2::drawing::types::anchor::Anchor;
use crate::v2::drawing::types::relationship_ui::RelationshipUi;
#[cfg(feature = "sarzak_multi")]
use crate::v2::sarzak::types::binary::Binary;
#[cfg(feature = "sarzak_single")]
use crate::v2::sarzak_single::types::binary::Binary;
use serde::{Deserialize, Serialize};

use crate::v2::drawing::store::ObjectStore as DrawingStore;
#[cfg(feature = "sarzak_multi")]
use crate::v2::sarzak::store::ObjectStore as SarzakStore;
#[cfg(feature = "sarzak_single")]
use crate::v2::sarzak_single::store::ObjectStore as SarzakStore;
// {"magic":"","directive":{"End":{"directive":"ignore-orig"}}}

// {"magic":"","directive":{"Start":{"directive":"ignore-orig","tag":"binary_ui-struct-documentation"}}}
Expand Down Expand Up @@ -57,10 +63,7 @@ impl BinaryUi {
// {"magic":"","directive":{"Start":{"directive":"ignore-orig","tag":"binary_ui-struct-impl-nav-forward-to-to"}}}
// {"magic":"","directive":{"Start":{"directive":"ignore-orig","tag":"binary_ui-struct-impl-nav-forward-to-binary_id"}}}
/// Navigate to [`Binary`] across R12(1-*)
pub fn r12_binary<'a>(
&'a self,
store: &'a SarzakStore,
) -> Vec<std::sync::Arc<std::sync::RwLock<Binary>>> {
pub fn r12_binary<'a>(&'a self, store: &'a SarzakStore) -> Vec<&Binary> {
vec![store.exhume_binary(&self.binary_id).unwrap()]
}
// {"magic":"","directive":{"End":{"directive":"ignore-orig"}}}
Expand Down
156 changes: 154 additions & 2 deletions src/v2/merlin/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ use crate::v2::merlin::ObjectStore;
use crate::v2::drawing::types::{Edge as FromEdge, ObjectUi, Point as FromPoint};
use crate::v2::drawing::ObjectStore as DrawingStore;

use crate::v2::sarzak::types::Cardinality;
use crate::v2::sarzak::ObjectStore as SarzakStore;
#[cfg(feature = "sarzak_multi")]
use crate::v2::sarzak::{types::Cardinality, ObjectStore as SarzakStore};
#[cfg(feature = "sarzak_single")]
use crate::v2::sarzak_single::{types::Cardinality, ObjectStore as SarzakStore};

/// Convert a v1 Drawing format into a v2 Drawing format
///
Expand All @@ -45,6 +47,7 @@ use crate::v2::sarzak::ObjectStore as SarzakStore;
/// Well darn. There isn't a good way to get an object from an anchor, nor an
/// anchor from an object -- not in the drawing domain anyway.
///
#[cfg(feature = "sarzak_mulit")]
impl From<(&DrawingStore, &SarzakStore)> for ObjectStore {
fn from((drawing, sarzak): (&DrawingStore, &SarzakStore)) -> Self {
let mut merlin = ObjectStore::new();
Expand Down Expand Up @@ -192,6 +195,155 @@ impl From<(&DrawingStore, &SarzakStore)> for ObjectStore {
}
}

#[cfg(feature = "sarzak_single")]
impl From<(&DrawingStore, &SarzakStore)> for ObjectStore {
fn from((drawing, sarzak): (&DrawingStore, &SarzakStore)) -> Self {
let mut merlin = ObjectStore::new();

merlin.inter_edge(Arc::new(RwLock::new(Edge::Bottom(BOTTOM))));
merlin.inter_edge(Arc::new(RwLock::new(Edge::Left(LEFT))));
merlin.inter_edge(Arc::new(RwLock::new(Edge::Right(RIGHT))));
merlin.inter_edge(Arc::new(RwLock::new(Edge::Top(TOP))));

for oui in drawing.iter_object_ui() {
let instance = Arc::new(RwLock::new(XBox::from((&*oui.read().unwrap(), drawing))));
merlin.inter_x_box(instance);
}

for bui in drawing.iter_binary_ui() {
let binary = &bui.read().unwrap();
let binary = binary.r12_binary(sarzak)[0];
let rel = &binary.r4_relationship(sarzak)[0];

let line = Line::new(&rel, &mut merlin);
let line_seg = LineSegment::new(&line, &mut merlin);

// Default to putting the relationship at the midpoint of the line,
let bisection = Bisection::new(0.5, &line_seg, &mut merlin);
let _name = RelationshipName::new(
format!("R{}", binary.number),
0,
0,
&line,
&bisection,
&mut merlin,
);

let from_anchor = &bui.read().unwrap().r7_anchor(drawing)[0];

// Our relationships are jacked up, so we have to do the dumb thing.
// Not that relationship navigation is any better, depending on the
// direction.
let referrer = &binary.r6_referrer(sarzak)[0];
let from_obj = &referrer.r17_object(sarzak)[0];
let from_obj_ui = drawing
.iter_object_ui()
.find(|oui| oui.read().unwrap().object_id == from_obj.id)
.unwrap();

// Get what we need to build the offset to which the line connects.
let point = &from_anchor.read().unwrap().r4_point(drawing)[0];
let edge = &from_anchor.read().unwrap().r3_edge(drawing)[0];
let (x, y) = get_anchor_offset(&point, &edge);

// Sort out how far along the edge the arrow should be drawn.
let origin = &from_obj_ui.read().unwrap().r13_point(drawing)[0];
let offset = get_anchor_line_offset(&edge, &point, &from_obj_ui, &origin);

// Sort out the glyph.
let card = &referrer.r9_cardinality(sarzak)[0];
let glyph = match *card {
Cardinality::One(_) => Glyph::new_one(&line, &mut merlin),
Cardinality::Many(_) => Glyph::new_many(&line, &mut merlin),
};

// Get the box.
let x_box = merlin
.exhume_x_box(&from_obj_ui.read().unwrap().id)
.unwrap()
.clone();

// Create the anchor.
let from_anchor = Anchor::new(
offset,
x,
y,
&Arc::new(RwLock::new(XyzzyEdge(&edge, &merlin).into())),
&glyph,
&x_box,
&line,
&mut merlin,
);

// Create the from point
let point = Point::new_anchor(
point.read().unwrap().x,
point.read().unwrap().y,
&from_anchor,
&mut merlin,
);

// Create the "line segment point"
LineSegmentPoint::new(&line_seg, &point, &mut merlin);

let to_anchor = &bui.read().unwrap().r8_anchor(drawing)[0];
let referent = &binary.r5_referent(sarzak)[0];
let from_obj = &referent.r16_object(sarzak)[0];
let from_obj_ui = drawing
.iter_object_ui()
.find(|oui| oui.read().unwrap().object_id == from_obj.id)
.unwrap();

// Get what we need to build the offset to which the line connects.
let point = &to_anchor.read().unwrap().r4_point(drawing)[0];
let edge = &to_anchor.read().unwrap().r3_edge(drawing)[0];
let (x, y) = get_anchor_offset(&point, &edge);

// Sort out how far along the edge the arrow should be drawn.
let origin = &from_obj_ui.read().unwrap().r13_point(drawing)[0];
let offset = get_anchor_line_offset(&edge, &point, &from_obj_ui, &origin);

// Sort out the glyph.
let card = &referent.r8_cardinality(sarzak)[0];
let glyph = match *card {
Cardinality::One(_) => Glyph::new_one(&line, &mut merlin),
Cardinality::Many(_) => Glyph::new_many(&line, &mut merlin),
};

// Get the box.
let x_box = merlin
.exhume_x_box(&from_obj_ui.read().unwrap().id)
.unwrap()
.clone();

// Create the anchor.
let to_anchor = Anchor::new(
offset,
x,
y,
&Arc::new(RwLock::new(XyzzyEdge(&edge, &merlin).into())),
&glyph,
&x_box,
&line,
&mut merlin,
);

// Create the to point
let point = Point::new_anchor(
point.read().unwrap().x,
point.read().unwrap().y,
&to_anchor,
&mut merlin,
);

// Create the "line segment point"
LineSegmentPoint::new(&line_seg, &point, &mut merlin);
}

merlin
}
}

fn get_anchor_offset(point: &Arc<RwLock<FromPoint>>, edge: &Arc<RwLock<FromEdge>>) -> (i64, i64) {
let (x, y) = (point.read().unwrap().x, point.read().unwrap().y);

Expand Down
9 changes: 3 additions & 6 deletions src/v2/merlin/types/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use crate::v2::merlin::types::glyph::Glyph;
use crate::v2::merlin::types::line_segment::LineSegment;
use crate::v2::merlin::types::relationship_name::RelationshipName;
use crate::v2::merlin::types::relationship_phrase::RelationshipPhrase;
use crate::v2::sarzak::types::relationship::Relationship;
use crate::v2::sarzak_single::types::relationship::Relationship;
use serde::{Deserialize, Serialize};

use crate::v2::merlin::store::ObjectStore as MerlinStore;
use crate::v2::sarzak::store::ObjectStore as SarzakStore;
use crate::v2::sarzak_single::store::ObjectStore as SarzakStore;
// {"magic":"","directive":{"End":{"directive":"ignore-orig"}}}

// {"magic":"","directive":{"Start":{"directive":"ignore-orig","tag":"line-struct-documentation"}}}
Expand Down Expand Up @@ -50,10 +50,7 @@ impl Line {
// {"magic":"","directive":{"End":{"directive":"ignore-orig"}}}
// {"magic":"","directive":{"Start":{"directive":"ignore-orig","tag":"line-struct-impl-nav-forward-to-relationship"}}}
/// Navigate to [`Relationship`] across R2(1-*)
pub fn r2_relationship<'a>(
&'a self,
store: &'a SarzakStore,
) -> Vec<std::sync::Arc<std::sync::RwLock<Relationship>>> {
pub fn r2_relationship<'a>(&'a self, store: &'a SarzakStore) -> Vec<&Relationship> {
span!("r2_relationship");
vec![store.exhume_relationship(&self.relationship).unwrap()]
}
Expand Down
Loading

0 comments on commit e4a6aa9

Please sign in to comment.