Index: doc/Object.man =================================================================== diff -u -rf52d344b772763bfd59bc41294e7a45a336b2346 -rbaee0c34119f4b237787204b8c3e64bc04c05782 --- doc/Object.man (.../Object.man) (revision f52d344b772763bfd59bc41294e7a45a336b2346) +++ doc/Object.man (.../Object.man) (revision baee0c34119f4b237787204b8c3e64bc04c05782) @@ -20,7 +20,7 @@ [vset CMD "obj"] [vset MODIFIER "object"] -[copyright {2014-16 Stefan Sobernig , Gustaf Neumann ; available under the Creative Commons Attribution 3.0 Austria license (CC BY 3.0 AT).}] +[copyright {2014-19 Stefan Sobernig , Gustaf Neumann ; available under the Creative Commons Attribution 3.0 Austria license (CC BY 3.0 AT).}] [moddesc "NX API"] [titledesc {API reference of the base class in the NX object system}] @@ -743,6 +743,108 @@ [list_end] +[cmd_def uplevel] + +[list_begin definitions] + +[call [arg obj] [method uplevel] [opt [arg level]] [arg arg1] [opt "[arg arg2] ..."]] + +Evaluate a script or a command at a different stack-frame +level. Behaves like Tcl's [cmd uplevel], with the following +important exceptions. + +[list_begin itemized] + +[item] If the [arg level] specifier is omitted, [method "uplevel"] +will skip any auxiliary frames added to the stack by active [term "filter"]s and [term "mixin"]s. The +resulting stack-frame level corresponds to the [term "callinglevel"] +as indicated by [cmd nx::current]. + +[item] If the [arg level] specifier is omitted, [method uplevel] gives +preference to the innermost enclosing procedure call, i.e., a frame +corresponding to a proc, method, or apply call. Any frames inbetween, +incl. those of filters and mixins (see above), will be skipped. + +[item] If the [arg level] specifier is provided (relative, or +absolute), [method "uplevel"] will move execution into the requested +stack-frame level (incl. those introduced by active active [term "filter"]s and +[term "mixin"]s), if valid. + +[list_end] + +[example { + % nx::Object create ::obj + ::obj + % ::obj public object method foo {varName} { + :uplevel set $varName 1; return + } + ::obj::foo + % namespace eval ::ns1 { + ::obj foo BAR + } + % namespace eval ::ns1 { + info exists BAR + } + 1 +}] + +[list_end] + +Note, in the example above, [method "uplevel"] is guaranteed to +resolve to the calling context of [method "foo"] ([term "ns1"]) despite +mixins and filters being (potentially) registered on [cmd "obj"]. + +[cmd_def upvar] + +[list_begin definitions] + +[call [arg obj] [method upvar] [opt [arg level]] [arg otherVar1] [arg localVar1] [opt "[arg otherVar2] [arg localVar2] ..."]] + +Links one or more local variables to variables defined for other +scopes (namespaces, objects, call frames). Behaves like Tcl's [cmd "upvar"], +with the following important exceptions. + +[list_begin itemized] + +[item] If the [arg level] specifier is omitted, [method "upvar"] +will skip any auxiliary frames added to the stack by active [term "filter"]s and [term "mixin"]s. The +resulting stack-frame level corresponds to the [term "callinglevel"] +as indicated by [cmd nx::current]. + +[item] If the [arg level] specifier is omitted, [method upvar] gives +preference to the innermost enclosing procedure call, i.e., a frame +corresponding to a proc, method, or apply call. Any frames inbetween, +incl. those of filters and mixins (see above), will be skipped. + +[item] If the [arg level] specifier is provided (relative, or +absolute), [method "upvar"] will link into the requested +stack-frame level (incl. those introduced by active active [term "filter"]s and +[term "mixin"]s), if valid. + +[list_end] + +[example { + % nx::Object create ::obj + ::obj + % ::obj public object method foo {varName} { + :upvar $varName x; set x 1; return + } + ::obj::foo + % namespace eval ::ns1 { + ::obj foo BAR + } + % namespace eval ::ns1 { + info exists BAR + } + 1 +}] + +[list_end] + +Note, in the example above, [method "upvar"] is guaranteed to +resolve to the calling context of [method "foo"] ([term "ns1"]) despite +mixins and filters being (potentially) registered on [cmd "obj"]. + [cmd_def variable] [list_begin definitions]