Index: TODO =================================================================== diff -u -rfcf8f9a57798757bcf7f2463a8ab6a9b49d3422f -rb37bf2deab94b6294509fa79bb7b922d6e8a5635 --- TODO (.../TODO) (revision fcf8f9a57798757bcf7f2463a8ab6a9b49d3422f) +++ TODO (.../TODO) (revision b37bf2deab94b6294509fa79bb7b922d6e8a5635) @@ -3521,16 +3521,17 @@ nsf::config(profile) = 0 -build-environment: +- build-environment: * make configure.in Makefile.in more in line with the TEA sample app (removing leftovers from prior versions of TEA) * remove GNU-Makefile-isms from Makefile.in -nsf.c: +- nsf.c: * provide an intermediary fix for the final memcount problem of elements in on the iPtr->errorStack * improve iPtr cleanup for memcount debugging +- added configure option: enable-assertions (default on) TODO: - private: Index: configure =================================================================== diff -u -r60d83a2fa5b5b46b6aa49e61ccc4ac4533cfeb88 -rb37bf2deab94b6294509fa79bb7b922d6e8a5635 --- configure (.../configure) (revision 60d83a2fa5b5b46b6aa49e61ccc4ac4533cfeb88) +++ configure (.../configure) (revision b37bf2deab94b6294509fa79bb7b922d6e8a5635) @@ -742,6 +742,7 @@ enable_profile enable_memcount enable_development +enable_assertions with_tcl with_tclinclude enable_threads @@ -1373,12 +1374,13 @@ --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-profile build nsf with profile support (default disabled) + --enable-profile build nsf with profile support (default: disabled) --enable-memcount=yes|trace - build nsf with memcount debug support (default + build nsf with memcount debug support (default: disabled) - --enable-development build nsf with development support (assertion - checking, etc.; default disabled) + --enable-development build nsf with development support (intensive + runtime checking, etc.; default: disabled) + --enable-assertions build nsf with assertion support (default: enabled) --enable-threads build with threads --enable-shared build and link with shared libraries (default: on) --enable-64bit enable 64bit support (default: off) @@ -2404,7 +2406,14 @@ enable_development=no fi +# Check whether --enable-assertions was given. +if test "${enable_assertions+set}" = set; then : + enableval=$enable_assertions; enable_assertions=$enableval +else + enable_assertions=yes +fi + subdirs="" if test "$with_actiweb" = yes; then @@ -5530,6 +5539,12 @@ fi +if test "$enable_assertions" = yes; then + +$as_echo "#define NSF_WITH_ASSERTIONS 1" >>confdefs.h + +fi + if test "$enable_profile" = yes; then $as_echo "#define NSF_PROFILE 1" >>confdefs.h Index: configure.in =================================================================== diff -u -r60d83a2fa5b5b46b6aa49e61ccc4ac4533cfeb88 -rb37bf2deab94b6294509fa79bb7b922d6e8a5635 --- configure.in (.../configure.in) (revision 60d83a2fa5b5b46b6aa49e61ccc4ac4533cfeb88) +++ configure.in (.../configure.in) (revision b37bf2deab94b6294509fa79bb7b922d6e8a5635) @@ -52,16 +52,20 @@ AC_HELP_STRING([--with-dtrace], [build nsf with dtrace (default: without)]), [with_dtrace=$enableval], [with_dtrace=no]) AC_ARG_ENABLE(profile, - AC_HELP_STRING([--enable-profile], [build nsf with profile support (default disabled)]), + AC_HELP_STRING([--enable-profile], [build nsf with profile support (default: disabled)]), [enable_profile=$enableval], [enable_profile=no]) AC_ARG_ENABLE(memcount, AC_HELP_STRING([--enable-memcount=yes|trace], - [build nsf with memcount debug support (default disabled)]), + [build nsf with memcount debug support (default: disabled)]), [enable_memcount=$enableval], [enable_memcount=no]) AC_ARG_ENABLE(development, AC_HELP_STRING([--enable-development], - [build nsf with development support (assertion checking, etc.; default disabled)]), + [build nsf with development support (intensive runtime checking, etc.; default: disabled)]), [enable_development=$enableval], [enable_development=no]) +AC_ARG_ENABLE(assertions, + AC_HELP_STRING([--enable-assertions], + [build nsf with assertion support (default: enabled)]), + [enable_assertions=$enableval], [enable_assertions=yes]) subdirs="" @@ -177,6 +181,10 @@ AC_DEFINE(HAVE_TCL_COMPILE_H, 1, [Do we have tclCompile.h installed?]) fi +if test "$enable_assertions" = yes; then + AC_DEFINE(NSF_WITH_ASSERTIONS, 1, [Are we building with assertions support?]) +fi + if test "$enable_profile" = yes; then AC_DEFINE(NSF_PROFILE, 1, [Are we building with profile support?]) fi Index: generic/nsf.c =================================================================== diff -u -rfcf8f9a57798757bcf7f2463a8ab6a9b49d3422f -rb37bf2deab94b6294509fa79bb7b922d6e8a5635 --- generic/nsf.c (.../nsf.c) (revision fcf8f9a57798757bcf7f2463a8ab6a9b49d3422f) +++ generic/nsf.c (.../nsf.c) (revision b37bf2deab94b6294509fa79bb7b922d6e8a5635) @@ -294,7 +294,6 @@ static int NextSearchAndInvoke(Tcl_Interp *interp, CONST char *methodName, int objc, Tcl_Obj *CONST objv[], NsfCallStackContent *cscPtr, int freeArgumentVector); -static void AssertionRemoveProc(NsfAssertionStore *aStore, CONST char *name); static void NsfCommandPreserve(Tcl_Command cmd); static void NsfCommandRelease(Tcl_Command cmd); @@ -303,6 +302,10 @@ static int MethodSourceMatches(int withSource, NsfClass *cl, NsfObject *object); static void DeleteNsfProcs(Tcl_Interp *interp, Tcl_Namespace *nsPtr); +#if defined(NSF_WITH_ASSERTIONS) +static void AssertionRemoveProc(NsfAssertionStore *aStore, CONST char *name); +#endif + #ifdef DO_FULL_CLEANUP static void DeleteProcsAndVars(Tcl_Interp *interp, Tcl_Namespace *nsPtr, int withKeepvars); #endif @@ -8674,9 +8677,9 @@ static int ProcMethodDispatchFinalize(ClientData data[], Tcl_Interp *interp, int result) { ParseContext *pcPtr = data[0]; - NsfCallStackContent *cscPtr = data[1]; /*CONST char *methodName = data[2];*/ #if defined(NSF_WITH_ASSERTIONS) + NsfCallStackContent *cscPtr = data[1]; NsfObject *object = cscPtr->self; NsfObjectOpt *opt = object->opt; #endif @@ -11531,6 +11534,13 @@ interp, nameObj, args, body, precondition, postcondition, defObject, regObject, cl == NULL, withInner_namespace); #else + if (precondition) { + NsfLog(interp, NSF_LOG_WARN, "Precondition %s provided, but not compiled with assertion enabled", + ObjStr(precondition)); + } else if (postcondition) { + NsfLog(interp, NSF_LOG_WARN, "Postcondition %s provided, but not compiled with assertion enabled", + ObjStr(postcondition)); + } result = MakeProc(cl ? cl->nsPtr : defObject->nsPtr, NULL, interp, nameObj, args, body, NULL, NULL, defObject, regObject, cl == NULL, withInner_namespace); Index: generic/nsf.h =================================================================== diff -u -r7c0fa49f01d0a37ccb4e36778e72ac1c1e3f6b30 -rb37bf2deab94b6294509fa79bb7b922d6e8a5635 --- generic/nsf.h (.../nsf.h) (revision 7c0fa49f01d0a37ccb4e36778e72ac1c1e3f6b30) +++ generic/nsf.h (.../nsf.h) (revision b37bf2deab94b6294509fa79bb7b922d6e8a5635) @@ -79,16 +79,16 @@ #define NSF_DEVELOPMENT 1 */ -/* activate/deacticate assert +/* activate/deactivate assert #define NDEBUG 1 */ /* additional language features #define NSF_WITH_INHERIT_NAMESPACES 1 +#define NSF_WITH_ASSERTIONS 1 */ #define NSF_WITH_OS_RESOLVER 1 -#define NSF_WITH_ASSERTIONS 1 #define NSF_WITH_VALUE_WARNINGS 1 /* activate/deacticate memory tracing Index: generic/nsfDebug.c =================================================================== diff -u -r5575658e6ea9c0f22a38223960a6c242e809dd67 -rb37bf2deab94b6294509fa79bb7b922d6e8a5635 --- generic/nsfDebug.c (.../nsfDebug.c) (revision 5575658e6ea9c0f22a38223960a6c242e809dd67) +++ generic/nsfDebug.c (.../nsfDebug.c) (revision b37bf2deab94b6294509fa79bb7b922d6e8a5635) @@ -31,6 +31,7 @@ */ void NsfReportVars(Tcl_Interp *interp) { + Tcl_SetVar(interp, "::nsf::version", NSF_VERSION, TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "::nsf::patchLevel", NSF_PATCHLEVEL, TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "::nsf::config(development)", @@ -40,34 +41,46 @@ "0", #endif TCL_GLOBAL_ONLY); + Tcl_SetVar(interp, "::nsf::config(memcount)", #ifdef NSF_MEM_COUNT "1", #else "0", #endif TCL_GLOBAL_ONLY); + Tcl_SetVar(interp, "::nsf::config(memtrace)", #ifdef NSF_MEM_TRACE "1", #else "0", #endif TCL_GLOBAL_ONLY); + Tcl_SetVar(interp, "::nsf::config(profile)", #ifdef NSF_PROFILE "1", #else "0", #endif TCL_GLOBAL_ONLY); + Tcl_SetVar(interp, "::nsf::config(dtrace)", #ifdef NSF_DTRACE "1", #else "0", #endif TCL_GLOBAL_ONLY); + + Tcl_SetVar(interp, "::nsf::config(assertions)", +#ifdef NSF_WITH_ASSERTIONS + "1", +#else + "0", +#endif + TCL_GLOBAL_ONLY); } /* Index: library/xotcl/library/xotcl2.tcl =================================================================== diff -u -r622880fd54236d56d371bd5726e7abcbef47a74a -rb37bf2deab94b6294509fa79bb7b922d6e8a5635 --- library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 622880fd54236d56d371bd5726e7abcbef47a74a) +++ library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision b37bf2deab94b6294509fa79bb7b922d6e8a5635) @@ -248,7 +248,6 @@ ::nsf::method::property Class dealloc redefine-protected true ::nsf::method::property Class create redefine-protected true - # # define parametercmd and instparametercmd in terms of ::nsf::setter # define filterguard and instfilterguard in terms of filterguard Index: library/xotcl/tests/testx.xotcl =================================================================== diff -u -ra24e1f836c3126d0a0e9467bde3a9fa8da901711 -rb37bf2deab94b6294509fa79bb7b922d6e8a5635 --- library/xotcl/tests/testx.xotcl (.../testx.xotcl) (revision a24e1f836c3126d0a0e9467bde3a9fa8da901711) +++ library/xotcl/tests/testx.xotcl (.../testx.xotcl) (revision b37bf2deab94b6294509fa79bb7b922d6e8a5635) @@ -143,7 +143,13 @@ @ TestX assertions { description {Regression test object testing the assertions.} } + TestX assertions -proc run {{n 20}} { + + if {!$::nsf::config(assertions)} { + return + } + for {set i 0} {$i < $n} {incr i} { Class C($i) @@ -279,14 +285,17 @@ if {![catch {b yTo2} err]} { set err "ok" } - ::errorCheck $err {Assertion failed check: {$y == 1} in proc 'yTo2'} \ - "inheritance b yTo2" + ::errorCheck $err {Assertion failed check: {$y == 1} in proc 'yTo2'} \ + "inheritance b yTo2" + + a destroy } @ TestX filterAddRemove { description {Regression test object testing adding/removing of filters.} } TestX filterAddRemove -proc run {{n 20}} { + set ::filterCount 0 for {set i 0} {$i < $n} {incr i} { Class SA($i) @@ -443,7 +452,8 @@ global filterResult set filterResult "" - Object a + + Object a -requireNamespace a set o 12 a set p 13 Class A @@ -457,7 +467,7 @@ ::append filterResult " $o $p $m" next } - + proc x {} { set ::a::e xxx } @@ -467,14 +477,14 @@ x ::errorCheck $::a::e xxx \ - "filterAddRemove: instvar test -- proc set failed" + "filterAddRemove: instvar test -- proc set failed" a set e yyy ::errorCheck $::a::e yyy \ - "filterAddRemove: instvar test -- obj set failed" + "filterAddRemove: instvar test -- obj set failed" ::errorCheck $filterResult " ::A instvar f 12 13 14 ::a set run 12 13 14" \ - "filterAddRemove: instvar test -- instvar filter failed" + "filterAddRemove: instvar test -- instvar filter failed" Object instfilter "" @@ -2539,6 +2549,7 @@ } TestX copymove -proc run {{n 10}} { + # Composite Class Composite -superclass Class Composite instproc addop {op} { @@ -2621,9 +2632,11 @@ ::errorCheck "[::cutSpaces [V info parameter]--[v set param1]--[v set param2]]" \ " {param1 1} {param2 2} --1--2" \ "parameter test" - ::errorCheck "[::cutSpaces [V info instinvar]--[V info instpre assProc]--[V info instpost assProc]]"\ - "{7 > 6} { #a comment }--{5 > 4} { #pre }--{5 > 4} { #post }"\ - "Copy Class Assertions" + if {$::nsf::config(assertions)} { + ::errorCheck "[::cutSpaces [V info instinvar]--[V info instpre assProc]--[V info instpost assProc]]"\ + "{7 > 6} { #a comment }--{5 > 4} { #pre }--{5 > 4} { #post }"\ + "Copy Class Assertions" + } ::errorCheck [V info instforward -definition a] "b" "copied instforward" ::errorCheck [V info forward -definition c] "d" "copied forward" #::errorCheck "[V info metadata]--[V metadata Author]--[V metadata Version]--[V metadata Nothing]"\ @@ -2685,12 +2698,14 @@ x copy y ::errorCheck "[x p1]--[x set var1]--[::x info class]" "::x-p1--12--::O"\ - "Simple Copy - Origin" + "Simple Copy - Origin" ::errorCheck "[y p1]--[y set var1]--[::y info class]" "::y-p1--12--::O"\ - "Simple Copy - Duplicate" - ::errorCheck "[::cutSpaces [y info invar]--[y info pre assProc]--[y info post assProc]]"\ - "{7 > 5} { #a comment }--{5 > 3} { #pre }--{5 > 4} {#post }"\ - "Copy Obj Assertions" + "Simple Copy - Duplicate" + if {$::nsf::config(assertions)} { + ::errorCheck "[::cutSpaces [y info invar]--[y info pre assProc]--[y info post assProc]]"\ + "{7 > 5} { #a comment }--{5 > 3} { #pre }--{5 > 4} {#post }"\ + "Copy Obj Assertions" + } # # move test # @@ -2705,9 +2720,11 @@ ::errorCheck "[::cutSpaces [V info parameter]--[v set param1]--[v set param2]]" \ " {param1 1} {param2 2} --1--2" \ "parameter move test" - ::errorCheck "[::cutSpaces [V info instinvar]--[V info instpre assProc]--[V info instpost assProc]]"\ - "{7 > 6} { #a comment }--{5 > 4} { #pre }--{5 > 4} { #post }"\ - "Move Class Assertions" + if {$::nsf::config(assertions)} { + ::errorCheck "[::cutSpaces [V info instinvar]--[V info instpre assProc]--[V info instpost assProc]]"\ + "{7 > 6} { #a comment }--{5 > 4} { #pre }--{5 > 4} { #post }"\ + "Move Class Assertions" + } #::errorCheck "[V info metadata]--[V metadata Author]--[V metadata Version]--[V metadata Nothing]"\ "Version Author Nothing--Uwe--0.0.9--"\ "Move Metadata" @@ -3550,6 +3567,7 @@ return $r } condMixins proc run {{n 20}} { + Object instproc signature {} {return "[self] [my info class] ([my age] years)"} Class Person -parameter {id name age} @@ -4266,6 +4284,7 @@ TestX copymove2 -proc run {{n 10}} { + # Composite Class Composite -superclass Class Composite instproc addop {op} { Index: tests/info-method.test =================================================================== diff -u -re529093e5930cb5c9de2bc81cef3eca2585f154f -rb37bf2deab94b6294509fa79bb7b922d6e8a5635 --- tests/info-method.test (.../info-method.test) (revision e529093e5930cb5c9de2bc81cef3eca2585f154f) +++ tests/info-method.test (.../info-method.test) (revision b37bf2deab94b6294509fa79bb7b922d6e8a5635) @@ -101,8 +101,13 @@ ? {C info method definition m} {::C public method m x {return proc-[self proc]}} ? {C info method def m} {::C public method m x {return proc-[self proc]}} ? {C class info method definition mpo} {::C public class method mpo {} {return instproc-[self proc]}} - ? {C info method definition m-with-assertions} \ - {::C public method m-with-assertions {} {return proc-[self proc]} -precondition 1 -postcondition 2} + if {$::nsf::config(assertions)} { + ? {C info method definition m-with-assertions} \ + {::C public method m-with-assertions {} {return proc-[self proc]} -precondition 1 -postcondition 2} + } else { + ? {C info method definition m-with-assertions} \ + {::C public method m-with-assertions {} {return proc-[self proc]}} + } ? {C info method parameter m} {x} ? {nx::Class info method parameter method} \ {name arguments:parameter,0..* -returns body -precondition -postcondition}