unknown.pltcl
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:2k
- #---------------------------------------------------------------------
- # Support for unknown command
- #---------------------------------------------------------------------
- proc unknown {proname args} {
- upvar #0 __PLTcl_unknown_support_plan_modname p_mod
- upvar #0 __PLTcl_unknown_support_plan_modsrc p_src
- #-----------------------------------------------------------
- # On first call prepare the plans
- #-----------------------------------------------------------
- if {![info exists p_mod]} {
- set p_mod [spi_prepare
- "select modname from pltcl_modfuncs
- where funcname = $1" name]
- set p_src [spi_prepare
- "select modseq, modsrc from pltcl_modules
- where modname = $1
- order by modseq" name]
- }
- #-----------------------------------------------------------
- # Lookup the requested function in pltcl_modfuncs
- #-----------------------------------------------------------
- set n [spi_execp -count 1 $p_mod [list [quote $proname]]]
- if {$n != 1} {
- #-----------------------------------------------------------
- # Not found there either - now it's really unknown
- #-----------------------------------------------------------
- return -code error "unknown command '$proname'"
- }
- #-----------------------------------------------------------
- # Collect the source pieces from pltcl_modules
- #-----------------------------------------------------------
- set src ""
- spi_execp $p_src [list [quote $modname]] {
- append src $modsrc
- }
- #-----------------------------------------------------------
- # Load the source into the interpreter
- #-----------------------------------------------------------
- if {[catch {
- uplevel #0 "$src"
- } msg]} {
- elog NOTICE "pltcl unknown: error while loading module $modname"
- elog WARN $msg
- }
- #-----------------------------------------------------------
- # This should never happen
- #-----------------------------------------------------------
- if {[catch {info args $proname}]} {
- return -code error
- "unknown command '$proname' (still after loading module $modname)"
- }
- #-----------------------------------------------------------
- # Finally simulate the initial procedure call
- #-----------------------------------------------------------
- return [uplevel 1 $proname $args]
- }