Tcl Source Code

Check-in [edd3cd05f0]
Login

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

Overview
Comment:Delete oo::singleton,configurable commands before defining them as classes
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | apn-oo-lazy-init
Files: files | file ages | folders
SHA3-256: edd3cd05f0357fff4b0103d8979aa80fe4cb5862d5aaccf5984cca2f6d3e1e82
User & Date: apnadkarni 2025-08-16 04:22:12.867
Context
2025-08-16
14:12
few improvements for [effa2e2346f8372a]: code deduplication, init commands declared as list, update ... Leaf check-in: 6a997a7f19 user: sebres tags: apn-oo-lazy-init-sbmod
04:22
Delete oo::singleton,configurable commands before defining them as classes Leaf check-in: edd3cd05f0 user: apnadkarni tags: apn-oo-lazy-init
04:02
Proof of concept to reduce interp start times by lazy loading oo check-in: 897093b790 user: apnadkarni tags: apn-oo-lazy-init
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclOO.c.
235
236
237
238
239
240
241


242

243
244
245

246
247
248
249
250
251
252
    TCL_UNUSED(void *),
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[])
{
    Interp *iPtr = (Interp *)interp;
    if (iPtr->objectFoundation == NULL) {


	/*

	 * Build the core of the OO system.
	 */


	if (InitFoundation(interp) != TCL_OK) {
	    return TCL_ERROR;
	}

    }
    return Tcl_EvalObjv(interp, objc, objv, 0);
}







>
>

>
|

|
>







235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
    TCL_UNUSED(void *),
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[])
{
    Interp *iPtr = (Interp *)interp;
    if (iPtr->objectFoundation == NULL) {
	/* Not initialized so do it */

	/*
	 * Defining of oo::{configurable,singleton} as classes will fail
	 * if the command of that name exists so delete their stubs.
	 */
	(void) Tcl_DeleteCommand(interp, "::oo::configurable");
	(void) Tcl_DeleteCommand(interp, "::oo::singleton");
	if (InitFoundation(interp) != TCL_OK) {
	    return TCL_ERROR;
	}

    }
    return Tcl_EvalObjv(interp, objc, objv, 0);
}
272
273
274
275
276
277
278


279
280
281
282
283


284
285
286
287
288
289
290
 */
int
TclOOInit(
    Tcl_Interp *interp)		/* The interpreter to install into. */
{
    Tcl_CreateObjCommand(interp, "::oo::class",
	    TclOOInitModuleObjCmd, INT2PTR(0), NULL);


    Tcl_CreateObjCommand(interp, "::oo::define",
	    TclOOInitModuleObjCmd, INT2PTR(0), NULL);
    Tcl_CreateObjCommand(interp, "::oo::objdefine",
	    TclOOInitModuleObjCmd, INT2PTR(0), NULL);
    Tcl_CreateObjCommand(interp, "::oo::object",


	    TclOOInitModuleObjCmd, INT2PTR(0), NULL);


    Tcl_Command infoCmd;
    Tcl_Obj *mapDict;

    /*







>
>





>
>







276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
 */
int
TclOOInit(
    Tcl_Interp *interp)		/* The interpreter to install into. */
{
    Tcl_CreateObjCommand(interp, "::oo::class",
	    TclOOInitModuleObjCmd, INT2PTR(0), NULL);
    Tcl_CreateObjCommand(interp, "::oo::configurable",
	    TclOOInitModuleObjCmd, INT2PTR(0), NULL);
    Tcl_CreateObjCommand(interp, "::oo::define",
	    TclOOInitModuleObjCmd, INT2PTR(0), NULL);
    Tcl_CreateObjCommand(interp, "::oo::objdefine",
	    TclOOInitModuleObjCmd, INT2PTR(0), NULL);
    Tcl_CreateObjCommand(interp, "::oo::object",
	    TclOOInitModuleObjCmd, INT2PTR(0), NULL);
    Tcl_CreateObjCommand(interp, "::oo::singleton",
	    TclOOInitModuleObjCmd, INT2PTR(0), NULL);


    Tcl_Command infoCmd;
    Tcl_Obj *mapDict;

    /*