Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tip-457 Excluding Merge-Ins
This is equivalent to a diff from f1c99ff14c to be60dadb16
2017-05-29
| ||
13:14 | merge core-8-6-branch check-in: a9965b7335 user: jan.nijtmans tags: trunk | |
2017-05-27
| ||
22:17 | Implement proposed 0d decimal radix prefix to compliment 0x,0b,0o. check-in: d492c01a39 user: griffin tags: bsg-0d-radix-prefix | |
2017-05-23
| ||
22:36 | TIP#457: Update named group ending Leaf check-in: be60dadb16 user: mlafon tags: tip-457 | |
22:27 | merge trunk check-in: 340fa5f4a8 user: mlafon tags: tip-457 | |
16:00 | [19a8c9399d] Plug mem leak in TIP 459 machinery. check-in: f1c99ff14c user: dgp tags: trunk | |
14:48 | Update internal tables to Unicode 10.0. Still in Beta, but to be released soon. check-in: 090498e9a8 user: jan.nijtmans tags: trunk | |
Changes to doc/info.n.
︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | + + + + + + | .TP \fBinfo args \fIprocname\fR . Returns a list containing the names of the arguments to procedure \fIprocname\fR, in order. \fIProcname\fR must be the name of a Tcl command procedure. .TP \fBinfo argspec ?\fIarg ...\fR . Returns information about the arguments specification of Tcl-pure procedures, lambda or class methods. The \fIsubcommand\fRs are described in \fBARGSPEC INTROSPECTION\fR below. .TP \fBinfo body \fIprocname\fR . Returns the body of procedure \fIprocname\fR. \fIProcname\fR must be the name of a Tcl command procedure. .TP \fBinfo class\fI subcommand class\fR ?\fIarg ...\fR .VS 8.6 |
︙ | |||
394 395 396 397 398 399 400 401 402 403 404 405 406 407 | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 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 477 478 479 480 481 482 483 484 485 486 487 488 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | the resulting list of variable names has each matching namespace variable qualified with the name of its namespace. Note that a currently-visible variable may not yet .QW exist if it has not been set (e.g. a variable declared but not set by \fBvariable\fR). .SS "ARGSPEC INTROSPECTION" .VS .PP The following \fIsubcommand\fR values are supported by \fBinfo argspec\fR: .VE .TP \fBinfo argspec constructor \fIclassName \fR?\fIarg\fR? .VS If \fIarg\fR is specified, returns a list containing the argument specifiers which describe the argument \fIarg\fR of the constructor of the class \fIclassName\fR. If \fIarg\fR is not specified, returns a list containing the argument specifiers list of all arguments of the constructor of the class \fIclassName\fR. .TP \fBinfo argspec lambda \fIlambdaTerm \fR?\fIarg\fR? .VS If \fIarg\fR is specified, returns a list containing the argument specifiers which describe the argument \fIarg\fR of the lambda \fIlambdaTerm\fR. If \fIarg\fR is not specified, returns a list containing the argument specifiers list of all arguments of the lambda \fIlambdaTerm\fR. .TP \fBinfo argspec method \fIclassName methodName \fR?\fIarg\fR? .VS If \fIarg\fR is specified, returns a list containing the argument specifiers which describe the argument \fIarg\fR of the method \fImethodName\fR of the class \fIclassName\fR. If \fIarg\fR is not specified, returns a list containing the argument specifiers list of all arguments of the method \fImethodName\fR of the class \fIclassName\fR. .TP \fBinfo argspec objmethod \fIobject methodName \fR?\fIarg\fR? .VS If \fIarg\fR is specified, returns a list containing the argument specifiers which describe the argument \fIarg\fR of the method \fImethodName\fR of the object \fIobject\fR. If \fIarg\fR is not specified, returns a list containing the argument specifiers list of all arguments of the method \fImethodName\fR of the object \fIobject\fR. .TP \fBinfo argspec proc \fIprocName \fR?\fIarg\fR? .VS If \fIarg\fR is specified, returns a list containing the argument specifiers which describe the argument \fIarg\fR of the procedure \fIprocName\fR. If \fIarg\fR is not specified, returns a list containing the argument specifiers list of all arguments of the procedure \fIprocName\fR. .TP \fBinfo argspec specifiers .VS Returns a list containing the argument specifiers supported by the current interpreter. .PP Note that the returned argument specifiers in all subcommands, except \fIspecifiers\fR, may not be exactly the same as the ones used during the procedure creation, but they are strictly equivalents. .VE .PP .CS proc p {{a -name A -name arg} {b -required 1 -default def}} {} info argspec proc p a \fI\(-> returns {a -name {A arg}}\fR info argspec proc p \fI\(-> returns {{a -name {A arg}} b}\fR .CE .PP In the example above, \fI-name A -name arg\fR and \fI-name {A arg}\fR are equivalent specifiers. Using \fI-required 1\fR and a default value on a non-keyword argument is equivalent to using no specifiers, as the default value is ignored when \fI-required 1\fR is used and will also force the argument to be specified. .VE .SS "CLASS INTROSPECTION" .VS 8.6 .PP The following \fIsubcommand\fR values are supported by \fBinfo class\fR: .VE 8.6 .TP \fBinfo class call\fI class method\fR |
︙ |
Changes to doc/proc.n.
︙ | |||
26 27 28 29 30 31 32 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | + - + - + + + + + - + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | and the new procedure is created in the current namespace. If \fIname\fR includes any namespace qualifiers, the procedure is created in the specified namespace. \fIArgs\fR specifies the formal arguments to the procedure. It consists of a list, possibly empty, each of whose elements specifies one argument. Each argument specifier is also a list with either one, two fields or an odd number of fields. |
︙ | |||
105 106 107 108 109 110 111 | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + | \fBproc\fR printArguments args { foreach arg $args { puts $arg } } .CE .PP |
Changes to generic/tclCmdIL.c.
︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | + + | * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tclInt.h" #include "tclRegexp.h" #include "tclCompile.h" #include "tclOOInt.h" /* * During execution of the "lsort" command, structures of the following type * are used to arrange the objects being sorted into a collection of linked * lists. */ |
︙ | |||
104 105 106 107 108 109 110 111 112 113 114 115 116 117 | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | + + | * Forward declarations for procedures defined in this file: */ static int DictionaryCompare(const char *left, const char *right); static Tcl_NRPostProc IfConditionCallback; static int InfoArgsCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int InfoArgSpecCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int InfoBodyCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int InfoCmdCountCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int InfoCommandsCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int InfoCompleteCmd(ClientData dummy, Tcl_Interp *interp, |
︙ | |||
157 158 159 160 161 162 163 164 165 166 167 168 169 170 | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | + | /* * Array of values describing how to implement each standard subcommand of the * "info" command. */ static const EnsembleImplMap defaultInfoMap[] = { {"args", InfoArgsCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0}, {"argspec", InfoArgSpecCmd, TclCompileBasic2ArgCmd, NULL, NULL, 0}, {"body", InfoBodyCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0}, {"cmdcount", InfoCmdCountCmd, TclCompileBasic0ArgCmd, NULL, NULL, 0}, {"commands", InfoCommandsCmd, TclCompileInfoCommandsCmd, NULL, NULL, 0}, {"complete", InfoCompleteCmd, TclCompileBasic1ArgCmd, NULL, NULL, 0}, {"coroutine", TclInfoCoroutineCmd, TclCompileInfoCoroutineCmd, NULL, NULL, 0}, {"default", InfoDefaultCmd, TclCompileBasic3ArgCmd, NULL, NULL, 0}, {"errorstack", InfoErrorStackCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 0}, |
︙ | |||
510 511 512 513 514 515 516 517 518 519 520 521 522 523 | 515 516 517 518 519 520 521 522 523 524 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 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj(localPtr->name, -1)); } } Tcl_SetObjResult(interp, listObjPtr); return TCL_OK; } /* *---------------------------------------------------------------------- * * InfoArgSpecCmd -- * * Called to implement the "info argspec" command that returns the * extendend argument specification for a procedure. * Handles the following syntaxes: * * info argspec proc procName ?arg? * info argspec lambda lambdaTerm ?arg? * info argspec constructor className ?arg? * info argspec method className methodName ?arg? * info argspec objmethod object methodName ?arg? * info argspec specifiers * * Results: * Returns TCL_OK if successful and TCL_ERROR if there is an error. * * Side effects: * Returns a result in the interpreter's result object. If there is an * error, the result is an error message. * *---------------------------------------------------------------------- */ static int InfoArgSpecCmd( ClientData dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const types[] = { "proc", "lambda", "constructor", "method", "objmethod", "specifiers", NULL, }; static const char *const specifiers[] = { /* supported specifiers, must be ordered */ "-default", "-name", "-required", "-switch", "-upvar", NULL }; enum Types { ARGSPEC_PROC, ARGSPEC_LAMBDA, ARGSPEC_CONSTRUCTOR, ARGSPEC_METHOD, ARGSPEC_OBJMETHOD, ARGSPEC_SPECIFIERS }; register Interp *iPtr = (Interp *) interp; const char *procName = NULL, *argName = NULL; Proc *procPtr = NULL; CompiledLocal *localPtr; Tcl_Obj *listObjPtr; Object *oPtr; Method *methodPtr; Tcl_HashEntry *hPtr; int idx, result; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "type ..."); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[1], types, "type", 0, &idx)!=TCL_OK) { return TCL_ERROR; } switch ((enum Types) idx) { case ARGSPEC_PROC: if (objc < 3 || objc > 4) { Tcl_WrongNumArgs(interp, 1, objv, "proc procname ?arg?"); return TCL_ERROR; } procName = TclGetString(objv[2]); procPtr = TclFindProc(iPtr, procName); if (procPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"%s\" isn't a procedure", procName)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "PROCEDURE", procName, NULL); return TCL_ERROR; } argName = (objc == 4) ? TclGetString(objv[3]) : NULL; break; case ARGSPEC_LAMBDA: if (objc < 3 || objc > 4) { Tcl_WrongNumArgs(interp, 1, objv, "lambda lambdaTerm ?arg?"); return TCL_ERROR; } if (objv[2]->typePtr == &tclLambdaType) { procPtr = objv[2]->internalRep.twoPtrValue.ptr1; } if (procPtr == NULL || procPtr->iPtr != (Interp *) interp) { result = tclLambdaType.setFromAnyProc(interp, objv[2]); if (result != TCL_OK) { return result; } procPtr = objv[2]->internalRep.twoPtrValue.ptr1; } procName = "lambdaTerm"; argName = (objc == 4) ? TclGetString(objv[3]) : NULL; break; case ARGSPEC_CONSTRUCTOR: if (objc < 3 || objc > 4) { Tcl_WrongNumArgs(interp, 1, objv, "constructor className ?arg?"); return TCL_ERROR; } oPtr = (Object *) Tcl_GetObjectFromObj(interp, objv[2]); if (oPtr == NULL) { return TCL_ERROR; } if (oPtr->classPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"%s\" is not a class", TclGetString(objv[2]))); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CLASS", TclGetString(objv[2]), NULL); return TCL_ERROR; } methodPtr = oPtr->classPtr->constructorPtr; if (methodPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"%s\" has no defined constructor", TclGetString(objv[2]))); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "ARGSPEC", "CONSRUCTOR", NULL); return TCL_ERROR; } procPtr = TclOOGetProcFromMethod(methodPtr); if (procPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "body not available for this kind of constructor", -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "ARGSPEC", "METHODTYPE", NULL); return TCL_ERROR; } procName = "constructor"; argName = (objc == 4) ? TclGetString(objv[3]) : NULL; break; case ARGSPEC_METHOD: if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 1, objv, "method className methodName ?arg?"); return TCL_ERROR; } oPtr = (Object *) Tcl_GetObjectFromObj(interp, objv[2]); if (oPtr == NULL) { return TCL_ERROR; } if (oPtr->classPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"%s\" is not a class", TclGetString(objv[2]))); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "CLASS", TclGetString(objv[2]), NULL); return TCL_ERROR; } procName = TclGetString(objv[3]); hPtr = Tcl_FindHashEntry(&oPtr->classPtr->classMethods, (char *) objv[3]); if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown method \"%s\"", procName)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD", TclGetString(objv[3]), NULL); return TCL_ERROR; } procPtr = TclOOGetProcFromMethod(Tcl_GetHashValue(hPtr)); if (procPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "body not available for this kind of method", -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "ARGSPEC", "METHODTYPE", NULL); return TCL_ERROR; } argName = (objc == 5) ? TclGetString(objv[4]) : NULL; break; case ARGSPEC_OBJMETHOD: if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 1, objv, "objmethod object methodName ?arg?"); return TCL_ERROR; } oPtr = (Object *) Tcl_GetObjectFromObj(interp, objv[2]); if (oPtr == NULL) { return TCL_ERROR; } if (oPtr->methodsPtr == NULL) { hPtr = NULL; } else { hPtr = Tcl_FindHashEntry(oPtr->methodsPtr, (char *) objv[3]); } procName = TclGetString(objv[3]); if (hPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "unknown method \"%s\"", procName)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "METHOD", TclGetString(objv[3]), NULL); return TCL_ERROR; } procPtr = TclOOGetProcFromMethod(Tcl_GetHashValue(hPtr)); if (procPtr == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "body not available for this kind of method", -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "ARGSPEC", "METHODTYPE", NULL); return TCL_ERROR; } argName = (objc == 5) ? TclGetString(objv[4]) : NULL; break; case ARGSPEC_SPECIFIERS: listObjPtr = Tcl_NewListObj(0, NULL); for (idx = 0; specifiers[idx] != NULL; idx++) { Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj(specifiers[idx], -1)); } Tcl_SetObjResult(interp, listObjPtr); return TCL_OK; break; } if (argName == NULL) { /* info argspec ... procName */ listObjPtr = Tcl_NewListObj(0, NULL); for (localPtr = procPtr->firstLocalPtr; localPtr != NULL; localPtr = localPtr->nextPtr) { if (TclIsVarArgument(localPtr)) { Tcl_ListObjAppendElement(interp, listObjPtr, TclProcGetArgSpec(interp, localPtr, TCL_GETARGSPEC_WITH_NAME)); } } Tcl_SetObjResult(interp, listObjPtr); return TCL_OK; } /* info argspec ... procName arg */ for (localPtr = procPtr->firstLocalPtr; localPtr != NULL; localPtr = localPtr->nextPtr) { if (TclIsVarArgument(localPtr) && (strcmp(argName, localPtr->name) == 0)) { listObjPtr = TclProcGetArgSpec(interp, localPtr, 0); Tcl_SetObjResult(interp, listObjPtr); return TCL_OK; } } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s \"%s\" doesn't have an argument \"%s\"", Tcl_GetString(objv[1]), procName, argName)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "ARGUMENT", argName, NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * InfoBodyCmd -- * * Called to implement the "info body" command that returns the body for |
︙ |
Changes to generic/tclCompile.c.
︙ | |||
3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 | 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 | + | localPtr->frameIndex = localVar; localPtr->flags = 0; if (name == NULL) { localPtr->flags |= VAR_TEMPORARY; } localPtr->defValuePtr = NULL; localPtr->resolveInfo = NULL; localPtr->argSpecPtr = NULL; if (name != NULL) { memcpy(localPtr->name, name, (size_t) nameBytes); } localPtr->name[nameBytes] = '\0'; procPtr->numCompiledLocals++; } |
︙ |
Changes to generic/tclInt.h.
︙ | |||
694 695 696 697 698 699 700 701 702 703 704 705 706 707 | 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | + + + + + + + | * VAR_TEMPORARY - 1 if the local variable is an anonymous * temporary variable. Temporaries have a NULL * name. * VAR_RESOLVED - 1 if name resolution has been done for this * variable. * VAR_IS_ARGS 1 if this variable is the last argument and is * named "args". * VAR_NAMED_GROUP 1 means that this argument is part of a named * group defined using an extended argument * specification. * VAR_ARG_UPVAR 1 means that this argument has been defined * using the -upvar extended arg specification. * VAR_ARG_OPTIONAL 1 means that this argument is not required to * be specified on call-site. */ /* * FLAGS RENUMBERED: everything breaks already, make things simpler. * * IMPORTANT: skip the values 0x10, 0x20, 0x40, 0x800 corresponding to * TCL_TRACE_(READS/WRITES/UNSETS/ARRAY): makes code simpler in tclTrace.c |
︙ | |||
735 736 737 738 739 740 741 742 743 744 745 746 747 748 | 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | + + + | (VAR_TRACED_READ|VAR_TRACED_WRITE|VAR_TRACED_ARRAY|VAR_TRACED_UNSET) /* Special handling on initialisation (only CompiledLocal). */ #define VAR_ARGUMENT 0x100 /* KEEP OLD VALUE! See tclProc.c */ #define VAR_TEMPORARY 0x200 /* KEEP OLD VALUE! See tclProc.c */ #define VAR_IS_ARGS 0x400 #define VAR_RESOLVED 0x8000 #define VAR_NAMED_GROUP 0x10000 #define VAR_ARG_UPVAR 0x20000 #define VAR_ARG_OPTIONAL 0x40000 /* * Macros to ensure that various flag bits are set properly for variables. * The ANSI C "prototypes" for these macros are: * * MODULE_SCOPE void TclSetVarScalar(Var *varPtr); * MODULE_SCOPE void TclSetVarArray(Var *varPtr); |
︙ | |||
841 842 843 844 845 846 847 848 849 850 851 852 853 854 | 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 | + + + | #define TclIsVarInHash(varPtr) \ ((varPtr)->flags & VAR_IN_HASHTABLE) #define TclIsVarDeadHash(varPtr) \ ((varPtr)->flags & VAR_DEAD_HASH) #define TclIsVarWithExtArgs(varPtr) \ ((varPtr)->flags & (VAR_NAMED_GROUP|VAR_ARG_UPVAR|VAR_ARG_OPTIONAL)) #define TclGetVarNsPtr(varPtr) \ (TclIsVarInHash(varPtr) \ ? ((TclVarHashTable *) ((((VarInHash *) (varPtr))->entry.tablePtr)))->nsPtr \ : NULL) #define VarHashRefCount(varPtr) \ ((VarInHash *) (varPtr))->refCount |
︙ | |||
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 | 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | * tclProc.c, tclCompile.c, and tclExecute.c. *---------------------------------------------------------------- */ /* * Forward declaration to prevent an error when the forward reference to * Command is encountered in the Proc and ImportRef types declared below. * Same for CompiledLocal in the NamedGroupEntry type. */ struct Command; struct CompiledLocal; /* * The variable-length structure below describes an entry in a group of * named parameter defined together. */ typedef struct NamedGroupEntry { struct NamedGroupEntry *nextPtr; /* Next entry in the named-group, or NULL if * this is the last entry. */ int nameLength; /* The number of characters in entry's name */ int localIndex; /* Index of the related local in the array of * compiler-assigned variables in the procedure * call frame. */ Tcl_Obj *valuePtr; /* Pointer to the default value of the named * parameter, used with the -switch argument * specifier. NULL if it is related to a named * parameter created with the -name argument * specifier. */ struct CompiledLocal *localPtr; /* Pointer to the related local in the linked * list of locals for the procedure. */ char name[1]; /* Name of the entry starts here. The actual * size of this field will be large enough to * hold the name. MUST BE THE LAST FIELD IN * THE STRUCTURE! */ } NamedGroupEntry; /* * The structure below describes an extended argument specification applied * on a proc argument (see TIP#457). */ typedef struct ExtendedArgSpec { struct NamedGroupEntry *firstNamedEntryPtr; /* Pointer to the first named parameter entry * defined on this proc argument. */ Tcl_HashTable *namedHashTable; /* Pointer to the hash table created for a * fast lookup of named entry. The pointer is * only set on the first local of a named * group. */ int remainAfterNamedGroup; /* If the number of arguments after a named * group is fixed and non-optional, this will * contain that number. Otherwise, will be set * to -1. This is only set on the first local * of a named group. */ Tcl_Obj *upvarLevelPtr; /* Pointer to the level value specified using * the -upvar specifier. */ } ExtendedArgSpec; /* * The variable-length structure below describes a local variable of a * procedure that was recognized by the compiler. These variables have a name, * an element in the array of compiler-assigned local variables in the * procedure's call frame, and various other items of information. If the * local variable is a formal argument, it may also have a default value. The |
︙ | |||
919 920 921 922 923 924 925 | 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 | + - + + + + | * variable's name. Used to speed up variable * lookups. */ int frameIndex; /* Index in the array of compiler-assigned * variables in the procedure call frame. */ int flags; /* Flag bits for the local variable. Same as * the flags for the Var structure above, * although only VAR_ARGUMENT, VAR_TEMPORARY, * VAR_RESOLVED, VAR_NAMED_GROUP and VAR_ARG_* |
︙ | |||
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | + + + + + + + + + + + + + + | * procedure. */ Tcl_Obj *bodyPtr; /* Points to the ByteCode object for * procedure's body command. */ int numArgs; /* Number of formal parameters. */ int numCompiledLocals; /* Count of local variables recognized by the * compiler including arguments and * temporaries. */ int flags; /* Various flag bits. See below. */ CompiledLocal *firstLocalPtr; /* Pointer to first of the procedure's * compiler-allocated local variables, or NULL * if none. The first numArgs entries in this * list describe the procedure's formal * arguments. */ CompiledLocal *lastLocalPtr;/* Pointer to the last allocated local * variable or NULL if none. This has frame * index (numCompiledLocals-1). */ } Proc; /* * Flag bits for procedures. * * PROC_HAS_EXT_ARG_SPEC 1 means that the procedure has at least one * argument defined using an extended argument * specification. * PROC_HAS_NAMED_GROUP 1 means that the procedure has at least one * named group. */ #define PROC_HAS_EXT_ARG_SPEC 0x01 #define PROC_HAS_NAMED_GROUP 0x02 /* * The type of functions called to process errors found during the execution * of a procedure (or lambda term or ...). */ typedef void (ProcErrorProc)(Tcl_Interp *interp, Tcl_Obj *procNameObj); |
︙ | |||
2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 | 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 | + + + + + + + + + | #define TCL_DD_CONVERSION_TYPE_MASK 0x3 /* Mask to isolate the conversion type */ #define TCL_DD_STEELE0 0x1 /* 'Steele&White' after masking */ #define TCL_DD_SHORTEST0 0x0 /* 'Shortest possible' after masking */ /* Flags for TclProcGetArgSpec */ #define TCL_GETARGSPEC_WITH_NAME 0x01 /* Include arg name before specification */ #define TCL_GETARGSPEC_TRY_OLDSTYLE 0x02 /* Return argument spec using old-style * specification if there is no other options * set on argument */ /* *---------------------------------------------------------------- * Procedures shared among Tcl modules but not used by the outside world: *---------------------------------------------------------------- */ MODULE_SCOPE void TclAppendBytesToByteArray(Tcl_Obj *objPtr, |
︙ | |||
3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 | 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 | + + | const char *expected, const char *bytes, int numBytes, const char **endPtrPtr, int flags); MODULE_SCOPE void TclParseInit(Tcl_Interp *interp, const char *string, int numBytes, Tcl_Parse *parsePtr); MODULE_SCOPE int TclParseAllWhiteSpace(const char *src, int numBytes); MODULE_SCOPE int TclProcessReturn(Tcl_Interp *interp, int code, int level, Tcl_Obj *returnOpts); MODULE_SCOPE Tcl_Obj * TclProcGetArgSpec(Tcl_Interp *interp, CompiledLocal *argPtr, int flags); MODULE_SCOPE int TclpObjLstat(Tcl_Obj *pathPtr, Tcl_StatBuf *buf); MODULE_SCOPE Tcl_Obj * TclpTempFileName(void); MODULE_SCOPE Tcl_Obj * TclpTempFileNameForLibrary(Tcl_Interp *interp, Tcl_Obj* pathPtr); MODULE_SCOPE Tcl_Obj * TclNewFSPathObj(Tcl_Obj *dirPtr, const char *addStrRep, int len); MODULE_SCOPE int TclpDeleteFile(const void *path); MODULE_SCOPE void TclpFinalizeCondition(Tcl_Condition *condPtr); |
︙ | |||
3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 | 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 | + + + | MODULE_SCOPE int TclSubstTokens(Tcl_Interp *interp, Tcl_Token *tokenPtr, int count, int *tokensLeftPtr, int line, int *clNextOuter, const char *outerScript); MODULE_SCOPE int TclTrimLeft(const char *bytes, int numBytes, const char *trim, int numTrim); MODULE_SCOPE int TclTrimRight(const char *bytes, int numBytes, const char *trim, int numTrim); MODULE_SCOPE int TclUpvarForExtArg(Tcl_Interp *interp, Tcl_Obj *frameNamePtr, Tcl_Obj *varNamePtr, const char *localNameStr); MODULE_SCOPE int TclUtfCasecmp(const char *cs, const char *ct); MODULE_SCOPE int TclUtfCount(int ch); MODULE_SCOPE Tcl_Obj * TclpNativeToNormalized(ClientData clientData); MODULE_SCOPE Tcl_Obj * TclpFilesystemPathType(Tcl_Obj *pathPtr); MODULE_SCOPE int TclpDlopen(Tcl_Interp *interp, Tcl_Obj *pathPtr, Tcl_LoadHandle *loadHandle, Tcl_FSUnloadFileProc **unloadProcPtr, int flags); |
︙ |
Changes to generic/tclOO.c.
︙ | |||
182 183 184 185 186 187 188 | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | - + - | */ static const char *clonedBody = "foreach p [info procs [info object namespace $originObject]::*] {" " set args [info args $p];" " set idx -1;" " foreach a $args {" |
︙ |
Changes to generic/tclOOInfo.c.
︙ | |||
264 265 266 267 268 269 270 | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | - - + + - - - - - - + | return TCL_ERROR; } resultObjs[0] = Tcl_NewObj(); for (localPtr=procPtr->firstLocalPtr; localPtr!=NULL; localPtr=localPtr->nextPtr) { if (TclIsVarArgument(localPtr)) { |
︙ | |||
854 855 856 857 858 859 860 | 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | - - + + - - - - - - + | return TCL_ERROR; } resultObjs[0] = Tcl_NewObj(); for (localPtr=procPtr->firstLocalPtr; localPtr!=NULL; localPtr=localPtr->nextPtr) { if (TclIsVarArgument(localPtr)) { |
︙ | |||
922 923 924 925 926 927 928 | 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 | - - + + - - - - - - + | return TCL_ERROR; } resultObjs[0] = Tcl_NewObj(); for (localPtr=procPtr->firstLocalPtr; localPtr!=NULL; localPtr=localPtr->nextPtr) { if (TclIsVarArgument(localPtr)) { |
︙ |
Changes to generic/tclOOMethod.c.
︙ | |||
1293 1294 1295 1296 1297 1298 1299 | 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 | - - + + - - - - - + | * Copy the argument list. */ argsObj = Tcl_NewObj(); for (localPtr=pmPtr->procPtr->firstLocalPtr; localPtr!=NULL; localPtr=localPtr->nextPtr) { if (TclIsVarArgument(localPtr)) { |
︙ |
Changes to generic/tclProc.c.
︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | + + + + + + + + + + + + + | */ static void DupLambdaInternalRep(Tcl_Obj *objPtr, Tcl_Obj *copyPtr); static void FreeLambdaInternalRep(Tcl_Obj *objPtr); static int InitArgsAndLocals(Tcl_Interp *interp, Tcl_Obj *procNameObj, int skip); static int InitArgsWithOptions(Tcl_Interp *interp, Tcl_Obj *procNameObj, Tcl_Obj *const *argObjs, int numArgs); static void InitResolvedLocals(Tcl_Interp *interp, ByteCode *codePtr, Var *defPtr, Namespace *nsPtr); static void InitLocalCache(Proc *procPtr); static void ProcBodyDup(Tcl_Obj *srcPtr, Tcl_Obj *dupPtr); static void ProcBodyFree(Tcl_Obj *objPtr); static int ProcWrongNumArgs(Tcl_Interp *interp, int skip); static void MakeProcError(Tcl_Interp *interp, Tcl_Obj *procNameObj); static void MakeLambdaError(Tcl_Interp *interp, Tcl_Obj *procNameObj); static int SetLambdaFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static int ProcAddNamedGroupEntry(Tcl_Interp *interp, CompiledLocal *localPtr, const char *argName, Tcl_Obj *valuePtr, NamedGroupEntry **lastEntryPtr, Tcl_HashTable **namedHashPtrPtr); static int ProcParseArgSpec(Tcl_Interp *interp, const char *argSpec, int argIdx, int isLastArg, CompiledLocal **localPtrPtr, Tcl_HashTable **namedHashPtrPtr); static inline int ProcCheckScalarArg(const char *arg, const char **err); static void ProcCompiledLocalsFree(CompiledLocal *localPtr); static Tcl_NRPostProc ApplyNR2; static Tcl_NRPostProc InterpProcNR2; static Tcl_NRPostProc Uplevel_Callback; /* * The ProcBodyObjType type |
︙ | |||
393 394 395 396 397 398 399 | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | - + - + + | Proc **procPtrPtr) /* Returns: pointer to proc data. */ { Interp *iPtr = (Interp *) interp; const char **argArray = NULL; register Proc *procPtr; int i, length, result, numArgs; |
︙ | |||
460 461 462 463 464 465 466 467 468 469 470 471 472 473 | 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | + | procPtr = ckalloc(sizeof(Proc)); procPtr->iPtr = iPtr; procPtr->refCount = 1; procPtr->bodyPtr = bodyPtr; procPtr->numArgs = 0; /* Actual argument count is set below. */ procPtr->numCompiledLocals = 0; procPtr->flags = 0; procPtr->firstLocalPtr = NULL; procPtr->lastLocalPtr = NULL; } /* * Break up the argument list into argument specifiers, then process each * argument specifier. If the body is precompiled, processing is limited |
︙ | |||
496 497 498 499 500 501 502 | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 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 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 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 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 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 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 | - - - - - - - - - + + - - - - - - - - - + - - - - - - - - - + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - + - + - - + + - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + + - - + - - + + + - + - - - - - + + + + + + - + + + + - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | localPtr = procPtr->firstLocalPtr; } else { procPtr->numArgs = numArgs; procPtr->numCompiledLocals = numArgs; } for (i = 0; i < numArgs; i++) { |
︙ | |||
1069 1070 1071 1072 1073 1074 1075 | 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 | - + | Tcl_Interp *interp, int skip) { CallFrame *framePtr = ((Interp *)interp)->varFramePtr; register Proc *procPtr = framePtr->procPtr; register Var *defPtr; int localCt = procPtr->numCompiledLocals, numArgs, i; |
︙ | |||
1091 1092 1093 1094 1095 1096 1097 | 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 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 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + | desiredObjs[0] = framePtr->objv[skip-1]; #else desiredObjs[0] = Tcl_NewListObj(1, framePtr->objv + skip - 1); #endif /* AVOID_HACKS_FOR_ITCL */ } Tcl_IncrRefCount(desiredObjs[0]); if (procPtr->flags & PROC_HAS_EXT_ARG_SPEC) { CompiledLocal *localPtr; int first = 1; TclNewObj(finalObj); numArgs = 0; for (localPtr = procPtr->firstLocalPtr; localPtr != NULL; localPtr = localPtr->nextPtr) { if (!TclIsVarArgument(localPtr)) { continue; } else if (localPtr->flags & VAR_IS_ARGS) { argObj = Tcl_NewStringObj("?arg ...?", -1); } else if ((localPtr->argSpecPtr != NULL) && (localPtr->argSpecPtr->firstNamedEntryPtr != NULL)) { NamedGroupEntry *namedGroupPtr; TclNewObj(argObj); for (namedGroupPtr = localPtr->argSpecPtr->firstNamedEntryPtr; namedGroupPtr != NULL; namedGroupPtr = namedGroupPtr->nextPtr) { Tcl_AppendStringsToObj(argObj, "|-", namedGroupPtr->name, NULL); if (localPtr->flags & VAR_ARG_UPVAR) { Tcl_AppendStringsToObj(argObj, " &", localPtr->name, "&", NULL); } else if (namedGroupPtr->valuePtr == NULL) { Tcl_AppendStringsToObj(argObj, " ", localPtr->name, NULL); } } Tcl_AppendStringsToObj(argObj, "|", NULL); } else { if (localPtr->flags & VAR_ARG_UPVAR) { TclNewObj(argObj); Tcl_AppendStringsToObj(argObj, "&", localPtr->name, "&", NULL); } else { argObj = Tcl_NewStringObj(localPtr->name, localPtr->nameLength); } } if ((localPtr->defValuePtr != NULL) || (localPtr->flags & VAR_ARG_OPTIONAL)) { Tcl_AppendStringsToObj(finalObj, first ? "?" : " ?", Tcl_GetString(argObj), "?", NULL); } else { Tcl_AppendStringsToObj(finalObj, first ? "" : " ", Tcl_GetString(argObj), NULL); } first = 0; Tcl_DecrRefCount(argObj); } final = Tcl_GetString(finalObj); } else { |
︙ | |||
1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 | 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 | + + + + + + + + + + + + + + | if (numArgs == 0) { if (argCt) { goto incorrectArgs; } else { goto correctArgs; } } if ((procPtr->flags & PROC_HAS_EXT_ARG_SPEC) != 0) { int result; memset(varPtr, 0, numArgs*sizeof(Var)); result = InitArgsWithOptions(interp, procNameObj, argObjs, argCt); varPtr += numArgs; if (result != TCL_OK) { goto incorrectArgs; } else { goto correctArgs; } } imax = ((argCt < numArgs-1) ? argCt : numArgs-1); for (i = 0; i < imax; i++, varPtr++, defPtr ? defPtr++ : defPtr) { /* * "Normal" arguments; last formal is special, depends on it being * 'args'. */ |
︙ | |||
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 | 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 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 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | TclInitRewriteEnsemble(interp, skip-1, 0, framePtr->objv)) { TclNRAddCallback(interp, TclClearRootEnsemble, NULL, NULL, NULL, NULL); } memset(varPtr, 0, ((framePtr->compiledLocals + localCt)-varPtr) * sizeof(Var)); return ProcWrongNumArgs(interp, skip); } /* *---------------------------------------------------------------------- * * InitArgsWithOptions -- * * This routine is invoked in order to initialize the arguments * for a new call frame for a proc with extended arguments * specification. The numArgs variables in the array of local * variables must be initialized prior to calling this function. * * Results: * A standard Tcl result. * * Side effects: * The numArgs variables inside the array of local variables * can be initialized with object references, even if an error * is returned. * *---------------------------------------------------------------------- */ static int InitArgsWithOptions( register Tcl_Interp *interp,/* Interpreter in which procedure was * invoked. */ Tcl_Obj *procNameObj, /* Procedure name for error reporting. */ Tcl_Obj *const *argObjs, /* Array of input arguments */ int argCt) /* Number of input arguments */ { CallFrame *framePtr = ((Interp *)interp)->varFramePtr; register Proc *procPtr = framePtr->procPtr; register Var *varPtr = framePtr->compiledLocals, *localVarPtr; int numArgs = procPtr->numArgs, iLocal, iArg; Tcl_Obj *objPtr; CompiledLocal *localPtr; NamedGroupEntry *namedGroupPtr; int optLength, result; const char *optStr; for (iLocal = 0, iArg = 0, localPtr = procPtr->firstLocalPtr; iLocal < numArgs; iLocal++, localPtr = localPtr->nextPtr) { if (localPtr->flags & VAR_IS_ARGS) { /* * 'args' last argument, copy remaining arguments (can be empty) */ objPtr = Tcl_NewListObj(argCt-iArg, argObjs+iArg); varPtr[iLocal].value.objPtr = objPtr; Tcl_IncrRefCount(objPtr); iArg = argCt; /* all arguments have been handled */ } else if (localPtr->flags & VAR_NAMED_GROUP) { /* * Start of a named argument group. Handle all of them together. */ for (; iArg < argCt; iArg++) { if ((localPtr->argSpecPtr != NULL) && (localPtr->argSpecPtr->remainAfterNamedGroup > 0) && ((argCt - iArg) <= localPtr->argSpecPtr->remainAfterNamedGroup)) { /* Remaining arguments must be assigned to remaining * positional locals after named group, end handling */ break; } optStr = TclGetString(argObjs[iArg]); if (*optStr != '-') { /* argument without leading dash, end named group */ break; } optStr++; optLength = strlen(optStr); if ((optLength == 1) && (optStr[0] == '-')) { /* end-of-option marker (--) */ iArg++; break; } /* * Find the referenced argument using the hash table * created with the first name of the named group. */ namedGroupPtr = NULL; if (localPtr->argSpecPtr->namedHashTable != NULL) { Tcl_HashEntry *hPtr; hPtr = Tcl_FindHashEntry( localPtr->argSpecPtr->namedHashTable, optStr); if (hPtr != NULL) { namedGroupPtr = Tcl_GetHashValue(hPtr); } } if (namedGroupPtr == NULL) { return TCL_ERROR; /* not found */ } else if (namedGroupPtr->valuePtr) { objPtr = namedGroupPtr->valuePtr; } else if (iArg+1 < argCt) { objPtr = argObjs[++iArg]; } else { return TCL_ERROR; /* not enough input args */ } if (namedGroupPtr->localPtr->flags & VAR_ARG_UPVAR) { result = TclUpvarForExtArg(interp, namedGroupPtr->localPtr->argSpecPtr->upvarLevelPtr, objPtr, namedGroupPtr->localPtr->name); if (result != TCL_OK) { return result; } } else { localVarPtr = &(varPtr[namedGroupPtr->localIndex]); if (localVarPtr->value.objPtr != NULL) { Tcl_DecrRefCount(localVarPtr->value.objPtr); } localVarPtr->value.objPtr = objPtr; Tcl_IncrRefCount(objPtr); } } /* * Ensure that all variables in the named group have been * set, have a default value or are optionals. localPtr is set * to the last argument of the named group so that the loop * will continue with the next argument. iLocal is updated in * the same way. */ for (; ; localPtr=localPtr->nextPtr, iLocal++) { if (!varPtr[iLocal].value.objPtr) { if (localPtr->defValuePtr) { objPtr = localPtr->defValuePtr; varPtr[iLocal].value.objPtr = objPtr; Tcl_IncrRefCount(objPtr); } else if (!(localPtr->flags & VAR_ARG_OPTIONAL)) { return TCL_ERROR; } } /* stop on the last argument of the named group */ if ((localPtr->nextPtr == NULL) || !(localPtr->nextPtr->flags & (VAR_NAMED_GROUP))) { break; } } } else if (iArg < argCt) { /* * Set normal or 'upvar' variable using next input argument. */ objPtr = argObjs[iArg++]; if (localPtr->flags & VAR_ARG_UPVAR) { result = TclUpvarForExtArg(interp, localPtr->argSpecPtr->upvarLevelPtr, objPtr, localPtr->name); if (result != TCL_OK) { return result; } } else { varPtr[iLocal].value.objPtr = objPtr; Tcl_IncrRefCount(objPtr); } } else if (localPtr->defValuePtr) { /* * No more input arguments, set default value */ objPtr = localPtr->defValuePtr; varPtr[iLocal].value.objPtr = objPtr; Tcl_IncrRefCount(objPtr); } else if (!(localPtr->flags & VAR_ARG_OPTIONAL)) { /* * No more input arguments, no default value, not optional. */ return TCL_ERROR; } } if (iArg < argCt) { /* * Remaining input arguments which have not been handled. */ return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * TclProcGetArgSpec -- * * This routine is invoked in order to build an argument specification * for an existing argument. The TCL_GETARGSPEC_WITH_NAME or * TCL_GETARGSPEC_TRY_OLDSTYLE flags can be used to change how the * returned list is built. * * Results: * Returns a pointer to a newly allocated Tcl_Obj list. * * Side effects: * The returned list is allocated. * *---------------------------------------------------------------------- */ Tcl_Obj * TclProcGetArgSpec( Tcl_Interp *interp, CompiledLocal *localPtr, int flags) { Tcl_Obj *listObjPtr, *nameListPtr = NULL, *switchListPtr = NULL; NamedGroupEntry *ngPtr; listObjPtr = Tcl_NewListObj(0, NULL); if (flags & TCL_GETARGSPEC_WITH_NAME) { Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj(localPtr->name, localPtr->nameLength)); } if ((flags & TCL_GETARGSPEC_TRY_OLDSTYLE) && (!TclIsVarWithExtArgs(localPtr))) { if (localPtr->defValuePtr != NULL) { Tcl_ListObjAppendElement(interp, listObjPtr, localPtr->defValuePtr); } return listObjPtr; } if (localPtr->defValuePtr != NULL) { Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("-default", -1)); Tcl_ListObjAppendElement(interp, listObjPtr, localPtr->defValuePtr); } if ((localPtr->flags & VAR_NAMED_GROUP) && !(localPtr->flags & VAR_ARG_OPTIONAL)) { Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("-required", -1)); Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewBooleanObj(1)); } else if (!(localPtr->flags & VAR_NAMED_GROUP) && (localPtr->flags & VAR_ARG_OPTIONAL)) { Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("-required", -1)); Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewBooleanObj(0)); } if ((localPtr->argSpecPtr != NULL) && (localPtr->flags & VAR_ARG_UPVAR)) { Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("-upvar", -1)); Tcl_ListObjAppendElement(interp, listObjPtr, localPtr->argSpecPtr->upvarLevelPtr); } if ((localPtr->argSpecPtr != NULL) && (localPtr->argSpecPtr->firstNamedEntryPtr != NULL)) { for (ngPtr = localPtr->argSpecPtr->firstNamedEntryPtr; ngPtr != NULL; ngPtr = ngPtr->nextPtr) { Tcl_Obj *objArray[2] = { Tcl_NewStringObj(ngPtr->name, ngPtr->nameLength), ngPtr->valuePtr }; if (objArray[1] == NULL) { if (nameListPtr == NULL) { nameListPtr = Tcl_NewListObj(0, NULL); } Tcl_ListObjAppendElement(interp, nameListPtr, objArray[0]); } else if ((objArray[0]->length == objArray[1]->length) && (strcmp(Tcl_GetString(objArray[0]), Tcl_GetString(objArray[1])) == 0)) { if (switchListPtr == NULL) { switchListPtr = Tcl_NewListObj(0, NULL); } Tcl_ListObjAppendElement(interp, switchListPtr, objArray[0]); } else { if (switchListPtr == NULL) { switchListPtr = Tcl_NewListObj(0, NULL); } Tcl_ListObjAppendElement(interp, switchListPtr, Tcl_NewListObj(2, objArray)); } } } if (nameListPtr != NULL) { Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("-name", -1)); Tcl_ListObjAppendElement(interp, listObjPtr, nameListPtr); } if (switchListPtr != NULL) { Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("-switch", -1)); Tcl_ListObjAppendElement(interp, listObjPtr, switchListPtr); } return listObjPtr; } /* *---------------------------------------------------------------------- * * TclPushProcCallFrame -- * * Compiles a proc body if necessary, then pushes a CallFrame suitable |
︙ | |||
2006 2007 2008 2009 2010 2011 2012 | 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 | - - - - - - - - - - - - - + | if (lastPtr) { lastPtr->nextPtr = NULL; } else { procPtr->firstLocalPtr = NULL; } procPtr->lastLocalPtr = lastPtr; |
︙ | |||
2140 2141 2142 2143 2144 2145 2146 | 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 | - - - - - - + - - - - - - - - - - - - - - - - | *---------------------------------------------------------------------- */ void TclProcCleanupProc( register Proc *procPtr) /* Procedure to be deleted. */ { |
︙ | |||
2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 | 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } ckfree(cfPtr->line); cfPtr->line = NULL; ckfree(cfPtr); } Tcl_DeleteHashEntry(hePtr); } /* *---------------------------------------------------------------------- * * ProcCompiledLocalsFree -- * * This function does all the real work of freeing up a CompiledLocal * linked list. * * Results: * None. * * Side effects: * Memory gets freed. * *---------------------------------------------------------------------- */ static void ProcCompiledLocalsFree( CompiledLocal *localPtr) { CompiledLocal *nextLocalPtr = localPtr; Tcl_ResolvedVarInfo *resVarInfo; NamedGroupEntry *entryPtr, *nextEntryPtr; while (nextLocalPtr != NULL) { localPtr = nextLocalPtr; nextLocalPtr = nextLocalPtr->nextPtr; resVarInfo = localPtr->resolveInfo; if (resVarInfo) { if (resVarInfo->deleteProc) { resVarInfo->deleteProc(resVarInfo); } else { ckfree(resVarInfo); } } if (localPtr->defValuePtr != NULL) { Tcl_DecrRefCount(localPtr->defValuePtr); } if (localPtr->argSpecPtr != NULL) { entryPtr = localPtr->argSpecPtr->firstNamedEntryPtr; while (entryPtr != NULL) { nextEntryPtr = entryPtr->nextPtr; if (entryPtr->valuePtr) { Tcl_DecrRefCount(entryPtr->valuePtr); } ckfree(entryPtr); entryPtr = nextEntryPtr; } if (localPtr->argSpecPtr->namedHashTable != NULL) { Tcl_HashTable *hTablePtr; hTablePtr = localPtr->argSpecPtr->namedHashTable; Tcl_DeleteHashTable(hTablePtr); ckfree(hTablePtr); } if (localPtr->argSpecPtr->upvarLevelPtr != NULL) { Tcl_DecrRefCount(localPtr->argSpecPtr->upvarLevelPtr); } ckfree(localPtr->argSpecPtr); } ckfree(localPtr); } } /* *---------------------------------------------------------------------- * * TclUpdateReturnInfo -- * * This function is called when procedures return, and at other points |
︙ |
Changes to generic/tclVar.c.
︙ | |||
4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 | 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | result = ObjMakeUpvar(interp, framePtr, part1Ptr, part2, 0, localNamePtr, flags, -1); Tcl_DecrRefCount(part1Ptr); Tcl_DecrRefCount(localNamePtr); return result; } /* *---------------------------------------------------------------------- * * TclUpvarForExtArg -- * * This function links one variable to another. It is used during * initialization of proc variables which use the upvar extended * argument specification. * * Results: * A standard Tcl completion code. If an error occurs then an error * message is left in the interp's result. * * Side effects: * The variable in upper frame whose name is given by varName becomes * accessible under the name localNameStr, so that references to * localNameStr are redirected to the other variable like a symbolic * link. * *---------------------------------------------------------------------- */ int TclUpvarForExtArg( Tcl_Interp *interp, /* Command interpreter in which varName is to * be looked up. */ Tcl_Obj *frameNamePtr, /* Name of the frame containing the source * variable. */ Tcl_Obj *varNamePtr, /* Name of variable in interp to link to. */ const char *localNameStr) /* Name of link variable. */ { int result; CallFrame *framePtr; Tcl_Obj *localNamePtr; if (TclObjGetFrame(interp, frameNamePtr, &framePtr) == -1) { return TCL_ERROR; } localNamePtr = Tcl_NewStringObj(localNameStr, -1); Tcl_IncrRefCount(localNamePtr); result = ObjMakeUpvar(interp, framePtr, varNamePtr, NULL, 0, localNamePtr, 0, -1); Tcl_DecrRefCount(localNamePtr); return result; } /* *---------------------------------------------------------------------- * * Tcl_GetVariableFullName -- * * Given a Tcl_Var token returned by Tcl_FindNamespaceVar, this function |
︙ |
Changes to tests/apply.test.
︙ | |||
45 46 47 48 49 50 51 | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | - + | } {1 {argument with no name} {argument with no name (parsing lambda expression "{{}} boo") invoked from within "apply $lambda"}} test apply-2.3 {malformed lambda} { set lambda [list {{a b c}} boo] list [catch {apply $lambda} msg] $msg $::errorInfo |
︙ |
Changes to tests/info.test.
︙ | |||
36 37 38 39 40 41 42 | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | - + | test info-1.1 {info args option} { proc t1 {a bbb c} {return foo} info args t1 } {a bbb c} test info-1.2 {info args option} { proc t1 {{a default1} {bbb default2} {c default3} args} {return foo} |
︙ | |||
674 675 676 677 678 679 680 | 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 | - + - + - + - + | unset functions msg test info-21.1 {miscellaneous error conditions} -returnCodes error -body { info } -result {wrong # args: should be "info subcommand ?arg ...?"} test info-21.2 {miscellaneous error conditions} -returnCodes error -body { info gorp |
︙ | |||
2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 | 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } -body { demo } -cleanup { unset -nocomplain body rename demo {} rename probe {} } -result 3 # ------------------------------------------------------------------------- # info argspec test info-40-0 {info argspec missing type} -body { info argspec } -returnCodes error -result {wrong # args: should be "info argspec type ..."} test info-40-1 {info argspec proc with old-style proc} { proc p { a { b 1 } { c {} } } {} list [info argspec proc p a] [info argspec proc p b] [info argspec proc p c] } {{} {-default 1} {-default {}}} test info-40-2 {info argspec proc missing procname} -body { info argspec proc } -returnCodes error -result {wrong # args: should be "info argspec proc procname ?arg?"} test info-40-3 {info argspec proc too many args} -body { info argspec proc proc arg foo } -returnCodes error -result {wrong # args: should be "info argspec proc procname ?arg?"} test info-40-4 {info argspec proc unknown proc} -body { info argspec proc fooproc x } -returnCodes error -result {"fooproc" isn't a procedure} test info-40-5 {info argspec proc unknown arg} -body { proc p {a} {} info argspec proc p x } -returnCodes error -result {proc "p" doesn't have an argument "x"} test info-40-6 {info argspec proc on local variable} -body { proc p {a} {set x 0} info argspec proc p x } -returnCodes error -result {proc "p" doesn't have an argument "x"} test info-40-7 {info argspec proc with new-style proc} { proc p { { a -default 2 } { b -upvar #1 } { c -required 0 } } {} list [info argspec proc p a] [info argspec proc p b] [info argspec proc p c] } {{-default 2} {-upvar #1} {-required 0}} test info-40-8 {info argspec proc with multiple named args} { proc p { { a -default 0 -name val -switch {flag1 { flag2 22 }} -name {val2}} } {} info argspec proc p a } {-default 0 -name {val val2} -switch {flag1 {flag2 22}}} test info-40-9 {info argspec proc without arg} { proc p { { a -default 2 } { b -name {B B1} -required 1 } args } {} info argspec proc p } {{a -default 2} {b -required 1 -name {B B1}} args} test info-40-10 {info argspec unknown type} -body { info argspec foo } -returnCodes error -result {bad type "foo": must be proc, lambda, constructor, method, objmethod, or specifiers} test info-40-11 {info argspec lambda} { set l [list {{a -name A} {b -default 5}} {list $a $b}] list [info argspec lambda $l] [info argspec lambda $l a] } {{{a -name A} {b -default 5}} {-name A}} test info-40-12 {info argspec lambda not a lambda} -body { proc p {} {} info argspec lambda p } -returnCodes error -result {can't interpret "p" as a lambda expression} test info-40-13 {info argspec specifiers} { info argspec specifiers } {-default -name -required -switch -upvar} test info-40-14 {info argspec objmethod} -setup { oo::object create foo } -body { oo::objdefine foo method bar {a {b B} {c -switch {{C 1}} -default 0}} {} list [info argspec objmethod foo bar] [info argspec objmethod foo bar c] } -cleanup { foo destroy } -result {{a {b -default B} {c -default 0 -switch {{C 1}}}} {-default 0 -switch {{C 1}}}} test info-40-15 {info argspec constructor} -setup { oo::class create testClass { constructor {{a -default 0 -name A}} { } } } -body { list [info argspec constructor testClass] [info argspec constructor testClass a] } -cleanup { testClass destroy } -result {{{a -default 0 -name A}} {-default 0 -name A}} test info-40-16 {info argspec method} -setup { oo::class create testClass { method m {a {b -required 0}} { } } } -body { list [info argspec method testClass m] [info argspec method testClass m b] } -cleanup { testClass destroy } -result {{a {b -required 0}} {-required 0}} # cleanup catch {namespace delete test_ns_info1 test_ns_info2} ::tcltest::cleanupTests return |
Changes to tests/oo.test.
︙ | |||
3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 | 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } {} test oo-35.4 {Bug 593baa032c: mixins list teardown} { # Bug makes this crash, especially with mem-debugging on oo::class create B {} oo::class create D {mixin B} namespace eval [info object namespace D] [list [namespace which B] destroy] } {} # TIP457-related tests test oo-36.1 {OO/CloneProcedureMethod with extended argspec} { oo::object create foo oo::objdefine foo { method p { {x -default off -switch {{ON on}}} } { lappend ::result [self object] >$x< } } set result {} foo p; foo p -ON oo::copy foo bar bar p; bar p -ON foo destroy; bar destroy set result } {::foo >off< ::foo >on< ::bar >off< ::bar >on<} catch {foo destroy} catch {bar destroy} test oo-36.2 {OO/clonedBody with extended argspec} -setup { oo::class create ArbitraryClass {export eval} } -body { ArbitraryClass create a a eval {proc foo {a {n -name num -default 3}} { return [string repeat $a $n] }} set result [a eval {foo A -num 2}] oo::copy a b lappend result [b eval {foo B -num 4}] [b eval {foo C}] } -cleanup { ArbitraryClass destroy } -result {AA BBBB CCC} test oo-36.3 {"info object definition" with extended argspec} -setup { oo::object create foo } -body { oo::objdefine foo method bar {a {b B} {c -switch {{C 1}} -default 0} {d -upvar 1} args} {body} set result [info object definition foo bar] } -cleanup { foo destroy } -result {{a {b B} {c -default 0 -switch {{C 1}}} {d -upvar 1} args} body} test oo-36.4 {"info class definition" with extended argspec} -setup { oo::class create foo } -body { oo::define foo method bar {a {b 8} {c -name C} {d -name D -upvar 1} args} {body} set result [info class definition foo bar] } -cleanup { foo destroy } -result {{a {b 8} {c -name C} {d -upvar 1 -name D} args} body} test oo-36.5 {OO constructor with extended argspec} { oo::class create testClass { constructor {{a -default 0 -name A}} { global result lappend result [self object] $a } } set result {} testClass create foo1 testClass create foo2 -A 5 testClass destroy return $result } {::foo1 0 ::foo2 5} cleanupTests return # Local Variables: # mode: tcl |
︙ |
Added tests/proc-enh.test.