Skip to content
Tcl Source Code View Ticket
Login

View Ticket

auto_mkindex don't detect ensembles

Closed / Fixed2102614fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 14 years ago
Descriptionplain2008-09-09 20:35:02
Linux debsam 2.6.18-6-k7 #1 SMP Mon Aug 18 09:20:26 UTC 2008 i686 GNU/Linux
Tcl: 8.6a3


auto_mkindex don't detect ensembles.

a patch perhaps:

diff auto.tcl auto.tcl.BAK
586,602d585
<         ensemble {
<             variable parser
<             variable index
<             variable scriptFile
<
<             set subcommand [lindex $args 0]
<             if {$subcommand eq "create"} {
<                set script [list _%@namespace ensemble {*}$args]
<              if {[catch {$parser eval $script} command] == 0} {
<                   append index [list set auto_index($command)] \
<                           [format { [list source [file join $dir %s]]} \
<                           [file split $scriptFile]] "\n"
<                }
<             } else {
<              $parser eval [list _%@namespace ensemble {*}$args]
<             }
<         }
dgp Ticket [2102614fff]: 2 changes [History diff]2008-09-10 22:15:52
dgp Ticket [2102614fff]: 1 change [History diff]2008-09-30 01:30:20
bgriffinplain2013-01-04 04:29:15
The proposed patch does not work for me.  This patch does work for me:

$ p4 diff -dc auto.tcl
==== //dvt/mti/prod/src/tcltk/8.5.8/tcl/tcl/library/auto.tcl#1 - /home/bgriffin/dev/devm2_backup/prod/src/tcltk/8.5.8/tcl/tcl/library/auto.tcl ====
***************
*** 604,609 ****
--- 604,618 ----
              }
              catch {$parser eval "_%@namespace import $args"}
          }
+         ensemble {
+             variable parser
+             variable contextStack
+           if {[lindex $args 0] eq "create"} {
+               set name ::[join [lreverse $contextStack] ::]
+               # create artifical proc to force a command entry in the tclIndex
+               $parser eval [list proc $name {} {}]
+           }
+         }
      }
  }
dgpplain2013-03-19 20:46:38
Anything we can put in the test suite for this one?
bgriffinplain2013-03-20 01:23:28
How's this:


$ .x/tcl/tcl/tests/autoMkindex.test                                <
==== //dvt/mti/prod/src/tcltk/8.5.x/tcl/tcl/tests/autoMkindex.test#1 - /home/bgriffin/dev/devm2_backup/prod/src/tcltk/8.5.x/tcl/tcl/tests/autoMkindex.test ====
***************
*** 251,256 ****
--- 251,289 ----
      list [lvalue $::result *mycmd4*] [lvalue $::result *mycmd5*] [lvalue $::result *mycmd6*]
  } "{::buried::mycmd4 $element} {::buried::mycmd5 $element} {mycmd6 $element}"
  
+ makeFile {
+     
+ namespace eval wok {
+     namespace ensemble create -subcommands {commands vars}
+ 
+       proc commands {{pattern *}} {
+               puts [join [lsort -dictionary [info commands $pattern]] \n]
+       }
+ 
+       proc vars {{pattern *}} {
+               puts [join [lsort -dictionary [info vars $pattern]] \n]
+       }
+ 
+ }
+ 
+ } ensemblecommands.tcl
+ 
+ test autoMkindex-3.3 {ensemble commands in tclIndex} {
+     file delete tclIndex
+     auto_mkindex . ensemblecommands.tcl
+     set f [open tclIndex r]
+     set dat [list]
+       foreach r [split [string trim [read $f]] "\n"] {
+               if {[string match {set auto_index*} $r]} {
+                       lappend dat $r
+               }
+       }
+     set result [lsort $dat]
+     close $f
+     set result
+ } {{set auto_index(::wok::commands) [list source [file join $dir ensemblecommands.tcl]]} {set auto_index(::wok::vars) [list source [file join $dir ensemblecommands.tcl]]} {set auto_index(wok) [list source [file join $dir ensemblecommands.tcl]]}}
+ 
+ removeFile ensemblecommands.tcl
  
  makeDirectory pkg
  makeFile {
dgpplain2013-03-21 21:29:59
allow_comments - 1

patches accepted.
Log in (anonymous is fine) to add a comment.