This file is indexed.

/usr/share/tcltk/xotcl1.6.7-lib/metadataAnalyzer.xotcl is in xotcl 1.6.7-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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
package provide xotcl::metadataAnalyzer 0.84 
package require XOTcl

namespace eval ::xotcl::metadataAnalyzer {
    namespace import ::xotcl::*

    @ @File {
	description {
	    XOTcl file analyzer for @ metadata. E.g.\ used for 
	    doumentation with xoDoc (but in the static variant 
				     StaticMetadataAnalyzer which uses the dynamic 
				     variant in this file).
	    <@p>
	    Sample sample usage:
	    <@pre>
	    package require xotcl::metadataAnalyzer

	    # instantiate metadata analyzer object
	    MetadataAnalyzer @::m
	    # make this object be known to @ and turn @ metadata processing on
	    @ analyzerObj @::m
	    @ onOff 1

	    # read in some metadata tags (in sample file) & execute the file
	    source lib/testx.xotcl

	    # turn @ metadata processing off again
	    @ onOff 0

	    # print out all collected metadata
	    puts [@::m print]
	    </@pre>
	}
    }

    @ Class MetadataToken {
	description {
	    Each collected metadata element is stored in a token object.
	    MetadataToken is superclass of token object classes. Each metadata token
	    has two interesting parameters: 
	    <@p>
	    "properties" contains list of all described metadata properties. E.g. can
	    be printed with
	    <@pre>
	    foreach p [my set properties] { 
		if {[my exists $p]} {
		    append c "    $p=[my set $p]\n"
		}
	    }
	    </@pre>
	    "name" contains the method, object, ... name of the metadata element.
	    <@p>
	    All metadata token are aggregated by @. Therefore, 
	    <@pre>
	    foreach mdt [@ info children] { 
		if {[$mdt istype MetadataToken]} {$mdt print}
	    }
	    </@pre>
	    prints all token.

	}
    }
    Class MetadataToken -parameter {
	{name ""}
	{properties ""}
    }

    @ MetadataToken proc sortTokenList {l "token list"} {
	description {Sort a token list with names. Since names are autonames, 
	    this means order of appearance in the program.}
    }
    MetadataToken proc sortTokenList l {
	foreach t $l {
	    set names([$t set name]) $t
	}
	set sortedNames [lsort [array names names]]
	set sortedList ""
	foreach n $sortedNames {
	    lappend sortedList $names($n)
	}
	return $sortedList
    }

    MetadataToken instproc evaluateMetadata md {
	my instvar properties
	foreach {p v} $md {
	    # only append property, if its not already there
	    # otherwise just overwrite the value
	    if {[lsearch $properties $p] == -1} {
		my lappend properties $p
	    }
	    my set $p $v
	}
    }

    @ MetadataToken instproc printProperties {} {
	description {Print metadata properties to stdout.}
    }
    MetadataToken instproc printProperties {} {
	set c ""
	foreach p [my set properties] { 
	    if {[my exists $p]} {
		append c "   [my capitalize $p]=[my set $p]\n"
	    }
	}
	return $c
    }

    MetadataToken instproc capitalize string {
	if {$::tcl_version >= 8.3} {
	    string toupper $string 0 0
	} else {
	    return "[string toupper [string range $string 0 0]][string range $string 1 end]"
	}
    }

    @ MetadataToken abstract instproc print {} {
	description {
	    Abstract method for printing a token to stdout.
	}
    }
    MetadataToken abstract instproc print {}

    @ Class FileToken -superclass MetadataToken {
	description {
	    Token for @File Metadata.
	}
    }
    Class FileToken -superclass MetadataToken
    FileToken instproc print {} {
	set c "FILE=[my set name]\n"
	append c [my printProperties]
	return $c
    }

    @ Class ConstraintToken -superclass MetadataToken {
	description {
	    Token for @Constraint Metadata.
	}
    }
    Class ConstraintToken -superclass MetadataToken
    ConstraintToken instproc print {} {
	set c "CONSTRAINT=[my set name]\n"
	append c [my printProperties]
	return $c
    }

    @ Class PackageToken -superclass MetadataToken {
	description {
	    Token for Package metadata. Contains additional parameters:
	    "version" of the package and "type"= either "require" or "provide".

	}
    }
    Class PackageToken -superclass MetadataToken -parameter {
	{version ""}
	{type ""}
    }

    @ Class ObjToken -superclass MetadataToken {
	description {
	    Token for Object metadata. Contains additional parameters:
	    "procList" = list of all proc token and "cl"= class name.
	}
    }
    Class ObjToken -superclass MetadataToken -parameter {
	{procList ""}
	cl
    }

