Itcl - the [incr Tcl] extension

Check-in [65fc8ad29b]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:remove a few MODULE_SCOPE functions which are not used anymore. refCount consistancy
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:65fc8ad29b3e7adb108935e8dce79e2c72efb745de81cd321a5ad44abe574a1e
User & Date: jan.nijtmans 2019-03-08 20:22:22
Context
2019-03-08
20:39
Eliminate compiler warnings, when compiling against Tcl 9 headers. check-in: 120bdb3153 user: jan.nijtmans tags: trunk
20:22
remove a few MODULE_SCOPE functions which are not used anymore. refCount consistancy check-in: 65fc8ad29b user: jan.nijtmans tags: trunk
2019-02-10
16:56
Re-generate configure script. Change various function calls to the *2() or *Ex() versions. This improves possible future compatibility with Tcl 9. For now, it doesn't really matter. check-in: ac9d8318e1 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/itclClass.c.

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

void
ItclReleaseClass(
    ClientData clientData)
{
    ItclClass *iclsPtr = (ItclClass *)clientData;

    if (--iclsPtr->refCount == 0) {
	ItclFreeClass((char *) clientData);
    }
}
 
/*
 * ------------------------------------------------------------------------
 *  Itcl_DeleteMemberFunc()







|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

void
ItclReleaseClass(
    ClientData clientData)
{
    ItclClass *iclsPtr = (ItclClass *)clientData;

    if (iclsPtr->refCount-- <= 1) {
	ItclFreeClass((char *) clientData);
    }
}
 
/*
 * ------------------------------------------------------------------------
 *  Itcl_DeleteMemberFunc()

Changes to generic/itclMethod.c.

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
..
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
....
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
....
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606

void
ItclReleaseIMF(
    ClientData clientData)
{
    ItclMemberFunc *imPtr = (ItclMemberFunc *)clientData;

    if (--imPtr->refCount == 0) {
	Itcl_DeleteMemberFunc(clientData);
    }
}

void
ItclPreserveMemberCode(
    ItclMemberCode *mcodePtr)
................................................................................
    mcodePtr->refCount++;
}

void
ItclReleaseMemberCode(
    ItclMemberCode *mcodePtr)
{
    if (--mcodePtr->refCount == 0) {
	ItclFreeMemberCode(mcodePtr);
    }
}
 
/*
 * ------------------------------------------------------------------------
 *  Itcl_BodyCmd()
................................................................................

    if (Itcl_GetStackSize(stackPtr) > 0) {
	Tcl_Panic("frame context stack not empty!");
    }
    Itcl_DeleteStack(stackPtr);
    ckfree((char *) stackPtr);
    Tcl_DeleteHashEntry(hPtr);
    if (--contextPtr->refCount) {
	Tcl_Panic("frame context ref count not zero!");
    }
    ckfree((char *)contextPtr);
}

int
Itcl_GetContext(
................................................................................
      }
        ioPtr->callRefCount--;
        if (ioPtr->flags & ITCL_OBJECT_SHOULD_VARNS_DELETE) {
            ItclDeleteObjectVariablesNamespace(interp, ioPtr);
        }
    }
    
    callContextPtr->refCount--;
    if (callContextPtr->refCount == 0) {
        if (callContextPtr->ioPtr != NULL) {
	    hPtr = Tcl_FindHashEntry(&callContextPtr->ioPtr->contextCache,
	            (char *)callContextPtr->imPtr);
            if (hPtr == NULL) {
                ckfree((char *)callContextPtr);
	    }
	    ItclReleaseObject(ioPtr);







|







 







|







 







|







 







|
<







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
..
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
....
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
....
2591
2592
2593
2594
2595
2596
2597
2598

2599
2600
2601
2602
2603
2604
2605

void
ItclReleaseIMF(
    ClientData clientData)
{
    ItclMemberFunc *imPtr = (ItclMemberFunc *)clientData;

    if (imPtr->refCount-- <= 1) {
	Itcl_DeleteMemberFunc(clientData);
    }
}

void
ItclPreserveMemberCode(
    ItclMemberCode *mcodePtr)
................................................................................
    mcodePtr->refCount++;
}

void
ItclReleaseMemberCode(
    ItclMemberCode *mcodePtr)
{
    if (mcodePtr->refCount-- <= 1) {
	ItclFreeMemberCode(mcodePtr);
    }
}
 
/*
 * ------------------------------------------------------------------------
 *  Itcl_BodyCmd()
................................................................................

    if (Itcl_GetStackSize(stackPtr) > 0) {
	Tcl_Panic("frame context stack not empty!");
    }
    Itcl_DeleteStack(stackPtr);
    ckfree((char *) stackPtr);
    Tcl_DeleteHashEntry(hPtr);
    if (contextPtr->refCount-- <= 1) {
	Tcl_Panic("frame context ref count not zero!");
    }
    ckfree((char *)contextPtr);
}

int
Itcl_GetContext(
................................................................................
      }
        ioPtr->callRefCount--;
        if (ioPtr->flags & ITCL_OBJECT_SHOULD_VARNS_DELETE) {
            ItclDeleteObjectVariablesNamespace(interp, ioPtr);
        }
    }
    
    if (callContextPtr->refCount-- <= 1) {

        if (callContextPtr->ioPtr != NULL) {
	    hPtr = Tcl_FindHashEntry(&callContextPtr->ioPtr->contextCache,
	            (char *)callContextPtr->imPtr);
            if (hPtr == NULL) {
                ckfree((char *)callContextPtr);
	    }
	    ItclReleaseObject(ioPtr);

Changes to generic/itclMigrate2TclCore.c.

240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
                    return 1;
                }
            }
        }
    }
    return 0;
}

int
Itcl_IsCallFrameLinkVar(
    Tcl_Interp *interp,
    const char *name)
{
    CallFrame *varFramePtr = ((Interp *)interp)->framePtr;
    Proc *procPtr;

    if (varFramePtr == NULL) {
        return 0;
    }
    if (!varFramePtr->isProcCallFrame) {
        return 0;
    }
    procPtr = varFramePtr->procPtr;
    /*
     *  Search through compiled locals first...
     */
    if (procPtr) {
        CompiledLocal *localPtr = procPtr->firstLocalPtr;
        int nameLen = strlen(name);

        for (;localPtr != NULL; localPtr = localPtr->nextPtr) {
            if (TclIsVarLink(localPtr)) {
                register char *localName = localPtr->name;
                if ((name[0] == localName[0])
                        && (nameLen == localPtr->nameLength)
                        && (strcmp(name, localName) == 0)) {
                    return 1;
                }
            }
        }
    }
    return 0;
}

