Ignore:
Timestamp:
Jul 3, 2020, 7:19:17 PM (4 years ago)
Author:
coas-nagasima
Message:

ASP3, TINET, mbed を更新

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  
    4646  #option::String : domain 指定子の第二引数
    4747  def initialize( region, domain_type_name, option )
     48    super()
    4849  end
    4950
     
    7778    return false
    7879  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
    7991end
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2AlarmHandlerPlugin.rb

    r321 r429  
    3434#   アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3535#   の責任を負わない.
     36#
     37#   $Id: HRP2AlarmHandlerPlugin.rb 2640 2017-06-03 11:27:12Z okuma-top $
    3638
    3739#++
     
    5052    def print_cfg_cre(file, cell, val, tab)
    5153        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_base
    54         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
    5557        # CRE_XXXの生成
    5658        if (cell.get_region.get_region_type != :DOMAIN) || (cell.get_region.get_param != :KERNEL_DOMAIN)
     
    5961        else
    6062            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 });
    6264EOT
    6365        end
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2CyclicHandlerPlugin.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2012 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
     
    5152    def print_cfg_cre(file, cell, val, tab)
    5253        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_base
    55         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
    5657        # CRE_XXXの生成
    5758        if (cell.get_region.get_region_type != :DOMAIN) || (cell.get_region.get_param != :KERNEL_DOMAIN)
     
    6061        else
    6162            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]} });
    6364EOT
    6465        end
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2DataqueuePlugin.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2012 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2EventflagPlugin.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2012 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2FixedSizeMemoryPoolPlugin.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2012 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2HandlerPlugin.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
    3940#require "HRP2KernelObjectPlugin"
    4041require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
    41 
    4242
    4343#== celltype プラグインの共通の親クラス
     
    5151    # tab  :
    5252    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
    5759        # CRE_XXXの生成
    5860        domainOption = cell.get_region.get_domain_root.get_domain_type.get_option
     
    6365        elsif @plugin_arg_str == "ALARM"
    6466            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 });
    6668EOT
    6769        elsif @plugin_arg_str == "CYCLIC"
    6870            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]} });
     72EOT
     73        elsif @plugin_arg_str == "CONFIG_INT"
     74            file.print <<EOT
     75#{tab}CFG_INT( #{val[:interruptNumber]}, { #{val[:attribute]}, #{val[:interruptPriority]} });
     76EOT
     77        elsif @plugin_arg_str == "ISR"
     78            file.print <<EOT
     79#{tab}ATT_ISR({ #{val[:attribute]}, #{cell_CBP}, #{val[:interruptNumber]}, tISR_start, #{val[:priority]} });
     80EOT
     81        elsif @plugin_arg_str == "INIT_ROUTINE"
     82            file.print <<EOT
     83#{tab}ATT_INI({ #{val[:attribute]}, #{cell_CBP}, tInitializeRoutine_start });
     84EOT
     85        elsif @plugin_arg_str == "TERM_ROUTINE"
     86            file.print <<EOT
     87#{tab}ATT_TER({ #{val[:attribute]}, #{cell_CBP}, tTerminateRoutine_start });
    7088EOT
    7189        else
     
    7997        elsif @plugin_arg_str == "CYCLIC"
    8098            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
    81107        else
    82108            raise "#{@plugin_arg_str} is unknown option"
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2KernelObjectPlugin.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2012 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
     
    185186                val = {}
    186187                @celltype.get_attribute_list.each{ |a|
    187                     p a.get_name
     188                    # p a.get_name
    188189                    if a.get_type.kind_of?( ArrayType )
    189190                        val[a.get_name] = []
     
    217218                if val[:id].nil? != true
    218219                    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 ) )
    220222                end
    221223                # $cbp$の代わり
     
    243245                        file2.puts "}\n"
    244246                    else
    245                         print "~~~~~ #{cell.get_region.get_name.to_s} is included in"
    246                         p @@region_list
     247                        dbgPrint "~~~~~ #{cell.get_region.get_name.to_s} is included in"
     248                        # p @@region_list
    247249                    end
    248250                    file3 = AppFile.open( "#{$gen}/tecsgen_#{cell_domain_root.get_name.to_s}.cfg" )
     
    257259                puts "===== end check my domain #{cell.get_name} ====="
    258260                # 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
    279300                    else
    280                         acv << "TACP_SHARED"
     301                        # 無所属の場合
     302                        print_cfg_sac(file2, val, acv)
    281303                    end
    282304
    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} ====="
    300306                end
    301 
    302                 puts "===== end check regions #{cell.get_name} ====="
    303307            end
    304308        }
     
    319323
    320324    def self.check_referenced_cells()
    321         puts "===== begin check registered celltype ====="
     325        dbgPrint "===== begin check registered celltype =====\n"
    322326        self.get_celltype_list.each { |ct|
    323             p ct.get_name.to_s
     327            dbgPrint( ct.get_name.to_s + "\n" )
    324328        }
    325         puts "===== end check registered celltype ====="
     329        dbgPrint "===== end check registered celltype =====\n"
    326330
    327331=begin
     
    331335                j = cell.get_join_list.get_item(p.get_name)
    332336                printf "===== check call port : "
    333                 p p.get_name.to_s
     337                # p p.get_name.to_s
    334338                next if j.nil? # 未結合の場合
    335339                if @@celltype_list.include?(j.get_celltype)
     
    338342                    j.get_cell.set_referenced_cell(cell, j.get_port_name)
    339343                    printf "===== check joined rhs cell : "
    340                     p j.get_cell.get_name.to_s
     344                    # p j.get_cell.get_name.to_s
    341345                    printf "===== check joined rhs port_name : "
    342                     p j.get_port_name
     346                    # p j.get_port_name
    343347                end
    344348            }
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2ObjectPlugin.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2Plugin.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2014 by TOPPERS Project
     6#   Copyright (C) 2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
     
    4344
    4445  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
    4659  end
    4760
     
    5467    # get_rhs_subscript:Integer or nil 受け口配列の添数 (Join::@rhs_subscript の説明参照)
    5568    # 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"
    5770
    5871    puts "=====Join Check Start====="
     
    107120  end
    108121
     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
    109135  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"
    111137    return true
    112138  end
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2PostHook.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2012 by TOPPERS Project
     6#   Copyright (C) 2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2RPCPlugin.rb

    r321 r429  
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
     
    7071  #=== RPCPlugin の initialize
    7172  #  説明は 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 )
    7374    super
    7475    @b_noClientSemaphore = false
     
    234235    if cell.get_allocator_list.length > 0 then
    235236
    236       dbgPrint "make allocator"
     237      dbgPrint "make allocator\n"
    237238      file.print "#{indent_str}[allocator("
    238239
     
    269270    nest = @end_region.gen_region_str_pre file
    270271    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
    271278
    272279    file.print <<EOT
    273280#{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};
    275282//#{indent_str}    #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name};
    276283#{indent_str}  //cTDR         = #{@channelCellName}.eTDR;
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2SVCPlugin.rb

    r321 r429  
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
     
    8384  @@generated_celltype_header = {}
    8485
    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 )
    8687    super
    8788    @ct_name_body = "#{@ct_name}SVCBody_#{@next_cell.get_name}_#{@next_cell_port_name}".to_sym
     
    217218    nest = @end_region.gen_region_str_pre file
    218219    nest_str = "  " * nest
     220    if @next_cell_port_subscript then
     221      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     222    else
     223      subscript = ""
     224    end
    219225
    220226    # サーバー側チャンネルの生成
     
    224230#{nest_str}  //  Server Side Channel
    225231#{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};
    227233#{nest_str}  };
    228234EOT
     
    241247    nest = @start_region.gen_region_str_pre file
    242248    nest_str = "  " * nest
     249    if @next_cell_port_subscript then
     250      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     251    else
     252      subscript = ""
     253    end
    243254
    244255    # クライアント側チャンネルの生成
     
    247258#{nest_str}  //  Client Side Channel
    248259#{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};
    250261#{nest_str}  };
    251262
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2TaskPlugin.rb

    r321 r429  
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
     
    5253    # tab  :
    5354    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 ) )
    5557        # $cbp$の代わり
    5658        index = cell.get_id - @celltype.get_id_base
     
    5860        cell_CB_name = "#{index}"
    5961        # CRE_XXX/DEF_XXXの生成
    60         print "assign task plugin\n"
     62        dbgPrint "assign task plugin\n"
    6163        domainOption = cell.get_region.get_domain_root.get_domain_type.get_option
    6264        # if cell.get_region.get_region_type == :DOMAIN
     65# cell.show_tree 1
    6366        if domainOption != "OutOfDomain"
    6467            # 保護ドメインに属する場合
     
    6871                    raise "system task cannot have user stack."
    6972                end
     73p "CRE_TSK 0 user=#{val[:userStackSize]} system=#{val[:systemStackSize]}"
    7074                file.print <<EOT
    7175#{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:systemStackSize]}, NULL });
     
    7680                    raise "user task must have user stack."
    7781                end
     82p "CRE_TSK 1"
    7883                if val[:systemStackSize] == "OMIT"
    7984                    file.print <<EOT
     
    8186EOT
    8287                else
     88p "CRE_TSK 2"
    8389                    file.print <<EOT
    8490#{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:userStackSize]}, NULL, #{val[:systemStackSize]}, NULL });
     
    121127                ct = cell.get_celltype
    122128                if ct.class == Celltype && check_celltype_list.include?( ct ) == false
     129                    # チェック済みセルタイプに登録
     130                    check_celltype_list << ct
     131
    123132                    # 未チェックのセルタイプだった場合
    124133                    # puts "check for ATT_MOD : #{ct.classget_global_name}"
     
    134143                    regions = ct.get_domain_roots
    135144                    regions_hrp2 = regions[ :HRP2 ]
    136                     print "HRP2 domain in #{ct.get_name}: "
     145                    dbgPrint "HRP2 domain in #{ct.get_name}: "
    137146                    regions_hrp2.each { |reg|
    138                         print reg.get_name
     147                        dbgPrint reg.get_name
    139148                    }
    140149                    puts ""
     
    179188                    file.print "ATT_MOD(\"#{ct.get_global_name}.o\");\n"
    180189                    file.close
    181 
    182                     check_celltype_list << ct
    183190                else
    184191                    # 何もしない
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgePlugin.rb

    r321 r429  
    33#  mruby => TECS bridge
    44
    5 #   Copyright (C) 2008-2015 by TOPPERS Project
     5#   Copyright (C) 2008-2017 by TOPPERS Project
    66#
    77#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3737#
    3838
    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 クラス
     40class 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
    21366    end
    21467  end
    215 
    216   #=== check paramter type
    217   def check_parameter_type func_head_array
    218     # check type of parameters
    219     func_head_array.each{ |fh|
    220       fh.get_paramlist.get_items.each{ |param_decl|
    221         case param_decl.get_direction
    222         when :SEND, :RECEIVE
    223           cdl_error( "MRB1003 $1: $2 parameter cannot be used in mruby Bridge",  param_decl.get_name, param_decl.get_direction.to_s.downcase )
    224         end
    225         type = param_decl.get_type
    226         type_org = type.get_original_type
    227         type_str = type.get_type_str + type.get_type_str_post
    228 
    229         b_ng = false
    230         case type_org
    231         when IntType
    232           case  type_org.get_bit_size
    233           when 8, 16, 32, 64
    234           when -1, -2, -3, -4, -11
    235           else
    236             b_ng = true
    237           end
    238         when BoolType
    239         when FloatType
    240         when PtrType
    241           ttype_org = type_org.get_type       # ポインタの指している先の型
    242           ttype = ttype_org.get_original_type # 上記の typedef されている場合、元の型
    243           register_ptr_type ttype_org
    244 
    245           if( type_org.get_string.to_s == "-1" ) then
    246             case param_decl.get_direction
    247             when :OUT, :INOUT
    248               cdl_error( "MRB9999 string specifier without length cannot be used for out & inout parameter")
    249             end
    250           end
    251 
    252           case ttype
    253           when IntType
    254             bit_size = ttype.get_bit_size
    255             # if  bit_size < 0 && bit_size != -1 then
    256             #   b_ng = true
    257             # end
    258           when FloatType
    259           when BoolType
    260           when StructType
    261             if( type_org.get_size || type_org.get_string || type_org.get_count ) then
    262               cdl_error( "MRB1004 $1: size_is, count_is, string cannot be specified for struct pointer", param_decl.get_name )
    263             end
    264             check_struct_member ttype_org
    265           else
    266             b_ng = true
    267           end
    268         when StructType
    269           check_struct_member type_org
    270         else  # ArrayType, FuncType, EnumType, VoidType
    271           b_ng = true
    272         end
    273         if b_ng then
    274           cdl_error( "MRB1005 $1: type $2 cannot be used in mruby Bridge", param_decl.get_name, type_str )
    275         end
    276       }
    277     }
    278   end
    279 
    280   #=== 構造体のメンバーの型のチェック
    281   def check_struct_member struct_type
    282     #p "tag name:#{struct_type.get_name}"
    283     # sttype = Namespace.find_tag( struct_type.get_name )
    284     sttype = struct_type.get_original_type
    285     if sttype.get_name == nil then
    286       cdl_error( "MRB10007 tagless-struct cannot be handled")
    287     end
    288     sttype.get_members_decl.get_items.each { |d|
    289       t = d.get_type.get_original_type
    290       case t
    291       when IntType, FloatType, BoolType
    292       else
    293         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       end
    295     }
    296     st_name = :"t{}"
    297     if @struct_list[ sttype.get_name ] == nil then
    298       # 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 ] = sttype
    301     end
    302   end
    303 
    304   def register_ptr_type ttype
    305     t_org = ttype.get_original_type
    306     tment = get_type_map_ent t_org
    307     if tment == nil then
    308       return
    309       cdl_error( "MRB1008 unknown pointer type '$1'", ttype.get_type_str )
    310     end
    311     ptr_celltype_name = :"t#{tment[1]}Pointer"
    312     if @@ptr_list[ ptr_celltype_name ] == nil then
    313       # 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 ] = tment
    316     end
    317     if @ptr_list[ ptr_celltype_name ] == nil then
    318       @ptr_list[ ptr_celltype_name ] = tment
    319     end
    320   end
    321 
    322   def get_type_map_ent ttype
    323     # structure type is registerd in check_struct_member
    324     if ttype.kind_of? StructType
    325       return
    326     end
    327     tstr = ttype.get_type_str.sub( /const /, "" )    # const は無視
    328     tstr = tstr.sub( /volatile /, "" )               # volatile も無視
    329     if @b_ignoreUnsigned then
    330       tstr = tstr.sub( /unsigned /, "" )             # volatile も無視
    331       tstr = tstr.sub( /uint/, "int" )               # volatile も無視
    332       tstr = tstr.sub( /[cs]char/, "char" )          # volatile も無視
    333     end
    334     return @@TYPE_MAP[ tstr.to_sym ]
    335   end
    336 
    337   #===  CDL ファイルの生成
    338   #      typedef, signature, celltype, cell コードを生成
    339   #file::        FILE       生成するファイル
    340   def gen_cdl_file(file)
    341 
    342     # ブリッジセルタイプの生成
    343     if @@celltypes[ @celltype_name ] == nil then
    344       @@celltypes[ @celltype_name ] = [ self ]
    345       @@init_celltypes[ @init_celltype_name ] = true
    346       print_msg <<EOT
    347   MrubyBridgePlugin: [signature] #{@signature.get_namespace_path} => [celltype] nMruby::#{@celltype_name} => [class] TECS::#{@class_name}
    348 EOT
    349 
    350       file.print <<EOT
    351 import( <mruby.cdl> );
    352 
    353 /****  Ruby => TECS Bridge Celltype (MBP500) ****/
    354 namespace nMruby{
    355     // bridge celltype
    356     [idx_is_id,active]   // not actually active, to avoid warning W1002, W1007
    357     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 celltype
    365     celltype #{@init_celltype_name} {
    366         entry sInitializeTECSBridge eInitialize;
    367     };
    368 };
    369 EOT
    370 
    371       # 構造体セルタイプの生成
    372       @struct_list.each{ |name, sttype|
    373         if @@struct_list[ name ] == nil then
    374           file.print <<EOT
    375 namespace nMruby{
    376     [singleton]
    377     celltype #{name} {
    378         entry sInitializeTECSBridge eInitialize;
    379     };
    380 };
    381 EOT
    382           @@struct_list[ name ] = sttype
    383         end
    384       }
    385 
    386     else
    387       cdl_warning( "MRBW001 MrubyBridgePlugin: signature '$1' duplicate. ignored current one", @signature.get_namespace_path )
    388       @@celltypes[ @celltype_name ] << self
    389     end
    390   end
    391 
    392   #=== gen_cdl_file で定義したセルタイプに 新しいセルが定義された
    393   # cell のセルタイプの名前は @celltype_name
    394   def new_cell cell
    395     if cell.get_celltype.get_name != @celltype_name then
    396       return
    397     end
    398 
    399     join = cell.get_join_list.get_item :VMname
    400     if join then
    401       vm_name = CDLString.remove_dquote(join.get_rhs.to_s).to_sym
    402     else
    403       vm_name = :"VM"
    404     end
    405 
    406     if @@VM_list[ vm_name ] == nil then
    407       @@VM_list[ vm_name ] = true
    408 
    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 <<EOT
    416 
    417   // prototype of TECSInitializer (MBP510)
    418   cell nMruby::tTECSInitializer #{vm_name}_TECSInitializer;
    419 EOT
    420       file.close
    421 
    422       Generator.parse( initializer_celltype_cdl, self )
    423     end
    424 
    425     if @@VM_celltypes[ vm_name ] then
    426       vma = @@VM_celltypes[ vm_name ]
    427 
    428       if vma[ @celltype_name ] then
    429         vma[ @celltype_name ] << cell
    430       else
    431         vma[ @celltype_name ] = [cell]
    432         @@VM_celltypes[ vm_name ] = vma
    433       end
    434     else
    435       vma = { }
    436       vma[ @celltype_name ] = [cell]
    437       @@VM_celltypes[ vm_name ] = vma
    438     end
    439 
    440     @struct_list.each{ |stname, sttype|
    441       if @@VM_struct_list[ vm_name ] then
    442         @@VM_struct_list[ vm_name ][ sttype.get_name ] = sttype
    443       else
    444         @@VM_struct_list[ vm_name ] = { sttype.get_name => sttype }
    445       end
    446     }
    447     @ptr_list.each{ |ptr_celltype_name, tment|
    448       if @@VM_ptr_list[ vm_name ] then
    449         @@VM_ptr_list[ vm_name ][ ptr_celltype_name ] = tment
    450       else
    451         @@VM_ptr_list[ vm_name ] = { ptr_celltype_name => tment }
    452       end
    453     }
    454 
    455   end
    456 
    457   #=== プラグインが CDL の POST コードを生成
    458   # tmp_plugin_post_code.cdl への出力
    459   def self.gen_post_code file
    460 
    461 #     file.print <<EOT
    462 # namespace nMruby {
    463 # EOT
    464 #
    465 #     @@ptr_list.each{ |name,tment|
    466 #       file.print <<EOT
    467 #
    468 #     // MBP600
    469 #     [singleton]
    470 #     celltype #{name} {
    471 #         entry  sInitializeTECSBridge eInitialize;
    472 #     };
    473 # EOT
    474 #     }
    475 #
    476 #     file.print <<EOT
    477 # };
    478 # EOT
    479 
    480 # gen_post_code で生成した celltype は gen_ep_func が呼び出されない #847
    481 #    @@struct_list.each{ |name,sttype|
    482 #      file.print <<EOT
    483 #
    484 #    [singleton]
    485 #    celltype #{name} {
    486 #        entry  sInitializeTECSBridge eInitialize;
    487 #    };
    488 #EOT
    489 #    }
    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 then
    496           ct_name = cell.get_celltype.get_name
    497         file.print <<EOT
    498   cell nMruby::#{ct_name}_Initializer #{vm_name}_#{ct_name}_Initializer{ };
    499 EOT
    500         end
    501       }
    502     }
    503 
    504     file.print "  // MBP602\n"
    505     @@ptr_list.each{ |name,tment|
    506       file.print <<EOT
    507   cell nMruby::#{name} C#{name} { };
    508 EOT
    509     }
    510 
    511     file.print "  // MBP603\n"
    512     @@struct_list.each{ |name,sttype|
    513       file.print <<EOT
    514   cell nMruby::#{name} C#{name} { };
    515 EOT
    516     }
    517 
    518     if @@VM_celltypes == nil
    519       raise "are0"
    520     end
    521     @@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_name
    530           file.print "    cInitialize[] = #{vm_name}_#{ct_name}_Initializer.eInitialize;\n"
    531         }
    532       }
    533       if @@VM_ptr_list[vm_name] then
    534         @@VM_ptr_list[vm_name].each{ |name, tment|
    535           file.print "    cInitialize[] = C#{name}.eInitialize;\n"
    536         }
    537       end
    538       if @@VM_struct_list[vm_name] then
    539         @@VM_struct_list[vm_name].each{ |name, sttype|
    540           file.print "    cInitialize[] = C#{name}.eInitialize;\n"
    541         }
    542       end
    543       file.print "  };"
    544     }
    545    
    546   end
    547 
    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 ] then
    554       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 ] then
    556       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 ] then
    558       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 ] then
    560       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     else
    562       raise "Unknown #{ct_name}"
    563     end
    564   end
    565 
    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   end
    569 
    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 <<EOT
    572     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 EOT
    579 
    580     @func_head_array.each{ |f|
    581       if ! f.is_function? then
    582         next
    583       end
    584       if f.get_name != :initialize then
    585         func_name = f.get_name
    586       else
    587         func_name = :initialize_cell
    588       end
    589 
    590       ret_type = f.get_return_type
    591       n_param = 0
    592       f.get_paramlist.get_items.each{ |param|
    593         case param.get_direction
    594         when :IN, :INOUT, :OUT
    595           n_param += 1
    596         when :SEND, :RECEIVE
    597           raise "send, receive"
    598         end
    599       }
    600       if n_param > 0 then
    601         p_str = "MRB_ARGS_REQ( #{n_param} )"
    602       else
    603         p_str = "MRB_ARGS_NONE()"
    604       end
    605       file.print <<EOT
    606         mrb_define_method( mrb, rc, "#{func_name}", MrubyBridge_#{@celltype_name}_#{func_name}, #{p_str} );
    607 EOT
    608     }
    609   end
    610 
    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 <<EOT
    616         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 EOT
    629 
    630     if t[2] == :Char then
    631       file.print <<EOT
    632         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 EOT
    635     end
    636   end
    637 
    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_name
    640     structType = @@struct_list[ tag ]
    641     file.print  <<EOT
    642         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 EOT
    649 
    650       structType.get_members_decl.get_items.each{ |d|
    651         file.print "  STRUCT_INIT_MEMBER( #{tag}, #{d.get_name} )\n"
    652       }
    653   end
    654 
    655   #===  受け口関数の preamble (C言語)を生成する
    656   #     必要なら preamble 部に出力する
    657   #file::           FILE        出力先ファイル
    658   #b_singleton::    bool        true if singleton
    659   #ct_name::        Symbol
    660   #global_ct_name:: string
    661   def gen_preamble( file, b_singleton, ct_name, global_ct_name )
    662     if @@celltypes[ ct_name ] then
    663       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 ] then
    668       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 ] then
    671       gen_preamble_ptr( file, b_singleton, ct_name, global_ct_name )
    672     elsif @@struct_list[ ct_name ] then
    673       gen_preamble_struct( file, b_singleton, ct_name, global_ct_name )
    674     else
    675       raise "Unknown #{ct_name}"
    676     end
    677   end
    678 
    679   def gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )
    680     file.print <<EOT
    681 /* 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 #else
    692 #define DLLEXPORT
    693 #endif
    694 
    695 #ifndef NULL
    696 #define NULL 0
    697 #endif
    698 EOT
    699   end
    700 
    701   def gen_preamble_instance( file, b_singleton, ct_name, global_ct_name )
    702     file.print <<EOT
    703 
    704 /* RData MBP001 */
    705 static void
    706 #{@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}_free
    717 };
    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 EOT
    730 
    731     # mikan namespace
    732     nsp = NamespacePath.new( :nMruby, true )
    733     nsp.append! ct_name
    734     ct = Namespace.find nsp
    735 
    736     ct.get_cell_list.each{ |cell|
    737       if cell.is_generate? then
    738         name_array = ct.get_name_array( cell )
    739         file.print "\t{ \"#{cell.get_name}\", #{name_array[8]} },\n"
    740       end
    741     }
    742 
    743     file.print <<EOT
    744 \t{ 0, 0 },
    745 };
    746 
    747 EOT
    748 
    749   end
    750 
    751   def gen_preamble_ptr( file, b_singleton, ct_name, global_ct_name )
    752     tment = @@ptr_list[ ct_name ]
    753     file.print <<EOT
    754 
    755 GET_SET_#{tment[3]}( #{tment[1]}, #{tment[0]} )
    756 POINTER_CLASS( #{tment[1]}, #{tment[0]} )
    757 EOT
    758   end
    759 
    760   def gen_preamble_struct( file, b_singleton, ct_name, global_ct_name )
    761     tag = ct_name
    762     structType = @@struct_list[ tag ]
    763     file.print <<EOT
    764 /* struct #{tag} */
    765 STRUCT_CLASS( #{tag} )
    766 EOT
    767 
    768     structType.get_members_decl.get_items.each{ |d|
    769       type = d.get_type.get_original_type
    770       case type
    771       when IntType, CIntType
    772         bit_size = type.get_bit_size
    773         case bit_size
    774         when -11, -1
    775           tType = "Char"
    776           ttype = "char"
    777         when -2
    778           tType = "Short"
    779           ttype = "short"
    780         when -3
    781           tType = "Int"
    782           ttype = "int"
    783         when -4
    784           tType = "Long"
    785           ttype = "long"
    786         when -5
    787           tType = "IntPtr"
    788           ttype = "intptr"
    789         when 8, 16, 32, 64
    790           tType = "Int#{bit_size}"
    791           ttype = "int#{bit_size}"
    792         else
    793             raise "cannot handle bit_size #{bit_size}"
    794         end
    795         file.print "MEMBER_GET_SET_INT( #{tag}, #{d.get_name}, #{tType}, #{ttype} )\n"
    796       when FloatType, CFloatType
    797         file.print "MEMBER_GET_SET_FLOAT( #{tag}, #{d.get_name} )\n"
    798       else
    799         raise "cannot handle type"
    800       end
    801     }
    802 
    803   end
    804 
    805   def gen_preamble_instance_proto( file, b_singleton, ct_name, global_ct_name )
    806     file.print <<EOT
    807 //  Prototype MBP400
    808 mrb_value  MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self);
    809 EOT
    810 
    811     @func_head_array.each{ |f|
    812       if ! f.is_function? then
    813         next
    814       end
    815       if f.get_name != :initialize then
    816         func_name = f.get_name
    817       else
    818         func_name = :initialize_cell
    819       end
    820 
    821       ret_type  = f.get_return_type
    822       ret_type0 = f.get_return_type.get_original_type
    823       b_void    = ret_type0.is_void?
    824       plist     = f.get_paramlist.get_items
    825 
    826       file.print <<EOT
    827 mrb_value  MrubyBridge_#{@celltype_name}_#{func_name}( mrb_state *mrb, mrb_value self );
    828 EOT
    829     }
    830   end
    831 
    832   def gen_preamble_instance_initialize( file, b_singleton, ct_name, global_ct_name )
    833     file.print <<EOT
    834 
    835 /* MBP100 */
    836 mrb_value
    837 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 EOT
    864   end
    865 
    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? then
    870         next
    871       end
    872       if f.get_name != :initialize then
    873         func_name = f.get_name
    874       else
    875         func_name = :initialize_cell
    876       end
    877 
    878       ret_type  = f.get_return_type
    879       ret_type0 = f.get_return_type.get_original_type
    880       b_void    = ret_type0.is_void?
    881       plist     = f.get_paramlist.get_items
    882 
    883       file.print <<EOT
    884 
    885 /* bridge function (MBP101) */
    886 mrb_value
    887 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 EOT
    892      
    893       file.print "      /* variables for return & parameter (MBP110) */\n"
    894       if ! b_void then
    895         file.print "    ", ret_type.get_type_str, "\tret_val", ret_type.get_type_str_post, ";\n"
    896       end
    897       arg_str = ""
    898       n_param  = 0
    899       n_scalar = 0
    900       n_ptr    = 0
    901       n_struct = 0
    902       plist.each{ |param|
    903         case param.get_direction
    904         when :IN, :INOUT, :OUT
    905           type = param.get_type.get_original_type
    906           case type
    907           when IntType
    908             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 += 1
    912             n_scalar += 1
    913           when FloatType
    914             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 += 1
    918             n_scalar += 1
    919           when BoolType
    920             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 += 1
    924             n_scalar += 1
    925           when PtrType
    926             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 += 1
    930             n_ptr += 1
    931           when StructType
    932             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 += 1
    936             n_struct += 1
    937           else
    938             raise "Unkown type"
    939           end
    940         end
    941       }
    942 
    943       if n_param > 0 then
    944         file.print "    /* retrieve arguments (MBP111) */\n"
    945         file.print "    mrb_get_args(mrb, \"#{arg_str}\""
    946         plist.each{ |param|
    947           case param.get_direction
    948           when :IN, :INOUT, :OUT
    949             type = param.get_type.get_original_type
    950             case type
    951             when IntType
    952               file.print ", &mrb_", param.get_name
    953             when FloatType
    954               file.print ", &mrb_", param.get_name
    955             when BoolType
    956               file.print ", &mrb_", param.get_name
    957             when PtrType
    958               file.print ", &mrb_", param.get_name
    959             when StructType
    960               file.print ", &mrb_", param.get_name
    961             else
    962               raise "Unkown type"
    963             end
    964           end
    965         }
    966         file.print " );\n"
    967 
    968         if n_scalar > 0 || n_struct > 0 then
    969           file.print "  /* convert mrb to C (MBP112) */\n"
    970         end
    971         plist.each{ |param|
    972           case param.get_direction
    973           when :IN, :INOUT, :OUT
    974             type = param.get_type.get_original_type
    975             case type
    976             when IntType
    977               ttype = type.get_original_type
    978               tment = get_type_map_ent ttype
    979               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 FloatType
    982               file.print "      #{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"
    983             when BoolType
    984               file.print "      #{param.get_name} = mrb_test( mrb_#{param.get_name} );\n"
    985             when PtrType
    986               ttype = type.get_type.get_original_type
    987               case ttype
    988               when StructType
    989                 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 IntType
    992               when FloatType
    993               when BoolType
    994               else
    995                 raise "cannot handle type"
    996               end
    997             when StructType
    998               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             else
    1001               raise( "canot treat class" )
    1002             end
    1003           end
    1004         }
    1005 
    1006         if n_ptr > 0 then
    1007           file.print "  /* convert mrb to C for pointer types (MBP113) */\n"
    1008         end
    1009         plist.each{ |param|
    1010           case param.get_direction
    1011           when :IN, :INOUT, :OUT
    1012             type = param.get_type.get_original_type
    1013             case type
    1014             when IntType
    1015             when FloatType
    1016             when BoolType
    1017             when PtrType
    1018               case type.get_type.get_original_type
    1019               when StructType
    1020               when IntType
    1021                 ptrMrb2C file, type, param
    1022               when FloatType
    1023                 ptrMrb2C file, type, param
    1024               when BoolType
    1025                 ptrMrb2C file, type, param
    1026               else
    1027                 raise "cannot handle type"
    1028               end
    1029             when StructType
    1030             else
    1031               raise( "canot treat class" )
    1032             end
    1033           end
    1034         }
    1035 
    1036       end
    1037 
    1038       file.print "      /* calling target (MBP120) */\n"
    1039       if ! b_void then
    1040         file.print "    ret_val = "
    1041       else
    1042         file.print "    "
    1043       end
    1044       delim = ""
    1045       file.print "cTECS_", f.get_name, "( "
    1046       plist.each{ |param|
    1047         if param.get_type.get_original_type.kind_of? StructType then
    1048           aster = "*"
    1049         else
    1050           aster = ""
    1051         end
    1052         file.print delim, aster, param.get_name
    1053         delim = ", "
    1054       }
    1055       file.print " );\n"
    1056      
    1057       file.print "      /* return (MBP130) */\n"
    1058       case ret_type0
    1059       when BoolType
    1060         file.print "    return ret_val ? mrb_true_value() : mrb_false_value();\n"
    1061       when IntType
    1062         file.print "    return mrb_fixnum_value( ret_val );\n"
    1063       when FloatType
    1064         file.print "    return mrb_float_value( mrb, ret_val );\n"
    1065       when VoidType
    1066         file.print "    return  mrb_nil_value();\n"
    1067       else
    1068         raise "unknown type"
    1069       end
    1070 
    1071       file.print "}\n"
    1072     }
    1073   end
    1074 
    1075   def ptrMrb2C file, type, param
    1076     ttype = type.get_type.get_original_type
    1077     tment = get_type_map_ent ttype
    1078     tstr = tment[1]
    1079 =begin
    1080     case ttype
    1081     when IntType
    1082       bit_size = ttype.get_bit_size
    1083       case bit_size
    1084       when -1, -11
    1085         tstr = "Char"
    1086       when 8, 16, 32, 64
    1087         tstr = "Int#{bit_size}"
    1088       when -2
    1089         tstr = "Short"
    1090       when -3
    1091         tstr = "Int"
    1092       when -4
    1093         tstr = "Long"
    1094       when -5
    1095         tstr = "IntPtr"
    1096       else
    1097         raise "not handle type"
    1098       end
    1099     when FloatType
    1100       if ttype.get_bit_size == 32 then
    1101         tstr = "Float32"
    1102       else
    1103         tstr = "Double64"
    1104       end
    1105     when BoolType
    1106       tstr = "Bool"
    1107     when StructType
    1108       raise "not handle type 2 #{ttype}"
    1109     else
    1110       raise "not handle type 2 #{ttype}"
    1111     end
    1112 =end
    1113     if( param.get_size ) then
    1114       sz_str = param.get_size.to_s
    1115     elsif param.get_string then      # mikan とりあえず size_is と string の同時指定 (二重ポインタ) はなし
    1116       sz_str = param.get_string.to_s
    1117     else
    1118       sz_str = "1"
    1119     end
    1120     # unsigned 型の場合には cast が必要
    1121     if ttype.get_original_type.get_type_str != param.get_type.get_type.get_type_str then
    1122       cast_str = "(#{param.get_type.get_type_str})"
    1123     else
    1124       cast_str = ""
    1125     end
    1126 
    1127     modify = ""
    1128     case param.get_direction
    1129     when :OUT, :INOUT
    1130       case tstr
    1131       when "Char", "SChar", "UChar"
    1132         modify = "Mod"
    1133       end
    1134     end
    1135     if param.is_nullable? then
    1136       nullable = "Nullable"
    1137     else
    1138       nullable = ""
    1139     end
    1140 
    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   end
    1145 
    1146   def get_celltype_name
    1147     @celltype_name
    1148   end
    1149 
    1150   #=== プラグイン引数 ignoreUnsigned
    1151   def set_ignoreUnsigned rhs
    1152     if rhs == "true" || rhs == nil then
    1153       @b_ignoreUnsigned = true
    1154     end
    1155   end
    1156   #=== プラグイン引数 include
    1157   def set_include rhs
    1158     funcs = rhs.split ','
    1159     funcs.each{ |rhs_func|
    1160       found = false
    1161       rhs_func.gsub!( /\s/, "" )
    1162       @signature.get_function_head_array.each{ |a|
    1163         if rhs_func.to_sym == a.get_name then
    1164           found = true
    1165         end
    1166       }
    1167       if found == false then
    1168         cdl_error( "MRB1009 include function '$1' not found in signagture '$2'", rhs, @signature.get_name )
    1169       else
    1170         @includes << rhs_func.to_sym
    1171       end
    1172     }
    1173   end
    1174   #=== プラグイン引数 exclude
    1175   def set_exclude rhs
    1176     funcs = rhs.split ','
    1177     funcs.each{ |rhs_func|
    1178       found = false
    1179       rhs_func.gsub!( /\s/, "" )
    1180       @signature.get_function_head_array.each{ |a|
    1181         if rhs_func.to_sym == a.get_name then
    1182           found = true
    1183         end
    1184       }
    1185       if found == false then
    1186         cdl_error( "MRB1010 exclude function '$1' not found in signagture '$2", rhs, @signature.get_name )
    1187       else
    1188         @excludes << rhs_func.to_sym
    1189       end
    1190     }
    1191   end
    119268end
    1193 
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/NotifierPlugin.rb

    r321 r429  
    11# -*- coding: utf-8 -*-
     2#
     3#  TECS Generator
     4#      Generator for TOPPERS Embedded Component System
    25#
    36#  Copyright (C) 2015 by Ushio Laboratory
     
    58#  Copyright (C) 2015-2016 by Embedded and Real-Time Systems Laboratory
    69#              Graduate School of Information Science, Nagoya Univ., JAPAN
     10#  Copyright (C) 2015-2018 by TOPPERS Project
    711#
     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#++
    844
    945NotifierPluginArgProc = {
     
    3167        #  - 受け口関数 - 一般化を行うと,実行時コストが大きく増大してしまうことが
    3268        #    確認されている.このため,一般化は行わない.EntryPropertyにも含めない.
    33         #  - セルインデックス - CELLIDX型で,型の規定はないが,"ポインタ値であったり
    34         #    整数値あったりする。" (TECS 5.3.6) より,インデックスかポインタある
     69        #  - セルインデックス - CELLIDX型で,型の規定はないが,"ホ゜インタ値て゛あったり
     70        #    整数値て゛あったりする。" (TECS 5.3.6) より,インデックスかポインタある
    3571        #    ことが分かる.インデックスだとすると,この値はセルCBのアドレッシングに
    3672        #    使用されるので,intptr_tに収まる筈である.ポインタの場合,当然intptr_t
     
    5894        #  - アダプタ関数へののポインタ
    5995        #  - アダプタ関数の引数
     96        #
     97        #   $Id$
    6098
    6199        # @private
     
    126164                        # @param [Cell, Symbol] cell セル.セルについて一般化する場合は `:generic`
    127165                        # @param [Integer, Symbol, nil] subscript 添字.添字について一般化する場合は `:generic`
     166                        # @param [Celltype] 呼び先のセルタイプ、cell==:generic の場合のみ有効
    128167                        # @private
    129                         def generate_inner(context, fn_name, cell, subscript)
     168                        def generate_inner(context, fn_name, cell, subscript, callee_ct=nil)
    130169                                source_file = context.source_file
    131170                                header_file = context.header_file
     
    139178                                unless ct.is_singleton?
    140179                                        if cell == :generic
    141                                                 params << "(CELLIDX)extinf"
     180                                                params << "(#{callee_ct.get_global_name}_IDX)extinf"
     181                                                # params << "(CELLIDX)extinf"
    142182                                        else
    143183                                                # セルのCELLIDXを得る
     
    231271
    232272                                                generate_inner context, fn_name,
    233                                                         :generic, subscript
     273                                                        :generic, subscript, ct
    234274
    235275                                                props.each { |prop|
     
    443483            # join:: Join : 結合 (declarationがPortであるもの)
    444484                def validate_join(handler, cell, join)
    445                 return !generate_attr_map(handler, cell).nil?
     485        return !generate_attr_map(handler, cell).nil?
    446486                end
    447487
     
    870910        parse_plugin_arg
    871911        unless @factory
    872                 cdl_error("ASP1003 celltype $1: option factory is not specified",
     912                cdl_error("NTF1003 celltype $1: option factory is not specified",
    873913                        celltype.get_name)
    874914        end
    875915        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",
    877917                        celltype.get_name)
    878918        end
     
    881921    def set_factory(template_string)
    882922        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",
    884924                        celltype.get_name)
    885925        end
     
    889929    def set_factory_output_file(output_file)
    890930        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",
    892932                        celltype.get_name)
    893933        end
     
    896936
    897937    def gen_factory file
    898         puts "===== begin #{@celltype.get_name.to_s} plugin ====="
     938        # puts "===== begin #{@celltype.get_name.to_s} plugin ====="
    899939
    900940        kernelCfg = AppFile.open( "#{$gen}/#{@output_file}" )
     
    920960                        subst_attr = @celltype.find(name)
    921961                        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.",
    923963                                @celltype.get_name, name)
    924964                        end
     
    933973
    934974        kernelCfg.close
    935         puts "===== end #{@celltype.get_name.to_s} plugin ====="
     975        # puts "===== end #{@celltype.get_name.to_s} plugin ====="
    936976    end
    937977
    938978    def gen_factory_for_cell(kernelCfg, cell)
     979      # print "########## gen_factory_for_cell cell=#{cell.get_name}\n"
    939980        handler_flags = []
    940981        handler_args = []
     
    957998                        when 'false' then ignoreErrors = false
    958999                        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",
    9601001                                        cell.get_name, ignoreErrors )
    9611002                                ignoreErrors = false
    9621003                end
    9631004
     1005    # ドメイン指定用文字列
     1006    pre_text  = ""
     1007    post_text = "\n"
     1008    indent    = ""
     1009 
    9641010        [EVENT_HANDLER, ERROR_HANDLER].each { |handler|
    9651011                # 呼び口の結合を取得
    9661012                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
    9671024
    9681025                # ハンドラタイプを判別する
     
    9721029
    9731030                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 )
    9751032                        next
    976                 end
     1033        end
    9771034
    9781035                        # 最初に見つかった有効なハンドラタイプを使用
    9791036                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
    9801086
    9811087                        # 通知ハンドラで「エラーが発生するはずがない」のに「エラーハンドラが指定されている」
     
    9841090                        #  なため、検出は行わない。)
    9851091                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.",
    9871093                                cell.get_name, handler_flag)
    9881094                end
    9891095                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.",
    9911097                                cell.get_name, handler_flag)
    9921098                end
     
    10551161                        # $id$等の置換
    10561162                        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
    10641192
    10651193end
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/OpaqueRPCPlugin.rb

    r321 r429  
    5656  #=== RPCPlugin の initialize
    5757  #  説明は 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 )
    5959    super
    6060    @b_noClientSemaphore = false
     
    254254    nest = @end_region.gen_region_str_pre file
    255255    nest_str = "  " * nest
     256    if @next_cell_port_subscript then
     257      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     258    else
     259      subscript = ""
     260    end
    256261
    257262    if @serverErrorHandler then
     
    282287#{nest_str}  cell #{@rpc_server_channel_celltype_name} #{@serverChannelCell}_Unmarshaler {
    283288#{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};
    285290#{serverErrorHandler_str}#{nest_str}  };
    286291EOT
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/RPCPlugin.rb

    r321 r429  
    6565  #=== RPCPlugin の initialize
    6666  #  説明は 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 )
    6868    super
    6969    @b_noClientSemaphore = false
     
    197197    nest = @region.gen_region_str_pre file
    198198    indent_str = "  " * nest
     199    if @next_cell_port_subscript then
     200      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     201    else
     202      subscript = ""
     203    end
    199204
    200205    file.print <<EOT
     
    233238    file.print <<EOT
    234239#{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};
    236241#{indent_str}  cTDR         = #{@channelCellName}.eTDR;
    237242#{indent_str}  cEventflag   = #{@channelCellName}.eEventflag;
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedOpaqueRPCPlugin.rb

    r321 r429  
    6868  #=== RPCPlugin の initialize
    6969  #  説明は 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 )
    7171    super
    7272    initialize_opaque_marshaler
     
    221221    nest = @start_region.gen_region_str_pre file
    222222    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
    223229
    224230    # セルを探す
     
    303309#{indent_str}cell #{@unmarshaler_celltype_name} #{@cell_name}_Server {
    304310#{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};
    306312#{ppallocator_join}#{indent_str}};
    307313EOT
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedRPCPlugin.rb

    r321 r429  
    6262  #=== RPCPlugin の initialize
    6363  #  説明は 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 )
    6565
    6666    # mikan プラグインオプション指定の不一致のチェック task_priority,
     
    236236    nest = @region.gen_region_str_pre file
    237237    indent_str = "  " * nest
     238    if @next_cell_port_subscript then
     239      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     240    else
     241      subscript = ""
     242    end
    238243
    239244    # セルを探す
     
    291296    file.print <<EOT
    292297#{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};
    294299#{indent_str}  cTDR         = #{@shared_channel_cell}.eTDR;
    295300#{indent_str}  cEventflag   = #{@shared_channel_cell}.eEventflag;
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/ThroughPlugin.rb

    r321 r429  
    4747#@next_cell:: Cell                    呼び口を結合するセル
    4848#@next_cell_port_name:: Symbol       呼び口を結合する受口の名前
     49#@next_cell_port_subscript::Nil|Integer   呼び口を結合する受口の配列添数.受け口配列でない場合 nil
    4950#@signature::      Signature          シグニチャ
    5051#@celltype::       Celltype           呼び先のセルのセルタイプ. through が連接する場合、最終的な呼び先のセルのセルタイプ
     
    7475  #next_cell::      Cell               呼び口を接続するセル
    7576  #next_cell_port_name:: Symbol        呼び口を接続する受口の名前
     77  #next_cell_port_subscript:: Nil|Integer  呼び口を接続する受口配列添数
    7678  #signature::      Signature          シグニチャ
    7779  #celltype::       Celltype           セルタイプ (呼び先のセルのセルタイプ)
    7880  #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 )
    8082    super()
    8183    @cell_name = cell_name                      # 生成すべきセル名(受け口側のセル名)
     
    8385    @next_cell = next_cell                      # 呼び先のセル
    8486    @next_cell_port_name = next_cell_port_name
     87    @next_cell_port_subscript = next_cell_port_subscript
    8588    @signature = signature
    8689    @entry_port_name = :"eThroughEntry"
     
    136139  def get_through_entry_port_name
    137140    @entry_port_name
     141  end
     142
     143  #===  生成されたセルの受け口配列添数を得る
     144  def get_through_entry_port_subscript
     145    @entry_port_subscript
    138146  end
    139147
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/TracePlugin.rb

    r321 r429  
    4444  #=== TracePlugin の initialize
    4545  #  説明は 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 )
    4747
    4848    @maxArrayDisplay = 16
     
    141141      nest = @region.gen_region_str_pre file
    142142      indent_str =  "  " * nest
     143      if @next_cell_port_subscript then
     144        subscript = '[' + @next_cell_port_subscript.to_s + ']'
     145      else
     146        subscript = ""
     147      end
    143148
    144149      if @probeName then
     
    155160      file.print <<EOT
    156161#{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};
    158163#{probeName_str}#{caller_cell_str}#{indent_str}};
    159164EOT
     
    210215    }
    211216    file.print( " );\n" )
     217    if @next_cell_port_subscript then
     218      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     219    else
     220      subscript = ""
     221    end
    212222
    213223    file.print <<EOT
    214224\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 );
    216226EOT
    217227
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    464464        /* Channel Lock */
    465465        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        }
    468470EOT
    469471
     
    554556        /* Channel Unlock */
    555557        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        }
     562EOT
     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_;
    558568EOT
    559569
     
    630640        file.print <<EOT
    631641        }else{
    632                 return;
     642                return E_ID;
    633643        }
    634644EOT
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb

    r321 r429  
    388388    };
    389389#{ppallocator_dealloc_str}
    390     return;
     390    return E_OK;
    391391
    392392error_reset:
     
    394394        (void)cTDR_reset();
    395395#{ppallocator_dealloc_str}
     396    return E_OK;
    396397EOT
    397398
Note: See TracChangeset for help on using the changeset viewer.