junrushao opened a new pull request, #446:
URL: https://github.com/apache/tvm-ffi/pull/446

   `DefaultValue` stores a single static default shared across all instances 
created via reflection.  For mutable defaults (Array, Map, etc.) this causes 
aliasing: every object receives the same underlying container.  
`DefaultFactory` fixes this by storing a callable `() -> Any` that is invoked 
each time a default is needed, producing a fresh value per instance—mirroring 
Python dataclass `default_factory`.
   
   Concrete changes:
   
   - Rename `TVMFFIFieldInfo::default_value` → `default_value_or_factory` to 
reflect that the slot now holds either a value or a factory.
   - Add `kTVMFFIFieldFlagBitMaskDefaultIsFactory` (1 << 5) to 
`TVMFFIFieldFlagBitMask`.
   - Add `reflection::DefaultFactory` trait (registry.h), symmetric to 
`DefaultValue`.
   - Add `reflection::SetFieldToDefault` helper (accessor.h) that resolves the 
default—calling the factory when the flag is set—so the three consumption sites 
(creator.h, reflection_extra.cc, serialization.cc) share one implementation.
   - Propagate the rename through Rust (`c_api.rs`) and Cython (`base.pxi`) 
bindings.
   - Add `TestObjWithFactory` + three tests exercising flag inspection, 
per-instance freshness, and explicit-value bypass.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to