home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / komix / DATA.Z / cpp_const.tcl < prev    next >
Text File  |  1996-06-05  |  9KB  |  368 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. # Copyright (c) 1994-1995 by Cadre Technologies 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 Cadre Technologies Inc.
  13. #
  14. #---------------------------------------------------------------------------
  15. #
  16. #    File        : @(#)cpp_const.tcl    2.1
  17. #    Original date    : Tue Apr 19 10:43:02 MET DST 1994
  18. #    Description    : C++ generator constants
  19. #
  20. #---------------------------------------------------------------------------
  21. #
  22.  
  23. # Name of type column in database
  24. #
  25. global TYPE_ID_NM
  26. set TYPE_ID_NM class_type
  27.  
  28. #
  29. # Regeneration magic strings
  30. #
  31. global START_INCLUDE_MESSAGE
  32. set START_INCLUDE_MESSAGE "// Start user added include file section"
  33. global END_INCLUDE_MESSAGE
  34. set END_INCLUDE_MESSAGE "// End user added include file section"
  35. global START_CTOR_MESSAGE
  36. set START_CTOR_MESSAGE "// Start constructor user section"
  37. global END_CTOR_MESSAGE
  38. set END_CTOR_MESSAGE "// End constructor user section"
  39. global START_DTOR_MESSAGE
  40. set START_DTOR_MESSAGE "// Start destructor user section"
  41. global END_DTOR_MESSAGE
  42. set END_DTOR_MESSAGE "// End destructor user section"
  43.  
  44. # regeneration stops after this marker is found
  45. #  
  46. global REGEN_END
  47. set REGEN_END "// Do not delete this line -- regeneration end marker"
  48.  
  49. #
  50. # default for type modifiers
  51. #
  52. global default_type_modifier
  53. set default_type_modifier "Reference"
  54. global default_return_type_modifier
  55. set default_return_type_modifier "Value"
  56.  
  57. #
  58. # Configuration functions
  59. #
  60.  
  61. # Return the file name for a class name
  62. #
  63. proc class2file {name} {
  64.     return $name
  65. }
  66.  
  67. proc h_class2file {name {ext "hxx"}} {
  68.     return [class2file $name].$ext
  69. }
  70.  
  71. # Generate an #include statement for 'class' in 'sect'
  72. #
  73. proc gen_include {class sect {ext "hxx"}} {
  74.     set protector [protector_name $class $ext]
  75.     expand_text $sect {
  76.         #ifndef ~$protector
  77.         #include "~[class2file $class].~$ext"
  78.         #endif
  79.  
  80.     }
  81. }
  82.  
  83. proc gen_include_filename {filename sect} {
  84.     expand_text $sect {
  85.         #include <~$filename>
  86.  
  87.     }
  88. }
  89.  
  90. # Return the protector name for 'class'
  91. #
  92. proc protector_name {class {ext "hxx"}} {
  93.     return "[string toupper [class2file $class]]_[string toupper $ext]"
  94. }
  95.  
  96. # Configure a list of include files that was specified in the 'include_list'
  97. # property of a class.  This allows for customization of the 'include_list'
  98. # property that was generated by 'Reverse Engineer C++', which by default
  99. # stores the path as specified in the 'Reverse Engineer C++' dialog.
  100. #
  101. # This routine will be passed a TCL list of include files, and
  102. # must return an optionally modified version of this list.
  103. #
  104. proc config_include_list {list} {
  105.     return $list
  106. }
  107.  
  108. # The "pointer" name for 'class'
  109. #
  110. proc pointer_name {class} {
  111.     return "${class}Ptr"
  112. }
  113.  
  114. # The "reference" name for 'class'
  115. #
  116. proc reference_name {class} {
  117.     return "${class}Ref"
  118. }
  119.  
  120. # The set name for 'class'
  121. #
  122. proc set_name {class} {
  123.     return "${class}Set"
  124. }
  125.  
  126. # The set type name for 'class'
  127. #
  128. proc set_type_name {class} {
  129.     add_hdr_inc_name ${set::name}
  130.     if [regexp {.*_type$} [$class get_obj_type]] {
  131.         set name [string trimright [generate $class fwd Value]]
  132.     } else {
  133.         set name [$class getName]
  134.     }
  135.     if $has_templates {
  136.         return "${set::name}<$name>"
  137.     }
  138.     instantiate_set $name
  139.     return ${name}_${set::name}
  140. }
  141.  
  142. # Generate the set type definition for 'class' in 'sect'
  143. #
  144. proc gen_set_type_def {class sect} {
  145.     if $has_templates {
  146.         # nothing to generate: templates are supported
  147.         return
  148.     }
  149.     # simulate an instantiation of a template
  150.     set protector [string toupper "${class}_${set::name}"]
  151.     expand_text $sect {
  152.         #ifndef ~$protector
  153.         #define ~$protector
  154.         class ~$class;
  155.         declare(~${set::name},~$class);
  156.         #endif
  157.  
  158.     }
  159. }
  160.  
  161. # The ordered set name for 'class'
  162. #
  163. proc oset_name {class} {
  164.     return "${class}OSet"
  165. }
  166.  
  167. # The ordered set type name for 'class'
  168. #
  169. proc oset_type_name {class} {
  170.     add_hdr_inc_name ${oset::name}
  171.     if [regexp {.*_type$} [$class get_obj_type]] {
  172.         set name [string trimright [generate $class fwd Value]]
  173.     } else {
  174.         set name [$class getName]
  175.     }
  176.     if $has_templates {
  177.         return "${oset::name}<$name>"
  178.     }
  179.     instantiate_oset $name
  180.     return ${name}_${oset::name}
  181. }
  182.         
  183. # Generate the ordered set type definition for 'class' in 'sect'
  184. #
  185. proc gen_oset_type_def {class sect} {
  186.     if $has_templates {
  187.         # nothing to generate: templates are supported
  188.         return
  189.     }
  190.     # simulate an instantiation of a template
  191.     set protector [string toupper "${class}_${oset::name}"]
  192.     expand_text $sect {
  193.         #ifndef ~$protector
  194.         #define ~$protector
  195.         class ~$class;
  196.         declare(~${oset::name},~$class);
  197.         #endif
  198.  
  199.     }
  200. }
  201.  
  202. # The dict name for 'class'
  203. #
  204. proc dict_name {class} {
  205.     return "${class}Dict"
  206. }
  207.  
  208. # The dict type name for 'key' and 'value'
  209. #
  210. proc dict_type_name {key_type value_type} {
  211.     add_hdr_inc_name ${dict::name}
  212.     # key : value semantics: include
  213.     # value : pointer semantics: forward
  214.     set key [string trimright [generate $key_type inc Value]]
  215.     set value [string trimright [generate $value_type fwd Value]]
  216.     if $has_templates {
  217.         return "${dict::name}<$key, $value>"
  218.     }
  219.     instantiate_dict $key $value
  220.     return ${key}${value}_${dict::name}
  221. }
  222.  
  223. # Generate the dict type definition for 'class' in 'sect'
  224. #
  225. proc gen_dict_type_def {key value sect} {
  226.     if $has_templates {
  227.         # nothing to generate: templates are supported
  228.         return
  229.     }
  230.     # simulate an instantiation of a template
  231.     set protector [string toupper "${key}${value}_${dict::name}"]
  232.     expand_text $sect {
  233.         #ifndef ~$protector
  234.         #define ~$protector
  235.         class ~$value;
  236.         declare2(~${dict::name},~$key,~$value);
  237.         #endif
  238.  
  239.     }
  240. }
  241.  
  242. # The set dict name for 'class'
  243. #
  244. proc set_dict_name {class} {
  245.     return "${class}PSDict"
  246. }
  247.  
  248. # The set dict type name for 'key' and 'value'
  249. #
  250. proc set_dict_type_name {key_type value_type} {
  251.     # key : value semantics: include
  252.     # value : pointer semantics: forward
  253.     set key [string trimright [generate $key_type inc Value]]
  254.     set value [string trimright [generate $value_type fwd Value]]
  255.  
  256.     # the PSetDict instantiation requires the PtrSet
  257.     # to be instantiated
  258.     instantiate_set $value
  259.  
  260.     add_hdr_inc_name ${psdict::name}
  261.     if $has_templates {
  262.         return "${psdict::name}<$key, $value>"
  263.     }
  264.  
  265.     instantiate_set_dict $key $value
  266.     return ${key}${value}_${psdict::name}
  267. }
  268.  
  269. # Generate the set dict type definition for 'class' in 'sect'
  270. #
  271. proc gen_set_dict_type_def {key value sect} {
  272.     if $has_templates {
  273.         # nothing to generate: templates are supported
  274.         return
  275.     }
  276.     # simulate an instantiation of a template
  277.     set protector [string toupper "${key}${value}_${psdict::name}"]
  278.     expand_text $sect {
  279.         #ifndef ~$protector
  280.         #define ~$protector
  281.         class ~$value;
  282.         declare2(~${psdict::name},~$key,~$value);
  283.         #endif
  284.  
  285.     }
  286. }
  287.  
  288. # The ordered set dict name for 'class'
  289. #
  290. proc oset_dict_name {class} {
  291.     return "${class}OPSDict"
  292. }
  293.  
  294. # The ordered set dict type name for 'key' and 'value'
  295. #
  296. proc oset_dict_type_name {key_type value_type} {
  297.     # key : value semantics: include
  298.     # value : pointer semantics: forward
  299.     set key [string trimright [generate $key_type inc Value]]
  300.     set value [string trimright [generate $value_type fwd Value]]
  301.  
  302.     # the OPSetDict instantiation requires the OPtrSet
  303.     # to be instantiated
  304.     instantiate_oset $value
  305.  
  306.     add_hdr_inc_name ${opsdict::name}
  307.     if $has_templates {
  308.         return "${opsdict::name}<$key, $value>"
  309.     }
  310.  
  311.     instantiate_oset_dict $key $value
  312.     return ${key}${value}_${opsdict::name}
  313. }
  314.  
  315. #Generate the ordered set dict type definition for 'class' in 'sect'
  316. #
  317. proc gen_oset_dict_type_def {key value sect} {
  318.     if $has_templates {
  319.         # nothing to generate: templates are supported
  320.         return
  321.     }
  322.     # simulate an instantiation of a template
  323.     set protector [string toupper "${key}${value}_${opsdict::name}"]
  324.     expand_text $sect {
  325.         #ifndef ~$protector
  326.         #define ~$protector
  327.         class ~$value;
  328.         declare2(~${opsdict::name},~$key,~$value);
  329.         #endif
  330.  
  331.     }
  332. }
  333.  
  334. # The funcmap name for 'func'
  335. #
  336. proc funcmap_name {func} {
  337.     return "${func}FM"
  338. }
  339.  
  340. # The funcmap type name for 'func'
  341. #
  342. proc funcmap_type_name {func} {
  343.     add_hdr_inc_name NmFuncMap
  344.     if $has_templates {
  345.         return "NmFuncMap< $func >"
  346.     }
  347.     instantiate_funcmap $func
  348.     return ${func}_NmFuncMap
  349. }
  350.  
  351. # Generate the funcmap type definition for 'func' in 'sect'
  352. #
  353. proc gen_funcmap_type_def {func sect} {
  354.     if $has_templates {
  355.         # nothing to generate: templates are supported
  356.         return
  357.     }
  358.     # simulate an instantiation of a template
  359.     set protector [string toupper "${func}_NmFuncMap"]
  360.     expand_text $sect {
  361.         #ifndef ~$protector
  362.         #define ~$protector
  363.         declare(NmFuncMap,~$func);
  364.         #endif
  365.  
  366.     }
  367. }
  368.