︙ | | |
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
-
-
-
-
-
-
-
|
ItclClass *contextClass;
ItclClass *ownerClass;
ItclObject *contextObj;
ArchInfo *info;
Tcl_Command accessCmd;
Tcl_Obj *objPtr;
Tcl_DString buffer;
#if 0
Tcl_CallFrame frame;
Tcl_CallFrame *uplevelFramePtr;
Tcl_CallFrame *oldFramePtr = NULL;
ItclObjectInfo *infoPtr;
ItclCallContext *callContextPtr;
#endif
ItclShowArgs(1, "Itk_ArchCompAddCmd", objc, objv);
/*
* Get the Archetype info associated with this widget.
*/
contextClass = NULL;
if (Itcl_GetContext(interp, &contextClass, &contextObj) != TCL_OK ||
|
︙ | | |
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
-
-
-
-
-
-
|
}
}
/*
* Execute the <createCmds> to create the component widget.
* Do this one level up, in the scope of the calling routine.
*/
#if 0
Itcl_SetCallFrameResolver(interp, contextClass->resolvePtr);
infoPtr = Tcl_GetAssocData(interp, ITCL_INTERP_DATA, NULL);
uplevelFramePtr = Itcl_GetUplevelCallFrame(interp, 1);
oldFramePtr = Itcl_ActivateCallFrame(interp, uplevelFramePtr);
#endif
result = Tcl_EvalObjEx(interp, objv[2], 0);
if (result != TCL_OK) {
goto compFail;
}
/*
* Take the result from the widget creation commands as the
|
︙ | | |
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
-
-
-
-
|
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"cannot find component access command \"",
path, "\" for component \"", name, "\"",
(char*)NULL);
goto compFail;
}
#if 0
(void) Itcl_ActivateCallFrame(interp, oldFramePtr);
oldFramePtr = NULL;
#endif
winNamePtr = Tcl_NewStringObj((char*)NULL, 0);
Tcl_GetCommandFullName(interp, accessCmd, winNamePtr);
Tcl_IncrRefCount(winNamePtr);
/*
* Create the component record. Set the protection level
|
︙ | | |
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
|
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
-
-
-
-
|
if (objc != 4) {
objPtr = Tcl_NewStringObj("usual", -1);
Tcl_IncrRefCount(objPtr);
} else {
objPtr = objv[3];
}
// result = Itcl_PushCallFrame(interp, &frame, parserNs,
// /* isProcCallFrame */ 0);
Tcl_Import(interp, NULL, "::itk::option-parser::*", 1);
if (result == TCL_OK) {
result = Tcl_EvalObj(interp, objPtr);
// Itcl_PopCallFrame(interp);
Tcl_ForgetImport(interp, NULL, "::itk::option-parser::*");
}
if (objc != 4) {
Tcl_DecrRefCount(objPtr);
}
if (result != TCL_OK) {
|
︙ | | |
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
|
516
517
518
519
520
521
522
523
524
525
526
527
528
529
|
-
-
-
-
-
|
Tcl_SetResult(interp, name, TCL_VOLATILE);
return TCL_OK;
/*
* If any errors were encountered, clean up and return.
*/
compFail:
#if 0
if (oldFramePtr) {
(void) Itcl_ActivateCallFrame(interp, oldFramePtr);
}
#endif
if (archComp) {
Itk_DelArchComponent(archComp);
}
if (entry) {
Tcl_DeleteHashEntry(entry);
}
if (path) {
|
︙ | | |
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
|
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
|
-
-
-
-
-
-
-
|
/*
* Update the public variable with the new option value.
* There should already be a call frame installed for handling
* instance variables, but make sure that the namespace context
* is the most-specific class, so that the public variable can
* be found.
*/
#if 0
result = Itcl_PushCallFrame(interp, &frame, contextObj->iclsPtr->nsPtr,
/*isProcCallFrame*/0);
#endif
if (result == TCL_OK) {
/*
* Casting away CONST of newval only to satisfy Tcl 8.3 and
* earlier headers.
*/
val = Tcl_SetVar2(interp, Tcl_GetString(ivPtr->fullNamePtr), (char *) NULL,
(char *) newval, TCL_LEAVE_ERR_MSG);
if (!val) {
result = TCL_ERROR;
}
#if 0
Itcl_PopCallFrame(interp);
#endif
}
if (result != TCL_OK) {
char msg[256];
sprintf(msg, "\n (error in configuration of public variable \"%.100s\")", Tcl_GetString(ivPtr->fullNamePtr));
Tcl_AddErrorInfo(interp, msg);
return TCL_ERROR;
|
︙ | | |
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
|
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
|
-
-
-
-
-
|
Tcl_Interp *interp, /* interpreter managing the object */
ArchInfo *info, /* info for Archetype mega-widget */
ArchOption *archOpt, /* option to initialize */
CONST char *defVal, /* last-resort default value */
char *currVal) /* current option value */
{
CONST char *init = NULL;
#if 0
Tcl_CallFrame frame;
int result;
#endif
CONST char *ival;
char c;
/*
* If the option is already initialized, then abort.
*/
if (archOpt->init) {
|
︙ | | |
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
|
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
(c == 's' && strcmp(archOpt->switchName,"-screen") == 0) ||
(c == 'v' && strcmp(archOpt->switchName,"-visual") == 0)) {
ival = currVal;
} else {
ival = init;
}
#if 1
Tcl_SetVar2(interp, "itk_option", archOpt->switchName,
(char *)((ival) ? ival : ""), 0);
#else
/*
* Set the initial value in the itk_option array.
* Since this might be called from the itk::option-parser
* namespace, reinstall the object context.
*/
result = Itcl_PushCallFrame(interp, &frame, info->itclObj->iclsPtr->nsPtr, /*isProcCallFrame*/0);
if (result == TCL_OK) {
/*
* Casting away CONST of ival only to satisfy Tcl 8.3 and
* earlier headers.
*/
fprintf(stdout, "ARCH INIT OPTION '%s'\n", archOpt->switchName);
fflush(stdout);
char *res = Tcl_SetVar2(interp, "itk_option", archOpt->switchName,
(char *)((ival) ? ival : ""), 0);
fprintf(stdout, "STORED: '%s'\n", res); fflush(stdout);
fprintf(stdout, "CONTEXT: '%s'\n", Tcl_GetCurrentNamespace(interp)->fullName);
Itcl_PopCallFrame(interp);
}
#endif
if (ival) {
archOpt->init = (char*)ckalloc((unsigned)(strlen(ival)+1));
strcpy(archOpt->init, ival);
}
}
|
︙ | | |
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
|
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
|
-
-
-
-
|
char *resClass, /* resource class name in X11 database */
CONST char *defVal, /* last-resort default value */
char *currVal, /* current value (or NULL) */
ArchOptionPart *optPart, /* part to be added in */
ArchOption **raOpt) /* returns: option containing new part */
{
CONST char *init = NULL;
#if 0
Tcl_CallFrame frame;
#endif
int result;
ArchOption *archOpt;
*raOpt = NULL;
archOpt = NULL;
/*
|
︙ | | |
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
|
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
|
-
-
-
|
* simply update this part to the current value. Otherwise,
* leave the configuration to Itk_ArchInitCmd().
*/
Itcl_AppendList(&archOpt->parts, (ClientData)optPart);
if ((archOpt->flags & ITK_ARCHOPT_INIT) != 0) {
// result = Itcl_PushCallFrame(interp, &frame, info->itclObj->iclsPtr->nsPtr, /*isProcCallFrame*/0);
if (result == TCL_OK) {
init = Tcl_GetVar2(interp, "itk_option", archOpt->switchName, 0);
// Itcl_PopCallFrame(interp);
}
if (!init) {
Itk_ArchOptAccessError(interp, info, archOpt);
return TCL_ERROR;
}
|
︙ | | |
︙ | | |
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
|
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
|
-
+
-
+
-
+
-
+
-
+
|
Itcl_ParseNamespPath(cmd, &buffer, &head, &tail);
if (objc < 2) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"wrong # args: should be one of...\n",
" ", tail, " add ?-protected? ?-private? ?--? name createCmds ?optionCmds?\n",
" ", tail, " delete name ?name name...?",
(char*)NULL);
Tcl_DStringFree(&buffer);
Tcl_DStringFree(&buffer);
return TCL_ERROR;
}
token = Tcl_GetString(objv[1]);
c = *token;
length = strlen(token);
/*
* Handle: itk_component add...
*/
if (c == 'a' && strncmp(token, "add", length) == 0) {
if (objc < 4) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"wrong # args: should be \"",
tail,
" add ?-protected? ?-private? ?--?",
" name createCmds ?optionCmds?\"",
(char*)NULL);
Tcl_DStringFree(&buffer);
Tcl_DStringFree(&buffer);
return TCL_ERROR;
}
Tcl_DStringFree(&buffer);
Tcl_DStringFree(&buffer);
return Itk_ArchCompAddCmd(dummy, interp, objc-1, objv+1);
} else {
/*
* Handle: itk_component delete...
*/
if (c == 'd' && strncmp(token, "delete", length) == 0) {
if (objc < 3) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"wrong # args: should be \"",
tail,
" delete name ?name name...?\"",
(char*)NULL);
Tcl_DStringFree(&buffer);
Tcl_DStringFree(&buffer);
return TCL_ERROR;
}
Tcl_DStringFree(&buffer);
Tcl_DStringFree(&buffer);
return Itk_ArchCompDeleteCmd(dummy, interp, objc-1, objv+1);
}
}
Tcl_DStringFree(&buffer);
/*
* Flag any errors.
|
︙ | | |
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
|
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
Itcl_ListElem *part;
ArchOption *archOpt;
ArchOptionPart *optPart;
ItclHierIter hier;
ItclVariable *ivPtr;
Tcl_HashSearch place;
Tcl_HashEntry *entry;
#if 0
ItclObjectInfo *infoPtr;
ItclCallContext *callContextPtr;
Tcl_HashEntry *hPtr;
#endif
ItclShowArgs(2, "Itk_ArchInitCmd", objc, objv);
contextClass = NULL;
if (Itcl_GetContext(interp, &contextClass, &contextObj) != TCL_OK ||
!contextObj) {
token = Tcl_GetString(objv[0]);
Tcl_ResetResult(interp);
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"improper usage: should be \"object ",
token, " ?-option value -option value...?\"",
(char*)NULL);
return TCL_ERROR;
}
#if 0
infoPtr = (ItclObjectInfo *)Tcl_GetAssocData(interp,
ITCL_INTERP_DATA, NULL);
#endif
if (Itk_GetArchInfo(interp, contextObj, &info) != TCL_OK) {
return TCL_ERROR;
}
/*
* See what class is being initialized by getting the namespace
* for the calling context.
*/
#if 0
infoPtr = Tcl_GetAssocData(interp, ITCL_INTERP_DATA, NULL);
callContextPtr = Itcl_GetStackValue(&infoPtr->contextStack,
Itcl_GetStackSize(&infoPtr->contextStack)-2);
hPtr = Tcl_FindHashEntry(
&callContextPtr->ioPtr->iclsPtr->infoPtr->namespaceClasses,
(char *)callContextPtr->nsPtr);
if (hPtr != NULL) {
contextClass = (ItclClass *)Tcl_GetHashValue(hPtr);
}
#endif
/*
* Integrate all public variables for the current class
* context into the composite option list.
*/
Itcl_InitHierIter(&hier, contextClass);
while ((iclsPtr=Itcl_AdvanceHierIter(&hier)) != NULL) {
|
︙ | | |
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
|
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
|
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
return TCL_ERROR;
}
if (Itk_GetArchInfo(interp, contextObj, &info) != TCL_OK) {
return TCL_ERROR;
}
callingNs = Tcl_GetCurrentNamespace(interp);
callingNs = Tcl_GetCurrentNamespace(interp);
#if 0
infoPtr = (ItclObjectInfo *)Tcl_GetAssocData(interp,
ITCL_INTERP_DATA, NULL);
if (Itcl_GetStackSize(&infoPtr->contextStack) == 1) {
callingNs = Tcl_GetGlobalNamespace(interp);
} else {
ItclCallContext *callContextPtr;
callContextPtr = Itcl_GetStackValue(&infoPtr->contextStack,
Itcl_GetStackSize(&infoPtr->contextStack)-2);
#ifdef NOTDEF
callingNs = (Tcl_Namespace *)Itcl_GetStackValue(
&infoPtr->namespaceStack,
Itcl_GetStackSize(&infoPtr->namespaceStack)-2);
#endif
callingNs = callContextPtr->nsPtr;
}
#endif
/*
* With no arguments, return a list of components that can be
* accessed from the calling scope.
*/
if (objc == 2) {
/* if the name of the component is the empty string ignore that arg */
if (strlen(Tcl_GetString(objv[1])) == 0) {
|
︙ | | |
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
|
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
|
-
+
-
+
-
+
|
}
}
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);
Tcl_Namespace *save = Tcl_GetCurrentNamespace(interp);
archOpt = (ArchOption*)Tcl_GetHashValue(info->order.list[i]);
Itcl_SetCallFrameNamespace(interp, contextObj->iclsPtr->nsPtr);
Itcl_SetCallFrameNamespace(interp, contextObj->iclsPtr->nsPtr);
val = Tcl_GetVar2(interp, "itk_option", archOpt->switchName, 0);
Itcl_SetCallFrameNamespace(interp, save);
Itcl_SetCallFrameNamespace(interp, save);
if (!val) {
Itk_ArchOptAccessError(interp, info, archOpt);
Tcl_DStringFree(&buffer);
return TCL_ERROR;
}
Tcl_DStringStartSublist(&buffer);
|
︙ | | |
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
|
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
|
-
+
-
+
-
+
|
/*
* 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);
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);
Itcl_SetCallFrameNamespace(interp, contextObj->iclsPtr->nsPtr);
val = Tcl_GetVar2(interp, "itk_option", archOpt->switchName, 0);
Itcl_SetCallFrameNamespace(interp, save);
Itcl_SetCallFrameNamespace(interp, save);
if (!val) {
Itk_ArchOptAccessError(interp, info, archOpt);
return TCL_ERROR;
}
Tcl_AppendElement(interp, archOpt->switchName);
Tcl_AppendElement(interp,
|
︙ | | |
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
|
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
|
-
+
-
+
-
+
|
/*
* 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);
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);
Itcl_SetCallFrameNamespace(interp, contextObj->iclsPtr->nsPtr);
code = Itk_ArchConfigOption(interp, info, token, value);
Itcl_SetCallFrameNamespace(interp, save);
Itcl_SetCallFrameNamespace(interp, save);
if (code != TCL_OK) {
return TCL_ERROR;
}
}
Tcl_ResetResult(interp);
return TCL_OK;
|
︙ | | |