1 # vim: ft=tcl foldmethod=marker foldmarker=<<<,>>> ts=4 shiftwidth=4
3 class tlc
::Refcounted {
8 method object_registry
{varname
}
17 method autoscoperef
{}
24 method clear_registry
{}
25 method reflog
{lvl msg args
}
30 body tlc
::Refcounted::constructor {} { #<<<
34 body tlc
::Refcounted::destructor {} { #<<<
39 body tlc
::Refcounted::autoscoperef {} { #<<<
40 reflog debug
"Refcounted::constructor callstack: [tlc::stackdump]"
41 upvar 2 _tlc_refcounted_scoperef_
[string map
{:: //} $this] scopevar
43 trace variable scopevar u
[code
$this decref
"scopevar unset"]
47 body tlc
::Refcounted::incref {args
} { #<<<
50 reflog debug
"$this: refcount $old -> $refcount ($args)"
54 body tlc
::Refcounted::decref {args
} { #<<<
57 reflog debug
"$this: refcount $old -> $refcount ($args)"
59 reflog debug
"$this: our time has come"
66 body tlc
::Refcounted::refcount {} { #<<<
71 body tlc
::Refcounted::object_registry {varname
} { #<<<
74 set registry_var
$varname
75 upvar $registry_var var_ref
81 body tlc
::Refcounted::clear_registry {} { #<<<
82 if {[info exists registry_var
]} {
83 upvar $registry_var old_registry
84 if {[info exists old_registry
]} {
91 body tlc
::Refcounted::reflog {lvl msg args
} { #<<<
93 uplevel 1 $log_cmd [list $lvl $msg {*}$args]