Class: SharedOpaqueRPCPlugin
- Inherits:
-
ThroughPlugin
- Object
- Node
- Plugin
- ThroughPlugin
- SharedOpaqueRPCPlugin
- Includes:
- GenOpaqueMarshaler, GenParamCopy
- Defined in:
- lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb
Overview
以下を仮定(制限事項)
呼び元、呼び先のエンディアン、char, short, int_t, long_t, intptr_t のサイズが同じ
有符号、無符号でサイズが同じ
Constant Summary collapse
RPCPluginArgProc.dup
{}
Constants included from GenOpaqueMarshaler
GenOpaqueMarshaler::RPCPluginArgProc
Constants inherited from Plugin
Instance Attribute Summary collapse
-
#cell_name ⇒ Object
readonly
{ chan_name => [ Plugin_obj0, Plugin_Obj1, … ] }.
-
#end_region ⇒ Object
readonly
{ chan_name => [ Plugin_obj0, Plugin_Obj1, … ] }.
-
#start_region ⇒ Object
readonly
{ chan_name => [ Plugin_obj0, Plugin_Obj1, … ] }.
Class Method Summary collapse
-
.gen_post_code(file) ⇒ Object
post コード(CDL) を生成 プラグインの後のコードを生成 file:: File:.
Instance Method Summary collapse
- #gen_plugin_decl_code(file) ⇒ Object
-
#gen_post_code(file, plugin_obj_array) ⇒ Object
post コード(CDL) を生成 共有チャンネルを生成する このメソッドは、チャンネルを共有する最初のプラグインオブジェクトのみ呼び出される.
-
#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) ⇒ SharedOpaqueRPCPlugin
constructor
RPCPlugin の initialize 説明は ThroughPlugin (plugin.rb) を参照.
-
#set_sharedChannelName(rhs) ⇒ Object
プラグイン引数 sharedChannelCell のチェック.
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, #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) ⇒ SharedOpaqueRPCPlugin
RPCPlugin の initialize
説明は ThroughPlugin (plugin.rb) を参照
68 69 70 71 72 73 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 |
# File 'lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb', line 68 def initialize(cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell) super initialize_opaque_marshaler @entry_port_name = :eClientEntry # Marshaler の受け口名 (through セルの入り口) # オプション:GenOpaqueMarshaler 参照 @plugin_arg_check_proc_tab = SharedOpaqueRPCPluginArgProc @sharedChannelName = nil parse_plugin_arg check_opener_code check_PPAllocator @shared_channel_ct_name = :tSharedOpaqueRPCPluginChannel_tTDR @shared_channel_server_ct_name = :"#{@shared_channel_ct_name}_Server" @shared_channel_client_ct_name = :"#{@shared_channel_ct_name}_Client" @shared_channel_ct_file_name = "#{$gen}/#{@shared_channel_ct_name}.cdl" if @sharedChannelName.nil? cdl_error("'sharedChannelName' option: mandatory") else @shared_channel_cell = @sharedChannelName end if @@shared_channel_list[@shared_channel_cell].nil? @@shared_channel_list[@shared_channel_cell] = [self] else @@shared_channel_list[@shared_channel_cell] << self end @sub_channel_no = @@shared_channel_list[@shared_channel_cell].length - 1 prev_start = @@shared_channel_list[@shared_channel_cell][0].start_region if @start_region != prev_start # 初出と start リージョン不一致 (初出は、自分自身とチェックされる。無駄だが小さいので放置) cdl_error("SharedRPCPlugin: start region mismatch current: #{@region.get_name} previous: #{prev_start.get_name}") end prev_end = @@shared_channel_list[@shared_channel_cell][0].end_region if @end_region != prev_end # 初出と end リージョン不一致 (初出は、自分自身とチェックされる。無駄だが小さいので放置) cdl_error("SharedRPCPlugin: end region mismatch current: #{@region.get_name} previous: #{prev_end.get_name}") end end |
Instance Attribute Details
#cell_name ⇒ Object (readonly)
{ chan_name => [ Plugin_obj0, Plugin_Obj1, … ] }
58 59 60 |
# File 'lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb', line 58 def cell_name @cell_name end |
#end_region ⇒ Object (readonly)
{ chan_name => [ Plugin_obj0, Plugin_Obj1, … ] }
58 59 60 |
# File 'lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb', line 58 def end_region @end_region end |
#start_region ⇒ Object (readonly)
{ chan_name => [ Plugin_obj0, Plugin_Obj1, … ] }
58 59 60 |
# File 'lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb', line 58 def start_region @start_region end |
Class Method Details
.gen_post_code(file) ⇒ Object
post コード(CDL) を生成
プラグインの後のコードを生成
- file
-
File:
314 315 316 317 318 319 320 321 |
# File 'lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb', line 314 def self.gen_post_code(file) file.print "/* '#{self.name}' post code */\n" @@shared_channel_list.each{|chan_name, plugin_obj_array| file.print "/* '#{chan_name}' shared channel */\n" plugin_obj_array[0].gen_post_code(file, plugin_obj_array) } end |
Instance Method Details
#gen_plugin_decl_code(file) ⇒ Object
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 149 150 151 152 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 |
# File 'lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb', line 124 def gen_plugin_decl_code(file) # このセルタイプ(同じシグニチャ)は既に生成されているか? if @@generated_celltype[@shared_channel_server_ct_name].nil? @@generated_celltype[@shared_channel_server_ct_name] = [self] else @@generated_celltype[@shared_channel_server_ct_name] << self end gen_marshaler_celltype # 同じ内容を二度書く可能性あり (AppFile は不可) if @PPAllocatorSize alloc_call_port = " call sPPAllocator cPPAllocator;\n" alloc_call_port_join = " cPPAllocator => composite.cPPAllocator;\n" else alloc_call_port = "" alloc_call_port_join = "" end f = CFile.open(@shared_channel_ct_file_name, "w") # 同じ内容を二度書く可能性あり (AppFile は不可) f.print <<EOT /* Shared Channel Celltype for Client */ composite #{@shared_channel_client_ct_name} { entry sTDR eTDR; entry sSemaphore eSemaphore[]; call sChannel cClientChannel; cell tTDR TDR { cChannel => composite.cClientChannel; }; cell tSemaphore Semaphore { count = 1; attribute = C_EXP("TA_NULL"); }; cell tRPCSharedChannelMan SharedChannelMan{ cSemaphore = Semaphore.eSemaphore; cClientSideTDR = TDR.eTDR; }; composite.eSemaphore => SharedChannelMan.eSemaphore; composite.eTDR => TDR.eTDR; }; /* Shared Channel Celltype for Server */ [active] composite #{@shared_channel_server_ct_name} { entry sTDR eTDR; call sChannel cServerChannel; call sUnmarshalerMain cUnmarshalAndCallFunction[]; call sServerChannelOpener cOpener; attr { PRI priority; }; cell tTDR TDR { cChannel => composite.cServerChannel; }; cell tRPCSharedTaskMainWithOpener RPCSharedTaskMain { cUnmarshalAndCallFunction => composite.cUnmarshalAndCallFunction; cServerSideTDR = TDR.eTDR; cOpener => composite.cOpener; }; cell tTask Task { cBody = RPCSharedTaskMain.eMain; taskAttribute = C_EXP("TA_ACT"); stackSize = 4096; priority = composite.priority; }; composite.eTDR => TDR.eTDR; }; EOT f.close end |
#gen_post_code(file, plugin_obj_array) ⇒ Object
post コード(CDL) を生成
共有チャンネルを生成する このメソッドは、チャンネルを共有する最初のプラグインオブジェクトのみ呼び出される
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb', line 326 def gen_post_code(file, plugin_obj_array) # 共有されている通信チャンネルの生成 # 各プラグインインスタンスでは @shared_channel_ct_name として記憶している # region = @caller_cell.get_region nest = @start_region.gen_region_str_pre file indent_str = " " * nest file.print <<EOT #{indent_str}cell #{@shared_channel_client_ct_name} #{@sharedChannelName} { #{indent_str} cClientChannel = #{@clientChannelCell}.eC0; #{indent_str}}; EOT @start_region.gen_region_str_post file nest = @end_region.gen_region_str_pre file indent_str = " " * nest file.print "#{indent_str}cell #{@shared_channel_server_ct_name} #{@sharedChannelName}_Server {\n" file.print <<EOT #{indent_str} cServerChannel = #{@serverChannelCell}.eC1; #{indent_str} cOpener = #{@serverChannelCell}.eOpener; EOT plugin_obj_array.each{|po| file.print <<EOT #{indent_str} cUnmarshalAndCallFunction[] = #{po.cell_name}_Server.eService; EOT } file.printf <<EOT #{indent_str} priority = #{@taskPriority}; #{indent_str}}; EOT @end_region.gen_region_str_post file end |
#gen_through_cell_code(file) ⇒ Object
through cell コードを生成
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 |
# File 'lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb', line 205 def gen_through_cell_code(file) gen_plugin_decl_code(file) file.print <<EOT import( "#{@marshaler_celltype_file_name}" ); import( "#{@shared_channel_ct_file_name}" ); EOT # nest = @caller_cell.get_region.gen_region_str_pre file nest = @start_region.gen_region_str_pre file indent_str = " " * nest nest_str = " " * nest if @next_cell_port_subscript subscript = "[" + @next_cell_port_subscript.to_s + "]" else subscript = "" end # セルを探す # path =["::",@next_cell.get_name] # cell = Namespace.find( path ) cell = Namespace.find(@next_cell.get_namespace_path) # 共有される通信チャンネルの生成のプロトタイプ宣言 file.print <<EOT #{indent_str}cell #{@shared_channel_client_ct_name} #{@shared_channel_cell}; EOT # マーシャラセルの生成(アロケータコードの生成から) # アロケータの指定があるか? if cell.get_allocator_list.length > 0 file.print "#{indent_str}[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#{indent_str} " # 最終行には出さない if subsc # 配列添数 subsc_str = '[#{subsc}]' else subsc_str = "" end eport = @entry_port_name # RPCの受け口名に変更 file.print "#{eport}#{subsc_str}.#{func}.#{buf} = #{alloc_str}" end file.puts ")]" end # マーシャラセル本体生成 file.print <<EOT /* OpaqueRPC Marshaler Cell */ #{indent_str}cell #{@marshaler_celltype_name} #{@cell_name} { #{indent_str} cTDR = #{@shared_channel_cell}.eTDR; #{indent_str} cLockChannel = #{@shared_channel_cell}.eSemaphore[#{@sub_channel_no}]; #{indent_str}}; EOT # @caller_cell.get_region.gen_region_str_post file @start_region.gen_region_str_post file # アンマーシャラセルの出力 # セル本体の生成 nest = @end_region.gen_region_str_pre file file.print <<EOT /* Server Channel Cell prototype */ #{indent_str}cell #{@shared_channel_server_ct_name} #{@sharedChannelName}_Server; EOT # PPAllocator が必要か? if @PPAllocatorSize if @sub_channel_no == 0 file.print <<EOT #{indent_str}cell tPPAllocator PPAllocator_#{@shared_channel_cell}{ #{indent_str} heapSize = #{@PPAllocatorSize}; #{indent_str}}; EOT end ppallocator_join = "#{indent_str} cPPAllocator = PPAllocator_#{@shared_channel_cell}.ePPAllocator;\n" else ppallocator_join = "" end file.print <<EOT #{indent_str}cell #{@unmarshaler_celltype_name} #{@cell_name}_Server { #{indent_str} cTDR = #{@shared_channel_cell}_Server.eTDR; #{indent_str} cServerCall = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript}; #{ppallocator_join}#{indent_str}}; EOT @end_region.gen_region_str_post file end |
#set_sharedChannelName(rhs) ⇒ Object
プラグイン引数 sharedChannelCell のチェック
115 116 117 118 119 120 121 122 |
# File 'lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb', line 115 def set_sharedChannelName(rhs) @sharedChannelName = rhs # path = [ "::", rhs ] # obj = Namespace.find( path ) # if ! obj.instance_of?( Cell ) then # cdl_error( "SharedOpaqueRPCPlugin: sharedChannelName '#{rhs}' not cell" ) # end end |