updated README and a bunch of other stuff
This commit is contained in:
@@ -105,6 +105,7 @@ pub struct PartMetadata {
|
||||
pub opts: Vec<OptMetadata>,
|
||||
pub methods: Vec<MethodMetadata>,
|
||||
pub effects: Vec<MethodMetadata>,
|
||||
pub applies: Vec<MethodMetadata>,
|
||||
pub threads: Vec<MethodMetadata>,
|
||||
pub natives: Vec<NativeMetadata>,
|
||||
}
|
||||
@@ -120,7 +121,7 @@ pub struct OptMetadata {
|
||||
pub struct MethodMetadata {
|
||||
pub name: String,
|
||||
pub id: MizeId,
|
||||
pub kind: String, // "method", "effect", "thread"
|
||||
pub kind: String, // "method", "effect", "apply", "thread"
|
||||
/// Raw signature string, e.g. `"String -> ()"` or `"Command, Func -> ()"`.
|
||||
pub signature: String,
|
||||
/// Parsed argument type names (left of `->`).
|
||||
@@ -339,20 +340,23 @@ impl Mize {
|
||||
// end of platform specific init code
|
||||
|
||||
// load the parts, as specified in the parts config
|
||||
match self
|
||||
.get_config("parts")
|
||||
{
|
||||
Ok(parts_to_load) => {
|
||||
for part_name in parts_to_load.cbor().as_array().ok_or("config parts was not an array")? {
|
||||
let part_name = part_name.as_text().ok_or("part name was not a string")?;
|
||||
if part_name.trim().is_empty() || self.has_part(part_name)? {
|
||||
continue;
|
||||
}
|
||||
self.load_part(part_name)?;
|
||||
// Prefer `parts` when it is an array; otherwise `parts.load` (so `parts.workspaces` /
|
||||
// `parts.dist.cd` can coexist under a `parts` table in TOML).
|
||||
let parts_to_load = match self.get_config("parts") {
|
||||
Ok(data) if data.cbor().as_array().is_some() => Some(data),
|
||||
_ => self.get_config("parts.load").ok(),
|
||||
};
|
||||
if let Some(parts_to_load) = parts_to_load {
|
||||
for part_name in parts_to_load
|
||||
.cbor()
|
||||
.as_array()
|
||||
.ok_or("config parts/parts.load was not an array")?
|
||||
{
|
||||
let part_name = part_name.as_text().ok_or("part name was not a string")?;
|
||||
if part_name.trim().is_empty() || self.has_part(part_name)? {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Err(_err) => {
|
||||
// no parts to load
|
||||
self.load_part(part_name)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,7 +538,7 @@ impl Mize {
|
||||
|
||||
pub fn load_part(&mut self, name: &str) -> MizeResult<()> {
|
||||
tracing::debug!("loading part: {name}");
|
||||
crate::platform::load_part(self, name, None)
|
||||
crate::platform::load_part(name, None, None)
|
||||
}
|
||||
|
||||
pub fn fetch_part(&mut self, name: &str) -> MizeResult<String> {
|
||||
@@ -542,9 +546,8 @@ impl Mize {
|
||||
crate::platform::fetch_part(self, name)
|
||||
}
|
||||
|
||||
pub fn load_part_at(&mut self, name: &str, path: String) -> MizeResult<()> {
|
||||
// platform specific init code
|
||||
crate::platform::load_part(self, name, Some(path))
|
||||
pub fn load_part_from_path(&mut self, name: &str, path: String) -> MizeResult<()> {
|
||||
crate::platform::load_part(name, Some(path), None)
|
||||
}
|
||||
|
||||
// ===== generate mode accessors =====
|
||||
@@ -600,6 +603,7 @@ impl Mize {
|
||||
};
|
||||
match kind {
|
||||
"effect" => metadata.effects.push(m),
|
||||
"apply" => metadata.applies.push(m),
|
||||
"thread" => metadata.threads.push(m),
|
||||
_ => metadata.methods.push(m),
|
||||
}
|
||||
@@ -1037,9 +1041,7 @@ impl Mize {
|
||||
|
||||
let calling_part = self.clone().cur_eval_part()?;
|
||||
self.clone().set_cur_eval_part(Some(part_id));
|
||||
println!("before call");
|
||||
let res = fun(args);
|
||||
println!("after call");
|
||||
self.clone().set_cur_eval_part(calling_part);
|
||||
let mut fun_values = self.fun_values.lock()?;
|
||||
fun_values.insert(id, fun);
|
||||
|
||||
@@ -48,14 +48,14 @@ fn test_get_module_hash() -> MizeResult<()> {
|
||||
toolchain_version = "rustc 1.78.0 (9b00956e5 2024-04-29)"
|
||||
"#;
|
||||
|
||||
instance.set_blocking("0/config/selector", ItemData::from_toml(&selector_toml)?)?;
|
||||
|
||||
let (hash, selector) = get_part_hash(&mut instance, "String", ItemData::new())?;
|
||||
// Pass selector fields as hash options (merges over defaults).
|
||||
let options = ItemData::from_toml(&selector_toml)?;
|
||||
let (hash, selector) = get_part_hash(&mut instance, "String", options)?;
|
||||
|
||||
println!("hash: {}", hash);
|
||||
println!("selector: {}", selector);
|
||||
|
||||
assert_eq!(hash, "e96edf60216688314efc263c1aa8d6ce".to_owned());
|
||||
assert_eq!(hash, "227b0216f9b7a324a621ff773c5241c9".to_owned());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user