home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-12-01 | 66.0 KB | 2,602 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 : cppgrammar.tcl
- # Author :
- # Original date : November 1997
- # Description : Classes for code generation
- #
- #---------------------------------------------------------------------------
-
- #---------------------------------------------------------------------------
- # File: @(#)cppextincl.tcl /main/titanic/1
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppExtInclude : {GCObject} {
- constructor
- method destructor
- method generate
- method definition
- attribute fileName
- attribute _definition
- }
-
- constructor CppExtInclude {class this definition} {
- set this [GCObject::constructor $class $this]
- $this _definition $definition
- [$definition _extIncludeSet] append $this
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppExtInclude::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method CppExtInclude::generate {this section} {
- $section append "#include <[$this fileName]>\n"
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppExtInclude::definition {this args} {
- if {$args == ""} {
- return [$this _definition]
- }
- set ref [$this _definition]
- if {$ref != ""} {
- [$ref _extIncludeSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _extIncludeSet] append $this
- }
- $this _definition $obj
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppfriend.tcl /main/titanic/5
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppFriend : {GCObject} {
- constructor
- method destructor
- method generate
- method friendOf
- attribute cl
- attribute _friendOf
- }
-
- constructor CppFriend {class this cl} {
- set this [GCObject::constructor $class $this]
- $this cl $cl
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppFriend::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method CppFriend::generate {this section} {
- $section append "friend class [[$this cl] getName];\n"
- [$this friendOf] addForward [$this cl] hdr
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppFriend::friendOf {this args} {
- if {$args == ""} {
- return [$this _friendOf]
- }
- set ref [$this _friendOf]
- if {$ref != ""} {
- [$ref _friendSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _friendSet] append $this
- }
- $this _friendOf $obj
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppgen.tcl /main/titanic/3
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppGen : {GCObject} {
- constructor
- method destructor
- method generate
- method subcl
- attribute isVirtual
- attribute cl
- attribute _subcl
- attribute access
- }
-
- constructor CppGen {class this cl access} {
- set this [GCObject::constructor $class $this]
- $this cl $cl
- $this access $access
- # Start constructor user section
- $this isVirtual 0
- # End constructor user section
- return $this
- }
-
- method CppGen::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method CppGen::generate {this section} {
- $section append "[$this access] "
- if [$this isVirtual] {
- $section append "virtual "
- }
- $section append "[[$this cl] getName]"
- [$this subcl] addInclude [$this cl] hdr
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppGen::subcl {this args} {
- if {$args == ""} {
- return [$this _subcl]
- }
- set ref [$this _subcl]
- if {$ref != ""} {
- [$ref _genSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _genSet] append $this
- }
- $this _subcl $obj
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppgencode.tcl /main/titanic/3
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppGenCode : {TextSection} {
- constructor
- method destructor
- method method
- attribute _method
- }
-
- constructor CppGenCode {class this method} {
- set this [TextSection::constructor $class $this]
- $this _method $method
- [$method _genCodeSet] append $this
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppGenCode::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppGenCode::method {this args} {
- if {$args == ""} {
- return [$this _method]
- }
- set ref [$this _method]
- if {$ref != ""} {
- [$ref _genCodeSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _genCodeSet] append $this
- }
- $this _method $obj
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppinitial.tcl /main/titanic/3
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppInitializer : {GCObject} {
- constructor
- method destructor
- method generate
- method ctor
- method valueSet
- method addValue
- method removeValue
- attribute name
- attribute _ctor
- attribute _valueSet
- }
-
- constructor CppInitializer {class this ctor} {
- set this [GCObject::constructor $class $this]
- $this _ctor $ctor
- [$ctor _initializerSet] append $this
- $this _valueSet [List new]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppInitializer::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method CppInitializer::generate {this section} {
- set cppCtor [$this ctor]
- set idx [ [$cppCtor initializerSet] search -exact $this ]
- if { $idx == -1 } {
- m4_fatal $F_INTINCON "CppInitializer::generate"
- return
- }
- if { $idx != 0 } {
- set comma ","
- } else {
- set comma " :"
- }
- $section indent +
- $section append "${comma}\n[$this name]("
- [$this valueSet] foreach value {
- $value generate $section
- }
- $section append ")"
- $section indent -
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppInitializer::ctor {this args} {
- if {$args == ""} {
- return [$this _ctor]
- }
- set ref [$this _ctor]
- if {$ref != ""} {
- [$ref _initializerSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _initializerSet] append $this
- }
- $this _ctor $obj
- }
-
- method CppInitializer::valueSet {this} {
- return [$this _valueSet]
- }
-
- method CppInitializer::addValue {this newValue} {
- [$this _valueSet] append $newValue
- $newValue _initializer $this
- }
-
- method CppInitializer::removeValue {this oldValue} {
- $oldValue _initializer ""
- [$this _valueSet] removeValue $oldValue
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppinitval.tcl /main/titanic/5
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppInitValue : {GCObject} {
- constructor
- method destructor
- method generate
- method initializer
- attribute value
- attribute _initializer
- }
-
- constructor CppInitValue {class this initializer} {
- set this [GCObject::constructor $class $this]
- $this _initializer $initializer
- [$initializer _valueSet] append $this
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppInitValue::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method CppInitValue::generate {this section} {
- set cppInit [$this initializer]
- set idx [ [$cppInit valueSet] search -exact $this ]
- if { $idx == -1 } {
- m4_fatal $F_INTINCON "CppInitValue::generate"
- exit
- }
- if { $idx != 0 } {
- set comma ", "
- } else {
- set comma ""
- }
- $section append "${comma}[$this value]"
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppInitValue::initializer {this args} {
- if {$args == ""} {
- return [$this _initializer]
- }
- set ref [$this _initializer]
- if {$ref != ""} {
- [$ref _valueSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _valueSet] append $this
- }
- $this _initializer $obj
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppmodel.tcl /main/titanic/14
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppModel : {GCObject} {
- constructor
- method destructor
- method findDefinition
- method generate
- method setFileNameParams
- method definitionSet
- method addDefinition
- method removeDefinition
- attribute _definitionSet
- }
-
- constructor CppModel {class this} {
- set this [GCObject::constructor $class $this]
- $this _definitionSet [List new]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppModel::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method CppModel::findDefinition {this name} {
- [$this definitionSet] foreach definition {
- if {$name == [$definition getName]} {
- return $definition
- }
- }
- return ""
- }
-
- method CppModel::generate {this typeToClassDict} {
-
- # define local section names
- # header file sections
- set hdrCategories [List new]
- set specialCategories [List new]
- # source file sections
- set cppCategories [List new]
- # title dictionary
- set titleDict [Dictionary new]
- # needs one indent
- set indentDict [Dictionary new]
-
- $cppCategories append "cpp-hdr"
- $cppCategories append "cpp-incl"
- $cppCategories append "cpp-static-init"
- $cppCategories append "cpp-ctor"
- $cppCategories append "cpp-dtor"
- $cppCategories append "cpp-impl"
- $titleDict set "cpp-impl-gen" "// ${CppConstants::regenEnd}\n"
- $cppCategories append "cpp-impl-gen"
- $cppCategories append "cpp-trailor"
-
- $hdrCategories append "hdr-hdr"
- $hdrCategories append "hdr-incl"
- $hdrCategories append "hdr-typedef" ; # special one
- $hdrCategories append "hdr-enum" ; # special one
- $hdrCategories append "hdr-class-head"
- foreach access {"public" "protected" "private"} {
- $titleDict set "hdr-typedef-$access" \
- "// Nested typedefs"
- $indentDict set "hdr-typedef-$access" "yes"
- $hdrCategories append "hdr-typedef-$access"
- $specialCategories append "hdr-typedef-$access"
-
- $titleDict set "hdr-ctor-$access" "// Default constructor/destructor"
- $indentDict set "hdr-ctor-$access" "yes"
- $hdrCategories append "hdr-ctor-$access"
- $indentDict set "hdr-dtor-$access" "yes"
- $hdrCategories append "hdr-dtor-$access"
-
- $titleDict set "hdr-user-defined-$access-meth" \
- "// User-defined methods"
- $indentDict set "hdr-user-defined-$access-meth" "yes"
- $hdrCategories append "hdr-user-defined-$access-meth"
-
- $titleDict set "hdr-attrib-access-$access" \
- "// Attribute accessor methods"
- $indentDict set "hdr-attrib-access-$access" "yes"
- $hdrCategories append "hdr-attrib-access-$access"
-
- $titleDict set "hdr-assoc-access-$access" \
- "// Association accessor methods"
- $indentDict set "hdr-assoc-access-$access" "yes"
- $hdrCategories append "hdr-assoc-access-$access"
-
- $titleDict set "hdr-user-defined-$access-data" \
- "// User-defined attributes"
- $indentDict set "hdr-user-defined-$access-data" "yes"
- $hdrCategories append "hdr-user-defined-$access-data"
-
- $titleDict set "hdr-special-$access-data" \
- "// Special attribute"
- $indentDict set "hdr-special-$access-data" "yes"
- $hdrCategories append "hdr-special-$access-data"
- $specialCategories append "hdr-special-$access-data"
-
- $titleDict set "hdr-special-$access-meth" \
- "// Special methods"
- $indentDict set "hdr-special-$access-meth" "yes"
- $hdrCategories append "hdr-special-$access-meth"
- $specialCategories append "hdr-special-$access-meth"
- }
-
- $specialCategories append "hdr-ctor-protected"
- $specialCategories append "hdr-ctor-private"
- $specialCategories append "hdr-user-defined-public-data"
- $specialCategories append "hdr-user-defined-protected-data"
-
- $titleDict set "hdr-assoc-storage-private-data" \
- "// Association attribute storage"
- $indentDict set "hdr-assoc-storage-private-data" "yes"
- $hdrCategories append "hdr-assoc-storage-private-data"
-
- $hdrCategories append "hdr-class-tail"
- $hdrCategories append "hdr-impl"
- $titleDict set "hdr-impl-gen" "// ${CppConstants::regenEnd}\n"
- $hdrCategories append "hdr-impl-gen"
- $specialCategories append "hdr-impl-gen"
- $hdrCategories append "hdr-trailor"
-
- [$this definitionSet] foreach definition {
- # first check if this is a normal class and if it
- # is synthetic, if so, skip this class
- if [$definition isA CppClass] {
- if [$definition isSynthetic] {
- continue
- }
- }
-
- # create sections
- set sections [CppSectionList new]
- $cppCategories foreach cat {
- $sections setSection $cat [TextSection new]
- }
- $hdrCategories foreach cat {
- $sections setSection $cat [TextSection new]
- }
-
- # generate code
- $definition generate $sections
-
- # combine sections
- set cppSection [TextSection new]
- set hdrSection [TextSection new]
-
- $cppCategories foreach cat {
- set sect [$sections getSection $cat]
- if {[string length [$sect contents]] != 0} {
- set marker [$titleDict set $cat]
- if { $marker != ""} {
- $cppSection append $marker
- $cppSection append "\n"
- }
- $cppSection appendSect $sect
- if {$cat == "cpp-static-init"} {
- $cppSection append "\n"
- }
- }
- }
-
- if { [$definition isA CppClass] } {
- $hdrCategories foreach cat {
- if { $cat == "hdr-typedef" } { continue }
- if { $cat == "hdr-enum" } { continue }
-
- switch $cat {
- "hdr-typedef-public" \
- { $hdrSection append "public:\n" }
- "hdr-typedef-protected" \
- { $hdrSection append "protected:\n" }
- "hdr-typedef-private" \
- { $hdrSection append "private:\n" }
- }
-
- if { [$indentDict set $cat] == "yes" } {
- $hdrSection indent +
- }
-
- set sect [$sections getSection $cat]
- set length [string length [$sect contents]]
-
- set marker [$titleDict set $cat]
- if { $marker != "" } {
- if { ($length != 0) ||
- ([$specialCategories search -exact $cat] == -1) } {
- $hdrSection append $marker
- $hdrSection append "\n"
- }
- }
-
- if {$length != 0} {
- $hdrSection appendSect $sect
- $hdrSection append "\n"
- }
-
- if { [$indentDict set $cat] == "yes" } {
- $hdrSection indent -
- }
- }
- } else {
- # special cases (typedef or enum)
- foreach cat {"hdr-hdr" "hdr-incl" "hdr-typedef" "hdr-enum" "hdr-impl" "hdr-trailor"} {
- set sect [$sections getSection $cat]
- if {[string length [$sect contents]] != 0} {
- $hdrSection appendSect $sect
- $hdrSection append "\n"
- }
- }
- }
-
- # add sections to the dictionary
- set sectDict [Dictionary new]
- $sectDict set "c++" $cppSection
- $sectDict set "h++" $hdrSection
- $typeToClassDict set [$definition OOPLClass] $sectDict
- }
- }
-
- method CppModel::setFileNameParams {this fileHandler} {
- [$this definitionSet] foreach definition {
- set oClass [$definition OOPLClass]
- if { $oClass != ""} {
- $definition hdrFileName \
- [$fileHandler getFsFileName $oClass [$fileHandler hdrType]]
- $definition cppFileName \
- [$fileHandler getFsFileName $oClass [$fileHandler cppType]]
- regsub {\.} [$definition hdrFileName] "_" prot
- $definition protector [string toupper $prot]
- } else {
- m4_error $E_DEFNOOOPL
- }
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppModel::definitionSet {this} {
- return [$this _definitionSet]
- }
-
- method CppModel::addDefinition {this newDefinition} {
- [$this _definitionSet] append $newDefinition
- $newDefinition _model $this
- }
-
- method CppModel::removeDefinition {this oldDefinition} {
- $oldDefinition _model ""
- [$this _definitionSet] removeValue $oldDefinition
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppobject.tcl /main/titanic/5
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppObject : {GCObject} {
- constructor
- method destructor
- method formatComment
- method generate
- method getName
- attribute comment
- attribute name
- }
-
- constructor CppObject {class this} {
- set this [GCObject::constructor $class $this]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppObject::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method CppObject::formatComment {this section {prefix "// "}} {
- if { [string length [$this comment]] > 0 } {
- set restComment [$this comment]
- set newlinePos [string first "\n" $restComment ]
- while {$newlinePos != -1} {
- set thisline [string range $restComment 0 [expr $newlinePos - 1]]
- set restComment \
- [string range $restComment [expr $newlinePos + 1] end]
- set newlinePos [string first "\n" $restComment ]
- $section append "${prefix}$thisline\n"
- }
- $section append "${prefix}$restComment\n"
- }
- }
-
- method CppObject::generate {this sections} {
- m4_fatal $F_ABSTRACT "CppObject::subGenerate"
- exit
- }
-
- method CppObject::getName {this} {
- return [$this name]
- }
-
- # Do not delete this line -- regeneration end marker
-
- #---------------------------------------------------------------------------
- # File: @(#)cppregen.tcl /main/titanic/3
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppRegen : {TextSection} {
- constructor
- method destructor
- method method
- attribute _method
- }
-
- constructor CppRegen {class this method} {
- set this [TextSection::constructor $class $this]
- $this _method $method
- [$method _regenSet] append $this
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppRegen::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppRegen::method {this args} {
- if {$args == ""} {
- return [$this _method]
- }
- set ref [$this _method]
- if {$ref != ""} {
- [$ref _regenSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _regenSet] append $this
- }
- $this _method $obj
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppsection.tcl /main/titanic/3
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppSectionList : {GCObject} {
- constructor
- method destructor
- method getSection
- method setSection
- method removeSection
- attribute section
- }
-
- constructor CppSectionList {class this} {
- set this [GCObject::constructor $class $this]
- $this section [Dictionary new]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppSectionList::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method CppSectionList::getSection {this title} {
- set sect [[$this section] set $title]
- if {$sect == ""} {
- m4_error $F_NOCATEGORY $title
- return [TextSection new]
- }
- return $sect
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppSectionList::setSection {this title newSection} {
- [$this section] set $title $newSection
- }
-
- method CppSectionList::removeSection {this title} {
- [$this section] unset $title
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cpptype.tcl /main/titanic/12
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppType : {GCObject} {
- constructor
- method destructor
- method isArray
- method getTypeName
- method generate
- method addTemplateParam
- method removeTemplateParam
- attribute name
- attribute isStatic
- attribute isConst
- attribute isPointer
- attribute arraySize
- attribute isReference
- attribute includeInFile
- attribute otherModifier
- attribute nested
- attribute localType
- attribute templateParamSet
- }
-
- constructor CppType {class this} {
- set this [GCObject::constructor $class $this]
- $this templateParamSet [List new]
- # Start constructor user section
- $this arraySize -1
- $this isStatic 0
- $this isConst 0
- $this isPointer 0
- $this isReference 0
- $this localType ""
- $this nested ""
- $this otherModifier ""
- $this includeInFile ""
- # End constructor user section
- return $this
- }
-
- method CppType::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method CppType::isArray {this {array -1}} {
- if {$array == -1 } {
- if {[$this arraySize] != -1} {
- return 1
- }
- return 0
- } else {
- if { $array == 0 } {
- $this arraySize -1
- } else {
- $this arraySize $array
- }
- }
- }
-
- method CppType::getTypeName {this fileT curDef} {
- if {($fileT == "hdr") &&
- ([$this localType] == $curDef) &&
- ([$this localType] != "") &&
- ([$this nested] != "")} {
- return [[$this nested] getTypeName $fileT $curDef]
- }
- set typeName ""
- if {[$this isConst] && [$this otherModifier] == ""} {
- set typeName "const "
- }
- if {[$this localType] == ""} {
- # Standard (or external) type
- if {[$this name] == ""} {
- set typeName "${typeName}void"
- } else {
- set typeName "${typeName}[$this name]"
- }
- } else {
- # Using a locally defined class, enum or typedef
- set typeName "${typeName}[[$this localType] getName]"
- }
-
- if {[$this otherModifier] != ""} {
- if {([$this localType] != "") && ($curDef != "")} {
- $curDef addInclude [$this localType] hdr
- }
- if [regsub -all {~\$name} [$this otherModifier] $typeName omf] {
- return $omf
- } else {
- return "${typeName}[$this otherModifier]"
- }
- }
-
- if {([$this localType] != "") && ($curDef != "")} {
- set hasExtIncl 0
- foreach incl [[[$this localType] OOPLClass] getPropertyValue "include_list"] {
- $curDef addExtIncl $incl
- set hasExtIncl 1
- }
- if {$fileT != "" && $hasExtIncl!=1} {
- if {[$this includeInFile] == ""} {
- if {[$this isPointer] || [$this isReference]} {
- $this includeInFile "cpp"
- } else {
- $this includeInFile "hdr"
- }
- }
-
- if {[$this includeInFile] == "cpp"} {
- if {$fileT == "hdr" && $fileT != "any" } {
- $curDef addForward [$this localType] hdr
- }
- if {$fileT == "cpp" || $fileT == "any"} {
- $curDef addInclude [$this localType] cpp
- }
- } else {
- if {$fileT == "hdr" || $fileT == "any"} {
- $curDef addInclude [$this localType] hdr
- }
- }
- }
- }
- if {![[$this templateParamSet] empty]} {
- set typeName "${typeName}< "
- set first 1
- [$this templateParamSet] foreach param {
- set pTypeName [$param getTypeName $fileT $curDef]
- if {!$first} {
- set typeName "${typeName}, $pTypeName"
- } else {
- set typeName "${typeName}$pTypeName"
- set first 0
- }
- }
- set typeName "${typeName} >"
- }
- if {[$this nested] != ""} {
- set typeName "${typeName}::[[$this nested] getTypeName $fileT $curDef]"
- }
- if {[$this isPointer]} { set typeName "${typeName}*" }
- if {[$this isReference]} { set typeName "${typeName}&" }
- return $typeName
- }
-
- method CppType::generate {this varName section fileT curDef} {
- set typeName "[$this getTypeName $fileT $curDef] "
- if {$fileT == "hdr" && [$this isStatic]} { $section append "static " }
- $section append $typeName
- $section append $varName
- if [$this isArray] {
- $section append "\[[$this arraySize]\]"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppType::addTemplateParam {this newTemplateParam} {
- [$this templateParamSet] append $newTemplateParam
-
- }
-
- method CppType::removeTemplateParam {this oldTemplateParam} {
- [$this templateParamSet] removeValue $oldTemplateParam
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppclfeatu.tcl /main/titanic/5
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppClFeature : {CppObject} {
- constructor
- method destructor
- method getCategory
- method getSection
- method cl
- attribute _cl
- attribute access
- attribute type
- }
-
- constructor CppClFeature {class this cl access type} {
- set this [CppObject::constructor $class $this]
- $this _cl $cl
- [$cl _featureSet] append $this
- $this access $access
- $this type $type
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppClFeature::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppObject::destructor
- }
-
- method CppClFeature::getCategory {this fileT} {
- m4_fatal $F_ABSTACT "CppClFeature::getCategory"
- exit
- }
-
- method CppClFeature::getSection {this fileT sections} {
- set sectName "[$this getCategory $fileT]"
- return [$section getSection $sectName]
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppClFeature::cl {this args} {
- if {$args == ""} {
- return [$this _cl]
- }
- set ref [$this _cl]
- if {$ref != ""} {
- [$ref _featureSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _featureSet] append $this
- }
- $this _cl $obj
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppattribu.tcl /main/titanic/7
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppAttribute : {CppClFeature} {
- constructor
- method destructor
- method generate
- method subGenerate
- method getCategory
- method accMethodSet
- method addAccMethod
- method removeAccMethod
- attribute defaultValue
- attribute _accMethodSet
- }
-
- constructor CppAttribute {class this cl access type} {
- set this [CppClFeature::constructor $class $this $cl $access $type]
- $this _accMethodSet [List new]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppAttribute::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppClFeature::destructor
- }
-
- method CppAttribute::generate {this sections} {
- $this subGenerate "hdr" \
- [$sections getSection "[$this getCategory hdr]"]
- $this subGenerate "cpp" \
- [$sections getSection "[$this getCategory cpp]"]
- }
-
- method CppAttribute::subGenerate {this fileT section} {
- if {$fileT == "hdr"} {
- # Attributes are only mentioned in the header file
- $this formatComment $section
-
- [$this type] generate [$this getName] $section \
- hdr [$this cl]
- if {[$this defaultValue] != ""} {
- $section append " /* = [$this defaultValue] */"
- }
- $section append ";\n"
- } else {
- # or they must be static
- if {([[$this type] isStatic] == 1) && ([$this defaultValue] != "")} {
- [$this type] generate \
- "[[$this cl] getName]::[$this getName]" \
- $section cpp [$this cl]
- $section append " = ([$this defaultValue]);\n"
- }
- }
- }
-
- method CppAttribute::getCategory {this fileT} {
- set access [string tolower [$this access]]
- if { $fileT == "hdr" } {
- return "hdr-special-${access}-data"
- } else {
- return "cpp-static-init"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppAttribute::accMethodSet {this} {
- return [$this _accMethodSet]
- }
-
- method CppAttribute::addAccMethod {this newAccMethod} {
- [$this _accMethodSet] append $newAccMethod
- $newAccMethod _belongsTo $this
- }
-
- method CppAttribute::removeAccMethod {this oldAccMethod} {
- $oldAccMethod _belongsTo ""
- [$this _accMethodSet] removeValue $oldAccMethod
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppmethod.tcl /main/titanic/12
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppMethod : {CppClFeature} {
- constructor
- method destructor
- method subGenerate
- method generate
- method getCategory
- method genSignature
- method genRegenCode
- method paramSet
- method addParam
- method removeParam
- method regenSet
- method addRegen
- method removeRegen
- attribute isDynamic
- attribute isAbstract
- attribute isInline
- attribute isConst
- attribute _paramSet
- attribute _regenSet
- }
-
- constructor CppMethod {class this cl access type} {
- set this [CppClFeature::constructor $class $this $cl $access $type]
- $this _paramSet [List new]
- $this _regenSet [List new]
- # Start constructor user section
- $this isInline 0
- $this isConst 0
- $this isDynamic 0
- $this isAbstract 0
- # End constructor user section
- return $this
- }
-
- method CppMethod::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppClFeature::destructor
- }
-
- method CppMethod::subGenerate {this fileT section} {
- m4_fatal $F_ABSTRACT "CppMethod::subGenerate"
- exit
- }
-
- method CppMethod::generate {this sections} {
- if { [$this access] != "None" } {
- set hdrSect [$sections getSection "[$this getCategory hdr]"]
- set hdrInclSect [$sections getSection "hdr-incl"]
-
- if { $hdrSect == "" } {
- m4_fatal $F_NOCATEGORY [$this getCategory hdr]
- return
- }
-
- $this subGenerate "hdr" $hdrSect
-
- set cppSect [$sections getSection "[$this getCategory cpp]"]
- set cppInclSect [$sections getSection "cpp-incl"]
-
- if { $cppSect == "" } {
- m4_fatal $F_NOCATEGORY [$this getCategory cpp]
- return
- }
-
- $this subGenerate "cpp" $cppSect
- $cppSect append "\n"
- }
- }
-
- method CppMethod::getCategory {this fileT} {
- m4_fatal $F_ABSTRACT "CppMethod::getCategory"
- return "${fileT}-user-defined-public"
- }
-
- method CppMethod::genSignature {this fileT section} {
- set mthdName ""
- if {$fileT == "cpp"} {
- set mthdName "${mthdName}[[$this cl] getName]::"
- }
- set mthdName "${mthdName}[$this getName]"
-
- if {([$this isDynamic] || [$this isAbstract]) && ($fileT == "hdr" || $fileT == "va")} {
- $section append "virtual "
- }
-
- if {[$this isInline] && $fileT == "cpp" } {
- $section append "inline "
- }
-
- if {[$this type] == "" || [$this isA CppConstructor] ||
- [$this isA CppDestructor] ||
- (([$this getName]==[[$this cl] getName]) && [[$this type] isStatic]) } {
- $section append $mthdName
- } else {
- if [[$this type] isArray] {
- # Arrays become pointers when returned
- [$this type] isArray 0
- [$this type] isPointer 1
- [$this type] isConst 1
- }
- set mthdName ""
- if {$fileT == "cpp"} {
- set mthdName "${mthdName}[[$this cl] getName]::"
- }
- set mthdName "${mthdName}[$this getName]"
-
- [$this type] generate $mthdName $section \
- $fileT [$this cl]
- }
- $section append "("
- [$this paramSet] foreach param {
- $param generate $fileT $section
- }
- if {$fileT == "hdr"} {
- $section append ")"
- if [$this isConst] {
- $section append " const"
- }
- if [$this isAbstract] {
- $section append " = 0"
- }
- $section append ";\n"
- } else {
- $section append ")"
- if [$this isConst] {
- $section append " const"
- }
- }
- }
-
- method CppMethod::genRegenCode {this section} {
- if {[[$this regenSet] empty] && ([$this name] != "")} {
- $section append "// !! Implement this function !!\n"
- set name [$this name]
- if [string match operator* $name] {
- set name "operator"
- }
- $section append "int ${name}_is_not_yet_implemented;\n"
- } else {
- $section indent -
- [$this regenSet] foreach regen {
- $section appendSect $regen
- }
- $section indent +
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppMethod::paramSet {this} {
- return [$this _paramSet]
- }
-
- method CppMethod::addParam {this newParam} {
- [$this _paramSet] append $newParam
- $newParam _method $this
- }
-
- method CppMethod::removeParam {this oldParam} {
- $oldParam _method ""
- [$this _paramSet] removeValue $oldParam
- }
-
- method CppMethod::regenSet {this} {
- return [$this _regenSet]
- }
-
- method CppMethod::addRegen {this newRegen} {
- [$this _regenSet] append $newRegen
- $newRegen _method $this
- }
-
- method CppMethod::removeRegen {this oldRegen} {
- $oldRegen _method ""
- [$this _regenSet] removeValue $oldRegen
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppusermet.tcl /main/titanic/5
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppUserMethod : {CppMethod} {
- constructor
- method destructor
- method getName
- method subGenerate
- method getCategory
- }
-
- constructor CppUserMethod {class this cl access type} {
- set this [CppMethod::constructor $class $this $cl $access $type]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppUserMethod::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppMethod::destructor
- }
-
- method CppUserMethod::getName {this} {
- if {([$this name]=="create") && [[$this type] isStatic]} {
- return [[$this cl] getName]
- } else {
- return [$this name]
- }
- }
-
- method CppUserMethod::subGenerate {this fileT section} {
- $this formatComment $section
- if { $fileT == "cpp" } {
- if {![$this isAbstract]} {
- $this genSignature $fileT $section
- $section append "\n{\n"
- $section indent +
- $this genRegenCode $section
- $section indent -
- $section append "}\n"
- }
- } else {
- $this genSignature $fileT $section
- }
- }
-
- method CppUserMethod::getCategory {this fileT} {
- if {$fileT == "hdr"} {
- return "hdr-user-defined-[string tolower [$this access]]-meth"
- } else {
- if [$this isInline] {
- return "hdr-impl"
- }
-
- return "cpp-impl"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- #---------------------------------------------------------------------------
- # File: @(#)cppdefinit.tcl /main/titanic/10
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- require "caynutil.tcl"
- # End user added include file section
-
-
- Class CppDefinition : {CppObject} {
- constructor
- method destructor
- method addProtectorStart
- method addProtectorEnd
- method addInclude
- method addForward
- method addExtIncl
- method addHeader
- method generateFwd
- method generateInc
- method model
- method extIncludeSet
- method addExtInclude
- method removeExtInclude
- method getIncludeSect
- method setIncludeSect
- method removeIncludeSect
- method getObsoleteCode
- method setObsoleteCode
- method removeObsoleteCode
- attribute hdrFileName
- attribute cppFileName
- attribute protector
- attribute includedDefs
- attribute forwardDefs
- attribute isSynthetic
- attribute OOPLClass
- attribute _model
- attribute _extIncludeSet
- attribute includeSect
- attribute obsoleteCode
- }
-
- constructor CppDefinition {class this OOPLClass model} {
- set this [CppObject::constructor $class $this]
- $this OOPLClass $OOPLClass
- $this _model $model
- [$model _definitionSet] append $this
- $this _extIncludeSet [List new]
- $this includeSect [Dictionary new]
- $this obsoleteCode [Dictionary new]
- # Start constructor user section
- $this setObsoleteCode "hdr" [TextSection new]
- $this setObsoleteCode "cpp" [TextSection new]
- $this setIncludeSect "hdr" [TextSection new]
- $this setIncludeSect "cpp" [TextSection new]
- $this includedDefs [Dictionary new]
- $this forwardDefs [Dictionary new]
- $this isSynthetic 0
- # End constructor user section
- return $this
- }
-
- method CppDefinition::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppObject::destructor
- }
-
- method CppDefinition::addProtectorStart {this section} {
- $section append "#ifndef [$this protector]\n"
- $section append "#define [$this protector] 1\n\n"
- }
-
- method CppDefinition::addProtectorEnd {this section} {
- $section append "#endif // [$this protector]\n"
- }
-
- method CppDefinition::addInclude {this forDef fileT} {
- if {$forDef == $this} {
- if {$fileT == "cpp"} {
- [$this includedDefs] set $forDef $fileT
- }
- } else {
- if {$fileT == "hdr"} {
- [$this includedDefs] set $forDef $fileT
- } else {
- if {![[$this includedDefs] exists $forDef]} {
- [$this includedDefs] set $forDef $fileT
- }
- }
- }
- }
-
- method CppDefinition::addForward {this forDef fileT} {
- if {$fileT == "hdr"} {
- if {$forDef != $this} {
- [$this forwardDefs] set $forDef $fileT
- }
- } else {
- if {![[$this forwardDefs] exists $forDef]} {
- [$this forwardDefs] set $forDef $fileT
- }
- }
- }
-
- method CppDefinition::addExtIncl {this fileName} {
- if {$fileName == ""} {
- return
- }
- [$this extIncludeSet] foreach extIncl {
- if { [$extIncl fileName] == "$fileName" } {
- return
- }
- }
- set newExtIncl [CppExtInclude new $this]
- $newExtIncl fileName "$fileName"
- }
-
- method CppDefinition::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
- $section append "\n"
- }
-
- method CppDefinition::generateFwd {this hdrSect srcSect} {
- set hdrList [List new]
-
- [$this forwardDefs] foreach forDef fileT {
- if {![[$this includedDefs] exists $forDef]} {
- $hdrList append "class [$forDef getName];\n\n"
- } else {
- if {[[$this includedDefs] set $forDef] == "cpp" } {
- $hdrList append "class [$forDef getName];\n\n"
- }
- }
- }
-
- $hdrList sort
- $hdrList foreach entry {
- $hdrSect append $entry
- }
- }
-
- method CppDefinition::generateInc {this hdrSect srcSect} {
- set hdrDict [Dictionary new]
- set cppDict [Dictionary new]
-
- [$this includedDefs] foreach forDef fileT {
- if {$fileT == "hdr"} {
- $hdrDict set [$forDef protector] [$forDef hdrFileName]
- } else {
- $cppDict set [$forDef protector] [$forDef hdrFileName]
- }
- }
-
- [$this extIncludeSet] foreach extIncl {
- $extIncl generate $hdrSect
- }
- if {![[$this extIncludeSet] empty]} {
- $hdrSect append "\n"
- }
- foreach protector [lsort [$hdrDict names]] {
- set hdrFileName [$hdrDict set $protector]
- $hdrSect append "#ifndef $protector\n"
- $hdrSect append "#include \"$hdrFileName\"\n"
- $hdrSect append "#endif\n\n"
- }
-
- foreach protector [lsort [$cppDict names]] {
- set hdrFileName [$cppDict set $protector]
- $srcSect append "#ifndef $protector\n"
- $srcSect append "#include \"$hdrFileName\"\n"
- $srcSect append "#endif\n\n"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppDefinition::model {this args} {
- if {$args == ""} {
- return [$this _model]
- }
- set ref [$this _model]
- if {$ref != ""} {
- [$ref _definitionSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _definitionSet] append $this
- }
- $this _model $obj
- }
-
- method CppDefinition::extIncludeSet {this} {
- return [$this _extIncludeSet]
- }
-
- method CppDefinition::addExtInclude {this newExtInclude} {
- [$this _extIncludeSet] append $newExtInclude
- $newExtInclude _definition $this
- }
-
- method CppDefinition::removeExtInclude {this oldExtInclude} {
- $oldExtInclude _definition ""
- [$this _extIncludeSet] removeValue $oldExtInclude
- }
-
- method CppDefinition::getIncludeSect {this fType} {
- return [[$this includeSect] set $fType]
- }
-
- method CppDefinition::setIncludeSect {this fType newIncludeSect} {
- [$this includeSect] set $fType $newIncludeSect
- }
-
- method CppDefinition::removeIncludeSect {this fType} {
- [$this includeSect] unset $fType
- }
-
- method CppDefinition::getObsoleteCode {this fType} {
- return [[$this obsoleteCode] set $fType]
- }
-
- method CppDefinition::setObsoleteCode {this fType newObsoleteCode} {
- [$this obsoleteCode] set $fType $newObsoleteCode
- }
-
- method CppDefinition::removeObsoleteCode {this fType} {
- [$this obsoleteCode] unset $fType
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cpptypedef.tcl /main/titanic/7
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppTypeDef : {CppDefinition} {
- constructor
- method destructor
- method generate
- attribute type
- }
-
- constructor CppTypeDef {class this OOPLClass model type} {
- set this [CppDefinition::constructor $class $this $OOPLClass $model]
- $this type $type
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppTypeDef::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppDefinition::destructor
- }
-
- method CppTypeDef::generate {this sections} {
-
- if [$this isSynthetic] {
- return
- }
-
- set hdrSect [ $sections getSection "hdr-hdr" ]
- set inclSect [ $sections getSection "hdr-incl" ]
- set typedSect [ $sections getSection "hdr-typedef" ]
- set trailSect [ $sections getSection "hdr-trailor" ]
-
- $this addHeader "hdr" $hdrSect
- $this addProtectorStart $hdrSect
- $this formatComment $typedSect
- $typedSect append "typedef "
- [$this type] generate [$this getName] $typedSect "hdr" $this
- $typedSect append ";\n"
- $this addProtectorEnd $trailSect
-
- $this generateInc $hdrSect $hdrSect
- $this generateFwd $hdrSect $hdrSect
-
- $hdrSect append "// "
- $hdrSect append ${CppConstants::startInclude}
- $hdrSect append "\n"
- $hdrSect appendSect [$this getIncludeSect "hdr"]
- $hdrSect append "// "
- $hdrSect append ${CppConstants::endInclude}
- $hdrSect append "\n\n"
- }
-
- # Do not delete this line -- regeneration end marker
-
- #---------------------------------------------------------------------------
- # File: @(#)cppparam.tcl /main/titanic/4
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppParam : {CppObject} {
- constructor
- method destructor
- method generate
- method method
- attribute defaultValue
- attribute type
- attribute _method
- }
-
- constructor CppParam {class this type method} {
- set this [CppObject::constructor $class $this]
- $this type $type
- $this _method $method
- [$method _paramSet] append $this
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppParam::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppObject::destructor
- }
-
- method CppParam::generate {this fileT section} {
- set cppMeth [$this method]
- set idx [ [$cppMeth paramSet] search -exact $this ]
- if { $idx == -1 } {
- m4_fatal $F_INTINCON "CppParam::generate"
- exit
- }
- if { $idx != 0 } {
- $section append ", "
- }
- if [[$this type] isArray] {
- [$this type] isArray 0
- [$this type] isPointer 1
- [$this type] isConst 1
- }
- [$this type] generate [$this getName] $section \
- $fileT [[$this method] cl]
- if {$fileT == "hdr" && [$this defaultValue] != ""} {
- $section append "= [$this defaultValue]"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppParam::method {this args} {
- if {$args == ""} {
- return [$this _method]
- }
- set ref [$this _method]
- if {$ref != ""} {
- [$ref _paramSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _paramSet] append $this
- }
- $this _method $obj
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppassocat.tcl /main/titanic/4
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppAssocAttrib : {CppAttribute} {
- constructor
- method destructor
- method getCategory
- }
-
- constructor CppAssocAttrib {class this cl access type} {
- set this [CppAttribute::constructor $class $this $cl $access $type]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppAssocAttrib::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppAttribute::destructor
- }
-
- method CppAssocAttrib::getCategory {this fileT} {
- if {$fileT == "hdr"} {
- return "hdr-assoc-storage-private-data"
- } else {
- return "cpp-static-init"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- #---------------------------------------------------------------------------
- # File: @(#)cppgenmeth.tcl /main/titanic/5
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppGenMethod : {CppMethod} {
- constructor
- method destructor
- method genGenCode
- method subGenerate
- method getCategory
- method genCodeSet
- method addGenCode
- method removeGenCode
- attribute _genCodeSet
- }
-
- constructor CppGenMethod {class this cl access type} {
- set this [CppMethod::constructor $class $this $cl $access $type]
- $this _genCodeSet [List new]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppGenMethod::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppMethod::destructor
- }
-
- method CppGenMethod::genGenCode {this section} {
- [$this genCodeSet] foreach genCode {
- $section appendSect $genCode
- }
- }
-
- method CppGenMethod::subGenerate {this fileT section} {
- $this formatComment $section
- if { $fileT == "cpp" } {
- if {![$this isAbstract]} {
- $this genSignature $fileT $section
- $section append "\n{\n"
- $section indent +
- $this genGenCode $section
- $section indent -
- $section append "}\n"
- }
- } else {
- $this genSignature $fileT $section
- }
- }
-
- method CppGenMethod::getCategory {this fileT} {
- if {$fileT == "hdr"} {
- set access [$this access]
- return "hdr-special-[string tolower $access]-meth"
- } else {
- if [$this isInline] {
- return "hdr-impl-gen"
- }
- return "cpp-impl-gen"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppGenMethod::genCodeSet {this} {
- return [$this _genCodeSet]
- }
-
- method CppGenMethod::addGenCode {this newGenCode} {
- [$this _genCodeSet] append $newGenCode
- $newGenCode _method $this
- }
-
- method CppGenMethod::removeGenCode {this oldGenCode} {
- $oldGenCode _method ""
- [$this _genCodeSet] removeValue $oldGenCode
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppdestruc.tcl /main/titanic/6
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppDestructor : {CppGenMethod} {
- constructor
- method destructor
- method getName
- method subGenerate
- method getCategory
- }
-
- constructor CppDestructor {class this cl access type} {
- set this [CppGenMethod::constructor $class $this $cl $access $type]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppDestructor::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppGenMethod::destructor
- }
-
- method CppDestructor::getName {this} {
- return "~[[$this cl] getName]"
- }
-
- method CppDestructor::subGenerate {this fileT section} {
- $this formatComment $section
- $this genSignature $fileT $section
- if { $fileT == "cpp" } {
- $section append "\n{\n"
- $section indent +
- $section append "// "
- $section append ${CppConstants::startDtor}
- $section append "\n"
- $this genRegenCode $section
- $section append "// "
- $section append ${CppConstants::endDtor}
- $section append "\n"
- $this genGenCode $section
- $section indent -
- $section append "}\n"
- }
- }
-
- method CppDestructor::getCategory {this fileT} {
- if {$fileT == "hdr"} {
- set access [string tolower [$this access]]
- if {$access == ""} {
- set access "public"
- }
- return "hdr-dtor-$access"
- } else {
- return "cpp-dtor"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- #---------------------------------------------------------------------------
- # File: @(#)cppenum.tcl /main/titanic/6
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppEnum : {CppDefinition} {
- constructor
- method destructor
- method generate
- method itemSet
- method addItem
- method removeItem
- attribute _itemSet
- }
-
- constructor CppEnum {class this OOPLClass model} {
- set this [CppDefinition::constructor $class $this $OOPLClass $model]
- $this _itemSet [List new]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppEnum::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppDefinition::destructor
- }
-
- method CppEnum::generate {this sections} {
-
- if [$this isSynthetic] {
- return
- }
-
- set hdrSect [ $sections getSection "hdr-hdr" ]
- set includeHdrSect [ $sections getSection "hdr-incl" ]
- set enumSect [ $sections getSection "hdr-enum" ]
- set trailSect [ $sections getSection "hdr-trailor" ]
-
- $this addHeader "hdr" $hdrSect
- $this addProtectorStart $hdrSect
- $this formatComment $enumSect
- $enumSect append "enum [$this getName] {\n"
- $enumSect indent +
- [$this itemSet] foreach item {
- $item generate $enumSect
- }
- $enumSect append "\n"
- $enumSect indent -
- $enumSect append "};\n"
- $this addProtectorEnd $trailSect
-
- $this generateInc $hdrSect $hdrSect
- $this generateFwd $hdrSect $hdrSect
-
- $hdrSect append "// "
- $hdrSect append ${CppConstants::startInclude}
- $hdrSect append "\n"
- $hdrSect appendSect [$this getIncludeSect "hdr"]
- $hdrSect append "// "
- $hdrSect append ${CppConstants::endInclude}
- $hdrSect append "\n\n"
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppEnum::itemSet {this} {
- return [$this _itemSet]
- }
-
- method CppEnum::addItem {this newItem} {
- [$this _itemSet] append $newItem
- $newItem _enum $this
- }
-
- method CppEnum::removeItem {this oldItem} {
- $oldItem _enum ""
- [$this _itemSet] removeValue $oldItem
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppconstru.tcl /main/titanic/5
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppConstructor : {CppGenMethod} {
- constructor
- method destructor
- method getName
- method subGenerate
- method getCategory
- method initializerSet
- method addInitializer
- method removeInitializer
- attribute _initializerSet
- }
-
- constructor CppConstructor {class this cl access type} {
- set this [CppGenMethod::constructor $class $this $cl $access $type]
- $this _initializerSet [List new]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppConstructor::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppGenMethod::destructor
- }
-
- method CppConstructor::getName {this} {
- return [[$this cl] getName]
- }
-
- method CppConstructor::subGenerate {this fileT section} {
- $this formatComment $section
- $this genSignature $fileT $section
- if { $fileT == "cpp" } {
- [$this initializerSet] foreach init {
- $init generate $section
- }
- $section append "\n{\n"
- $section indent +
- $this genGenCode $section
- $section append "// "
- $section append ${CppConstants::startCtor}
- $section append "\n"
- $this genRegenCode $section
- $section append "// "
- $section append ${CppConstants::endCtor}
- $section append "\n"
- $section indent -
- $section append "}\n"
- }
- }
-
- method CppConstructor::getCategory {this fileT} {
- if {$fileT == "cpp"} {
- if [$this isInline] {
- m4_warning $W_INLINECTOR
- $this isInline 0
- }
- return "cpp-ctor"
- } else {
- set access [string tolower [$this access]]
- if {$access == ""} {
- set access "public"
- }
- return "hdr-ctor-$access"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppConstructor::initializerSet {this} {
- return [$this _initializerSet]
- }
-
- method CppConstructor::addInitializer {this newInitializer} {
- [$this _initializerSet] append $newInitializer
- $newInitializer _ctor $this
- }
-
- method CppConstructor::removeInitializer {this oldInitializer} {
- $oldInitializer _ctor ""
- [$this _initializerSet] removeValue $oldInitializer
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppnestedt.tcl /main/titanic/2
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppNestedTypeDef : {CppClFeature} {
- constructor
- method destructor
- method generate
- }
-
- constructor CppNestedTypeDef {class this cl access type} {
- set this [CppClFeature::constructor $class $this $cl $access $type]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppNestedTypeDef::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppClFeature::destructor
- }
-
- method CppNestedTypeDef::generate {this sections} {
- set access [string tolower [$this access]]
- if {$access == ""} {
- set access "public"
- }
- set typedSect [ $sections getSection "hdr-typedef-$access" ]
- $this formatComment $typedSect
- $typedSect append "typedef "
- [$this type] generate [$this getName] $typedSect "hdr" [$this cl]
- $typedSect append ";\n"
-
- }
-
- # Do not delete this line -- regeneration end marker
-
- #---------------------------------------------------------------------------
- # File: @(#)cppaccmeth.tcl /main/titanic/6
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppAccMethod : {CppGenMethod} {
- constructor
- method destructor
- method subGenerate
- method getCategory
- method getMethodName
- method belongsTo
- attribute kind
- attribute _belongsTo
- }
-
- constructor CppAccMethod {class this cl access type belongsTo} {
- set this [CppGenMethod::constructor $class $this $cl $access $type]
- $this _belongsTo $belongsTo
- [$belongsTo _accMethodSet] append $this
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppAccMethod::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppGenMethod::destructor
- }
-
- method CppAccMethod::subGenerate {this fileT section} {
- $this formatComment $section
- $this genSignature $fileT $section
- if { $fileT == "cpp" } {
- $section append "\n{\n"
- $section indent +
- $this genGenCode $section
- $section indent -
- $section append "}\n"
- }
- }
-
- method CppAccMethod::getCategory {this fileT} {
- if {$fileT == "hdr"} {
- set access [$this access]
- if [[$this belongsTo] isA CppAssocAttrib] {
- return "hdr-assoc-access-[string tolower $access]"
- } else {
- return "hdr-attrib-access-[string tolower $access]"
- }
- } else {
- if [$this isInline] {
- return "hdr-impl-gen"
- }
- return "cpp-impl-gen"
- }
- }
-
- method CppAccMethod::getMethodName {this kind name} {
- set firstUp [string toupper [string range $name 0 0]]
- set uName "${firstUp}[string range $name 1 end]"
-
- switch $kind {
- attrib-get {
- set fullName "get${uName}"
- }
- attrib-set {
- set fullName "set${uName}"
- }
- assoc-get {
- set fullName "get${uName}"
- }
- assoc-get-set {
- set fullName "get${uName}Set"
- }
- assoc-set {
- set fullName "set${uName}"
- }
- assoc-add {
- set fullName "add${uName}"
- }
- assoc-remove {
- set fullName "remove${uName}"
- }
- default {
- puts stderr "Unknown kind: $kind, $name"
- set fullName "$name"
- }
- }
- return $fullName
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppAccMethod::belongsTo {this args} {
- if {$args == ""} {
- return [$this _belongsTo]
- }
- set ref [$this _belongsTo]
- if {$ref != ""} {
- [$ref _accMethodSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _accMethodSet] append $this
- }
- $this _belongsTo $obj
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppenumite.tcl /main/titanic/3
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppEnumItem : {CppObject} {
- constructor
- method destructor
- method generate
- method enum
- attribute item
- attribute value
- attribute _enum
- }
-
- constructor CppEnumItem {class this enum} {
- set this [CppObject::constructor $class $this]
- $this _enum $enum
- [$enum _itemSet] append $this
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppEnumItem::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppObject::destructor
- }
-
- method CppEnumItem::generate {this section} {
- set cppEnum [$this enum]
- set idx [ [$cppEnum itemSet] search -exact $this ]
- if { $idx == -1 } {
- m4_fatal $F_INTINCON "CppEnumItem::generate"
- exit
- }
- if { $idx != 0 } {
- set comma ",\n"
- } else {
- set comma ""
- }
- if { [ string length [$this value] ] > 0 } {
- $section append "${comma}[$this item] = [$this value]"
- } else {
- $section append "${comma}[$this item]"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppEnumItem::enum {this args} {
- if {$args == ""} {
- return [$this _enum]
- }
- set ref [$this _enum]
- if {$ref != ""} {
- [$ref _itemSet] removeValue $this
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- [$obj _itemSet] append $this
- }
- $this _enum $obj
- }
-
- #---------------------------------------------------------------------------
- # File: @(#)cppuseratt.tcl /main/titanic/6
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppUserAttrib : {CppAttribute} {
- constructor
- method destructor
- method getCategory
- }
-
- constructor CppUserAttrib {class this cl access type} {
- set this [CppAttribute::constructor $class $this $cl $access $type]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppUserAttrib::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppAttribute::destructor
- }
-
- method CppUserAttrib::getCategory {this fileT} {
- if {$fileT == "hdr"} {
- set access [string tolower [$this access]]
- return "hdr-user-defined-$access-data"
- } else {
- return "cpp-static-init"
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- #---------------------------------------------------------------------------
- # File: @(#)cppderived.tcl /main/titanic/3
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppDerivedAttrib : {CppAttribute} {
- constructor
- method destructor
- method getCategory
- }
-
- constructor CppDerivedAttrib {class this cl access type} {
- set this [CppAttribute::constructor $class $this $cl $access $type]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method CppDerivedAttrib::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppAttribute::destructor
- }
-
- method CppDerivedAttrib::getCategory {this fileT} {
- return "${fileT}-user-defined-private-data"
- }
-
- # Do not delete this line -- regeneration end marker
-
- #---------------------------------------------------------------------------
- # File: @(#)cppclass.tcl /main/titanic/9
- #---------------------------------------------------------------------------
-
- # Start user added include file section
- # End user added include file section
-
-
- Class CppClass : {CppDefinition} {
- constructor
- method destructor
- method addFriendClass
- method generate
- method friendSet
- method addFriend
- method removeFriend
- method genSet
- method addGen
- method removeGen
- method featureSet
- method addFeature
- method removeFeature
- attribute _friendSet
- attribute _genSet
- attribute _featureSet
- }
-
- constructor CppClass {class this OOPLClass model} {
- set this [CppDefinition::constructor $class $this $OOPLClass $model]
- $this _friendSet [List new]
- $this _genSet [List new]
- $this _featureSet [List new]
- # Start constructor user section
- $this name [$OOPLClass getName]
- # End constructor user section
- return $this
- }
-
- method CppClass::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this CppDefinition::destructor
- }
-
- method CppClass::addFriendClass {this friend} {
- [$this friendSet] foreach fr {
- if {$friend == [$fr cl]} {
- return $fr
- }
- }
- set fr [CppFriend new $friend]
- $this addFriend $fr
- return $fr
- }
-
- method CppClass::generate {this sections} {
-
- if [$this isSynthetic] {
- return
- }
-
- set hdrHdrSect [ $sections getSection "hdr-hdr" ]
- set hdrCppSect [ $sections getSection "cpp-hdr" ]
- set includeHdrSect [ $sections getSection "hdr-incl" ]
- set includeCppSect [ $sections getSection "cpp-incl" ]
- set classHeadSect [ $sections getSection "hdr-class-head" ]
- set classTailSect [ $sections getSection "hdr-class-tail" ]
- set trailSect [ $sections getSection "hdr-trailor" ]
- set obsoleteHdrSect [ $sections getSection "hdr-impl" ]
- set obsoleteCppSect [ $sections getSection "cpp-impl" ]
-
- $this addHeader "hdr" $hdrHdrSect
- $this addHeader "cpp" $hdrCppSect
- $this addInclude $this "cpp"
-
- $this addProtectorStart $hdrHdrSect
-
- $this formatComment $classHeadSect
- $classHeadSect append "class [$this getName]"
- set first 1
- [$this genSet] foreach gen {
- if {$first} {
- set first 0
- $classHeadSect append ": "
- } else {
- $classHeadSect append ", "
- }
- $gen generate $classHeadSect
- }
- $classHeadSect append " {\n"
-
- $classHeadSect indent +
- [$this friendSet] foreach friend {
- $friend generate $classHeadSect
- }
- $classHeadSect indent -
-
- [$this featureSet] foreach feature {
- $feature generate $sections
- }
-
- if {[[$this getObsoleteCode "hdr"] contents] != ""} {
- m4_warning $W_GENOCODE ${CppConstants::obsoleteCode} [$this hdrFileName]
- $obsoleteHdrSect append "#ifdef "
- $obsoleteHdrSect append ${CppConstants::obsoleteCode}
- $obsoleteHdrSect append "\n\n"
- $obsoleteHdrSect appendSect [$this getObsoleteCode "hdr"]
- $obsoleteHdrSect append "#endif // "
- $obsoleteHdrSect append ${CppConstants::obsoleteCode}
- $obsoleteHdrSect append "\n"
- }
- if {[[$this getObsoleteCode "cpp"] contents] != ""} {
- m4_warning $W_GENOCODE ${CppConstants::obsoleteCode} [$this cppFileName]
- $obsoleteCppSect append "#ifdef "
- $obsoleteCppSect append ${CppConstants::obsoleteCode}
- $obsoleteCppSect append "\n\n"
- $obsoleteCppSect appendSect [$this getObsoleteCode "cpp"]
- $obsoleteCppSect append "#endif // "
- $obsoleteCppSect append ${CppConstants::obsoleteCode}
- $obsoleteCppSect append "\n"
- }
-
- $classTailSect append "};\n"
- $this addProtectorEnd $trailSect
-
- $this generateInc $hdrHdrSect $hdrCppSect
- $this generateFwd $hdrHdrSect $hdrCppSect
-
- $hdrCppSect append "// "
- $hdrCppSect append ${CppConstants::startInclude}
- $hdrCppSect append "\n"
- $hdrCppSect appendSect [$this getIncludeSect "cpp"]
- $hdrCppSect append "// "
- $hdrCppSect append ${CppConstants::endInclude}
- $hdrCppSect append "\n\n"
-
- $hdrHdrSect append "// "
- $hdrHdrSect append ${CppConstants::startInclude}
- $hdrHdrSect append "\n"
- $hdrHdrSect appendSect [$this getIncludeSect "hdr"]
- $hdrHdrSect append "// "
- $hdrHdrSect append ${CppConstants::endInclude}
- $hdrHdrSect append "\n"
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CppClass::friendSet {this} {
- return [$this _friendSet]
- }
-
- method CppClass::addFriend {this newFriend} {
- [$this _friendSet] append $newFriend
- $newFriend _friendOf $this
- }
-
- method CppClass::removeFriend {this oldFriend} {
- $oldFriend _friendOf ""
- [$this _friendSet] removeValue $oldFriend
- }
-
- method CppClass::genSet {this} {
- return [$this _genSet]
- }
-
- method CppClass::addGen {this newGen} {
- [$this _genSet] append $newGen
- $newGen _subcl $this
- }
-
- method CppClass::removeGen {this oldGen} {
- $oldGen _subcl ""
- [$this _genSet] removeValue $oldGen
- }
-
- method CppClass::featureSet {this} {
- return [$this _featureSet]
- }
-
- method CppClass::addFeature {this newFeature} {
- [$this _featureSet] append $newFeature
- $newFeature _cl $this
- }
-
- method CppClass::removeFeature {this oldFeature} {
- $oldFeature _cl ""
- [$this _featureSet] removeValue $oldFeature
- }
-
-