Re: how to invoke Tcl_DupInternalRepProc for testing



On Apr 10, 10:20 am, "Anders Moe" <anders....@xxxxxxxxx> wrote:

I'm making my own types using Tcl_RegisterObjType and all that, which
includes assigning a Tcl_DupInternalRepProc function. Now, for testing
purposes I'd like to provoke Tcl into calling my Tcl_DupInternalRepProc
function, presumably as a result of some copying operation, but I'm not sure
how to do that. Can anyone help me here ?

Since Tcl has a copy-on-write mechanism, a mere "copy" like [set x $y]
is not enough. If you look for calls to the generic Tcl_DuplicateObj()
function (which in turn calls your type-specific dup), you'll see it
pretty hard-coded in the idiom "if (Tcl_IsShared(...)) ...
Tcl_DuplicateObj()" where in-place modification of data is about to
take place (lappend, linsert, lreplace, incr...). This of course is
unlikely to happen outside your type implementation (since only you
can know what in-place mod means for your intrep).

However, there's the debugging function "testobj", with subcommand
"duplicate".
Granted, this is more of an "in vitro" test...

HTH,

-Alex

.



Relevant Pages

  • how to invoke Tcl_DupInternalRepProc for testing
    ... includes assigning a Tcl_DupInternalRepProc function. ... purposes I'd like to provoke Tcl into calling my Tcl_DupInternalRepProc ...
    (comp.lang.tcl)
  • Re: Check on correctness
    ... You should not be calling any method of a parent class in a dialog. ... document class at all. ... reading that I should call GetDocument every time rather than assigning ...
    (microsoft.public.vc.mfc)
  • Re: How do I use a different NIC in Small Business Server 2003?
    ... assigning the IP information that was on the first one, reboot, and running ... the Internet Connection Wizard? ... Calling an illegal alien an "undocumented worker" is like calling a ...
    (microsoft.public.windows.server.sbs)
  • Re: "as" keyword woes
    ... and strong force when dealing with math software, ... discount it in general, just for purposes of this discussion) why is ... You'll gain nothing but confusion by calling them ...
    (comp.lang.python)
  • Re: Outlook 2003 PIA Question
    ... I am trying to run this sample code but keep getting an "Invalid Cast" ... exception when calling oItems.GetFirst and assigning the resulting ...
    (microsoft.public.outlook.interop)