home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
classes.tcl
< prev
next >
Wrap
Text File
|
1997-06-03
|
8KB
|
304 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1995
#
# File: @(#)classes.tcl /main/hindenburg/8
# Author: Harm Leijendeckers
# Description: Report on classes
# Usage in: SystemVersion and CAD editor
#
#---------------------------------------------------------------------------
# SccsId = @(#)classes.tcl /main/hindenburg/8 3 Jun 1997 Copyright 1995 Cadre Technologies Inc.
eval [$cc getCustomFileContents semanticbase tcl reports]
Class ReportClasses : {SemanticBase} {
constructor
method doReport
method getItemName
method showProps
method classProps
method attrProps
method methodProps
attribute maxPropNameLength
}
constructor ReportClasses {class this} {
set this [SemanticBase::constructor $class $this]
$this reportName Classes
# calculate max length op property name for a good format in showProps
set max 0
foreach propName [concat [$this classProps] \
[$this attrProps] \
[$this methodProps]] {
set len [string length $propName]
if { $len > $max } {
set max $len
}
}
$this maxPropNameLength $max
return $this
}
method ReportClasses::doReport {this model} {
# get all CAD Classes
set classes [$model getSMObjects $OMT_CAD_CB_Class]
set classItems [flatten [query -s getItem "getItem != [ORB::nil]" $classes]]
if [lempty $classItems] { return 0 }
set class_props [lvarpop Options]
set attribute_props [lvarpop Options]
set method_props [lvarpop Options]
set report [$this report]
set cv [$this configV]
set pv [$this phaseV]
set sv [$this systemV]
if ![$sv isNil] {
set allCdms [query "file.type == cdm" $sv.localFileVersions]
} else {
set allCdms [query "file.type == cdm" \
$pv.systemVersions.localFileVersions]
}
set qoAllCdms [QueryObject new allCdms file.name]
foreach classItem [osort name -nocase $classItems] {
set name [$classItem name]
set cdm [query "file.name == \"$name\"" $qoAllCdms]
if [lempty $cdm] {
$pv getDecompositions $classItem $cv decompFiles {cdm} dummy cdm
}
set classDescription ""
append classDescription "Class $name"
if ![lempty $cdm] {
if { [$cdm status] == "reused" } {
append classDescription "(reused) "
}
if [$cdm inCorporate] {
append classDescription " (in corporate)"
}
}
$report print $classDescription\: line
$report print = [string length $classDescription] fill line
set classWi [$pv findDefinition $classItem $cv]
$report space 2
$report print "scope" [$this maxPropNameLength]
$report print ": "
if ![$classWi isNil] {
set scope [$classWi scope]
regsub -all scope [$classWi scope] "" scope
$report print $scope
set owner [$classWi owner]
if { $owner != $sv } {
$report print " (defined in [$owner text])"
}
} else {
$report print "PhaseRef (no definition)"
}
$report line
# print class properties if given
#
if ![lempty [$this classProps]] {
if { ![$classWi isNil] && ![[$classWi properties] isNil] } {
$this showProps [[$classWi properties] properties] \
[$this classProps] 2
}
}
# print empty line between class name and attributes
$report line
# stop with class if no cdm found
if [lempty $cdm] {
$report print " No cdm found." line
$report line
$report line
continue
}
# print cdm
$cdm loadRowData {{name_type}} rowDataList
set label_attr 0
set label_meth 0
foreach rowData $rowDataList {
set row [lvarpop rowData]
set rowItems [lvarpop rowData]
set rowProps [lvarpop rowData]
set cellDataList [lvarpop rowData]
set type [$row type]
# print Attributes: or Operations:
if { !$label_attr && $type == "attribute" } {
$report print " Attributes:" line
$report print " ----------" line
set label_attr 1
} else {
if { !$label_meth && $type == "method" } {
$report print " Operations:" line
$report print " ----------" line
set label_meth 1
}
}
set name_item [query "type != cl" $rowItems]
set type_item [query "type == cl" $rowItems]
set row_name [$this getItemName $name_item]
set row_type [$this getItemName $type_item]
$report space 8
# $
set icf [query "name == is_class_feature && value == 1" $rowProps]
if ![lempty $icf] {
$report print "$"
}
set ikey [query "name == key && value == 1" $rowProps]
if ![lempty $ikey] {
$report print "*"
}
set ider [query "name == is_derived && value == 1" $rowProps]
if ![lempty $ider] {
$report print "/"
}
# name
$report print $row_name
# args if it's a method
if { $type == "method" } {
set hpl [query "name == has_parmlist && value == 1" $rowProps]
if { $row_name == "create" && ![lempty $icf] && [lempty $hpl]} {
$report line
continue
}
$report print (
set first 1
foreach cellData $cellDataList {
set cell [lvarpop cellData]
set cellItems [lvarpop cellData]
set cellProps [lvarpop cellData]
set cell_name_item [query "type != cl" $cellItems]
set cell_type_item [query "type == cl" $cellItems]
if !$first {
$report print ", "
} else {
set first 0
}
$report print [$this getItemName $cell_name_item]
$report print " : "
$report print [$this getItemName $cell_type_item]
}
$report print )
}
if ![lempty $row_type] {
$report print " : "
# type
$report print [$this getItemName $type_item]
}
# initial value
set ival [query -s value "name == initial_value" $rowProps]
if ![lempty $ival] {
$report print " = $ival"
}
$report line
# print attribute properties if given
#
if { ![lempty [$this attrProps]] && $type == "attribute" } {
set wi [$pv findDefinition $name_item $cv]
if ![$wi isNil] {
$this showProps "[[$wi properties] properties] $rowProps" \
[$this attrProps] 16
}
}
# print method properties if given
#
if { ![lempty [$this methodProps]] && $type == "method" } {
set wi [$pv findDefinition $name_item $cv]
if ![$wi isNil] {
$this showProps "[[$wi properties] properties] $rowProps" \
[$this methodProps] 16
}
}
# print empty line between every attribute and method
$report line
}
$report line
}
if { [[$executeMe report] pageno] || [[$executeMe report] lineno] } {
$report page
}
return 0
}
method ReportClasses::getItemName {this item} {
if ![lempty $item] {
return [$item name]
}
}
method ReportClasses::showProps {this properties propNames spaces} {
if [lempty $properties] {
return
}
set report [$this report]
foreach prop [query "name in {$propNames}" $properties] {
$report space $spaces
$report print [$prop name] [$this maxPropNameLength] break
$report print ": "
$report print [$prop value] 99 line
}
}
# Note: Next three methods define which properties are printed for each
# class, attribute and method and the order in which they are shown.
# Add or remove a short property name to change the report.
method ReportClasses::classProps {this} {
return "freeText persistent abbrev class_source include_list"
}
method ReportClasses::attrProps {this} {
return "freeText abbrev attrib_access nullable"
}
method ReportClasses::methodProps {this} {
return "freeText method_access method_impl is_dyn_bound is_const_func \
modifier"
}
set executeMe [ReportClasses new]