Skip to content
Permalink
Browse files

Use variable traces for the option proc handlers

git-svn-id: https://svn.macports.org/repository/macports/trunk/base@4105 d073be05-634f-4543-b044-5fe20cf6d1d6
  • Loading branch information
landonf committed Dec 1, 2003
1 parent cdde0e5 commit 52cc00af729ecbc073ae074c9b772efc88498261
Showing with 21 additions and 18 deletions.
  1. +21 −18 src/port1.0/portutil.tcl
@@ -101,11 +101,6 @@ proc options {args} {
global ${option} user_options option_procs \n\
\if \{!\[info exists user_options(${option})\]\} \{ \n\
set ${option} \$args \n\
if \{\[info exists option_procs($option)\]\} \{ \n\
foreach p \$option_procs($option) \{ \n\
eval \"\$p $option set \$args\" \n\
\} \n\
\} \n\
\} \n\
\}"

@@ -118,11 +113,6 @@ proc options {args} {
if \{\[string length \$\{${option}\}\] == 0\} \{ \n\
unset ${option} \n\
\} \n\
if \{\[info exists option_procs($option)\]\} \{ \n\
foreach p \$option_procs($option) \{ \n\
eval \"\$p $option delete \$args\" \n\
\} \n\
\} \n\
\} \n\
\}"
eval "proc ${option}-append {args} \{ \n\
@@ -133,11 +123,6 @@ proc options {args} {
\} else \{ \n\
set ${option} \$args \n\
\} \n\
if \{\[info exists option_procs($option)\]\} \{ \n\
foreach p \$option_procs($option) \{ \n\
eval \"\$p $option append \$args\" \n\
\} \n\
\} \n\
\} \n\
\}"
}
@@ -185,15 +170,33 @@ proc option_proc {option args} {
global option_procs $option
eval "lappend option_procs($option) $args"
# Add a read trace to the variable, as the option procedures have no access to reads
trace variable $option r option_proc_trace
trace variable $option rwu option_proc_trace
}

# option_proc_trace
# trace handler for option reads. Calls option procedures with correct arguments.
proc option_proc_trace {optionName index op} {
global option_procs
foreach p $option_procs($optionName) {
eval "$p $optionName read"
switch $op {
w {
foreach p $option_procs($optionName) {
eval "$p $optionName set"
}
return
}
r {
foreach p $option_procs($optionName) {
eval "$p $optionName read"
}
return
}
u {
foreach p $option_procs($optionName) {
eval "$p $optionName delete"
trace vdelete $optionName rwu $p
}
return
}
}
}

0 comments on commit 52cc00a

Please sign in to comment.
You can’t perform that action at this time.