Changeset 429 for EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin
- Timestamp:
- Jul 3, 2020, 7:19:17 PM (4 years ago)
- Location:
- EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin
- Files:
-
- 18 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/DomainPlugin.rb
r321 r429 46 46 #option::String : domain 指定子の第二引数 47 47 def initialize( region, domain_type_name, option ) 48 super() 48 49 end 49 50 … … 77 78 return false 78 79 end 80 81 #== ドメイン種別を返す 82 #return::Symbol :kernel, :user, :OutOfDomain 83 def get_kind 84 :kernel 85 end 86 87 #== factory 生成 88 # DomainPlugin の factory は特定のファイルへの出力が想定されていない 89 def gen_factory 90 end 79 91 end -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2AlarmHandlerPlugin.rb
r321 r429 34 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 35 # の責任を負わない. 36 # 37 # $Id: HRP2AlarmHandlerPlugin.rb 2640 2017-06-03 11:27:12Z okuma-top $ 36 38 # 37 39 #++ … … 50 52 def print_cfg_cre(file, cell, val, tab) 51 53 val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" ) 52 # $cbp$ の代わり53 index = cell.get_id - @celltype.get_id_base54 cell_CB _name = "#{@celltype.get_global_name}_CB_tab[#{index}]"54 # $cbp$ #983 55 name_array = @celltype.get_name_array cell 56 cell_CBP = name_array[8] # CBP 55 57 # CRE_XXXの生成 56 58 if (cell.get_region.get_region_type != :DOMAIN) || (cell.get_region.get_param != :KERNEL_DOMAIN) … … 59 61 else 60 62 file.print <<EOT 61 #{tab}CRE_ALM(#{val[:id]}, { #{val[:attribute]}, &#{cell_CB_name}, tAlarmHandler_start });63 #{tab}CRE_ALM(#{val[:id]}, { #{val[:attribute]}, #{cell_CBP}, tAlarmHandler_start }); 62 64 EOT 63 65 end -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2CyclicHandlerPlugin.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 2by TOPPERS Project6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 … … 51 52 def print_cfg_cre(file, cell, val, tab) 52 53 val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" ) 53 # $cbp$ の代わり54 index = cell.get_id - @celltype.get_id_base55 cell_CB _name = "#{@celltype.get_global_name}_CB_tab[#{index}]"54 # $cbp$ #983 55 name_array = @celltype.get_name_array cell 56 cell_CBP = name_array[8] # CBP 56 57 # CRE_XXXの生成 57 58 if (cell.get_region.get_region_type != :DOMAIN) || (cell.get_region.get_param != :KERNEL_DOMAIN) … … 60 61 else 61 62 file.print <<EOT 62 #{tab}CRE_CYC(#{val[:id]}, { #{val[:attribute]}, &#{cell_CB_name}, tCyclicHandler_start, #{val[:cyclicTime]}, #{val[:cyclicPhase]} });63 #{tab}CRE_CYC(#{val[:id]}, { #{val[:attribute]}, #{cell_CBP}, tCyclicHandler_start, #{val[:cyclicTime]}, #{val[:cyclicPhase]} }); 63 64 EOT 64 65 end -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2DataqueuePlugin.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 2by TOPPERS Project6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2EventflagPlugin.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 2by TOPPERS Project6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2FixedSizeMemoryPoolPlugin.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 2by TOPPERS Project6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2HandlerPlugin.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 4by TOPPERS Project6 # Copyright (C) 2008-2018 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 39 40 #require "HRP2KernelObjectPlugin" 40 41 require_tecsgen_lib "HRP2KernelObjectPlugin.rb" 41 42 42 43 43 #== celltype プラグインの共通の親クラス … … 51 51 # tab : 52 52 def print_cfg_cre(file, cell, val, tab) 53 val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" ) 54 # $cbp$の代わり 55 index = cell.get_id - @celltype.get_id_base 56 cell_CB_name = "#{@celltype.get_global_name}_CB_tab[#{index}]" 53 if !val[:id].nil? 54 val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" ) 55 end 56 # $cbp$ #983 57 name_array = @celltype.get_name_array cell 58 cell_CBP = name_array[8] # CBP 57 59 # CRE_XXXの生成 58 60 domainOption = cell.get_region.get_domain_root.get_domain_type.get_option … … 63 65 elsif @plugin_arg_str == "ALARM" 64 66 file.print <<EOT 65 #{tab}CRE_ALM(#{val[:id]}, { #{val[:attribute]}, &#{cell_CB_name}, tAlarmHandler_start });67 #{tab}CRE_ALM(#{val[:id]}, { #{val[:attribute]}, #{cell_CBP}, tAlarmHandler_start }); 66 68 EOT 67 69 elsif @plugin_arg_str == "CYCLIC" 68 70 file.print <<EOT 69 #{tab}CRE_CYC(#{val[:id]}, { #{val[:attribute]}, &#{cell_CB_name}, tCyclicHandler_start, #{val[:cyclicTime]}, #{val[:cyclicPhase]} }); 71 #{tab}CRE_CYC(#{val[:id]}, { #{val[:attribute]}, #{cell_CBP}, tCyclicHandler_start, #{val[:cyclicTime]}, #{val[:cyclicPhase]} }); 72 EOT 73 elsif @plugin_arg_str == "CONFIG_INT" 74 file.print <<EOT 75 #{tab}CFG_INT( #{val[:interruptNumber]}, { #{val[:attribute]}, #{val[:interruptPriority]} }); 76 EOT 77 elsif @plugin_arg_str == "ISR" 78 file.print <<EOT 79 #{tab}ATT_ISR({ #{val[:attribute]}, #{cell_CBP}, #{val[:interruptNumber]}, tISR_start, #{val[:priority]} }); 80 EOT 81 elsif @plugin_arg_str == "INIT_ROUTINE" 82 file.print <<EOT 83 #{tab}ATT_INI({ #{val[:attribute]}, #{cell_CBP}, tInitializeRoutine_start }); 84 EOT 85 elsif @plugin_arg_str == "TERM_ROUTINE" 86 file.print <<EOT 87 #{tab}ATT_TER({ #{val[:attribute]}, #{cell_CBP}, tTerminateRoutine_start }); 70 88 EOT 71 89 else … … 79 97 elsif @plugin_arg_str == "CYCLIC" 80 98 file.puts "SAC_CYC(#{val[:id]}, { #{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]} });" 99 elsif @plugin_arg_str == "CONFIG_INT" 100 # nothing to do 101 elsif @plugin_arg_str == "ISR" 102 # nothing to do 103 elsif @plugin_arg_str == "INIT_ROUTINE" 104 # nothing to do 105 elsif @plugin_arg_str == "TERM_ROUTINE" 106 # nothing to do 81 107 else 82 108 raise "#{@plugin_arg_str} is unknown option" -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2KernelObjectPlugin.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 2by TOPPERS Project6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 … … 185 186 val = {} 186 187 @celltype.get_attribute_list.each{ |a| 187 p a.get_name188 # p a.get_name 188 189 if a.get_type.kind_of?( ArrayType ) 189 190 val[a.get_name] = [] … … 217 218 if val[:id].nil? != true 218 219 puts val[:id] 219 val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" ) 220 #val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" ) 221 val[:id] = @celltype.subst_name( val[:id], @celltype.get_name_array( cell ) ) 220 222 end 221 223 # $cbp$の代わり … … 243 245 file2.puts "}\n" 244 246 else 245 print "~~~~~ #{cell.get_region.get_name.to_s} is included in"246 p @@region_list247 dbgPrint "~~~~~ #{cell.get_region.get_name.to_s} is included in" 248 # p @@region_list 247 249 end 248 250 file3 = AppFile.open( "#{$gen}/tecsgen_#{cell_domain_root.get_name.to_s}.cfg" ) … … 257 259 puts "===== end check my domain #{cell.get_name} =====" 258 260 # SAC_XXXの生成 259 puts "===== begin check regions #{cell.get_name} =====" 260 p val[:accessPattern] 261 p val[:accessPattern].class 262 263 #ep = [ :eTaskActivate, :eTaskControl, :eTaskManage, :eTaskRefer ] 264 #各カーネルオブジェクトの受け口名を取得 265 # ep = get_entry_ports_name_list() 266 i = 0 267 acv = [] 268 # アクセス許可ベクタの生成 269 val[:accessPattern].each { |acptnx| 270 # アクセス許可パターンの生成 271 if acptnx != "OMIT" 272 acv << acptnx 273 p acv[i] 274 elsif cell_domain_type.get_option.to_s == "trusted" 275 acv << "TACP_KERNEL" 276 p acv[i] 277 elsif cell_domain_type.get_option.to_s != "OutOfDomain" 278 acv << "TACP(#{cell_domain_root.get_name.to_s})" 261 if !val[:accessPattern].nil? 262 puts "===== begin check regions #{cell.get_name} =====" 263 # p val[:accessPattern] 264 # p val[:accessPattern].class 265 266 #ep = [ :eTaskActivate, :eTaskControl, :eTaskManage, :eTaskRefer ] 267 #各カーネルオブジェクトの受け口名を取得 268 # ep = get_entry_ports_name_list() 269 i = 0 270 acv = [] 271 # アクセス許可ベクタの生成 272 val[:accessPattern].each { |acptnx| 273 # アクセス許可パターンの生成 274 if acptnx != "OMIT" 275 acv << acptnx 276 # p acv[i] 277 elsif cell_domain_type.get_option.to_s == "trusted" 278 acv << "TACP_KERNEL" 279 # p acv[i] 280 elsif cell_domain_type.get_option.to_s != "OutOfDomain" 281 acv << "TACP(#{cell_domain_root.get_name.to_s})" 282 else 283 acv << "TACP_SHARED" 284 end 285 286 i += 1 287 } 288 289 dbgPrint "acv = " 290 p acv 291 292 #各種SACの生成 293 domainOption = cell_domain_type.get_option 294 # if cell.get_region.get_region_type == :DOMAIN 295 if domainOption != "OutOfDomain" 296 # 保護ドメインに属する場合 297 file3 = AppFile.open( "#{$gen}/tecsgen_#{cell.get_region.get_name.to_s}.cfg" ) 298 print_cfg_sac(file3, val, acv) 299 file3.close 279 300 else 280 acv << "TACP_SHARED" 301 # 無所属の場合 302 print_cfg_sac(file2, val, acv) 281 303 end 282 304 283 i += 1 284 } 285 286 print "acv = " 287 p acv 288 289 #各種SACの生成 290 domainOption = cell_domain_type.get_option 291 # if cell.get_region.get_region_type == :DOMAIN 292 if domainOption != "OutOfDomain" 293 # 保護ドメインに属する場合 294 file3 = AppFile.open( "#{$gen}/tecsgen_#{cell.get_region.get_name.to_s}.cfg" ) 295 print_cfg_sac(file3, val, acv) 296 file3.close 297 else 298 # 無所属の場合 299 print_cfg_sac(file2, val, acv) 305 puts "===== end check regions #{cell.get_name} =====" 300 306 end 301 302 puts "===== end check regions #{cell.get_name} ====="303 307 end 304 308 } … … 319 323 320 324 def self.check_referenced_cells() 321 puts "===== begin check registered celltype ====="325 dbgPrint "===== begin check registered celltype =====\n" 322 326 self.get_celltype_list.each { |ct| 323 p ct.get_name.to_s327 dbgPrint( ct.get_name.to_s + "\n" ) 324 328 } 325 puts "===== end check registered celltype ====="329 dbgPrint "===== end check registered celltype =====\n" 326 330 327 331 =begin … … 331 335 j = cell.get_join_list.get_item(p.get_name) 332 336 printf "===== check call port : " 333 p p.get_name.to_s337 # p p.get_name.to_s 334 338 next if j.nil? # 未結合の場合 335 339 if @@celltype_list.include?(j.get_celltype) … … 338 342 j.get_cell.set_referenced_cell(cell, j.get_port_name) 339 343 printf "===== check joined rhs cell : " 340 p j.get_cell.get_name.to_s344 # p j.get_cell.get_name.to_s 341 345 printf "===== check joined rhs port_name : " 342 p j.get_port_name346 # p j.get_port_name 343 347 end 344 348 } -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2ObjectPlugin.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 4by TOPPERS Project6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2Plugin.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 201 4by TOPPERS Project6 # Copyright (C) 2018 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 … … 43 44 44 45 def initialize( region, name, option ) 45 print "MyDomainPlugin: initialize: region=#{region.get_name}, domainName=#{name}, option=#{option}\n" 46 super 47 print "HRP2Plugin: initialize: region=#{region.get_name}, domainName=#{name}, option=#{option}\n" 48 @region = region 49 @name = name 50 51 case option 52 when "trusted", "nontrusted", "OutOfDomain" 53 # OK 54 @option = option 55 else 56 cdl_error( "HRPPlugin: '$1' is unacceptable domain kind, specify 'trusted' or 'nontrusted'", option ) 57 @option = "trusted" # とりあえず trusted を設定しておく 58 end 46 59 end 47 60 … … 54 67 # get_rhs_subscript:Integer or nil 受け口配列の添数 (Join::@rhs_subscript の説明参照) 55 68 # return [] 56 print " MyDomainPlugin: add_through_plugin: #{current_region.get_name}=>#{next_region.get_name}, #{join.get_owner.get_name}.#{join.get_definition.get_name}=>#{join.get_cell.get_name}.#{join.get_port_name}, #{through_type}\n"69 print "HRP2Plugin: add_through_plugin: #{current_region.get_name}=>#{next_region.get_name}, #{join.get_owner.get_name}.#{join.get_definition.get_name}=>#{join.get_cell.get_name}.#{join.get_port_name}, #{through_type}\n" 57 70 58 71 puts "=====Join Check Start=====" … … 107 120 end 108 121 122 #== ドメイン種別を返す 123 #return::Symbol :kernel, :user, :OutOfDomain 124 def get_kind 125 case @option 126 when "trusted" 127 return :kernel 128 when "nontrusted" 129 return :user 130 when "OutOfDomain" 131 return :OutOfDomain 132 end 133 end 134 109 135 def joinable?(current_region, next_region, through_type ) 110 print " MyDomainPlugin: joinable? from #{current_region.get_name} to #{next_region.get_name} (#{through_type})\n"136 print "HRP2Plugin: joinable? from #{current_region.get_name} to #{next_region.get_name} (#{through_type})\n" 111 137 return true 112 138 end -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2PostHook.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 201 2by TOPPERS Project6 # Copyright (C) 2017 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2RPCPlugin.rb
r321 r429 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 … … 70 71 #=== RPCPlugin の initialize 71 72 # 説明は ThroughPlugin (plugin.rb) を参照 72 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )73 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell ) 73 74 super 74 75 @b_noClientSemaphore = false … … 234 235 if cell.get_allocator_list.length > 0 then 235 236 236 dbgPrint "make allocator "237 dbgPrint "make allocator\n" 237 238 file.print "#{indent_str}[allocator(" 238 239 … … 269 270 nest = @end_region.gen_region_str_pre file 270 271 indent_str = " " * nest 272 nest_str = " " * nest 273 if @next_cell_port_subscript then 274 subscript = '[' + @next_cell_port_subscript.to_s + ']' 275 else 276 subscript = "" 277 end 271 278 272 279 file.print <<EOT 273 280 #{indent_str}cell #{@rpc_channel_celltype_name}Server #{@cell_name}Body { 274 #{indent_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name} ;281 #{indent_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript}; 275 282 //#{indent_str} #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name}; 276 283 #{indent_str} //cTDR = #{@channelCellName}.eTDR; -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2SVCPlugin.rb
r321 r429 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 … … 83 84 @@generated_celltype_header = {} 84 85 85 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )86 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell ) 86 87 super 87 88 @ct_name_body = "#{@ct_name}SVCBody_#{@next_cell.get_name}_#{@next_cell_port_name}".to_sym … … 217 218 nest = @end_region.gen_region_str_pre file 218 219 nest_str = " " * nest 220 if @next_cell_port_subscript then 221 subscript = '[' + @next_cell_port_subscript.to_s + ']' 222 else 223 subscript = "" 224 end 219 225 220 226 # サーバー側チャンネルの生成 … … 224 230 #{nest_str} // Server Side Channel 225 231 #{nest_str} cell #{@ct_name_body} #{@cell_name_body}{ 226 #{nest_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name} ;232 #{nest_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript}; 227 233 #{nest_str} }; 228 234 EOT … … 241 247 nest = @start_region.gen_region_str_pre file 242 248 nest_str = " " * nest 249 if @next_cell_port_subscript then 250 subscript = '[' + @next_cell_port_subscript.to_s + ']' 251 else 252 subscript = "" 253 end 243 254 244 255 # クライアント側チャンネルの生成 … … 247 258 #{nest_str} // Client Side Channel 248 259 #{nest_str} cell #{@ct_name} #{@cell_name}{ 249 #{nest_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name} ;260 #{nest_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript}; 250 261 #{nest_str} }; 251 262 -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2TaskPlugin.rb
r321 r429 35 35 # の責任を負わない. 36 36 # 37 # $Id$ 37 38 #++ 38 39 … … 52 53 # tab : 53 54 def print_cfg_cre(file, cell, val, tab) 54 val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" ) 55 #val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_global_name.to_s}" ) 56 #val[:id] = @celltype.subst_name( val[:id], @celltype.get_name_array( cell ) ) 55 57 # $cbp$の代わり 56 58 index = cell.get_id - @celltype.get_id_base … … 58 60 cell_CB_name = "#{index}" 59 61 # CRE_XXX/DEF_XXXの生成 60 print "assign task plugin\n"62 dbgPrint "assign task plugin\n" 61 63 domainOption = cell.get_region.get_domain_root.get_domain_type.get_option 62 64 # if cell.get_region.get_region_type == :DOMAIN 65 # cell.show_tree 1 63 66 if domainOption != "OutOfDomain" 64 67 # 保護ドメインに属する場合 … … 68 71 raise "system task cannot have user stack." 69 72 end 73 p "CRE_TSK 0 user=#{val[:userStackSize]} system=#{val[:systemStackSize]}" 70 74 file.print <<EOT 71 75 #{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:systemStackSize]}, NULL }); … … 76 80 raise "user task must have user stack." 77 81 end 82 p "CRE_TSK 1" 78 83 if val[:systemStackSize] == "OMIT" 79 84 file.print <<EOT … … 81 86 EOT 82 87 else 88 p "CRE_TSK 2" 83 89 file.print <<EOT 84 90 #{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:userStackSize]}, NULL, #{val[:systemStackSize]}, NULL }); … … 121 127 ct = cell.get_celltype 122 128 if ct.class == Celltype && check_celltype_list.include?( ct ) == false 129 # チェック済みセルタイプに登録 130 check_celltype_list << ct 131 123 132 # 未チェックのセルタイプだった場合 124 133 # puts "check for ATT_MOD : #{ct.classget_global_name}" … … 134 143 regions = ct.get_domain_roots 135 144 regions_hrp2 = regions[ :HRP2 ] 136 print "HRP2 domain in #{ct.get_name}: "145 dbgPrint "HRP2 domain in #{ct.get_name}: " 137 146 regions_hrp2.each { |reg| 138 print reg.get_name147 dbgPrint reg.get_name 139 148 } 140 149 puts "" … … 179 188 file.print "ATT_MOD(\"#{ct.get_global_name}.o\");\n" 180 189 file.close 181 182 check_celltype_list << ct183 190 else 184 191 # 何もしない -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgePlugin.rb
r321 r429 3 3 # mruby => TECS bridge 4 4 # 5 # Copyright (C) 2008-201 5by TOPPERS Project5 # Copyright (C) 2008-2017 by TOPPERS Project 6 6 # 7 7 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 37 37 # 38 38 39 # Todo: 40 # 生成するもの 41 # gen_cdl_file 42 # ブリッジ初期化セルタイプ (シグニチャごと) 43 # @@init_celltypes に記録 44 # ブリッジセルタイプ (シグニチャごと) 45 # @@celltypes に記録 46 # 構造体セルタイプ 47 # @@struct_list に記録 48 # new_cell 49 # TECS 初期化セル(プロトタイプ宣言) 50 # @@VM_init_cells に記録 51 # @@VM_struct_list に記録 52 # @@VM_ptr_list に記録 53 # gen_post_code 54 # 構造体初期化セル 55 # ポインタ初期化セル 56 # TECS 初期化セル 57 # 58 # ep_func の作成 59 # signature, ポインタ、構造体 … 初期化受け口=mruby VM への登録 60 # ポインタ 61 # preamble の作成 62 # ポインタ、構造体 … アクセス用コードの生成 63 # signature … ブリッジ関数のプロトタイプ宣言 64 # postamble の作成 65 # signature … ブリッジ関数の定義 66 67 class MrubyBridgePlugin < SignaturePlugin 68 69 # プラグイン引数名 => Proc 70 MrubyBridgePluginArgProc = { 71 "ignoreUnsigned" => Proc.new { |obj,rhs| obj.set_ignoreUnsigned rhs }, 72 "include" => Proc.new { |obj,rhs| obj.set_include rhs }, 73 "exclude" => Proc.new { |obj,rhs| obj.set_exclude rhs }, 74 } 75 76 @@celltypes = { } # {celltype_name => [ BridgePlugin のインスタンスの配列 } 77 @@init_celltypes = { } # {celltype_name => [ BridgePlugin のインスタンスの配列 } 78 @@struct_list = { } # {struct_name=>StructType} 79 @@ptr_list = { } # {ptr_celltype_name=> @@TYPE_MAP の対応するもの} 80 @@VM_list = { } # VM_name => true 81 @@VM_celltypes = { } # VM_name => { @celltype_name => セルの配列 } 82 @@VM_struct_list = { } # {name=>StructType} 83 @@VM_ptr_list = { } # { VM_name => {name=> @@TYPE_MAP の対応するもの} } 84 @@TYPE_MAP = { # type_str class GET_SET 85 :char_t => [:char_t, "Char", :Char, :INT ], 86 :uchar_t => [:uchar_t, "UChar", :Char, :INT ], 87 :schar_t => [:schar_t, "SChar", :Char, :INT ], 88 89 :bool_t => [:bool_t, "Bool", :Bool, :BOOL ], 90 :int8_t => [:int8_t, "Int8", :Int, :INT ], 91 :int16_t => [:int16_t, "Int16", :Int, :INT ], 92 :int32_t => [:int32_t, "Int32", :Int, :INT ], 93 :int64_t => [:int64_t, "Int64", :Int, :INT ], 94 :uint8_t => [:uint8_t, "UInt8", :Int, :INT ], 95 :uint16_t => [:uint16_t, "UInt16", :Int, :INT ], 96 :uint32_t => [:uint32_t, "UInt32", :Int, :INT ], 97 :uint64_t => [:uint64_t, "UInt64", :Int, :INT ], 98 99 :int => [:int, "Int", :Int, :INT ], 100 :char => [:char, "Char", :Char, :INT ], # char は char_t として扱う 101 :short => [:short, "Short", :Int, :INT ], 102 :long => [:long, "Long", :Int, :INT ], 103 104 :"unsigned char" => [:uchar_t, "UChar", :Char, :INT ], 105 :"unsigned int" => [:"unsigned int", "UInt", :Int, :INT ], 106 :"unsigned short" => [:"unsigned short", "UShort", :Int, :INT ], 107 :"unsigned long" => [:"unsigned long", "ULong", :Int, :INT ], 108 :"signed char" => [:schar_t, "SChar", :Char, :INT ], 109 :"signed int" => [:int, "Int", :Int, :INT ], 110 :"signed short" => [:short, "Short", :Int, :INT ], 111 :"signed long" => [:long, "Long", :Int, :INT ], 112 113 :float32_t => [:float32_t, "Float32", :Float, :FLOAT ], 114 :double64_t => [:double64_t,"Double64", :Float, :FLOAT ], 115 116 :float => [:float, "Float32", :Float, :FLOAT ], 117 :double => [:double, "Double64", :Float, :FLOAT ] 118 } 119 120 # included or excluded functions 121 122 ### ロードされた時点で実行される ### 123 124 # -I に $(TECSPATH)/mruby を追加 125 # TECSGEN::Makefile.add_obj "$(MRUBY_MAIN_OBJ)" 126 TECSGEN::Makefile.add_ldflag "-lmruby -L$(MRUBYPATH)/lib -lm" 127 TECSGEN::Makefile.add_search_path "$(MRUBYPATH)/include" 128 TECSGEN::Makefile.add_var "MRUBYPATH", "..", "CHANGE this to suitable path" 129 # TECSGEN::Makefile.add_var "MRUBY_MAIN_OBJ", "$(_TECS_OBJ_DIR)tecs_mruby.o", "CHANGE this if your have your main" 130 131 132 #=== プラグインインスタンスの初期化 133 # 戻り値、引数の型が使用可能なものかチェックする 134 # 135 def initialize( signature, option ) 136 super 137 138 if ! $no_banner 139 STDERR << "MrubyBridgePlugin: version 1.2.0 (Suitable for mruby ver 1.2.0. Has backward compatibility with ver 1.1.0)\n" 140 end 141 142 @b_ignoreUnsigned = false 143 @includes = [] 144 @excludes = [] 145 @struct_list = { } 146 @ptr_list = { } 147 148 @plugin_arg_check_proc_tab = MrubyBridgePluginArgProc 149 parse_plugin_arg 150 151 @celltype_name = :"t#{@signature.get_global_name}" 152 @init_celltype_name = :"#{@celltype_name}_Initializer" 153 # this variable is sometimes not used. rhs coded directry. 154 @class_name = :"T#{@signature.get_global_name}" 155 156 @func_head_array = [] 157 if @includes.length > 0 && @excludes.length > 0 then 158 cdl_error( "MRB1011 both include && exclude are specified" ) 159 end 160 161 if signature.get_function_head_array == nil then 162 return # 以前に文法エラー発生 163 end 164 165 signature.get_function_head_array.each{ |func_head| 166 if @includes.length > 0 then 167 if @includes.index func_head.get_name then 168 dbgPrint "MrubyBridgePlugin: #{func_head.get_name} INCLUDED\n" 169 @func_head_array << func_head 170 else 171 dbgPrint "MrubyBridgePlugin: #{func_head.get_name} NOT included\n" 172 end 173 elsif @excludes.length > 0 then 174 if @excludes.index( func_head.get_name ) == nil then 175 dbgPrint "MrubyBridgePlugin: #{func_head.get_name} NOT excluded\n" 176 @func_head_array << func_head 177 else 178 dbgPrint "MrubyBridgePlugin: #{func_head.get_name} EXCLUDED\n" 179 end 180 else 181 @func_head_array << func_head 182 end 183 } 184 185 if @func_head_array.length == 0 then 186 cdl_error( "MRB1012 '$1' no function remained by exclude", @signature.get_name ) 187 end 188 189 check_name_and_return_type @func_head_array 190 check_parameter_type @func_head_array 191 192 end 193 194 #=== check function name & return type 195 def check_name_and_return_type func_head_array 196 b_init = false; b_init_cell = false 197 func_head_array.each{ |func_head| 198 if( func_head.get_name == :initialize )then 199 cdl_warning( "MRW2001 initialize: internally defined. change to initialize_cell in ruby" ) 200 b_init = true 201 elsif( func_head.get_name == :initialize_cell )then 202 b_init_cell = true 203 end 204 rtype = func_head.get_return_type.get_original_type 205 case rtype 206 when BoolType, IntType, FloatType, VoidType 207 else 208 cdl_error( "MRB1001 cannot return type $1", rtype.get_type_str ) 209 end 210 } 211 if( b_init && b_init_cell )then 212 cdl_warning( "MRB1002 initialize: internally defined. change to initialize_cell in ruby" ) 39 #== MrubyBridgePlugin クラス 40 class MrubyBridgePlugin < MultiPlugin 41 def self.get_plugin superClass 42 # case when (つまりは ===) では、期待したように一致しない模様 43 if superClass == SignaturePlugin then 44 dbgPrint "MrubyBridgePlugin: SignaturePlugin" 45 require_tecsgen_lib 'tecslib/plugin/MrubyBridgeSignaturePlugin.rb' 46 return MrubyBridgeSignaturePlugin 47 elsif superClass == CelltypePlugin 48 dbgPrint "MrubyBridgePlugin: CelltypePlugin" 49 require_tecsgen_lib 'tecslib/plugin/MrubyBridgeCelltypePlugin.rb' 50 return MrubyBridgeCelltypePlugin 51 elsif superClass == CompositePlugin 52 dbgPrint "MrubyBridgePlugin: CompositePlugin" 53 require_tecsgen_lib 'tecslib/plugin/MrubyBridgeCompositePlugin.rb' 54 return MrubyBridgeCompositePlugin 55 elsif superClass == CellPlugin 56 dbgPrint "MrubyBridgePlugin: CellPlugin" 57 require_tecsgen_lib 'tecslib/plugin/MrubyBridgeCellPlugin.rb' 58 return MrubyBridgeCellPlugin 59 #elsif superClass == ThroughPlugin 60 # return ThroughPlugin 61 #elsif superClass == DomainPlugin 62 # return DomainPlugin 63 else 64 dbgPrint "MrubyBridgePlugin: unsupported" 65 return nil 213 66 end 214 67 end 215 216 #=== check paramter type217 def check_parameter_type func_head_array218 # check type of parameters219 func_head_array.each{ |fh|220 fh.get_paramlist.get_items.each{ |param_decl|221 case param_decl.get_direction222 when :SEND, :RECEIVE223 cdl_error( "MRB1003 $1: $2 parameter cannot be used in mruby Bridge", param_decl.get_name, param_decl.get_direction.to_s.downcase )224 end225 type = param_decl.get_type226 type_org = type.get_original_type227 type_str = type.get_type_str + type.get_type_str_post228 229 b_ng = false230 case type_org231 when IntType232 case type_org.get_bit_size233 when 8, 16, 32, 64234 when -1, -2, -3, -4, -11235 else236 b_ng = true237 end238 when BoolType239 when FloatType240 when PtrType241 ttype_org = type_org.get_type # ポインタの指している先の型242 ttype = ttype_org.get_original_type # 上記の typedef されている場合、元の型243 register_ptr_type ttype_org244 245 if( type_org.get_string.to_s == "-1" ) then246 case param_decl.get_direction247 when :OUT, :INOUT248 cdl_error( "MRB9999 string specifier without length cannot be used for out & inout parameter")249 end250 end251 252 case ttype253 when IntType254 bit_size = ttype.get_bit_size255 # if bit_size < 0 && bit_size != -1 then256 # b_ng = true257 # end258 when FloatType259 when BoolType260 when StructType261 if( type_org.get_size || type_org.get_string || type_org.get_count ) then262 cdl_error( "MRB1004 $1: size_is, count_is, string cannot be specified for struct pointer", param_decl.get_name )263 end264 check_struct_member ttype_org265 else266 b_ng = true267 end268 when StructType269 check_struct_member type_org270 else # ArrayType, FuncType, EnumType, VoidType271 b_ng = true272 end273 if b_ng then274 cdl_error( "MRB1005 $1: type $2 cannot be used in mruby Bridge", param_decl.get_name, type_str )275 end276 }277 }278 end279 280 #=== 構造体のメンバーの型のチェック281 def check_struct_member struct_type282 #p "tag name:#{struct_type.get_name}"283 # sttype = Namespace.find_tag( struct_type.get_name )284 sttype = struct_type.get_original_type285 if sttype.get_name == nil then286 cdl_error( "MRB10007 tagless-struct cannot be handled")287 end288 sttype.get_members_decl.get_items.each { |d|289 t = d.get_type.get_original_type290 case t291 when IntType, FloatType, BoolType292 else293 cdl_error( "MRB1006 $1: type $2 not allowed for struct member", d.get_name, d.get_type.get_type_str + d.get_type.get_type_str_post )294 end295 }296 st_name = :"t{}"297 if @struct_list[ sttype.get_name ] == nil then298 # print_msg " MrubyBridgePlugin: [struct] #{struct_type.get_type_str} => class TECS::Struct#{sttype.get_name}\n"299 print " MrubyBridgePlugin: [struct] #{struct_type.get_type_str} => class TECS::Struct#{sttype.get_name}\n"300 @struct_list[ sttype.get_name ] = sttype301 end302 end303 304 def register_ptr_type ttype305 t_org = ttype.get_original_type306 tment = get_type_map_ent t_org307 if tment == nil then308 return309 cdl_error( "MRB1008 unknown pointer type '$1'", ttype.get_type_str )310 end311 ptr_celltype_name = :"t#{tment[1]}Pointer"312 if @@ptr_list[ ptr_celltype_name ] == nil then313 # print_msg " MrubyBridgePlugin: [pointer] #{ttype.get_type_str}* => class TECS::#{tment[1]}Pointer\n"314 print " MrubyBridgePlugin: [pointer] #{ttype.get_type_str}* => class TECS::#{tment[1]}Pointer\n"315 @@ptr_list[ ptr_celltype_name ] = tment316 end317 if @ptr_list[ ptr_celltype_name ] == nil then318 @ptr_list[ ptr_celltype_name ] = tment319 end320 end321 322 def get_type_map_ent ttype323 # structure type is registerd in check_struct_member324 if ttype.kind_of? StructType325 return326 end327 tstr = ttype.get_type_str.sub( /const /, "" ) # const は無視328 tstr = tstr.sub( /volatile /, "" ) # volatile も無視329 if @b_ignoreUnsigned then330 tstr = tstr.sub( /unsigned /, "" ) # volatile も無視331 tstr = tstr.sub( /uint/, "int" ) # volatile も無視332 tstr = tstr.sub( /[cs]char/, "char" ) # volatile も無視333 end334 return @@TYPE_MAP[ tstr.to_sym ]335 end336 337 #=== CDL ファイルの生成338 # typedef, signature, celltype, cell コードを生成339 #file:: FILE 生成するファイル340 def gen_cdl_file(file)341 342 # ブリッジセルタイプの生成343 if @@celltypes[ @celltype_name ] == nil then344 @@celltypes[ @celltype_name ] = [ self ]345 @@init_celltypes[ @init_celltype_name ] = true346 print_msg <<EOT347 MrubyBridgePlugin: [signature] #{@signature.get_namespace_path} => [celltype] nMruby::#{@celltype_name} => [class] TECS::#{@class_name}348 EOT349 350 file.print <<EOT351 import( <mruby.cdl> );352 353 /**** Ruby => TECS Bridge Celltype (MBP500) ****/354 namespace nMruby{355 // bridge celltype356 [idx_is_id,active] // not actually active, to avoid warning W1002, W1007357 celltype #{@celltype_name} {358 call #{@signature.get_namespace_path.to_s} cTECS;359 attr {360 [omit]361 char_t *VMname = "VM";362 };363 };364 // bridge initializer celltype365 celltype #{@init_celltype_name} {366 entry sInitializeTECSBridge eInitialize;367 };368 };369 EOT370 371 # 構造体セルタイプの生成372 @struct_list.each{ |name, sttype|373 if @@struct_list[ name ] == nil then374 file.print <<EOT375 namespace nMruby{376 [singleton]377 celltype #{name} {378 entry sInitializeTECSBridge eInitialize;379 };380 };381 EOT382 @@struct_list[ name ] = sttype383 end384 }385 386 else387 cdl_warning( "MRBW001 MrubyBridgePlugin: signature '$1' duplicate. ignored current one", @signature.get_namespace_path )388 @@celltypes[ @celltype_name ] << self389 end390 end391 392 #=== gen_cdl_file で定義したセルタイプに 新しいセルが定義された393 # cell のセルタイプの名前は @celltype_name394 def new_cell cell395 if cell.get_celltype.get_name != @celltype_name then396 return397 end398 399 join = cell.get_join_list.get_item :VMname400 if join then401 vm_name = CDLString.remove_dquote(join.get_rhs.to_s).to_sym402 else403 vm_name = :"VM"404 end405 406 if @@VM_list[ vm_name ] == nil then407 @@VM_list[ vm_name ] = true408 409 initializer_celltype_cdl = "#{$gen}/#{cell.get_name}Initializer.cdl"410 file = CFile.open( initializer_celltype_cdl, "w" )411 412 # TECS 初期化セル(プロトタイプ宣言)413 print_msg " MrubyBridgePlugin: join your VM's cInitialize to #{vm_name}_TECSInitializer.eInitialize\n"414 415 file.print <<EOT416 417 // prototype of TECSInitializer (MBP510)418 cell nMruby::tTECSInitializer #{vm_name}_TECSInitializer;419 EOT420 file.close421 422 Generator.parse( initializer_celltype_cdl, self )423 end424 425 if @@VM_celltypes[ vm_name ] then426 vma = @@VM_celltypes[ vm_name ]427 428 if vma[ @celltype_name ] then429 vma[ @celltype_name ] << cell430 else431 vma[ @celltype_name ] = [cell]432 @@VM_celltypes[ vm_name ] = vma433 end434 else435 vma = { }436 vma[ @celltype_name ] = [cell]437 @@VM_celltypes[ vm_name ] = vma438 end439 440 @struct_list.each{ |stname, sttype|441 if @@VM_struct_list[ vm_name ] then442 @@VM_struct_list[ vm_name ][ sttype.get_name ] = sttype443 else444 @@VM_struct_list[ vm_name ] = { sttype.get_name => sttype }445 end446 }447 @ptr_list.each{ |ptr_celltype_name, tment|448 if @@VM_ptr_list[ vm_name ] then449 @@VM_ptr_list[ vm_name ][ ptr_celltype_name ] = tment450 else451 @@VM_ptr_list[ vm_name ] = { ptr_celltype_name => tment }452 end453 }454 455 end456 457 #=== プラグインが CDL の POST コードを生成458 # tmp_plugin_post_code.cdl への出力459 def self.gen_post_code file460 461 # file.print <<EOT462 # namespace nMruby {463 # EOT464 #465 # @@ptr_list.each{ |name,tment|466 # file.print <<EOT467 #468 # // MBP600469 # [singleton]470 # celltype #{name} {471 # entry sInitializeTECSBridge eInitialize;472 # };473 # EOT474 # }475 #476 # file.print <<EOT477 # };478 # EOT479 480 # gen_post_code で生成した celltype は gen_ep_func が呼び出されない #847481 # @@struct_list.each{ |name,sttype|482 # file.print <<EOT483 #484 # [singleton]485 # celltype #{name} {486 # entry sInitializeTECSBridge eInitialize;487 # };488 #EOT489 # }490 491 file.print " // MBP601\n"492 @@VM_celltypes.each{ |vm_name, instance_list|493 instance_list.each { |celltype_name, array|494 cell = array[0]495 if cell.get_celltype then496 ct_name = cell.get_celltype.get_name497 file.print <<EOT498 cell nMruby::#{ct_name}_Initializer #{vm_name}_#{ct_name}_Initializer{ };499 EOT500 end501 }502 }503 504 file.print " // MBP602\n"505 @@ptr_list.each{ |name,tment|506 file.print <<EOT507 cell nMruby::#{name} C#{name} { };508 EOT509 }510 511 file.print " // MBP603\n"512 @@struct_list.each{ |name,sttype|513 file.print <<EOT514 cell nMruby::#{name} C#{name} { };515 EOT516 }517 518 if @@VM_celltypes == nil519 raise "are0"520 end521 @@VM_celltypes.each{ |vm_name, instance_list|522 file.print " /* === VM #{vm_name} === (MBP610) */\n"523 init_cell_name = "#{vm_name}_TECSInitializer"524 525 file.print " cell nMruby::tTECSInitializer #{init_cell_name} {\n"526 527 instance_list.each { |celltype_name, array|528 array.each{ |cell|529 ct_name = cell.get_celltype.get_name530 file.print " cInitialize[] = #{vm_name}_#{ct_name}_Initializer.eInitialize;\n"531 }532 }533 if @@VM_ptr_list[vm_name] then534 @@VM_ptr_list[vm_name].each{ |name, tment|535 file.print " cInitialize[] = C#{name}.eInitialize;\n"536 }537 end538 if @@VM_struct_list[vm_name] then539 @@VM_struct_list[vm_name].each{ |name, sttype|540 file.print " cInitialize[] = C#{name}.eInitialize;\n"541 }542 end543 file.print " };"544 }545 546 end547 548 ####### 以下コード生成段階 ######549 550 #=== 受け口関数の本体コードを生成(頭部と末尾は別途出力)551 #ct_name:: Symbol (プラグインで生成された) セルタイプ名 .Symbol として送られてくる552 def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )553 if @@celltypes[ ct_name ] then554 gen_ep_func_body_bridge( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )555 elsif @@init_celltypes[ ct_name ] then556 gen_ep_func_body_bridge_init( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )557 elsif @@ptr_list[ ct_name ] then558 gen_ep_func_body_ptr( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )559 elsif @@struct_list[ ct_name ] then560 gen_ep_func_body_struct( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )561 else562 raise "Unknown #{ct_name}"563 end564 end565 566 def gen_ep_func_body_bridge( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )567 raise "unexpected "568 end569 570 def gen_ep_func_body_bridge_init( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )571 file.print <<EOT572 CELLCB *p_cellcb = GET_CELLCB( idx ); /* no error check */ /* MBP700 */573 struct RClass *rc;574 575 rc = mrb_define_class_under( mrb, TECS, \"#{@class_name}\", mrb->object_class );576 mrb_define_method( mrb, rc, "initialize", MrubyBridge_#{@celltype_name}_initialize, MRB_ARGS_REQ(1) );577 MRB_SET_INSTANCE_TT(rc, MRB_TT_DATA);578 EOT579 580 @func_head_array.each{ |f|581 if ! f.is_function? then582 next583 end584 if f.get_name != :initialize then585 func_name = f.get_name586 else587 func_name = :initialize_cell588 end589 590 ret_type = f.get_return_type591 n_param = 0592 f.get_paramlist.get_items.each{ |param|593 case param.get_direction594 when :IN, :INOUT, :OUT595 n_param += 1596 when :SEND, :RECEIVE597 raise "send, receive"598 end599 }600 if n_param > 0 then601 p_str = "MRB_ARGS_REQ( #{n_param} )"602 else603 p_str = "MRB_ARGS_NONE()"604 end605 file.print <<EOT606 mrb_define_method( mrb, rc, "#{func_name}", MrubyBridge_#{@celltype_name}_#{func_name}, #{p_str} );607 EOT608 }609 end610 611 def gen_ep_func_body_ptr( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )612 613 t = @@ptr_list[ct_name]614 type = t[1]615 file.print <<EOT616 struct RClass *a; /* MBP710 */617 618 a = mrb_define_class_under(mrb, TECS, "#{type}Pointer", mrb->object_class);619 MRB_SET_INSTANCE_TT(a, MRB_TT_DATA);620 621 mrb_define_method(mrb, a, "initialize", #{type}Pointer_initialize, MRB_ARGS_REQ(1));622 mrb_define_method(mrb, a, "[]", #{type}Pointer_aget, MRB_ARGS_REQ(1));623 mrb_define_method(mrb, a, "value", #{type}Pointer_get_val, MRB_ARGS_NONE());624 mrb_define_method(mrb, a, "[]=", #{type}Pointer_aset, MRB_ARGS_REQ(2));625 mrb_define_method(mrb, a, "value=", #{type}Pointer_set_val, MRB_ARGS_REQ(1));626 mrb_define_method(mrb, a, "size", #{type}Pointer_size, MRB_ARGS_NONE());627 mrb_define_method(mrb, a, "length", #{type}Pointer_size, MRB_ARGS_NONE());628 EOT629 630 if t[2] == :Char then631 file.print <<EOT632 mrb_define_method(mrb, a, "to_s", CharPointer_to_s, MRB_ARGS_NONE());633 mrb_define_method(mrb, a, "from_s", CharPointer_from_s, MRB_ARGS_REQ(1));634 EOT635 end636 end637 638 def gen_ep_func_body_struct( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )639 tag = ct_name640 structType = @@struct_list[ tag ]641 file.print <<EOT642 struct RClass *a; /* MBP720 */643 644 a = mrb_define_class_under(mrb, TECS, "Struct#{tag}", mrb->object_class);645 MRB_SET_INSTANCE_TT(a, MRB_TT_DATA);646 647 mrb_define_method(mrb, a, "initialize", Struct_#{tag}_initialize, MRB_ARGS_NONE());648 EOT649 650 structType.get_members_decl.get_items.each{ |d|651 file.print " STRUCT_INIT_MEMBER( #{tag}, #{d.get_name} )\n"652 }653 end654 655 #=== 受け口関数の preamble (C言語)を生成する656 # 必要なら preamble 部に出力する657 #file:: FILE 出力先ファイル658 #b_singleton:: bool true if singleton659 #ct_name:: Symbol660 #global_ct_name:: string661 def gen_preamble( file, b_singleton, ct_name, global_ct_name )662 if @@celltypes[ ct_name ] then663 gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )664 gen_preamble_instance( file, b_singleton, ct_name, global_ct_name )665 gen_preamble_instance_initialize( file, b_singleton, ct_name, global_ct_name )666 gen_preamble_bridge_func( file, b_singleton, ct_name, global_ct_name )667 elsif @@init_celltypes[ ct_name ] then668 gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )669 gen_preamble_instance_proto( file, b_singleton, ct_name, global_ct_name )670 elsif @@ptr_list[ ct_name ] then671 gen_preamble_ptr( file, b_singleton, ct_name, global_ct_name )672 elsif @@struct_list[ ct_name ] then673 gen_preamble_struct( file, b_singleton, ct_name, global_ct_name )674 else675 raise "Unknown #{ct_name}"676 end677 end678 679 def gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )680 file.print <<EOT681 /* MBP: MrubyBridgePlugin: MBP000 */682 #include "mruby.h"683 #include "mruby/class.h"684 #include "mruby/data.h"685 #include "mruby/string.h"686 #include "TECSPointer.h"687 #include "TECSStruct.h"688 689 #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)690 #define DLLEXPORT __declspec(dllexport)691 #else692 #define DLLEXPORT693 #endif694 695 #ifndef NULL696 #define NULL 0697 #endif698 EOT699 end700 701 def gen_preamble_instance( file, b_singleton, ct_name, global_ct_name )702 file.print <<EOT703 704 /* RData MBP001 */705 static void706 #{@celltype_name}_free( mrb_state *mrb, void *p )707 {708 if( p )709 (void)mrb_free( mrb, p );710 }711 712 /* RData MBP002 */713 struct mrb_data_type data_type_#{@celltype_name} =714 {715 "#{@celltype_name}",716 #{@celltype_name}_free717 };718 719 /* RData MBP003 */720 struct tecs_#{@celltype_name} {721 CELLCB *cbp;722 };723 724 /* name_to_cbp MBP010 */725 const struct name_to_cbp_#{@celltype_name} {726 char *name; /* Cell Name */727 CELLCB *cbp;728 } Name_to_cbp_#{@celltype_name}[] = {729 EOT730 731 # mikan namespace732 nsp = NamespacePath.new( :nMruby, true )733 nsp.append! ct_name734 ct = Namespace.find nsp735 736 ct.get_cell_list.each{ |cell|737 if cell.is_generate? then738 name_array = ct.get_name_array( cell )739 file.print "\t{ \"#{cell.get_name}\", #{name_array[8]} },\n"740 end741 }742 743 file.print <<EOT744 \t{ 0, 0 },745 };746 747 EOT748 749 end750 751 def gen_preamble_ptr( file, b_singleton, ct_name, global_ct_name )752 tment = @@ptr_list[ ct_name ]753 file.print <<EOT754 755 GET_SET_#{tment[3]}( #{tment[1]}, #{tment[0]} )756 POINTER_CLASS( #{tment[1]}, #{tment[0]} )757 EOT758 end759 760 def gen_preamble_struct( file, b_singleton, ct_name, global_ct_name )761 tag = ct_name762 structType = @@struct_list[ tag ]763 file.print <<EOT764 /* struct #{tag} */765 STRUCT_CLASS( #{tag} )766 EOT767 768 structType.get_members_decl.get_items.each{ |d|769 type = d.get_type.get_original_type770 case type771 when IntType, CIntType772 bit_size = type.get_bit_size773 case bit_size774 when -11, -1775 tType = "Char"776 ttype = "char"777 when -2778 tType = "Short"779 ttype = "short"780 when -3781 tType = "Int"782 ttype = "int"783 when -4784 tType = "Long"785 ttype = "long"786 when -5787 tType = "IntPtr"788 ttype = "intptr"789 when 8, 16, 32, 64790 tType = "Int#{bit_size}"791 ttype = "int#{bit_size}"792 else793 raise "cannot handle bit_size #{bit_size}"794 end795 file.print "MEMBER_GET_SET_INT( #{tag}, #{d.get_name}, #{tType}, #{ttype} )\n"796 when FloatType, CFloatType797 file.print "MEMBER_GET_SET_FLOAT( #{tag}, #{d.get_name} )\n"798 else799 raise "cannot handle type"800 end801 }802 803 end804 805 def gen_preamble_instance_proto( file, b_singleton, ct_name, global_ct_name )806 file.print <<EOT807 // Prototype MBP400808 mrb_value MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self);809 EOT810 811 @func_head_array.each{ |f|812 if ! f.is_function? then813 next814 end815 if f.get_name != :initialize then816 func_name = f.get_name817 else818 func_name = :initialize_cell819 end820 821 ret_type = f.get_return_type822 ret_type0 = f.get_return_type.get_original_type823 b_void = ret_type0.is_void?824 plist = f.get_paramlist.get_items825 826 file.print <<EOT827 mrb_value MrubyBridge_#{@celltype_name}_#{func_name}( mrb_state *mrb, mrb_value self );828 EOT829 }830 end831 832 def gen_preamble_instance_initialize( file, b_singleton, ct_name, global_ct_name )833 file.print <<EOT834 835 /* MBP100 */836 mrb_value837 MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self)838 {839 mrb_value name;840 struct tecs_#{@celltype_name} *tecs_cb;841 const struct name_to_cbp_#{@celltype_name} *ntc;842 843 /* set DATA_TYPE earlier to avoid SEGV */844 DATA_TYPE( self ) = &data_type_#{@celltype_name};845 846 mrb_get_args(mrb, "o", &name );847 if( mrb_type( name ) != MRB_TT_STRING ){848 mrb_raise(mrb, E_NAME_ERROR, "cell name not string");849 }850 for( ntc = &Name_to_cbp_#{@celltype_name}[0]; ntc->name != NULL; ntc++ ){851 if( strcmp( ntc->name, RSTRING_PTR( name ) ) == 0 )852 break;853 }854 if( ntc->name == 0 ){855 mrb_raise(mrb, E_ARGUMENT_ERROR, "cell not found");856 }857 tecs_cb = (struct tecs_#{@celltype_name} *)mrb_malloc(mrb, sizeof(struct tecs_#{@celltype_name}) );858 tecs_cb->cbp = ntc->cbp;859 DATA_PTR( self ) = (void *)tecs_cb;860 861 return self;862 }863 EOT864 end865 866 def gen_preamble_bridge_func( file, b_singleton, ct_name, global_ct_name )867 868 @func_head_array.each{ |f|869 if ! f.is_function? then870 next871 end872 if f.get_name != :initialize then873 func_name = f.get_name874 else875 func_name = :initialize_cell876 end877 878 ret_type = f.get_return_type879 ret_type0 = f.get_return_type.get_original_type880 b_void = ret_type0.is_void?881 plist = f.get_paramlist.get_items882 883 file.print <<EOT884 885 /* bridge function (MBP101) */886 mrb_value887 MrubyBridge_#{ct_name}_#{func_name}( mrb_state *mrb, mrb_value self )888 {889 /* cellcbp (MBP105) */890 CELLCB *p_cellcb = ((struct tecs_#{@celltype_name} *)DATA_PTR(self))->cbp;891 EOT892 893 file.print " /* variables for return & parameter (MBP110) */\n"894 if ! b_void then895 file.print " ", ret_type.get_type_str, "\tret_val", ret_type.get_type_str_post, ";\n"896 end897 arg_str = ""898 n_param = 0899 n_scalar = 0900 n_ptr = 0901 n_struct = 0902 plist.each{ |param|903 case param.get_direction904 when :IN, :INOUT, :OUT905 type = param.get_type.get_original_type906 case type907 when IntType908 file.print " mrb_int mrb_", param.get_name, ";\n"909 file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"910 arg_str += "i"911 n_param += 1912 n_scalar += 1913 when FloatType914 file.print " mrb_float mrb_", param.get_name, ";\n"915 file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"916 arg_str += "f"917 n_param += 1918 n_scalar += 1919 when BoolType920 file.print " mrb_value mrb_", param.get_name, ";\n"921 file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"922 arg_str += "o"923 n_param += 1924 n_scalar += 1925 when PtrType926 file.print " mrb_value mrb_", param.get_name, ";\n"927 file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"928 arg_str += "o"929 n_param += 1930 n_ptr += 1931 when StructType932 file.print " mrb_value mrb_", param.get_name, ";\n"933 file.print " #{param.get_type.get_type_str} *#{param.get_name}#{param.get_type.get_type_str_post};\n"934 arg_str += "o"935 n_param += 1936 n_struct += 1937 else938 raise "Unkown type"939 end940 end941 }942 943 if n_param > 0 then944 file.print " /* retrieve arguments (MBP111) */\n"945 file.print " mrb_get_args(mrb, \"#{arg_str}\""946 plist.each{ |param|947 case param.get_direction948 when :IN, :INOUT, :OUT949 type = param.get_type.get_original_type950 case type951 when IntType952 file.print ", &mrb_", param.get_name953 when FloatType954 file.print ", &mrb_", param.get_name955 when BoolType956 file.print ", &mrb_", param.get_name957 when PtrType958 file.print ", &mrb_", param.get_name959 when StructType960 file.print ", &mrb_", param.get_name961 else962 raise "Unkown type"963 end964 end965 }966 file.print " );\n"967 968 if n_scalar > 0 || n_struct > 0 then969 file.print " /* convert mrb to C (MBP112) */\n"970 end971 plist.each{ |param|972 case param.get_direction973 when :IN, :INOUT, :OUT974 type = param.get_type.get_original_type975 case type976 when IntType977 ttype = type.get_original_type978 tment = get_type_map_ent ttype979 file.print " VALCHECK_#{tment[1]}( mrb, mrb_#{param.get_name} );\n"980 file.print " #{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"981 when FloatType982 file.print " #{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"983 when BoolType984 file.print " #{param.get_name} = mrb_test( mrb_#{param.get_name} );\n"985 when PtrType986 ttype = type.get_type.get_original_type987 case ttype988 when StructType989 file.print " CHECK_STRUCT( #{ttype.get_name}, mrb_#{param.get_name} );\n"990 file.print " #{param.get_name} = (struct #{ttype.get_name}*)DATA_PTR(mrb_#{param.get_name});\n"991 when IntType992 when FloatType993 when BoolType994 else995 raise "cannot handle type"996 end997 when StructType998 file.print " CHECK_STRUCT( #{type.get_name}, mrb_#{param.get_name} );\n"999 file.print " #{param.get_name} = (struct #{type.get_name}*)DATA_PTR(mrb_#{param.get_name});\n"1000 else1001 raise( "canot treat class" )1002 end1003 end1004 }1005 1006 if n_ptr > 0 then1007 file.print " /* convert mrb to C for pointer types (MBP113) */\n"1008 end1009 plist.each{ |param|1010 case param.get_direction1011 when :IN, :INOUT, :OUT1012 type = param.get_type.get_original_type1013 case type1014 when IntType1015 when FloatType1016 when BoolType1017 when PtrType1018 case type.get_type.get_original_type1019 when StructType1020 when IntType1021 ptrMrb2C file, type, param1022 when FloatType1023 ptrMrb2C file, type, param1024 when BoolType1025 ptrMrb2C file, type, param1026 else1027 raise "cannot handle type"1028 end1029 when StructType1030 else1031 raise( "canot treat class" )1032 end1033 end1034 }1035 1036 end1037 1038 file.print " /* calling target (MBP120) */\n"1039 if ! b_void then1040 file.print " ret_val = "1041 else1042 file.print " "1043 end1044 delim = ""1045 file.print "cTECS_", f.get_name, "( "1046 plist.each{ |param|1047 if param.get_type.get_original_type.kind_of? StructType then1048 aster = "*"1049 else1050 aster = ""1051 end1052 file.print delim, aster, param.get_name1053 delim = ", "1054 }1055 file.print " );\n"1056 1057 file.print " /* return (MBP130) */\n"1058 case ret_type01059 when BoolType1060 file.print " return ret_val ? mrb_true_value() : mrb_false_value();\n"1061 when IntType1062 file.print " return mrb_fixnum_value( ret_val );\n"1063 when FloatType1064 file.print " return mrb_float_value( mrb, ret_val );\n"1065 when VoidType1066 file.print " return mrb_nil_value();\n"1067 else1068 raise "unknown type"1069 end1070 1071 file.print "}\n"1072 }1073 end1074 1075 def ptrMrb2C file, type, param1076 ttype = type.get_type.get_original_type1077 tment = get_type_map_ent ttype1078 tstr = tment[1]1079 =begin1080 case ttype1081 when IntType1082 bit_size = ttype.get_bit_size1083 case bit_size1084 when -1, -111085 tstr = "Char"1086 when 8, 16, 32, 641087 tstr = "Int#{bit_size}"1088 when -21089 tstr = "Short"1090 when -31091 tstr = "Int"1092 when -41093 tstr = "Long"1094 when -51095 tstr = "IntPtr"1096 else1097 raise "not handle type"1098 end1099 when FloatType1100 if ttype.get_bit_size == 32 then1101 tstr = "Float32"1102 else1103 tstr = "Double64"1104 end1105 when BoolType1106 tstr = "Bool"1107 when StructType1108 raise "not handle type 2 #{ttype}"1109 else1110 raise "not handle type 2 #{ttype}"1111 end1112 =end1113 if( param.get_size ) then1114 sz_str = param.get_size.to_s1115 elsif param.get_string then # mikan とりあえず size_is と string の同時指定 (二重ポインタ) はなし1116 sz_str = param.get_string.to_s1117 else1118 sz_str = "1"1119 end1120 # unsigned 型の場合には cast が必要1121 if ttype.get_original_type.get_type_str != param.get_type.get_type.get_type_str then1122 cast_str = "(#{param.get_type.get_type_str})"1123 else1124 cast_str = ""1125 end1126 1127 modify = ""1128 case param.get_direction1129 when :OUT, :INOUT1130 case tstr1131 when "Char", "SChar", "UChar"1132 modify = "Mod"1133 end1134 end1135 if param.is_nullable? then1136 nullable = "Nullable"1137 else1138 nullable = ""1139 end1140 1141 # file.print " CHECK_POINTER( #{tstr}, mrb_#{param.get_name}, #{sz_str} );\n"1142 # file.print " #{param.get_name} = #{cast_str}((struct #{tstr}PointerBody*)(DATA_PTR(mrb_#{param.get_name})))->buf;\n"1143 file.print " #{param.get_name} = CheckAndGet#{tstr}Pointer#{modify}#{nullable}( mrb, mrb_#{param.get_name}, #{sz_str} );\n"1144 end1145 1146 def get_celltype_name1147 @celltype_name1148 end1149 1150 #=== プラグイン引数 ignoreUnsigned1151 def set_ignoreUnsigned rhs1152 if rhs == "true" || rhs == nil then1153 @b_ignoreUnsigned = true1154 end1155 end1156 #=== プラグイン引数 include1157 def set_include rhs1158 funcs = rhs.split ','1159 funcs.each{ |rhs_func|1160 found = false1161 rhs_func.gsub!( /\s/, "" )1162 @signature.get_function_head_array.each{ |a|1163 if rhs_func.to_sym == a.get_name then1164 found = true1165 end1166 }1167 if found == false then1168 cdl_error( "MRB1009 include function '$1' not found in signagture '$2'", rhs, @signature.get_name )1169 else1170 @includes << rhs_func.to_sym1171 end1172 }1173 end1174 #=== プラグイン引数 exclude1175 def set_exclude rhs1176 funcs = rhs.split ','1177 funcs.each{ |rhs_func|1178 found = false1179 rhs_func.gsub!( /\s/, "" )1180 @signature.get_function_head_array.each{ |a|1181 if rhs_func.to_sym == a.get_name then1182 found = true1183 end1184 }1185 if found == false then1186 cdl_error( "MRB1010 exclude function '$1' not found in signagture '$2", rhs, @signature.get_name )1187 else1188 @excludes << rhs_func.to_sym1189 end1190 }1191 end1192 68 end 1193 -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/NotifierPlugin.rb
r321 r429 1 1 # -*- coding: utf-8 -*- 2 # 3 # TECS Generator 4 # Generator for TOPPERS Embedded Component System 2 5 # 3 6 # Copyright (C) 2015 by Ushio Laboratory … … 5 8 # Copyright (C) 2015-2016 by Embedded and Real-Time Systems Laboratory 6 9 # Graduate School of Information Science, Nagoya Univ., JAPAN 10 # Copyright (C) 2015-2018 by TOPPERS Project 7 11 # 12 #-- 13 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 14 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 15 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 16 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 17 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 18 # スコード中に含まれていること. 19 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 20 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 21 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 22 # の無保証規定を掲載すること. 23 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 24 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 25 # と. 26 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 27 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 28 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 29 # 報告すること. 30 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 31 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 32 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 33 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 34 # 免責すること. 35 # 36 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 37 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 38 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 39 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 40 # の責任を負わない. 41 # 42 # $Id$ 43 #++ 8 44 9 45 NotifierPluginArgProc = { … … 31 67 # - 受け口関数 - 一般化を行うと,実行時コストが大きく増大してしまうことが 32 68 # 確認されている.このため,一般化は行わない.EntryPropertyにも含めない. 33 # - セルインデックス - CELLIDX型で,型の規定はないが," ポインタ値であったり34 # 整数値 であったりする。" (TECS 5.3.6) より,インデックスかポインタある69 # - セルインデックス - CELLIDX型で,型の規定はないが,"ホ゜インタ値て゛あったり 70 # 整数値て゛あったりする。" (TECS 5.3.6) より,インデックスかポインタある 35 71 # ことが分かる.インデックスだとすると,この値はセルCBのアドレッシングに 36 72 # 使用されるので,intptr_tに収まる筈である.ポインタの場合,当然intptr_t … … 58 94 # - アダプタ関数へののポインタ 59 95 # - アダプタ関数の引数 96 # 97 # $Id$ 60 98 61 99 # @private … … 126 164 # @param [Cell, Symbol] cell セル.セルについて一般化する場合は `:generic` 127 165 # @param [Integer, Symbol, nil] subscript 添字.添字について一般化する場合は `:generic` 166 # @param [Celltype] 呼び先のセルタイプ、cell==:generic の場合のみ有効 128 167 # @private 129 def generate_inner(context, fn_name, cell, subscript )168 def generate_inner(context, fn_name, cell, subscript, callee_ct=nil) 130 169 source_file = context.source_file 131 170 header_file = context.header_file … … 139 178 unless ct.is_singleton? 140 179 if cell == :generic 141 params << "(CELLIDX)extinf" 180 params << "(#{callee_ct.get_global_name}_IDX)extinf" 181 # params << "(CELLIDX)extinf" 142 182 else 143 183 # セルのCELLIDXを得る … … 231 271 232 272 generate_inner context, fn_name, 233 :generic, subscript 273 :generic, subscript, ct 234 274 235 275 props.each { |prop| … … 443 483 # join:: Join : 結合 (declarationがPortであるもの) 444 484 def validate_join(handler, cell, join) 445 485 return !generate_attr_map(handler, cell).nil? 446 486 end 447 487 … … 870 910 parse_plugin_arg 871 911 unless @factory 872 cdl_error(" ASP1003 celltype $1: option factory is not specified",912 cdl_error("NTF1003 celltype $1: option factory is not specified", 873 913 celltype.get_name) 874 914 end 875 915 unless @output_file 876 cdl_error(" ASP1003 celltype $1: option output_file is not specified",916 cdl_error("NTF1003 celltype $1: option output_file is not specified", 877 917 celltype.get_name) 878 918 end … … 881 921 def set_factory(template_string) 882 922 unless @factory.nil? 883 cdl_error(" ASP1003 celltype $1: option factory was specified more than once",923 cdl_error("NTF1003 celltype $1: option factory was specified more than once", 884 924 celltype.get_name) 885 925 end … … 889 929 def set_factory_output_file(output_file) 890 930 unless @output_file.nil? 891 cdl_error(" ASP1003 celltype $1: option output_file was specified more than once",931 cdl_error("NTF1003 celltype $1: option output_file was specified more than once", 892 932 celltype.get_name) 893 933 end … … 896 936 897 937 def gen_factory file 898 puts "===== begin #{@celltype.get_name.to_s} plugin ====="938 # puts "===== begin #{@celltype.get_name.to_s} plugin =====" 899 939 900 940 kernelCfg = AppFile.open( "#{$gen}/#{@output_file}" ) … … 920 960 subst_attr = @celltype.find(name) 921 961 unless subst_attr 922 cdl_error( " ASP1007 celltype $1: additional_param: attribute $2 does not exist.",962 cdl_error( "NTF1007 celltype $1: additional_param: attribute $2 does not exist.", 923 963 @celltype.get_name, name) 924 964 end … … 933 973 934 974 kernelCfg.close 935 puts "===== end #{@celltype.get_name.to_s} plugin ====="975 # puts "===== end #{@celltype.get_name.to_s} plugin =====" 936 976 end 937 977 938 978 def gen_factory_for_cell(kernelCfg, cell) 979 # print "########## gen_factory_for_cell cell=#{cell.get_name}\n" 939 980 handler_flags = [] 940 981 handler_args = [] … … 957 998 when 'false' then ignoreErrors = false 958 999 else 959 cdl_warning ( "ASP1005 cell $1: unrecognized value '$2' specified for ignoreErrors",1000 cdl_warning2( cell.get_locale, "NTF1005 cell $1: unrecognized value '$2' specified for ignoreErrors", 960 1001 cell.get_name, ignoreErrors ) 961 1002 ignoreErrors = false 962 1003 end 963 1004 1005 # ドメイン指定用文字列 1006 pre_text = "" 1007 post_text = "\n" 1008 indent = "" 1009 964 1010 [EVENT_HANDLER, ERROR_HANDLER].each { |handler| 965 1011 # 呼び口の結合を取得 966 1012 call_join = cell.get_join_list.get_item(handler.call_port_name.to_sym) 1013 domain_root = cell.get_region.get_domain_root 1014 if cell.get_region.get_domain_root.get_domain_type then 1015 # print "cell=#{cell.get_name} domain_root=#{domain_root.get_name} domain_type=#{domain_root.get_domain_type.get_name} domain_option=#{domain_root.get_domain_type.get_option}\n" 1016 else 1017 # print "cell=#{cell.get_name} domain_root=#{cell.get_region.get_domain_root.get_name}\n" 1018 end 1019 if call_join 1020 # print "validate_join: hanlder=#{handler.class.name} cell=#{cell.get_name} join=#{call_join.get_name} rhs_cell=#{call_join.get_cell}\n" 1021 else 1022 # print "validate_join: hanlder=#{handler.class.name} cell=#{cell.get_name}\n" 1023 end 967 1024 968 1025 # ハンドラタイプを判別する … … 972 1029 973 1030 if matches.length == 0 974 cdl_error ( "ASP1001 cell $1: no matching handler type found for $2", cell.get_name, handler.call_port_name )1031 cdl_error2( cell.get_locale, "NTF1001 cell $1: no matching handler type found for $2", cell.get_name, handler.call_port_name ) 975 1032 next 976 1033 end 977 1034 978 1035 # 最初に見つかった有効なハンドラタイプを使用 979 1036 ht = matches[0] 1037 1038 # ドメインプラグインが指定されている場合、所属ドメインのチェック 1039 domain_root = cell.get_region.get_domain_root 1040 if domain_root.get_domain_type then 1041 if domain_root.get_domain_type.get_name == :HRP then 1042 option = domain_root.get_domain_type.get_option 1043 matches.each{ |match| 1044 # p "match:#{match}" 1045 case match 1046 when ActivateTaskHandlerType, WakeUpTaskHandlerType, 1047 SetVariableHandlerType, SetVariableToErrorCodeHandlerType, 1048 IncrementVariableHandlerType, SignalSemaphoreHandlerType, 1049 SetEventflagHandlerType, SendToDataqueueHandlerType, 1050 SendErrorCodeToDataqueueHandlerType 1051 if option == "OutOfDomain" then 1052 cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 cannot be placed out of domain", cell.get_name ) 1053 elsif call_join.get_cell.get_region.get_domain_root == nil || 1054 call_join.get_cell.get_region.get_domain_root != domain_root then 1055 cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 and $2 must be placed in same domain", cell.get_name, call_join.get_cell.get_name ) 1056 end 1057 dbgPrint "#{self.class.name}: match pattern 1.\n" 1058 when UserHandlerType 1059 if option != "kernel" then 1060 cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 can be placed in kernel domain only, because notify target is handler", cell.get_name ) 1061 elsif call_join.get_cell.get_region.get_domain_root == nil || 1062 call_join.get_cell.get_region.get_domain_root != domain_root then 1063 cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 and $2 must be placed in same domain", cell.get_name, call_join.get_cell.get_name ) 1064 end 1065 dbgPrint "#{self.class.name}: match pattern 2.\n" 1066 when NullHandlerType.new # エラー通知を指定していない 1067 dbgPrint "#{self.class.name}: match pattern 3.\n" 1068 end 1069 } 1070 1071 # if cell.get_region.get_param == :KERNEL_DOMAIN 1072 if option == "kernel" 1073 pre_text = "KERNEL_DOMAIN{\n" 1074 post_text = "}\n" 1075 indent = "\t" 1076 elsif option != "OutOfDomain" then 1077 pre_text = "DOMAIN(#{domain_root.get_name.to_s}){\n" 1078 post_text = "}\n" 1079 indent = "\t" 1080 end 1081 else 1082 cdl_error( "NTF9999: NotifierPlugin: unknown domain type $1", domain_root.get_domain_type.get_name ) 1083 end 1084 1085 end 980 1086 981 1087 # 通知ハンドラで「エラーが発生するはずがない」のに「エラーハンドラが指定されている」 … … 984 1090 # なため、検出は行わない。) 985 1091 if handler == ERROR_HANDLER && !ht.is_a?(NullHandlerType) && !event_handler_might_fail 986 cdl_error ( "ASP1004 cell $1: handler type $2 which never raises an error was inferred for the normal notification handler, but an error notification handler was specified.",1092 cdl_error2( cell.get_locale, "NTF1004 cell $1: handler type $2 which never raises an error was inferred for the normal notification handler, but an error notification handler was specified.", 987 1093 cell.get_name, handler_flag) 988 1094 end 989 1095 if handler == ERROR_HANDLER && ht.is_a?(NullHandlerType) && event_handler_might_fail && !ignoreErrors 990 cdl_warning ( "ASP1006 cell $1: handler type $2 which might raise an error was inferred for the normal notificaton handler, but an error notification handler was not specified.",1096 cdl_warning2( cell.get_locale, "NTF1006 cell $1: handler type $2 which might raise an error was inferred for the normal notificaton handler, but an error notification handler was not specified.", 991 1097 cell.get_name, handler_flag) 992 1098 end … … 1055 1161 # $id$等の置換 1056 1162 cell.get_celltype.subst_name(subst, name_array) 1057 } 1058 1059 # 出力 1060 kernelCfg.puts text 1061 1062 end 1063 private :gen_factory_for_cell 1163 } 1164 1165 # 出力 (CRE_xxx) 1166 kernelCfg.print pre_text 1167 kernelCfg.print indent, text, "\n" 1168 gen_sac kernelCfg, cell, indent 1169 kernelCfg.print post_text 1170 end 1171 1172 def gen_sac file, cell, indent 1173 domain_root = cell.get_region.get_domain_root 1174 if domain_root.get_domain_type then 1175 id = (cell.get_attr_initializer :id).to_s 1176 name_array = cell.get_celltype.get_name_array(cell) 1177 case cell.get_celltype.get_name 1178 when :tCyclicNotifier 1179 obj_type = "CYC" 1180 when :tAlarmNotifier 1181 obj_type = "ALM" 1182 else 1183 raise "NotifierPlugin: unknown celltype #{cell.get_celltype.get_name}" 1184 end 1185 id = cell.get_celltype.subst_name(id, name_array) 1186 # p obj_type 1187 # p HRPPlugin.get_sac_str cell 1188 file.print indent, "SAC_#{obj_type}( #{id}, #{HRPPlugin.get_sac_str cell} );\n" 1189 end 1190 end 1191 private :gen_factory_for_cell 1064 1192 1065 1193 end -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/OpaqueRPCPlugin.rb
r321 r429 56 56 #=== RPCPlugin の initialize 57 57 # 説明は ThroughPlugin (plugin.rb) を参照 58 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )58 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell ) 59 59 super 60 60 @b_noClientSemaphore = false … … 254 254 nest = @end_region.gen_region_str_pre file 255 255 nest_str = " " * nest 256 if @next_cell_port_subscript then 257 subscript = '[' + @next_cell_port_subscript.to_s + ']' 258 else 259 subscript = "" 260 end 256 261 257 262 if @serverErrorHandler then … … 282 287 #{nest_str} cell #{@rpc_server_channel_celltype_name} #{@serverChannelCell}_Unmarshaler { 283 288 #{nest_str} cChannel = #{@serverChannelCell}.eC1; 284 #{nest_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name} ;289 #{nest_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript}; 285 290 #{serverErrorHandler_str}#{nest_str} }; 286 291 EOT -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/RPCPlugin.rb
r321 r429 65 65 #=== RPCPlugin の initialize 66 66 # 説明は ThroughPlugin (plugin.rb) を参照 67 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )67 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell ) 68 68 super 69 69 @b_noClientSemaphore = false … … 197 197 nest = @region.gen_region_str_pre file 198 198 indent_str = " " * nest 199 if @next_cell_port_subscript then 200 subscript = '[' + @next_cell_port_subscript.to_s + ']' 201 else 202 subscript = "" 203 end 199 204 200 205 file.print <<EOT … … 233 238 file.print <<EOT 234 239 #{indent_str}cell #{@rpc_channel_celltype_name} #{@cell_name} { 235 #{indent_str} #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name} ;240 #{indent_str} #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript}; 236 241 #{indent_str} cTDR = #{@channelCellName}.eTDR; 237 242 #{indent_str} cEventflag = #{@channelCellName}.eEventflag; -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedOpaqueRPCPlugin.rb
r321 r429 68 68 #=== RPCPlugin の initialize 69 69 # 説明は ThroughPlugin (plugin.rb) を参照 70 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )70 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell ) 71 71 super 72 72 initialize_opaque_marshaler … … 221 221 nest = @start_region.gen_region_str_pre file 222 222 indent_str = " " * nest 223 nest_str = " " * nest 224 if @next_cell_port_subscript then 225 subscript = '[' + @next_cell_port_subscript.to_s + ']' 226 else 227 subscript = "" 228 end 223 229 224 230 # セルを探す … … 303 309 #{indent_str}cell #{@unmarshaler_celltype_name} #{@cell_name}_Server { 304 310 #{indent_str} cTDR = #{@shared_channel_cell}_Server.eTDR; 305 #{indent_str} cServerCall = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name} ;311 #{indent_str} cServerCall = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript}; 306 312 #{ppallocator_join}#{indent_str}}; 307 313 EOT -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedRPCPlugin.rb
r321 r429 62 62 #=== RPCPlugin の initialize 63 63 # 説明は ThroughPlugin (plugin.rb) を参照 64 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )64 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell ) 65 65 66 66 # mikan プラグインオプション指定の不一致のチェック task_priority, … … 236 236 nest = @region.gen_region_str_pre file 237 237 indent_str = " " * nest 238 if @next_cell_port_subscript then 239 subscript = '[' + @next_cell_port_subscript.to_s + ']' 240 else 241 subscript = "" 242 end 238 243 239 244 # セルを探す … … 291 296 file.print <<EOT 292 297 #{indent_str}cell #{@rpc_channel_celltype_name} #{@cell_name} { 293 #{indent_str} #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name} ;298 #{indent_str} #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript}; 294 299 #{indent_str} cTDR = #{@shared_channel_cell}.eTDR; 295 300 #{indent_str} cEventflag = #{@shared_channel_cell}.eEventflag; -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/ThroughPlugin.rb
r321 r429 47 47 #@next_cell:: Cell 呼び口を結合するセル 48 48 #@next_cell_port_name:: Symbol 呼び口を結合する受口の名前 49 #@next_cell_port_subscript::Nil|Integer 呼び口を結合する受口の配列添数.受け口配列でない場合 nil 49 50 #@signature:: Signature シグニチャ 50 51 #@celltype:: Celltype 呼び先のセルのセルタイプ. through が連接する場合、最終的な呼び先のセルのセルタイプ … … 74 75 #next_cell:: Cell 呼び口を接続するセル 75 76 #next_cell_port_name:: Symbol 呼び口を接続する受口の名前 77 #next_cell_port_subscript:: Nil|Integer 呼び口を接続する受口配列添数 76 78 #signature:: Signature シグニチャ 77 79 #celltype:: Celltype セルタイプ (呼び先のセルのセルタイプ) 78 80 #caller_cell:: Cell 呼び元のセル.@caller_cell の項を参照 79 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )81 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell ) 80 82 super() 81 83 @cell_name = cell_name # 生成すべきセル名(受け口側のセル名) … … 83 85 @next_cell = next_cell # 呼び先のセル 84 86 @next_cell_port_name = next_cell_port_name 87 @next_cell_port_subscript = next_cell_port_subscript 85 88 @signature = signature 86 89 @entry_port_name = :"eThroughEntry" … … 136 139 def get_through_entry_port_name 137 140 @entry_port_name 141 end 142 143 #=== 生成されたセルの受け口配列添数を得る 144 def get_through_entry_port_subscript 145 @entry_port_subscript 138 146 end 139 147 -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/TracePlugin.rb
r321 r429 44 44 #=== TracePlugin の initialize 45 45 # 説明は ThroughPlugin (plugin.rb) を参照 46 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )46 def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell ) 47 47 48 48 @maxArrayDisplay = 16 … … 141 141 nest = @region.gen_region_str_pre file 142 142 indent_str = " " * nest 143 if @next_cell_port_subscript then 144 subscript = '[' + @next_cell_port_subscript.to_s + ']' 145 else 146 subscript = "" 147 end 143 148 144 149 if @probeName then … … 155 160 file.print <<EOT 156 161 #{indent_str}cell #{@ct_name} #{@cell_name} { 157 #{indent_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name} ;162 #{indent_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript}; 158 163 #{probeName_str}#{caller_cell_str}#{indent_str}}; 159 164 EOT … … 210 215 } 211 216 file.print( " );\n" ) 217 if @next_cell_port_subscript then 218 subscript = '[' + @next_cell_port_subscript.to_s + ']' 219 else 220 subscript = "" 221 end 212 222 213 223 file.print <<EOT 214 224 \tgetMicroTime( &utime ); 215 \tsyslog( LOG_INFO, \"Leave: %sTime=%d: #{@next_cell.get_name}.#{@next_cell_port_name} .#{func_name}\", ATTR_probeName_str, utime );225 \tsyslog( LOG_INFO, \"Leave: %sTime=%d: #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript}.#{func_name}\", ATTR_probeName_str, utime ); 216 226 EOT 217 227 -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 4by TOPPERS Project6 # Copyright (C) 2008-2018 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 464 464 /* Channel Lock */ 465 465 SET_RPC_STATE( state_, RPCSTATE_CLIENT_GET_SEM ); 466 if( is_cLockChannel_joined() ) 467 cLockChannel_wait(); 466 if( is_cLockChannel_joined() ){ 467 if( (ercd_=cLockChannel_wait()) != E_OK ) 468 goto error_reset; 469 } 468 470 EOT 469 471 … … 554 556 /* Channel Unlock */ 555 557 SET_RPC_STATE( state_, RPCSTATE_CLIENT_RELEASE_SEM ); 556 if( is_cLockChannel_joined() ) 557 cLockChannel_signal(); 558 if( is_cLockChannel_joined() ){ 559 if( (ercd_=cLockChannel_signal()) != E_OK ) 560 goto error_reset; 561 } 562 EOT 563 564 file.print <<EOT 565 /* state_ is not used in normal case */ 566 /* below is to avoid 'set but not used' warnning */ 567 (void)state_; 558 568 EOT 559 569 … … 630 640 file.print <<EOT 631 641 }else{ 632 return ;642 return E_ID; 633 643 } 634 644 EOT -
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb
r321 r429 388 388 }; 389 389 #{ppallocator_dealloc_str} 390 return ;390 return E_OK; 391 391 392 392 error_reset: … … 394 394 (void)cTDR_reset(); 395 395 #{ppallocator_dealloc_str} 396 return E_OK; 396 397 EOT 397 398
Note:
See TracChangeset
for help on using the changeset viewer.