forked from 1b-agent/opencadstudio-upstream
Complete MultiLeader host model coverage
Extends the adapter generator (Color, LineWeight, mixed unit/payload enums, fixed float arrays, bitflags-2 newtypes, keep_types override) and maps MultiLeader with a merge-style context patch, host validation and reference checks. staged_python_multileader_lifecycle_over_real_ipc passes the full gate including DWG and DXF reopen. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
22f9c20fe8
commit
b3f5388208
14 files changed
+523
-31
No files matched your search
@@ -3188,6 +3188,18 @@ mod ocs {
|
||||
})
|
||||
}
|
||||
|
||||
fn py_to_f64_array<const N: usize>(value: PyObjectRef, vm: &VirtualMachine) -> PyResult<[f64; N]> {
|
||||
let items: Vec<PyObjectRef> = value.try_into_value(vm)?;
|
||||
if items.len() != N {
|
||||
return Err(vm.new_value_error(format!("expected {N} numbers, got {}", items.len())));
|
||||
}
|
||||
let mut out = [0.0; N];
|
||||
for (slot, item) in out.iter_mut().zip(items) {
|
||||
*slot = py_number_to_f64(item, vm)?;
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Accept a Python int or float; `try_into_value::<f64>` rejects ints.
|
||||
fn py_number_to_f64(value: PyObjectRef, vm: &VirtualMachine) -> PyResult<f64> {
|
||||
Ok(value.try_float(vm)?.to_f64())
|
||||
@@ -3249,6 +3261,7 @@ mod ocs {
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/entity_crud.rs"));
|
||||
include!("dimension_model.rs.inc");
|
||||
include!("patch_helpers.rs.inc");
|
||||
|
||||
// ════════════════════════════════════════════════════════════════════
|
||||
// Phase 1 — wiring the generic conversion functions above into `ocs`.
|
||||
@@ -4743,7 +4756,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
assert_eq!(emitted.len(), 25);
|
||||
assert_eq!(emitted.len(), 26);
|
||||
}
|
||||
|
||||
#[cfg(feature = "experimental-host-model")]
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// Merge helpers for nested structs that scripts edit as a partial patch.
|
||||
|
||||
/// Apply `patch` (a dict of context fields) onto `existing`, so a script can
|
||||
/// change one context field without resetting the rest. Unknown keys error.
|
||||
fn merge_multileader_context(
|
||||
existing: &acadrust::entities::MultiLeaderAnnotContext,
|
||||
patch: PyObjectRef,
|
||||
vm: &VirtualMachine,
|
||||
) -> PyResult<acadrust::entities::MultiLeaderAnnotContext> {
|
||||
let patch = patch.try_into_value::<rustpython_vm::builtins::PyDictRef>(vm)?;
|
||||
let merged = multi_leader_annot_context_to_dict(vm, existing)?
|
||||
.try_into_value::<rustpython_vm::builtins::PyDictRef>(vm)?;
|
||||
for key in patch.keys_vec() {
|
||||
let name = key.clone().try_into_value::<String>(vm)?;
|
||||
if merged.get_item_opt(name.as_str(), vm)?.is_none() {
|
||||
return Err(vm.new_value_error(format!(
|
||||
"ocs: MultiLeader.context property {name:?} is outside the editable schema"
|
||||
)));
|
||||
}
|
||||
merged.set_item(name.as_str(), patch.get_item(name.as_str(), vm)?, vm)?;
|
||||
}
|
||||
dict_to_multi_leader_annot_context(merged.into(), vm)
|
||||
}
|
||||
Reference in new issue
Block a user