int 
Itcl_IsVarLink(Tcl_Var varPtr) {
    return TclIsVarLink((Var *)varPtr);
}







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
240
241
242
243
244
245
246









































                    return 1;
                }
            }
        }
    }
    return 0;
}









































Changes to generic/itclMigrate2TclCore.h.

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* here come the definitions for code which should be migrated to Tcl core */
/* these functions DO NOT exist and are not published */
#ifndef _TCL_PROC_DEFINED
typedef struct Tcl_Proc_ *Tcl_Proc;
#define _TCL_PROC_DEFINED 1
#endif

#define Tcl_SetProcCmd _Tcl_SetProcCmd

MODULE_SCOPE Tcl_Var Tcl_NewNamespaceVar(Tcl_Interp *interp, Tcl_Namespace *nsPtr,
	const char *varName);
MODULE_SCOPE void Itcl_PreserveVar(Tcl_Var var);
MODULE_SCOPE void Itcl_ReleaseVar(Tcl_Var var);
MODULE_SCOPE int Itcl_IsCallFrameArgument(Tcl_Interp *interp, const char *name);
MODULE_SCOPE int Itcl_GetCallVarFrameObjc(Tcl_Interp *interp);
MODULE_SCOPE int Itcl_IsVarLink(Tcl_Var var);
MODULE_SCOPE int Itcl_IsCallFrameLinkVar(Tcl_Interp *interp, const char *name);
MODULE_SCOPE Tcl_Obj * const * Itcl_GetCallVarFrameObjv(Tcl_Interp *interp);
#define Tcl_SetNamespaceResolver _Tcl_SetNamespaceResolver
MODULE_SCOPE int _Tcl_SetNamespaceResolver(Tcl_Namespace *nsPtr,
        struct Tcl_Resolve *resolvePtr);







<
<






<
<




67
68
69
70
71
72
73


74
75
76
77
78
79


80
81
82
83
/* here come the definitions for code which should be migrated to Tcl core */
/* these functions DO NOT exist and are not published */
#ifndef _TCL_PROC_DEFINED
typedef struct Tcl_Proc_ *Tcl_Proc;
#define _TCL_PROC_DEFINED 1
#endif



MODULE_SCOPE Tcl_Var Tcl_NewNamespaceVar(Tcl_Interp *interp, Tcl_Namespace *nsPtr,
	const char *varName);
MODULE_SCOPE void Itcl_PreserveVar(Tcl_Var var);
MODULE_SCOPE void Itcl_ReleaseVar(Tcl_Var var);
MODULE_SCOPE int Itcl_IsCallFrameArgument(Tcl_Interp *interp, const char *name);
MODULE_SCOPE int Itcl_GetCallVarFrameObjc(Tcl_Interp *interp);


MODULE_SCOPE Tcl_Obj * const * Itcl_GetCallVarFrameObjv(Tcl_Interp *interp);
#define Tcl_SetNamespaceResolver _Tcl_SetNamespaceResolver
MODULE_SCOPE int _Tcl_SetNamespaceResolver(Tcl_Namespace *nsPtr,
        struct Tcl_Resolve *resolvePtr);

Changes to generic/itclObject.c.

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

void
ItclReleaseObject(
    ClientData clientData)
{
    ItclObject *ioPtr = (ItclObject *)clientData;

    if (--ioPtr->refCount == 0) {
	ItclFreeObject((char *) clientData);
    }
}

 
/*
 * ------------------------------------------------------------------------







|







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

void
ItclReleaseObject(
    ClientData clientData)
{
    ItclObject *ioPtr = (ItclObject *)clientData;

    if (ioPtr->refCount-- <= 1) {
	ItclFreeObject((char *) clientData);
    }
}

 
/*
 * ------------------------------------------------------------------------