This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
[RFA] Recognize unqualified itcl commands for auto_mkindex
- From: Keith Seitz <keiths at redhat dot com>
- To: Insight Maling List <insight at sources dot redhat dot com>
- Cc: Ian Roxborough <irox at redhat dot com>
- Date: Thu, 10 Jan 2002 20:17:16 -0800 (PST)
- Subject: [RFA] Recognize unqualified itcl commands for auto_mkindex
Hi,
This patch "fixes" itcl so that we can use it to generate tclIndexes. The
patch has two parts:
o For every itcl command dealing with autoloading, recognize the command
without the namespace qualifier, i.e., "class" in addition to "itcl_class"
and "itcl::class". We should probably change our sources to NOT import
itcl::*, since this really seems to be a headache for auto_mkindex.
o Fix the "public" auto_mkindex_parser command so that it properly evals
expressions like:
public {
method foo {}
proc bar {}
}
Previously, chunks of code like this were being eval'd to require a
command like:
auto_mkindex_parser::command public\{\n\ \ \ method\ foo\ \{\}\n and so
on.
Silly.
With these changes and one pending change in gdb/gdbtk/library/Makefile,
we should now be able to regenerate a proper tclIndex for ourselves.
Keith
ChangeLog
2002-01-10 Keith Seitz <keiths@redhat.com>
* itcl/library/itcl.tcl: Add recognition for "class", "body",
"ensemble", and "configbody" without the "itc::" namespace
qualifier.
(auto_mkindex_parser::command public): If given an argument
list of just one item, re-eval it again so that the whole
thing is not interpreted as one humongous command.
Patch
Index: itcl/itcl/library/itcl.tcl
===================================================================
RCS file: /cvs/src/src/itcl/itcl/library/itcl.tcl,v
retrieving revision 1.1.1.2
diff -p -r1.1.1.2 itcl.tcl
*** itcl/itcl/library/itcl.tcl 2001/09/09 19:49:04 1.1.1.2
--- itcl/itcl/library/itcl.tcl 2002/01/11 04:11:21
*************** proc ::itcl::local {class name args} {
*** 42,52 ****
# parser in Tcl...
#
#
# USAGE: itcl::class name body
# Adds an entry for the given class declaration.
#
! foreach cmd {itcl::class itcl_class} {
auto_mkindex_parser::command $cmd {name body} {
variable index
variable scriptFile
--- 42,53 ----
# parser in Tcl...
#
+ # RED HAT LOCAL: don't require namespace qualifier
#
# USAGE: itcl::class name body
# Adds an entry for the given class declaration.
#
! foreach cmd {itcl::class itcl_class class} {
auto_mkindex_parser::command $cmd {name body} {
variable index
variable scriptFile
*************** foreach cmd {itcl::class itcl_class} {
*** 61,99 ****
}
}
#
# USAGE: itcl::body name arglist body
# Adds an entry for the given method/proc body.
#
! auto_mkindex_parser::command itcl::body {name arglist body} {
! variable index
! variable scriptFile
! append index "set [list auto_index([fullname $name])]"
! append index " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
}
#
# USAGE: itcl::configbody name arglist body
# Adds an entry for the given method/proc body.
#
! auto_mkindex_parser::command itcl::configbody {name body} {
! variable index
! variable scriptFile
! append index "set [list auto_index([fullname $name])]"
! append index " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
}
#
# USAGE: ensemble name ?body?
# Adds an entry to the auto index list for the given ensemble name.
#
! auto_mkindex_parser::command itcl::ensemble {name {body ""}} {
! variable index
! variable scriptFile
! append index "set [list auto_index([fullname $name])]"
! append index " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
}
#
# USAGE: public arg ?arg arg...?
# protected arg ?arg arg...?
--- 62,111 ----
}
}
+ # RED HAT LOCAL: don't require namespace qualifier
#
# USAGE: itcl::body name arglist body
# Adds an entry for the given method/proc body.
#
! foreach cmd {itcl::body body} {
! auto_mkindex_parser::command $cmd {name arglist body} {
! variable index
! variable scriptFile
! append index "set [list auto_index([fullname $name])]"
! append index " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
! }
}
+ # RED HAT LOCAL: don't require namespace qualifier
#
# USAGE: itcl::configbody name arglist body
# Adds an entry for the given method/proc body.
#
! foreach cmd {itcl::configbody configbody} {
! auto_mkindex_parser::command $cmd {name body} {
! variable index
! variable scriptFile
! append index "set [list auto_index([fullname $name])]"
! append index " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
! }
}
+ # RED HAT LOCAL: don't require namespace qualifier
#
# USAGE: ensemble name ?body?
# Adds an entry to the auto index list for the given ensemble name.
#
! foreach cmd {itcl::ensemble ensemble} {
! auto_mkindex_parser::command $cmd {name {body ""}} {
! variable index
! variable scriptFile
! append index "set [list auto_index([fullname $name])]"
! append index " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
! }
}
+ # RED HAT LOCAL: treat public differently, since we do care about
+ # public procs
#
# USAGE: public arg ?arg arg...?
# protected arg ?arg arg...?
*************** auto_mkindex_parser::command itcl::ensem
*** 102,115 ****
# Evaluates the arguments as commands, so we can recognize proc
# declarations within classes.
#
! foreach cmd {public protected private} {
auto_mkindex_parser::command $cmd {args} {
variable parser
$parser eval $args
}
}
! # CYGNUS LOCAL
# This version of auto_import does not work, because it relies
# WHOLLY on the tclIndex files, but the tclIndex files have no
# notion of what the export list for a namespace is. So at the
--- 114,141 ----
# Evaluates the arguments as commands, so we can recognize proc
# declarations within classes.
#
! foreach cmd {protected private} {
auto_mkindex_parser::command $cmd {args} {
variable parser
$parser eval $args
}
}
+
+ # RED HAT LOCAL: When the user has used "public {...}" (llength $args == 1),
+ # we must eval $args again into its component statements so
+ # that we look at every line in the "body". Otherwise,
+ # we'll be looking for the contents of the "{...}" as a
+ # command, which is funny business.
+ auto_mkindex_parser::command public {args} {
+ variable parser
+ if {[llength $args] == 1} {
+ eval $parser eval $args
+ } else {
+ $parser eval $args
+ }
+ }
! # RED HAT LOCAL
# This version of auto_import does not work, because it relies
# WHOLLY on the tclIndex files, but the tclIndex files have no
# notion of what the export list for a namespace is. So at the