Class: OpaqueRPCPlugin
- Inherits:
-
ThroughPlugin
- Object
- Node
- Plugin
- ThroughPlugin
- OpaqueRPCPlugin
- Includes:
- GenOpaqueMarshaler, GenParamCopy
- Defined in:
- lib/tecsgen/plugin/OpaqueRPCPlugin.rb
Constant Summary collapse
- OpaqueRPCPluginArgProc =
OpaqueRPCPlugin 専用のオプション
RPCPluginArgProc.dup
Constants included from GenOpaqueMarshaler
GenOpaqueMarshaler::RPCPluginArgProc
Constants inherited from Plugin
Instance Method Summary collapse
- #gen_plugin_decl_code(file) ⇒ Object
-
#gen_through_cell_code(file) ⇒ Object
through cell コードを生成.
-
#initialize(cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell) ⇒ OpaqueRPCPlugin
constructor
RPCPlugin の initialize 説明は ThroughPlugin (plugin.rb) を参照.
-
#set_noClientSemaphore(rhs) ⇒ Object
プラグイン引数 noClientSemaphore のチェック.
Methods included from GenParamCopy
#print_nullable_post, #print_nullable_pre, #print_param, #print_param0
Methods included from GenOpaqueMarshaler
#alloc_for_out_param, #alloc_for_out_params, #check_PPAllocator, #check_opener_code, #dealloc_for_params, #gen_ep_func_body, #gen_ep_func_body_marshal, #gen_ep_func_body_unmarshal, #gen_marshaler_celltype, #gen_postamble, #gen_preamble, #get_cell_name, #initialize_opaque_marshaler, #optparse, #print_out_nullable, #print_params, #set_PPAllocatorSize, #set_TDRCelltype, #set_clientChannelCell, #set_clientChannelCelltype, #set_clientChannelInitializer, #set_clientErrorHandler, #set_clientSemaphoreCelltype, #set_clientSemaphoreInitializer, #set_noServerChannelOpenerCode, #set_serverChannelCell, #set_serverChannelCelltype, #set_serverChannelInitializer, #set_serverErrorHandler, #set_stackSize, #set_substituteAllocator, #set_taskCelltype, #set_taskPriority
Methods inherited from ThroughPlugin
#check_plugin_arg, #gen_cdl_file, #gen_ep_func_body, gen_post_code, #get_cell_name, #get_cell_namespace_path, #get_through_entry_port_name, #get_through_entry_port_subscript, #set_through_info, #show_tree, #subst_name
Methods inherited from Plugin
#cdl_error, #check_plugin_arg, #gen_cdl_file, #gen_ep_func?, #gen_postamble, #gen_preamble, #new_cell, #parse_plugin_arg, #print_msg, #set_locale, #set_silent
Methods inherited from Node
#cdl_error, #cdl_error2, #cdl_error3, #cdl_info, #cdl_info2, #cdl_warning, #cdl_warning2, #get_locale, #locale_str, #set_locale
Constructor Details
#initialize(cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell) ⇒ OpaqueRPCPlugin
RPCPlugin の initialize
説明は ThroughPlugin (plugin.rb) を参照
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/tecsgen/plugin/OpaqueRPCPlugin.rb', line 56 def initialize(cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell) super @b_noClientSemaphore = false initialize_opaque_marshaler @plugin_arg_check_proc_tab = OpaqueRPCPluginArgProc parse_plugin_arg check_opener_code check_PPAllocator print "OpaqueRPCPlugin: #{@clientChannelCell}\n" @rpc_server_channel_celltype_name = "tOpaqueRPCPlugin_#{@TDRCelltype}_#{@serverChannelCelltype}_#{@signature.get_global_name}" @rpc_server_channel_celltype_file_name = "#{$gen}/#{@rpc_server_channel_celltype_name}.cdl" @rpc_client_channel_celltype_name = "tOpaqueRPCPlugin_#{@TDRCelltype}_#{@clientChannelCelltype}_#{@signature.get_global_name}" @rpc_client_channel_celltype_file_name = "#{$gen}/#{@rpc_client_channel_celltype_name}.cdl" end |
Instance Method Details
#gen_plugin_decl_code(file) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/tecsgen/plugin/OpaqueRPCPlugin.rb', line 74 def gen_plugin_decl_code(file) gen_marshaler_celltype # チャンネル composite セルタイプの生成 # ここで生成された CDL ファイルは、tecsgen が直接 import するのではなく # セルコードの CDL から import される f = CFile.open(@rpc_client_channel_celltype_file_name, "w") # 同じ内容を二度書く可能性あり (AppFile は不可) f.print <<EOT import( "#{@marshaler_celltype_file_name}" ); /* RPC Client side composite celltype */ composite #{@rpc_client_channel_celltype_name} { /* marshaler entry port */ entry #{@signature.get_namespace_path} eThroughEntry; call sChannel cChannel; [optional] call sRPCErrorHandler cErrorHandler; [optional] call sSemaphore cLockChannel; cell #{@TDRCelltype} TDR { cChannel => composite.cChannel; }; cell #{@marshaler_celltype_name} Marshaler{ cTDR = TDR.eTDR; cErrorHandler => composite.cErrorHandler; cLockChannel => composite.cLockChannel; }; composite.eThroughEntry => Marshaler.eClientEntry; }; EOT f.close if @PPAllocatorSize alloc_cell = " cell tPPAllocator PPAllocator {\n heapSize = #{@PPAllocatorSize};\n };\n" alloc_call_port_join = " cPPAllocator = PPAllocator.ePPAllocator;\n" else alloc_cell = "" alloc_call_port_join = "" end f = CFile.open(@rpc_server_channel_celltype_file_name, "w") # 同じ内容を二度書く可能性あり (AppFile は不可) f.print <<EOT import( "#{@marshaler_celltype_file_name}" ); /* RPC Server side composite celltype */ composite #{@rpc_server_channel_celltype_name} { /* Interface */ call #{@signature.get_namespace_path} #{@call_port_name}; call sChannel cChannel; [optional] call sRPCErrorHandler cErrorHandler; entry sUnmarshalerMain eService; /* Implementation */ cell #{@TDRCelltype} TDR { cChannel => composite.cChannel; }; #{alloc_cell} cell #{@unmarshaler_celltype_name} Unmarshaler{ cTDR = TDR.eTDR; cErrorHandler => composite.cErrorHandler; cServerCall => composite.#{@call_port_name}; #{alloc_call_port_join} }; composite.eService => Unmarshaler.eService; }; EOT f.close end |
#gen_through_cell_code(file) ⇒ Object
through cell コードを生成
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/tecsgen/plugin/OpaqueRPCPlugin.rb', line 153 def gen_through_cell_code(file) gen_plugin_decl_code(file) # セルを探す # path =["::",@next_cell.get_name] # mikan namespace # cell = Namespace.find( path ) cell = Namespace.find(@next_cell.get_namespace_path) file.print <<EOT import( "#{@rpc_client_channel_celltype_file_name}" ); import( "#{@rpc_server_channel_celltype_file_name}" ); EOT ##### クライアント側のセルの生成 ##### nest = @start_region.gen_region_str_pre file nest_str = " " * nest # セマフォの生成 if @b_noClientSemaphore == false file.print <<EOT #{nest_str} // Semaphore for Multi-task use ("specify noClientSemaphore" option to delete this) #{nest_str} cell #{@semaphoreCelltype} #{@serverChannelCell}_Semaphore{ #{nest_str} #{@semaphoreInitializer} #{nest_str} }; EOT end # クライアント側チャンネル (TINET, Socket など)の生成 file.print <<EOT #{nest_str} // Client Side Channel #{nest_str} cell #{@clientChannelCelltype} #{@clientChannelCell}{ #{nest_str} #{@clientChannelInitializer} #{nest_str} }; #{nest_str} // Marshaler EOT # セマフォの結合文 if @b_noClientSemaphore == false semaphore = "#{nest_str} cLockChannel = #{@serverChannelCell}_Semaphore.eSemaphore;\n" else semaphore = "" end ### クライアント側チャンネル (マーシャラ+TDR)の生成 ### # アロケータの指定があるか? if cell.get_allocator_list.length > 0 file.print nest_str file.print "[allocator(" delim = "" cell.get_allocator_list.each do |type, eport, subsc, func, buf, alloc| alloc_str = alloc.to_s subst = @substituteAllocator[alloc_str.to_sym] if subst alloc_str = subst[2] + "." + subst[3] end file.print delim delim = ",\n" # 最終行には出さない if subsc # 配列添数 subsc_str = '[#{subsc}]' else subsc_str = "" end eport = "eThroughEntry" # RPCの受け口名に変更 file.print nest_str file.print "#{eport}#{subsc_str}.#{func}.#{buf} = #{alloc_str}" end file.puts ")]" end if @clientErrorHandler clientErrorHandler_str = "#{nest_str} cErrorHandler = #{@clientErrorHandler};\n" else clientErrorHandler_str = "" end file.print <<EOT #{nest_str} cell #{@rpc_client_channel_celltype_name} #{@cell_name} { #{nest_str} cChannel = #{@clientChannelCell}.eC0; #{clientErrorHandler_str}#{semaphore}#{nest_str} }; EOT ### END: クライアント側チャンネル (マーシャラ+TDR)の生成 ### @start_region.gen_region_str_post file file.print "\n\n" ##### サーバー側のセルの生成 ##### nest = @end_region.gen_region_str_pre file nest_str = " " * nest if @next_cell_port_subscript subscript = "[" + @next_cell_port_subscript.to_s + "]" else subscript = "" end if @serverErrorHandler serverErrorHandler_str = "#{nest_str} cErrorHandler = #{@serverErrorHandler};\n" else serverErrorHandler_str = "" end if @b_genOpener opener = "#{nest_str} cOpener = #{@serverChannelCell}.eOpener;\n" else opener = "" end # サーバー側チャンネル (TINET, Socket など) file.print <<EOT #{nest_str} // Server Side Channel #{nest_str} cell #{@serverChannelCelltype} #{@serverChannelCell}{ #{nest_str} #{@serverChannelInitializer} #{nest_str} }; EOT # サーバー側チャンネル (アンマーシャラ+TDR) file.print <<EOT #{nest_str} // Unmarshaler #{nest_str} cell #{@rpc_server_channel_celltype_name} #{@serverChannelCell}_Unmarshaler { #{nest_str} cChannel = #{@serverChannelCell}.eC1; #{nest_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript}; #{serverErrorHandler_str}#{nest_str} }; EOT # サーバー側タスクメイン file.print <<EOT #{nest_str} // Unmarshaler Task Main #{nest_str} cell #{@taskMainCelltype} #{@serverChannelCell}_TaskMain { #{nest_str} cMain = #{@serverChannelCell}_Unmarshaler.eService; #{opener}#{nest_str} }; EOT # サーバー側タスク file.print <<EOT #{nest_str} // Unmarshaler Task #{nest_str} cell #{@taskCelltype} #{@serverChannelCell}_Task { #{nest_str} cBody = #{@serverChannelCell}_TaskMain.eMain; #{nest_str} priority = #{@taskPriority}; #{nest_str} stackSize = #{@stackSize}; #{nest_str} taskAttribute = C_EXP( "TA_ACT" ); /* mikan : marshaler task starts at beginning */ #{nest_str} }; EOT @end_region.gen_region_str_post file end |
#set_noClientSemaphore(rhs) ⇒ Object
プラグイン引数 noClientSemaphore のチェック
313 314 315 316 317 318 319 320 321 322 |
# File 'lib/tecsgen/plugin/OpaqueRPCPlugin.rb', line 313 def set_noClientSemaphore(rhs) rhs = rhs.to_sym if rhs == :true @b_noClientSemaphore = true elsif rhs == :false @b_noClientSemaphore = false else cdl_error("RPCPlugin: specify true or false for noClientSemaphore") end end |