Table of Contents

Interface ISessionObjects

Namespace
RDCore.SDK.Runtime.Abstract.Execution
Assembly
RDCore.SDK.dll

The object lifetime manager of an execution session: creates instances and tracks their roots and reference counts.

public interface ISessionObjects

Properties

TemporaryCount

The number of temporaries held now: what PopTemporary() lets go of down to, when the statement that made them is over.

int TemporaryCount { get; }

Property Value

int

Remarks

A temporary is the value of an expression that is no variable's - an object New made, what a call returned - held for as long as the statement that evaluates the expression runs (MS-VBAL §5.3.1.10: an object is destroyed when nothing references it, and a value the statement is still using references it). The temporaries of the statements being executed are a stack: a call's own statements make theirs above the caller's, and let go of them before the call returns.

Methods

AddRef(VBRuntimeObjectId, IBindingHandle)

Records a new reference (root) to an instance.

void AddRef(VBRuntimeObjectId instance, IBindingHandle handle)

Parameters

instance VBRuntimeObjectId
handle IBindingHandle

AttachEventHandlers(VBRuntimeObjectId, VBRuntimeObjectId, Symbol)

Records that variable, a WithEvents variable of subscriber, now holds source, so that the procedures of the subscriber's class that handle events of the variable handle those of the source (MS-VBAL §5.4.3.9).

void AttachEventHandlers(VBRuntimeObjectId source, VBRuntimeObjectId subscriber, Symbol variable)

Parameters

source VBRuntimeObjectId
subscriber VBRuntimeObjectId
variable Symbol

Remarks

A source's handlers are in the order their variables were assigned, so one that is already attached is moved to the end of that order: it is the last to handle an event raised from now on (MS-VBAL §5.4.2.20).

Clear()

Forgets every object, with the references that were held to it, whatever their count: the objects of a program that Ended.

void Clear()

CreateObject()

Creates a new object instance and returns its identity.

VBRuntimeObjectId CreateObject()

Returns

VBRuntimeObjectId

DetachEventHandlers(VBRuntimeObjectId, VBRuntimeObjectId, Symbol)

Records that variable of subscriber no longer holds source: its handlers no longer handle the source's events.

void DetachEventHandlers(VBRuntimeObjectId source, VBRuntimeObjectId subscriber, Symbol variable)

Parameters

source VBRuntimeObjectId
subscriber VBRuntimeObjectId
variable Symbol

DetachSubscriber(VBRuntimeObjectId)

Detaches every handler of subscriber, from every source: it is being destroyed, and nothing of it can handle an event any more.

void DetachSubscriber(VBRuntimeObjectId subscriber)

Parameters

subscriber VBRuntimeObjectId

EventSubscribers(VBRuntimeObjectId)

The subscriptions that handle the events of source, in the order they were attached.

IReadOnlyList<EventSubscription> EventSubscribers(VBRuntimeObjectId source)

Parameters

source VBRuntimeObjectId

Returns

IReadOnlyList<EventSubscription>

IsHeldBy(VBRuntimeObjectId, IBindingHandle)

Whether handle is one of the roots currently holding a reference to an instance.

bool IsHeldBy(VBRuntimeObjectId instance, IBindingHandle handle)

Parameters

instance VBRuntimeObjectId
handle IBindingHandle

Returns

bool

NotifyDestroying(VBRuntimeObjectId)

Calls every handler OnDestroying(Action<VBRuntimeObjectId>) registered with instance, which is being destroyed.

void NotifyDestroying(VBRuntimeObjectId instance)

Parameters

instance VBRuntimeObjectId

OnDestroying(Action<VBRuntimeObjectId>)

Registers release to be called with each object that is destroyed, after its Terminate ran and before it is removed (MS-VBAL §5.3.1.10).

void OnDestroying(Action<VBRuntimeObjectId> release)

Parameters

release Action<VBRuntimeObjectId>

Lets go of what the object it is given holds.

Remarks

For a library class whose objects hold state that is not the variables of a class module, and that holds objects - the members of a Collection: what an object holds is let go of when it is destroyed, which can be what destroys those in turn. The variables of a class module's object are let go of by the session itself. A handler is called for every object destroyed, and ignores one that is not its own.

PopTemporary()

Takes the most recent temporary off the stack, for its references to be let go of.

IBindingHandle? PopTemporary()

Returns

IBindingHandle

Its cell, or null when there is none.

PushTemporary(IBindingHandle)

Holds cell as a temporary of the statement being executed: the cell holds the value, and is what the objects in it are held by until it is popped.

void PushTemporary(IBindingHandle cell)

Parameters

cell IBindingHandle

RefCount(VBRuntimeObjectId)

The number of references currently held to an instance; 0 for one that is not live.

int RefCount(VBRuntimeObjectId instance)

Parameters

instance VBRuntimeObjectId

Returns

int

RemoveRef(VBRuntimeObjectId, IBindingHandle)

Drops a reference to an instance and returns the remaining reference count.

int RemoveRef(VBRuntimeObjectId instance, IBindingHandle handle)

Parameters

instance VBRuntimeObjectId
handle IBindingHandle

Returns

int

TryBeginTerminate(VBRuntimeObjectId)

Records that Terminate is about to run for an instance (MS-VBAL §5.3.1.10: at most once during an object's lifetime, however often it becomes a candidate for destruction).

bool TryBeginTerminate(VBRuntimeObjectId instance)

Parameters

instance VBRuntimeObjectId

Returns

bool

true the first time it is asked of a live instance; otherwise false.

TryRemoveObject(VBRuntimeObjectId)

Removes an instance whose reference count has reached zero.

bool TryRemoveObject(VBRuntimeObjectId instance)

Parameters

instance VBRuntimeObjectId

Returns

bool