home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
javaconv.tcl
< prev
next >
Wrap
Text File
|
1996-12-23
|
5KB
|
205 lines
#---------------------------------------------------------------------------
#
# Copyright (c) 1996 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 : @(#)javaconv.tcl /main/hindenburg/3
# Author : Discovery
# Original date : December 1996
# Description : Tcl Script doing the following conversions on CDM's
# that are created for generating Java code in the
# current system:
# * attribute property
#
# default_value -> initial_value
#
# - " = <default_value>" is appended to name_type
# label
# - existing initial_value overrules default_value
# - default_value is deleted
# * row property
#
# is_static -> is_class_feature
#
# - "$" is prepended to name_type label if needed
# - existing is_class_feature overrules is_static
# - is_static is deleted
# Usage : otsh -f <this_file>
#
#---------------------------------------------------------------------------
#
# @(#)javaconv.tcl /main/hindenburg/3 23 Dec 1996 Copyright 1996 Cayenne Software Inc.
#
#---------------------------------------------------------------------------
global SCCS_W; set SCCS_W "
@(#)javaconv.tcl /main/hindenburg/3
"
global file
proc rowConv {row} {
if {[$row getCompType] == "attribute"} {
set isStatic [$row getProp "is_static" "name_type" "de"]
} else {
set isStatic [$row getProp "is_static"]
}
if {$isStatic != ""} {
set doConvert 1
set isClassFeature [$row getProp "is_class_feature"]
if {$isClassFeature != "" && $isStatic != $isClassFeature} {
puts stderr "WARNING: $file: [$row getCompType] '[$row getLabel "name_type"]' has 'is_static = $isStatic' unequal to 'is_class_feature = $isClassFeature'; latter one overrules"
set doConvert 0
}
if {[$row getCompType] == "attribute"} {
$row setProp "is_static" "" "name_type" "de"
} else {
$row setProp "is_static" ""
}
if {$doConvert} {
set nameType [$row getLabel "name_type"]
regsub {$} $nameType {} nameType
if {$isStatic == "1"} {
$row setLabel "name_type" "\$$nameType"
}
}
return 1
}
return 0
}
proc attrConv {attr} {
set defaultValue [$attr getProp "default_value" "name_type" "de"]
if {$defaultValue != ""} {
set doConvert 1
set initialValue [$attr getProp "initial_value"]
if {$initialValue != "" && $defaultValue != $initialValue} {
puts stderr "WARNING: $file: attribute '[$attr getLabel "name_type"]' has 'default_value = $defaultValue' unequal to 'initial_value = $initialValue'; latter one overrules"
set doConvert 0
}
$attr setProp "default_value" "" "name_type" "de"
if {$doConvert} {
set nameType [$attr getLabel "name_type"]
regsub {[ ]*=.*} $nameType {} nameType
$attr setLabel "name_type" "$nameType = $defaultValue"
}
return 1
}
return 0
}
proc javaConv {fileV} {
set diag [EdCDM new [[$fileV file] name] "" "" "" "" "" "" "" 1]
set isChanged 0
foreach row [$diag getRows] {
if {[$row getCompType] == "attribute"} {
set isChanged [expr $isChanged + [attrConv $row]]
}
set isChanged [expr $isChanged + [rowConv $row]]
}
if {$isChanged} {
$diag formatLayout
$diag save
} else {
$diag quit
}
}
proc main {} {
global file
set file [string trim $SCCS_W "\n"]
regsub "@.#.(.*)\t.*" $file {\1} file
set cc [ClientContext::global]
set sysV [$cc currentSystem]
if {[$cc currentLevel] == "File"} {
$cc upLevel
}
if {[$cc currentLevel] != "System"} {
puts stderr "ERROR: $file: cannot find out current system (levelpath is '[$cc currentLevelString]')"
exit 1
}
$cc upLevel
#
# Now we are at phase level, so we can freeze the system version
#
set systemName [[$sysV system] name]
if {[$sysV status] != "frozen"} {
puts "Freezing system '$systemName' before starting conversion."
$sysV freeze "Freeze before Java conversion ObjectTeam 4.0 to 5.1.1"
}
#
# Create new system version
#
set phaseV [$cc currentPhase]
puts "Creating new version of system '$systemName'"
set sysV [$phaseV derive -systemVersion $sysV [$cc currentConfig]]
$cc downLevelId $sysV
#
# Create new versions of all files
#
set fileVersions [$sysV allFileVersions]
foreach fileV $fileVersions {
set file [$fileV file]
puts "Creating new version of file '[$file name].[$file type]'"
$sysV derive -fileVersion $fileV [$cc currentConfig]
}
puts ""
puts "Starting conversion"
puts ""
OTShRegister::importToolEdExt
foreach fileV [$sysV allFileVersions] {
if {[[$fileV file] type] == "cdm"} {
javaConv $fileV
}
}
exit 0
}
main