tecscde 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rubocop.yml +125 -0
  4. data/.rubocop_todo.yml +188 -0
  5. data/CHANGELOG.md +3 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE +46 -0
  8. data/LICENSE.ja +32 -0
  9. data/README.ja.md +200 -0
  10. data/README.md +35 -0
  11. data/Rakefile +27 -0
  12. data/bin/tecscde +64 -0
  13. data/glade/tecscde-cell-property.glade +205 -0
  14. data/glade/tecscde-celltype-property.glade +172 -0
  15. data/glade/tecscde-celltype.glade +414 -0
  16. data/glade/tecscde-export.glade +161 -0
  17. data/glade/test-cell-plugin.rb +51 -0
  18. data/glade/test-cell-property.rb +35 -0
  19. data/glade/test-export.rb +35 -0
  20. data/glade/test-palette.rb +26 -0
  21. data/lib/tcflow.rb +148 -0
  22. data/lib/tecscde.rb +65 -0
  23. data/lib/tecscde/NewCell.png +0 -0
  24. data/lib/tecscde/SelectArrow.png +0 -0
  25. data/lib/tecscde/attr_tree_view.rb +253 -0
  26. data/lib/tecscde/cell_plugin_dialog.glade +294 -0
  27. data/lib/tecscde/cell_plugin_dialog.rb +89 -0
  28. data/lib/tecscde/celltype_tree_view.rb +105 -0
  29. data/lib/tecscde/change_set_control.rb +35 -0
  30. data/lib/tecscde/change_set_control/change_set.rb +32 -0
  31. data/lib/tecscde/change_set_control/change_set_manager.rb +62 -0
  32. data/lib/tecscde/command.rb +35 -0
  33. data/lib/tecscde/control.rb +491 -0
  34. data/lib/tecscde/highlighted_objects.rb +180 -0
  35. data/lib/tecscde/logger.rb +74 -0
  36. data/lib/tecscde/main_view_and_model.rb +80 -0
  37. data/lib/tecscde/palette.glade +553 -0
  38. data/lib/tecscde/palette.rb +174 -0
  39. data/lib/tecscde/preferences.glade +117 -0
  40. data/lib/tecscde/preferences.rb +44 -0
  41. data/lib/tecscde/tecs_model.rb +1137 -0
  42. data/lib/tecscde/tecs_model/hbar.rb +68 -0
  43. data/lib/tecscde/tecs_model/tm_c_port.rb +122 -0
  44. data/lib/tecscde/tecs_model/tm_c_port_array.rb +98 -0
  45. data/lib/tecscde/tecs_model/tm_cell.rb +496 -0
  46. data/lib/tecscde/tecs_model/tm_e_port.rb +126 -0
  47. data/lib/tecscde/tecs_model/tm_e_port_array.rb +78 -0
  48. data/lib/tecscde/tecs_model/tm_join.rb +293 -0
  49. data/lib/tecscde/tecs_model/tm_join_bar.rb +146 -0
  50. data/lib/tecscde/tecs_model/tm_port.rb +238 -0
  51. data/lib/tecscde/tecs_model/tm_port_array.rb +246 -0
  52. data/lib/tecscde/tecs_model/tm_region.rb +107 -0
  53. data/lib/tecscde/tecs_model/tm_uneditable.rb +68 -0
  54. data/lib/tecscde/tecs_model/vbar.rb +68 -0
  55. data/lib/tecscde/templates/_cell_info.cde.erb +15 -0
  56. data/lib/tecscde/templates/_join_info.cde.erb +28 -0
  57. data/lib/tecscde/templates/main.cde.erb +49 -0
  58. data/lib/tecscde/tm_object.rb +91 -0
  59. data/lib/tecscde/version.rb +4 -0
  60. data/lib/tecscde/view.rb +58 -0
  61. data/lib/tecscde/view/cairo_matrix.rb +90 -0
  62. data/lib/tecscde/view/canvas.rb +59 -0
  63. data/lib/tecscde/view/constants.rb +114 -0
  64. data/lib/tecscde/view/main_view.rb +1245 -0
  65. data/lib/tecsflow.rb +475 -0
  66. data/lib/tecsflow/C_parser.tab.rb +2471 -0
  67. data/lib/tecsflow/C_parser.y.rb +1087 -0
  68. data/lib/tecsflow/classes.rb +421 -0
  69. data/lib/tecsgen.rb +581 -0
  70. data/lib/tecsgen/core/C_parser.tab.rb +2477 -0
  71. data/lib/tecsgen/core/C_parser.y +1032 -0
  72. data/lib/tecsgen/core/bnf-deb.tab.rb +5193 -0
  73. data/lib/tecsgen/core/bnf.tab.rb +5193 -0
  74. data/lib/tecsgen/core/bnf.y +2211 -0
  75. data/lib/tecsgen/core/componentobj.rb +7901 -0
  76. data/lib/tecsgen/core/ctypes.rb +226 -0
  77. data/lib/tecsgen/core/expression.rb +1031 -0
  78. data/lib/tecsgen/core/gen_xml.rb +374 -0
  79. data/lib/tecsgen/core/generate.rb +5206 -0
  80. data/lib/tecsgen/core/location.rb +116 -0
  81. data/lib/tecsgen/core/messages.rb +101 -0
  82. data/lib/tecsgen/core/optimize.rb +456 -0
  83. data/lib/tecsgen/core/plugin.rb +332 -0
  84. data/lib/tecsgen/core/pluginModule.rb +165 -0
  85. data/lib/tecsgen/core/syntaxobj.rb +1234 -0
  86. data/lib/tecsgen/core/tecs_lang.rb +306 -0
  87. data/lib/tecsgen/core/tecsgen.rb +453 -0
  88. data/lib/tecsgen/core/tecsinfo.rb +860 -0
  89. data/lib/tecsgen/core/tool_info.rb +258 -0
  90. data/lib/tecsgen/core/types.rb +1632 -0
  91. data/lib/tecsgen/core/unjoin_plugin.rb +218 -0
  92. data/lib/tecsgen/core/value.rb +650 -0
  93. data/lib/tecsgen/messages/messages_console_en_US.rb +1171 -0
  94. data/lib/tecsgen/messages/messages_console_ja_JP.rb +1171 -0
  95. data/lib/tecsgen/messages/messages_file_en_US.rb +334 -0
  96. data/lib/tecsgen/messages/messages_file_ja_JP.rb +163 -0
  97. data/lib/tecsgen/plugin/ATK1AlarmPlugin.rb +196 -0
  98. data/lib/tecsgen/plugin/ATK1DelayTaskPlugin.rb +106 -0
  99. data/lib/tecsgen/plugin/ATK1EventPlugin.rb +147 -0
  100. data/lib/tecsgen/plugin/ATK1ISRPlugin.rb +174 -0
  101. data/lib/tecsgen/plugin/ATK1KernelPlugin.rb +287 -0
  102. data/lib/tecsgen/plugin/ATK1ResourcePlugin.rb +124 -0
  103. data/lib/tecsgen/plugin/ATK1TaskPlugin.rb +220 -0
  104. data/lib/tecsgen/plugin/C2TECSBridgePlugin.rb +210 -0
  105. data/lib/tecsgen/plugin/CellPlugin.rb +61 -0
  106. data/lib/tecsgen/plugin/CelltypePlugin.rb +72 -0
  107. data/lib/tecsgen/plugin/CompositePlugin.rb +66 -0
  108. data/lib/tecsgen/plugin/DomainPlugin.rb +89 -0
  109. data/lib/tecsgen/plugin/HRP2AlarmHandlerPlugin.rb +76 -0
  110. data/lib/tecsgen/plugin/HRP2Cache.rb +1 -0
  111. data/lib/tecsgen/plugin/HRP2CyclicHandlerPlugin.rb +75 -0
  112. data/lib/tecsgen/plugin/HRP2DataqueuePlugin.rb +68 -0
  113. data/lib/tecsgen/plugin/HRP2EventflagPlugin.rb +68 -0
  114. data/lib/tecsgen/plugin/HRP2FixedSizeMemoryPoolPlugin.rb +68 -0
  115. data/lib/tecsgen/plugin/HRP2HandlerPlugin.rb +117 -0
  116. data/lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb +372 -0
  117. data/lib/tecsgen/plugin/HRP2ObjectPlugin.rb +94 -0
  118. data/lib/tecsgen/plugin/HRP2Plugin.rb +140 -0
  119. data/lib/tecsgen/plugin/HRP2PostHook.rb +111 -0
  120. data/lib/tecsgen/plugin/HRP2PriorityDataqueuePlugin.rb +66 -0
  121. data/lib/tecsgen/plugin/HRP2RPCPlugin.rb +319 -0
  122. data/lib/tecsgen/plugin/HRP2SVCPlugin.rb +473 -0
  123. data/lib/tecsgen/plugin/HRP2SemaphorePlugin.rb +67 -0
  124. data/lib/tecsgen/plugin/HRP2TaskPlugin.rb +200 -0
  125. data/lib/tecsgen/plugin/HRPHandlerPlugin.rb +125 -0
  126. data/lib/tecsgen/plugin/HRPKernelObjectManager.rb +72 -0
  127. data/lib/tecsgen/plugin/HRPKernelObjectPlugin.rb +333 -0
  128. data/lib/tecsgen/plugin/HRPObjectPlugin.rb +93 -0
  129. data/lib/tecsgen/plugin/HRPPlugin.rb +356 -0
  130. data/lib/tecsgen/plugin/HRPRPCPlugin.rb +407 -0
  131. data/lib/tecsgen/plugin/HRPSVCPlugin.rb +859 -0
  132. data/lib/tecsgen/plugin/HRPTaskPlugin.rb +107 -0
  133. data/lib/tecsgen/plugin/Mruby2CBridgePlugin.rb +86 -0
  134. data/lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb +264 -0
  135. data/lib/tecsgen/plugin/MrubyBridgeCelltypePlugin.rb +293 -0
  136. data/lib/tecsgen/plugin/MrubyBridgeCompositePlugin.rb +49 -0
  137. data/lib/tecsgen/plugin/MrubyBridgePlugin.rb +67 -0
  138. data/lib/tecsgen/plugin/MrubyBridgeSignaturePlugin.rb +1307 -0
  139. data/lib/tecsgen/plugin/MrubyInfoBridgePlugin.rb +14 -0
  140. data/lib/tecsgen/plugin/MrubyInfoBridgeSignaturePlugin.rb +994 -0
  141. data/lib/tecsgen/plugin/MultiPlugin.rb +57 -0
  142. data/lib/tecsgen/plugin/NotifierPlugin.rb +1217 -0
  143. data/lib/tecsgen/plugin/OpaqueMarshalerPlugin.rb +81 -0
  144. data/lib/tecsgen/plugin/OpaqueRPCPlugin.rb +323 -0
  145. data/lib/tecsgen/plugin/RPCPlugin.rb +266 -0
  146. data/lib/tecsgen/plugin/RepeatCellPlugin.rb +166 -0
  147. data/lib/tecsgen/plugin/RepeatJoinPlugin.rb +130 -0
  148. data/lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb +357 -0
  149. data/lib/tecsgen/plugin/SharedRPCPlugin.rb +329 -0
  150. data/lib/tecsgen/plugin/SignaturePlugin.rb +77 -0
  151. data/lib/tecsgen/plugin/TECS2CBridgePlugin.rb +178 -0
  152. data/lib/tecsgen/plugin/TECSInfoPlugin.rb +280 -0
  153. data/lib/tecsgen/plugin/ThroughPlugin.rb +333 -0
  154. data/lib/tecsgen/plugin/TracePlugin.rb +484 -0
  155. data/lib/tecsgen/plugin/lib/GenHRP2Marshaler.rb +761 -0
  156. data/lib/tecsgen/plugin/lib/GenOpaqueMarshaler.rb +1107 -0
  157. data/lib/tecsgen/plugin/lib/GenParamCopy.rb +365 -0
  158. data/lib/tecsgen/plugin/lib/GenTransparentMarshaler.rb +683 -0
  159. data/lib/tecsgen/plugin/lib/MrubyBridgeCelltypePluginModule.rb +283 -0
  160. data/lib/tecsgen/plugin/lib/MrubyBridgeSignaturePluginModule.rb +277 -0
  161. data/lib/tecsgen/version.rb +6 -0
  162. data/samples/FigureSamples/active/active.cde +104 -0
  163. data/samples/FigureSamples/active/active.cdl +20 -0
  164. data/samples/FigureSamples/active/active.pdf +0 -0
  165. data/samples/FigureSamples/active/active.png +0 -0
  166. data/samples/FigureSamples/active/gen/tmp_C_src.c +36 -0
  167. data/samples/FigureSamples/active/gen/tmp_cygwin_tecs.h +1908 -0
  168. data/samples/FigureSamples/active/gen/tmp_plugin_post_code.cdl +0 -0
  169. data/samples/FigureSamples/allocator/allocator-internal.png +0 -0
  170. data/samples/FigureSamples/allocator/allocator.cde +171 -0
  171. data/samples/FigureSamples/allocator/allocator.cdl +58 -0
  172. data/samples/FigureSamples/allocator/allocator.png +0 -0
  173. data/samples/FigureSamples/basic/Makefile +87 -0
  174. data/samples/FigureSamples/basic/SimpleSample-trace.cdl +50 -0
  175. data/samples/FigureSamples/basic/SimpleSample.cde +91 -0
  176. data/samples/FigureSamples/basic/SimpleSample.cdl +47 -0
  177. data/samples/FigureSamples/basic/basic.cde +93 -0
  178. data/samples/FigureSamples/basic/basic.cdl +46 -0
  179. data/samples/FigureSamples/basic/basic.png +0 -0
  180. data/samples/FigureSamples/callback/callback.cde +130 -0
  181. data/samples/FigureSamples/callback/callback.cdl +29 -0
  182. data/samples/FigureSamples/callback/callback.png +0 -0
  183. data/samples/FigureSamples/carray/carray.cde +144 -0
  184. data/samples/FigureSamples/carray/carray.cdl +38 -0
  185. data/samples/FigureSamples/carray/carray.png +0 -0
  186. data/samples/FigureSamples/cearray/cearray.cde +314 -0
  187. data/samples/FigureSamples/cearray/cearray.cdl +60 -0
  188. data/samples/FigureSamples/cearray/cearray.png +0 -0
  189. data/samples/FigureSamples/composite/composite-internal.png +0 -0
  190. data/samples/FigureSamples/composite/composite.cde +216 -0
  191. data/samples/FigureSamples/composite/composite.cdl +95 -0
  192. data/samples/FigureSamples/composite/composite.png +0 -0
  193. data/samples/FigureSamples/earray/earray.cde +142 -0
  194. data/samples/FigureSamples/earray/earray.cdl +38 -0
  195. data/samples/FigureSamples/earray/earray.png +0 -0
  196. data/samples/FigureSamples/join/Makefile +87 -0
  197. data/samples/FigureSamples/join/join.cde +132 -0
  198. data/samples/FigureSamples/join/join.cdl +40 -0
  199. data/samples/FigureSamples/join/join.png +0 -0
  200. data/samples/FigureSamples/relay/Makefile +99 -0
  201. data/samples/FigureSamples/relay/relay-internal.png +0 -0
  202. data/samples/FigureSamples/relay/relay.cde +284 -0
  203. data/samples/FigureSamples/relay/relay.cdl +52 -0
  204. data/samples/FigureSamples/relay/relay.png +0 -0
  205. data/samples/FigureSamples/rpc/Makefile +123 -0
  206. data/samples/FigureSamples/rpc/rpc-expand.png +0 -0
  207. data/samples/FigureSamples/rpc/rpc.cde +245 -0
  208. data/samples/FigureSamples/rpc/rpc.png +0 -0
  209. data/samples/FigureSamples/rpc/rpc_sample.cdl +53 -0
  210. data/samples/SimpleSample/Makefile +25 -0
  211. data/samples/SimpleSample/SimpleSample/Makefile +86 -0
  212. data/samples/SimpleSample/SimpleSample/Makefile-trace +91 -0
  213. data/samples/SimpleSample/SimpleSample/README.txt +106 -0
  214. data/samples/SimpleSample/SimpleSample/SimpleSample-trace.cdl +50 -0
  215. data/samples/SimpleSample/SimpleSample/SimpleSample.cdl +45 -0
  216. data/samples/SimpleSample/SimpleSample/src/tSample.c +77 -0
  217. data/samples/SimpleSample/SimpleSample/src/tSimple.c +48 -0
  218. data/samples/SimpleSample/SimpleSample/src/tecs-types.h +27 -0
  219. data/samples/SimpleSample/SimpleSampleOpaqueRPC/Makefile +51 -0
  220. data/samples/SimpleSample/SimpleSampleOpaqueRPC/Makefile-trace +91 -0
  221. data/samples/SimpleSample/SimpleSampleOpaqueRPC/README.txt +106 -0
  222. data/samples/SimpleSample/SimpleSampleOpaqueRPC/SimpleSample-trace.cdl +80 -0
  223. data/samples/SimpleSample/SimpleSampleOpaqueRPC/SimpleSample.cdl +77 -0
  224. data/samples/SimpleSample/SimpleSampleOpaqueRPC/rSample/Makefile +112 -0
  225. data/samples/SimpleSample/SimpleSampleOpaqueRPC/rSimple/Makefile +109 -0
  226. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tSample.c +80 -0
  227. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tSimple.c +47 -0
  228. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tTaskMain.c +66 -0
  229. data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tecs-types.h +27 -0
  230. data/samples/SimpleSample/SimpleSampleTransparentRPC/Makefile +125 -0
  231. data/samples/SimpleSample/SimpleSampleTransparentRPC/Makefile-trace +130 -0
  232. data/samples/SimpleSample/SimpleSampleTransparentRPC/SimpleSample-trace.cdl +54 -0
  233. data/samples/SimpleSample/SimpleSampleTransparentRPC/SimpleSample.cdl +53 -0
  234. data/samples/SimpleSample/SimpleSampleTransparentRPC/src/tSample.c +80 -0
  235. data/samples/SimpleSample/SimpleSampleTransparentRPC/src/tSimple.c +54 -0
  236. data/tecscde.gemspec +41 -0
  237. metadata +353 -0
