Browse Source

fix pipe = commands

master
Julian Noble 1 year ago
parent
commit
2796eb5563
  1. 28
      src/modules/punk-0.1.tm
  2. 4
      src/modules/punk/ns-999999.0a1.0.tm

28
src/modules/punk-0.1.tm

@ -436,7 +436,7 @@ namespace eval punk {
scan $s %${p}s%s
}
proc _split_patterns {varspecs} {
set name_mapped [pipecmd_rhsmapping $varspecs]
set name_mapped [pipecmd_namemapping $varspecs]
set cmdname ::punk::pipecmds::split_patterns_$name_mapped
if {$cmdname in [info commands $cmdname]} {
return [$cmdname]
@ -1876,7 +1876,7 @@ namespace eval punk {
proc _var_classify {multivar} {
set cmdname ::punk::pipecmds::var_classify_$multivar
set cmdname ::punk::pipecmds::var_classify_[pipecmd_namemapping $multivar]
if {$cmdname in [info commands $cmdname]} {
return [$cmdname]
}
@ -2848,8 +2848,10 @@ namespace eval punk {
#map rhs to names suitable to use in pipemcd proc name (whitespace mapping)
# (for .= and = pipecmds)
proc pipecmd_rhsmapping {rhs} {
return [string map [list " " "<sp>" \t "<tab>"] $rhs]
proc pipecmd_namemapping {rhs} {
set rhs [string trim $rhs];#ignore all leading & trailing whitespace
set rhs [regsub -all {\s{1,}} $rhs {<sp>}] ;#collapse all internal whitespace to a single <sp> token
return $rhs
}
#same as used in unknown func for initial launch
@ -2865,16 +2867,16 @@ namespace eval punk {
}
#puts stderr ">> match_assign '$scopepattern=$equalsrhs' $args"
set fulltail $args
set homens ::punk::pipecmds
set rhsmapping [pipecmd_rhsmapping $equalsrhs]
set pipecmd ${homens}::$scopepattern=$rhsmapping
set cmdns ::punk::pipecmds
set namemapping [pipecmd_namemapping $equalsrhs]
set pipecmd ${cmdns}::$scopepattern=$namemapping
#pipecmd could have glob chars - test $pipcmd in the list - not just that info commands returns results.
if {$pipecmd in [info commands $pipecmd]} {
#puts "==nscaller: '[uplevel 1 [list namespace current]]'"
#uplevel 1 [list ::namespace import $pipecmd]
set existing_path [uplevel 1 [list ::namespace path]]
if {$homens ni $existing_path} {
uplevel 1 [list ::namespace path [concat $existing_path $homens]]
if {$cmdns ni $existing_path} {
uplevel 1 [list ::namespace path [concat $existing_path $cmdns]]
}
tailcall $pipecmd {*}$args
}
@ -3037,8 +3039,8 @@ namespace eval punk {
debug.punk.pipe.compile {match_assign creating proc $pipecmd} 2
uplevel 1 [list ::proc $pipecmd args $script]
set existing_path [uplevel 1 [list ::namespace path]]
if {$homens ni $existing_path} {
uplevel 1 [list ::namespace path [concat $existing_path $homens]]
if {$cmdns ni $existing_path} {
uplevel 1 [list ::namespace path [concat $existing_path $cmdns]]
}
tailcall $pipecmd {*}$args
}
@ -3683,7 +3685,7 @@ namespace eval punk {
set segment_members_filled [list]
set segmenttail $segment_members ;# todo - change to segment_members here to match punk::match_assign
set rhsmapped [pipecmd_rhsmapping $rhs]
set rhsmapped [pipecmd_namemapping $rhs]
set cmdname "::punk::pipecmds::insertion_$rhsmapped"
#commandname can contain glob chars - must search for exact membership in 'info commands' result.
if {$cmdname ni [info commands $cmdname]} {
@ -4227,7 +4229,7 @@ namespace eval punk {
} else {
set nscaller [uplevel 1 [list ::namespace current]]
#jmn
set rhsmapped [pipecmd_rhsmapping $equalsrhs]
set rhsmapped [pipecmd_namemapping $equalsrhs]
set commands [uplevel 1 [list ::info commands $pattern=$rhsmapped]] ;#uplevel - or else we are checking from perspective of this namespace ::punk
#we must check for exact match of the command in the list - because command could have glob chars.
if {"$pattern=$rhsmapped" in $commands} {

4
src/modules/punk/ns-999999.0a1.0.tm

@ -1124,6 +1124,7 @@ namespace eval punk::ns {
set nsdict [dict create\
location $location\
children [lsort $childtailmatches]\
commands $commands\
procs $procs\
@ -1135,7 +1136,6 @@ namespace eval punk::ns {
ooclasses $ooclasses\
namespacexport $exportpatterns\
undetermined $undetermined\
location $location\
namespacepath $nspathdict\
glob $glob\
itemcount $itemcount\
@ -1143,8 +1143,6 @@ namespace eval punk::ns {
lappend nsdict_list $nsdict
}
return $nsdict_list
#return [list children [lsort $tailmatches] commands $commands procs $procs exported $exported imported $imported aliases $aliases ensembles $ensembles ooobjects $ooobjects ooclasses $ooclasses namespacexport $exportpatterns location $location glob $glob]
}
#Must be no ansi when only single arg used.
#review - ansi codes will be very confusing in some scenarios!

Loading…
Cancel
Save