link) that is deliberately NOT marked by the GC, so the referent can be...">link) that is deliberately NOT marked by the GC, so the referent can be...">link) that is deliberately NOT marked by the GC, so the referent can be...">link) that is deliberately NOT marked by the GC, so the referent can be...">
C implementation of WeakLink. Holds a single non-owning pointer (DATA(self)->link) that is deliberately NOT marked by the GC, so the referent can be collected even while a WeakLink names it. The mechanism for notification is the IoObject listener list plus the tag's notificationFunc: on setLink, the WeakLink registers as a listener on the target via IoObject_addListener_; when the target is freed, the collector fires IoWeakLink_notification which clears the pointer back to NULL. There is no markFunc registered — that is the whole point. The commented-out writeToStream/readFromStream pair persists WeakLinks by PID (IoObject_pid) so they can be rehydrated through IoState_objectWithPid_.
Registered as the tag's freeFunc. Unregisters from the target's listener list first, then releases the IoWeakLinkData payload.
Convenience constructor: look up the WeakLink proto and clone it.
Builds the WeakLink tag. Installs a notificationFunc — unique to WeakLink among the core protos — which fires when a listened-to target is collected. Deliberately registers no markFunc so the link target is never retained by this object.
Creates a WeakLink whose target is v. Note this helper stashes v directly without registering as a listener — most callers should use IoWeakLink_rawSetLink instead so collection notification fires.
Registered as the tag's notificationFunc. The GC calls this when the target object of this WeakLink is collected; we null out the link pointer so the next `link` query returns nil. The commented- out IoMessage_locals_performOn_ would fire an Io-level callback, left in place as a stub for future support.
Creates the WeakLink proto: allocates an empty IoWeakLinkData with link set to NULL, attaches the tag, registers the proto, and installs the Io-visible method table (setLink, link).
Registered as the tag's cloneFunc. Fresh clones start with a null link rather than inheriting the proto's target — a WeakLink chained through cloning would otherwise register multiple listeners on one target and break the unregister-on-free invariant.
Internal setter used by setLink. Unregisters from the previous target first, then either clears the link (if v is nil) or stores v and registers for collection notification. No IOREF — this is a weak reference by design, which is the whole reason this object exists.
Removes this WeakLink from the current target's listener list so the collector stops notifying it. Used before rebinding the link and on free — without this, a freed WeakLink could still be notified and dereference its own freed data pointer.
Restores a serialized WeakLink by reading a tagged PID and resolving it against the current IoState's object table. Not currently registered on the tag (see commented-out setup in IoWeakLink_newTag) but kept for potential future persistence layers.