home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / komix / DATA.Z / cppgrammar.tcl < prev    next >
Text File  |  1997-12-01  |  68KB  |  2,602 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. # Copyright (c) 1997 by Cayenne Software, Inc.
  4. #
  5. # This software is furnished under a license and may be used only in
  6. # accordance with the terms of such license and with the inclusion of
  7. # the above copyright notice. This software or any other copies thereof
  8. # may not be provided or otherwise made available to any other person.
  9. # No title to and ownership of the software is hereby transferred.
  10. #
  11. # The information in this software is subject to change without notice
  12. # and should not be construed as a commitment by Cayenne Software, Inc.
  13. #
  14. #---------------------------------------------------------------------------
  15. #
  16. #       File            : cppgrammar.tcl
  17. #       Author          : 
  18. #       Original date   : November 1997
  19. #       Description     : Classes for code generation
  20. #
  21. #---------------------------------------------------------------------------
  22.  
  23. #---------------------------------------------------------------------------
  24. #      File:           @(#)cppextincl.tcl    /main/titanic/1
  25. #---------------------------------------------------------------------------
  26.  
  27. # Start user added include file section
  28. # End user added include file section
  29.  
  30.  
  31. Class CppExtInclude : {GCObject} {
  32.     constructor
  33.     method destructor
  34.     method generate
  35.     method definition
  36.     attribute fileName
  37.     attribute _definition
  38. }
  39.  
  40. constructor CppExtInclude {class this definition} {
  41.     set this [GCObject::constructor $class $this]
  42.     $this _definition $definition
  43.     [$definition _extIncludeSet] append $this
  44.     # Start constructor user section
  45.     # End constructor user section
  46.     return $this
  47. }
  48.  
  49. method CppExtInclude::destructor {this} {
  50.     # Start destructor user section
  51.     # End destructor user section
  52. }
  53.  
  54. method CppExtInclude::generate {this section} {
  55.     $section append "#include <[$this fileName]>\n"
  56. }
  57.  
  58. # Do not delete this line -- regeneration end marker
  59.  
  60. method CppExtInclude::definition {this args} {
  61.     if {$args == ""} {
  62.         return [$this _definition]
  63.     }
  64.     set ref [$this _definition]
  65.     if {$ref != ""} {
  66.         [$ref _extIncludeSet] removeValue $this
  67.     }
  68.     set obj [lindex $args 0]
  69.     if {$obj != ""} {
  70.         [$obj _extIncludeSet] append $this
  71.     }
  72.     $this _definition $obj
  73. }
  74.  
  75. #---------------------------------------------------------------------------
  76. #      File:           @(#)cppfriend.tcl    /main/titanic/5
  77. #---------------------------------------------------------------------------
  78.  
  79. # Start user added include file section
  80. # End user added include file section
  81.  
  82.  
  83. Class CppFriend : {GCObject} {
  84.     constructor
  85.     method destructor
  86.     method generate
  87.     method friendOf
  88.     attribute cl
  89.     attribute _friendOf
  90. }
  91.  
  92. constructor CppFriend {class this cl} {
  93.     set this [GCObject::constructor $class $this]
  94.     $this cl $cl
  95.     # Start constructor user section
  96.     # End constructor user section
  97.     return $this
  98. }
  99.  
  100. method CppFriend::destructor {this} {
  101.     # Start destructor user section
  102.     # End destructor user section
  103. }
  104.  
  105. method CppFriend::generate {this section} {
  106.     $section append "friend class [[$this cl] getName];\n"
  107.     [$this friendOf] addForward [$this cl] hdr
  108. }
  109.  
  110. # Do not delete this line -- regeneration end marker
  111.  
  112. method CppFriend::friendOf {this args} {
  113.     if {$args == ""} {
  114.         return [$this _friendOf]
  115.     }
  116.     set ref [$this _friendOf]
  117.     if {$ref != ""} {
  118.         [$ref _friendSet] removeValue $this
  119.     }
  120.     set obj [lindex $args 0]
  121.     if {$obj != ""} {
  122.         [$obj _friendSet] append $this
  123.     }
  124.     $this _friendOf $obj
  125. }
  126.  
  127. #---------------------------------------------------------------------------
  128. #      File:           @(#)cppgen.tcl    /main/titanic/3
  129. #---------------------------------------------------------------------------
  130.  
  131. # Start user added include file section
  132. # End user added include file section
  133.  
  134.  
  135. Class CppGen : {GCObject} {
  136.     constructor
  137.     method destructor
  138.     method generate
  139.     method subcl
  140.     attribute isVirtual
  141.     attribute cl
  142.     attribute _subcl
  143.     attribute access
  144. }
  145.  
  146. constructor CppGen {class this cl access} {
  147.     set this [GCObject::constructor $class $this]
  148.     $this cl $cl
  149.     $this access $access
  150.     # Start constructor user section
  151.     $this isVirtual 0
  152.     # End constructor user section
  153.     return $this
  154. }
  155.  
  156. method CppGen::destructor {this} {
  157.     # Start destructor user section
  158.     # End destructor user section
  159. }
  160.  
  161. method CppGen::generate {this section} {
  162.     $section append "[$this access] "
  163.     if [$this isVirtual] {
  164.         $section append "virtual "
  165.     }
  166.     $section append "[[$this cl] getName]"
  167.     [$this subcl] addInclude [$this cl] hdr
  168. }
  169.  
  170. # Do not delete this line -- regeneration end marker
  171.  
  172. method CppGen::subcl {this args} {
  173.     if {$args == ""} {
  174.         return [$this _subcl]
  175.     }
  176.     set ref [$this _subcl]
  177.     if {$ref != ""} {
  178.         [$ref _genSet] removeValue $this
  179.     }
  180.     set obj [lindex $args 0]
  181.     if {$obj != ""} {
  182.         [$obj _genSet] append $this
  183.     }
  184.     $this _subcl $obj
  185. }
  186.  
  187. #---------------------------------------------------------------------------
  188. #      File:           @(#)cppgencode.tcl    /main/titanic/3
  189. #---------------------------------------------------------------------------
  190.  
  191. # Start user added include file section
  192. # End user added include file section
  193.  
  194.  
  195. Class CppGenCode : {TextSection} {
  196.     constructor
  197.     method destructor
  198.     method method
  199.     attribute _method
  200. }
  201.  
  202. constructor CppGenCode {class this method} {
  203.     set this [TextSection::constructor $class $this]
  204.     $this _method $method
  205.     [$method _genCodeSet] append $this
  206.     # Start constructor user section
  207.     # End constructor user section
  208.     return $this
  209. }
  210.  
  211. method CppGenCode::destructor {this} {
  212.     # Start destructor user section
  213.     # End destructor user section
  214. }
  215.  
  216. # Do not delete this line -- regeneration end marker
  217.  
  218. method CppGenCode::method {this args} {
  219.     if {$args == ""} {
  220.         return [$this _method]
  221.     }
  222.     set ref [$this _method]
  223.     if {$ref != ""} {
  224.         [$ref _genCodeSet] removeValue $this
  225.     }
  226.     set obj [lindex $args 0]
  227.     if {$obj != ""} {
  228.         [$obj _genCodeSet] append $this
  229.     }
  230.     $this _method $obj
  231. }
  232.  
  233. #---------------------------------------------------------------------------
  234. #      File:           @(#)cppinitial.tcl    /main/titanic/3
  235. #---------------------------------------------------------------------------
  236.  
  237. # Start user added include file section
  238. # End user added include file section
  239.  
  240.  
  241. Class CppInitializer : {GCObject} {
  242.     constructor
  243.     method destructor
  244.     method generate
  245.     method ctor
  246.     method valueSet
  247.     method addValue
  248.     method removeValue
  249.     attribute name
  250.     attribute _ctor
  251.     attribute _valueSet
  252. }
  253.  
  254. constructor CppInitializer {class this ctor} {
  255.     set this [GCObject::constructor $class $this]
  256.     $this _ctor $ctor
  257.     [$ctor _initializerSet] append $this
  258.     $this _valueSet [List new]
  259.     # Start constructor user section
  260.     # End constructor user section
  261.     return $this
  262. }
  263.  
  264. method CppInitializer::destructor {this} {
  265.     # Start destructor user section
  266.     # End destructor user section
  267. }
  268.  
  269. method CppInitializer::generate {this section} {
  270.     set cppCtor [$this ctor]
  271.     set idx [ [$cppCtor initializerSet] search -exact $this ]
  272.     if { $idx == -1 } {
  273.         m4_fatal $F_INTINCON "CppInitializer::generate"
  274.         return
  275.     }
  276.     if { $idx != 0 } {
  277.         set comma ","
  278.     } else {
  279.         set comma " :"
  280.     }
  281.     $section indent +
  282.     $section append "${comma}\n[$this name]("
  283.     [$this valueSet] foreach value {
  284.         $value generate $section
  285.     }
  286.     $section append ")"
  287.     $section indent -
  288. }
  289.  
  290. # Do not delete this line -- regeneration end marker
  291.  
  292. method CppInitializer::ctor {this args} {
  293.     if {$args == ""} {
  294.         return [$this _ctor]
  295.     }
  296.     set ref [$this _ctor]
  297.     if {$ref != ""} {
  298.         [$ref _initializerSet] removeValue $this
  299.     }
  300.     set obj [lindex $args 0]
  301.     if {$obj != ""} {
  302.         [$obj _initializerSet] append $this
  303.     }
  304.     $this _ctor $obj
  305. }
  306.  
  307. method CppInitializer::valueSet {this} {
  308.     return [$this _valueSet]
  309. }
  310.  
  311. method CppInitializer::addValue {this newValue} {
  312.     [$this _valueSet] append $newValue
  313.     $newValue _initializer $this
  314. }
  315.  
  316. method CppInitializer::removeValue {this oldValue} {
  317.     $oldValue _initializer ""
  318.     [$this _valueSet] removeValue $oldValue
  319. }
  320.  
  321. #---------------------------------------------------------------------------
  322. #      File:           @(#)cppinitval.tcl    /main/titanic/5
  323. #---------------------------------------------------------------------------
  324.  
  325. # Start user added include file section
  326. # End user added include file section
  327.  
  328.  
  329. Class CppInitValue : {GCObject} {
  330.     constructor
  331.     method destructor
  332.     method generate
  333.     method initializer
  334.     attribute value
  335.     attribute _initializer
  336. }
  337.  
  338. constructor CppInitValue {class this initializer} {
  339.     set this [GCObject::constructor $class $this]
  340.     $this _initializer $initializer
  341.     [$initializer _valueSet] append $this
  342.     # Start constructor user section
  343.     # End constructor user section
  344.     return $this
  345. }
  346.  
  347. method CppInitValue::destructor {this} {
  348.     # Start destructor user section
  349.     # End destructor user section
  350. }
  351.  
  352. method CppInitValue::generate {this section} {
  353.     set cppInit [$this initializer]
  354.     set idx [ [$cppInit valueSet] search -exact $this ]
  355.     if { $idx == -1 } {
  356.         m4_fatal $F_INTINCON "CppInitValue::generate"
  357.         exit
  358.     }
  359.     if { $idx != 0 } {
  360.         set comma ", "
  361.     } else {
  362.         set comma ""
  363.     }
  364.     $section append "${comma}[$this value]"
  365. }
  366.  
  367. # Do not delete this line -- regeneration end marker
  368.  
  369. method CppInitValue::initializer {this args} {
  370.     if {$args == ""} {
  371.         return [$this _initializer]
  372.     }
  373.     set ref [$this _initializer]
  374.     if {$ref != ""} {
  375.         [$ref _valueSet] removeValue $this
  376.     }
  377.     set obj [lindex $args 0]
  378.     if {$obj != ""} {
  379.         [$obj _valueSet] append $this
  380.     }
  381.     $this _initializer $obj
  382. }
  383.  
  384. #---------------------------------------------------------------------------
  385. #      File:           @(#)cppmodel.tcl    /main/titanic/14
  386. #---------------------------------------------------------------------------
  387.  
  388. # Start user added include file section
  389. # End user added include file section
  390.  
  391.  
  392. Class CppModel : {GCObject} {
  393.     constructor
  394.     method destructor
  395.     method findDefinition
  396.     method generate
  397.     method setFileNameParams
  398.     method definitionSet
  399.     method addDefinition
  400.     method removeDefinition
  401.     attribute _definitionSet
  402. }
  403.  
  404. constructor CppModel {class this} {
  405.     set this [GCObject::constructor $class $this]
  406.     $this _definitionSet [List new]
  407.     # Start constructor user section
  408.     # End constructor user section
  409.     return $this
  410. }
  411.  
  412. method CppModel::destructor {this} {
  413.     # Start destructor user section
  414.     # End destructor user section
  415. }
  416.  
  417. method CppModel::findDefinition {this name} {
  418.     [$this definitionSet] foreach definition {
  419.         if {$name == [$definition getName]} {
  420.             return $definition
  421.         }
  422.     }
  423.     return ""
  424. }
  425.  
  426. method CppModel::generate {this typeToClassDict} {
  427.  
  428.     # define local section names
  429.     # header file sections
  430.     set hdrCategories [List new]
  431.     set specialCategories [List new]
  432.     # source file sections
  433.     set cppCategories [List new]
  434.     # title dictionary
  435.     set titleDict [Dictionary new]
  436.     # needs one indent
  437.     set indentDict [Dictionary new]
  438.  
  439.     $cppCategories append "cpp-hdr"
  440.     $cppCategories append "cpp-incl"
  441.     $cppCategories append "cpp-static-init"
  442.     $cppCategories append "cpp-ctor"
  443.     $cppCategories append "cpp-dtor"
  444.     $cppCategories append "cpp-impl"
  445.     $titleDict set "cpp-impl-gen" "// ${CppConstants::regenEnd}\n"
  446.     $cppCategories append "cpp-impl-gen"
  447.     $cppCategories append "cpp-trailor"
  448.  
  449.     $hdrCategories append "hdr-hdr"
  450.     $hdrCategories append "hdr-incl"
  451.     $hdrCategories append "hdr-typedef" ;     # special one
  452.     $hdrCategories append "hdr-enum" ;    # special one
  453.     $hdrCategories append "hdr-class-head"
  454.     foreach access {"public" "protected" "private"} {
  455.         $titleDict set "hdr-typedef-$access" \
  456.             "// Nested typedefs"
  457.         $indentDict set "hdr-typedef-$access" "yes"
  458.         $hdrCategories append "hdr-typedef-$access"
  459.         $specialCategories append "hdr-typedef-$access"
  460.  
  461.         $titleDict set "hdr-ctor-$access" "// Default constructor/destructor"
  462.         $indentDict set "hdr-ctor-$access" "yes"
  463.         $hdrCategories append "hdr-ctor-$access"
  464.         $indentDict set "hdr-dtor-$access" "yes"
  465.         $hdrCategories append "hdr-dtor-$access"
  466.  
  467.         $titleDict set "hdr-user-defined-$access-meth" \
  468.             "// User-defined methods"
  469.         $indentDict set "hdr-user-defined-$access-meth" "yes"
  470.         $hdrCategories append "hdr-user-defined-$access-meth"
  471.  
  472.         $titleDict set "hdr-attrib-access-$access" \
  473.             "// Attribute accessor methods"
  474.         $indentDict set "hdr-attrib-access-$access" "yes"
  475.         $hdrCategories append "hdr-attrib-access-$access"
  476.  
  477.         $titleDict set "hdr-assoc-access-$access" \
  478.             "// Association accessor methods"
  479.         $indentDict set "hdr-assoc-access-$access" "yes"
  480.         $hdrCategories append "hdr-assoc-access-$access"
  481.  
  482.         $titleDict set "hdr-user-defined-$access-data" \
  483.             "// User-defined attributes"
  484.         $indentDict set "hdr-user-defined-$access-data" "yes"
  485.         $hdrCategories append "hdr-user-defined-$access-data"
  486.  
  487.         $titleDict set "hdr-special-$access-data" \
  488.             "// Special attribute"
  489.         $indentDict set "hdr-special-$access-data" "yes"
  490.         $hdrCategories append "hdr-special-$access-data"
  491.         $specialCategories append "hdr-special-$access-data"
  492.  
  493.         $titleDict set "hdr-special-$access-meth" \
  494.             "// Special methods"
  495.         $indentDict set "hdr-special-$access-meth" "yes"
  496.         $hdrCategories append "hdr-special-$access-meth"
  497.         $specialCategories append "hdr-special-$access-meth"
  498.     }
  499.  
  500.     $specialCategories append "hdr-ctor-protected"
  501.     $specialCategories append "hdr-ctor-private"
  502.     $specialCategories append "hdr-user-defined-public-data" 
  503.     $specialCategories append "hdr-user-defined-protected-data" 
  504.  
  505.     $titleDict set "hdr-assoc-storage-private-data" \
  506.         "// Association attribute storage"
  507.     $indentDict set "hdr-assoc-storage-private-data" "yes"
  508.     $hdrCategories append "hdr-assoc-storage-private-data"
  509.  
  510.     $hdrCategories append "hdr-class-tail"
  511.     $hdrCategories append "hdr-impl"
  512.     $titleDict set "hdr-impl-gen" "// ${CppConstants::regenEnd}\n"
  513.     $hdrCategories append "hdr-impl-gen"
  514.     $specialCategories append "hdr-impl-gen"
  515.     $hdrCategories append "hdr-trailor"
  516.  
  517.     [$this definitionSet] foreach definition {
  518.         # first check if this is a normal class and if it
  519.         # is synthetic, if so, skip this class
  520.         if [$definition isA CppClass] {
  521.             if [$definition isSynthetic] {
  522.                 continue
  523.             }
  524.         }
  525.  
  526.         # create sections
  527.         set sections [CppSectionList new]
  528.         $cppCategories foreach cat {
  529.             $sections setSection $cat [TextSection new]
  530.         }
  531.         $hdrCategories foreach cat {
  532.             $sections setSection $cat [TextSection new]
  533.         }
  534.  
  535.         # generate code
  536.         $definition generate $sections
  537.  
  538.         # combine sections 
  539.         set cppSection [TextSection new]
  540.         set hdrSection [TextSection new]
  541.  
  542.         $cppCategories foreach cat {
  543.             set sect [$sections getSection $cat]
  544.             if {[string length [$sect contents]] != 0} {
  545.                 set marker [$titleDict set $cat]
  546.                 if { $marker != ""} {
  547.                     $cppSection append $marker
  548.                     $cppSection append "\n"
  549.                 }
  550.                 $cppSection appendSect $sect
  551.                 if {$cat == "cpp-static-init"} {
  552.                     $cppSection append "\n"
  553.                 }
  554.             }
  555.         }
  556.  
  557.         if { [$definition isA CppClass] } {
  558.             $hdrCategories foreach cat {
  559.                 if { $cat == "hdr-typedef" } { continue }
  560.                 if { $cat == "hdr-enum" } { continue }
  561.  
  562.                 switch $cat {
  563.                     "hdr-typedef-public" \
  564.                         { $hdrSection append "public:\n" }
  565.                     "hdr-typedef-protected" \
  566.                         { $hdrSection append "protected:\n" }
  567.                     "hdr-typedef-private" \
  568.                         { $hdrSection append "private:\n" }
  569.                 }
  570.  
  571.                 if { [$indentDict set $cat] == "yes" } {
  572.                     $hdrSection indent +
  573.                 }
  574.  
  575.                 set sect [$sections getSection $cat]
  576.                 set length [string length [$sect contents]]
  577.  
  578.                 set marker [$titleDict set $cat]
  579.                 if { $marker != "" } {
  580.                     if { ($length != 0) || 
  581.                          ([$specialCategories search -exact $cat] == -1) } {
  582.                         $hdrSection append $marker
  583.                         $hdrSection append "\n"
  584.                     }
  585.                 }
  586.  
  587.                 if {$length != 0} {
  588.                     $hdrSection appendSect $sect
  589.                     $hdrSection append "\n"
  590.                 }
  591.  
  592.                 if { [$indentDict set $cat] == "yes" } {
  593.                     $hdrSection indent -
  594.                 }
  595.             }
  596.         } else {
  597.             # special cases (typedef or enum)
  598.             foreach cat {"hdr-hdr" "hdr-incl" "hdr-typedef" "hdr-enum" "hdr-impl" "hdr-trailor"} {
  599.                 set sect [$sections getSection $cat]
  600.                 if {[string length [$sect contents]] != 0} {
  601.                     $hdrSection appendSect $sect
  602.                     $hdrSection append "\n"
  603.                 }
  604.             }
  605.         }
  606.  
  607.         # add sections to the dictionary
  608.         set sectDict [Dictionary new]
  609.         $sectDict set "c++" $cppSection
  610.         $sectDict set "h++" $hdrSection
  611.         $typeToClassDict set [$definition OOPLClass] $sectDict
  612.     }
  613. }
  614.  
  615. method CppModel::setFileNameParams {this fileHandler} {
  616.     [$this definitionSet] foreach definition {
  617.         set oClass [$definition OOPLClass]
  618.         if { $oClass != ""} {
  619.             $definition hdrFileName \
  620.                 [$fileHandler getFsFileName $oClass [$fileHandler hdrType]]
  621.             $definition cppFileName \
  622.                 [$fileHandler getFsFileName $oClass [$fileHandler cppType]]
  623.             regsub {\.} [$definition hdrFileName] "_" prot
  624.             $definition protector [string toupper $prot]
  625.         } else {
  626.             m4_error $E_DEFNOOOPL 
  627.         }
  628.     }
  629. }
  630.  
  631. # Do not delete this line -- regeneration end marker
  632.  
  633. method CppModel::definitionSet {this} {
  634.     return [$this _definitionSet]
  635. }
  636.  
  637. method CppModel::addDefinition {this newDefinition} {
  638.     [$this _definitionSet] append $newDefinition
  639.     $newDefinition _model $this
  640. }
  641.  
  642. method CppModel::removeDefinition {this oldDefinition} {
  643.     $oldDefinition _model ""
  644.     [$this _definitionSet] removeValue $oldDefinition
  645. }
  646.  
  647. #---------------------------------------------------------------------------
  648. #      File:           @(#)cppobject.tcl    /main/titanic/5
  649. #---------------------------------------------------------------------------
  650.  
  651. # Start user added include file section
  652. # End user added include file section
  653.  
  654.  
  655. Class CppObject : {GCObject} {
  656.     constructor
  657.     method destructor
  658.     method formatComment
  659.     method generate
  660.     method getName
  661.     attribute comment
  662.     attribute name
  663. }
  664.  
  665. constructor CppObject {class this} {
  666.     set this [GCObject::constructor $class $this]
  667.     # Start constructor user section
  668.     # End constructor user section
  669.     return $this
  670. }
  671.  
  672. method CppObject::destructor {this} {
  673.     # Start destructor user section
  674.     # End destructor user section
  675. }
  676.  
  677. method CppObject::formatComment {this section {prefix "// "}} {
  678.     if { [string length [$this comment]] > 0 } {
  679.         set restComment [$this comment]
  680.         set newlinePos [string first "\n" $restComment ]
  681.         while {$newlinePos != -1} {
  682.             set thisline [string range $restComment 0 [expr $newlinePos - 1]]
  683.             set restComment \
  684.                 [string range $restComment [expr $newlinePos + 1] end]
  685.             set newlinePos [string first "\n" $restComment ]
  686.             $section append "${prefix}$thisline\n"
  687.         }
  688.         $section append "${prefix}$restComment\n"
  689.     }
  690. }
  691.  
  692. method CppObject::generate {this sections} {
  693.     m4_fatal $F_ABSTRACT "CppObject::subGenerate"
  694.     exit
  695. }
  696.  
  697. method CppObject::getName {this} {
  698.     return [$this name]
  699. }
  700.  
  701. # Do not delete this line -- regeneration end marker
  702.  
  703. #---------------------------------------------------------------------------
  704. #      File:           @(#)cppregen.tcl    /main/titanic/3
  705. #---------------------------------------------------------------------------
  706.  
  707. # Start user added include file section
  708. # End user added include file section
  709.  
  710.  
  711. Class CppRegen : {TextSection} {
  712.     constructor
  713.     method destructor
  714.     method method
  715.     attribute _method
  716. }
  717.  
  718. constructor CppRegen {class this method} {
  719.     set this [TextSection::constructor $class $this]
  720.     $this _method $method
  721.     [$method _regenSet] append $this
  722.     # Start constructor user section
  723.     # End constructor user section
  724.     return $this
  725. }
  726.  
  727. method CppRegen::destructor {this} {
  728.     # Start destructor user section
  729.     # End destructor user section
  730. }
  731.  
  732. # Do not delete this line -- regeneration end marker
  733.  
  734. method CppRegen::method {this args} {
  735.     if {$args == ""} {
  736.         return [$this _method]
  737.     }
  738.     set ref [$this _method]
  739.     if {$ref != ""} {
  740.         [$ref _regenSet] removeValue $this
  741.     }
  742.     set obj [lindex $args 0]
  743.     if {$obj != ""} {
  744.         [$obj _regenSet] append $this
  745.     }
  746.     $this _method $obj
  747. }
  748.  
  749. #---------------------------------------------------------------------------
  750. #      File:           @(#)cppsection.tcl    /main/titanic/3
  751. #---------------------------------------------------------------------------
  752.  
  753. # Start user added include file section
  754. # End user added include file section
  755.  
  756.  
  757. Class CppSectionList : {GCObject} {
  758.     constructor
  759.     method destructor
  760.     method getSection
  761.     method setSection
  762.     method removeSection
  763.     attribute section
  764. }
  765.  
  766. constructor CppSectionList {class this} {
  767.     set this [GCObject::constructor $class $this]
  768.     $this section [Dictionary new]
  769.     # Start constructor user section
  770.     # End constructor user section
  771.     return $this
  772. }
  773.  
  774. method CppSectionList::destructor {this} {
  775.     # Start destructor user section
  776.     # End destructor user section
  777. }
  778.  
  779. method CppSectionList::getSection {this title} {
  780.     set sect [[$this section] set $title]
  781.     if {$sect == ""} {
  782.         m4_error $F_NOCATEGORY $title
  783.         return [TextSection new]
  784.     }
  785.     return $sect
  786. }
  787.  
  788. # Do not delete this line -- regeneration end marker
  789.  
  790. method CppSectionList::setSection {this title newSection} {
  791.     [$this section] set $title $newSection
  792. }
  793.  
  794. method CppSectionList::removeSection {this title} {
  795.     [$this section] unset $title
  796. }
  797.  
  798. #---------------------------------------------------------------------------
  799. #      File:           @(#)cpptype.tcl    /main/titanic/12
  800. #---------------------------------------------------------------------------
  801.  
  802. # Start user added include file section
  803. # End user added include file section
  804.  
  805.  
  806. Class CppType : {GCObject} {
  807.     constructor
  808.     method destructor
  809.     method isArray
  810.     method getTypeName
  811.     method generate
  812.     method addTemplateParam
  813.     method removeTemplateParam
  814.     attribute name
  815.     attribute isStatic
  816.     attribute isConst
  817.     attribute isPointer
  818.     attribute arraySize
  819.     attribute isReference
  820.     attribute includeInFile
  821.     attribute otherModifier
  822.     attribute nested
  823.     attribute localType
  824.     attribute templateParamSet
  825. }
  826.  
  827. constructor CppType {class this} {
  828.     set this [GCObject::constructor $class $this]
  829.     $this templateParamSet [List new]
  830.     # Start constructor user section
  831.     $this arraySize -1
  832.     $this isStatic 0
  833.     $this isConst 0
  834.     $this isPointer 0
  835.     $this isReference 0
  836.     $this localType ""
  837.     $this nested ""
  838.     $this otherModifier ""
  839.     $this includeInFile ""
  840.     # End constructor user section
  841.     return $this
  842. }
  843.  
  844. method CppType::destructor {this} {
  845.     # Start destructor user section
  846.     # End destructor user section
  847. }
  848.  
  849. method CppType::isArray {this {array -1}} {
  850.     if {$array == -1 } {
  851.         if {[$this arraySize] != -1} {
  852.             return 1
  853.         }
  854.         return 0
  855.     } else {
  856.         if { $array == 0 } {
  857.             $this arraySize -1
  858.         } else {
  859.             $this arraySize $array
  860.         }
  861.     }
  862. }
  863.  
  864. method CppType::getTypeName {this fileT curDef} {
  865.     if {($fileT == "hdr") &&
  866.         ([$this localType] == $curDef) &&
  867.         ([$this localType] != "") &&
  868.         ([$this nested] != "")} {
  869.         return [[$this nested] getTypeName $fileT $curDef]
  870.     }
  871.     set typeName ""
  872.     if {[$this isConst] && [$this otherModifier] == ""} {
  873.         set typeName "const "
  874.     }
  875.     if {[$this localType] == ""} {
  876.         # Standard (or external) type
  877.         if {[$this name] == ""} {
  878.             set typeName "${typeName}void"
  879.         } else {
  880.             set typeName "${typeName}[$this name]"
  881.         }
  882.     } else {
  883.         # Using a locally defined class, enum or typedef
  884.         set typeName "${typeName}[[$this localType] getName]"
  885.     }
  886.  
  887.     if {[$this otherModifier] != ""} {
  888.         if {([$this localType] != "") && ($curDef != "")} {
  889.             $curDef addInclude [$this localType] hdr
  890.         } 
  891.         if [regsub -all {~\$name} [$this otherModifier] $typeName omf] {
  892.             return $omf
  893.         } else {
  894.             return "${typeName}[$this otherModifier]"
  895.         }
  896.     }
  897.  
  898.     if {([$this localType] != "") && ($curDef != "")} {
  899.         set hasExtIncl 0
  900.         foreach incl [[[$this localType] OOPLClass] getPropertyValue "include_list"] {
  901.             $curDef addExtIncl $incl
  902.             set hasExtIncl 1
  903.         }
  904.         if {$fileT != "" && $hasExtIncl!=1} {
  905.             if {[$this includeInFile] == ""} {
  906.                 if {[$this isPointer] || [$this isReference]} {
  907.                     $this includeInFile "cpp"
  908.                 } else {
  909.                     $this includeInFile "hdr"
  910.                 }
  911.             }
  912.  
  913.             if {[$this includeInFile] == "cpp"} {
  914.                 if {$fileT == "hdr" && $fileT != "any" } {
  915.                     $curDef addForward [$this localType] hdr
  916.                 }
  917.                 if {$fileT == "cpp" || $fileT == "any"} {
  918.                     $curDef addInclude [$this localType] cpp
  919.                 }
  920.             } else {
  921.                 if {$fileT == "hdr" || $fileT == "any"} {
  922.                     $curDef addInclude [$this localType] hdr
  923.                 }
  924.             }
  925.         }
  926.     }
  927.     if {![[$this templateParamSet] empty]} {
  928.         set typeName "${typeName}< "
  929.         set first 1
  930.         [$this templateParamSet] foreach param {
  931.             set pTypeName [$param getTypeName $fileT $curDef]
  932.             if {!$first} {
  933.                 set typeName "${typeName}, $pTypeName"
  934.             } else {
  935.                 set typeName "${typeName}$pTypeName"
  936.                 set first 0
  937.             }
  938.         }
  939.         set typeName "${typeName} >"
  940.     }
  941.     if {[$this nested] != ""} {
  942.         set typeName "${typeName}::[[$this nested] getTypeName $fileT $curDef]"
  943.     }
  944.     if {[$this isPointer]} { set typeName "${typeName}*" }
  945.     if {[$this isReference]} { set typeName "${typeName}&" }
  946.     return $typeName
  947. }
  948.  
  949. method CppType::generate {this varName section fileT curDef} {
  950.     set typeName "[$this getTypeName $fileT $curDef] "
  951.     if {$fileT == "hdr" && [$this isStatic]} { $section append "static " }
  952.     $section append $typeName
  953.     $section append $varName
  954.     if [$this isArray] {
  955.         $section append "\[[$this arraySize]\]"
  956.     }
  957. }
  958.  
  959. # Do not delete this line -- regeneration end marker
  960.  
  961. method CppType::addTemplateParam {this newTemplateParam} {
  962.     [$this templateParamSet] append $newTemplateParam
  963.  
  964. }
  965.  
  966. method CppType::removeTemplateParam {this oldTemplateParam} {
  967.     [$this templateParamSet] removeValue $oldTemplateParam
  968. }
  969.  
  970. #---------------------------------------------------------------------------
  971. #      File:           @(#)cppclfeatu.tcl    /main/titanic/5
  972. #---------------------------------------------------------------------------
  973.  
  974. # Start user added include file section
  975. # End user added include file section
  976.  
  977.  
  978. Class CppClFeature : {CppObject} {
  979.     constructor
  980.     method destructor
  981.     method getCategory
  982.     method getSection
  983.     method cl
  984.     attribute _cl
  985.     attribute access
  986.     attribute type
  987. }
  988.  
  989. constructor CppClFeature {class this cl access type} {
  990.     set this [CppObject::constructor $class $this]
  991.     $this _cl $cl
  992.     [$cl _featureSet] append $this
  993.     $this access $access
  994.     $this type $type
  995.     # Start constructor user section
  996.     # End constructor user section
  997.     return $this
  998. }
  999.  
  1000. method CppClFeature::destructor {this} {
  1001.     # Start destructor user section
  1002.     # End destructor user section
  1003.     $this CppObject::destructor
  1004. }
  1005.  
  1006. method CppClFeature::getCategory {this fileT} {
  1007.     m4_fatal $F_ABSTACT "CppClFeature::getCategory"
  1008.     exit
  1009. }
  1010.  
  1011. method CppClFeature::getSection {this fileT sections} {
  1012.     set sectName "[$this getCategory $fileT]"
  1013.     return [$section getSection $sectName]
  1014. }
  1015.  
  1016. # Do not delete this line -- regeneration end marker
  1017.  
  1018. method CppClFeature::cl {this args} {
  1019.     if {$args == ""} {
  1020.         return [$this _cl]
  1021.     }
  1022.     set ref [$this _cl]
  1023.     if {$ref != ""} {
  1024.         [$ref _featureSet] removeValue $this
  1025.     }
  1026.     set obj [lindex $args 0]
  1027.     if {$obj != ""} {
  1028.         [$obj _featureSet] append $this
  1029.     }
  1030.     $this _cl $obj
  1031. }
  1032.  
  1033. #---------------------------------------------------------------------------
  1034. #      File:           @(#)cppattribu.tcl    /main/titanic/7
  1035. #---------------------------------------------------------------------------
  1036.  
  1037. # Start user added include file section
  1038. # End user added include file section
  1039.  
  1040.  
  1041. Class CppAttribute : {CppClFeature} {
  1042.     constructor
  1043.     method destructor
  1044.     method generate
  1045.     method subGenerate
  1046.     method getCategory
  1047.     method accMethodSet
  1048.     method addAccMethod
  1049.     method removeAccMethod
  1050.     attribute defaultValue
  1051.     attribute _accMethodSet
  1052. }
  1053.  
  1054. constructor CppAttribute {class this cl access type} {
  1055.     set this [CppClFeature::constructor $class $this $cl $access $type]
  1056.     $this _accMethodSet [List new]
  1057.     # Start constructor user section
  1058.     # End constructor user section
  1059.     return $this
  1060. }
  1061.  
  1062. method CppAttribute::destructor {this} {
  1063.     # Start destructor user section
  1064.     # End destructor user section
  1065.     $this CppClFeature::destructor
  1066. }
  1067.  
  1068. method CppAttribute::generate {this sections} {
  1069.     $this subGenerate "hdr" \
  1070.         [$sections getSection "[$this getCategory hdr]"]
  1071.     $this subGenerate "cpp" \
  1072.         [$sections getSection "[$this getCategory cpp]"]
  1073. }
  1074.  
  1075. method CppAttribute::subGenerate {this fileT section} {
  1076.     if {$fileT == "hdr"} {
  1077.         # Attributes are only mentioned in the header file
  1078.         $this formatComment $section
  1079.  
  1080.         [$this type] generate [$this getName] $section \
  1081.             hdr [$this cl]
  1082.         if {[$this defaultValue] != ""} {
  1083.             $section append " /* = [$this defaultValue] */"
  1084.         }
  1085.         $section append ";\n"
  1086.     } else {
  1087.         # or they must be static
  1088.         if {([[$this type] isStatic] == 1) && ([$this defaultValue] != "")} {
  1089.             [$this type] generate \
  1090.                 "[[$this cl] getName]::[$this getName]" \
  1091.                 $section cpp [$this cl]
  1092.             $section append " = ([$this defaultValue]);\n"
  1093.         }
  1094.     }
  1095. }
  1096.  
  1097. method CppAttribute::getCategory {this fileT} {
  1098.     set access [string tolower [$this access]]
  1099.     if { $fileT == "hdr" } {
  1100.         return "hdr-special-${access}-data"
  1101.     } else {
  1102.         return "cpp-static-init"
  1103.     }
  1104. }
  1105.  
  1106. # Do not delete this line -- regeneration end marker
  1107.  
  1108. method CppAttribute::accMethodSet {this} {
  1109.     return [$this _accMethodSet]
  1110. }
  1111.  
  1112. method CppAttribute::addAccMethod {this newAccMethod} {
  1113.     [$this _accMethodSet] append $newAccMethod
  1114.     $newAccMethod _belongsTo $this
  1115. }
  1116.  
  1117. method CppAttribute::removeAccMethod {this oldAccMethod} {
  1118.     $oldAccMethod _belongsTo ""
  1119.     [$this _accMethodSet] removeValue $oldAccMethod
  1120. }
  1121.  
  1122. #---------------------------------------------------------------------------
  1123. #      File:           @(#)cppmethod.tcl    /main/titanic/12
  1124. #---------------------------------------------------------------------------
  1125.  
  1126. # Start user added include file section
  1127. # End user added include file section
  1128.  
  1129.  
  1130. Class CppMethod : {CppClFeature} {
  1131.     constructor
  1132.     method destructor
  1133.     method subGenerate
  1134.     method generate
  1135.     method getCategory
  1136.     method genSignature
  1137.     method genRegenCode
  1138.     method paramSet
  1139.     method addParam
  1140.     method removeParam
  1141.     method regenSet
  1142.     method addRegen
  1143.     method removeRegen
  1144.     attribute isDynamic
  1145.     attribute isAbstract
  1146.     attribute isInline
  1147.     attribute isConst
  1148.     attribute _paramSet
  1149.     attribute _regenSet
  1150. }
  1151.  
  1152. constructor CppMethod {class this cl access type} {
  1153.     set this [CppClFeature::constructor $class $this $cl $access $type]
  1154.     $this _paramSet [List new]
  1155.     $this _regenSet [List new]
  1156.     # Start constructor user section
  1157.     $this isInline 0
  1158.     $this isConst 0
  1159.     $this isDynamic 0
  1160.     $this isAbstract 0
  1161.     # End constructor user section
  1162.     return $this
  1163. }
  1164.  
  1165. method CppMethod::destructor {this} {
  1166.     # Start destructor user section
  1167.     # End destructor user section
  1168.     $this CppClFeature::destructor
  1169. }
  1170.  
  1171. method CppMethod::subGenerate {this fileT section} {
  1172.     m4_fatal $F_ABSTRACT "CppMethod::subGenerate"
  1173.     exit
  1174. }
  1175.  
  1176. method CppMethod::generate {this sections} {
  1177.     if { [$this access] != "None" } {
  1178.         set hdrSect [$sections getSection "[$this getCategory hdr]"]
  1179.         set hdrInclSect [$sections getSection "hdr-incl"]
  1180.  
  1181.         if { $hdrSect == "" } {
  1182.             m4_fatal $F_NOCATEGORY [$this getCategory hdr]
  1183.             return
  1184.         }
  1185.  
  1186.         $this subGenerate "hdr" $hdrSect
  1187.  
  1188.         set cppSect [$sections getSection "[$this getCategory cpp]"]
  1189.         set cppInclSect [$sections getSection "cpp-incl"]
  1190.  
  1191.         if { $cppSect == "" } {
  1192.             m4_fatal $F_NOCATEGORY [$this getCategory cpp]
  1193.             return
  1194.         }
  1195.  
  1196.         $this subGenerate "cpp" $cppSect
  1197.         $cppSect append "\n"
  1198.     }
  1199. }
  1200.  
  1201. method CppMethod::getCategory {this fileT} {
  1202.     m4_fatal $F_ABSTRACT "CppMethod::getCategory"
  1203.     return "${fileT}-user-defined-public"
  1204. }
  1205.  
  1206. method CppMethod::genSignature {this fileT section} {
  1207.     set mthdName ""
  1208.     if {$fileT == "cpp"} {
  1209.         set mthdName "${mthdName}[[$this cl] getName]::"
  1210.     }
  1211.     set mthdName "${mthdName}[$this getName]"
  1212.  
  1213.     if {([$this isDynamic] || [$this isAbstract]) && ($fileT == "hdr" || $fileT == "va")} {
  1214.         $section append "virtual "
  1215.     }
  1216.  
  1217.     if {[$this isInline] && $fileT == "cpp" } {
  1218.         $section append "inline "
  1219.     }
  1220.  
  1221.     if {[$this type] == "" || [$this isA CppConstructor] ||
  1222.         [$this isA CppDestructor] ||
  1223.         (([$this getName]==[[$this cl] getName]) && [[$this type] isStatic]) } {
  1224.         $section append $mthdName
  1225.     } else {
  1226.         if [[$this type] isArray] {
  1227.             # Arrays become pointers when returned
  1228.             [$this type] isArray 0
  1229.             [$this type] isPointer 1
  1230.             [$this type] isConst 1
  1231.         }
  1232.         set mthdName ""
  1233.         if {$fileT == "cpp"} {
  1234.             set mthdName "${mthdName}[[$this cl] getName]::"
  1235.         }
  1236.         set mthdName "${mthdName}[$this getName]"
  1237.  
  1238.         [$this type] generate $mthdName $section \
  1239.             $fileT [$this cl]
  1240.     }
  1241.     $section append "("
  1242.     [$this paramSet] foreach param {
  1243.         $param generate $fileT $section
  1244.     }
  1245.     if {$fileT == "hdr"} {
  1246.         $section append ")"
  1247.         if [$this isConst] {
  1248.             $section append " const"
  1249.         }
  1250.         if [$this isAbstract] {
  1251.             $section append " = 0"
  1252.         }
  1253.         $section append ";\n"
  1254.     } else {
  1255.         $section append ")"
  1256.         if [$this isConst] {
  1257.             $section append " const"
  1258.         }
  1259.     }
  1260. }
  1261.  
  1262. method CppMethod::genRegenCode {this section} {
  1263.     if {[[$this regenSet] empty] && ([$this name] != "")} {
  1264.         $section append "// !! Implement this function !!\n"
  1265.         set name [$this name]
  1266.         if [string match operator* $name] {
  1267.             set name "operator"
  1268.         }
  1269.         $section append "int ${name}_is_not_yet_implemented;\n"
  1270.     } else {
  1271.         $section indent -
  1272.         [$this regenSet] foreach regen {
  1273.             $section appendSect $regen
  1274.         }
  1275.         $section indent +
  1276.     }
  1277. }
  1278.  
  1279. # Do not delete this line -- regeneration end marker
  1280.  
  1281. method CppMethod::paramSet {this} {
  1282.     return [$this _paramSet]
  1283. }
  1284.  
  1285. method CppMethod::addParam {this newParam} {
  1286.     [$this _paramSet] append $newParam
  1287.     $newParam _method $this
  1288. }
  1289.  
  1290. method CppMethod::removeParam {this oldParam} {
  1291.     $oldParam _method ""
  1292.     [$this _paramSet] removeValue $oldParam
  1293. }
  1294.  
  1295. method CppMethod::regenSet {this} {
  1296.     return [$this _regenSet]
  1297. }
  1298.  
  1299. method CppMethod::addRegen {this newRegen} {
  1300.     [$this _regenSet] append $newRegen
  1301.     $newRegen _method $this
  1302. }
  1303.  
  1304. method CppMethod::removeRegen {this oldRegen} {
  1305.     $oldRegen _method ""
  1306.     [$this _regenSet] removeValue $oldRegen
  1307. }
  1308.  
  1309. #---------------------------------------------------------------------------
  1310. #      File:           @(#)cppusermet.tcl    /main/titanic/5
  1311. #---------------------------------------------------------------------------
  1312.  
  1313. # Start user added include file section
  1314. # End user added include file section
  1315.  
  1316.  
  1317. Class CppUserMethod : {CppMethod} {
  1318.     constructor
  1319.     method destructor
  1320.     method getName
  1321.     method subGenerate
  1322.     method getCategory
  1323. }
  1324.  
  1325. constructor CppUserMethod {class this cl access type} {
  1326.     set this [CppMethod::constructor $class $this $cl $access $type]
  1327.     # Start constructor user section
  1328.     # End constructor user section
  1329.     return $this
  1330. }
  1331.  
  1332. method CppUserMethod::destructor {this} {
  1333.     # Start destructor user section
  1334.     # End destructor user section
  1335.     $this CppMethod::destructor
  1336. }
  1337.  
  1338. method CppUserMethod::getName {this} {
  1339.     if {([$this name]=="create") && [[$this type] isStatic]} {
  1340.         return [[$this cl] getName]
  1341.     } else {
  1342.         return [$this name]
  1343.     }
  1344. }
  1345.  
  1346. method CppUserMethod::subGenerate {this fileT section} {
  1347.     $this formatComment $section
  1348.     if { $fileT == "cpp" } {
  1349.         if {![$this isAbstract]} {
  1350.             $this genSignature $fileT $section
  1351.             $section append "\n{\n"
  1352.             $section indent +
  1353.             $this genRegenCode $section
  1354.             $section indent -
  1355.             $section append "}\n"
  1356.         }
  1357.     } else {
  1358.         $this genSignature $fileT $section
  1359.     }
  1360. }
  1361.  
  1362. method CppUserMethod::getCategory {this fileT} {
  1363.     if {$fileT == "hdr"} {
  1364.         return "hdr-user-defined-[string tolower [$this access]]-meth"
  1365.     } else {
  1366.         if [$this isInline] {
  1367.             return "hdr-impl"
  1368.         }
  1369.  
  1370.         return "cpp-impl"
  1371.     }
  1372. }
  1373.  
  1374. # Do not delete this line -- regeneration end marker
  1375.  
  1376. #---------------------------------------------------------------------------
  1377. #      File:           @(#)cppdefinit.tcl    /main/titanic/10
  1378. #---------------------------------------------------------------------------
  1379.  
  1380. # Start user added include file section
  1381. require "caynutil.tcl"
  1382. # End user added include file section
  1383.  
  1384.  
  1385. Class CppDefinition : {CppObject} {
  1386.     constructor
  1387.     method destructor
  1388.     method addProtectorStart
  1389.     method addProtectorEnd
  1390.     method addInclude
  1391.     method addForward
  1392.     method addExtIncl
  1393.     method addHeader
  1394.     method generateFwd
  1395.     method generateInc
  1396.     method model
  1397.     method extIncludeSet
  1398.     method addExtInclude
  1399.     method removeExtInclude
  1400.     method getIncludeSect
  1401.     method setIncludeSect
  1402.     method removeIncludeSect
  1403.     method getObsoleteCode
  1404.     method setObsoleteCode
  1405.     method removeObsoleteCode
  1406.     attribute hdrFileName
  1407.     attribute cppFileName
  1408.     attribute protector
  1409.     attribute includedDefs
  1410.     attribute forwardDefs
  1411.     attribute isSynthetic
  1412.     attribute OOPLClass
  1413.     attribute _model
  1414.     attribute _extIncludeSet
  1415.     attribute includeSect
  1416.     attribute obsoleteCode
  1417. }
  1418.  
  1419. constructor CppDefinition {class this OOPLClass model} {
  1420.     set this [CppObject::constructor $class $this]
  1421.     $this OOPLClass $OOPLClass
  1422.     $this _model $model
  1423.     [$model _definitionSet] append $this
  1424.     $this _extIncludeSet [List new]
  1425.     $this includeSect [Dictionary new]
  1426.     $this obsoleteCode [Dictionary new]
  1427.     # Start constructor user section
  1428.     $this setObsoleteCode "hdr" [TextSection new]
  1429.     $this setObsoleteCode "cpp" [TextSection new]
  1430.     $this setIncludeSect "hdr" [TextSection new]
  1431.     $this setIncludeSect "cpp" [TextSection new]
  1432.     $this includedDefs [Dictionary new]
  1433.     $this forwardDefs [Dictionary new]
  1434.     $this isSynthetic 0
  1435.     # End constructor user section
  1436.     return $this
  1437. }
  1438.  
  1439. method CppDefinition::destructor {this} {
  1440.     # Start destructor user section
  1441.     # End destructor user section
  1442.     $this CppObject::destructor
  1443. }
  1444.  
  1445. method CppDefinition::addProtectorStart {this section} {
  1446.     $section append "#ifndef [$this protector]\n"
  1447.     $section append "#define [$this protector] 1\n\n"
  1448. }
  1449.  
  1450. method CppDefinition::addProtectorEnd {this section} {
  1451.     $section append "#endif // [$this protector]\n"
  1452. }
  1453.  
  1454. method CppDefinition::addInclude {this forDef fileT} {
  1455.     if {$forDef == $this} {
  1456.         if {$fileT == "cpp"} {
  1457.             [$this includedDefs] set $forDef $fileT
  1458.         }
  1459.     } else {
  1460.         if {$fileT == "hdr"} {
  1461.             [$this includedDefs] set $forDef $fileT
  1462.         } else {
  1463.             if {![[$this includedDefs] exists $forDef]} {
  1464.                 [$this includedDefs] set $forDef $fileT
  1465.             }
  1466.         }
  1467.     }
  1468. }
  1469.  
  1470. method CppDefinition::addForward {this forDef fileT} {
  1471.     if {$fileT == "hdr"} {
  1472.         if {$forDef != $this} {
  1473.             [$this forwardDefs] set $forDef $fileT
  1474.         }
  1475.     } else {
  1476.         if {![[$this forwardDefs] exists $forDef]} {
  1477.             [$this forwardDefs] set $forDef $fileT
  1478.         }
  1479.     }
  1480. }
  1481.  
  1482. method CppDefinition::addExtIncl {this fileName} {
  1483.     if {$fileName == ""} {
  1484.         return
  1485.     }
  1486.     [$this extIncludeSet] foreach extIncl {
  1487.         if { [$extIncl fileName] == "$fileName" } {
  1488.             return 
  1489.         } 
  1490.     }
  1491.     set newExtIncl [CppExtInclude new $this]
  1492.     $newExtIncl fileName "$fileName"
  1493. }
  1494.  
  1495. method CppDefinition::addHeader {this fileT section} {
  1496.  
  1497.     if {$fileT == "hdr"} {
  1498.         set filename [$this hdrFileName]
  1499.     } else {
  1500.         set filename [$this cppFileName]
  1501.     }
  1502.  
  1503.     if {$fileT == "hdr" } {
  1504.         set name "h++"
  1505.     } else {    
  1506.         set name "c++"
  1507.     }
  1508.  
  1509.     expandHeaderIntoSection $filename $name $section
  1510.     $section append "\n"
  1511. }
  1512.  
  1513. method CppDefinition::generateFwd {this hdrSect srcSect} {
  1514.     set hdrList [List new]
  1515.  
  1516.     [$this forwardDefs] foreach forDef fileT {
  1517.         if {![[$this includedDefs] exists $forDef]} {
  1518.             $hdrList append "class [$forDef getName];\n\n"
  1519.         } else {
  1520.             if {[[$this includedDefs] set $forDef] == "cpp" } {
  1521.                 $hdrList append "class [$forDef getName];\n\n"
  1522.             }
  1523.         }
  1524.     }
  1525.  
  1526.     $hdrList sort
  1527.     $hdrList foreach entry {
  1528.         $hdrSect append $entry
  1529.     }
  1530. }
  1531.  
  1532. method CppDefinition::generateInc {this hdrSect srcSect} {
  1533.     set hdrDict [Dictionary new]
  1534.     set cppDict [Dictionary new]
  1535.  
  1536.     [$this includedDefs] foreach forDef fileT {
  1537.         if {$fileT == "hdr"} {
  1538.             $hdrDict set [$forDef protector] [$forDef hdrFileName]
  1539.         } else {
  1540.             $cppDict set [$forDef protector] [$forDef hdrFileName]
  1541.         }
  1542.     }
  1543.  
  1544.     [$this extIncludeSet] foreach extIncl {
  1545.         $extIncl generate $hdrSect
  1546.     }
  1547.     if {![[$this extIncludeSet] empty]} {
  1548.         $hdrSect append "\n"
  1549.     }
  1550.     foreach protector [lsort [$hdrDict names]] {
  1551.         set hdrFileName [$hdrDict set $protector]
  1552.         $hdrSect append "#ifndef $protector\n"
  1553.         $hdrSect append "#include \"$hdrFileName\"\n"
  1554.         $hdrSect append "#endif\n\n"
  1555.     }
  1556.  
  1557.     foreach protector [lsort [$cppDict names]] {
  1558.         set hdrFileName [$cppDict set $protector]
  1559.         $srcSect append "#ifndef $protector\n"
  1560.         $srcSect append "#include \"$hdrFileName\"\n"
  1561.         $srcSect append "#endif\n\n"
  1562.     }
  1563. }
  1564.  
  1565. # Do not delete this line -- regeneration end marker
  1566.  
  1567. method CppDefinition::model {this args} {
  1568.     if {$args == ""} {
  1569.         return [$this _model]
  1570.     }
  1571.     set ref [$this _model]
  1572.     if {$ref != ""} {
  1573.         [$ref _definitionSet] removeValue $this
  1574.     }
  1575.     set obj [lindex $args 0]
  1576.     if {$obj != ""} {
  1577.         [$obj _definitionSet] append $this
  1578.     }
  1579.     $this _model $obj
  1580. }
  1581.  
  1582. method CppDefinition::extIncludeSet {this} {
  1583.     return [$this _extIncludeSet]
  1584. }
  1585.  
  1586. method CppDefinition::addExtInclude {this newExtInclude} {
  1587.     [$this _extIncludeSet] append $newExtInclude
  1588.     $newExtInclude _definition $this
  1589. }
  1590.  
  1591. method CppDefinition::removeExtInclude {this oldExtInclude} {
  1592.     $oldExtInclude _definition ""
  1593.     [$this _extIncludeSet] removeValue $oldExtInclude
  1594. }
  1595.  
  1596. method CppDefinition::getIncludeSect {this fType} {
  1597.     return [[$this includeSect] set $fType]
  1598. }
  1599.  
  1600. method CppDefinition::setIncludeSect {this fType newIncludeSect} {
  1601.     [$this includeSect] set $fType $newIncludeSect
  1602. }
  1603.  
  1604. method CppDefinition::removeIncludeSect {this fType} {
  1605.     [$this includeSect] unset $fType
  1606. }
  1607.  
  1608. method CppDefinition::getObsoleteCode {this fType} {
  1609.     return [[$this obsoleteCode] set $fType]
  1610. }
  1611.  
  1612. method CppDefinition::setObsoleteCode {this fType newObsoleteCode} {
  1613.     [$this obsoleteCode] set $fType $newObsoleteCode
  1614. }
  1615.  
  1616. method CppDefinition::removeObsoleteCode {this fType} {
  1617.     [$this obsoleteCode] unset $fType
  1618. }
  1619.  
  1620. #---------------------------------------------------------------------------
  1621. #      File:           @(#)cpptypedef.tcl    /main/titanic/7
  1622. #---------------------------------------------------------------------------
  1623.  
  1624. # Start user added include file section
  1625. # End user added include file section
  1626.  
  1627.  
  1628. Class CppTypeDef : {CppDefinition} {
  1629.     constructor
  1630.     method destructor
  1631.     method generate
  1632.     attribute type
  1633. }
  1634.  
  1635. constructor CppTypeDef {class this OOPLClass model type} {
  1636.     set this [CppDefinition::constructor $class $this $OOPLClass $model]
  1637.     $this type $type
  1638.     # Start constructor user section
  1639.     # End constructor user section
  1640.     return $this
  1641. }
  1642.  
  1643. method CppTypeDef::destructor {this} {
  1644.     # Start destructor user section
  1645.     # End destructor user section
  1646.     $this CppDefinition::destructor
  1647. }
  1648.  
  1649. method CppTypeDef::generate {this sections} {
  1650.  
  1651.     if [$this isSynthetic] {
  1652.         return
  1653.     }
  1654.  
  1655.     set hdrSect [ $sections getSection "hdr-hdr" ]
  1656.     set inclSect [ $sections getSection "hdr-incl" ]
  1657.     set typedSect [ $sections getSection "hdr-typedef" ]
  1658.     set trailSect [ $sections getSection "hdr-trailor" ]
  1659.  
  1660.     $this addHeader "hdr" $hdrSect
  1661.     $this addProtectorStart $hdrSect
  1662.     $this formatComment $typedSect
  1663.     $typedSect append "typedef "
  1664.     [$this type] generate [$this getName] $typedSect "hdr" $this
  1665.     $typedSect append ";\n"
  1666.     $this addProtectorEnd $trailSect
  1667.  
  1668.     $this generateInc $hdrSect $hdrSect
  1669.     $this generateFwd $hdrSect $hdrSect
  1670.  
  1671.     $hdrSect append "// "
  1672.     $hdrSect append ${CppConstants::startInclude}
  1673.     $hdrSect append "\n"
  1674.     $hdrSect appendSect [$this getIncludeSect "hdr"]
  1675.     $hdrSect append "// "
  1676.     $hdrSect append ${CppConstants::endInclude}
  1677.     $hdrSect append "\n\n"
  1678. }
  1679.  
  1680. # Do not delete this line -- regeneration end marker
  1681.  
  1682. #---------------------------------------------------------------------------
  1683. #      File:           @(#)cppparam.tcl    /main/titanic/4
  1684. #---------------------------------------------------------------------------
  1685.  
  1686. # Start user added include file section
  1687. # End user added include file section
  1688.  
  1689.  
  1690. Class CppParam : {CppObject} {
  1691.     constructor
  1692.     method destructor
  1693.     method generate
  1694.     method method
  1695.     attribute defaultValue
  1696.     attribute type
  1697.     attribute _method
  1698. }
  1699.  
  1700. constructor CppParam {class this type method} {
  1701.     set this [CppObject::constructor $class $this]
  1702.     $this type $type
  1703.     $this _method $method
  1704.     [$method _paramSet] append $this
  1705.     # Start constructor user section
  1706.     # End constructor user section
  1707.     return $this
  1708. }
  1709.  
  1710. method CppParam::destructor {this} {
  1711.     # Start destructor user section
  1712.     # End destructor user section
  1713.     $this CppObject::destructor
  1714. }
  1715.  
  1716. method CppParam::generate {this fileT section} {
  1717.     set cppMeth [$this method]
  1718.     set idx [ [$cppMeth paramSet] search -exact $this ]
  1719.     if { $idx == -1 } {
  1720.         m4_fatal $F_INTINCON "CppParam::generate"
  1721.         exit
  1722.     }
  1723.     if { $idx != 0 } {
  1724.         $section append ", "
  1725.     }
  1726.     if [[$this type] isArray] {
  1727.         [$this type] isArray 0
  1728.         [$this type] isPointer 1
  1729.         [$this type] isConst 1
  1730.     }
  1731.     [$this type] generate [$this getName] $section \
  1732.         $fileT [[$this method] cl]
  1733.     if {$fileT == "hdr" && [$this defaultValue] != ""} {
  1734.         $section append "= [$this defaultValue]"
  1735.     }
  1736. }
  1737.  
  1738. # Do not delete this line -- regeneration end marker
  1739.  
  1740. method CppParam::method {this args} {
  1741.     if {$args == ""} {
  1742.         return [$this _method]
  1743.     }
  1744.     set ref [$this _method]
  1745.     if {$ref != ""} {
  1746.         [$ref _paramSet] removeValue $this
  1747.     }
  1748.     set obj [lindex $args 0]
  1749.     if {$obj != ""} {
  1750.         [$obj _paramSet] append $this
  1751.     }
  1752.     $this _method $obj
  1753. }
  1754.  
  1755. #---------------------------------------------------------------------------
  1756. #      File:           @(#)cppassocat.tcl    /main/titanic/4
  1757. #---------------------------------------------------------------------------
  1758.  
  1759. # Start user added include file section
  1760. # End user added include file section
  1761.  
  1762.  
  1763. Class CppAssocAttrib : {CppAttribute} {
  1764.     constructor
  1765.     method destructor
  1766.     method getCategory
  1767. }
  1768.  
  1769. constructor CppAssocAttrib {class this cl access type} {
  1770.     set this [CppAttribute::constructor $class $this $cl $access $type]
  1771.     # Start constructor user section
  1772.     # End constructor user section
  1773.     return $this
  1774. }
  1775.  
  1776. method CppAssocAttrib::destructor {this} {
  1777.     # Start destructor user section
  1778.     # End destructor user section
  1779.     $this CppAttribute::destructor
  1780. }
  1781.  
  1782. method CppAssocAttrib::getCategory {this fileT} {
  1783.     if {$fileT == "hdr"} {
  1784.         return "hdr-assoc-storage-private-data"
  1785.     } else {
  1786.         return "cpp-static-init"
  1787.     }
  1788. }
  1789.  
  1790. # Do not delete this line -- regeneration end marker
  1791.  
  1792. #---------------------------------------------------------------------------
  1793. #      File:           @(#)cppgenmeth.tcl    /main/titanic/5
  1794. #---------------------------------------------------------------------------
  1795.  
  1796. # Start user added include file section
  1797. # End user added include file section
  1798.  
  1799.  
  1800. Class CppGenMethod : {CppMethod} {
  1801.     constructor
  1802.     method destructor
  1803.     method genGenCode
  1804.     method subGenerate
  1805.     method getCategory
  1806.     method genCodeSet
  1807.     method addGenCode
  1808.     method removeGenCode
  1809.     attribute _genCodeSet
  1810. }
  1811.  
  1812. constructor CppGenMethod {class this cl access type} {
  1813.     set this [CppMethod::constructor $class $this $cl $access $type]
  1814.     $this _genCodeSet [List new]
  1815.     # Start constructor user section
  1816.     # End constructor user section
  1817.     return $this
  1818. }
  1819.  
  1820. method CppGenMethod::destructor {this} {
  1821.     # Start destructor user section
  1822.     # End destructor user section
  1823.     $this CppMethod::destructor
  1824. }
  1825.  
  1826. method CppGenMethod::genGenCode {this section} {
  1827.     [$this genCodeSet] foreach genCode {
  1828.         $section appendSect $genCode 
  1829.     }
  1830. }
  1831.  
  1832. method CppGenMethod::subGenerate {this fileT section} {
  1833.     $this formatComment $section
  1834.     if { $fileT == "cpp" } {
  1835.         if {![$this isAbstract]} {
  1836.             $this genSignature $fileT $section
  1837.             $section append "\n{\n"
  1838.             $section indent +
  1839.             $this genGenCode $section
  1840.             $section indent -
  1841.             $section append "}\n"
  1842.         }
  1843.     } else {
  1844.         $this genSignature $fileT $section
  1845.     }
  1846. }
  1847.  
  1848. method CppGenMethod::getCategory {this fileT} {
  1849.     if {$fileT == "hdr"} {
  1850.         set access [$this access]
  1851.         return "hdr-special-[string tolower $access]-meth"
  1852.     } else {
  1853.         if [$this isInline] {
  1854.             return "hdr-impl-gen"
  1855.         }
  1856.         return "cpp-impl-gen"
  1857.     }
  1858. }
  1859.  
  1860. # Do not delete this line -- regeneration end marker
  1861.  
  1862. method CppGenMethod::genCodeSet {this} {
  1863.     return [$this _genCodeSet]
  1864. }
  1865.  
  1866. method CppGenMethod::addGenCode {this newGenCode} {
  1867.     [$this _genCodeSet] append $newGenCode
  1868.     $newGenCode _method $this
  1869. }
  1870.  
  1871. method CppGenMethod::removeGenCode {this oldGenCode} {
  1872.     $oldGenCode _method ""
  1873.     [$this _genCodeSet] removeValue $oldGenCode
  1874. }
  1875.  
  1876. #---------------------------------------------------------------------------
  1877. #      File:           @(#)cppdestruc.tcl    /main/titanic/6
  1878. #---------------------------------------------------------------------------
  1879.  
  1880. # Start user added include file section
  1881. # End user added include file section
  1882.  
  1883.  
  1884. Class CppDestructor : {CppGenMethod} {
  1885.     constructor
  1886.     method destructor
  1887.     method getName
  1888.     method subGenerate
  1889.     method getCategory
  1890. }
  1891.  
  1892. constructor CppDestructor {class this cl access type} {
  1893.     set this [CppGenMethod::constructor $class $this $cl $access $type]
  1894.     # Start constructor user section
  1895.     # End constructor user section
  1896.     return $this
  1897. }
  1898.  
  1899. method CppDestructor::destructor {this} {
  1900.     # Start destructor user section
  1901.     # End destructor user section
  1902.     $this CppGenMethod::destructor
  1903. }
  1904.  
  1905. method CppDestructor::getName {this} {
  1906.     return "~[[$this cl] getName]"
  1907. }
  1908.  
  1909. method CppDestructor::subGenerate {this fileT section} {
  1910.     $this formatComment $section
  1911.     $this genSignature $fileT $section
  1912.     if { $fileT == "cpp" } {
  1913.         $section append "\n{\n"
  1914.         $section indent +
  1915.         $section append "// "
  1916.         $section append ${CppConstants::startDtor}
  1917.         $section append "\n"
  1918.         $this genRegenCode $section
  1919.         $section append "// "
  1920.         $section append ${CppConstants::endDtor}
  1921.         $section append "\n"
  1922.         $this genGenCode $section
  1923.         $section indent -
  1924.         $section append "}\n"
  1925.     }
  1926. }
  1927.  
  1928. method CppDestructor::getCategory {this fileT} {
  1929.     if {$fileT == "hdr"} {
  1930.         set access [string tolower [$this access]]
  1931.         if {$access == ""} {
  1932.             set access "public"
  1933.         }
  1934.         return "hdr-dtor-$access"
  1935.     } else {
  1936.         return "cpp-dtor"
  1937.     }
  1938. }
  1939.  
  1940. # Do not delete this line -- regeneration end marker
  1941.  
  1942. #---------------------------------------------------------------------------
  1943. #      File:           @(#)cppenum.tcl    /main/titanic/6
  1944. #---------------------------------------------------------------------------
  1945.  
  1946. # Start user added include file section
  1947. # End user added include file section
  1948.  
  1949.  
  1950. Class CppEnum : {CppDefinition} {
  1951.     constructor
  1952.     method destructor
  1953.     method generate
  1954.     method itemSet
  1955.     method addItem
  1956.     method removeItem
  1957.     attribute _itemSet
  1958. }
  1959.  
  1960. constructor CppEnum {class this OOPLClass model} {
  1961.     set this [CppDefinition::constructor $class $this $OOPLClass $model]
  1962.     $this _itemSet [List new]
  1963.     # Start constructor user section
  1964.     # End constructor user section
  1965.     return $this
  1966. }
  1967.  
  1968. method CppEnum::destructor {this} {
  1969.     # Start destructor user section
  1970.     # End destructor user section
  1971.     $this CppDefinition::destructor
  1972. }
  1973.  
  1974. method CppEnum::generate {this sections} {
  1975.     
  1976.     if [$this isSynthetic] {
  1977.         return
  1978.     }
  1979.  
  1980.     set hdrSect [ $sections getSection "hdr-hdr" ]
  1981.     set includeHdrSect [ $sections getSection "hdr-incl" ]
  1982.     set enumSect [ $sections getSection "hdr-enum" ]
  1983.     set trailSect [ $sections getSection "hdr-trailor" ]
  1984.  
  1985.     $this addHeader "hdr" $hdrSect
  1986.     $this addProtectorStart $hdrSect
  1987.     $this formatComment $enumSect
  1988.     $enumSect append "enum [$this getName] {\n"
  1989.     $enumSect indent +
  1990.     [$this itemSet] foreach item {
  1991.         $item generate $enumSect
  1992.     }
  1993.     $enumSect append "\n"
  1994.     $enumSect indent -
  1995.     $enumSect append "};\n"
  1996.     $this addProtectorEnd $trailSect
  1997.  
  1998.     $this generateInc $hdrSect $hdrSect
  1999.     $this generateFwd $hdrSect $hdrSect
  2000.  
  2001.     $hdrSect append "// "
  2002.     $hdrSect append ${CppConstants::startInclude}
  2003.     $hdrSect append "\n"
  2004.     $hdrSect appendSect [$this getIncludeSect "hdr"]
  2005.     $hdrSect append "// "
  2006.     $hdrSect append ${CppConstants::endInclude}
  2007.     $hdrSect append "\n\n"
  2008. }
  2009.  
  2010. # Do not delete this line -- regeneration end marker
  2011.  
  2012. method CppEnum::itemSet {this} {
  2013.     return [$this _itemSet]
  2014. }
  2015.  
  2016. method CppEnum::addItem {this newItem} {
  2017.     [$this _itemSet] append $newItem
  2018.     $newItem _enum $this
  2019. }
  2020.  
  2021. method CppEnum::removeItem {this oldItem} {
  2022.     $oldItem _enum ""
  2023.     [$this _itemSet] removeValue $oldItem
  2024. }
  2025.  
  2026. #---------------------------------------------------------------------------
  2027. #      File:           @(#)cppconstru.tcl    /main/titanic/5
  2028. #---------------------------------------------------------------------------
  2029.  
  2030. # Start user added include file section
  2031. # End user added include file section
  2032.  
  2033.  
  2034. Class CppConstructor : {CppGenMethod} {
  2035.     constructor
  2036.     method destructor
  2037.     method getName
  2038.     method subGenerate
  2039.     method getCategory
  2040.     method initializerSet
  2041.     method addInitializer
  2042.     method removeInitializer
  2043.     attribute _initializerSet
  2044. }
  2045.  
  2046. constructor CppConstructor {class this cl access type} {
  2047.     set this [CppGenMethod::constructor $class $this $cl $access $type]
  2048.     $this _initializerSet [List new]
  2049.     # Start constructor user section
  2050.     # End constructor user section
  2051.     return $this
  2052. }
  2053.  
  2054. method CppConstructor::destructor {this} {
  2055.     # Start destructor user section
  2056.     # End destructor user section
  2057.     $this CppGenMethod::destructor
  2058. }
  2059.  
  2060. method CppConstructor::getName {this} {
  2061.     return [[$this cl] getName]
  2062. }
  2063.  
  2064. method CppConstructor::subGenerate {this fileT section} {
  2065.     $this formatComment $section
  2066.     $this genSignature $fileT $section
  2067.     if { $fileT == "cpp" } {
  2068.         [$this initializerSet] foreach init {
  2069.             $init generate $section
  2070.         }
  2071.         $section append "\n{\n"
  2072.         $section indent +
  2073.         $this genGenCode $section
  2074.         $section append "// "
  2075.         $section append ${CppConstants::startCtor}
  2076.         $section append "\n"
  2077.         $this genRegenCode $section
  2078.         $section append "// "
  2079.         $section append ${CppConstants::endCtor}
  2080.         $section append "\n"
  2081.         $section indent -
  2082.         $section append "}\n"
  2083.     }
  2084. }
  2085.  
  2086. method CppConstructor::getCategory {this fileT} {
  2087.     if {$fileT == "cpp"} {
  2088.         if [$this isInline] {
  2089.             m4_warning $W_INLINECTOR
  2090.             $this isInline 0
  2091.         } 
  2092.         return "cpp-ctor"
  2093.     } else {
  2094.         set access [string tolower [$this access]]
  2095.         if {$access == ""} {
  2096.             set access "public"
  2097.         }
  2098.         return "hdr-ctor-$access"
  2099.     }
  2100. }
  2101.  
  2102. # Do not delete this line -- regeneration end marker
  2103.  
  2104. method CppConstructor::initializerSet {this} {
  2105.     return [$this _initializerSet]
  2106. }
  2107.  
  2108. method CppConstructor::addInitializer {this newInitializer} {
  2109.     [$this _initializerSet] append $newInitializer
  2110.     $newInitializer _ctor $this
  2111. }
  2112.  
  2113. method CppConstructor::removeInitializer {this oldInitializer} {
  2114.     $oldInitializer _ctor ""
  2115.     [$this _initializerSet] removeValue $oldInitializer
  2116. }
  2117.  
  2118. #---------------------------------------------------------------------------
  2119. #      File:           @(#)cppnestedt.tcl    /main/titanic/2
  2120. #---------------------------------------------------------------------------
  2121.  
  2122. # Start user added include file section
  2123. # End user added include file section
  2124.  
  2125.  
  2126. Class CppNestedTypeDef : {CppClFeature} {
  2127.     constructor
  2128.     method destructor
  2129.     method generate
  2130. }
  2131.  
  2132. constructor CppNestedTypeDef {class this cl access type} {
  2133.     set this [CppClFeature::constructor $class $this $cl $access $type]
  2134.     # Start constructor user section
  2135.     # End constructor user section
  2136.     return $this
  2137. }
  2138.  
  2139. method CppNestedTypeDef::destructor {this} {
  2140.     # Start destructor user section
  2141.     # End destructor user section
  2142.     $this CppClFeature::destructor
  2143. }
  2144.  
  2145. method CppNestedTypeDef::generate {this sections} {
  2146.     set access [string tolower [$this access]]
  2147.     if {$access == ""} {
  2148.         set access "public"
  2149.     }
  2150.     set typedSect [ $sections getSection "hdr-typedef-$access" ]
  2151.     $this formatComment $typedSect
  2152.     $typedSect append "typedef "
  2153.     [$this type] generate [$this getName] $typedSect "hdr" [$this cl]
  2154.     $typedSect append ";\n"
  2155.  
  2156. }
  2157.  
  2158. # Do not delete this line -- regeneration end marker
  2159.  
  2160. #---------------------------------------------------------------------------
  2161. #      File:           @(#)cppaccmeth.tcl    /main/titanic/6
  2162. #---------------------------------------------------------------------------
  2163.  
  2164. # Start user added include file section
  2165. # End user added include file section
  2166.  
  2167.  
  2168. Class CppAccMethod : {CppGenMethod} {
  2169.     constructor
  2170.     method destructor
  2171.     method subGenerate
  2172.     method getCategory
  2173.     method getMethodName
  2174.     method belongsTo
  2175.     attribute kind
  2176.     attribute _belongsTo
  2177. }
  2178.  
  2179. constructor CppAccMethod {class this cl access type belongsTo} {
  2180.     set this [CppGenMethod::constructor $class $this $cl $access $type]
  2181.     $this _belongsTo $belongsTo
  2182.     [$belongsTo _accMethodSet] append $this
  2183.     # Start constructor user section
  2184.     # End constructor user section
  2185.     return $this
  2186. }
  2187.  
  2188. method CppAccMethod::destructor {this} {
  2189.     # Start destructor user section
  2190.     # End destructor user section
  2191.     $this CppGenMethod::destructor
  2192. }
  2193.  
  2194. method CppAccMethod::subGenerate {this fileT section} {
  2195.     $this formatComment $section
  2196.     $this genSignature $fileT $section
  2197.     if { $fileT == "cpp" } {
  2198.         $section append "\n{\n"
  2199.         $section indent +
  2200.         $this genGenCode $section
  2201.         $section indent -
  2202.         $section append "}\n"
  2203.     }
  2204. }
  2205.  
  2206. method CppAccMethod::getCategory {this fileT} {
  2207.     if {$fileT == "hdr"} {
  2208.         set access [$this access]
  2209.         if [[$this belongsTo] isA CppAssocAttrib] {
  2210.             return "hdr-assoc-access-[string tolower $access]"
  2211.         } else {
  2212.             return "hdr-attrib-access-[string tolower $access]"
  2213.         }
  2214.     } else {
  2215.         if [$this isInline] {
  2216.             return "hdr-impl-gen"
  2217.         }
  2218.         return "cpp-impl-gen"
  2219.     }
  2220. }
  2221.  
  2222. method CppAccMethod::getMethodName {this kind name} {
  2223.     set firstUp [string toupper [string range $name 0 0]]
  2224.     set uName "${firstUp}[string range $name 1 end]"
  2225.  
  2226.     switch $kind {
  2227.         attrib-get {
  2228.             set fullName "get${uName}"
  2229.         }
  2230.         attrib-set {
  2231.             set fullName "set${uName}"
  2232.         }
  2233.         assoc-get {
  2234.             set fullName "get${uName}"
  2235.         }
  2236.         assoc-get-set {
  2237.             set fullName "get${uName}Set"
  2238.         }
  2239.         assoc-set {
  2240.             set fullName "set${uName}"
  2241.         }
  2242.         assoc-add {
  2243.             set fullName "add${uName}"
  2244.         }
  2245.         assoc-remove {
  2246.             set fullName "remove${uName}"
  2247.         }
  2248.         default {
  2249.             puts stderr "Unknown kind: $kind, $name"
  2250.             set fullName "$name"
  2251.         }
  2252.     }
  2253.     return $fullName
  2254. }
  2255.  
  2256. # Do not delete this line -- regeneration end marker
  2257.  
  2258. method CppAccMethod::belongsTo {this args} {
  2259.     if {$args == ""} {
  2260.         return [$this _belongsTo]
  2261.     }
  2262.     set ref [$this _belongsTo]
  2263.     if {$ref != ""} {
  2264.         [$ref _accMethodSet] removeValue $this
  2265.     }
  2266.     set obj [lindex $args 0]
  2267.     if {$obj != ""} {
  2268.         [$obj _accMethodSet] append $this
  2269.     }
  2270.     $this _belongsTo $obj
  2271. }
  2272.  
  2273. #---------------------------------------------------------------------------
  2274. #      File:           @(#)cppenumite.tcl    /main/titanic/3
  2275. #---------------------------------------------------------------------------
  2276.  
  2277. # Start user added include file section
  2278. # End user added include file section
  2279.  
  2280.  
  2281. Class CppEnumItem : {CppObject} {
  2282.     constructor
  2283.     method destructor
  2284.     method generate
  2285.     method enum
  2286.     attribute item
  2287.     attribute value
  2288.     attribute _enum
  2289. }
  2290.  
  2291. constructor CppEnumItem {class this enum} {
  2292.     set this [CppObject::constructor $class $this]
  2293.     $this _enum $enum
  2294.     [$enum _itemSet] append $this
  2295.     # Start constructor user section
  2296.     # End constructor user section
  2297.     return $this
  2298. }
  2299.  
  2300. method CppEnumItem::destructor {this} {
  2301.     # Start destructor user section
  2302.     # End destructor user section
  2303.     $this CppObject::destructor
  2304. }
  2305.  
  2306. method CppEnumItem::generate {this section} {
  2307.     set cppEnum [$this enum]
  2308.     set idx [ [$cppEnum itemSet] search -exact $this ]
  2309.     if { $idx == -1 } {
  2310.         m4_fatal $F_INTINCON "CppEnumItem::generate"
  2311.         exit
  2312.     }
  2313.     if { $idx != 0 } {
  2314.         set comma ",\n"
  2315.     } else {
  2316.         set comma ""
  2317.     }
  2318.     if { [ string length [$this value] ] > 0 } {
  2319.         $section append "${comma}[$this item] = [$this value]"
  2320.     } else {
  2321.         $section append "${comma}[$this item]"
  2322.     }
  2323. }
  2324.  
  2325. # Do not delete this line -- regeneration end marker
  2326.  
  2327. method CppEnumItem::enum {this args} {
  2328.     if {$args == ""} {
  2329.         return [$this _enum]
  2330.     }
  2331.     set ref [$this _enum]
  2332.     if {$ref != ""} {
  2333.         [$ref _itemSet] removeValue $this
  2334.     }
  2335.     set obj [lindex $args 0]
  2336.     if {$obj != ""} {
  2337.         [$obj _itemSet] append $this
  2338.     }
  2339.     $this _enum $obj
  2340. }
  2341.  
  2342. #---------------------------------------------------------------------------
  2343. #      File:           @(#)cppuseratt.tcl    /main/titanic/6
  2344. #---------------------------------------------------------------------------
  2345.  
  2346. # Start user added include file section
  2347. # End user added include file section
  2348.  
  2349.  
  2350. Class CppUserAttrib : {CppAttribute} {
  2351.     constructor
  2352.     method destructor
  2353.     method getCategory
  2354. }
  2355.  
  2356. constructor CppUserAttrib {class this cl access type} {
  2357.     set this [CppAttribute::constructor $class $this $cl $access $type]
  2358.     # Start constructor user section
  2359.     # End constructor user section
  2360.     return $this
  2361. }
  2362.  
  2363. method CppUserAttrib::destructor {this} {
  2364.     # Start destructor user section
  2365.     # End destructor user section
  2366.     $this CppAttribute::destructor
  2367. }
  2368.  
  2369. method CppUserAttrib::getCategory {this fileT} {
  2370.     if {$fileT == "hdr"} {
  2371.         set access [string tolower [$this access]]
  2372.         return "hdr-user-defined-$access-data"
  2373.     } else {
  2374.         return "cpp-static-init"
  2375.     }
  2376. }
  2377.  
  2378. # Do not delete this line -- regeneration end marker
  2379.  
  2380. #---------------------------------------------------------------------------
  2381. #      File:           @(#)cppderived.tcl    /main/titanic/3
  2382. #---------------------------------------------------------------------------
  2383.  
  2384. # Start user added include file section
  2385. # End user added include file section
  2386.  
  2387.  
  2388. Class CppDerivedAttrib : {CppAttribute} {
  2389.     constructor
  2390.     method destructor
  2391.     method getCategory
  2392. }
  2393.  
  2394. constructor CppDerivedAttrib {class this cl access type} {
  2395.     set this [CppAttribute::constructor $class $this $cl $access $type]
  2396.     # Start constructor user section
  2397.     # End constructor user section
  2398.     return $this
  2399. }
  2400.  
  2401. method CppDerivedAttrib::destructor {this} {
  2402.     # Start destructor user section
  2403.     # End destructor user section
  2404.     $this CppAttribute::destructor
  2405. }
  2406.  
  2407. method CppDerivedAttrib::getCategory {this fileT} {
  2408.     return "${fileT}-user-defined-private-data"
  2409. }
  2410.  
  2411. # Do not delete this line -- regeneration end marker
  2412.  
  2413. #---------------------------------------------------------------------------
  2414. #      File:           @(#)cppclass.tcl    /main/titanic/9
  2415. #---------------------------------------------------------------------------
  2416.  
  2417. # Start user added include file section
  2418. # End user added include file section
  2419.  
  2420.  
  2421. Class CppClass : {CppDefinition} {
  2422.     constructor
  2423.     method destructor
  2424.     method addFriendClass
  2425.     method generate
  2426.     method friendSet
  2427.     method addFriend
  2428.     method removeFriend
  2429.     method genSet
  2430.     method addGen
  2431.     method removeGen
  2432.     method featureSet
  2433.     method addFeature
  2434.     method removeFeature
  2435.     attribute _friendSet
  2436.     attribute _genSet
  2437.     attribute _featureSet
  2438. }
  2439.  
  2440. constructor CppClass {class this OOPLClass model} {
  2441.     set this [CppDefinition::constructor $class $this $OOPLClass $model]
  2442.     $this _friendSet [List new]
  2443.     $this _genSet [List new]
  2444.     $this _featureSet [List new]
  2445.     # Start constructor user section
  2446.     $this name [$OOPLClass getName]
  2447.     # End constructor user section
  2448.     return $this
  2449. }
  2450.  
  2451. method CppClass::destructor {this} {
  2452.     # Start destructor user section
  2453.     # End destructor user section
  2454.     $this CppDefinition::destructor
  2455. }
  2456.  
  2457. method CppClass::addFriendClass {this friend} {
  2458.     [$this friendSet] foreach fr {
  2459.         if {$friend == [$fr cl]} {
  2460.             return $fr
  2461.         }
  2462.     }
  2463.     set fr [CppFriend new $friend]
  2464.     $this addFriend $fr
  2465.     return $fr
  2466. }
  2467.  
  2468. method CppClass::generate {this sections} {
  2469.  
  2470.     if [$this isSynthetic] {
  2471.         return
  2472.     }
  2473.  
  2474.     set hdrHdrSect [ $sections getSection "hdr-hdr" ]
  2475.     set hdrCppSect [ $sections getSection "cpp-hdr" ]
  2476.     set includeHdrSect [ $sections getSection "hdr-incl" ]
  2477.     set includeCppSect [ $sections getSection "cpp-incl" ]
  2478.     set classHeadSect [ $sections getSection "hdr-class-head" ]
  2479.     set classTailSect [ $sections getSection "hdr-class-tail" ]
  2480.     set trailSect [ $sections getSection "hdr-trailor" ]
  2481.     set obsoleteHdrSect [ $sections getSection "hdr-impl" ]
  2482.     set obsoleteCppSect [ $sections getSection "cpp-impl" ]
  2483.     
  2484.     $this addHeader "hdr" $hdrHdrSect
  2485.     $this addHeader "cpp" $hdrCppSect
  2486.     $this addInclude $this "cpp"
  2487.  
  2488.     $this addProtectorStart $hdrHdrSect
  2489.  
  2490.     $this formatComment $classHeadSect
  2491.     $classHeadSect append "class [$this getName]"
  2492.     set first 1
  2493.     [$this genSet] foreach gen {
  2494.         if {$first} {
  2495.             set first 0
  2496.             $classHeadSect append ": "
  2497.         } else {
  2498.             $classHeadSect append ", "
  2499.         }
  2500.         $gen generate $classHeadSect
  2501.     }
  2502.     $classHeadSect append " {\n"
  2503.  
  2504.     $classHeadSect indent +
  2505.     [$this friendSet] foreach friend {
  2506.         $friend generate $classHeadSect
  2507.     }
  2508.     $classHeadSect indent -
  2509.  
  2510.     [$this featureSet] foreach feature {
  2511.         $feature generate $sections
  2512.     }
  2513.  
  2514.     if {[[$this getObsoleteCode "hdr"] contents] != ""} {
  2515.         m4_warning $W_GENOCODE ${CppConstants::obsoleteCode} [$this hdrFileName]
  2516.         $obsoleteHdrSect append "#ifdef "
  2517.         $obsoleteHdrSect append ${CppConstants::obsoleteCode}
  2518.         $obsoleteHdrSect append "\n\n"
  2519.         $obsoleteHdrSect appendSect [$this getObsoleteCode "hdr"]
  2520.         $obsoleteHdrSect append "#endif // "
  2521.         $obsoleteHdrSect append ${CppConstants::obsoleteCode}
  2522.         $obsoleteHdrSect append "\n"
  2523.     }
  2524.     if {[[$this getObsoleteCode "cpp"] contents] != ""} {
  2525.         m4_warning $W_GENOCODE ${CppConstants::obsoleteCode} [$this cppFileName]
  2526.         $obsoleteCppSect append "#ifdef "
  2527.         $obsoleteCppSect append ${CppConstants::obsoleteCode}
  2528.         $obsoleteCppSect append "\n\n"
  2529.         $obsoleteCppSect appendSect [$this getObsoleteCode "cpp"]
  2530.         $obsoleteCppSect append "#endif // "
  2531.         $obsoleteCppSect append ${CppConstants::obsoleteCode}
  2532.         $obsoleteCppSect append "\n"
  2533.     }
  2534.  
  2535.     $classTailSect append "};\n"
  2536.     $this addProtectorEnd $trailSect
  2537.  
  2538.     $this generateInc $hdrHdrSect $hdrCppSect
  2539.     $this generateFwd $hdrHdrSect $hdrCppSect
  2540.  
  2541.     $hdrCppSect append "// "
  2542.     $hdrCppSect append ${CppConstants::startInclude}
  2543.     $hdrCppSect append "\n"
  2544.     $hdrCppSect appendSect [$this getIncludeSect "cpp"]
  2545.     $hdrCppSect append "// "
  2546.     $hdrCppSect append ${CppConstants::endInclude}
  2547.     $hdrCppSect append "\n\n"
  2548.  
  2549.     $hdrHdrSect append "// "
  2550.     $hdrHdrSect append ${CppConstants::startInclude}
  2551.     $hdrHdrSect append "\n"
  2552.     $hdrHdrSect appendSect [$this getIncludeSect "hdr"]
  2553.     $hdrHdrSect append "// "
  2554.     $hdrHdrSect append ${CppConstants::endInclude}
  2555.     $hdrHdrSect append "\n"
  2556. }
  2557.  
  2558. # Do not delete this line -- regeneration end marker
  2559.  
  2560. method CppClass::friendSet {this} {
  2561.     return [$this _friendSet]
  2562. }
  2563.  
  2564. method CppClass::addFriend {this newFriend} {
  2565.     [$this _friendSet] append $newFriend
  2566.     $newFriend _friendOf $this
  2567. }
  2568.  
  2569. method CppClass::removeFriend {this oldFriend} {
  2570.     $oldFriend _friendOf ""
  2571.     [$this _friendSet] removeValue $oldFriend
  2572. }
  2573.  
  2574. method CppClass::genSet {this} {
  2575.     return [$this _genSet]
  2576. }
  2577.  
  2578. method CppClass::addGen {this newGen} {
  2579.     [$this _genSet] append $newGen
  2580.     $newGen _subcl $this
  2581. }
  2582.  
  2583. method CppClass::removeGen {this oldGen} {
  2584.     $oldGen _subcl ""
  2585.     [$this _genSet] removeValue $oldGen
  2586. }
  2587.  
  2588. method CppClass::featureSet {this} {
  2589.     return [$this _featureSet]
  2590. }
  2591.  
  2592. method CppClass::addFeature {this newFeature} {
  2593.     [$this _featureSet] append $newFeature
  2594.     $newFeature _cl $this
  2595. }
  2596.  
  2597. method CppClass::removeFeature {this oldFeature} {
  2598.     $oldFeature _cl ""
  2599.     [$this _featureSet] removeValue $oldFeature
  2600. }
  2601.  
  2602.