    ObjToken instproc printProcs {} {
	set c "  PROCS:\n"
	set pl [MetadataToken sortTokenList [my procList]]
	if {[my istype ClassToken]} {
	    set pl [concat [MetadataToken sortTokenList [my instprocList]] $pl]
	}
	foreach p $pl {
	    append c "    [$p set name]\n"
	}
	return $c
    }

    ObjToken instproc print {} {
	set c "OBJECT=[my set name]\n"
	if {[my exists cl]} {append c "  CLASS=[my set cl]\n"}
	if {[my exists heritage]} {append c "  HERITAGE=[my set heritage]\n"}
	append c [my printProperties]

	set pl [MetadataToken sortTokenList [my procList]]
	if {[my istype ClassToken]} {
	    set pl [concat [MetadataToken sortTokenList [my instprocList]] $pl]
	}
	foreach p $pl {
	    append c [$p print]
	}

	return $c
    }

    @ Class ClassToken -superclass ObjToken {
	description {
	    Token for Class metadata. Contains additional parameters:
	    "instprocList" = list of all instproc token.
	}
    }
    Class ClassToken -superclass ObjToken -parameter {
	{instprocList ""}
    }
    ClassToken instproc print {} {
	regsub "^OBJECT=" [next] "CLASS=" r
	return $r
    }

    @ Class MetaClassToken -superclass ClassToken {
	description {
	    Token for Meta-Class metadata.
	}
    }
    Class MetaClassToken -superclass ClassToken
    MetaClassToken instproc print {} {
	regsub "^CLASS=" [next] "META-CLASS=" r
	return $r
    }

    @ Class MethodToken -superclass MetadataToken {
	description {
	    Token for Method metadata. Contains additional parameters:
	    "arguments" of the method, "returnValue"  of the method, 
	    "obj" name, "abstract" = 0 or 1 (whether its an abstract method or not).
	}
    }
    Class MethodToken -superclass MetadataToken -parameter {
	arguments
	returnValue
	obj
	{abstract 0}
    }

    # Prints out method information
    MethodToken instproc print {} {
	set c "  METHOD=[my set name], ARGUMENTS= "

	if {[my exists arguments]} {
	    foreach {arg argDescription} [my set arguments] {
		# ignore argDescription and default values
		if {[llength $arg] > 1} {set arg [lindex $arg 0]}
		append c $arg " "
	    }
	}
	append c "\n [my printProperties]"
	return $c
    }

    @ Class ProcToken -superclass MethodToken {
	description {
	    Token for Proc metadata
	}
    }
    Class ProcToken -superclass MethodToken
    ProcToken instproc print {} {
	regsub "^  METHOD=" [next] "  PROC=" r
	return $r
    }

    @ Class InstprocToken -superclass MethodToken {
	description {
	    Token for Instproc metadata.
	}
    }
    Class InstprocToken -superclass MethodToken
    InstprocToken instproc print {} {
	regsub "^  METHOD=" [next] "  INSTPROC=" r
	return $r
    }

    @ Class MetadataAnalyzer { 
	description "Handler class for building a metadata runtime structure"
    }

    Class MetadataAnalyzer -parameter {
	{objList ""}
	{packageList ""}
	{knownMetaclasses "Class"}
	{ns ""}
	fileToken
	{constraintList ""}
    }

    MetadataAnalyzer instproc init args {
	next
    }

    MetadataAnalyzer instproc handleMethod {obj type name {argList ""} {doc ""}} {
	#puts stderr "+++Method $type $name $argList $doc"
	set procClass ProcToken
	set objCl ObjToken
	if {$type eq "instproc"} {
	    set procCl InstprocToken
	    set objCl ClassToken
	}
	set t [$procClass create [my autoname ::xotcl::@::t]]
	
	set n [$t set name [string trimleft $name :]]
	$t set obj $obj

	set objFound 0
	foreach o [my set objList] {
	    if {[$o set name] == $obj} {
		set objFound 1
		if {$type eq "instproc" && ![$o istype ClassToken]} {
		    $o class ClassToken
		}
		break
	    }
	}
	if {$objFound == 0} {
	    set o [$objCl create [my autoname ::xotcl::@::t]]
	    $o set name $obj
	    my lappend objList $o
	}
	$o lappend ${type}List $t

	$t set arguments $argList 

	$t evaluateMetadata $doc
	return $t
    }

