For categories whose layout is multi_uclass, emit: - the base class block (between PROPERTIES / IMPORT / EXPORT tags) - per-subtype UCLASS skeletons appended to the base file (first-run only) - per-subtype blocks (between SUBCLASS_ _PROPERTIES / IMPORT / EXPORT
(
category: str,
cat_rules: Dict[str, Any],
schema: Dict[str, Any],
rules: Dict[str, Any],
public_root: str,
private_root: str,
mjspec: Dict[str, Any] | None = None,
)
| 2406 | with open(source_path, "r", encoding="utf-8") as f: |
| 2407 | c_text = f.read() |
| 2408 | c_text, ok_i = _inject_or_diag( |
| 2409 | c_text, "IMPORT", emitted.imports_cpp, |
| 2410 | host_path=source_path, host_kind="base source", |
| 2411 | block_label=f"category '{category}' import block", |
| 2412 | diag_source="base_inject", |
| 2413 | ) |
| 2414 | # ``xml_passthrough_emission`` routes per-attr export through the |
| 2415 | # XML_PASSTHROUGH block, NOT the EXPORT block — the mjs-side |
| 2416 | # ``Element->field = ...`` writes don't apply (flexcomp). |
| 2417 | # ``disable_mjs_export_emission`` covers categories that have no |
| 2418 | # corresponding mjs struct so the export block can't compile even |
| 2419 | # if injected (inertial — writes through ParentBody->ipos/iquat |
| 2420 | # in a hand-rolled RegisterToSpec). Both flags suppress EXPORT |
| 2421 | # injection AND its missing-marker diagnostic. |
| 2422 | skip_export = ( |
| 2423 | cat_rules.get("xml_passthrough_emission") |
| 2424 | or cat_rules.get("disable_mjs_export_emission") |
| 2425 | ) |
| 2426 | ok_e = False |
| 2427 | if not skip_export: |
| 2428 | c_text, ok_e = _inject_or_diag( |
| 2429 | c_text, "EXPORT", emitted.exports_cpp, |
| 2430 | host_path=source_path, host_kind="base source", |
| 2431 | block_label=f"category '{category}' export block", |
| 2432 | diag_source="base_inject", |
| 2433 | ) |
| 2434 | ok_x = False |
| 2435 | if cat_rules.get("xml_passthrough_emission"): |
| 2436 | xml_body = emit_xml_passthrough_body(common_attrs, rules, element_name=category) |
| 2437 | c_text, ok_x = _inject_or_diag( |
| 2438 | c_text, "XML_PASSTHROUGH", xml_body, |
| 2439 | host_path=source_path, host_kind="base source", |
| 2440 | block_label=f"category '{category}' xml_passthrough block", |
| 2441 | diag_source="base_inject", |
| 2442 | ) |
| 2443 | if ok_i or ok_e or ok_x: |
| 2444 | writes.append(FileWrite(path=source_path, content=c_text)) |
| 2445 | else: |
| 2446 | _diag_add( |
| 2447 | f"[diagnostic] category '{category}' base source '{source_path}' " |
| 2448 | f"does not exist; import + export blocks could not be injected.", |
| 2449 | source="base_inject", |
| 2450 | ) |
| 2451 | |
| 2452 | return writes |
| 2453 | |
| 2454 | |
| 2455 | # --------------------------------------------------------------------------- |
| 2456 | # Pipeline: multi-UCLASS base (site / tendon / equality) |
| 2457 | # --------------------------------------------------------------------------- |
| 2458 | |
| 2459 | def emit_multi_uclass( |
| 2460 | category: str, |
| 2461 | cat_rules: Dict[str, Any], |
| 2462 | schema: Dict[str, Any], |
| 2463 | rules: Dict[str, Any], |
| 2464 | public_root: str, |
| 2465 | private_root: str, |
no test coverage detected