make semantics work other than field diffs

This commit is contained in:
2025-10-12 23:16:00 +05:30
parent 80396c78a6
commit 785182787c
3 changed files with 61 additions and 30 deletions

View File

@ -9,6 +9,7 @@ class Field:
name: str
type: type
ctype_complex_type: Optional[Any]
containing_type: Optional[Any]
type_size: Optional[int]
value: Any = None
@ -44,6 +45,12 @@ class Field:
if mark_ready:
self.ready = True
def set_ctype_complex_type(self, ctype_complex_type: Any, mark_ready: bool = True) -> None:
"""Set the ctype_complex_type of this field and optionally mark it as ready."""
self.ctype_complex_type = ctype_complex_type
if mark_ready:
self.ready = True
@dataclass
class DependencyNode:
@ -100,6 +107,7 @@ class DependencyNode:
initial_value: Any = None,
containing_type: Optional[Any] = None,
type_size: Optional[int] = None,
ctype_complex_type: Optional[int] = None,
ready: bool = False,
) -> None:
"""Add a field to the node with an optional initial value and readiness state."""
@ -110,6 +118,7 @@ class DependencyNode:
ready=ready,
containing_type=containing_type,
type_size=type_size,
ctype_complex_type=ctype_complex_type
)
# Invalidate readiness cache
self._ready_cache = None
@ -158,6 +167,17 @@ class DependencyNode:
# Invalidate readiness cache
self._ready_cache = None
def set_field_ctype_complex_type(
self, name: str, ctype_complex_type: Any, mark_ready: bool = True
) -> None:
"""Set a field's ctype_complex_type and optionally mark it as ready."""
if name not in self.fields:
raise KeyError(f"Field '{name}' does not exist in node '{self.name}'")
self.fields[name].set_ctype_complex_type(ctype_complex_type, mark_ready)
# Invalidate readiness cache
self._ready_cache = None
def set_field_ready(self, name: str, is_ready: bool = True) -> None:
"""Mark a field as ready or not ready."""
if name not in self.fields: