• =?UTF-8?Q?Tcl_TIP_=E2=86=92_auto_call_destructor_of_embedded_class?=

    From aotto1968@21:1/5 to All on Sat May 25 23:58:21 2024
    Hi, this is an "interface" class used as callback in tcl-oo
    → In the class are TWO other tcl-oo objects embedded (valBFL and colBFL)
    → the both objects are created with "create" *in* the namespace of the
    LibSq3LiteRpcServerExecIF→instance because the name was part of the
    "variable" declaration.
    → TRICK: if the instance (myInst) is deleted (destroy) than automatic the both
    MkBufferListC→objects are delete too because the valBFL are created *in*
    the namespace of the LibSq3LiteRpcServerExecIF→instance.
    → TRICK: no additional cleanup (destructor) is required.

    oo::class create LibSq3LiteRpcServerExecIF {
    variable rpc bus tok valBFL colBFL

    constructor {myRpc myBus myTok} {
    set rpc $myRpc
    set bus $myBus
    set tok $myTok
    MkBufferListC create valBFL
    MkBufferListC create colBFL
    }

    method callback {sq3lite valL colL} {
    valBFL Reset
    valBFL AppendLA {*}$valL
    colBFL Reset
    colBFL AppendLA {*}$colL
    if {$bus eq "MK_NULL"} {
    $rpc Send "W" "$tok:LL" valBFL colBFL
    } else {
    $bus Reset
    $bus WriteBFL valBFL
    $bus WriteBFL colBFL
    }
    }
    }

    LibSq3LiteRpcServerExecIF create myInst
    myInst destroy ...



    mfg ao

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)