@@ -0,0 +1,860 @@
1
+ #
2
+ # TECS Generator
3
+ # Generator for TOPPERS Embedded Component System
4
+ #
5
+ # Copyright (C) 2017-2018 by TOPPERS Project
6
+ #--
7
+ # 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
8
+ # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
9
+ # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
10
+ # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
11
+ # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
12
+ # スコード中に含まれていること.
13
+ # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
14
+ # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
15
+ # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
16
+ # の無保証規定を掲載すること.
17
+ # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
18
+ # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
19
+ # と.
20
+ # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
21
+ # 作権表示,この利用条件および下記の無保証規定を掲載すること.
22
+ # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
23
+ # 報告すること.
24
+ # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
25
+ # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
26
+ # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
27
+ # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
28
+ # 免責すること.
29
+ #
30
+ # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
31
+ # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
32
+ # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
33
+ # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
34
+ # の責任を負わない.
35
+ #
36
+ # $Id: tecsinfo.rb 2850 2018-04-01 12:38:45Z okuma-top $
37
+ #++
38
+
39
+ # TECS 情報セルの生成
40
+ module TECSInfo
41
+ # region は Link root のこと
42
+ def self.print_info(f, region)
43
+ # p "region: "+ region.get_name.to_s
44
+ nest = region.gen_region_str_pre f
45
+ indent0 = " " * nest
46
+ indent = " " * (nest + 1)
47
+ f.print <<EOT
48
+ #{indent0}region rTECSInfo {
49
+ EOT
50
+ Type.reset_print_info
51
+
52
+ # mikan 全部生成するのではなく、region 下のセルのセルタイプと、そこから参照されるシグニチャ、セルタイプに限定して出力すべき
53
+ # しかし、意味解析後に出力するため、これは容易ではない.最適化とコード生成は、リンクルートごとに行われる.
54
+ Namespace.print_info f, indent
55
+ region.get_link_root.print_info f, indent
56
+
57
+ f.print "\n#{indent}/*** TYPE information cell ***/\n"
58
+ Type.print_info_post f, indent
59
+
60
+ f.print "\n#{indent}/*** TECS information cell ***/\n"
61
+ f.print <<EOT
62
+ #{indent}cell nTECSInfo::tTECSInfoSub TECSInfoSub {
63
+ #{indent} cNamespaceInfo = _RootNamespaceInfo.eNamespaceInfo;
64
+ #{indent} cRegionInfo = _LinkRootRegionInfo.eRegionInfo;
65
+ #{indent}} /* TECSInfoSub */;
66
+ #{indent0}}; /* rTECSInfo */
67
+ EOT
68
+ region.gen_region_str_post f
69
+ end
70
+ end
71
+
72
+ class Namespace
73
+ # RootRegion と LinkRegion は同じ Region クラスのオブジェクトである
74
+ # 子ネームスペースは Namespace クラスの、子リージョンは Region クラスのオブジェクトである
75
+ # これは、意味解析段階で呼び出されるため、リンクユニットごとに出しわけることができない
76
+ # 出しわけるには、2パスにする必要がある
77
+ def print_info_ns_sub(f, indent)
78
+ if @name == "::"
79
+ name = "_Root"
80
+ else
81
+ name = @global_name
82
+ end
83
+ f.print "\n#{indent}/*** #{get_namespace_path} namespace information cell ***/\n"
84
+ f.print <<EOT
85
+ #{indent}cell nTECSInfo::tNamespaceInfo #{name}NamespaceInfo{
86
+ #{indent} name = "#{@name}";
87
+ EOT
88
+ if @signature_list.length > 0
89
+ f.print "\n#{indent} /* SIGNATURE info */\n"
90
+ end
91
+ @signature_list.each{|sig|
92
+ f.print <<EOT
93
+ #{indent} cSignatureInfo[] = #{sig.get_global_name}SignatureInfo.eSignatureInfo;
94
+ EOT
95
+ }
96
+ if @celltype_list.length > 0
97
+ f.print "\n#{indent} /* CELLTYPE info */\n"
98
+ end
99
+ @celltype_list.each{|ct|
100
+ if ct.get_cell_list.length > 0
101
+ f.print <<EOT
102
+ #{indent} cCelltypeInfo[] = #{ct.get_global_name}CelltypeInfo.eCelltypeInfo;
103
+ EOT
104
+ end
105
+ }
106
+ if @namespace_list.length > 0
107
+ f.print "\n#{indent} /* NAMESPACE info */\n"
108
+ end
109
+ @namespace_list.each{|ns|
110
+ if ns.instance_of? Namespace
111
+ f.print <<EOT
112
+ #{indent} cNamespaceInfo[] = #{ns.get_global_name}NamespaceInfo.eNamespaceInfo;
113
+ EOT
114
+ end
115
+ }
116
+ f.print <<EOT
117
+ #{indent}}; /* cell nTECSInfo::tNamespaceInfo #{name}NamespaceInfo */
118
+ EOT
119
+ end
120
+
121
+ def print_info_ns(f, indent)
122
+ # p "print_info: #{self.get_global_name}"
123
+ print_info_ns_sub f, indent
124
+ @signature_list.each {|sig|
125
+ sig.print_info f, indent
126
+ }
127
+ @celltype_list.each {|ct|
128
+ if ct.get_cell_list.length > 0
129
+ ct.print_info f, indent
130
+ end
131
+ }
132
+ @namespace_list.each {|ns|
133
+ if ns.instance_of? Namespace # region を含めない
134
+ ns.print_info_ns f, indent
135
+ end
136
+ }
137
+ end
138
+
139
+ def self.print_info(f, indent)
140
+ @@root_namespace.print_info_ns f, indent
141
+ end
142
+
143
+ #=== Namespace# 構造体メンバーのオフセット定義
144
+ def print_struct_define(f)
145
+ f.print "\n/***** Offset of members of structures *****/\n"
146
+ @struct_tag_list.get_items.each{|tag, sttype|
147
+ # print "sttype: #{tag.get_name} #{sttype}\n"
148
+ tag.get_members_decl.get_items.each{|decl|
149
+ f.printf "#define OFFSET_OF_%-30s (%s)\n",
150
+ "#{tag.get_ID_str}_#{decl.get_name}",
151
+ "(uint32_t)(intptr_t)&(((#{tag.get_type_str}#{tag.get_type_str_post}*)0)->#{decl.get_name})"
152
+ f.printf "#define PLACE_OF_%-30s (%s)\n",
153
+ "#{tag.get_ID_str}_#{decl.get_name}",
154
+ "VARDECL_PLACE_STRUCT"
155
+ }
156
+ }
157
+ end
158
+
159
+ def print_celltype_define_offset(f)
160
+ @celltype_list.each {|ct|
161
+ if ct.get_cell_list.length > 0
162
+ ct.print_define_offset f
163
+ end
164
+ }
165
+ @namespace_list.each {|ns|
166
+ if ns.instance_of? Namespace # region を含めない
167
+ ns.print_celltype_define_offset f
168
+ end
169
+ }
170
+ end
171
+
172
+ def print_celltype_define(f)
173
+ @celltype_list.each {|ct|
174
+ if ct.get_cell_list.length > 0
175
+ ct.print_celltype_define f
176
+ end
177
+ }
178
+ @namespace_list.each {|ns|
179
+ if ns.instance_of? Namespace # region を含めない
180
+ ns.print_celltype_define f
181
+ end
182
+ }
183
+ end
184
+
185
+ def print_call_define(f)
186
+ @celltype_list.each {|ct|
187
+ if ct.get_cell_list.length > 0
188
+ ct.print_call_define f
189
+ end
190
+ }
191
+ @namespace_list.each {|ns|
192
+ if ns.instance_of? Namespace # region を含めない
193
+ ns.print_call_define f
194
+ end
195
+ }
196
+ end
197
+
198
+ def print_entry_define(f)
199
+ @celltype_list.each {|ct|
200
+ if ct.get_cell_list.length > 0
201
+ ct.print_entry_define f
202
+ end
203
+ }
204
+ @namespace_list.each {|ns|
205
+ if ns.instance_of? Namespace # region を含めない
206
+ ns.print_entry_define f
207
+ end
208
+ }
209
+ end
210
+ end
211
+
212
+ class Region
213
+ def print_info_region_sub(f, indent)
214
+ if get_link_root == self
215
+ name = "_LinkRoot"
216
+ else
217
+ name = @global_name
218
+ end
219
+ # p "region:#{get_name}"
220
+ f.print "\n#{indent}/*** #{get_namespace_path} region information cell ***/\n"
221
+ f.print <<EOT
222
+ #{indent}cell nTECSInfo::tRegionInfo #{name}RegionInfo{
223
+ #{indent} name = "#{@name}";
224
+ EOT
225
+ @cell_list.each{|cell|
226
+ # print "cell class="+cell.get_celltype.class.name+", " + cell.get_celltype.get_name.to_s + " 1\n"
227
+ if !cell.exclude_info?
228
+ # print "cell class="+cell.get_celltype.class.name+", " + cell.get_celltype.get_name.to_s + " 2\n"
229
+ f.print "#{indent} cCellInfo[] = #{cell.get_global_name}CellInfo.eCellInfo;\n"
230
+ end
231
+ }
232
+ @namespace_list.each {|region|
233
+ if region.instance_of? Region
234
+ f.print "#{indent} cRegionInfo[] = #{region.get_global_name}RegionInfo.eRegionInfo;\n"
235
+ end
236
+ }
237
+ f.print "#{indent}};\n"
238
+ @cell_list.each{|cell|
239
+ if !cell.exclude_info?
240
+ cell.print_info f, indent
241
+ end
242
+ }
243
+ end
244
+
245
+ def print_info_region(f, indent)
246
+ self.print_info_region_sub f, indent
247
+ @namespace_list.each {|region|
248
+ if region.instance_of? Region
249
+ region.print_info_region f, indent
250
+ end
251
+ }
252
+ end
253
+
254
+ def print_info(f, indent)
255
+ # p "print_info: #{self.get_global_name}"
256
+ self.print_info_region f, indent
257
+ end
258
+
259
+ def self.print_cell_define(f)
260
+ region.get_link_root.print_cell_define f
261
+ region.get_link_root.get_region{|region|
262
+ if region.instance_of? Region
263
+ region.print_cell_define_offset f
264
+ end
265
+
266
+ }
267
+ end
268
+
269
+ def print_cell_define(f)
270
+ ct_list = {}
271
+ @cell_list.each{|cell|
272
+ next if cell.exclude_info_factory?
273
+ ct_list[cell.get_celltype] = true
274
+ }
275
+ f.print "#define TOPPERS_CB_TYPE_ONLY\n"
276
+ ct_list.each{|ct, val|
277
+ f.print "#include \"#{ct.get_global_name}_tecsgen.h\"\n"
278
+ }
279
+ f.print "\n"
280
+ @cell_list.each{|cell|
281
+ next if cell.exclude_info_factory?
282
+ name_array = cell.get_celltype.get_name_array cell
283
+ if cell.get_celltype.has_CB?
284
+ cb = "(void*)#{name_array[8]}"
285
+ cb_proto = "extern #{cell.get_celltype.get_global_name}_CB #{name_array[4]};\n"
286
+ else
287
+ cb = "0"
288
+ cb_proto = ""
289
+ end
290
+ if cell.get_celltype.has_INIB?
291
+ inib = "(void*)&#{name_array[5]}"
292
+ inib_proto = "extern #{cell.get_celltype.get_global_name}_INIB #{name_array[11]};\n"
293
+ else
294
+ inib = "0"
295
+ inib_proto = ""
296
+ end
297
+ if !cell.exclude_info_factory?
298
+ f.print <<EOT
299
+ #{cb_proto}#define #{cell.get_global_name}__CBP #{cb}
300
+ #{inib_proto}#define #{cell.get_global_name}__INIBP #{inib}
301
+ EOT
302
+ end
303
+ }
304
+ @namespace_list.each {|region|
305
+ if region.instance_of? Region
306
+ region.print_cell_define f
307
+ end
308
+ }
309
+ end
310
+
311
+ def print_entry_descriptor_define(f)
312
+ @cell_list.each{|cell|
313
+ next if cell.exclude_info_factory?
314
+
315
+ signatures = {}
316
+ cell.get_celltype.get_port_list.each{|port|
317
+ next if port.get_port_type != :ENTRY
318
+
319
+ if signatures[port.get_signature].nil?
320
+ f.print "#include \"#{port.get_signature.get_global_name}_tecsgen.h\"\n"
321
+ end
322
+ if cell.get_celltype.get_global_name == :nTECSInfo_tRawEntryDescriptorInfo
323
+ f.print "const struct tag_#{cell.get_celltype.get_global_name}_#{port.get_name}_DES "
324
+ f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
325
+ else
326
+ f.print "extern struct tag_#{port.get_signature.get_global_name}_VDES "
327
+ f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
328
+ end
329
+ }
330
+ }
331
+ @namespace_list.each {|region|
332
+ if region.instance_of? Region
333
+ region.print_entry_descriptor_define f
334
+ end
335
+ }
336
+ end
337
+ end
338
+
339
+ class Celltype
340
+ def print_info(f, indent)
341
+ f.print <<EOT
342
+ #{indent}cell nTECSInfo::tCelltypeInfo #{@global_name}CelltypeInfo {
343
+ #{indent} name = "#{@name}";
344
+ #{indent} b_singleton = #{@singleton};
345
+ #{indent} b_IDX_is_ID_act = C_EXP( "#{@global_name}__IDX_is_ID_act" );
346
+ #{indent} sizeOfCB = C_EXP( "#{@global_name}__sizeOfCB" );
347
+ #{indent} sizeOfINIB = C_EXP( "#{@global_name}__sizeOfINIB" );
348
+ #{indent} n_cellInLinkUnit = C_EXP( "#{@global_name}__NCELLINLINKUNIT" );
349
+ #{indent} n_cellInSystem = #{@cell_list.length};
350
+ EOT
351
+ @port.each{|port|
352
+ if port.get_port_type == :ENTRY
353
+ f.print <<EOT
354
+ #{indent} cEntryInfo[] = #{@global_name}_#{port.get_name}EntryInfo.eEntryInfo;
355
+ EOT
356
+ end
357
+ }
358
+ @port.each{|port|
359
+ if port.get_port_type == :CALL
360
+ f.print <<EOT
361
+ #{indent} cCallInfo[] = #{@global_name}_#{port.get_name}CallInfo.eCallInfo;
362
+ EOT
363
+ end
364
+ }
365
+ @attribute.each{|decl|
366
+ f.print <<EOT
367
+ #{indent} cAttrInfo[] = #{@global_name}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;
368
+ EOT
369
+ }
370
+ @var.each{|decl|
371
+ f.print <<EOT
372
+ #{indent} cVarInfo[] = #{@global_name}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;
373
+ EOT
374
+ }
375
+ f.print <<EOT
376
+ #{indent}};
377
+ EOT
378
+ @port.each{|port|
379
+ if port.get_port_type == :ENTRY
380
+ port.print_info f, @global_name, indent
381
+ end
382
+ }
383
+ @port.each{|port|
384
+ if port.get_port_type == :CALL
385
+ port.print_info f, @global_name, indent
386
+ end
387
+ }
388
+ @attribute.each{|decl|
389
+ decl.print_info f, @global_name, indent, :DECLTYPE_ATTR
390
+ }
391
+ @var.each{|decl|
392
+ decl.print_info f, @global_name, indent, :DECLTYPE_VAR
393
+ }
394
+ end
395
+
396
+ def print_define_offset(f)
397
+ # intptr_t に一回キャストするのは 64bit 版を考量してのこと.しかし 32bit としているので 4GB を超える構造体等は扱えない
398
+ if @n_cell_gen > 0
399
+ f.print <<EOT
400
+
401
+ #include "#{@global_name}_tecsgen.h"
402
+ EOT
403
+ @attribute.each{|decl|
404
+ if has_INIB?
405
+ inib_cb = "INIB"
406
+ else
407
+ inib_cb = "CB"
408
+ end
409
+ if !decl.is_omit?
410
+ offset = "(uint32_t)(intptr_t)&(((#{@global_name}_#{inib_cb}*)0)->#{decl.get_name})"
411
+ place = inib_cb
412
+ else
413
+ offset = "0xffffffff"
414
+ place = "NON"
415
+ end
416
+ f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", offset
417
+ f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_%s\n", "#{@global_name}_#{decl.get_name}", place
418
+ }
419
+ @var.each{|decl|
420
+ if decl.get_size_is && has_INIB?
421
+ inib_cb = "INIB"
422
+ else
423
+ inib_cb = "CB"
424
+ end
425
+ place = inib_cb
426
+ f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", "(uint32_t)(intptr_t)&(((#{@global_name}_#{inib_cb}*)0)->#{decl.get_name})"
427
+ f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_%s\n", "#{@global_name}_#{decl.get_name}", place
428
+ }
429
+ else
430
+ f.print <<EOT
431
+
432
+ // #include "#{@global_name}_tecsgen.h" // no cell exist
433
+ EOT
434
+ # 生成されないセルタイプ
435
+ @attribute.each{|decl|
436
+ f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff"
437
+ f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_NON\n", "#{@global_name}_#{decl.get_name}"
438
+ }
439
+ @var.each{|decl|
440
+ f.printf "#define OFFSET_OF_%-30s (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff"
441
+ f.printf "#define PLACE_OF_%-30s VARDECL_PLACE_NON\n", "#{@global_name}_#{decl.get_name}"
442
+ }
443
+ end
444
+ end
445
+
446
+ def print_celltype_define(f)
447
+ if has_INIB?
448
+ size_INIB = "(sizeof(#{@global_name}_INIB))"
449
+ else
450
+ size_INIB = "(0)"
451
+ end
452
+ if has_CB?
453
+ size_CB = "(sizeof(#{@global_name}_CB))"
454
+ else
455
+ size_CB = "(0)"
456
+ end
457
+
458
+ if @n_cell_gen > 0
459
+ f.printf "\n#include \"#{@global_name}_tecsgen.h\"\n"
460
+ f.printf "#define %-50s (#{@idx_is_id_act})\n", "#{@global_name}__IDX_is_ID_act"
461
+ f.printf "#define %-50s (#{size_CB})\n", "#{@global_name}__sizeOfCB"
462
+ f.printf "#define %-50s (#{size_INIB})\n", "#{@global_name}__sizeOfINIB"
463
+ f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
464
+ else
465
+ f.printf "#define %-50s (false)\n", "#{@global_name}__IDX_is_ID_act"
466
+ f.printf "#define %-50s (0)\n", "#{@global_name}__sizeOfCB"
467
+ f.printf "#define %-50s (0)\n", "#{@global_name}__sizeOfINIB"
468
+ f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
469
+ end
470
+ end
471
+
472
+ def print_call_define(f)
473
+ if @n_cell_gen > 0
474
+ f.print <<EOT
475
+
476
+ #include "#{@global_name}_tecsgen.h"
477
+ EOT
478
+ else
479
+ f.print <<EOT
480
+
481
+ // #include "#{@global_name}_tecsgen.h" // no cell exist
482
+ EOT
483
+ end
484
+ @port.each{|port|
485
+ next if port.get_port_type == :ENTRY
486
+ if port.is_omit? || (port.is_VMT_useless? && port.is_cell_unique?) || @n_cell_gen == 0
487
+ place = "CALL_PLACE_NON"
488
+ elsif port.is_dynamic?
489
+ if port.get_array_size
490
+ place = "CALL_PLACE_INIB_DES"
491
+ else
492
+ place = "CALL_PLACE_CB_DES"
493
+ end
494
+ elsif !has_INIB?
495
+ if port.is_VMT_useless?
496
+ place = "CALL_PLACE_CB_IDX"
497
+ else
498
+ place = "CALL_PLACE_CB_DES"
499
+ end
500
+ else
501
+ if port.is_VMT_useless?
502
+ place = "CALL_PLACE_INIB_IDX"
503
+ else
504
+ place = "CALL_PLACE_INIB_DES"
505
+ end
506
+ end
507
+ if (port.is_VMT_useless? && port.is_cell_unique?) || port.is_omit? || @n_cell_gen == 0
508
+ offset = "0xffffffff"
509
+ else
510
+ if port.is_dynamic? || !has_INIB?
511
+ cb_inib = "CB"
512
+ else
513
+ cb_inib = "INIB"
514
+ end
515
+ offset = "(uint32_t)(intptr_t)&((#{@global_name}_#{cb_inib}*)0)->#{port.get_name}"
516
+ end
517
+ array_size = port.get_array_size
518
+ if array_size == "[]"
519
+ array_size = "0xffffffff"
520
+ elsif array_size.nil?
521
+ array_size = "0"
522
+ end
523
+
524
+ f.printf "#define %-50s (#{offset})\n", "#{@global_name}_#{port.get_name}__offset"
525
+ f.printf "#define %-50s (#{array_size})\n", "#{@global_name}_#{port.get_name}__array_size"
526
+ f.printf "#define %-50s (#{place})\n", "#{@global_name}_#{port.get_name}__place"
527
+ f.printf "#define %-50s (#{port.is_VMT_useless?})\n", "#{@global_name}_#{port.get_name}__b_VMT_useless"
528
+ f.printf "#define %-50s (#{port.is_skelton_useless?})\n", "#{@global_name}_#{port.get_name}__b_skelton_useless"
529
+ f.printf "#define %-50s (#{port.is_cell_unique?})\n", "#{@global_name}_#{port.get_name}__b_cell_unique"
530
+ }
531
+ end
532
+
533
+ def print_entry_define(f)
534
+ @port.each{|port|
535
+ next if port.get_port_type == :CALL
536
+ array_size = port.get_array_size
537
+ if array_size == "[]"
538
+ array_size = "0xffffffff"
539
+ elsif array_size.nil?
540
+ array_size = "0"
541
+ end
542
+
543
+ f.printf "#define %-50s (#{array_size})\n", "#{@global_name}_#{port.get_name}__array_size"
544
+ }
545
+ end
546
+ end
547
+
548
+ class Port
549
+ def print_info(f, ct_global, indent)
550
+ return if @signature.nil? # signature not found error in cdl
551
+ if @port_type == :ENTRY
552
+ f.print <<EOT
553
+ #{indent}cell nTECSInfo::tEntryInfo #{ct_global}_#{@name}EntryInfo{
554
+ #{indent} name = "#{@name}";
555
+ #{indent} cSignatureInfo = #{@signature.get_global_name}SignatureInfo.eSignatureInfo;
556
+ #{indent} b_inline = #{@b_inline};
557
+ #{indent} array_size = C_EXP( "#{ct_global}_#{@name}__array_size" );
558
+ #{indent}};
559
+ EOT
560
+ else
561
+ f.print <<EOT
562
+ #{indent}cell nTECSInfo::tCallInfo #{ct_global}_#{@name}CallInfo{
563
+ #{indent} name = "#{@name}";
564
+ #{indent} cSignatureInfo = #{@signature.get_global_name}SignatureInfo.eSignatureInfo;
565
+ #{indent} offset = C_EXP( "#{ct_global}_#{@name}__offset" );
566
+ #{indent} array_size = C_EXP( "#{ct_global}_#{@name}__array_size" );
567
+ #{indent} b_optional = #{@b_optional};
568
+ #{indent} b_omit = #{@b_omit};
569
+ #{indent} b_dynamic = #{@b_dynamic};
570
+ #{indent} b_ref_desc = #{@b_ref_desc};
571
+ #{indent} b_allocator_port = #{!@allocator_port.nil? ? true : false};
572
+ #{indent} b_require_port = #{@b_require};
573
+ #{indent} place = C_EXP( "#{ct_global}_#{@name}__place" );
574
+ #{indent} b_VMT_useless = C_EXP( "#{ct_global}_#{@name}__b_VMT_useless" );
575
+ #{indent} b_skelton_useless = C_EXP( "#{ct_global}_#{@name}__b_skelton_useless" );
576
+ #{indent} b_cell_unique = C_EXP( "#{ct_global}_#{@name}__b_cell_unique" );
577
+
578
+ #{indent}};
579
+ EOT
580
+ end
581
+ end
582
+ end
583
+
584
+ class Cell
585
+ def print_info(f, indent)
586
+ if exclude_info?
587
+ return
588
+ end
589
+ f.print <<EOT
590
+
591
+ #{indent}/*** #{@global_name} cell information ****/
592
+ #{indent}cell nTECSInfo::tCellInfo #{@global_name}CellInfo {
593
+ #{indent} name = "#{@name}";
594
+ #{indent} cbp = C_EXP( \"#{@global_name}__CBP\" );
595
+ #{indent} inibp = C_EXP( \"#{@global_name}__INIBP\" );
596
+ #{indent} cCelltypeInfo = #{@celltype.get_global_name}CelltypeInfo.eCelltypeInfo;
597
+ EOT
598
+ @celltype.get_port_list.each{|port|
599
+ next if port.get_port_type != :ENTRY
600
+
601
+ f.print <<EOT
602
+ #{indent} cRawEntryDescriptor[] = #{@global_name}_#{port.get_name}RawEntryDescriptorInfo.eRawEntryDescriptor;
603
+ EOT
604
+ }
605
+ f.print "#{indent}};\n"
606
+
607
+ # RawEntryDescriptorInfo cells
608
+ @celltype.get_port_list.each{|port|
609
+ next if port.get_port_type != :ENTRY
610
+
611
+ size = port.get_array_size
612
+ if size.nil?
613
+ size = 1
614
+ elsif size == "[]"
615
+ size = @entry_array_max_subscript[port]
616
+ end
617
+ if !port.is_omit?
618
+ red = "C_EXP( \"&#{@global_name}_#{port.get_name}_des\" )"
619
+ else
620
+ red = "(void *)0"
621
+ end
622
+ # mikan 受け口配列
623
+ f.print <<EOT
624
+ #{indent}cell nTECSInfo::tRawEntryDescriptorInfo #{@global_name}_#{port.get_name}RawEntryDescriptorInfo {
625
+ #{indent} size = #{size};
626
+ #{indent} rawEntryDescriptor = { #{red} };
627
+ EOT
628
+ # #{indent} cEntryInfo = #{@celltype.get_global_name}_#{port.get_name}EntryInfo.eEntryInfo;
629
+ f.print "#{indent}};\n"
630
+ }
631
+ end
632
+
633
+ def exclude_info?
634
+ # print "exclude_info?: name=" + get_name.to_s
635
+ if @celltype.nil? ||
636
+ is_of_composite? ||
637
+ @celltype.get_global_name == :nTECSInfo_tTECSInfoSub ||
638
+ post_code_generated? ||
639
+ @b_defined == false
640
+ # print ": true celltype_is_of_composite=#{is_of_composite?} celltype_name=#{@celltype.get_global_name} celltype.need_generate=#{@celltype.need_generate?}\n"
641
+ return true
642
+ else
643
+ # print ": false\n"
644
+ return false
645
+ end
646
+ end
647
+
648
+ def exclude_info_factory?
649
+ # print "exclude_info_factory?: name=" + get_name.to_s
650
+ if @celltype.nil? ||
651
+ is_of_composite? ||
652
+ @celltype.get_global_name == :nTECSInfo_tTECSInfoSub ||
653
+ !@celltype.need_generate?
654
+ # print ": true celltype_is_of_composite=#{is_of_composite?} celltype_name=#{@celltype.get_global_name} celltype.need_generate=#{@celltype.need_generate?}\n"
655
+ return true
656
+ else
657
+ # print ": false\n"
658
+ return false
659
+ end
660
+ end
661
+ end
662
+
663
+ class Signature
664
+ def print_info(f, indent)
665
+ f.print <<EOT
666
+
667
+ #{indent}/*** #{@global_name} signature information ****/
668
+ #{indent}cell nTECSInfo::tSignatureInfo #{@global_name}SignatureInfo {
669
+ #{indent} name = "#{@name}";
670
+ EOT
671
+ @function_head_list.get_items.each{|fh|
672
+ f.print <<EOT
673
+ #{indent} cFunctionInfo[] = #{@global_name}_#{fh.get_name}FunctionInfo.eFunctionInfo;
674
+ EOT
675
+ }
676
+ f.print <<EOT
677
+ #{indent}};
678
+ EOT
679
+ @function_head_list.get_items.each{|fh|
680
+ fh.print_info f, indent
681
+ }
682
+ end
683
+ end
684
+
685
+ class FuncHead
686
+ def print_info(f, indent)
687
+ sig_name = @owner.get_global_name
688
+ func_name = get_name
689
+ f.print <<EOT
690
+ #{indent}cell nTECSInfo::tFunctionInfo #{sig_name}_#{func_name}FunctionInfo {
691
+ #{indent} name = "#{get_name}";
692
+ #{indent} bOneway = #{is_oneway?};
693
+ EOT
694
+ get_paramlist.get_items.each{|param|
695
+ f.print <<EOT
696
+ #{indent} cParamInfo[] = #{sig_name}_#{func_name}_#{param.get_name}ParamInfo.eParamInfo;
697
+ EOT
698
+ }
699
+ f.print <<EOT
700
+ #{indent} cReturnTypeInfo = #{get_return_type.get_ID_str}TypeInfo.eTypeInfo;
701
+ #{indent}};
702
+ EOT
703
+ get_paramlist.get_items.each{|param|
704
+ dbgPrint "param_list #{sig_name}, #{func_name}, #{param.get_name}\n"
705
+ param.print_info f, sig_name, func_name, get_paramlist, indent
706
+ }
707
+ get_return_type.print_info f, indent
708
+ end
709
+ end
710
+
711
+ class ParamDecl
712
+ def print_info(f, signature_global_name, func_name, paramdecl_list, indent)
713
+ if @size
714
+ size = "\"#{@size.get_rpn(paramdecl_list)}\""
715
+ else
716
+ size = "(char_t*)0"
717
+ end
718
+ if @count
719
+ count = "\"#{@count.get_rpn(paramdecl_list)}\""
720
+ else
721
+ count = "(char_t*)0"
722
+ end
723
+ if @string
724
+ if @string == -1
725
+ string = '""'
726
+ else
727
+ string = "\"#{@string.get_rpn(paramdecl_list)}\""
728
+ end
729
+ else
730
+ string = "(char_t*)0"
731
+ end
732
+ f.print <<EOT
733
+ #{indent}cell nTECSInfo::tParamInfo #{signature_global_name}_#{func_name}_#{get_name}ParamInfo {
734
+ #{indent} name = "#{get_name}";
735
+ #{indent} dir = PARAM_DIR_#{@direction};
736
+ #{indent} sizeIsExpr = #{size};
737
+ #{indent} countIsExpr = #{count};
738
+ #{indent} stringExpr = #{string};
739
+ #{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;
740
+ #{indent}};
741
+ EOT
742
+ get_type.print_info f, indent
743
+ end
744
+ end
745
+
746
+ class Decl
747
+ def print_info(f, parent_ID_str, indent, decl_type)
748
+ if @size_is
749
+ size = "\"mikan\""
750
+ else
751
+ size = "(char_t*)0"
752
+ end
753
+ f.print <<EOT
754
+ #{indent}cell nTECSInfo::tVarDeclInfo #{parent_ID_str}_#{get_name}VarDeclInfo {
755
+ #{indent} name = "#{get_name}";
756
+ #{indent} sizeIsExpr = #{size};
757
+ #{indent} declType = #{decl_type};
758
+ #{indent} offset = C_EXP( "OFFSET_OF_#{parent_ID_str}_#{get_name}" );
759
+ #{indent} place = C_EXP( "PLACE_OF_#{parent_ID_str}_#{get_name}" );
760
+ #{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;
761
+ #{indent}};
762
+ EOT
763
+ get_type.print_info f, indent
764
+ end
765
+ end
766
+
767
+ class Type
768
+ @@typeinfo_printed = {}
769
+
770
+ def self.reset_print_info
771
+ @@typeinfo_printed = {}
772
+ end
773
+
774
+ def print_info(f, indent)
775
+ # Type の info は、最後にまとめて出力するので、ここでは記録するだけ
776
+ if @@typeinfo_printed[get_ID_str]
777
+ return
778
+ end
779
+ # p "ID Str: #{get_ID_str}"
780
+ @@typeinfo_printed[get_ID_str] = self
781
+ if self.is_a? PtrType
782
+ get_referto.print_info f, indent
783
+ elsif self.is_a? ArrayType
784
+ get_type.print_info f, indent
785
+ elsif self.is_a? DefinedType
786
+ get_type.print_info f, indent
787
+ elsif self.is_a? StructType
788
+ get_members_decl.get_items.each{|decl|
789
+ decl.print_info f, get_ID_str, indent, :DECLTYPE_STMEMBER
790
+ }
791
+ end
792
+ end
793
+
794
+ def self.print_info_post(f, indent)
795
+ @@typeinfo_printed.each{|nm, type|
796
+ type.print_info_post f, indent
797
+ }
798
+ end
799
+
800
+ def print_info_post(f, indent)
801
+ if self.class.superclass == Type # 親クラスが Type の場合 types.rb のクラス
802
+ type_name = self.class.name
803
+ else
804
+ type_name = self.class.superclass.name # ctypes.rb のクラス (親クラスが types.rb のクラス)
805
+ end
806
+ # p "type: #{type_name}, #{self.class.name}"
807
+
808
+ # p "class=#{self.class.name} size=#{bit_size}"
809
+ f.print <<EOT
810
+ #{indent}cell nTECSInfo::t#{type_name}Info #{get_ID_str}TypeInfo{
811
+ #{indent} name = "#{get_type_str}#{get_type_str_post}";
812
+ #{indent} typeKind = TECSTypeKind_#{type_name};
813
+ #{indent} size = C_EXP( "sizeof(#{get_type_str}#{get_type_str_post})" );
814
+ #{indent} b_const = #{is_const?};
815
+ #{indent} b_volatile = #{is_volatile?};
816
+ EOT
817
+ if self.is_a? PtrType
818
+ f.print "#{indent} cTypeInfo = #{get_referto.get_ID_str}TypeInfo.eTypeInfo;\n"
819
+ elsif self.is_a? ArrayType
820
+ f.print "#{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
821
+ elsif self.is_a? DefinedType
822
+ f.print "#{indent} cTypeInfo = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
823
+ elsif self.is_a? StructType
824
+ get_members_decl.get_items.each{|decl|
825
+ f.print "#{indent} cVarDeclInfo[] = #{get_ID_str}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;\n"
826
+ }
827
+ elsif self.is_a? DescriptorType
828
+ f.print "#{indent} cSignatureInfo = #{get_signature.get_global_name}SignatureInfo.eSignatureInfo;\n"
829
+ end
830
+
831
+ f.print <<EOT
832
+ #{indent}};
833
+ EOT
834
+ end
835
+
836
+ #=== Type# 型文字列の識別子化
837
+ # 型文字列に含まれる識別子として用いることのできない文字を用いることのできる文字列に置き換える
838
+ # 空白 => __
839
+ # * => _Ptr_
840
+ # [] => _Array_
841
+ # Descriptor() => Descriptor_of_
842
+ def get_ID_str
843
+ # puts "get_ID_str: #{self.class.name}"
844
+ if is_a? PtrType
845
+ str = get_referto.get_ID_str + "_Ptr_"
846
+ elsif is_a? ArrayType
847
+ str = get_type.get_ID_str + "_Array" + get_subscript.eval_const(nil).to_s + "_"
848
+ elsif is_a? StructType
849
+ str = "struct #{@tag}"
850
+ elsif is_a? DescriptorType
851
+ str = "Descriptor_of_" + get_signature.get_global_name.to_s
852
+ else
853
+ str = get_type_str + get_type_str_post
854
+ end
855
+ # p "before: #{str}"
856
+ str.gsub!(/ /, "__")
857
+ # p "after: #{str}"
858
+ return str
859
+ end
860
+ end