    MetadataAnalyzer instproc handleObj {class name args} {
	my instvar knownMetaclasses objList extensions
	set objCl ObjToken
	if {[lsearch $class $knownMetaclasses] != -1} {
	    set objCl ClassToken
	}
	# if an instproc/proc has created an entry for this obj/class
	# -> use it and overwrite it with new info
	if {[set idx [lsearch $name $objList]] != -1} {
	    set t [lindex $objList $idx]
	    $t class $objCl
	} else {
	    set t [$objCl create [my autoname ::xotcl::@::t]]
	    my lappend objList $t
	}

	$t set name $name

	set la [llength $args]

	# evaluate -superclass argument
	if {($la == 3 || $la == 2) && [lindex $args 0] eq "-superclass"} {
	    set heritage [$t set heritage [lindex $args 1]]
	    foreach h $heritage {
		if {[lsearch $h $knownMetaclasses] != -1} {
		    # A new metaclass was defined
		    lappend knownMetaclasses $name
		    $t class MetaClassToken
		}
	    }
	}

	# evaluate documentation
	set doc ""
	if {$la == 1} {
	    set doc [lindex $args 0]
	} elseif {$la == 3} {
	    set doc [lindex $args 2]
	}
	$t evaluateMetadata $doc
	$t set cl $class

	#puts stderr "+++Obj $name $args"
    }

    MetadataAnalyzer instproc handleFile doc {
	if {[my exists fileToken]} {
	    [my set fileToken] evaluateMetadata $doc
	}
    }

    MetadataAnalyzer instproc handleConstraint {constraint name args} {
	set t [ConstraintToken create [my autoname ::xotcl::@::t]]
	my lappend constraintList $t
	$t set name $name
	set doc [lindex $args 0]
	$t evaluateMetadata $doc
    }

    MetadataAnalyzer instproc handlePackage args {
	#puts "$args"
	if {[llength $args] > 2} {
	    set type [lindex $args 1]
	    if {$type eq "provide" || $type eq "require"} {
		set t [PackageToken create [my autoname ::xotcl::@::t]]
		my lappend packageList $t
		$t set name [lindex $args 2]
		$t set type $type
		if {[llength $args] > 3} {
		    $t set version [lindex $args 3]
		}
	    }
	}
    }

    @ MetadataAnalyzer instproc print {} {
	description "Print all collected token information to stdout. 
   This method is also an exmaple how the tokens can be used."
    }
    MetadataAnalyzer instproc print {} {
	my instvar extensions packageList
	set c ""
	if {[llength $packageList] > 0} {
	    append c "PACKAGES:"
	    foreach t $packageList {
		if {[$t type] eq "provide"} {
		    append c "  Package provided: [$t name] [$t version]\n"
		} elseif {[$t type] eq "require"} {
		    append c "  Package required: [$t name] [$t version]\n"
		}
	    }
	}

	if {[my exists fileToken]} {
	    append c [[my set fileToken] print]
	}

	if {[my exists constraintToken]} {
	    append c [[my set constraintToken] print]
	}

	if {[info exists extensions]} {
	    # Add list of extensions.
	    foreach extension $extensions {
		append c "\nExtensions: [$extension name], " \
		    "Description: [$extension description]"
	    }
	}

	set objList [MetadataToken sortTokenList [my objList]]

	if {[llength $objList]>0} {
	    foreach obj $objList {append c [$obj print]}
	}
	return $c
    }

    @ Class AnalyzerCmd {
	description {Class that overload the unknown mechanism of @ to provide metadata analysis.}
    }
    Class AnalyzerCmd -parameter {
	{analyzerObj ""}
	{onOff 0}
    } 
    AnalyzerCmd instproc unknown args {
	my instvar analyzerObj onOff

	if {!$onOff} {return [next]}

	if {[llength $args] > 1} {
	    set abstract 0
	    if {[lindex $args 1] eq "abstract"} {
		if {[llength $args] > 2} {
		    set p [lindex $args 2]
		    if {$p eq "proc" || $p eq "instproc"} {
			set args [lreplace $args 1 1]
			set abstract 1
		    }
		}
	    }
	    switch [lindex $args 1] {
		proc - instproc {
		    set r [eval $analyzerObj handleMethod $args]
		    if {$abstract} {$r abstract 1}
		    return $r
		}
		default {
		    switch [lindex $args 0] {
			@File {
			    return [$analyzerObj handleFile [lindex $args 1]]
			}
			@Constraint {
			    return [eval $analyzerObj handleConstraint $args]
			}
			default {
			    return [eval $analyzerObj handleObj $args]
			}
		    }
		}
	    }
	}
	puts stderr "Unknown @ metadata: '$args'"
    }
    @ AnalyzerCmd @ {
	description {Recreate @ with metadata analyis funtionality.}
    }
    AnalyzerCmd @

    namespace export \
	MetadataToken FileToken ConstraintToken PackageToken ObjToken \
	ClassToken MetaClassToken MethodToken ProcToken InstprocToken \
	MetadataAnalyzer AnalyzerCmd
}

namespace import ::xotcl::metadataAnalyzer::*