home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
cstarget.tcl
< prev
next >
Wrap
Text File
|
1997-09-05
|
5KB
|
198 lines
#---------------------------------------------------------------------------
#
# 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 : @(#)cstarget.tcl /main/titanic/6 5 Sep 1997
# Original date : Fri Sep 5 12:02:36 MET DST 1997
# Description : Constraint satisfaction module
# Target language model derived custmizations
#
#---------------------------------------------------------------------------
require "cgcustom.tcl"
require "csconst.tcl"
Class CSRegen : [customizeTargetModel CppRegen CSRegen] {
attribute userCodeOk
method promoter
method append
}
method CSRegen::promoter {this} {
$this userCodeOk 1
}
method CSRegen::append {this text} {
global Constraint::beginEnsure
global Constraint::endEnsure
global Constraint::beginRequire
global Constraint::endRequire
global CSRegen::super
if {[string first ${Constraint::beginEnsure} $text] != -1} {
$this userCodeOk 0
}
if {[string first ${Constraint::beginRequire} $text] != -1} {
$this userCodeOk 0
}
if {[$this userCodeOk]==1} {
$this ${CSRegen::super}::append $text
}
if {[string first ${Constraint::endEnsure} $text] != -1} {
$this userCodeOk 1
}
if {[string first ${Constraint::endRequire} $text] != -1} {
$this userCodeOk 1
}
}
selfPromoter CppRegen {this} {
CSRegen promote $this
}
Class CSUserMethod : [customizeTargetModel CppUserMethod CSUserMethod] {
attribute ensure
attribute require
method formatComment
method formatHdrComment
method subGenerate
}
method CSUserMethod::formatComment {this section {prefix "// "}} {
}
method CSUserMethod::formatHdrComment {this section {prefix "// "}} {
global CSUserMethod::super
$this ${CSUserMethod::super}::formatComment $section $prefix
if {[$this require] != ""} {
$section append "${prefix}Require: [$this require]\n"
}
if {[$this ensure] != ""} {
$section append "${prefix}Ensure: [$this ensure]\n"
}
}
method CSUserMethod::subGenerate {this fileT section} {
global Constraint::beginEnsure
global Constraint::endEnsure
global Constraint::beginRequire
global Constraint::endRequire
$this formatComment $section
if { $fileT == "cpp" } {
if {![$this isAbstract]} {
$this genSignature $fileT $section
$section append "\n{\n"
$section indent +
if {[$this require] != ""} {
$section append "${Constraint::beginRequire}\n"
$section append "require([$this require]);\n"
$section append "${Constraint::endRequire}\n"
}
$this genRegenCode $section
if {[$this ensure] != ""} {
$section append "${Constraint::beginEnsure}\n"
$section append "ensure([$this ensure]);\n"
$section append "#ifdef RETURN\n"
$section append "return RETURN;\n"
$section append "#undef RETURN\n"
$section append "#endif\n"
$section append "${Constraint::endEnsure}\n"
}
$section indent -
$section append "}\n"
}
} else {
$this genSignature $fileT $section
}
}
selfPromoter CppUserMethod {this} {
CSUserMethod promote $this
}
Class CSUserAttrib : [customizeTargetModel CppUserAttrib CSUserAttrib] {
attribute invariant
method formatComment
method formatHdrComment
}
method CSUserAttrib::formatComment {this section {prefix "// "}} {
}
method CSUserAttrib::formatHdrComment {this section {prefix "// "}} {
global CSUserAttrib::super
$this ${CSUserAttrib::super}::formatComment $section $prefix
if {[$this invariant] != ""} {
$section append "${prefix}Invariants: [$this invariant]\n"
}
}
selfPromoter CppUserAttrib {this} {
CSUserAttrib promote $this
}
Class CSClass : [customizeTargetModel CppClass CSClass] {
method addHeader
}
method CSClass::addHeader {this fileT section} {
if {$fileT == "hdr"} {
set filename [$this hdrFileName]
} else {
set filename [$this cppFileName]
}
if {$fileT == "hdr" } {
set name "h++"
} else {
set name "c++"
}
expandHeaderIntoSection $filename $name $section
if { $fileT == "hdr" } {
$section append "// Class [$this name]\n"
$this formatComment $section "// "
$section append "//\n"
[$this featureSet] foreach feature {
if [$feature isA CppUserAttrib] {
$section append "// Attribute [$feature name]\n"
$feature formatHdrComment $section "// "
$section append "//\n"
}
}
[$this featureSet] foreach feature {
if [$feature isA CppUserMethod] {
$section append "// Method [$feature name]("
set comma ""
[$feature paramSet] foreach param {
$section append "${comma}[$param name]"
set comma ", "
}
$section append ")\n"
$feature formatHdrComment $section "// "
$section append "//\n"
}
}
}
$section append "\n"
}
selfPromoter CppClass {this} {
CSClass promote $this
}