home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
roundtrip.tcl
< prev
next >
Wrap
Text File
|
1997-12-01
|
68KB
|
2,662 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1996
#
# File: @(#)header.tcl /main/titanic/3
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)header.tcl /main/titanic/3 23 Jun 1997 Copyright 1996 Cadre Technologies Inc.
require "wmt_util.tcl"
require "fstorage.tcl"
require "rt_getset.tcl"
require "propknowle.tcl"
require "config.tcl"
require "platform.tcl"
require "procs.tcl"
OTShRegister::importToolEdExt
#---------------------------------------------------------------------------
#
# Copyright (c) 1997 by Cayenne Software, Inc.
#
# This software is furnished under a license and may be used only in
# accordance with the terms of such license and with the inclusion of
# the above copyright notice. This software or any other copies thereof
# may not be provided or otherwise made available to any other person.
# No title to and ownership of the software is hereby transferred.
#
# The information in this software is subject to change without notice
# and should not be construed as a commitment by Cayenne Software, Inc.
#
#---------------------------------------------------------------------------
#
# File : tmp
# Author :
# Original date : November 1997
# Description : Classes for code generation
#
#---------------------------------------------------------------------------
# File: @(#)rtcomp.tcl /main/titanic/5
# End user added include file section
Class RTComp : {GCObject} {
constructor
method destructor
method getUniqueName
method setLabel
method setProp
method findLabel
method findProp
method getLabel
method getProp
method REGenerateSub
method rtDiagram
method rtLabelSet
method addRtLabel
method removeRtLabel
method rtPropertySet
method addRtProperty
method removeRtProperty
attribute objId
attribute _rtDiagram
attribute _rtLabelSet
attribute _rtPropertySet
}
global RTComp::objects
set RTComp::objects 0
constructor RTComp {class this rtDiagram} {
set this [GCObject::constructor $class $this]
$this _rtDiagram $rtDiagram
[$rtDiagram _rtCompSet] append $this
$this _rtLabelSet [List new]
$this _rtPropertySet [List new]
# Start constructor user section
global RTComp::objects
$this objId ${RTComp::objects}
incr RTComp::objects
# End constructor user section
return $this
}
method RTComp::destructor {this} {
# Start destructor user section
# End destructor user section
}
method RTComp::getUniqueName {this} {
return "obj[$this objId]"
}
method RTComp::setLabel {this name value} {
set lbl [$this findLabel $name]
if {$lbl == ""} {
set lbl [RTLabel new [$this rtDiagram]]
$lbl name $name
$this addRtLabel $lbl
}
$lbl value $value
}
method RTComp::setProp {this name value {item "comp"}} {
switch $item {
de {set item "name"}
pe {set item "name"}
cl {set item "type"}
}
set prop [$this findProp $name $item]
if { $prop == "" } {
set prop [RTProperty new]
$prop name $name
$prop item $item
$this addRtProperty $prop
}
$prop value $value
}
method RTComp::findLabel {this name} {
[$this rtLabelSet] foreach lbl {
if { [$lbl name] == $name } {
return $lbl
}
}
return ""
}
method RTComp::findProp {this name {item "comp"}} {
switch $item {
de {set item "name"}
pe {set item "name"}
cl {set item "type"}
}
[$this rtPropertySet] foreach prop {
if { ( [$prop name] == $name ) &&
( [$prop item] == $item ) } {
return $prop
}
}
return ""
}
method RTComp::getLabel {this name} {
set lbl [$this findLabel $name]
if {$lbl != ""} {
return [$lbl value]
} else {
return ""
}
}
method RTComp::getProp {this name {item "comp"}} {
set prop [$this findProp $name $item]
if {$prop != ""} {
return [$prop value]
} else {
return ""
}
}
method RTComp::REGenerateSub {this RTFd} {
[$this rtPropertySet] foreach prop {
$prop REGenerate $RTFd
}
[$this rtLabelSet] foreach lbl {
$lbl REGenerate $RTFd
}
}
# Do not delete this line -- regeneration end marker
method RTComp::rtDiagram {this args} {
if {$args == ""} {
return [$this _rtDiagram]
}
set ref [$this _rtDiagram]
if {$ref != ""} {
[$ref _rtCompSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _rtCompSet] append $this
}
$this _rtDiagram $obj
}
method RTComp::rtLabelSet {this} {
return [$this _rtLabelSet]
}
method RTComp::addRtLabel {this newRtLabel} {
[$this _rtLabelSet] append $newRtLabel
$newRtLabel _rtComp $this
}
method RTComp::removeRtLabel {this oldRtLabel} {
$oldRtLabel _rtComp ""
[$this _rtLabelSet] removeValue $oldRtLabel
}
method RTComp::rtPropertySet {this} {
return [$this _rtPropertySet]
}
method RTComp::addRtProperty {this newRtProperty} {
[$this _rtPropertySet] append $newRtProperty
$newRtProperty _rtComp $this
}
method RTComp::removeRtProperty {this oldRtProperty} {
$oldRtProperty _rtComp ""
[$this _rtPropertySet] removeValue $oldRtProperty
}
#---------------------------------------------------------------------------
# File: @(#)rtdiagram.tcl /main/titanic/15
# End user added include file section
Class RTDiagram : {GCObject} {
method destructor
method startREFile
method EndREFile
method DoRE
constructor
method addClass
method addNode
method findClass
method addConn
method update
method checkAccess
method save
method rtCompSet
method addRtComp
method removeRtComp
attribute fileName
attribute systemName
attribute phaseName
attribute phaseType
attribute configName
attribute configVersion
attribute projectName
attribute hasScopePhase
attribute overwriteDiagram
attribute RTFd
attribute RTFName
attribute REFName
attribute _rtCompSet
}
method RTDiagram::destructor {this} {
# Start destructor user section
# End destructor user section
}
method RTDiagram::startREFile {this} {
if {[$this RTFd] == ""} {
# zet er nu gewoon wat in maar moet file discript zijn
$this RTFName [BasicFS::tmpFile]
$this RTFd [open [$this RTFName] w]
puts [$this RTFd] "# generated by roundtrip"
puts [$this RTFd] " "
puts [$this RTFd] "# generated for reverse engineering"
puts [$this RTFd] " "
if {[$this fileName] == ""} {
$this fileName "NewRT"
}
puts [$this RTFd] "set diag \[REDiagram new \"[$this fileName]\" \"[$this systemName]\" \"[$this phaseName]\" \"[$this phaseType]\" \"[$this configName]\" \"[$this configVersion]\" \"[$this projectName]\" \"[$this hasScopePhase]\"\ [$this overwriteDiagram] \]"
puts [$this RTFd] " "
}
}
method RTDiagram::EndREFile {this} {
if {[$this RTFd] != ""} {
puts [$this RTFd] " "
$this REFName [BasicFS::tmpFile]
puts [$this RTFd] "\$diag save \{[$this REFName]\}"
close [$this RTFd]
$this RTFd ""
}
}
method RTDiagram::DoRE {this} {
if {[$this RTFName] != ""} {
global EXE_EXT
set otprint [quoteIf [m4_path_name bin otprint$EXE_EXT]]
system "$otprint [$this RTFName]"
puts ""
source [$this REFName]
BasicFS::removeFile [$this RTFName]
BasicFS::removeFile [$this REFName]
}
}
constructor RTDiagram {class this {fin ""} {syn ""} {phn ""} {pht ""} {con ""} {cov ""} {prn ""} {hsp ""} {overwrite ""}} {
set this [GCObject::constructor $class $this]
$this _rtCompSet [List new]
$this fileName $fin
$this systemName $syn
$this phaseName $phn
$this phaseType $pht
$this configName $con
$this configVersion $cov
$this projectName $prn
$this hasScopePhase $hsp
$this overwriteDiagram $overwrite
return $this
}
method RTDiagram::addClass {this {name ""} {section ""}} {
set clss [RTClass new $this]
$clss section $section
if { $name != "" } {
$clss setLabel "name" $name
}
return $clss
}
method RTDiagram::addNode {this type} {
if {$type=="cad_class"} {
return [$this addClass]
}
return ""
}
method RTDiagram::findClass {this name} {
[$this rtCompSet] foreach comp {
if [ $comp isA RTClass ] {
if { [[$comp findLabel "name"] value] == $name } {
return $comp
}
}
}
return ""
}
method RTDiagram::addConn {this type st end} {
return [RTConn new $this $type $st $end]
}
method RTDiagram::update {this} {
[$this rtCompSet] foreach comp {
if [$comp isA RTClass] {
$comp update
}
}
}
method RTDiagram::checkAccess {this} {
[$this rtCompSet] foreach comp {
if [ $comp isA RTAttrib ] {
$comp checkAccess
}
}
}
method RTDiagram::save {this {filename ""}} {
set status [catch {
$this update
$this checkAccess
set rtitui [RTITUserInterface new]
# combine models
[$this rtCompSet] foreach comp {
if [$comp isA RTClass] {
# Temporary save current levelpath
set cc [ClientContext::global]
set path [$cc currentLevelString]
set rtitClass [RTITClass new $comp $rtitui]
if {[$rtitClass go] == 0} {
$rtitClass deleteUnUsed
$rtitClass update
$rtitClass save
}
$cc setLevelPath $path
}
}
$this EndREFile
$this DoRE
} msg]
if {$status} {
puts stderr $msg
if [info exists debug] {
puts stderr $errorInfo
}
}
}
# Do not delete this line -- regeneration end marker
method RTDiagram::rtCompSet {this} {
return [$this _rtCompSet]
}
method RTDiagram::addRtComp {this newRtComp} {
[$this _rtCompSet] append $newRtComp
$newRtComp _rtDiagram $this
}
method RTDiagram::removeRtComp {this oldRtComp} {
$oldRtComp _rtDiagram ""
[$this _rtCompSet] removeValue $oldRtComp
}
#---------------------------------------------------------------------------
# File: @(#)rtitattrib.tcl /main/titanic/14
# End user added include file section
Class RTITAttrib : {GCObject} {
constructor
method destructor
method go
method update
method setBestMatch
method setPosition
method prev
method next
method clss
attribute rtAttrib
attribute _clss
attribute edAttrib
}
constructor RTITAttrib {class this rtAttrib clss} {
set this [GCObject::constructor $class $this]
$this rtAttrib $rtAttrib
$this _clss $clss
[$clss _attrSet] append $this
# Start constructor user section
# End constructor user section
return $this
}
method RTITAttrib::destructor {this} {
# Start destructor user section
# End destructor user section
}
method RTITAttrib::go {this} {
$this setBestMatch
$this setPosition
}
method RTITAttrib::update {this} {
# Check pre-conditions
if {[$this edAttrib] == "" } return
# Special key attribute handling
if [[$this rtAttrib] keyAttrib] {
if {[[$this edAttrib] getProp "nullable" name_type de] == "no"} {
[$this rtAttrib] setProp "nullable" "no" "name"
} else {
if {[[$this rtAttrib] getProp "key"] != 1} {
[$this rtAttrib] setProp "key" 1
[$this rtAttrib] setLabel name_type \
"*[[$this rtAttrib] getLabel name_type]"
}
}
}
# check the label
# compare the items name and type and check the properties which
# change the label
set attribName [[$this edAttrib] getItem name_type de]
set standTypeDiag [[$this edAttrib] getItem name_type cl]
set langTypeDiag $standTypeDiag
set type [${RTITClass::langTypeTable} getTypeByStdTypeName $standTypeDiag]
if {$type != ""} {
set langTypeDiag [$type name]
}
if { ([[$this rtAttrib] name] != $attribName) ||
(([[$this rtAttrib] type] != $standTypeDiag) &&
([[$this rtAttrib] type] != $langTypeDiag)) ||
([[$this rtAttrib] getProp "is_class_feature"] !=
[[$this edAttrib] getProp "is_class_feature"]) ||
([[$this rtAttrib] getProp "is_derived"] !=
[[$this edAttrib] getProp "is_derived"]) ||
([[$this rtAttrib] getProp "key"] !=
[[$this edAttrib] getProp "key"]) ||
([[$this rtAttrib] getProp "initial_value"] !=
[[$this edAttrib] getProp "initial_value"]) } {
set typeStr ""
if {[[$this rtAttrib] type] == $langTypeDiag} {
set typeStr $standTypeDiag
} else {
set type [${RTITClass::langTypeTable} getTypeByStdTypeName [[$this rtAttrib] type]]
if {$type == ""} {
set type [${RTITClass::langTypeTable} getType [[$this rtAttrib] type]]
if {$type != ""} {
set typeStr [$type stdTypeName]
}
}
}
if {$typeStr != ""} {
if [regsub "(.*:.*)[[$this rtAttrib] type](.*)" \
"[[$this rtAttrib] getLabel name_type]" \
"\\1$typeStr\\2" newLabel] {
[$this rtAttrib] setLabel name_type $newLabel
}
}
set clssName [[[$this clss] rtClass] name]
set attrNLbl [[$this rtAttrib] getLabel name_type]
regsub -all "\n" [[$this edAttrib] getLabel name_type] "" attrOLbl
set answer [[[$this clss] ui] askQuestion \
"In class \"$clssName\": \
\n change attribute \"$attrOLbl\" into \"$attrNLbl\"" \
"Change this attribute?" \
"attribute-change_label" \
[$this clss]]
if {$answer == "yes"} {
[$this edAttrib] setLabel name_type \
"[[$this rtAttrib] getLabel name_type]"
}
}
# check all known properties
# known properties are properties which have been defined by the
# parser which gave us our input
[[$this rtAttrib] rtPropertySet] foreach prop {
set name [$prop name]
switch $name {
"is_class_feature" continue
"is_derived" continue
"key" continue
"initial_value" continue
}
set item [$prop item]
switch $item {
"name" { set itlbl "name_type" ; set ititem "de" }
"type" { set itlbl "name_type" ; set ititem "cl" }
"comp" { set itlbl "" ; set ititem "" }
}
set value [$prop value]
set itvalue [[$this edAttrib] getProp $name $itlbl $ititem]
set defaultValue [PropKnowledge::getDefaultValue $name]
if [info exists debug] {
puts stderr "value: '$value' itvalue: '$itvalue' defaultValue: '$defaultValue'"
}
if { $itvalue == "" } {
set itvalue $defaultValue
}
if { $value == "" } {
set value $defaultValue
}
if { $itvalue != $value } {
set clssName [[[$this clss] rtClass] name]
set fullPropName [PropKnowledge::getLongName $name]
set answer [[[$this clss] ui] askQuestion \
"In class \"$clssName\": \
\n change property \"$fullPropName\" of attribute \"$attribName\" \
\n from \"$itvalue\" into \"$value\"" \
"Change this attribute property?" \
"attribute-change_property" \
[$this clss]]
if {$answer == "yes"} {
if { $value == $defaultValue } {
set value ""
}
[$this edAttrib] setProp $name $value $itlbl $ititem
}
}
}
}
method RTITAttrib::setBestMatch {this} {
[[$this clss] unUsedAttribSet] foreach attr {
if { [$attr getItem name_type de] == [[$this rtAttrib] name] } {
# found an attribute with the same name.
# only one attribute with a specific name can
# exists at one time, so this is the one.
$this edAttrib $attr
[[$this clss] unUsedAttribSet] removeValue $attr
return
}
}
# attribute was not found
# create a new attribute
set clssName [[[$this clss] rtClass] name]
set attribName [[$this rtAttrib] name]
set answer [[[$this clss] ui] askQuestion \
"In class \"$clssName\": add attribute \"$attribName\"" \
"Add attribute?" \
"attribute-add" \
[$this clss]]
if {$answer == "yes"} {
set newAttr [[[$this clss] edMatrix] addRow "attribute"]
$this edAttrib $newAttr
set type [${RTITClass::langTypeTable} getTypeByStdTypeName [[$this rtAttrib] type]]
if {$type == ""} {
set type [${RTITClass::langTypeTable} getType [[$this rtAttrib] type]]
if {$type != ""} {
set typeStr [$type stdTypeName]
if [regsub "(.*:.*)[[$this rtAttrib] type](.*)" \
"[[$this rtAttrib] getLabel name_type]" \
"\\1$typeStr\\2" newLabel] {
[$this rtAttrib] setLabel name_type $newLabel
}
}
}
$newAttr setLabel name_type [[$this rtAttrib] getLabel name_type]
[[$this rtAttrib] rtPropertySet] foreach prop {
set name [$prop name]
switch $name {
"is_class_feature" continue
"is_derived" continue
"key" continue
"initial_value" continue
}
set item [$prop item]
switch $item {
"name" { set itlbl "name_type" ; set ititem "de" }
"type" { set itlbl "name_type" ; set ititem "cl" }
"comp" { set itlbl "" ; set ititem "" }
}
set value [$prop value]
$newAttr setProp $name $value $itlbl $ititem
}
} else {
$this edAttrib ""
}
}
method RTITAttrib::setPosition {this} {
if {[$this edAttrib] == ""} return
set prev [$this prev]
if { $prev != "" } {
# not the first one, so move
if { [$prev edAttrib] != "" } {
[$this edAttrib] moveBehind [$prev edAttrib]
}
}
}
method RTITAttrib::prev {this} {
# Look for myself and sub one to the index
set idx [[[$this clss] attrSet] search -exact $this]
if { $idx == -1 } {
return ""
} else {
set previdx [expr $idx - 1]
if { $previdx != -1 } {
return [[[$this clss] attrSet] index $previdx]
} else {
return ""
}
}
}
method RTITAttrib::next {this} {
# Look for myself and add one to the index
set idx [[[$this clss] attrSet] search -exact $this]
if { $idx == -1 } {
return ""
} else {
set nextidx [expr $idx + 1]
if { $nextidx < [[[$this clss] attrSet] length] } {
return [[[$this clss] attrSet] index $nextidx]
} else {
return ""
}
}
}
# Do not delete this line -- regeneration end marker
method RTITAttrib::clss {this args} {
if {$args == ""} {
return [$this _clss]
}
set ref [$this _clss]
if {$ref != ""} {
[$ref _attrSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _attrSet] append $this
}
$this _clss $obj
}
#---------------------------------------------------------------------------
# File: @(#)rtitclass.tcl /main/titanic/14
# End user added include file section
Class RTITClass : {GCObject} {
constructor
method destructor
method go
method update
method deleteUnUsed
method save
method createLists
method addUnUsedAttrib
method removeUnUsedAttrib
method attrSet
method addAttr
method removeAttr
method mthdSet
method addMthd
method removeMthd
method addUnUsedMethod
method removeUnUsedMethod
attribute rtClass
attribute unUsedAttribSet
attribute _attrSet
attribute _mthdSet
attribute ui
attribute edMatrix
attribute unUsedMethodSet
}
global RTITClass::langTypeTable
set RTITClass::langTypeTable ""
constructor RTITClass {class this rtClass ui} {
set this [GCObject::constructor $class $this]
$this rtClass $rtClass
$this ui $ui
$this unUsedAttribSet [List new]
$this _attrSet [List new]
$this _mthdSet [List new]
$this unUsedMethodSet [List new]
# Start constructor user section
if {${RTITClass::langTypeTable} == ""} {
global RTITClass::langTypeTable
set RTITClass::langTypeTable [LangTypeTable::createTable]
}
[[$this rtClass] rtAttribSet] foreach attr {
if { [$attr section] == "user-defined-attribute" } {
RTITAttrib new $attr $this
}
}
[[$this rtClass] rtMethodSet] foreach mthd {
if { [$mthd section] == "user-defined-method" } {
RTITMethod new $this $mthd
}
}
# End constructor user section
return $this
}
method RTITClass::destructor {this} {
# Start destructor user section
# End destructor user section
}
method RTITClass::go {this} {
# find out CDM name with some help of fstorage
# (if we still know the file name)
set CDMname ""
set fileName [[$this rtClass] getProp include_list type]
if {$fileName != "" } {
set CDMname [fstorage::get_imp_from $fileName]
}
if { $CDMname == "" } {
# Last resort
set CDMname [[$this rtClass] name]
}
# Check if this class has a CDM
# if no CDM exists, we should not try to roundtrip this file
set cc [ClientContext::global]
set levelPath "/[[$cc currentCorporate] name]"
set diag [[$this rtClass] rtDiagram]
if {[$diag projectName] != ""} {
set levelPath "${levelPath}/[$diag projectName]"
} else {
set levelPath "${levelPath}/[[$cc currentProject] name]"
}
if {[$diag configName] != ""} {
set levelPath "${levelPath}/[$diag configName]"
} else {
set levelPath "${levelPath}/[[[$cc currentConfig] config] name]"
}
if {[$diag configVersion] != ""} {
set levelPath "${levelPath}:[$diag configVersion]"
} else {
set levelPath "${levelPath}:[[$cc currentConfig] versionNumber]"
}
if {[$diag phaseName] != ""} {
set levelPath "${levelPath}/[$diag phaseName]"
} else {
set levelPath "${levelPath}/[[[$cc currentPhase] phase] name]"
}
if {[$diag phaseType] != ""} {
set levelPath "${levelPath}.[$diag phaseType]"
} else {
set levelPath "${levelPath}.[[[$cc currentPhase] phase] type]"
}
if {[$diag systemName] != ""} {
set levelPath "${levelPath}/[$diag systemName].system"
} else {
set levelPath "${levelPath}/[[[$cc currentSystem] system] name].system"
}
set prop [[$this rtClass] getProp "is_folded" comp]
if {$prop != ""} {
if { $prop == "1" } {
$this edMatrix ""
return 1
}
}
$cc setLevelPath $levelPath
set sysV [$cc currentSystem]
set item [[$cc currentProject] findItem $CDMname cl]
if {$item != "" && ![$item isNil]} {
$sysV getDecompositions $item [$cc currentConfig] decompFiles \
{cdm} resultSystems resultFiles
if {[lempty $resultFiles]} {
puts "Warning: CDM ($CDMname) not found, roundtrip skipped..."
return 1
}
} else {
if {[[$this rtClass] section] != "new-control"} {
puts "Warning: CDM ($CDMname) not found, roundtrip skipped..."
return 1
} else {
set clssName [[$this rtClass] name]
set answer [[$this ui] askQuestion \
"Add new control \"$clssName\"" \
"Add control?" \
"control-add" \
$this]
if {$answer == "yes"} {
[$this rtClass] REGenerate
}
return 1
}
}
set diag [[$this rtClass] rtDiagram]
set newEdCDM [EdCDM new $CDMname \
"[$diag systemName]" "[$diag phaseName]" \
"[$diag phaseType]" "[$diag configName]" \
"[$diag configVersion]" "[$diag projectName]" \
"[$diag hasScopePhase]" "[$diag overwriteDiagram]"]
$this edMatrix $newEdCDM
$this createLists
[$this attrSet] foreach attr {
$attr go
}
[$this mthdSet] foreach mthd {
$mthd go
}
return 0
}
method RTITClass::update {this} {
if {[$this edMatrix] == ""} return
[$this attrSet] foreach attr {
$attr update
}
[$this mthdSet] foreach mthd {
$mthd update
}
[$this edMatrix] formatLayout
}
method RTITClass::deleteUnUsed {this} {
if {[$this edMatrix] == ""} return
set clssName [[$this rtClass] name]
[$this unUsedAttribSet] foreach attr {
set attribName [$attr getItem name_type de]
set answer [[$this ui] askQuestion \
"In class \"$clssName\": delete attribute \"$attribName\"" \
"Delete attribute?" \
"attribute-delete" \
$this]
if {$answer == "yes"} {
[$this edMatrix] deleteRow $attr
}
}
[$this unUsedMethodSet] foreach mthd {
# Check if this is the default ctor
# if so, don't remove it
if {[$mthd getItem name_type pe] != "create" ||
[$mthd getProp is_class_feature] != "1" ||
[llength [$mthd getCells]] != 0} {
set methodName [$mthd getItem name_type pe]
set answer [[$this ui] askQuestion \
"In class \"$clssName\": delete method \"$methodName\"" \
"Delete method?" \
"method-delete" \
$this]
if {$answer == "yes"} {
[$this edMatrix] deleteRow $mthd
}
}
}
[$this mthdSet] foreach mthd {
$mthd deleteUnUsed
}
}
method RTITClass::save {this} {
if {[$this edMatrix] == ""} return
if {[[$this ui] changes] <= 0} {
puts "No changes..."
[$this edMatrix] quit
return
}
set clssName [[$this rtClass] name]
set answer [[$this ui] askQuestion \
"Save class \"$clssName\" and accept all changes" \
"Save changes?" \
"class-save" \
$this]
if { $answer == "yes"} {
[$this edMatrix] save
} else {
puts "Abandoning all changes..."
[$this edMatrix] quit
}
}
method RTITClass::createLists {this} {
if {[$this edMatrix] == ""} return
foreach row [[$this edMatrix] getRows] {
switch [$row getType] {
"attribute" { $this addUnUsedAttrib $row }
"method" { $this addUnUsedMethod $row }
}
}
}
# Do not delete this line -- regeneration end marker
method RTITClass::addUnUsedAttrib {this newUnUsedAttrib} {
[$this unUsedAttribSet] append $newUnUsedAttrib
}
method RTITClass::removeUnUsedAttrib {this oldUnUsedAttrib} {
[$this unUsedAttribSet] removeValue $oldUnUsedAttrib
}
method RTITClass::attrSet {this} {
return [$this _attrSet]
}
method RTITClass::addAttr {this newAttr} {
[$this _attrSet] append $newAttr
$newAttr _clss $this
}
method RTITClass::removeAttr {this oldAttr} {
$oldAttr _clss ""
[$this _attrSet] removeValue $oldAttr
}
method RTITClass::mthdSet {this} {
return [$this _mthdSet]
}
method RTITClass::addMthd {this newMthd} {
[$this _mthdSet] append $newMthd
$newMthd _clss $this
}
method RTITClass::removeMthd {this oldMthd} {
$oldMthd _clss ""
[$this _mthdSet] removeValue $oldMthd
}
method RTITClass::addUnUsedMethod {this newUnUsedMethod} {
[$this unUsedMethodSet] append $newUnUsedMethod
}
method RTITClass::removeUnUsedMethod {this oldUnUsedMethod} {
[$this unUsedMethodSet] removeValue $oldUnUsedMethod
}
#---------------------------------------------------------------------------
# File: @(#)rtitmethod.tcl /main/titanic/13
# End user added include file section
Class RTITMethod : {GCObject} {
constructor
method destructor
method go
method update
method deleteUnUsed
method createList
method setBestMatch
method setPosition
method prev
method next
method clss
method paramSet
method addParam
method removeParam
method addUnUsedParam
method removeUnUsedParam
attribute _clss
attribute rtMethod
attribute _paramSet
attribute edMethod
attribute unUsedParamSet
}
constructor RTITMethod {class this clss rtMethod} {
set this [GCObject::constructor $class $this]
$this _clss $clss
[$clss _mthdSet] append $this
$this rtMethod $rtMethod
$this _paramSet [List new]
$this unUsedParamSet [List new]
# Start constructor user section
[[$this rtMethod] rtParamSet] foreach param {
RTITParam new $this $param
}
# End constructor user section
return $this
}
method RTITMethod::destructor {this} {
# Start destructor user section
# End destructor user section
}
method RTITMethod::go {this} {
$this setBestMatch
$this setPosition
$this createList
[$this paramSet] foreach param {
$param go
}
}
method RTITMethod::update {this} {
if {[$this edMethod] == ""} return
# check the name_type label
# compare the items and all properties which change the label
set methodName [[$this edMethod] getItem name_type pe]
set standTypeDiag [[$this edMethod] getItem name_type cl]
set langTypeDiag $standTypeDiag
set type [${RTITClass::langTypeTable} getTypeByStdTypeName $standTypeDiag]
if {$type != ""} {
set langTypeDiag [$type name]
}
if { ([[$this rtMethod] name] != $methodName) ||
(([[$this rtMethod] type] != $standTypeDiag) &&
([[$this rtMethod] type] != $langTypeDiag)) ||
([[$this rtMethod] getProp "is_class_feature"] !=
[[$this edMethod] getProp "is_class_feature"]) ||
([[$this rtMethod] getProp "is_abstract"] !=
[[$this edMethod] getProp "is_abstract"])} {
set typeStr ""
if {[[$this rtMethod] type] == $langTypeDiag} {
set typeStr $standTypeDiag
} else {
set type [${RTITClass::langTypeTable} getTypeByStdTypeName [[$this rtMethod] type]]
if {$type == ""} {
set type [${RTITClass::langTypeTable} getType [[$this rtMethod] type]]
if {$type != ""} {
set typeStr [$type stdTypeName]
}
}
}
if {$typeStr != ""} {
if [regsub "(.*:.*)[[$this rtMethod] type](.*)" \
"[[$this rtMethod] getLabel name_type]" \
"\\1$typeStr\\2" newLabel] {
[$this rtMethod] setLabel name_type $newLabel
}
}
set mthdNLbl [[$this rtMethod] getLabel name_type]
regsub -all "\n" [[$this edMethod] getLabel name_type] "" mthdOLbl
set clssName [[[$this clss] rtClass] name]
set answer [[[$this clss] ui] askQuestion \
"In class \"$clssName\": \
\n change method \"$mthdOLbl\" into \"$mthdNLbl\"" \
"Change method?" \
"method-change_label" \
[$this clss]]
if {$answer == "yes"} {
[$this edMethod] setLabel name_type \
[[$this rtMethod] getLabel name_type]
}
}
# check all known properties
# known properties are properties which have been defined by the
# parser which gave us our input
[[$this rtMethod] rtPropertySet] foreach prop {
set name [$prop name]
switch $name {
"is_class_feature" continue
"is_abstract" continue
}
set item [$prop item]
switch $item {
"name" { set itlbl "name_type" ; set ititem "pe" }
"type" { set itlbl "name_type" ; set ititem "cl" }
"comp" { set itlbl "" ; set ititem "" }
}
set value [$prop value]
set itvalue [[$this edMethod] getProp $name $itlbl $ititem]
set defaultValue [PropKnowledge::getDefaultValue $name]
if [info exists debug] {
puts stderr "value: '$value' itvalue: '$itvalue' defaultValue: '$defaultValue'"
}
if { $itvalue == "" } {
set itvalue $defaultValue
}
if { $value == "" } {
set value $defaultValue
}
if { $itvalue != $value } {
set clssName [[[$this clss] rtClass] name]
set fullPropName [PropKnowledge::getLongName $name]
set answer [[[$this clss] ui] askQuestion \
"In class \"$clssName\": \
\n change property \"$fullPropName\" of method \"$methodName\" \
\n from \"$itvalue\" into \"$value\"" \
"Change method property?" \
"method-change_property" \
[$this clss]]
if {$answer == "yes"} {
if { $value == $defaultValue } {
set value ""
}
[$this edMethod] setProp $name $value $itlbl $ititem
}
}
}
[$this paramSet] foreach param {
$param update
}
[$this edMethod] formatLayout
}
method RTITMethod::deleteUnUsed {this} {
if {[$this edMethod] == ""} return
[$this unUsedParamSet] foreach param {
set clssName [[[$this clss] rtClass] name]
set paramName [$param getItem name_type de]
set methodName [[$this rtMethod] name]
set answer [[[$this clss] ui] askQuestion \
"In class \"$clssName\", method \"$methodName\":\
\n delete parameter \"$paramName\"" \
"Delete parameter?" \
"parameter-delete" \
[$this clss]]
if {$answer == "yes"} {
[$this edMethod] deleteCell $param
}
}
}
method RTITMethod::createList {this} {
if {[$this edMethod] == ""} return
foreach cell [[$this edMethod] getCells] {
$this addUnUsedParam $cell
}
}
method RTITMethod::setBestMatch {this} {
# this is the most tricky method.
# methods are the same if the signature is the same, this
# means that we should determine the signature of the
# methods from the it and rt models, compare these and
# it they match use that one. if they don't match use
# the first method with the same name (warning: this makes
# re-ordering of methods dangerous)
# a signature consists of the name, type and parameters
# (with their names, types and ordering).
# calc signature of RT method
set signatureRt "[[$this rtMethod] name]:[[$this rtMethod] type]"
[[$this rtMethod] rtParamSet] foreach param {
set signatureRt "$signatureRt:[$param name]:[$param type]"
}
[[$this clss] unUsedMethodSet] foreach mthd {
# make sure it is not the default ctor "$create"
if [regexp {^.*$create[^(]*$} [$mthd getLabel name_type]] {
puts "Default ctor found"
[[$this clss] unUsedMethodSet] removeValue $mthd
continue
}
# calc signature of IT method
set signatureEd "[$mthd getItem name_type pe]"
set signatureEd "$signatureEd:[$mthd getItem name_type cl]"
foreach cell [$mthd getCells] {
set signatureEd "$signatureEd:[$cell getItem name_type de]"
set signatureEd "$signatureEd:[$cell getItem name_type cl]"
}
if { $signatureRt == $signatureEd } {
# found a matching signature
$this edMethod $mthd
[[$this clss] unUsedMethodSet] removeValue $mthd
return
}
}
# no matching signature found, so try to find a method with the same name
[[$this clss] unUsedMethodSet] foreach mthd {
if { [$mthd getItem "name_type" "pe"] == [[$this rtMethod] name] } {
# found a matching name (signatures don't match)
$this edMethod $mthd
[[$this clss] unUsedMethodSet] removeValue $mthd
return
}
}
# no matching name found either, so create a new method
set clssName [[[$this clss] rtClass] name]
set mthdName [[$this rtMethod] name]
set answer [[[$this clss] ui] askQuestion \
"In class \"$clssName\": add method \"$mthdName\"" \
"Add method?" \
"method-add" \
[$this clss]]
if {$answer == "yes"} {
set newMethod [[[$this clss] edMatrix] addRow "method"]
$this edMethod $newMethod
set type [${RTITClass::langTypeTable} getTypeByStdTypeName [[$this rtMethod] type]]
if {$type == ""} {
set type [${RTITClass::langTypeTable} getType [[$this rtMethod] type]]
if {$type != ""} {
set typeStr [$type stdTypeName]
if [regsub "(.*:.*)[[$this rtMethod] type](.*)" \
"[[$this rtMethod] getLabel name_type]" \
"\\1$typeStr\\2" newLabel] {
[$this rtMethod] setLabel name_type $newLabel
}
}
}
$newMethod setLabel name_type [[$this rtMethod] getLabel name_type]
[[$this rtMethod] rtPropertySet] foreach prop {
set name [$prop name]
switch $name {
"is_class_feature" continue
"is_abstract" continue
}
set item [$prop item]
switch $item {
"name" { set itlbl "name_type" ; set ititem "pe" }
"type" { set itlbl "name_type" ; set ititem "cl" }
"comp" { set itlbl "name_type" ; set ititem "" }
}
set value [$prop value]
$newMethod setProp $name $value $itlbl $ititem
}
} else {
$this edMethod ""
}
}
method RTITMethod::setPosition {this} {
if {[$this edMethod] == ""} return
set prev [$this prev]
if { $prev != "" } {
# not the first one, so move
if { [$prev edMethod] != ""} {
[$this edMethod] moveBehind [$prev edMethod]
}
}
}
method RTITMethod::prev {this} {
# Look for myself and sub one to the index
set idx [[[$this clss] mthdSet] search -exact $this]
if { $idx == -1 } {
return ""
} else {
set previdx [expr $idx - 1]
if { $previdx != -1 } {
return [[[$this clss] mthdSet] index $previdx]
} else {
return ""
}
}
}
method RTITMethod::next {this} {
# Look for myself and add one to the index
set idx [[[$this clss] mthdSet] search -exact $this]
if { $idx == -1 } {
return ""
} else {
set nextidx [expr $idx + 1]
if { $nextidx < [[[$this clss] mthdSet] length] } {
return [[[$this clss] mthdSet] index $nextidx]
} else {
return ""
}
}
}
# Do not delete this line -- regeneration end marker
method RTITMethod::clss {this args} {
if {$args == ""} {
return [$this _clss]
}
set ref [$this _clss]
if {$ref != ""} {
[$ref _mthdSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _mthdSet] append $this
}
$this _clss $obj
}
method RTITMethod::paramSet {this} {
return [$this _paramSet]
}
method RTITMethod::addParam {this newParam} {
[$this _paramSet] append $newParam
$newParam _mthd $this
}
method RTITMethod::removeParam {this oldParam} {
$oldParam _mthd ""
[$this _paramSet] removeValue $oldParam
}
method RTITMethod::addUnUsedParam {this newUnUsedParam} {
[$this unUsedParamSet] append $newUnUsedParam
}
method RTITMethod::removeUnUsedParam {this oldUnUsedParam} {
[$this unUsedParamSet] removeValue $oldUnUsedParam
}
#---------------------------------------------------------------------------
# File: @(#)rtitparam.tcl /main/titanic/13
# End user added include file section
Class RTITParam : {GCObject} {
constructor
method destructor
method go
method update
method setBestMatch
method setPosition
method prev
method next
method mthd
attribute _mthd
attribute rtParam
attribute edParam
}
constructor RTITParam {class this mthd rtParam} {
set this [GCObject::constructor $class $this]
$this _mthd $mthd
[$mthd _paramSet] append $this
$this rtParam $rtParam
# Start constructor user section
# End constructor user section
return $this
}
method RTITParam::destructor {this} {
# Start destructor user section
# End destructor user section
}
method RTITParam::go {this} {
$this setBestMatch
$this setPosition
}
method RTITParam::update {this} {
if {[$this edParam] == ""} return
if {[$this mthd] == ""} return
if {[[$this mthd] clss] == ""} return
# compare the name and type item of each parameter
set paramName [[$this edParam] getItem name_type de]
set standTypeDiag [[$this edParam] getItem name_type cl]
set langTypeDiag $standTypeDiag
set type [${RTITClass::langTypeTable} getTypeByStdTypeName $standTypeDiag]
if {$type != ""} {
set langTypeDiag [$type name]
}
if { ([[$this rtParam] name] != $paramName) ||
(([[$this rtParam] type] != $standTypeDiag) &&
([[$this rtParam] type] != $langTypeDiag))} {
set typeStr ""
if {[[$this rtParam] type] == $langTypeDiag} {
set typeStr $standTypeDiag
} else {
set type [${RTITClass::langTypeTable} getTypeByStdTypeName [[$this rtParam] type]]
if {$type == ""} {
set type [${RTITClass::langTypeTable} getType [[$this rtParam] type]]
if {$type != ""} {
set typeStr [$type stdTypeName]
}
}
}
if {$typeStr != ""} {
if [regsub "(.*:.*)[[$this rtParam] type](.*)" \
[[$this rtParam] getLabel name_type] \
"\\1$typeStr\\2" newLabel] {
[$this rtParam] setLabel name_type $newLabel
}
}
set clssName [[[[$this mthd] clss] rtClass] name]
set methodName [[[$this mthd] rtMethod] name]
set paramNLbl [[$this rtParam] getLabel name_type]
regsub -all "\[\t\n, \]" [[$this edParam] getLabel name_type] "" paramOLbl
set answer [[[[$this mthd] clss] ui] askQuestion \
"In class \"$clssName\":\
\n change parameter of method \"$methodName\"\
\n from \"$paramOLbl\" into \"$paramNLbl\"" \
"Change parameter?" \
"parameter-change_label" \
[[$this mthd] clss]]
if {$answer == "yes"} {
[$this edParam] setLabel name_type $paramNLbl
}
}
# check all known properties
# known properties are properties which have been defined by the
# parser which gave us our input
[[$this rtParam] rtPropertySet] foreach prop {
set item [$prop item]
switch $item {
"name" { set itlbl "name_type" ; set ititem "de" }
"type" { set itlbl "name_type" ; set ititem "cl" }
"comp" { set itlbl "" ; set ititem "" }
}
set name [$prop name]
set value [$prop value]
set itvalue [[$this edParam] getProp $name $itlbl $ititem]
set defaultValue [PropKnowledge::getDefaultValue $name]
if [info exists debug] {
puts stderr "value: '$value' itvalue: '$itvalue' defaultValue: '$defaultValue'"
}
if { $itvalue == "" } {
set itvalue $defaultValue
}
if { $value == "" } {
set value $defaultValue
}
if { $itvalue != $value } {
set clssName [[[[$this mthd] clss] rtClass] name]
set methodName [[[$this mthd] rtMethod] name]
set fullPropName [PropKnowledge::getLongName $name]
set answer [[[[$this mthd] clss] ui] askQuestion \
"In class \"$clssName\", method \"$methodName\"\
\n change property \"$fullPropName\" of parameter \"$paramName\"\
\n from \"$itvalue\" into \"$value\"" \
"Change parameter property?" \
"parameter-change_property" \
[[$this mthd] clss]]
if {$answer == "yes"} {
if { $value == $defaultValue } {
set value ""
}
[$this edParam] setProp $name $value $itlbl $ititem
}
}
}
}
method RTITParam::setBestMatch {this} {
if {[$this rtParam] == ""} return
if {[$this mthd] == ""} return
if {[[$this mthd] clss] == ""} return
if {[[$this mthd] edMethod] == ""} return
[[$this mthd] unUsedParamSet] foreach param {
if { [$param getItem name_type de] == [[$this rtParam] name] } {
# found a parameter with the same name.
# most languages don't support multiple parameters
# with the same name, but if there is a language,
# we will simply take the first one found.
$this edParam $param
[[$this mthd] unUsedParamSet] removeValue $param
return
}
}
# attribute was not found
# create a new attribute
set clssName [[[[$this mthd] clss] rtClass] name]
set methodName [[[$this mthd] rtMethod] name]
set paramName [[$this rtParam] name]
set answer [[[[$this mthd] clss] ui] askQuestion \
"In class \"$clssName\", method \"$methodName\":\
\n add parameter \"$paramName\"" \
"Add parameter?" \
"parameter-add" \
[[$this mthd] clss]]
if {$answer == "yes"} {
set newParam [[[$this mthd] edMethod] addCell "parameter"]
$this edParam $newParam
set type [${RTITClass::langTypeTable} getTypeByStdTypeName [[$this rtParam] type]]
if {$type == ""} {
set type [${RTITClass::langTypeTable} getType [[$this rtParam] type]]
if {$type != ""} {
set typeStr [$type stdTypeName]
if [regsub "(.*:.*)[[$this rtParam] type](.*)" \
"[[$this rtParam] getLabel name_type]" \
"\\1$typeStr\\2" newLabel] {
[$this rtParam] setLabel name_type $newLabel
}
}
}
$newParam setLabel name_type [[$this rtParam] getLabel name_type]
[[$this rtParam] rtPropertySet] foreach prop {
set item [$prop item]
switch $item {
"name" { set itlbl "name_type" ; set ititem "de" }
"type" { set itlbl "name_type" ; set ititem "cl" }
"comp" { set itlbl "" ; set ititem "" }
}
set name [$prop name]
set value [$prop value]
set itvalue [[$this edParam] getProp $name $itlbl $ititem]
$newParam setProp $name $value $itlbl $ititem
}
} else {
$this edParam ""
}
}
method RTITParam::setPosition {this} {
if {[$this edParam] == ""} return
set prev [$this prev]
if { $prev != "" } {
# not the first one, so move
if { [$prev edParam] != "" } {
[$this edParam] moveBehind [$prev edParam]
}
}
}
method RTITParam::prev {this} {
# Look for myself and sub one to the index
set idx [[[$this mthd] paramSet] search -exact $this]
if { $idx == -1 } {
return ""
} else {
set previdx [expr $idx - 1]
if { $previdx != -1 } {
return [[[$this mthd] paramSet] index $previdx]
} else {
return ""
}
}
}
method RTITParam::next {this} {
# Look for myself and add one to the index
set idx [[[$this mthd] paramSet] search -exact $this]
if { $idx == -1 } {
return ""
} else {
set nextidx [expr $idx + 1]
if { $nextidx < [[[$this mthd] paramSet] length] } {
return [[[$this mthd] paramSet] index $nextidx]
} else {
return ""
}
}
}
# Do not delete this line -- regeneration end marker
method RTITParam::mthd {this args} {
if {$args == ""} {
return [$this _mthd]
}
set ref [$this _mthd]
if {$ref != ""} {
[$ref _paramSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _paramSet] append $this
}
$this _mthd $obj
}
#---------------------------------------------------------------------------
# File: @(#)rtituserin.tcl /main/titanic/17
# End user added include file section
Class RTITUserInterface : {GCObject} {
constructor
method destructor
method askQuestion
attribute configuration
attribute changes
}
constructor RTITUserInterface {class this} {
set this [GCObject::constructor $class $this]
# Start constructor user section
$this configuration [Dictionary new]
$this changes 0
set clientContext [ClientContext::global]
set config [path_name concat \
[location [M4Login::getHomeDir] icase] roundtrip roundtrip]
if [file exists $config] {
set configList [readConfigurationFile $config]
} else {
set config [args_file {}]
$clientContext downLoadCustomFile roundtrip roundtrip etc $config
set configList [readConfigurationFile $config]
unlink $config
}
foreach configLine $configList {
set key "[lindex $configLine 0]-[lindex $configLine 1]"
set value "[lindex $configLine 2] [lindex $configLine 3]"
[$this configuration] set $key $value
}
# End constructor user section
return $this
}
method RTITUserInterface::destructor {this} {
# Start destructor user section
# End destructor user section
}
method RTITUserInterface::askQuestion {this question shortQuestion qtype {clss ""}} {
set action ""
set defaultAnswer ""
set conf [[$this configuration] set $qtype]
if {$conf != ""} {
set action [lindex $conf 0]
set defaultAnswer [string tolower [lindex $conf 1]]
}
if { ($action != "ask") && ($action != "display") && ($action != "none") } {
set action "ask"
}
if { ($defaultAnswer != "yes") && ($defaultAnswer != "no") } {
set defaultAnswer "no"
}
if { ($action == "ask") || ($action == "display") } {
puts "\n$question"
}
if { ($action == "display") || ($action == "none") } {
if { $defaultAnswer != "yes" } {
puts "Skipped..."
} else {
$this changes [expr [$this changes] + 1]
}
return $defaultAnswer
}
puts -nonewline \
"QUESTION $defaultAnswer $shortQuestion"
flush stdout
set answer [gets stdin]
set retval $defaultAnswer
if {[string toupper [string index $answer 0]] == "N"} {
return "no"
}
if {[string toupper [string index $answer 0]] == "Y"} {
$this changes [expr [$this changes] + 1]
return "yes"
}
if {[string toupper [string index $answer 0]] == "S"} {
if {$clss != ""} {
set matrix [$clss edMatrix]
if {$matrix != ""} {
$matrix quit
exit
}
} else {
$this changes -10000
return "no"
}
}
if { $defaultAnswer == "yes" } {
$this changes [expr [$this changes] + 1]
}
return $defaultAnswer
}
# Do not delete this line -- regeneration end marker
#---------------------------------------------------------------------------
# File: @(#)rtproperty.tcl /main/titanic/2
Class RTProperty : {GCObject} {
constructor
method destructor
method REGenerate
method rtComp
attribute name
attribute value
attribute item
attribute _rtComp
}
constructor RTProperty {class this} {
set this [GCObject::constructor $class $this]
# Start constructor user section
# End constructor user section
return $this
}
method RTProperty::destructor {this} {
# Start destructor user section
# End destructor user section
}
method RTProperty::REGenerate {this RTFd} {
puts $RTFd "\$[[$this rtComp] getUniqueName] setProp \{[$this name]\} \{[$this value]\} [$this item]"
}
# Do not delete this line -- regeneration end marker
method RTProperty::rtComp {this args} {
if {$args == ""} {
return [$this _rtComp]
}
set ref [$this _rtComp]
if {$ref != ""} {
[$ref _rtPropertySet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _rtPropertySet] append $this
}
$this _rtComp $obj
}
#---------------------------------------------------------------------------
# File: @(#)rtattrib.tcl /main/titanic/6
Class RTAttrib : {RTComp} {
constructor
method destructor
method update
method checkAccess
method REGenerate
method rtClass
attribute section
attribute mods
attribute name
attribute type
attribute initValue
attribute keyAttrib
attribute _rtClass
}
constructor RTAttrib {class this rtDiagram} {
set this [RTComp::constructor $class $this $rtDiagram]
# Start constructor user section
$this keyAttrib 0
# End constructor user section
return $this
}
method RTAttrib::destructor {this} {
# Start destructor user section
# End destructor user section
$this RTComp::destructor
}
method RTAttrib::update {this} {
if {[$this name] != ""} {
# WARNING: key attributes update should be called after all ctors
# are available!
return
}
set lbl [$this findLabel "name_type"]
if {$lbl != ""} {
if [regexp \
"(\[ \t\]*)(\[\\\$/*\]*)(\[ \t\]*)(\[^:= \t\]+)(\[: \t\]*)(\[^= \t\]+)?(\[ \t\]*)(=.*)?\$" \
[$lbl value] discard ws0 mods ws1 name point type ws2 initval] {
$this mods $mods
$this name $name
$this type $type
if [regexp "(\[ \t=\]*)(.*)" $initval discard assign val] {
$this initValue $val
} else {
$this initValue $initval
}
$this setProp "initial_value" [$this initValue]
if [regexp {\$} $mods] {
$this setProp "is_class_feature" "1"
}
if [regexp {/} $mods] {
$this setProp "is_derived" "1"
}
if [regexp {[*]} $mods] {
$this setProp "key" "1"
} else {
# Look for a default constructor with this attrib as param
[[$this rtClass] rtMethodSet] foreach mthd {
if { [$mthd section] == "default-constructor-destructor" &&
[$mthd name] == "create" } {
# Found the constructor we were looking for
# Check it parameters (try to match this attributes name)
set paramName "i_[$this name]"
[$mthd rtParamSet] foreach param {
if {$paramName == [$param name]} {
# Found the parameter
$this keyAttrib 1
break
}
}
break
}
}
}
}
}
}
method RTAttrib::checkAccess {this} {
if {[$this section] != "user-defined-attribute"} {
# skip all non user-defined attributes
return
}
if {![info exists hasGetSetMethod]} {
return
}
if {!$hasGetSetMethod} {
return
}
set raccess "None"
set waccess "None"
global methodAccessPropName
[[$this rtClass] rtMethodSet] foreach mthd {
if { [$mthd section] == "attribute-accessor-method" } {
set prop [$mthd findProp $methodAccessPropName "comp"]
if {$prop != ""} {
set access [$prop value]
} else {
set access [PropKnowledge::getDefaultValue method_access]
}
if [isGetMethod $mthd $this] {
set raccess $access
}
if [isSetMethod $mthd $this] {
set waccess $access
}
}
}
global attribAccessPropName
$this setProp $attribAccessPropName "${raccess}-${waccess}" "name"
}
method RTAttrib::REGenerate {this RTFd} {
puts $RTFd "set [$this getUniqueName] \[\$[[$this rtClass] getUniqueName] addAttrib \"\" \{[$this section]\}\]"
$this REGenerateSub $RTFd
}
# Do not delete this line -- regeneration end marker
method RTAttrib::rtClass {this args} {
if {$args == ""} {
return [$this _rtClass]
}
set ref [$this _rtClass]
if {$ref != ""} {
[$ref _rtAttribSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _rtAttribSet] append $this
}
$this _rtClass $obj
}
#---------------------------------------------------------------------------
# File: @(#)rtclass.tcl /main/titanic/8
# End user added include file section
Class RTClass : {RTComp} {
constructor
method destructor
method addMethod
method addAttrib
method addGeneralization
method update
method REGenerate
method accessible
method assocStartSet
method addAssocStart
method removeAssocStart
method superGenSet
method addSuperGen
method removeSuperGen
method assocEndSet
method addAssocEnd
method removeAssocEnd
method rtAttribSet
method addRtAttrib
method removeRtAttrib
method rtMethodSet
method addRtMethod
method removeRtMethod
method genSet
method addGen
method removeGen
attribute section
attribute derived
attribute name
attribute doneNN
attribute _assocStartSet
attribute _superGenSet
attribute _assocEndSet
attribute _rtAttribSet
attribute _rtMethodSet
attribute _genSet
}
constructor RTClass {class this rtDiagram} {
set this [RTComp::constructor $class $this $rtDiagram]
$this doneNN 0
$this _assocStartSet [List new]
$this _superGenSet [List new]
$this _assocEndSet [List new]
$this _rtAttribSet [List new]
$this _rtMethodSet [List new]
$this _genSet [List new]
# Start constructor user section
# End constructor user section
return $this
}
method RTClass::destructor {this} {
# Start destructor user section
# End destructor user section
$this RTComp::destructor
}
method RTClass::addMethod {this {nameType ""} {section "user-defined-method"}} {
set mthd [RTMethod new [$this rtDiagram]]
$mthd section $section
if {$nameType != ""} {
$mthd setLabel "name_type" $nameType
}
$this addRtMethod $mthd
return $mthd
}
method RTClass::addAttrib {this {nameType ""} {section "user-defined-attribute"}} {
set attr [RTAttrib new [$this rtDiagram]]
$attr section $section
if {$nameType != ""} {
$attr setLabel "name_type" $nameType
}
$this addRtAttrib $attr
return $attr
}
method RTClass::addGeneralization {this super {overlap 0}} {
[$super genSet] foreach gen {
if { [$gen overlap] == $overlap } {
$gen addDerived $this
return $gen
}
}
# No generalization created yet, create one
set ng [RTGen new [$this rtDiagram]]
$ng overlap $overlap
$ng super $super
$ng addDerived $this
return $ng
}
method RTClass::update {this} {
[$this rtMethodSet] foreach mthd {
$mthd update
}
[$this rtAttribSet] foreach attr {
$attr update
}
if {[$this name] != ""} {
return
}
set lbl [$this findLabel "name"]
if {$lbl != ""} {
regsub -all "\[ \t\n\]" [$lbl value] "" value
if [regexp {(/*)(.*)} $value discard derived name] {
$this derived $derived
$this name $name
}
}
set prop [$this getProp "is_folded"]
if {$prop != ""} {
if {$prop == "1"} {
return
}
}
}
method RTClass::REGenerate {this} {
$this doneNN 1
[$this rtDiagram] startREFile
puts [[$this rtDiagram] RTFd] "set [$this getUniqueName] \[\$diag findClass \"[$this name]\"]"
puts [[$this rtDiagram] RTFd] "if {\$[$this getUniqueName] == \"\"} {"
puts [[$this rtDiagram] RTFd] " set [$this getUniqueName] \[\$diag addClass \"[$this name]\"\]"
puts [[$this rtDiagram] RTFd] " \$[$this getUniqueName] setProp {rt_control} {1} name"
puts [[$this rtDiagram] RTFd] "}"
$this REGenerateSub [[$this rtDiagram] RTFd]
[$this rtMethodSet] foreach mthd {
$mthd REGenerate [[$this rtDiagram] RTFd]
}
[$this rtAttribSet] foreach attr {
$attr REGenerate [[$this rtDiagram] RTFd]
}
[$this genSet] foreach gen {
$gen REGenerateSubC [[$this rtDiagram] RTFd]
}
[$this superGenSet] foreach gen {
$gen REGenerateSuper [[$this rtDiagram] RTFd] $this
}
[$this assocStartSet] foreach con {
$con REGenerate [[$this rtDiagram] RTFd]
}
[$this assocEndSet] foreach con {
$con REGenerate [[$this rtDiagram] RTFd]
}
}
method RTClass::accessible {this} {
if {[$this doneNN] == 1} {
return 1
}
if {[$this section] != "new-control"} {
puts [[$this rtDiagram] RTFd] "set [$this getUniqueName] \[\$diag findClass \"[$this name]\"]"
puts [[$this rtDiagram] RTFd] "if {\$[$this getUniqueName] == \"\"} {"
puts [[$this rtDiagram] RTFd] " set [$this getUniqueName] \[\$diag addClass \"[$this name]\"\]"
puts [[$this rtDiagram] RTFd] "}"
puts [[$this rtDiagram] RTFd] "\$[$this getUniqueName] setProp {is_folded} {1} comp"
return 1
}
return 0
}
# Do not delete this line -- regeneration end marker
method RTClass::assocStartSet {this} {
return [$this _assocStartSet]
}
method RTClass::addAssocStart {this newAssocStart} {
[$this _assocStartSet] append $newAssocStart
$newAssocStart _start $this
}
method RTClass::removeAssocStart {this oldAssocStart} {
$oldAssocStart _start ""
[$this _assocStartSet] removeValue $oldAssocStart
}
method RTClass::superGenSet {this} {
return [$this _superGenSet]
}
method RTClass::addSuperGen {this newSuperGen} {
[$this _superGenSet] append $newSuperGen
[$newSuperGen _derivedSet] append $this
}
method RTClass::removeSuperGen {this oldSuperGen} {
[$oldSuperGen _derivedSet] removeValue $this
[$this _superGenSet] removeValue $oldSuperGen
}
method RTClass::assocEndSet {this} {
return [$this _assocEndSet]
}
method RTClass::addAssocEnd {this newAssocEnd} {
[$this _assocEndSet] append $newAssocEnd
$newAssocEnd _end $this
}
method RTClass::removeAssocEnd {this oldAssocEnd} {
$oldAssocEnd _end ""
[$this _assocEndSet] removeValue $oldAssocEnd
}
method RTClass::rtAttribSet {this} {
return [$this _rtAttribSet]
}
method RTClass::addRtAttrib {this newRtAttrib} {
[$this _rtAttribSet] append $newRtAttrib
$newRtAttrib _rtClass $this
}
method RTClass::removeRtAttrib {this oldRtAttrib} {
$oldRtAttrib _rtClass ""
[$this _rtAttribSet] removeValue $oldRtAttrib
}
method RTClass::rtMethodSet {this} {
return [$this _rtMethodSet]
}
method RTClass::addRtMethod {this newRtMethod} {
[$this _rtMethodSet] append $newRtMethod
$newRtMethod _rtClass $this
}
method RTClass::removeRtMethod {this oldRtMethod} {
$oldRtMethod _rtClass ""
[$this _rtMethodSet] removeValue $oldRtMethod
}
method RTClass::genSet {this} {
return [$this _genSet]
}
method RTClass::addGen {this newGen} {
[$this _genSet] append $newGen
$newGen _super $this
}
method RTClass::removeGen {this oldGen} {
$oldGen _super ""
[$this _genSet] removeValue $oldGen
}
#---------------------------------------------------------------------------
# File: @(#)rtconn.tcl /main/titanic/1
Class RTConn : {RTComp} {
constructor
method destructor
method REGenerate
method start
method end
attribute connType
attribute done
attribute _start
attribute _end
}
constructor RTConn {class this rtDiagram i_connType start end} {
set this [RTComp::constructor $class $this $rtDiagram]
$this done 0
$this connType $i_connType
$this _start $start
[$start _assocStartSet] append $this
$this _end $end
[$end _assocEndSet] append $this
# Start constructor user section
# End constructor user section
return $this
}
method RTConn::destructor {this} {
# Start destructor user section
# End destructor user section
$this RTComp::destructor
}
method RTConn::REGenerate {this RTFd} {
if {[$this done] != 1} {
if {[[$this start] accessible] == 1} {
if {[[$this end] accessible] == 1} {
$this done 1
puts $RTFd "set [$this getUniqueName] \[ \$diag addConn \{[$this connType]\} \$[[$this start] getUniqueName] \$[[$this end] getUniqueName]\]"
$this REGenerateSub $RTFd
}
}
}
}
# Do not delete this line -- regeneration end marker
method RTConn::start {this args} {
if {$args == ""} {
return [$this _start]
}
set ref [$this _start]
if {$ref != ""} {
[$ref _assocStartSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _assocStartSet] append $this
}
$this _start $obj
}
method RTConn::end {this args} {
if {$args == ""} {
return [$this _end]
}
set ref [$this _end]
if {$ref != ""} {
[$ref _assocEndSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _assocEndSet] append $this
}
$this _end $obj
}
#---------------------------------------------------------------------------
# File: @(#)rtgen.tcl /main/titanic/2
Class RTGen : {RTComp} {
constructor
method destructor
method ifDone
method REGenerateSubC
method REGenerateSuper
method super
method addDone
method removeDone
method derivedSet
method addDerived
method removeDerived
attribute overlap
attribute _super
attribute doneSet
attribute _derivedSet
}
constructor RTGen {class this rtDiagram} {
set this [RTComp::constructor $class $this $rtDiagram]
$this doneSet [List new]
$this _derivedSet [List new]
# Start constructor user section
# End constructor user section
return $this
}
method RTGen::destructor {this} {
# Start destructor user section
# End destructor user section
$this RTComp::destructor
}
method RTGen::ifDone {this cls} {
[$this doneSet] foreach don {
if {$cls == $don} {
return 1
}
}
return 0
}
method RTGen::REGenerateSubC {this RTFd} {
if {[[$this super] accessible] == 1} {
[$this derivedSet] foreach sub {
if {[$this ifDone $sub] != 1} {
if {[$sub accessible] == 1} {
puts $RTFd "set [$this getUniqueName] \[\$[$sub getUniqueName] addGeneralization \$[[$this super] getUniqueName] \{[$this overlap]\}\]"
$this REGenerateSub $RTFd
$this addDone $sub
}
}
}
}
}
method RTGen::REGenerateSuper {this RTFd sub} {
if {[[$this super] accessible] == 1} {
if {[$this ifDone $sub] != 1} {
if {[$sub accessible] == 1} {
puts $RTFd "set [$this getUniqueName] \[\$[$sub getUniqueName] addGeneralization \$[[$this super] getUniqueName] \{[$this overlap]\}\]"
$this REGenerateSub $RTFd
$this addDone $sub
}
}
}
}
# Do not delete this line -- regeneration end marker
method RTGen::super {this args} {
if {$args == ""} {
return [$this _super]
}
set ref [$this _super]
if {$ref != ""} {
[$ref _genSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _genSet] append $this
}
$this _super $obj
}
method RTGen::addDone {this newDone} {
[$this doneSet] append $newDone
}
method RTGen::removeDone {this oldDone} {
[$this doneSet] removeValue $oldDone
}
method RTGen::derivedSet {this} {
return [$this _derivedSet]
}
method RTGen::addDerived {this newDerived} {
[$this _derivedSet] append $newDerived
[$newDerived _superGenSet] append $this
}
method RTGen::removeDerived {this oldDerived} {
[$oldDerived _superGenSet] removeValue $this
[$this _derivedSet] removeValue $oldDerived
}
#---------------------------------------------------------------------------
# File: @(#)rtlabel.tcl /main/titanic/2
Class RTLabel : {RTComp} {
constructor
method destructor
method REGenerate
method rtComp
attribute name
attribute value
attribute _rtComp
}
constructor RTLabel {class this rtDiagram} {
set this [RTComp::constructor $class $this $rtDiagram]
# Start constructor user section
# End constructor user section
return $this
}
method RTLabel::destructor {this} {
# Start destructor user section
# End destructor user section
$this RTComp::destructor
}
method RTLabel::REGenerate {this RTFd} {
puts $RTFd "set [$this getUniqueName] \[\$[[$this rtComp] getUniqueName] setLabel \{[$this name]\} \{[$this value]\}\]"
$this REGenerateSub $RTFd
}
# Do not delete this line -- regeneration end marker
method RTLabel::rtComp {this args} {
if {$args == ""} {
return [$this _rtComp]
}
set ref [$this _rtComp]
if {$ref != ""} {
[$ref _rtLabelSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _rtLabelSet] append $this
}
$this _rtComp $obj
}
#---------------------------------------------------------------------------
# File: @(#)rtmethod.tcl /main/titanic/3
Class RTMethod : {RTComp} {
constructor
method destructor
method addParam
method update
method REGenerate
method rtClass
method rtParamSet
method addRtParam
method removeRtParam
attribute section
attribute mods
attribute name
attribute type
attribute constraint
attribute _rtClass
attribute _rtParamSet
}
constructor RTMethod {class this rtDiagram} {
set this [RTComp::constructor $class $this $rtDiagram]
$this _rtParamSet [List new]
# Start constructor user section
# End constructor user section
return $this
}
method RTMethod::destructor {this} {
# Start destructor user section
# End destructor user section
$this RTComp::destructor
}
method RTMethod::addParam {this {nameType ""}} {
set prm [RTParam new [$this rtDiagram]]
$this addRtParam $prm
if { $nameType != "" } {
$prm setLabel "name_type" $nameType
}
return $prm
}
method RTMethod::update {this} {
[$this rtParamSet] foreach prm {
$prm update
}
if {[$this name] != ""} {
return
}
set lbl [$this findLabel "name_type"]
if {$lbl != ""} {
regsub -all "\[ \t\n\]" [$lbl value] "" value
if [regexp {(\$)?([^(:\{]+)([()]*)(:[^\{]+)?(\{abstract\})?$}\
$value discard mods name braces type constraint] {
$this mods $mods
$this name $name
if [regexp {(:)?(.*)} $type discard point typeName] {
$this type $typeName
} else {
$this type $type
}
$this constraint $constraint
if { $constraint == "{abstract}" } {
$this setProp "is_abstract" "1"
}
if { $mods == "\$" } {
$this setProp "is_class_feature" "1"
}
}
}
}
method RTMethod::REGenerate {this RTFd} {
puts $RTFd "set [$this getUniqueName] \[\$[[$this rtClass] getUniqueName] addMethod \"\" \{[$this section]\}\]"
[$this rtParamSet] foreach para {
$para REGenerate $RTFd
}
$this REGenerateSub $RTFd
}
# Do not delete this line -- regeneration end marker
method RTMethod::rtClass {this args} {
if {$args == ""} {
return [$this _rtClass]
}
set ref [$this _rtClass]
if {$ref != ""} {
[$ref _rtMethodSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _rtMethodSet] append $this
}
$this _rtClass $obj
}
method RTMethod::rtParamSet {this} {
return [$this _rtParamSet]
}
method RTMethod::addRtParam {this newRtParam} {
[$this _rtParamSet] append $newRtParam
$newRtParam _rtMethod $this
}
method RTMethod::removeRtParam {this oldRtParam} {
$oldRtParam _rtMethod ""
[$this _rtParamSet] removeValue $oldRtParam
}
#---------------------------------------------------------------------------
# File: @(#)rtparam.tcl /main/titanic/3
Class RTParam : {RTComp} {
constructor
method destructor
method update
method REGenerate
method rtMethod
attribute name
attribute type
attribute _rtMethod
}
constructor RTParam {class this rtDiagram} {
set this [RTComp::constructor $class $this $rtDiagram]
# Start constructor user section
# End constructor user section
return $this
}
method RTParam::destructor {this} {
# Start destructor user section
# End destructor user section
$this RTComp::destructor
}
method RTParam::update {this} {
if {[$this name] != ""} {
return
}
set lbl [$this findLabel "name_type"]
if {$lbl != ""} {
regsub -all "\[ \t\n\]" [$lbl value] "" value
if [regexp {([^:]+)(:)(.*)} $value discard name point type] {
$this name $name
$this type $type
}
}
}
method RTParam::REGenerate {this RTFd} {
puts $RTFd "set [$this getUniqueName] \[\$[[$this rtMethod] getUniqueName] addParam \"\"\]"
$this REGenerateSub $RTFd
}
# Do not delete this line -- regeneration end marker
method RTParam::rtMethod {this args} {
if {$args == ""} {
return [$this _rtMethod]
}
set ref [$this _rtMethod]
if {$ref != ""} {
[$ref _rtParamSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _rtParamSet] append $this
}
$this _rtMethod $obj
}