Itk - the [incr Tk] extension

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

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

Overview
Comment:Get the namespace contexts right for configure method and friends.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dgp-method-type
Files: files | file ages | folders
SHA1: bdbf1878b9c07cfc4ed6b74796390b5907d0ff45
User & Date: dgp 2015-10-22 13:56:05
Context
2015-10-22
14:44
Test revised -- think it was expecting wrong [itcl::code] context, but callback is fully qualified so it doesn't appear to matter. Also removed things not longer needed. check-in: c1c300c05c user: dgp tags: dgp-method-type
13:56
Get the namespace contexts right for configure method and friends. check-in: bdbf1878b9 user: dgp tags: dgp-method-type
2015-10-21
18:14
Adjust the frame management of Itk_PropagatePublicVar() to new expectations. check-in: 0893a4080a user: dgp tags: dgp-method-type
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/itkArchetype.c.

1097
1098
1099
1100
1101
1102
1103

1104


1105

1106
1107
1108
1109
1110
1111
1112
....
1127
1128
1129
1130
1131
1132
1133

1134
1135
1136
1137
1138
1139
1140
1141
1142
1143

1144

1145
1146
1147
1148
1149
1150
1151
....
1161
1162
1163
1164
1165
1166
1167


1168
1169
1170
1171
1172
1173
1174
1175
1176

1177


