Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 41a65bad6f522608a992cda244b9f0a1d62368ae
Ticket: 2997642fffffffffffffffffffffffffffffffff
many type casts needed when using Tcl_Pkg* API
User & Date: jenglish on 2010-08-31 01:35:03
Changes

  1. icomment:
    Remembering that "ClientData" == "void *":
    
    Previous signature had:
       Tcl_PkgProvideEx(...., void *clientData);
       Tcl_PkgRequireEx(..., void **clientData_rtn);
    
    IOW: put pointer-to-T in, get void * back out,  which the caller must convert back to a pointer-to-T.
    
    (Note that the PkgRequire() call did not require an explicit cast even under the old signature  when using the usual idiom, and the PkgProvide call only needed a cast-away-from-const cast if the clientData is a pointer-to-const-T.)
    
    New signature has:
       Tcl_PkgProvideEx(...., const void *clientData);
       Tcl_PkgRequireEx(..., void *rtn);
    
    IOW: put a pointer-to-T or pointer-to-const-T in, get *anything* back out.  This pokes an even bigger hole in the type system (including internally removing 'const' qualifiers), but since 'void *' is already involved that's probably not a big deal; we're already relying on the caller to get things right, the compiler won't help here.
    
    As long as it does not cause a regression of #1091431, it's probably OK.  (Basically: make sure that if you're changing the usual idiom 
    
       void *pkgData = NULL;
       if (Tcl_PkgRequireEx(...., &pkgData) != NULL && pkgData != NULL)
           fooStubsPtr = pkgData;
    
    to 
    
       Tcl_PkgRequireEx(..., &fooStubsPtr);
    
    make sure that 'fooStubsPtr' doesn't get stomped in cases where the PkgRequire() fails.
    
    (It doesn't look like that should happen, but I can't really tell; the PkgRequire() codepath has gotten a lot more convoluted since last I looked at it.)
    
    
  2. login: "jenglish"
  3. mimetype: "text/plain"
  4. username: "jenglish"