Index: TODO =================================================================== diff -u -rcc751d3067631542fabfb7205286e1a8757c60ca -rfcd388b1a6745e75ba21d123ebaf8c280d0094d3 --- TODO (.../TODO) (revision cc751d3067631542fabfb7205286e1a8757c60ca) +++ TODO (.../TODO) (revision fcd388b1a6745e75ba21d123ebaf8c280d0094d3) @@ -2361,17 +2361,17 @@ some other deleted from the same hash table. - extended regression test. +- made default setting more compatible with XOTcl 1 + * set variables to defaults only when not set already + * flag init_called already before init is called, not afterwards + (a call to "configure" within init does not clear the already + set instance variables) + TODO: - serializer: check, why catch is needed for object-level alias (search for ns_cache_flush) -- NSF_PROFILE - * provide an interface to clear and to output PROFILE data. - * output should provide a cutoff value. - * most probably it has memory leak in multithreaded apps, - since it was originally just developed for simple testing - - document value added replacements of Tcl functions - object parameter type forward: @@ -2386,6 +2386,9 @@ - default/initcmd/subsdefault: can we simplify these? or add messages for conflicting usages. +- CallConfigureMethod() + TODO: don't check hard coded method name + - doc: NextScriptingLanguage/index.html: Index: generic/nsf.c =================================================================== diff -u -rcc751d3067631542fabfb7205286e1a8757c60ca -rfcd388b1a6745e75ba21d123ebaf8c280d0094d3 --- generic/nsf.c (.../nsf.c) (revision cc751d3067631542fabfb7205286e1a8757c60ca) +++ generic/nsf.c (.../nsf.c) (revision fcd388b1a6745e75ba21d123ebaf8c280d0094d3) @@ -11621,16 +11621,24 @@ */ INCR_REF_COUNT(resultObj); Tcl_ListObjGetElements(interp, resultObj, &nobjc, &nobjv); + /* * Trying CallDirectly does not make much sense, since init is * already defined in predefined */ methodObj = NsfMethodObj(object, NSF_o_init_idx); + + /* + * Flag the call to "init" before the dispatch, such that a call to + * "configure" within init does not clear the already set instance + * variables. + */ + object->flags |= NSF_INIT_CALLED; + if (methodObj) { result = CallMethod((ClientData) object, interp, methodObj, nobjc+2, nobjv, NSF_CM_NO_PROTECT|NSF_CSC_IMMEDIATE); } - object->flags |= NSF_INIT_CALLED; DECR_REF_COUNT(resultObj); } @@ -12561,6 +12569,12 @@ /* fprintf(stderr, "CallConfigureMethod method %s->'%s' level %d, argc %d\n", ObjectName(object), methodName, level, argc);*/ + /* + * When configure gets "-init" passed, we call "init" and notice the fact it + * in the object's flags. + * + * TODO: don't check hard coded method name "init" + */ if (isInitString(methodName)) { object->flags |= NSF_INIT_CALLED; } @@ -16714,8 +16728,21 @@ * avoid overwriting with default values when e.g. "o configure" * is called lated without arguments. */ + /* + fprintf(stderr, "param %s, INIT CALLED %d is default %d value = %s\n", + paramPtr->name, (object->flags & NSF_INIT_CALLED), + (pc.flags[i-1] & NSF_PC_IS_DEFAULT), + ObjStr(pc.full_objv[i])); + */ if ((object->flags & NSF_INIT_CALLED) && (pc.flags[i-1] & NSF_PC_IS_DEFAULT)) { - continue; + Tcl_Obj *varObj; + + if (paramPtr->flags & (NSF_ARG_INITCMD|NSF_ARG_ALIAS|NSF_ARG_FORWARD)) continue; + + varObj = Tcl_ObjGetVar2(interp, paramPtr->nameObj, NULL, TCL_PARSE_PART1); + if (varObj) { + continue; + } } newValue = pc.full_objv[i]; @@ -16871,7 +16898,9 @@ #if defined(CONFIGURE_ARGS_TRACE) fprintf(stderr, "*** %s SET %s '%s'\n", ObjectName(object), ObjStr(paramPtr->nameObj), ObjStr(newValue)); #endif - /* Actually set instance variable */ + /* + * Actually set instance variable with the provided or default value. + */ Tcl_ObjSetVar2(interp, paramPtr->nameObj, NULL, newValue, TCL_LEAVE_ERR_MSG|TCL_PARSE_PART1); } }