1178
1179
1180
1181
1182
1183
1184
	}
    }
    ItclShowArgs(1, "Itk_ArchConfigureCmd2", objc, objv);
    if (objc == 1) {
        Tcl_DStringInit(&buffer);

        for (i=0; i < info->order.len; i++) {

            archOpt = (ArchOption*)Tcl_GetHashValue(info->order.list[i]);


            val = Tcl_GetVar2(interp, "itk_option", archOpt->switchName, 0);

            if (!val) {
                Itk_ArchOptAccessError(interp, info, archOpt);
                Tcl_DStringFree(&buffer);
                return TCL_ERROR;
            }

            Tcl_DStringStartSublist(&buffer);
................................................................................

        /*
         *  If there is just one argument, then query the information
         *  for that one argument and return:
         *    {name resName resClass init value}
         */
        if (objc == 2) {

            token = Tcl_GetString(objv[1]);
            entry = Tcl_FindHashEntry(&info->options, token);
            if (!entry) {
                Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
                    "unknown option \"", token, "\"",
                    (char*)NULL);
                return TCL_ERROR;
            }

            archOpt = (ArchOption*)Tcl_GetHashValue(entry);

            val = Tcl_GetVar2(interp, "itk_option", archOpt->switchName, 0);

            if (!val) {
                Itk_ArchOptAccessError(interp, info, archOpt);
                return TCL_ERROR;
            }

            Tcl_AppendElement(interp, archOpt->switchName);
            Tcl_AppendElement(interp,
................................................................................

    /*
     *  Otherwise, it must be a series of "-option value" assignments.
     *  Look up each option and assign the new value.
     */
    for (objc--,objv++; objc > 0; objc-=2, objv+=2) {
	char *value;


        token = Tcl_GetString(objv[0]);
        if (objc < 2) {
            Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
                "value for \"", token, "\" missing",
                (char*)NULL);
            return TCL_ERROR;
        }
        value = Tcl_GetString(objv[1]);


        if (Itk_ArchConfigOption(interp, info, token, value) != TCL_OK) {


            return TCL_ERROR;
        }
    }

    Tcl_ResetResult(interp);
    return TCL_OK;
}






>

>
>

>







 







>










>

>







 







>
>









>
|
>
>







1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
....
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
....
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
	}
    }
    ItclShowArgs(1, "Itk_ArchConfigureCmd2", objc, objv);
    if (objc == 1) {
        Tcl_DStringInit(&buffer);

        for (i=0; i < info->order.len; i++) {
Tcl_Namespace *save = Tcl_GetCurrentNamespace(interp);
            archOpt = (ArchOption*)Tcl_GetHashValue(info->order.list[i]);

Itcl_SetCallFrameNamespace(interp, contextObj->iclsPtr->nsPtr);
            val = Tcl_GetVar2(interp, "itk_option", archOpt->switchName, 0);
Itcl_SetCallFrameNamespace(interp, save);
            if (!val) {
                Itk_ArchOptAccessError(interp, info, archOpt);
                Tcl_DStringFree(&buffer);
                return TCL_ERROR;
            }

            Tcl_DStringStartSublist(&buffer);
................................................................................

        /*
         *  If there is just one argument, then query the information
         *  for that one argument and return:
         *    {name resName resClass init value}
         */
        if (objc == 2) {
Tcl_Namespace *save = Tcl_GetCurrentNamespace(interp);
            token = Tcl_GetString(objv[1]);
            entry = Tcl_FindHashEntry(&info->options, token);
            if (!entry) {
                Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
                    "unknown option \"", token, "\"",
                    (char*)NULL);
                return TCL_ERROR;
            }

            archOpt = (ArchOption*)Tcl_GetHashValue(entry);
Itcl_SetCallFrameNamespace(interp, contextObj->iclsPtr->nsPtr);
            val = Tcl_GetVar2(interp, "itk_option", archOpt->switchName, 0);
Itcl_SetCallFrameNamespace(interp, save);
            if (!val) {
                Itk_ArchOptAccessError(interp, info, archOpt);
                return TCL_ERROR;
            }

            Tcl_AppendElement(interp, archOpt->switchName);
            Tcl_AppendElement(interp,
................................................................................

    /*
     *  Otherwise, it must be a series of "-option value" assignments.
     *  Look up each option and assign the new value.
     */
    for (objc--,objv++; objc > 0; objc-=2, objv+=2) {
	char *value;
	int code;
Tcl_Namespace *save = Tcl_GetCurrentNamespace(interp);
        token = Tcl_GetString(objv[0]);
        if (objc < 2) {
            Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
                "value for \"", token, "\" missing",
                (char*)NULL);
            return TCL_ERROR;
        }
        value = Tcl_GetString(objv[1]);

Itcl_SetCallFrameNamespace(interp, contextObj->iclsPtr->nsPtr);
        code = Itk_ArchConfigOption(interp, info, token, value);
Itcl_SetCallFrameNamespace(interp, save);
        if (code != TCL_OK) {
            return TCL_ERROR;
        }
    }

    Tcl_ResetResult(interp);
    return TCL_OK;
}

Changes to library/Archetype.itk.

62
63
64
65
66
67
68
69
70


71
72
73
74
75


76
77
78
79
80
81
82
        ::itcl::builtin::Archetype delete
    }

    method cget {option} {
        ::itcl::builtin::Archetype cget $option
    }

    method configure {{option ""} args} {
        ::itcl::builtin::Archetype configure $option {*}$args


    }

    method config {{option ""} args} {
        eval configure $option $args
    }



#    method component {{name ""} args} {
#        ::itcl::builtin::Archetype component $name {*}$args
#    }
    method component {{name ""} args} @Archetype-component

#    protected method itk_component {option args} {






|
|
>
>
|
<
|
|
<
>
>







62
63
64
65
66
67
68
69
70
71
72
73

74
75

76
77
78
79
80
81
82
83
84
        ::itcl::builtin::Archetype delete
    }

    method cget {option} {
        ::itcl::builtin::Archetype cget $option
    }

#    method configure {{option ""} args} {
#        ::itcl::builtin::Archetype configure $option {*}$args
#    }
    method configure {{option ""} args} @Archetype-configure


#    method config {{option ""} args} {
#        eval configure $option $args

#    }
    method config {{option ""} args} @Archetype-configure

#    method component {{name ""} args} {
#        ::itcl::builtin::Archetype component $name {*}$args
#    }
    method component {{name ""} args} @Archetype-component

#    protected method itk_component {option args} {