466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
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
|
*
* Helper functions for LinkTraceProc and ObjValue. These are all
* factored out here to make those functions simpler.
*
*----------------------------------------------------------------------
*/
static inline int
GetInt(
Tcl_Obj *objPtr,
int *intPtr)
{
return (Tcl_GetIntFromObj(NULL, objPtr, intPtr) != TCL_OK
&& GetInvalidIntFromObj(objPtr, intPtr) != TCL_OK);
}
static inline int
GetWide(
Tcl_Obj *objPtr,
Tcl_WideInt *widePtr)
{
if (TclGetWideIntFromObj(NULL, objPtr, widePtr) != TCL_OK) {
int intValue;
if (GetInvalidIntFromObj(objPtr, &intValue) != TCL_OK) {
return 1;
}
*widePtr = intValue;
}
return 0;
}
static inline int
GetUWide(
Tcl_Obj *objPtr,
Tcl_WideUInt *uwidePtr)
{
if (Tcl_GetWideUIntFromObj(NULL, objPtr, uwidePtr) != TCL_OK) {
int intValue;
if (GetInvalidIntFromObj(objPtr, &intValue) != TCL_OK) {
return 1;
}
*uwidePtr = intValue;
}
return 0;
}
static inline int
GetDouble(
Tcl_Obj *objPtr,
double *dblPtr)
{
if (Tcl_GetDoubleFromObj(NULL, objPtr, dblPtr) == TCL_OK) {
return 0;
} else {
#ifdef ACCEPT_NAN
Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objPtr, &tclDoubleType);
if (irPtr != NULL) {
*dblPtr = irPtr->doubleValue;
return 0;
}
#endif /* ACCEPT_NAN */
return GetInvalidDoubleFromObj(objPtr, dblPtr) != TCL_OK;
}
}
static inline int
EqualDouble(
double a,
double b)
{
return (a == b)
#ifdef ACCEPT_NAN
|| (isnan(a) && isnan(b))
#endif /* ACCEPT_NAN */
;
}
static inline int
IsSpecial(
double a)
{
return isinf(a)
#ifdef ACCEPT_NAN
|| isnan(a)
#endif /* ACCEPT_NAN */
|
|
|
|
|
|
|
|
|
|
|
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
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
|
*
* Helper functions for LinkTraceProc and ObjValue. These are all
* factored out here to make those functions simpler.
*
*----------------------------------------------------------------------
*/
static inline bool
GetInt(
Tcl_Obj *objPtr,
int *intPtr)
{
return (Tcl_GetIntFromObj(NULL, objPtr, intPtr) != TCL_OK
&& GetInvalidIntFromObj(objPtr, intPtr) != TCL_OK);
}
static inline int
GetWide(
Tcl_Obj *objPtr,
Tcl_WideInt *widePtr)
{
if (TclGetWideIntFromObj(NULL, objPtr, widePtr) != TCL_OK) {
int intValue;
if (GetInvalidIntFromObj(objPtr, &intValue) != TCL_OK) {
return TCL_ERROR;
}
*widePtr = intValue;
}
return TCL_OK;
}
static inline int
GetUWide(
Tcl_Obj *objPtr,
Tcl_WideUInt *uwidePtr)
{
if (Tcl_GetWideUIntFromObj(NULL, objPtr, uwidePtr) != TCL_OK) {
int intValue;
if (GetInvalidIntFromObj(objPtr, &intValue) != TCL_OK) {
return TCL_ERROR;
}
*uwidePtr = intValue;
}
return TCL_OK;
}
static inline int
GetDouble(
Tcl_Obj *objPtr,
double *dblPtr)
{
if (Tcl_GetDoubleFromObj(NULL, objPtr, dblPtr) == TCL_OK) {
return TCL_OK;
} else {
#ifdef ACCEPT_NAN
Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objPtr, &tclDoubleType);
if (irPtr != NULL) {
*dblPtr = irPtr->doubleValue;
return TCL_OK;
}
#endif /* ACCEPT_NAN */
return GetInvalidDoubleFromObj(objPtr, dblPtr) != TCL_OK;
}
}
static inline bool
EqualDouble(
double a,
double b)
{
return (a == b)
#ifdef ACCEPT_NAN
|| (isnan(a) && isnan(b))
#endif /* ACCEPT_NAN */
;
}
static inline bool
IsSpecial(
double a)
{
return isinf(a)
#ifdef ACCEPT_NAN
|| isnan(a)
#endif /* ACCEPT_NAN */
|
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
|
TCL_UNUSED(const char *) /*name2*/,
/* Links can only be made to global variables,
* so we can find them with need to resolve
* caller-supplied name in caller context. */
int flags) /* Miscellaneous additional information. */
{
Link *linkPtr = (Link *)clientData;
int changed;
Tcl_Size valueLength = 0;
const char *value;
char **pp;
Tcl_Obj *valueObj;
int valueInt;
Tcl_WideInt valueWide;
Tcl_WideUInt valueUWide;
|
|
|
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
|
TCL_UNUSED(const char *) /*name2*/,
/* Links can only be made to global variables,
* so we can find them with need to resolve
* caller-supplied name in caller context. */
int flags) /* Miscellaneous additional information. */
{
Link *linkPtr = (Link *)clientData;
bool changed;
Tcl_Size valueLength = 0;
const char *value;
char **pp;
Tcl_Obj *valueObj;
int valueInt;
Tcl_WideInt valueWide;
Tcl_WideUInt valueUWide;
|
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
|
break;
case TCL_LINK_FLOAT:
changed = !EqualDouble(LinkedVar(float), linkPtr->lastValue.f);
break;
case TCL_LINK_STRING:
case TCL_LINK_CHARS:
case TCL_LINK_BINARY:
changed = 1;
break;
default:
changed = 0;
/* return (char *) "internal error: bad linked variable type"; */
}
}
if (changed) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
}
|
|
|
|
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
|
break;
case TCL_LINK_FLOAT:
changed = !EqualDouble(LinkedVar(float), linkPtr->lastValue.f);
break;
case TCL_LINK_STRING:
case TCL_LINK_CHARS:
case TCL_LINK_BINARY:
changed = true;
break;
default:
changed = false;
/* return (char *) "internal error: bad linked variable type"; */
}
}
if (changed) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr),
TCL_GLOBAL_ONLY);
}
|