Index: TODO =================================================================== diff -u -r27bb1e990885cba2fd62749c714566c01f2ca662 -rfd39317a31fcc1aae5985fb0236901b910b4bae3 --- TODO (.../TODO) (revision 27bb1e990885cba2fd62749c714566c01f2ca662) +++ TODO (.../TODO) (revision fd39317a31fcc1aae5985fb0236901b910b4bae3) @@ -2901,6 +2901,9 @@ (for some unknown reasons, we see crashes from mp_clear) - extend regression test +- improve bignum conversion handling further +- found memleak in tcl + TODO: - in method-require.test # TODO: make me more pretty Index: generic/nsf.c =================================================================== diff -u -re9526ccbad4ba04e46d73d78719ec4aa26312d6a -rfd39317a31fcc1aae5985fb0236901b910b4bae3 --- generic/nsf.c (.../nsf.c) (revision e9526ccbad4ba04e46d73d78719ec4aa26312d6a) +++ generic/nsf.c (.../nsf.c) (revision fd39317a31fcc1aae5985fb0236901b910b4bae3) @@ -162,6 +162,8 @@ *Nsf_OT_byteCodeType = NULL, *Nsf_OT_tclCmdNameType = NULL, *Nsf_OT_listType = NULL, + *Nsf_OT_doubleType = NULL, +//*Nsf_OT_bignumType = NULL, *Nsf_OT_intType = NULL; /* @@ -9467,31 +9469,32 @@ ClientData *clientData, Tcl_Obj **outObjPtr) { int result; - //fprintf(stderr, "type is on call %p %s value %s\n", - // objPtr->typePtr, objPtr->typePtr? objPtr->typePtr->name:"NULL", ObjStr(objPtr)); - /* * Try to short_cut common cases to avoid conversion to bignums, since * Tcl_GetBignumFromObj returns a value, which has to be freed. */ - if (objPtr->typePtr == Nsf_OT_intType) { - //fprintf(stderr, "shortcut\n"); + if (objPtr->typePtr == Nsf_OT_intType /*|| objPtr->typePtr == Nsf_OT_bignumType*/) { + //fprintf(stderr, "shortcut OK\n"); result = TCL_OK; + } else if (objPtr->typePtr == Nsf_OT_doubleType) { + //fprintf(stderr, "shortcut NOT OK\n"); + result = TCL_ERROR; } else { mp_int bignumValue; + + //if (objPtr->typePtr) { + // fprintf(stderr, "type is on call %p %s value %s bignum %p\n", + // objPtr->typePtr, objPtr->typePtr? objPtr->typePtr->name:"NULL", ObjStr(objPtr), + // Nsf_OT_bignumType); + //} + result = Tcl_GetBignumFromObj(interp, objPtr, &bignumValue); //fprintf(stderr, "type after call %p %s\n", - // objPtr->typePtr, objPtr->typePtr? objPtr->typePtr->name:"NULL"); + // objPtr->typePtr, objPtr->typePtr? objPtr->typePtr->name:"NULL"); if (result == TCL_OK) { - //fprintf(stderr, "call clear used %d alloc %d sign %d dp %p\n", bignumValue.used, bignumValue.alloc, bignumValue.sign, bignumValue.dp); - //foo(); - - /* for some unknown reasons, the folloing call crashes */ mp_clear(&bignumValue); - - //fprintf(stderr, "call clear DONE\n"); } } @@ -20970,15 +20973,20 @@ Nsf_OT_intType = Tcl_GetObjType("int"); assert(Nsf_OT_intType); + + Nsf_OT_doubleType = Tcl_GetObjType("double"); + assert(Nsf_OT_doubleType); + #if 0 { - mp_int bignumValue = {NULL}; + mp_int bignumValue; Tcl_Obj *objPtr; - // also this crashes mp_init(&bignumValue); objPtr = Tcl_NewBignumObj(&bignumValue); Nsf_OT_bignumType = objPtr->typePtr; + DECR_REF_COUNT(objPtr); + //mp_clear(&bignumValue); } assert(Nsf_OT_bignumType); #endif Index: tests/parameters.test =================================================================== diff -u -r27bb1e990885cba2fd62749c714566c01f2ca662 -rfd39317a31fcc1aae5985fb0236901b910b4bae3 --- tests/parameters.test (.../parameters.test) (revision 27bb1e990885cba2fd62749c714566c01f2ca662) +++ tests/parameters.test (.../parameters.test) (revision fd39317a31fcc1aae5985fb0236901b910b4bae3) @@ -1673,6 +1673,7 @@ ? {o foo [expr {wide(2 ** 63)}]} "-9223372036854775808" + ? {o foo [expr {2.0}]} {expected integer but got "2.0" for parameter "x"} ? {o foo [expr {2.0 * 2}]} {expected integer but got "4.0" for parameter "x"} ? {o foo [expr {2.0 ** 128}]} {expected integer but got "3.4028236692093846e+38" for parameter "x"} ? {o foo [expr {(2 ** 128)*1.0}]} {expected integer but got "3.4028236692093846e+38" for parameter "x"}