/usr/share/tcltk/nsf-nx/class-method.tcl is in nsf 2.0.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | package provide nx::class-method 1.0
#
# Provide a convenience layer to class methods/variables by using
# "class method" rather than "object method". This reflects the naming
# conventions of NX 2.0b4 and earlier. By using this package, one can
# use instead of
#
# nx::Class create C {
# :public object method foo args {....}
# :object property p:integer
# :object mixins add M
# #...
# puts [:info object methods]
# }
#
# a terminology closer to text book vocabulary
#
# package require nx::class-method
#
# nx::Object create o {
# :public class method foo args {....}
# :class property p:integer
# :class mixins add M
# #...
# puts [:class info methods]
# }
#
# Note that for object specific methods of object, have still to be
# defined via "object method" etc. (see also package
# nx::plain-object-method).
#
#
# make "class" an accepted method defining method
#
namespace eval ::nsf {
array set ::nsf::methodDefiningMethod {
class 1
}
}
namespace eval ::nx {
#
# Define a method to allow configuration for tracing of the
# convenience methods. Use
#
# nx::configure class-method-warning on|off
#
# for activation/deactivation of tracing. This might be
# useful for porting legacy NX programs or for testing
# default-configuration compliance.
#
nx::configure public object method class-method-warning {onoff:boolean,optional} {
if {[info exists onoff]} {
set :class-method-warning $onoff
} else {
if {[info exists :class-method-warning]} {
if {${:class-method-warning}} {
uplevel {::nsf::log warn "class method: [self] [current method] [current args]"}
}
}
}
}
nx::Class eval {
#
# Definitions redirected to "object"
#
foreach m {
alias
filters
forward
method
mixins
property
variable
} {
:public method "class $m" {args} {
nx::configure class-method-warning
:object [current method] {*}[current args]
}
}
#
# info subcommands
#
foreach m {
method methods slots variables
filters mixins
} {
:public method "class info $m" {args} [subst -nocommands {
nx::configure class-method-warning
:info object $m {*}[current args]
}]
}
}
#
# Deletions
#
foreach m {
property
variable
method
} {
nx::Class public method "class delete $m" {args} {
nx::configure class-method-warning
:delete object [current method] {*}[current args]
}
}
######################################################################
# Provide method "require"
######################################################################
Object eval {
#
# method require, base cases
#
:method "require class method" {methodName} {
nx::configure class-method-warning
::nsf::method::require [::nsf::self] $methodName 1
return [:info lookup method $methodName]
}
#
# method require, public explicitly
#
:method "require public class method" {methodName} {
nx::configure class-method-warning
set result [:require class method $methodName]
::nsf::method::property [self] $result call-protected false
return $result
}
#
# method require, protected explicitly
#
:method "require protected class method" {methodName} {
nx::configure class-method-warning
set result [:require class method $methodName]
::nsf::method::property [self] $result call-protected true
return $result
}
#
# method require, private explicitly
#
:method "require private class method" {methodName} {
nx::configure class-method-warning
set result [:require class method $methodName]
::nsf::method::property [self] $result call-private true
return $result
}
}
}
|