%3 ::xotcl::package ::xotcl::package → contains → create → extend → import → present → require → unknown → verbose ::nx::Class ::nx::Class __class_configureparameter alias delete method delete property delete variable filters forward info info info method args info method body info method callprotection info method debug info method definition info method definitionhandle info method deprecated info method exists info method handle info method origin info method parameters info method registrationhandle info method returns info method submethods info method syntax info method type info slots info variables method mixins property require method require private method require protected method require public method unknown variable ::xotcl::package->::nx::Class ::nx::MetaSlot ::nx::MetaSlot → createFromParameterSpec → optionsToValueCheckingSpec → parseParameterSpec → requireClass → substDefaultOptions ::nx::MetaSlot->::nx::Class ::nx::Object ::nx::Object __default_accessor __default_method_call_protection __object_configureparameter __resolve_method_path contains copy delete object method delete object property delete object variable destroy_on_cleanup info info info lookup parameters info lookup slots info lookup syntax info lookup variables info object method args info object method body info object method callprotection info object method debug info object method definition info object method definitionhandle info object method deprecated info object method exists info object method handle info object method origin info object method parameters info object method registrationhandle info object method returns info object method submethods info object method syntax info object method type info object slots info object variables info variable definition info variable name info variable parameter move object alias object forward object method object property object variable private protected public qn require namespace require object method require private object method require protected object method require public object method serialize ::nx::Class->::nx::Object

Class ::xotcl::package

::xotcl::package[i] create ... \
           [ -autoexport (default "") ] \
           [ -export (default "") ] \
           [ -provide provide ] \
           [ -version (default "1.0") ]

Defined in

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::nx::Class[i]
::nx::Class create ::xotcl::package \
     -superclass ::nx::Class

Methods (to be applied on the object)

  • contains (scripted, public)

     xotcl::package[i] contains script
    Parameters:
    script (required)

    Testcases:
    No testcase defined.
    if {[info exists :provide]} {
      package provide [set :provide] [set :version]
    } else {
      package provide [::xotcl::self] [set :version]
    }
    namespace eval [::xotcl::self] {namespace import ::xotcl::*}
    #namespace eval [::xotcl::self] $script
    #::nsf::directdispatch [::xotcl::self] -frame method ::apply [list {} $script [::xotcl::self]]
    ::apply [list {} $script [::xotcl::self]]
    
    foreach e [set :export] {
      set nq [namespace qualifiers $e]
      if {$nq ne ""} {
        namespace eval [::xotcl::self]::$nq [list namespace export [namespace tail $e]]
      } else {
        namespace eval [::xotcl::self] [list namespace export $e]
      }
    }
    foreach e [set :autoexport] {
      namespace eval :: [list namespace import [::xotcl::self]::$e]
    }
  • create (scripted, public)

     xotcl::package[i] create name args [ args... ]
    Parameters:
    name (required)
    args (required)

    Testcases:
    No testcase defined.
    set nq [namespace qualifiers $name]
    if {$nq ne "" && ![namespace exists $nq]} {Object create $nq}
    next
  • extend (scripted, public)

     xotcl::package[i] extend name args [ args... ]
    Parameters:
    name (required)
    args (required)

    Testcases:
    No testcase defined.
    :require $name
    $name configure {*}$args
  • import (scripted, public)

     xotcl::package[i] import [ -into into ] pkg
    Switches:
    -into (optional, defaults to "::")
    Parameters:
    pkg (required)

    Testcases:
    No testcase defined.
    :require $pkg
    namespace eval $into [subst -nocommands {
      #puts stderr "*** package import ${pkg}::* into [namespace current]"
      namespace import ${pkg}::*
    }]
    # import subclasses if any
    foreach e [$pkg export] {
      set nq [namespace qualifiers $e]
      if {$nq ne ""} {
        namespace eval $into$nq [list namespace import ${pkg}::$e]
      }
    }
  • present (scripted, public)

     xotcl::package[i] present args [ args... ]
    Parameters:
    args (required)

    Testcases:
    No testcase defined.
    if {$::tcl_version<8.3} {
      switch -exact -- [lindex $args 0] {
        -exact  {set pkg [lindex $args 1]}
        default {set pkg [lindex $args 0]}
      }
      if {[info exists :loaded($pkg)]} {
        return ${:loaded}($pkg)
      } else {
        error "not found"
      }
    } else {
        [set :packagecmd] present {*}$args
    }
  • require (scripted, public)

     xotcl::package[i] require args [ args... ]

    puts "XOTCL package require $args, current=[namespace current]"

    Parameters:
    args (required)

    Testcases:
    No testcase defined.
    set prevComponent ${:component}
    if {[catch {set v [package present {*}$args]} msg]} {
      #puts stderr "we have to load $msg"
      switch -exact -- [lindex $args 0] {
        -exact  {set pkg [lindex $args 1]}
        default {set pkg [lindex $args 0]}
      }
      set :component $pkg
      lappend :uses($prevComponent${:component}
      set v [::uplevel \#1 [set :packagecmd] require $args]
      if {$v ne "" && ${:verbose}} {
      set path [lindex [::package ifneeded $pkg $v] 1]
        puts "... $pkg $v loaded from '$path'"
        set :loaded($pkg$v   ;# loaded stuff needed for Tcl 8.0
      }
    }
    set :component $prevComponent
    return $v
  • unknown (scripted, public)

     xotcl::package[i] unknown args [ args... ]

    puts stderr "unknown: package $args"

    Parameters:
    args (required)

    Testcases:
    No testcase defined.
    [set :packagecmd] {*}$args
  • verbose (scripted, public)

     xotcl::package[i] verbose value
    Parameters:
    value (required)

    Testcases:
    No testcase defined.
    set :verbose $value