Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1AlarmPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1AlarmPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1AlarmPlugin.rb	(revision 374)
@@ -35,5 +35,5 @@
 #   の責任を負わない．
 #  
-#   $Id
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1DelayTaskPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1DelayTaskPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1DelayTaskPlugin.rb	(revision 374)
@@ -35,5 +35,5 @@
 #   の責任を負わない．
 #  
-#   $Id
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1ISRPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1ISRPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1ISRPlugin.rb	(revision 374)
@@ -35,5 +35,5 @@
 #   の責任を負わない．
 #  
-#   $Id
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1KernelPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1KernelPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1KernelPlugin.rb	(revision 374)
@@ -35,5 +35,5 @@
 #   の責任を負わない．
 #  
-#   $Id
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1ResourcePlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1ResourcePlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1ResourcePlugin.rb	(revision 374)
@@ -35,5 +35,5 @@
 #   の責任を負わない．
 #  
-#   $Id
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1TaskPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1TaskPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1TaskPlugin.rb	(revision 374)
@@ -35,5 +35,5 @@
 #   の責任を負わない．
 #  
-#   $Id
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/DomainPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/DomainPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/DomainPlugin.rb	(revision 374)
@@ -46,4 +46,5 @@
   #option::String : domain 指定子の第二引数
   def initialize( region, domain_type_name, option )
+    super()
   end
 
@@ -77,3 +78,14 @@
     return false
   end
+
+  #== ドメイン種別を返す
+  #return::Symbol :kernel, :user, :OutOfDomain
+  def get_kind
+    :kernel
+  end
+
+  #== factory 生成
+  # DomainPlugin の factory は特定のファイルへの出力が想定されていない
+  def gen_factory
+  end
 end
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2Cache.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2Cache.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2Cache.rb	(revision 374)
@@ -1,3 +1,4 @@
 # -*- coding: utf-8 -*-
 
+#   $Id$
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2CyclicHandlerPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2CyclicHandlerPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2CyclicHandlerPlugin.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2008-2012 by TOPPERS Project
+#   Copyright (C) 2008-2017 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2DataqueuePlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2DataqueuePlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2DataqueuePlugin.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2008-2012 by TOPPERS Project
+#   Copyright (C) 2008-2017 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -35,4 +35,5 @@
 #   の責任を負わない．
 #  
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2EventflagPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2EventflagPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2EventflagPlugin.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2008-2012 by TOPPERS Project
+#   Copyright (C) 2008-2017 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -35,4 +35,5 @@
 #   の責任を負わない．
 #  
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2FixedSizeMemoryPoolPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2FixedSizeMemoryPoolPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2FixedSizeMemoryPoolPlugin.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2008-2012 by TOPPERS Project
+#   Copyright (C) 2008-2017 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -35,4 +35,5 @@
 #   の責任を負わない．
 #  
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2HandlerPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2HandlerPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2HandlerPlugin.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2008-2014 by TOPPERS Project
+#   Copyright (C) 2008-2018 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -77,13 +77,13 @@
         elsif @plugin_arg_str == "ISR"
             file.print <<EOT
-#{tab}ATT_ISR({ #{val[:attribute]}, &#{cell_CB_name}, #{val[:interruptNumber]}, tISR_start, #{val[:priority]} });
+#{tab}ATT_ISR({ #{val[:attribute]}, #{cell_CBP}, #{val[:interruptNumber]}, tISR_start, #{val[:priority]} });
 EOT
         elsif @plugin_arg_str == "INIT_ROUTINE"
             file.print <<EOT
-#{tab}ATT_INI({ #{val[:attribute]}, &#{cell_CB_name}, tInitializeRoutine_start });
+#{tab}ATT_INI({ #{val[:attribute]}, #{cell_CBP}, tInitializeRoutine_start });
 EOT
         elsif @plugin_arg_str == "TERM_ROUTINE"
             file.print <<EOT
-#{tab}ATT_TER({ #{val[:attribute]}, &#{cell_CB_name}, tTerminateRoutine_start });
+#{tab}ATT_TER({ #{val[:attribute]}, #{cell_CBP}, tTerminateRoutine_start });
 EOT
         else
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2KernelObjectPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2KernelObjectPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2KernelObjectPlugin.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2008-2012 by TOPPERS Project
+#   Copyright (C) 2008-2017 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -186,5 +186,5 @@
                 val = {}
                 @celltype.get_attribute_list.each{ |a|
-                    p a.get_name
+                    # p a.get_name
                     if a.get_type.kind_of?( ArrayType )
                         val[a.get_name] = []
@@ -218,5 +218,6 @@
                 if val[:id].nil? != true
                     puts val[:id]
-                    val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
+                    #val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
+                    val[:id] = @celltype.subst_name( val[:id], @celltype.get_name_array( cell ) )
                 end
                 # $cbp$の代わり
@@ -244,6 +245,6 @@
                         file2.puts "}\n"
                     else
-                        print "~~~~~ #{cell.get_region.get_name.to_s} is included in"
-                        p @@region_list
+                        dbgPrint "~~~~~ #{cell.get_region.get_name.to_s} is included in"
+                        # p @@region_list
                     end
                     file3 = AppFile.open( "#{$gen}/tecsgen_#{cell_domain_root.get_name.to_s}.cfg" )
@@ -260,6 +261,6 @@
                 if !val[:accessPattern].nil?
                     puts "===== begin check regions #{cell.get_name} ====="
-                    p val[:accessPattern]
-                    p val[:accessPattern].class
+                    # p val[:accessPattern]
+                    # p val[:accessPattern].class
 
                     #ep = [ :eTaskActivate, :eTaskControl, :eTaskManage, :eTaskRefer ]
@@ -273,8 +274,8 @@
                         if acptnx != "OMIT"
                             acv << acptnx
-                            p acv[i]
+                            # p acv[i]
                         elsif cell_domain_type.get_option.to_s == "trusted"
                             acv << "TACP_KERNEL"
-                            p acv[i]
+                            # p acv[i]
                         elsif cell_domain_type.get_option.to_s != "OutOfDomain"
                             acv << "TACP(#{cell_domain_root.get_name.to_s})"
@@ -286,5 +287,5 @@
                     }
 
-                    print "acv = "
+                    dbgPrint "acv = "
                     p acv
 
@@ -322,9 +323,9 @@
 
     def self.check_referenced_cells()
-        puts "===== begin check registered celltype ====="
+        dbgPrint "===== begin check registered celltype =====\n"
         self.get_celltype_list.each { |ct|
-            p ct.get_name.to_s
+            dbgPrint( ct.get_name.to_s + "\n" )
         }
-        puts "===== end check registered celltype ====="
+        dbgPrint "===== end check registered celltype =====\n"
 
 =begin
@@ -334,5 +335,5 @@
                 j = cell.get_join_list.get_item(p.get_name)
                 printf "===== check call port : "
-                p p.get_name.to_s
+                # p p.get_name.to_s
                 next if j.nil? # 未結合の場合
                 if @@celltype_list.include?(j.get_celltype)
@@ -341,7 +342,7 @@
                     j.get_cell.set_referenced_cell(cell, j.get_port_name)
                     printf "===== check joined rhs cell : "
-                    p j.get_cell.get_name.to_s
+                    # p j.get_cell.get_name.to_s
                     printf "===== check joined rhs port_name : "
-                    p j.get_port_name
+                    # p j.get_port_name
                 end
             }
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2ObjectPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2ObjectPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2ObjectPlugin.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2008-2014 by TOPPERS Project
+#   Copyright (C) 2008-2017 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -35,4 +35,5 @@
 #   の責任を負わない．
 #  
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2Plugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2Plugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2Plugin.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2014 by TOPPERS Project
+#   Copyright (C) 2018 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -44,5 +44,17 @@
 
   def initialize( region, name, option )
+    super
     print "HRP2Plugin: initialize: region=#{region.get_name}, domainName=#{name}, option=#{option}\n"
+    @region = region
+    @name   = name
+
+    case option
+    when "trusted", "nontrusted", "OutOfDomain"
+      # OK
+      @option = option
+    else
+      cdl_error( "HRPPlugin: '$1' is unacceptable domain kind, specify 'trusted' or 'nontrusted'", option )
+      @option = "trusted"   # とりあえず trusted を設定しておく
+    end
   end
 
@@ -108,4 +120,17 @@
   end
 
+  #== ドメイン種別を返す
+  #return::Symbol :kernel, :user, :OutOfDomain
+  def get_kind
+    case @option
+    when "trusted"
+      return :kernel
+    when "nontrusted"
+      return :user
+    when "OutOfDomain"
+      return :OutOfDomain
+    end
+  end
+
   def joinable?(current_region, next_region, through_type )
     print "HRP2Plugin: joinable? from #{current_region.get_name} to #{next_region.get_name} (#{through_type})\n"
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2PostHook.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2PostHook.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2PostHook.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2012 by TOPPERS Project
+#   Copyright (C) 2017 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -35,4 +35,5 @@
 #   の責任を負わない．
 #  
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2PriorityDataqueuePlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2PriorityDataqueuePlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2PriorityDataqueuePlugin.rb	(revision 374)
@@ -35,4 +35,5 @@
 #   の責任を負わない．
 #  
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2RPCPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2RPCPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2RPCPlugin.rb	(revision 374)
@@ -35,4 +35,5 @@
 #   の責任を負わない．
 #  
+#   $Id$
 #++
 
@@ -70,5 +71,5 @@
   #=== RPCPlugin の initialize
   #  説明は ThroughPlugin (plugin.rb) を参照
-  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
     super
     @b_noClientSemaphore = false
@@ -234,5 +235,5 @@
     if cell.get_allocator_list.length > 0 then
 
-      dbgPrint "make allocator"
+      dbgPrint "make allocator\n"
       file.print "#{indent_str}[allocator("
 
@@ -269,8 +270,14 @@
     nest = @end_region.gen_region_str_pre file
     indent_str = "  " * nest
+    nest_str = "  " * nest
+    if @next_cell_port_subscript then
+      subscript = '[' + @next_cell_port_subscript.to_s + ']'
+    else
+      subscript = ""
+    end
 
     file.print <<EOT
 #{indent_str}cell #{@rpc_channel_celltype_name}Server #{@cell_name}Body {
-#{indent_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{indent_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
 //#{indent_str}    #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name};
 #{indent_str}  //cTDR         = #{@channelCellName}.eTDR;
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2SVCPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2SVCPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2SVCPlugin.rb	(revision 374)
@@ -35,4 +35,5 @@
 #   の責任を負わない．
 #  
+#   $Id$
 #++
 
@@ -83,5 +84,5 @@
   @@generated_celltype_header = {}
 
-  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
     super
     @ct_name_body = "#{@ct_name}SVCBody_#{@next_cell.get_name}_#{@next_cell_port_name}".to_sym
@@ -217,4 +218,9 @@
     nest = @end_region.gen_region_str_pre file
     nest_str = "  " * nest
+    if @next_cell_port_subscript then
+      subscript = '[' + @next_cell_port_subscript.to_s + ']'
+    else
+      subscript = ""
+    end
 
     # サーバー側チャンネルの生成 
@@ -224,5 +230,5 @@
 #{nest_str}  //  Server Side Channel
 #{nest_str}  cell #{@ct_name_body} #{@cell_name_body}{
-#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
 #{nest_str}  };
 EOT
@@ -241,4 +247,9 @@
     nest = @start_region.gen_region_str_pre file
     nest_str = "  " * nest
+    if @next_cell_port_subscript then
+      subscript = '[' + @next_cell_port_subscript.to_s + ']'
+    else
+      subscript = ""
+    end
 
     # クライアント側チャンネルの生成
@@ -247,5 +258,5 @@
 #{nest_str}  //  Client Side Channel
 #{nest_str}  cell #{@ct_name} #{@cell_name}{
-#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
 #{nest_str}  };
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2SemaphorePlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2SemaphorePlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2SemaphorePlugin.rb	(revision 374)
@@ -35,4 +35,5 @@
 #   の責任を負わない．
 #  
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2TaskPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2TaskPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2TaskPlugin.rb	(revision 374)
@@ -53,5 +53,6 @@
     # tab  : 
     def print_cfg_cre(file, cell, val, tab)
-        val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
+        #val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_global_name.to_s}" )
+        #val[:id] = @celltype.subst_name( val[:id], @celltype.get_name_array( cell ) )
         # $cbp$の代わり
         index = cell.get_id - @celltype.get_id_base
@@ -59,7 +60,8 @@
         cell_CB_name = "#{index}"
         # CRE_XXX/DEF_XXXの生成
-        print "assign task plugin\n"
+        dbgPrint "assign task plugin\n"
         domainOption = cell.get_region.get_domain_root.get_domain_type.get_option
         # if cell.get_region.get_region_type == :DOMAIN
+# cell.show_tree 1
         if domainOption != "OutOfDomain"
             # 保護ドメインに属する場合
@@ -69,4 +71,5 @@
                     raise "system task cannot have user stack."
                 end
+p "CRE_TSK 0 user=#{val[:userStackSize]} system=#{val[:systemStackSize]}"
                 file.print <<EOT
 #{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:systemStackSize]}, NULL });
@@ -77,4 +80,5 @@
                     raise "user task must have user stack."
                 end
+p "CRE_TSK 1"
                 if val[:systemStackSize] == "OMIT"
                     file.print <<EOT
@@ -82,4 +86,5 @@
 EOT
                 else
+p "CRE_TSK 2"
                     file.print <<EOT
 #{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:userStackSize]}, NULL, #{val[:systemStackSize]}, NULL });
@@ -138,7 +143,7 @@
                     regions = ct.get_domain_roots
                     regions_hrp2 = regions[ :HRP2 ]
-                    print "HRP2 domain in #{ct.get_name}: "
+                    dbgPrint "HRP2 domain in #{ct.get_name}: "
                     regions_hrp2.each { |reg|
-                        print reg.get_name
+                        dbgPrint reg.get_name
                     }
                     puts ""
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPHandlerPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPHandlerPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPHandlerPlugin.rb	(revision 374)
@@ -0,0 +1,145 @@
+# coding: utf-8
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2018 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+require_tecsgen_lib "HRPKernelObjectPlugin.rb"
+
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class HRPHandlerPlugin < HRPKernelObjectPlugin
+
+    ##
+    # oyama: add to avoid Ruby exception in code generation phase.
+    def new_cell cell
+        domainOption = cell.get_region.get_domain_root.get_domain_type.get_option
+        if (domainOption == "OutOfDomain") || (domainOption != "kernel")
+          cdl_error( "HRP9999 HRP handler '$1' must belong to kernel domain", cell.get_name )
+        end
+    end
+
+    ##
+    #
+    # file : output file (ex.tecsgen.cfg)
+    # cell : 
+    # val  : 
+    # tab  : 
+    def print_cfg_cre(file, cell, val, tab)
+        if !val[:id].nil?
+            val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
+        end
+        # $cbp$ã®ä»£ãã
+        index = cell.get_id - @celltype.get_id_base
+        #cell_CB_name = "#{@celltype.get_global_name}_CB_tab[#{index}]"
+        name_array = cell.get_celltype.get_name_array cell
+        cell_CBP = name_array[8]
+        # CRE_XXXã®çæ
+        domainOption = cell.get_region.get_domain_root.get_domain_type.get_option
+        if (domainOption == "OutOfDomain") || (domainOption != "kernel")
+            # ç¡æå± or ã¦ã¼ã¶ãã¡ã¤ã³ã«å±ããå ´å
+                raise "#{@plugin_arg_str.to_s.downcase} handler #{val[:id]} must belong to kernel domain."
+        elsif @plugin_arg_str == "CONFIG_INT"
+            file.print <<EOT
+#{tab}CFG_INT( #{val[:interruptNumber]}, { #{val[:attribute]}, #{val[:interruptPriority]} });
+EOT
+        elsif @plugin_arg_str == "ISR"
+            file.print <<EOT
+#{tab}CRE_ISR(#{val[:id]}, { #{val[:attribute]}, #{cell_CBP}, #{val[:interruptNumber]}, tISR_start, #{val[:isrPriority]} });
+EOT
+        elsif @plugin_arg_str == "DEF_INH"
+            name_array = @celltype.get_name_array cell
+            start = @celltype.subst_name( "$id$_start", name_array )
+            file.print <<EOT
+#{tab}DEF_INH(#{val[:interruptHandlerNumber]}, { #{val[:attribute]}, #{start} });
+EOT
+        elsif @plugin_arg_str == "DEF_EXC"
+            name_array = @celltype.get_name_array cell
+            start = @celltype.subst_name( "$id$_start", name_array )
+            file.print <<EOT
+#{tab}DEF_EXC(#{val[:cpuExceptionHandlerNumber]}, { #{val[:attribute]}, #{start} });
+EOT
+        elsif @plugin_arg_str == "INIT_ROUTINE"
+            file.print <<EOT
+#{tab}ATT_INI({ #{val[:attribute]}, #{cell_CBP}, tInitializeRoutine_start });
+EOT
+        elsif @plugin_arg_str == "TERM_ROUTINE"
+            file.print <<EOT
+#{tab}ATT_TER({ #{val[:attribute]}, #{cell_CBP}, tTerminateRoutine_start });
+EOT
+        else
+            raise "#{@plugin_arg_str} is unknown option"
+        end
+    end
+
+    def print_cfg_sac(file, val, acv)
+        if @plugin_arg_str == "CONFIG_INT"
+            # nothing to do
+        elsif @plugin_arg_str == "ISR"
+            # kernel.cdl ã® tISR ã§ accessPattern1 ï½ accessPattern4 ãå®ç¾©ããã¦ããã¨ãã®åæ®ã
+            # accessPattern1 ãå®ç¾©ããã¦ããªãå ´åããããã¸ã¯æ¥ãªãï¼å¾©æ´»ããã¨ãã«åãã¦æ®ãã¦ããï¼
+            # file.puts "SAC_#{@plugin_arg_str}(#{val[:id]}, { #{acv[:accessPattern1]}, #{acv[:accessPattern2]}, #{acv[:accessPattern3]}, #{acv[:accessPattern4]} });"
+            puts "*** Unsupported *** SAC_#{@plugin_arg_str}(#{val[:id]}, { #{acv[:accessPattern1]}, #{acv[:accessPattern2]}, #{acv[:accessPattern3]}, #{acv[:accessPattern4]} });\n"
+        elsif @plugin_arg_str == "DEF_INH"
+            # nothing to do
+        elsif @plugin_arg_str == "DEF_EXC"
+            # nothing to do
+        elsif @plugin_arg_str == "INIT_ROUTINE"
+            # nothing to do
+        elsif @plugin_arg_str == "TERM_ROUTINE"
+            # nothing to do
+        else
+            raise "#{@plugin_arg_str} is unknown option"
+        end
+    end
+
+end
+
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPKernelObjectManager.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPKernelObjectManager.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPKernelObjectManager.rb	(revision 374)
@@ -0,0 +1,86 @@
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2015-2018 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#
+#   $Id$
+#  
+#++
+# This file has been generated by gen_kernel_celltype.py
+class HRPKernelObjectManager
+	@@kernel_objs = [\
+		:tKernel, \
+		:tTask, \
+		:tSemaphore, \
+		:tEventflag, \
+		:tDataqueue, \
+		:tPriorityDataqueue, \
+		:tMutex, \
+		:tFixedSizeMemoryPool, \
+		:tTimeEventHandler, \
+		:tCyclicNotifier, \
+		:tAlarmNotifier, \
+		:tInterruptRequest, \
+		:tISR, \
+		:tInterruptHandler, \
+		:tCpuExceptionHandler, \
+		:tInitializeRoutine, \
+		:tTerminateRoutine, \
+		:tMessageBuffer, \
+	]
+
+    def initialize()
+        # 
+        #  æ¬ã¯ã©ã¹ã¯ã¤ã³ã¹ã¿ã³ã¹ãæããªãä»®æ³çãªã¯ã©ã¹ã§ãã
+        #
+        raise "class #{self.class.name} shall not have instances"
+    end
+    def self.include_celltype?(str)
+        return @@kernel_objs.include?(str)
+    end
+end
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPKernelObjectPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPKernelObjectPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPKernelObjectPlugin.rb	(revision 374)
@@ -0,0 +1,364 @@
+# coding: utf-8
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2018 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#
+#  $Id$
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class HRPKernelObjectPlugin < CelltypePlugin
+    # @@obj_hash = {}
+
+    #@celltype:: Celltype
+    #@option:: String     :ãªãã·ã§ã³æå­å
+    def initialize( celltype, option )
+        super
+        #
+        #  ããããã®ã«ã¼ãã«ãªãã¸ã§ã¯ããè§£æå¯¾è±¡ã»ã«ã¿ã¤ãã«è¿½å 
+        #  ç®çï¼
+        #   - ã«ã¼ãã«ãªãã¸ã§ã¯ãã®ã»ã«ãã¡ã¢ãªä¿è­·å¯¾è±¡å¤ã¨ãã
+        #    - ã«ã¼ãã«ãªãã¸ã§ã¯ãæ¬ä½ã®ç®¡çã¯TECSã§ãªãOSã§å®æ½ãããã
+        #   - ã«ã¼ãã«ãªãã¸ã§ã¯ãã®ã»ã«ã¸ã®ã¢ã¯ã»ã¹ãç´æ¥é¢æ°å¼åºã
+        #   ãã¨ãã
+        #    - ã·ã¹ãã ãµã¼ãã¹å¼åºãã¯OSãæä¾ãããã
+        HRPKernelObjectPlugin.set_celltype(celltype)
+    end
+  
+    #=== HRPKernelObjectPlugin#print_cfg_cre
+    # åç¨®ã«ã¼ãã«ãªãã¸ã§ã¯ãã®CRE_*ã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # tab :: string:   ã¤ã³ãã³ãç¨ã®tab
+    def print_cfg_cre(file, cell, val, tab)
+        raise "called virtual method print_cfg_cre in #{@celltype.get_name} plugin"
+    end
+  
+    #=== HRPKernelObjectPlugin#print_cfg_sac
+    # åç¨®ã«ã¼ãã«ãªãã¸ã§ã¯ãã®SAC_*ã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # acv :: string:   ã¢ã¯ã»ã¹ãã¯ã¿
+    def print_cfg_sac(file, val, acv)
+        raise "called virtual method print_cfg_sac in #{@celltype.get_name} plugin"
+    end
+  
+    #
+    #  ã»ã«ã¿ã¤ããã©ã°ã¤ã³ã®æ¬ä½ã¡ã½ãã
+    #   - éçAPIã®çæ
+    #  file:: FILE:     åºåå
+ãã¡ã¤ã«
+    #
+    def gen_factory file
+        dbgPrint "===== begin #{@celltype.get_name.to_s} plugin =====\n"
+
+        #
+        # å¯¾è±¡ã¨ãªããã¹ã¦ã®ã»ã«ã«ã¤ãã¦ãåãå£ã«çµåããã¦ãã
+        # ã»ã«ã®æå±ãã¡ã¤ã³ãè§£æ
+        #  - çæãã¹ãcfgãã¡ã¤ã«åãåå¾ããããã«å¿
+è¦
+        #
+        if !HRPKernelObjectPlugin.isChecked()
+            HRPKernelObjectPlugin.check_referenced_cells()
+        else
+            dbgPrint "***** already checked\n"
+        end
+
+        # è¿½è¨ããããã« AppFile ãä½¿ãï¼æå­ã³ã¼ãå¤æãããªãï¼
+        file2 = AppFile.open( "#{$gen}/tecsgen.cfg" )
+        file2.print "\n/* Generated by #{self.class.name} */\n\n"
+
+        @celltype.get_cell_list.each { |cell|
+            if cell.is_generate?
+                dbgPrint "===== begin check my domain #{cell.get_name} =====\n"
+                #
+                #  ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ãï¼valã«ã³ãã¼
+                #
+                val = {}
+                @celltype.get_attribute_list.each{ |a|
+                    # p a.get_name
+                    if a.get_type.kind_of?( ArrayType )
+                        val[a.get_name] = []
+                        if j = cell.get_join_list.get_item(a.get_name)
+                            # ã»ã«çææã«åæåããå ´å
+                            j.get_rhs.each { |elem|
+                                val[a.get_name] << elem.to_s
+                            }
+                        elsif i = a.get_initializer
+                            # ã»ã«ã¿ã¤ãã®åæåå¤ãä½¿ãå ´å
+                            i.each { |elem|
+                                val[a.get_name] << elem.to_s
+                            }
+                        else
+                            raise "attribute is not initialized"
+                        end
+                    else
+                        if j = cell.get_join_list.get_item(a.get_name)
+                            # ã»ã«çææã«åæåããå ´å
+                            val[a.get_name] = j.get_rhs.to_s
+                        elsif i = a.get_initializer
+                            # ã»ã«ã¿ã¤ãã®åæåå¤ãä½¿ãå ´å
+                            val[a.get_name] = i.to_s
+                        else
+                            raise "attribute is not initialized"
+                        end
+                    end
+                }
+                # generate.rbãåèã«
+                # $id$ãç½®æ
+                if val[:id].nil? != true
+                    name_array = @celltype.get_name_array( cell )
+                    val[:id]   = @celltype.subst_name( val[:id], name_array )
+                end
+                # $cbp$ã®ä»£ãã
+                cell_domain_root = cell.get_region.get_domain_root
+                cell_domain_type = cell.get_region.get_domain_root.get_domain_type
+
+                # CRE_XXX/DEF_XXXã®çæ
+                if cell_domain_type.get_option.to_s != "OutOfDomain"
+                    # ä¿è­·ãã¡ã¤ã³ã«å±ããå ´å
+                    if !HRPKernelObjectPlugin.include_region(cell_domain_root.get_name.to_s)
+                        # ãã®ä¿è­·ãã¡ã¤ã³ã®.cfgãçæããã¦ããªãå ´å
+                        HRPKernelObjectPlugin.set_region_list(cell_domain_root.get_name.to_s)
+                        dbgPrint "~~~~~ #{cell_domain_root.get_name.to_s} is registered!\n"
+
+#                        # if cell.get_region.get_param == :KERNEL_DOMAIN
+#                        if cell_domain_type.get_option.to_s == "kernel"
+#                            file2.print "KERNEL_DOMAIN{\n"
+#                        else
+#                            file2.print "DOMAIN(#{cell_domain_root.get_name.to_s}){\n"
+#                        end
+#                        file2.puts "\tINCLUDE(\"#{$gen}/tecsgen_#{cell_domain_root.get_name.to_s}.cfg\");" 
+#                        file2.puts "}\n"
+                    else
+                        dbgPrint "~~~~~ #{cell.get_region.get_namespace_path} is included in"
+                        #p @@region_list
+                    end
+                    file3 = AppFile.open( "#{$gen}/tecsgen_#{cell_domain_root.get_global_name}.cfg" )
+                    print_cfg_cre(file3, cell, val,"")
+                    file3.close
+                else
+                    # ç¡æå±ã®å ´å
+                    dbgPrint "~~~~~ #{cell_domain_root.get_namespace_path} is OutOfDomain\n"
+                    # print "~~~~~ #{cell_domain_root.get_namespace_path} is OutOfDomain\n"
+                    # p cell_domain_root.get_name
+                    if cell_domain_root.get_name == "::" then
+                      print_cfg_cre(file2, cell, val, "")
+                    else
+#                      if !HRPKernelObjectPlugin.include_region(cell_domain_root.get_name.to_s)
+#                        # ãã®ä¿è­·ãã¡ã¤ã³ã®.cfgãçæããã¦ããªãå ´å
+#                        HRPKernelObjectPlugin.set_region_list(cell_domain_root.get_name.to_s)
+#                        file2.puts "INCLUDE(\"#{$gen}/tecsgen_#{cell_domain_root.get_name.to_s}.cfg\");\n"
+#                      end
+                      file3 = AppFile.open( "#{$gen}/tecsgen_#{cell_domain_root.get_name.to_s}.cfg" )
+                      print_cfg_cre(file3, cell, val,"")
+                      file3.close
+                    end
+
+                end
+
+                dbgPrint "===== end check my domain #{cell.get_name} =====\n"
+
+                #
+                # SAC_XXXã®çæ
+                #
+                if !val[:accessPattern1].nil?
+                    dbgPrint "===== begin check regions #{cell.get_name} =====\n"
+                    i = 0
+                    acv = { \
+                            :accessPattern1 => val[:accessPattern1], \
+                            :accessPattern2 => val[:accessPattern2], \
+                            :accessPattern3 => val[:accessPattern3], \
+                            :accessPattern4 => val[:accessPattern4] \
+                    }
+                    acv_tmp = []
+                    domain_roots = HRPPlugin.get_inter_domain_join_roots cell
+                    # çµåå
+ã»ã«ã®ãã¡ã¤ã³ãå ãã
+                    if cell_domain_type.get_kind != :OutOfDomain then
+                      domain_roots << cell_domain_root
+                    end
+                    domain_roots.each{ |dr|
+                      case dr.get_domain_type.get_kind
+                      when :user
+                        acv_tmp << "TACP(#{dr.get_name})"
+                      when :kernel
+                        acv_tmp << "TACP_KERNEL"
+                      when :OutOfDomain
+                        if cell_domain_type.get_kind == :OutOfDomain then
+                          # å¼ã³å
+ããå¼ã³å
+ã OutOfDomain ã®å ´å
+                          acv_tmp << "TACP_SHARED"
+                        end
+                      end
+                    }
+                    acv_tmp.uniq!
+                    if acv_tmp.length == 0 then
+                      # å¼ã³å
+ã»ã«ãç¡æå±ãã¤ãå¼ã³å
+ãç¡æå±ã®ã¿ãã¾ãã¯çµåç¡ãã®å ´å
+                      acv_tmp = [ "TACP_SHARED" ]
+                    end
+                    b_info = false
+                    b_warn = false
+                    acv.each { |key, acp|
+                        if !acp.nil?
+                            if acp != "OMIT"
+                            elsif cell_domain_type.get_kind != :OutOfDomain
+                              # p "UserDomainCell or KernelDomainCell"
+                              domain_roots = HRPPlugin.get_inter_domain_join_roots cell
+                              domain_roots.each{ |dr|
+                                # 
+                                case dr.get_domain_type.get_kind
+                                when :kernel
+                                when :user
+                                  if dr.get_namespace_path != cell.get_region.get_domain_root.get_namespace_path
+                                    # ä»ã®ã¦ã¼ã¶ã¼ãã¡ã¤ã³ããã®çµå
+                                    if( b_warn == false ) then
+                                      cdl_error( "HRP9999 '$1': kernel object joined from other user domain. kernel object joined from multi-user-domain must be placed out of domain", cell.get_name )
+                                      b_warn = true
+                                    end
+                                  end
+                                when :OutOfDomain
+                                  if( b_info == false ) then
+                                    # ç¡æå±ããã®çµå
+                                    # cdl_error( "HRP9999 kernel object joined from out of domain" )
+                                    if cell_domain_type.get_kind == :OutOfDomain
+                                      # ãã®æ
+å ±ã¯ãä¸è¦ã¨å¤æ­ãã (ç¡æå±ããç¡æå±ã¸çµåãããã¨ãã¢ã¯ã»ã¹è¨±å¯ãã¯ã¿ãè¨­å®ãããªã)
+                                      # cdl_info2( cell.get_locale, "HRP9999 '$1': kernel object joined from out of domain, access vector is not set", cell.get_name )
+                                      b_info = true
+                                    end
+                                  end
+                                else
+                                  raise "unknown domain kind"
+                                end
+                              }
+                              # acv[key] = "TACP(#{cell_domain_root.get_name.to_s})"
+                            else
+                              # p "OutOfDomainCell"
+                              # ç¡æå±ã®ã»ã«
+                              # çµåå
+ãã¡ã¤ã³ã«è¨±å¯ãã
+                              # çµåå
+ã«ç¡æå±ã®ã»ã«ãããã¨ãTACP_SHARED ãè¨­å®ããã. ãã­ã¼è§£æãã¦ãã¡ã¤ã³ãç¹å®ã§ããã®ããããã¹ãä»æ§
+                            end
+                            if acp == "OMIT"
+                              acv[key] = acv_tmp.join( '|' )
+                            end 
+                        end
+                    }
+                    #åç¨®SACã®çæ
+                    domainOption = cell_domain_type.get_option
+                    # p "domain_root ", cell.get_region.get_domain_root.get_name
+                    if domainOption != "OutOfDomain" || cell.get_region.get_domain_root.get_name != "::"
+                        # ä¿è­·ãã¡ã¤ã³ã«å±ããå ´å
+                        file3 = AppFile.open( "#{$gen}/tecsgen_#{cell.get_region.get_name.to_s}.cfg" )
+                        print_cfg_sac(file3, val, acv)
+                        file3.close
+                    else
+                        # ç¡æå±ã®å ´å
+                        print_cfg_sac(file2, val, acv)
+                    end
+
+                    dbgPrint "===== end check regions #{cell.get_name} =====\n"
+                end
+            end
+        }
+        dbgPrint "===== end #{@celltype.get_name.to_s} plugin =====\n"
+        file2.close
+    end
+
+    # ã«ã¼ãã«ãªãã¸ã§ã¯ãã»ã«ã¿ã¤ãã®ç®¡ç
+    # HRPKernelObjectPluginã¯ã©ã¹ã«å¯¾ãã¦ã¡ã½ããå¼åºããè¡ããã¨ãæ³å®
+    @@checked = false
+    @@celltype_list = []
+    @@region_list = []
+
+    def self.isChecked()
+        return @@checked
+    end
+
+    def self.check_referenced_cells()
+        dbgPrint "===== begin check registered celltype =====\n"
+        self.get_celltype_list.each { |ct|
+          dbgPrint( ct.get_name.to_s + "\n" )
+        }
+        dbgPrint "===== end check registered celltype =====\n"
+
+        @@checked = true
+    end
+
+    def self.set_celltype( celltype )
+        @@celltype_list << celltype
+    end
+
+    def self.get_celltype_list
+        return @@celltype_list
+    end
+
+    def self.set_region_list( region )
+        @@region_list << region
+    end
+
+    def self.include_region( region )
+        return @@region_list.include?(region)
+    end
+
+    def self.include_celltype?( celltype )
+        return @@celltype_list.include?(celltype)
+    end
+
+end
+
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPObjectPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPObjectPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPObjectPlugin.rb	(revision 374)
@@ -0,0 +1,114 @@
+# coding: utf-8
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2018 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#  $Id$
+#++
+
+require_tecsgen_lib "HRPKernelObjectPlugin.rb"
+
+
+class HRPObjectPlugin < HRPKernelObjectPlugin
+    @@api = {
+        "SEMAPHORE"=>["SEM", :id, :attribute, :initialCount, :maxCount],
+        "EVENTFLAG"=>["FLG", :id, :attribute, :flagPattern],
+        "DATAQUEUE"=>["DTQ", :id, :attribute, :dataCount, :dataqueueManagementBuffer],
+        "PRIORITY_DATAQUEUE"=>["PDQ", :id, :attribute, :dataCount, :maxDataPriority, :priorityDataqueueManagementBuffer],
+        "FIXED_SIZE_MEMORYPOOL"=>["MPF", :id, :attribute, :blockCount, :blockSize, :memoryPool, :memoryPoolManagementBuffer],
+        "KERNEL"=>["SYS"],
+        "MESSAGE_BUFFER"=>["MBF", :id, :attribute, :maxMessageSize, :bufferSize, :mbfmb],
+        "MUTEX"=>["MTX", :id, :attribute, :ceilingPriority]
+    }
+
+    #=== HRPObjectPlugin#print_cfg_cre
+    # CRE_XXXã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # tab :: string:   ã¤ã³ãã³ãç¨ã®tab
+    def print_cfg_cre(file, cell, val, tab)
+        if @@api.has_key?(@plugin_arg_str) == false
+            raise "#{@plugin_arg_str} is unknown"
+        elsif @plugin_arg_str != "KERNEL"
+            arg_list = []
+            params = @@api[@plugin_arg_str]
+            if @plugin_arg_str == "MUTEX" && ((val[:attribute] =~ /\bTA_CEILING\b/)==nil)
+              slice_end = -2   # :ceilingPriority ãå¤ã
+            else
+              slice_end = -1
+            end
+            # p @plugin_arg_str, slice_end, val[:attribute], (val[:attribute] =~ /\bTA_CEILING\b/)
+            params.slice(2..slice_end).each { |attr|
+                arg_list << "#{val[attr]}"
+            }
+            file.print tab
+            file.puts "CRE_#{@@api[@plugin_arg_str].at(0)}(#{val[:id]}, { #{arg_list.join(", ")} });"
+        end
+    end
+    #=== HRPObjectPlugin#print_cfg_sac
+    # SAC_XXXã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # acv :: string:   ã¢ã¯ã»ã¹ãã¯ã¿    
+    def print_cfg_sac(file, val, acv)
+        if @@api.has_key?(@plugin_arg_str) == false
+            raise "#{@plugin_arg_str} is unknown"
+        elsif @plugin_arg_str != "KERNEL"
+            file.puts "SAC_#{@@api[@plugin_arg_str].at(0)}(#{val[:id]}, { #{acv[:accessPattern1]}, #{acv[:accessPattern2]}, #{acv[:accessPattern3]}, #{acv[:accessPattern4]} });"
+        else
+            file.puts "SAC_#{@@api[@plugin_arg_str].at(0)}({ #{acv[:accessPattern1]}, #{acv[:accessPattern2]}, #{acv[:accessPattern3]}, #{acv[:accessPattern4]} });"
+        end
+    end
+
+end
+
+
+  
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPPlugin.rb	(revision 374)
@@ -0,0 +1,384 @@
+# coding: utf-8
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2014-2018 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#  $Id$
+#++
+
+
+require_tecsgen_lib "HRPKernelObjectManager.rb"
+#
+# åã¡ã½ããã®å½¹å²ãã¯ãDomainPlugin.rb ãåç
+§ã®ãã¨
+# HRPã«ã¼ãã«ç¨ãã¡ã¤ã³ãã©ã°ã¤ã³
+class HRPPlugin < DomainPlugin
+  
+  def initialize( region, name, option )
+    super
+    dbgPrint "HRPPlugin: initialize: region=#{region.get_name}, domainName=#{name}, option=#{option}\n"
+    @region = region
+    @name   = name
+    case option
+    when "kernel", "user", "OutOfDomain"
+      # OK
+      @option = option
+    else
+      cdl_error( "HRPPlugin: '$1' is unacceptable domain kind, specify 'kernel' or 'user'", option )
+      @option = "kernel"   # ã¨ãããã kernel ãè¨­å®ãã¦ãã
+    end
+  end
+
+  def add_through_plugin( join, current_region, next_region, through_type )
+    # join.get_owner:Cell  å·¦è¾ºã®ã»ã«
+    # join.get_definition:Port å¼ã³å£
+    # join.get_subscript:Integer or nil å¼ã³å£é
+åã®æ·»æ° (Join::@subscript ã®èª¬æåç
+§)
+    # join.get_cell:Cell å³è¾ºã®ã»ã«
+    # join.get_port_name:Symbol åãå£
+    # get_rhs_subscript:Integer or nil åãå£é
+åã®æ·»æ° (Join::@rhs_subscript ã®èª¬æåç
+§)
+    # return []
+    dbgPrint "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"
+
+    #puts "=====Join Check Start====="
+    #puts "caller: #{join.get_owner.get_name.to_s}, callee: #{join.get_cell.get_name.to_s}"
+    #puts "=====Join Check param====="
+    current_domain = current_region.get_domain_root.get_domain_type
+    next_domain = next_region.get_domain_root.get_domain_type
+    #puts current_domain.get_option.to_s
+    # if !next_domain.nil?
+    #     puts next_domain.get_option.to_s
+    # else
+    #     puts "next domain is nil!"
+    # end
+
+    HRPPlugin.add_inter_domain_join_set join
+    # p join.get_cell.get_name
+    # p join.get_cell.get_real_celltype(join.get_rhs_port1).get_name
+    # if HRPKernelObjectManager.include_celltype?(join.get_cell.get_celltype.get_global_name)   #oyama: get_name => get_global_name 
+    if HRPKernelObjectManager.include_celltype?(join.
+                                                 get_cell.
+                                                 get_real_celltype(join.get_rhs_port1).
+                                                 get_global_name)                #oyama: get_name => get_global_name 
+        # çµåå
+ãã«ã¼ãã«ãªãã¸ã§ã¯ãã»ã«
+        # @plugin_body = HRP2SVCPlugin.new(cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell)
+        # ä½ãããªãthrough
+        # puts "***** #{join.get_cell.get_celltype.get_name} is kernel object"
+        return []
+        # return [ :HRP2SVCPlugin, "channelCelltype=tMessagebufferChannel,noClientSemaphore=true" ]
+    # elsif @end_region.is_root?
+    # elsif next_region.get_option == OutOfDomain
+    # elsif next_domain.nil?
+    elsif next_domain.get_option.to_s == "OutOfDomain"
+    #     # çµåå
+ãç¡æå±
+    #     # ä½ãããªãthrough
+    #     # @plugin_body = HRP2SVCPlugin.new(cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell)
+        # puts "***** nil"
+        return []
+    #elsif @start_region.get_param != :KERNEL_DOMAIN && @end_region.get_param == :KERNEL_DOMAIN
+    elsif current_domain.get_option.to_s != "kernel" && next_domain.get_option.to_s == "kernel"
+        # ã¦ã¼ã¶ãã¡ã¤ã³ããã«ã¼ãã«ãã¡ã¤ã³ã¸ã®çµå
+        # @plugin_body = HRP2SVCPlugin.new(cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell)
+        # puts "***** svc"
+        return [ :HRPSVCPlugin, "" ]
+    elsif current_domain != next_domain
+        # å¥ã®ã¦ã¼ã¶ãã¡ã¤ã³ã¸ã®çµå
+        # @plugin_body = HRP2RPCPlugin.new(cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell)
+        # puts "***** rpc"
+        # return [ :HRPRPCPlugin, "channelCelltype=tMessagebufferChannel,noClientSemaphore=true" ]
+        # puts "HRPPlugin:RPC:PPAllocatorSize=256"
+        return [ :HRPRPCPlugin, "noClientSemaphore=false,PPAllocatorSize=256" ]
+    else
+        # ãã®ä»
+        # ä½ãããªãthrough
+        # @plugin_body = HRP2SVCPlugin.new(cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell)
+        dbgPrint "warning: at HRP Join Check"
+        return nil
+    end
+
+    # puts "=====Join Check End====="
+  end
+
+  def joinable?(current_region, next_region, through_type )
+    dbgPrint "MyDomainPlugin: joinable? from #{current_region.get_name} to #{next_region.get_name} (#{through_type})\n"
+    return true
+  end
+
+  #== ãã¡ã¤ã³ç¨®å¥ãè¿ã
+  #return::Symbol :kernel, :user, :OutOfDomain
+  def get_kind
+    return @option.to_sym
+  end
+  
+  def self.gen_post_code file
+  end
+
+  # ATT_MODãçææ¸ã¿ãã©ãã                   # 2017.8.27
+  @@generate_memory_module = false
+
+  @@include_extsvc_fncd = false  # 17.07.26 æ«å®
+  # 
+  #  ATT_MODã®çæ
+  #  gen_factoryå®è¡æã«ã¯ï¼ãã¹ã¦ã®ã»ã«ã¿ã¤ããã©ã°ã¤ã³ãçææ¸ã¿ã®ã¯ããªã®ã§ï¼
+  #  ã«ã¼ãã«APIã³ã¼ãã®ã¡ã¢ãªä¿è­·ãçç¥ã§ããï¼
+  #
+  def gen_factory
+    super
+
+    if @@include_extsvc_fncd == false
+      file = AppFile.open( "#{$gen}/tecsgen.cfg" )
+      file.print "/* HRPPlugin 001 */\n"
+      file.print "#include \"extsvc_fncode.h\"\n"   ## 2017.7.26
+      file.close
+      @@include_extsvc_fncd = true
+    end
+
+    if @@generate_memory_module == false
+
+      # INCLUDE ãåºå
+      #  ãã¹ã¦ã®ãã¡ã¤ã³ã«å¯¾ãã cfg ãå
+ã«çæãã¦ãã
+      #  ããããã¡ã¤ã³ã«å±ããã«ã¼ãã«ãªãã¸ã§ã¯ãããã¢ã¸ã¥ã¼ã«ããªãå ´åã§ããcfg ãåºåããã
+      regions = DomainType.get_domain_regions[ :HRP ]
+      file = AppFile.open( "#{$gen}/tecsgen.cfg" )
+      file.print "/* HRPPlugin 002 */\n"
+      regions.each{ |region|
+        if ! region.is_root? then
+          nsp = "#{region.get_global_name}"
+          file2 = AppFile.open( "#{$gen}/tecsgen_#{nsp}.cfg" )
+          file2.close
+          case region.get_domain_type.get_kind
+          when :kernel
+            pre = "KERNEL_DOMAIN{\n    "
+            post = "}\n"
+          when :user
+            pre = "DOMAIN(#{region.get_name}){\n    "
+            post = "}\n"
+          when :OutOfDomain
+            pre = ""
+            post = "\n"
+          end
+          file.puts "#{pre}INCLUDE(\"#{$gen}/tecsgen_#{nsp}.cfg\");\n#{post}"
+        end
+      }
+      file.print "/* HRPPlugin 002 end */\n\n"
+      file.close
+
+      check_celltype_list = []
+
+      # 
+      #  ATT_MODã®çæ
+      #
+      Cell.get_cell_list2.each { |cell|
+        # ãã¹ã¦ã®ã»ã«ãèµ°æ»ãã¦ã»ã«ã¿ã¤ãããã§ãã¯
+        ct = cell.get_celltype
+        if ct.class == Celltype && check_celltype_list.include?( ct ) == false
+          # ãã§ãã¯æ¸ã¿ã»ã«ã¿ã¤ãã«ç»é²
+          check_celltype_list << ct
+
+          # æªãã§ãã¯ã®ã»ã«ã¿ã¤ãã ã£ãå ´å
+          # puts "check for ATT_MOD : #{ct.classget_global_name}"
+          # puts "check for ATT_MOD : #{ct.get_global_name}"
+
+          # ã«ã¼ãã«APIã®ã³ã¼ãï¼ãã¼ã¿ã¯ã¡ã¢ãªä¿è­·ããªã # HRP3 oyama delete by Takada's request
+          # next if HRPKernelObjectManager.include_celltype?( ct.get_name )
+
+          # å¿
+è¦ã®ãªãã»ã«ã¿ã¤ãã®ã³ã¼ãï¼ãã¼ã¿ã¯ã¡ã¢ãªä¿è­·ããªã
+          next if ! ct.need_generate?
+
+          # HRPã®ãã¡ã¤ã³ãªã¼ã¸ã§ã³ãåå¾
+          regions = ct.get_domain_roots
+          regions_hrp = regions[ :HRP ]
+          dbgPrint "HRP domain in #{ct.get_name}: "
+          regions_hrp.each { |reg|
+            dbgPrint reg.get_name
+          }
+          # puts ""
+
+          # ã»ã«ç®¡çãã­ãã¯ã¨ã¹ã±ã«ãã³ã®ã¡ã¢ãªä¿è­·
+          # gen_celltype_names_domain ç¸å½ã®å¦ç
+          if regions_hrp.include?( Region.get_root ) == false && regions_hrp.length > 1
+            # ãã¡ã¤ã³ãè¤æ°ã§ï¼OutOfDomainã«ã»ã«ãå­å¨ããªãã»ã«ã¿ã¤ãã®å ´å
+            # å
+±æã®ã»ã«ç®¡çãã­ãã¯ã¨ã¹ã±ã«ãã³ã³ã¼ããç»é²ãã
+            file = AppFile.open( "#{$gen}/tecsgen.cfg" )
+            file.printf "%-60s/* HRPPlugin 003 */\n", "ATT_MOD(\"#{ct.get_global_name}_tecsgen.o\");"
+            file.close
+          end
+
+          regions_hrp.each { |reg|
+            if reg.is_root? 
+              nsp = ""
+            else
+              nsp = "_#{reg.get_global_name}"
+            end
+            file = AppFile.open( "#{$gen}/tecsgen#{nsp}.cfg" )
+            file.printf "%-50s/* HRPPlugin 004 */\n", "ATT_MOD(\"#{ct.get_global_name}#{nsp}_tecsgen.o\");"
+            file.close
+          }
+
+          # ã»ã«ã¿ã¤ãã³ã¼ãããªãå ´åã¯ã¹ã­ãã
+          next if ct.is_all_entry_inline? && ! ct.is_active?
+
+          # ã»ã«ã¿ã¤ãã³ã¼ãã®ã¡ã¢ãªä¿è­·
+          # gen_celltype_names_domain2 ç¸å½ã®å¦ç
+          if regions_hrp.include?( Region.get_root ) == true || regions_hrp.length > 1
+            # OutOfDomainã«ã»ã«ãå­å¨ããã»ã«ã¿ã¤ãã®å ´å
+            # ã¾ãã¯ï¼è¤æ°ã®ãã¡ã¤ã³ã«ã»ã«ãå­å¨ããã»ã«ã¿ã¤ãã®å ´å
+            # ã»ã«ã¿ã¤ãã³ã¼ããå
+±æããããã«ç»é²ãã
+            file = AppFile.open( "#{$gen}/tecsgen.cfg" )
+          else
+            # OutOfDomainã§ãªãåä¸ã®ãã¡ã¤ã³ã«ã»ã«ãå­å¨ããã»ã«ã¿ã¤ãã®å ´å
+            # ã»ã«ã¿ã¤ãã³ã¼ããå°æããããã«ç»é²ãã
+            file = AppFile.open( "#{$gen}/tecsgen_#{regions_hrp[0].get_global_name}.cfg" )
+          end
+
+          file.printf "%-50s/* HRPPlugin 005 */\n", "ATT_MOD(\"#{ct.get_global_name}.o\");"
+          file.close
+        else
+          # ä½ãããªã
+        end
+      }
+
+      @@generate_memory_module = true
+    else
+      # ä½ãããªã
+    end
+  end
+
+  #----- Inter Domain Join Set -----#
+  @@inter_domain_join_set = {}      #{entry_cell =>{domain_root=>count} }  Hash of inter domain join
+  def self.add_inter_domain_join_set join
+    rhs_cell = join.get_cell
+    dbgPrint "--------- add_inter_domain:#{join.get_owner.get_namespace_path} => #{join.get_cell.get_namespace_path}-----\n"
+    domain_root = join.get_owner.get_region.get_domain_root   # lhs cell's domain root
+    if @@inter_domain_join_set[ rhs_cell ] == nil then
+      @@inter_domain_join_set[ rhs_cell ] = []
+    end
+    # å·¦è¾ºã®ãã¡ã¤ã³ã«ã¼ããè¨é²
+    @@inter_domain_join_set[ rhs_cell ] << join
+  end
+  def self.get_inter_domain_join_set rhs_cell
+    if @@inter_domain_join_set[ rhs_cell ] then
+      @@inter_domain_join_set[ rhs_cell ].uniq!
+    else
+      @@inter_domain_join_set[ rhs_cell ] = []
+    end
+    return @@inter_domain_join_set[ rhs_cell ]
+  end
+  def self.get_inter_domain_join_roots rhs_cell
+    dbgPrint "--------- get_inter_domain #{rhs_cell.get_namespace_path} -----\n"
+    domain_roots = []
+    set = get_inter_domain_join_set rhs_cell
+    set.each{ |join|
+      dbgPrint "--------- get_inter_domain:#{join.get_owner.get_namespace_path} => #{join.get_cell.get_namespace_path}-----\n"
+      # if join.get_owner.get_region.get_domain_root.get_domain_type.get_option == "user" then
+        domain_roots << join.get_owner.get_region.get_domain_root
+      # end
+    }
+    return domain_roots.uniq
+  end
+
+  def self.get_sac_str cell
+    domain_roots = self.get_inter_domain_join_roots cell
+    delim = ""
+    acv = ""
+    cell_domain_root = cell.get_region.get_domain_root
+    if cell_domain_root.get_domain_type.get_kind != :OutOfDomain then
+      domain_roots << cell.get_region.get_domain_root  # çµåå
+ã®ãã¡ã¤ã³ãå«ãã
+    end
+    domain_roots.each{ |dr|
+      case dr.get_domain_type.get_kind
+      when :kernel
+        acv += "#{delim}TACP_KERNEL"
+        delim = "|"
+      when :user
+        acv += "#{delim}TACP(#{dr.get_name})"
+        delim = "|"
+        if cell_domain_root.get_domain_type.get_kind != :OutOfDomain &&
+           dr.get_namespace_path != cell_domain_root.get_namespace_path then
+          cdl_error( "HRP9999 '$1': kernel object joined from other user domain. kernel object joined from multi-user-domain must be placed out of domain", cell.get_name )
+        end
+      when :OutOfDomain
+        if cell_domain_root.get_domain_type.get_kind == :OutOfDomain then
+          acv += "#{delim}TACP_SHARED"
+          delim = "|"
+        end
+      else
+        raise "unkown domain kind"
+      end
+    }
+    if acv == "" then
+      # å¼ã³å
+ã»ã«ãç¡æå±ãã¤ãå¼ã³å
+ãç¡æå±ã®ã¿ãã¾ãã¯çµåç¡ãã®å ´å
+      acv = "TACP_SHARED"
+    end
+    sac_str = "{"
+    delim = ""
+    [:accessPattern1, :accessPattern2, :accessPattern3, :accessPattern4].each{ |acp|
+      init = (cell.get_attr_initializer acp).to_s
+      if init != "OMIT"
+        sac_str += delim + init
+      else
+        sac_str += delim + acv
+      end
+      delim = ", "
+    }
+    return sac_str + '}'
+  end
+end
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPRPCPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPRPCPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPRPCPlugin.rb	(revision 374)
@@ -0,0 +1,441 @@
+# coding: utf-8
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2018 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#  $Id$
+#++
+
+require_tecsgen_lib "lib/GenOpaqueMarshaler.rb"
+require_tecsgen_lib "lib/GenParamCopy.rb"
+
+#= HRPRPCPlugin ãã©ã°ã¤ã³
+# ã¹ã«ã¼ãã©ã°ã¤ã³ (through)
+# ã»OpaqueMarshalerPlugin ãä½¿ç¨ãã¦ãã¼ã·ã£ã©ã»ã«ã¿ã¤ããçæãã
+# ã»ãã¼ã·ã£ã©ãTDRããã£ã³ãã«ãã¡ãã»ã¼ã¸ãããã¡ãçæãã
+#
+class HRPRPCPlugin < ThroughPlugin
+
+  include GenOpaqueMarshaler
+  include GenParamCopy
+
+  # RPCPlugin å°ç¨ã®ãªãã·ã§ã³
+  HRPRPCPluginArgProc = RPCPluginArgProc.dup  # è¤è£½ãä½ã£ã¦å
+ãå¤æ´ããªãããã«ãã
+  HRPRPCPluginArgProc[ "noClientSemaphore"  ] = Proc.new { |obj,rhs| obj.set_noClientSemaphore rhs }
+  HRPRPCPluginArgProc[ "semaphoreCelltype"  ] = Proc.new { |obj,rhs| obj.set_semaphoreCelltype rhs }
+  @@isFirstInstance = true
+
+  #=== RPCPlugin ã® initialize
+  #  èª¬æã¯ ThroughPlugin (plugin.rb) ãåç
+§
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
+    super
+    @b_noClientSemaphore = false
+    @semaphoreCelltype = "tSemaphore"
+    initialize_opaque_marshaler
+
+    # ãªãã·ã§ã³ï¼GenOpaqueMarshaler åç
+§
+    @plugin_arg_check_proc_tab = HRPRPCPluginArgProc
+    parse_plugin_arg
+
+    @rpc_channel_celltype_name = "tRPCPlugin_#{@TDRCelltype}_#{@channelCelltype}_#{@signature.get_name}"
+    @rpc_channel_celltype_file_name = "#{$gen}/#{@rpc_channel_celltype_name}.cdl"
+
+    if @signature.get_context == "non-task" then
+        cdl_error( "HRP9999 RPC cannot be applied to non-task context signature '$1'", @signature.get_name )
+    elsif @signature.get_context == "any" then
+        cdl_info( "HRP9999 RPC is applied to any context signature '$1'", @signature.get_name )
+    end
+
+    if @signature.need_PPAllocator?(true) then
+      if @PPAllocatorSize == nil then
+        cdl_error( "HRP9999 PPAllocatorSize must be speicified for pointer argments" )
+        # @PPAllocatorSize = 0   # ä»®ã« 0 ã¨ãã¦ãã (cdl ã®æ§æã¨ã©ã¼ãé¿ãããã)
+      end
+    elsif @PPAllocatorSize then
+      cdl_warning( "HRP9999 PPAllocatorSize speicified in spite of PPAllocator unnecessary" )
+      @PPAllocatorSize = nil
+    end
+
+#    @signature.each_param{ |func_decl, param_decl|
+#      if func_decl.get_type.is_oneway? then
+#        if ( param_decl.get_size || param_decl.get_count ) && param_decl.get_string then
+#          cdl_error( "array of string not supported for oneway function in Transparent RPC" )  # mikan æå­åã®é
+å
+#        elsif param_decl.get_string == -1 then
+#          cdl_error( "length unspecified string is not permited for oneway function in Transparent RPC" )  # mikan é·ãæªæå®æå­å
+#        end
+#      end
+#    }
+
+    # 
+    #  tecsgen/tecs/rpcã«includeãã¹ãéã
+    #  #include "tecs_rpc.h" ãå®ç¾ããããã«å¿
+è¦
+    #    å¤§å±±:åé¤ Makefile.tecsgen ã« vpath, INCLUDES ãå
+¥ããã®ã¯ããããªãèã
+    #             TECSGEN.add_search_path ã§ Makefile_templ ã«å
+¥ããã®ããã
+    # if @@isFirstInstance
+    #     f = AppFile.open( "#{$gen}/Makefile.tecsgen" )
+    #     f.puts "INCLUDES := $(INCLUDES) -I $(TECSPATH) -I $(TECSPATH)/rpc"
+    #     f.puts "vpath %.c $(TECSPATH) $(TECSPATH)/rpc"
+    #     f.close()
+    #     @@isFirstInstance = false
+    # end
+  end
+
+  #=== plugin ã®å®£è¨ã³ã¼ã (celltype ã®å®ç¾©) çæ
+  def gen_plugin_decl_code( file )
+
+    ct_name = "#{@ct_name}_#{@channelCelltype}"
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if @@generated_celltype[ ct_name ] == nil then
+      @@generated_celltype[ ct_name ] = [ self ]
+    else
+      @@generated_celltype[ ct_name ] << self
+      return
+    end
+
+    f = CFile.open( @rpc_channel_celltype_file_name, "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    f.print <<EOT
+import( <rpc.cdl> );
+import( <tMessageBufferCEP.cdl> );
+generate( OpaqueMarshalerPlugin, #{@signature.get_namespace_path}, "" );
+
+composite tOpaqueMarshaler_#{@signature.get_global_name}_through {
+  entry #{@signature.get_namespace_path} eThroughEntry;
+  call sTDR       cTDR;
+  [optional]
+    call sSemaphore cLockChannel;
+  [optional]
+    call sRPCErrorHandler cErrorHandler;
+
+  cell tOpaqueMarshaler_#{@signature.get_global_name} Marshaler{
+    cTDR          => composite.cTDR;
+    cLockChannel  => composite.cLockChannel;
+    cErrorHandler => composite.cErrorHandler;
+  };
+  composite.eThroughEntry => Marshaler.eClientEntry;
+};
+
+EOT
+
+    f.close
+  end
+
+  #===  through cell ã³ã¼ããçæ
+  #
+  #
+  def gen_through_cell_code( file )
+
+    gen_plugin_decl_code( file )
+    file.print <<EOT
+import( <#{@rpc_channel_celltype_file_name}> );
+EOT
+
+    case @start_region.get_domain_root.get_domain_type.get_kind
+    when :kernel
+      tacp_str = "\"TACP_KERNEL"
+    when :user
+      tacp_str = "\"TACP(#{@start_region.get_domain_root.get_name})"
+    when :OutOfDomain
+      tacp_str = "\"TACP_SHARED"
+    end
+    # p "end_region=#{@end_region.get_name} kind=#{@end_region.get_domain_root.get_domain_type.get_kind}"
+    case @end_region.get_domain_root.get_domain_type.get_kind
+    when :kernel
+      tacp_str += "|TACP_KERNEL\""
+    when :user
+      tacp_str += "|TACP(#{@end_region.get_domain_root.get_name})\""
+    when :OutOfDomain
+      tacp_str += "|TACP_SHARED\""
+    end
+    nest_str = ""
+    file.print <<EOT
+#{nest_str}  //  MessageBuffer client=>server
+#{nest_str}  cell tMessageBuffer #{@clientChannelCell}Body0{
+#{nest_str}      maxMessageSize = 64;      /* This value must be same as MessageBufferCEP's buffer size */
+#{nest_str}      bufferSize     = 128;
+#{nest_str}      accessPattern1 = C_EXP( #{tacp_str} );
+#{nest_str}      accessPattern2 = C_EXP( #{tacp_str} );
+#{nest_str}      accessPattern3 = C_EXP( #{tacp_str} );
+#{nest_str}      accessPattern4 = C_EXP( #{tacp_str} );
+#{nest_str}  };
+EOT
+    file.print <<EOT
+
+#{nest_str}  //  MessageBuffer server=>client
+#{nest_str}  cell tMessageBuffer #{@clientChannelCell}Body1{
+#{nest_str}      maxMessageSize = 64;      /* This value must be same as MessageBufferCEP's buffer size */
+#{nest_str}      bufferSize     = 128;
+#{nest_str}      accessPattern1 = C_EXP( #{tacp_str} );
+#{nest_str}      accessPattern2 = C_EXP( #{tacp_str} );
+#{nest_str}      accessPattern3 = C_EXP( #{tacp_str} );
+#{nest_str}      accessPattern4 = C_EXP( #{tacp_str} );
+#{nest_str}  };
+EOT
+
+    ##### ã¯ã©ã¤ã¢ã³ãå´ã®ã»ã«ã®çæ #####
+    nest = @start_region.gen_region_str_pre file
+    nest_str = "  " * nest
+
+    # ã»ããã©ã®çæ
+    if @b_noClientSemaphore == false then
+      file.print <<EOT
+#{nest_str}  //  Semaphore for Multi-task use ("specify noClientSemaphore" option to delete this)
+#{nest_str}  cell #{@semaphoreCelltype} #{@serverChannelCell}_Semaphore{
+#{nest_str}    initialCount = 1;
+#{nest_str}  };
+EOT
+    end
+
+    # ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã« (tMessageBufferCEP)ã®çæ
+    # ãã£ã³ãã«ã¯å¿
+ããªã¼ã¸ã§ã³ä¸ã«ããã®ã§ã '::' ã§ã¤ãªã (ã§ãªããã°ãã«ã¼ããªã¼ã¸ã§ã³ã«ãªãããã§ãã¯ãå¿
+è¦ï¼
+
+    file.print <<EOT
+#{nest_str}  //  Client Side Channel
+#{nest_str}  cell tMessageBufferCEP #{@clientChannelCell}_CEP{
+#{nest_str}      cMessageBuffer0 = #{@clientChannelCell}Body0.eMessageBuffer;
+#{nest_str}      cMessageBuffer1 = #{@clientChannelCell}Body1.eMessageBuffer;
+#{nest_str}  };
+
+#{nest_str}  //  Client Side TDR
+#{nest_str}  cell tTDR #{@clientChannelCell}_TDR{
+#{nest_str}    cChannel = #{@clientChannelCell}_CEP.eChannel;
+#{nest_str}  };
+
+#{nest_str}  //  Marshaler
+EOT
+
+    # ã»ããã©ã®çµåæ
+    if @b_noClientSemaphore == false then
+      semaphore = "#{nest_str}    cLockChannel = #{@serverChannelCell}_Semaphore.eSemaphore;\n"
+    else
+      semaphore = ""
+    end
+
+    ### ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã« (ãã¼ã·ã£ã©+TDR)ã®çæ ###
+    cell = @next_cell
+    # ã¢ã­ã±ã¼ã¿ã®æå®ããããï¼
+    if cell.get_allocator_list.length > 0 then
+
+      file.print nest_str
+      file.print "[allocator("
+
+      delim = ""
+      cell.get_allocator_list.each do |type, eport, subsc, func, buf, alloc|
+
+        alloc_str = alloc.to_s
+        subst = @substituteAllocator[alloc_str.to_sym]
+        if subst then
+          alloc_str = subst[2]+"."+subst[3]
+        end
+
+        file.print delim
+        delim = ",\n"        # æçµè¡ã«ã¯åºããªã
+
+        if subsc then        # é
+åæ·»æ°
+          subsc_str = '[#{subsc}]'
+        else
+          subsc_str = ""
+        end
+
+        eport = "eThroughEntry" #RPCã®åãå£åã«å¤æ´
+        file.print nest_str
+        file.print  "#{eport}#{subsc_str}.#{func}.#{buf} = #{alloc_str}"
+      end
+
+      file.puts ")]"
+    end
+
+    if @clientErrorHandler then
+      clientErrorHandler_str = "#{nest_str}    cErrorHandler = #{@clientErrorHandler};\n"
+    else
+      clientErrorHandler_str = ""
+    end
+
+    file.print <<EOT
+#{nest_str}  cell tOpaqueMarshaler_#{@signature.get_global_name}_through #{@cell_name} {
+#{nest_str}    cTDR = #{@clientChannelCell}_TDR.eTDR;
+#{clientErrorHandler_str}#{semaphore}#{nest_str}  };
+EOT
+    ### END: ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã« (ãã¼ã·ã£ã©+TDR)ã®çæ ###
+    @start_region.gen_region_str_post file
+    file.print "\n\n"
+
+    ##### ãµã¼ãã¼å´ã®ã»ã«ã®çæ #####
+    nest = @end_region.gen_region_str_pre file
+    nest_str = "  " * nest
+
+    if @serverErrorHandler then
+      serverErrorHandler_str = "#{nest_str}    cErrorHandler = #{@serverErrorHandler};\n"
+    else
+      serverErrorHandler_str = ""
+    end
+
+    if @b_genOpener then
+      opener = "#{nest_str}    cOpener       = #{@serverChannelCell}.eOpener;\n"
+    else
+      opener = ""
+    end
+
+    # ãµã¼ãã¼å´ãã£ã³ãã« (tMessageBufferCEP)
+    if @PPAllocatorSize then
+      alloc_cell =<<EOT
+
+#{nest_str}  cell tPPAllocator #{@serverChannelCell}_PPAllocator {
+#{nest_str}    heapSize = #{@PPAllocatorSize};
+#{nest_str}  };
+EOT
+      alloc_call_port_join = "#{nest_str}    cPPAllocator = #{@serverChannelCell}_PPAllocator.ePPAllocator;\n"
+    else
+      alloc_cell = ""
+      alloc_call_port_join = ""
+    end
+
+    file.print <<EOT
+#{nest_str}  //  Server Side Channel
+#{nest_str}  cell tMessageBufferCEP #{@serverChannelCell}_CEP{
+#{nest_str}      cMessageBuffer0 = #{@clientChannelCell}Body1.eMessageBuffer;
+#{nest_str}      cMessageBuffer1 = #{@clientChannelCell}Body0.eMessageBuffer;
+#{nest_str}  };
+EOT
+
+    # ãµã¼ãã¼å´TDR
+    file.print <<EOT
+
+#{nest_str}  //  Server Side TDR
+#{nest_str}  cell tTDR #{@serverChannelCell}_TDR{
+#{nest_str}    cChannel = #{@serverChannelCell}_CEP.eChannel;
+#{nest_str}  };
+EOT
+
+    if @next_cell_port_subscript then
+      subscript = '[' + @next_cell_port_subscript.to_s + ']'
+    else
+      subscript = ""
+    end
+
+    # ãµã¼ãã¼å´ãã£ã³ãã« (ã¢ã³ãã¼ã·ã£ã©)
+    file.print <<EOT
+#{alloc_cell}
+#{nest_str}  //  Unmarshaler
+#{nest_str}  cell tOpaqueUnmarshaler_#{@signature.get_global_name} #{@serverChannelCell}_Unmarshaler {
+#{nest_str}    cTDR        = #{@serverChannelCell}_TDR.eTDR;
+#{nest_str}    cServerCall = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
+#{alloc_call_port_join}#{serverErrorHandler_str}#{nest_str}  };
+EOT
+
+    # ãµã¼ãã¼å´ã¿ã¹ã¯ã¡ã¤ã³
+    file.print <<EOT
+
+#{nest_str}  //  Unmarshaler Task Main
+#{nest_str}  cell #{@taskMainCelltype} #{@serverChannelCell}_TaskMain {
+#{nest_str}    cMain         = #{@serverChannelCell}_Unmarshaler.eService;
+#{opener}#{nest_str}  };
+EOT
+
+    # ãµã¼ãã¼å´ã¿ã¹ã¯
+    file.print <<EOT
+
+#{nest_str}  //  Unmarshaler Task
+#{nest_str}  cell #{@taskCelltype} #{@serverChannelCell}_Task {
+#{nest_str}    cTaskBody = #{@serverChannelCell}_TaskMain.eMain;
+#{nest_str}    priority  = #{@taskPriority};
+#{nest_str}    stackSize = #{@stackSize};
+#{nest_str}    attribute = C_EXP( "TA_ACT" );  /* mikan : marshaler task starts at beginning */
+#{nest_str}  };
+EOT
+    @end_region.gen_region_str_post file
+  end
+
+
+  #=== ãã©ã°ã¤ã³å¼æ° noClientSemaphore ã®ãã§ãã¯
+  def set_noClientSemaphore rhs
+    rhs = rhs.to_sym
+    if rhs == :true then
+      @b_noClientSemaphore = true
+    elsif rhs == :false then
+      @b_noClientSemaphore = false
+    else
+      cdl_error( "RPCPlugin: specify true or false for noClientSemaphore" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° semaphoreCelltype ã®ãã§ãã¯
+  def set_semaphoreCelltype rhs
+    @semaphoreCelltype = rhs.to_sym
+    nsp = NamespacePath.analyze( @semaphoreCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: semaphoreCelltype '#{rhs}' not celltype or not defined" )
+    end
+  end
+
+  #=== NamespacePath ãå¾ã
+  # çæããã»ã«ã® namespace path ãçæãã
+  def get_cell_namespace_path
+#    nsp = @region.get_namespace.get_namespace_path
+    nsp = @start_region.get_namespace_path
+    return nsp.append( @cell_name )
+  end
+
+end
+
+
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPSVCPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPSVCPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPSVCPlugin.rb	(revision 374)
@@ -0,0 +1,910 @@
+# coding: utf-8
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2018 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#  $Id$
+#++
+
+# mikan through plugin: namespace ãèæ
+®ããã¦ããªã
+# ãããå©ç¨ããå ´åãä»¥ä¸ã®ããã« toppers_jsp.cdl sChannel.cdl ãæå®ããå¿
+è¦ããã
+# tecsgen toppers_jsp.cdl sChannel.cdl your_description.cdl
+
+# ä»¥ä¸ãä»®å®ï¼å¶éäºé 
+ï¼
+#  å¼ã³å
+ãå¼ã³å
+ã®ã¨ã³ãã£ã¢ã³ãchar, short, int_t, long_t, intptr_t ã®ãµã¤ãºãåã
+#  æç¬¦å·ãç¡ç¬¦å·ã§ãµã¤ãºãåã
+
+class SVCManage
+    #
+    #  @@id: TECSã®ãã©ã°ã¤ã³ã§çæããæ¡å¼µãµã¼ãã¹ã³ã¼ã«ã«å²ãå½ã¦ãid
+    #        å®éã®æ¡å¼µãµã¼ãã¹ã³ã¼ã«IDã¯ï¼TFN_TECSGEN_ORIGINã§ä¸é§ã
+    #        å±¥ãããå¤ã¨ãªã
+    #        TFN_TECSGEN_ORIGINã¯ï¼hrp3/include/extsvc_fncode.h ã§å®ç¾©
+    #        ããã
+    #  @@func_ids: æ¡å¼µãµã¼ãã¹ã³ã¼ã«ã®é¢æ°åã¨æ¡å¼µãµã¼ãã¹ã³ã¼ã«IDã
+    #  ãããå¯¾å¿ã¥ããããã·ã¥
+    #
+    @@id = 0
+    @@func_ids = {}
+    def initialize()
+        # 
+      #  æ¬ã¯ã©ã¹ã¯ã¤ã³ã¹ã¿ã³ã¹ãæããªãä»®æ³çãªã¯ã©ã¹ã§ãã
+        #
+        raise "class #{self.class.name} shall not have instances"
+    end
+    def self.get_func_id func_name
+        return @@func_ids[ func_name ]
+    end
+    def self.set_func_id func_name
+        @@func_ids[ func_name ] = self.assign_id
+        # puts @@func_ids[ func_name ]
+    end
+    def self.get_id
+        return @@id
+    end
+    def self.set_id id
+        @@id = id
+    end
+    def self.assign_id
+        assignedId = @@id
+        @@id += 1
+        return assignedId
+    end
+end
+
+#
+#  æ¡å¼µãµã¼ãã¹ã³ã¼ã«ãç¨ãããã¡ã¤ã³ééä¿¡ã®
+#  throughãã©ã°ã¤ã³
+#  HRPãã¡ã¤ã³ãã©ã°ã¤ã³ã«ãã£ã¦æ¿å
+¥ããã
+#  åææ¡ä»¶: å¼åºãå
+ãã«ã¼ãã«ãªãã¸ã§ã¯ããã©ããã®å¤å®ã¯HRPãã¡ã¤ã³ãã©ã°ã¤ã³
+#  ãããããã§å®æ½ãããããï¼ããã§ã¯å¤å®ããªããã¨ã¨ãã
+#
+class HRPSVCPlugin < ThroughPlugin
+
+  NUM_SVC_ARG_MAX = 5              # HRP3 ã®æ¡å¼µãµã¼ãã¹ã³ã¼ã«ã§æ±ããã¨ã®ã§ããå¼æ°ã®æå¤§åæ°
+
+  @@generated_celltype ={}    # ã»ã«ã¿ã¤ãã®éè¤æé¤ç¨
+  @@generated_cell = {}       # ã»ã«ã®éè¤æé¤ç¨
+
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
+    super
+
+    # åãå£é
+åã®å ´åãé
+åæ·»æ°ãã¨ã«å¥ã®ã»ã«ã¿ã¤ãã¨ãã
+    # ã»ã«ã¿ã¤ããã·ã³ã°ã«ãã³åãããããã
+    # ãããªãã¨ãã»ã«ãè­å¥ããå¼æ°ãæ¸¡ãå¿
+è¦ããããNUM_SVC_ARG_MAX(5) ã¤ããæ¸¡ããªãå¼æ°ã®ä¸ã¤ãæ¶è²»ãããã¨ã«ãªãããã
+    if @next_cell_port_subscript then
+      subscript = "__" + @next_cell_port_subscript.to_s
+    else
+      subscript = ""
+    end
+    @ct_name_body = "#{@ct_name}SVCBody_#{@next_cell.get_name}_#{@next_cell_port_name}#{subscript}".to_sym
+    @ct_name = "#{@ct_name}SVCCaller_#{@next_cell.get_name}_#{@next_cell_port_name}#{subscript}".to_sym
+    @cell_name_body = "#{@cell_name}SVCBody".to_sym
+    @cell_name = "#{@cell_name}SVCCaller".to_sym
+    # puts "%%%% "
+    # p @next_cell.get_name
+    # p @caller_cell.get_name
+    @b_printed_include_stdint = false
+    check_signature signature
+  end
+
+  #=== NamespacePath ãå¾ã
+  # çæããã»ã«ã® namespace path ãçæãã
+  def get_cell_namespace_path
+#    nsp = @region.get_namespace.get_namespace_path
+    nsp = @start_region.get_namespace_path
+    return nsp.append( @cell_name )
+  end
+
+  def gen_plugin_decl_code( file )
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if @@generated_celltype[ @ct_name_body ] == nil then
+        @@generated_celltype[ @ct_name_body ] = [ self ]
+        file2 = CFile.open( "#{$gen}/#{@ct_name_body}.cdl", "w" )
+        file2.print <<EOT
+import_C( "t_stdlib.h" );
+
+/* HRPSVC0001 */
+[active,singleton]
+celltype #{@ct_name_body} {
+    call #{@signature.get_name} #{@call_port_name};
+    FACTORY {
+		write("$ct$_tecsgen.h", "#include \\"kernel_cfg.h\\"");
+    };
+};
+EOT
+        file2.close
+    else
+      @@generated_celltype[ @ct_name_body ] << self
+    end
+    file.print "import( \"#{$gen}/#{@ct_name_body}.cdl\" );\n"
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if @@generated_celltype[ @ct_name ] == nil then
+        @@generated_celltype[ @ct_name ] = [ self ]
+        file2 = CFile.open( "#{$gen}/#{@ct_name}.cdl", "w" )
+        file2.print <<EOT
+/* HRPSVC0002 */
+celltype #{@ct_name} {
+    entry #{@signature.get_name} #{@entry_port_name};
+    FACTORY {
+		write("$ct$_tecsgen.h", "#include \\"extsvc_fncode.h\\"");
+    };
+};
+EOT
+        file2.close
+    else
+      @@generated_celltype[ @ct_name ] << self
+    end
+    file.print "import( \"#{$gen}/#{@ct_name}.cdl\" );\n"
+
+=begin
+    # TODO: send. receive å¯¾å¿
+    send_receive = []
+    if @signature != nil then
+      @signature.each_param{ |fd,param|
+        dir =param.get_direction
+        case dir
+        when :SEND, :RECEIVE
+          send_receive << [ dir, fd, param ]
+        end
+      }
+    end
+=end
+
+=begin
+composite #{@ct_name} {
+    entry #{@signature.get_name} #{@entry_port_name};
+    call #{@signature.get_name} #{@call_port_name};
+
+    cell #{@ct_name}Client #{@cell_name}Client{
+    };
+
+    [active]
+    cell #{@ct_name}Server #{@cell_name}Server{
+        #{@call_port_name} => composite.#{@call_port_name};
+    };
+
+    composite.#{@entry_port_name} => #{@cell_name}.#{@entry_port_name};
+};
+=end
+
+  end
+
+  #===  through cell ã³ã¼ããçæ
+  #
+  #
+  def gen_through_cell_code( file )
+
+    # gen_plugin_decl_code( file )  this is called from super.
+
+    # ã»ã«ãæ¢ã
+    # path =["::",@next_cell.get_name]  # mikan namespace
+    # cell = Namespace.find( path )
+    # cell = Namespace.find( @next_cell.get_namespace_path )
+
+    ##### ã¯ã©ã¤ã¢ã³ãå´ã®ã»ã«ã®çæ #####
+    # file.print "[domain(HRP, \"kernel\")]"
+    nest = @start_region.gen_region_str_pre file
+    nest_str = "  " * nest
+
+    # ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã«ã®çæ
+    # æ¡å¼µãµã¼ãã¹ã³ã¼ã«å¼åºã
+    file.print <<EOT
+/* HRPSVC0003 */
+#{nest_str}  //  Client Side Channel
+#{nest_str}  cell #{@ct_name} #{@cell_name}{
+#{nest_str}  };
+
+EOT
+
+    @start_region.gen_region_str_post file
+    file.print "\n\n"
+
+    ##### ãµã¼ãã¼å´ã®ã»ã«ã®çæ #####
+    # print "######  #{@cell_name_body} ... #{@ct_name_body} #{@@generated_cell[ @ct_name_body ].class}  #####\n"
+
+    if @@generated_cell[ @ct_name_body ] then
+      file.print "/* cell #{@ct_name_body} #{@@generated_cell[ @ct_name_body ]}: already generated. */\n"
+    else
+      @@generated_cell[ @ct_name_body ] = @cell_name_body
+      nest = @end_region.gen_region_str_pre file
+      nest_str = "  " * nest
+      if @next_cell_port_subscript then
+        subscript = '[' + @next_cell_port_subscript.to_s + ']'
+      else
+        subscript = ""
+      end
+
+      # ãµã¼ãã¼å´ãã£ã³ãã«ã®çæ 
+      # æ¡å¼µãµã¼ãã¹ã³ã¼ã«æ¬ä½
+      file.print <<EOT
+
+/* HRPSVC0004 */
+#{nest_str}  //  Server Side Channel
+#{nest_str}  cell #{@ct_name_body} #{@cell_name_body}{
+#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
+#{nest_str}  };
+EOT
+
+      @end_region.gen_region_str_post file
+
+      file2 = AppFile.open( "#{$gen}/tecsgen.cfg" )
+      file2.print "\n/* Generated by HRPSVCPlugin */\n\n"
+      file2.print <<EOT
+/* HRPSVC0005 */
+#include "#{@ct_name_body}_factory.h"
+EOT
+      file2.close
+
+      # callee_cell ã®get_restricted_regions ãå¼ã³åºãã¦ãã
+      # restrict ãåç
+§ãããå°ãã¤ãããã
+      @callee_cell.get_restricted_regions( :dummy_entry_name, :dummy_func_name )
+    end
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     éå¸¸ã§ããã°ãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã©ã°ã¤ã³ã®å ´åãå¤æ´ããå¿
+è¦ã®ãªãã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+  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 )
+        # puts "generate ep_func for #{ct_name}"
+
+        #
+        #  æ¡å¼µãµã¼ãã¹ã³ã¼ã«å¼åºãå´ã®é¢æ°çæ
+        #
+        #  å®æå½¢ã®ã¤ã¡ã¼ã¸
+        #  
+        # ER_UINT
+        # eThroughEntry_write(CELLIDX idx, const char* buffer, uint_t length)
+        # {
+        #   ER_UINT  retval;
+        #   tHRPSVCPlugin_<Sig>SVCCaller_<Cell>_<Entry>_CB    *p_cellcb;
+        #   if( VALID_IDX( idx ) ){
+        #       p_cellcb = tHRPSVCPlugin_<Sig>SVCBody_<Cell>_<Entry>_GET_CELLCB(idx);
+        #   }else{
+        #       /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+        #   }
+        # 
+        #   retval = (ER_UINT)cal_svc( TFN_TECSGEN_ORIGIN + svcid, 
+        #                              (intptr_t)par1, (intptr_t)par2, 0, 0, 0 );
+        #
+        #   return retval;
+        # }
+
+        if ! func_type.get_type.kind_of?( VoidType ) then
+            file.print( "  #{func_type.get_type_str}  retval;\n" )
+        end
+
+        # p "celltype_name, sig_name, func_name, func_global_name"
+        # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
+
+        delim = ""
+        if ! func_type.get_type.kind_of?( VoidType ) then
+            file.print( "  retval = (#{func_type.get_type_str})" )
+        else
+            file.print( "  " )
+        end
+
+        #file.print( "#{@call_port_name}_#{func_name}(" )
+        SVCManage.set_func_id( "#{@ct_name_body}_#{func_name}" )
+        svcid = SVCManage.get_func_id( "#{@ct_name_body}_#{func_name}" )
+        #file.print( "cal_svc( #{@ct_name_body}_#{func_name}" )
+        file.print( "cal_svc( TFN_TECSGEN_ORIGIN + #{svcid.to_s}" )
+
+        #    if ( ! b_singleton ) then
+        #      file.print( " tecs_this" )
+        #      delim = ","
+        #    end
+
+        i = 0
+        passed_param = {}
+        params.each{ |param|
+            delim = ","
+            file.printf( "#{delim} (intptr_t)#{param.get_name}" )
+            passed_param[i] = param.get_name
+            i += 1
+        }
+
+        while(i < NUM_SVC_ARG_MAX) do
+            delim = ","
+            file.printf( "#{delim} 0" )
+            passed_param[i] = "par#{i+1}"
+            i += 1
+        end
+
+        file.print( " );\n\n" )
+
+        if ! func_type.get_type.kind_of?( VoidType ) then
+            file.print( "  return retval;\n" )
+        end
+
+        #
+        #  æ¡å¼µãµã¼ãã¹ã³ã¼ã«æ¬ä½å´ã®é¢æ°çæ
+        #
+        #  å®æå½¢ã®ã¤ã¡ã¼ã¸
+        #  
+        # ER_UINT
+        # eThroughEntry_write(CELLIDX idx, const char* buffer, uint_t length)
+        # {
+        #   ER_UINT  retval;
+        #   tHRPSVCPlugin_<Sig>SVCBody_<Cell>_<Entry>_CB    *p_cellcb;
+        #   if( VALID_IDX( idx ) ){
+        #       p_cellcb = tHRPSVCPlugin_<Sig>SVCBody_<Cell>_<Entry>_GET_CELLCB(idx);
+        #   }else{
+        #       /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+        #   }
+        # 
+        #   retval = (ER_UINT)cal_svc( TFN_TECSGEN_ORIGIN + svcid, 
+        #                              (intptr_t)par1, (intptr_t)par2, 0, 0, 0 );
+        #
+        #   return retval;
+        # }
+            file2 = AppFile.open( "#{$gen}/#{@ct_name_body}.c" )
+            if @b_printed_include_stdint == false then
+              file2.print <<EOT
+#ifndef SIZE_MAX
+#define  SIZE_MAX   (~0UL)
+#endif
+
+EOT
+              @b_printed_include_stdint = true
+            end
+
+            if func_type.get_type.kind_of?( VoidType ) then
+                retval_assign = ""
+            else
+                retval_assign = "retval = (ER_UINT)"
+            end
+
+            file2.print <<EOT
+/* HRPSVC0006 */
+ER_UINT
+#{@ct_name_body}_#{func_name}(intptr_t #{passed_param[0]}, intptr_t #{passed_param[1]}, intptr_t #{passed_param[2]}, intptr_t #{passed_param[3]}, intptr_t #{passed_param[4]}, ID cdmid)
+{
+    ER_UINT retval = E_OK;
+
+EOT
+
+            # 
+            #  ã¨ã©ã¼ãã§ãã¯å¦çã®çæ
+            #
+
+            # 
+            #  å¼åºãå
+ãã¡ã¤ã³ã®ãã§ãã¯
+            #   * private method: gen_caller_check_codeåç
+§
+            #
+            generated_check_code = gen_caller_check_code(func_name)
+            check_code = generated_check_code["check_code"]
+            user_cannot_callable = generated_check_code["user_cannot_callable"]
+
+            # 
+            #  ãã©ã¡ã¼ã¿ã«ãã¤ã³ã¿ãå­å¨ããå ´åï¼å¼åºãå
+ã¿ã¹ã¯ã«å¯¾ãã
+            #  ã¢ã¯ã»ã¹æ¨©ã®ãã§ãã¯å¦çãåºåãã
+            #  â» cdmidãã«ã¼ãã«ãã¡ã¤ã³(æ¡å¼µãµã¼ãã¹ã³ã¼ã«å¼åºãä¸­ã®ã¦ã¼ã¶
+            #    ãã¡ã¤ã³ãå«ã)ã§ããã°prb_memã®å¦çãã¹ã­ãããï¼åæ®µã®
+            #    æ¡å¼µãµã¼ãã¹ã³ã¼ã«ã®ã¿prb_memãå¼åºãå
+ã¿ã¹ã¯ã«çºè¡ãã
+            #
+            num = 0
+            params.each{ |param|
+                if param.get_declarator.get_ptr_level > 0 then
+                    align_check_str = "!ALIGN_TYPE(#{passed_param[num]}, #{param.get_type.get_referto.get_type_str}) || "
+                  
+                    if param.get_type.get_referto.kind_of?(IntType) then
+                        case param.get_type.get_referto.get_bit_size
+                        when -11, -1, 8   # char, char_t, int8_t (ç¡ç¬¦å·å«ã)
+                        #
+                        #  charãã¼ã¿ã®å ´åï¼ALIGN_TYPEã¯å¿
+ãTRUE
+                        #  ã¨ãªãã®ã§ï¼ã¨ã©ã¼ãã§ãã¯ãçç¥
+                        #  charåã®@bit_sizeã¯-11
+                        #  tecsgen/tecslib/core/types.rbãåç
+§
+                        #
+                          align_check_str = ""
+                        end
+                    end
+                    if param.get_direction == :IN then
+                        #
+                        #  å
+¥å([in])ã®ãã¤ã³ã¿ãã©ã¡ã¼ã¿ã¯ï¼å¼åºãå
+ã¿ã¹ã¯ã«
+                        #  TPM_READ(èª­åºãå¯è½)ã®ã¢ã¯ã»ã¹æ¨©ãå¿
+è¦
+                        #
+                        # äºéãã¤ã³ã¿ãä¸å¯ã®ãããsize_is ã¨ string ãåæã«è¨­å®ããããã¨ã¯ãªã
+                        prb_func = "prb_mem"
+                        if param.get_size then
+                          size_str = param.get_size.to_s
+                        elsif param.get_string == -1 then
+                          size_str = "SIZE_MAX"
+                          prb_func = "prb_str"
+                        elsif param.get_string then
+                          size_str = param.get_string.to_s
+                          prb_func = "prb_str"
+                        else
+                          size_str = "1"
+                        end
+                        check_code.concat <<EOT
+        /* HRPSVC0007 */
+        if (#{align_check_str}#{prb_func}((void *)#{passed_param[num]}, sizeof(#{param.get_type.get_referto.get_type_str}) * (#{size_str}), TSK_SELF, TPM_READ) != E_OK) {
+            return E_MACV;
+        }
+EOT
+
+                    elsif param.get_direction == :OUT || param.get_direction == :INOUT then
+                        #
+                        #  åºå([out])ã®ãã¤ã³ã¿ãã©ã¡ã¼ã¿ã¯ï¼å¼åºãå
+ã¿ã¹ã¯ã«
+                        #  TPM_WRITE(æ¸è¾¼ã¿å¯è½)ã®ã¢ã¯ã»ã¹æ¨©ãå¿
+è¦
+                        #
+                        prb_func = "prb_mem"
+                        if param.get_size then
+                          size_str = param.get_size.to_s
+                        elsif param.get_string then          # å¼æ°ãªãã® string ã¯ãªã
+                          size_str = param.get_string.to_s
+                          # prb_func = "prb_str"             # out, inout ã®å ´åãå¿
+ãé åãç¢ºä¿ãã. prb_mem ãç¨ãã
+                        else
+                          size_str = "1"
+                        end
+                        check_code.concat <<EOT
+        /* HRPSVC0008 */
+        if (#{align_check_str}#{prb_func}((void *)#{passed_param[num]}, sizeof(#{param.get_type.get_referto.get_type_str}) * (#{size_str}), TSK_SELF, TPM_WRITE) != E_OK) {
+            return E_MACV;
+        }
+EOT
+
+                    end
+                end
+                num += 1
+            }
+
+            # 
+            #  å¼åºãå
+ãã«ã¼ãã«ãã¡ã¤ã³ã®ã¿è¨±å¯ããã¦ããå ´åï¼
+            #  ãã¹ã¦ã®ã¦ã¼ã¶ãã¡ã¤ã³ããã®å¼åºãã«å¯¾ãï¼E_OACVãè¿ã
+            #
+            if user_cannot_callable
+                check_code = "\t\treturn E_OACV;"
+            end
+
+            if check_code != ""
+                # 
+                #  å¼åºãå
+ãã«ã¼ãã«ãã¡ã¤ã³ã®å ´åï¼ã¢ã¯ã»ã¹æ¨©ã®ãã§ãã¯
+                #  å¦çãã¹ã­ããããã
+                #
+                file2.print <<eot
+    if (cdmid != TDOM_KERNEL) {
+#{check_code}
+    }
+eot
+            end
+
+            # 
+            #  æ¡å¼µãµã¼ãã¹ã³ã¼ã«æ¬ä½(æ¬æ¥ã®åãå£é¢æ°)ãå¼ã³åºã
+            #
+            file2.print"    #{retval_assign}#{@call_port_name}_#{func_name}("
+
+            delim = ""
+            num = 0
+            params.each{ |param|
+                file2.print "#{delim}"
+                delim = ", "
+                file2.print "(#{param.get_type.get_type_str})"
+                file2.print passed_param[num]
+                file2.print param.get_type.get_type_str_post
+                num += 1
+            }
+
+            file2.print ");\n"
+
+            file2.print "\n    return retval;\n"
+            file2.print "}\n\n"
+
+            file2.close
+
+            # 
+            #  æ¡å¼µãµã¼ãã¹ã³ã¼ã«ã®ç»é²
+            #
+            file2 = AppFile.open( "#{$gen}/tecsgen.cfg" )
+            file2.print "\n/* Generated by HRPSVCPlugin */\n\n"
+            file2.print <<EOT
+/* HRPSVC0009 */
+KERNEL_DOMAIN{
+    DEF_SVC( TFN_TECSGEN_ORIGIN + #{svcid.to_s}, { TA_NULL, #{@ct_name_body}_#{func_name}, SSZ_#{func_global_name} } );
+}
+EOT
+            file2.close
+
+            # 
+            #  æ¡å¼µãµã¼ãã¹ã³ã¼ã«ç»é²ã«å¿
+è¦ãªæ
+å ±ããããã«åºå
+            #   - æ¡å¼µãµã¼ãã¹ã³ã¼ã«å¼åºãæã®ãã§ãã¯ã§ä½¿ç¨ããã¹ã¿ãã¯ãµã¤ãºãåºå
+            #   - æ¡å¼µãµã¼ãã¹ã³ã¼ã«ã¨ãã¦ç»é²ããé¢æ°åã®externå®£è¨ãåºå
+            #
+            file2 = AppFile.open( "#{$gen}/#{@ct_name_body}_factory.h" )
+            file2.print "\n/* Generated by HRPSVCPlugin */\n\n"
+            file2.print <<EOT
+/* HRPSVC0010 */
+#ifndef SSZ_#{func_global_name}
+#define SSZ_#{func_global_name}	DefaultExtsvcStackSize
+#endif /* SSZ_#{func_global_name} */
+
+/* HRPSVC0011 */
+extern ER_UINT #{@ct_name_body}_#{func_name}(intptr_t par1, intptr_t par2, intptr_t par3, intptr_t par4, intptr_t par5, ID cdmid);
+EOT
+            file2.close
+  end
+
+  def get_callee_cell
+      return @callee_cell
+  end
+
+  def get_caller_cell
+      return @caller_cell
+  end
+
+  def get_callee_ep_name
+      return @join.get_port_name
+  end
+
+  private
+  # 
+  #  æ¡å¼µãµã¼ãã¹ã³ã¼ã«æ¬ä½ã«ãããï¼å¼åºãå
+ãã§ãã¯ã®ã³ã¼ãã
+  #  åºåãã
+  #  gen_ep_func_body ããã®ã¿å¼ã³åºããã
+  #  å¼æ°: å¯¾è±¡ã®é¢æ°å
+  #  è¿ãå¤: ä¸è¨ã®ããã·ã¥
+  #    {"check_code"=>åºåããã¨ã©ã¼ãã§ãã¯ã³ã¼ã, 
+  #     "user_cannot_callable"=>ã¦ã¼ã¶ãã¡ã¤ã³ãå¼åºãä¸å¯è½ãã©ããã®ãã©ã°}
+  #
+  def gen_caller_check_code(func_name)  
+    dbgPrint "gen_caller_check_code(func_name): #{@callee_cell.get_name}\n"
+      # 
+      #  ã¨ã©ã¼ãã§ãã¯å¦ç
+      #
+      check_code = ""
+      user_cannot_callable = false
+      all_domain_callable = false
+      caller_unrestricted = false
+
+      # 
+      #  å¼åºãå
+ãã¡ã¤ã³ã®ãã§ãã¯å¦ç
+      #  callable_domains: æ¡å¼µãµã¼ãã¹ã³ã¼ã«ãå¼åºãå¯è½ãªãã¡ã¤ã³ã®ãªã¹ã
+      #    - ç¡æå±ã®ã»ã«ããçµåããã¦ããå ´åï¼ãã¹ã¦ã®ã»ã«ã«å¯¾ãã¦ï¼
+      #    ãcallable?ããã§ãã¯ãï¼å¼åºãå¯è½ãªãã¹ã¦ã®ãã¡ã¤ã³ãè¿ã
+      #    - ç¡æå±ä»¥å¤ã®ã»ã«ããçµåããã¦ããå ´åï¼ãã®ã»ã«ã«å¯¾ãã¦
+      #      callable?ããã§ãã¯ãï¼å¼åºãå¯è½ã§ããã°ï¼ãã®ãã¡ã¤ã³ãè¿ã
+      #
+      callable_domains = []
+      @@generated_celltype[ @ct_name_body ].each { |svcplugin|
+          if svcplugin.get_caller_cell.get_region.get_domain_root.get_domain_type.get_option == "OutOfDomain"
+              # ç¡æå±ãã¤ active ãªå ´åããrestrict ã«å¾ã
+              # if svcplugin.get_caller_cell.get_celltype.is_active?
+              #    #
+              #    #  ç¡æå±ãã¤activeãªã»ã«ã¯ãTECSããå­å¨ãèªè­ããã¦ããªãã®ã
+              #    #  å«ãä»»æã®ãã¡ã¤ã³ããå¼ã³åºãããå¯è½æ§ãå­å¨ãã
+              #    #
+              #    caller_unrestricted = true
+              # else
+              #     # 
+              #     #  ç¡æå±ããæ¥ç¶ããã¦ããå ´åã¯ï¼ãã¹ã¦ã®ã»ã«ã®
+              #     #  restrictããã§ãã¯
+              #     #
+              #     Cell.get_cell_list2.each { |cell|
+              #         if cell.callable?(svcplugin.get_callee_cell, svcplugin.get_callee_ep_name, func_name)
+              #             callable_domains << cell.get_region.get_domain_root
+              #         end
+              #     }
+              #     print "callable_domains: "
+              #     callable_domains.each{ |dm| print dm.get_name, " " }
+              #     print "\n"
+              # end
+
+              # restrict æå®ãããå ´åã«ã¯ãããã«å¾ãããããªããã°ããã§ãã¯ããªã
+              callable_domains = @callee_cell.get_restricted_regions( get_callee_ep_name, func_name )
+              if callable_domains == nil then
+                caller_unrestricted = true
+              end
+              #  print "restrict_list: "
+              #  delim = ""
+              #  callable_domains.each{ |domain|
+              #    print delim, domain
+              #    delim = ", "
+              #  }
+              #  print "\n"
+
+          elsif svcplugin.get_caller_cell.callable?( svcplugin.get_callee_cell, svcplugin.get_callee_ep_name, func_name )
+              # 
+              #  ç¹å®ã®ãã¡ã¤ã³ããæ¥ç¶ããã¦ããå ´åã¯ï¼å¼åºãå
+ã»ã«ã®
+              #  restrictããã§ãã¯
+              #
+              callable_domains << svcplugin.get_caller_cell.get_region.get_domain_root
+          else
+              # 
+              #  ç¡æå±ããçµåããã¦ãããï¼ç¹å®ã®å¼åºãå
+ãã¡ã¤ã³ã«ã¢ã¯ã»ã¹æ¨©
+              #  ããªãå ´åï¼callable_domainsã¯ç©ºã¨ãªã
+              #
+              # pp "#{svcplugin.get_caller_cell.get_name} cannot call #{svcplugin.get_callee_cell.get_name}_#{svcplugin.get_callee_ep_name}_#{func_name}"
+          end
+      }
+
+      if caller_unrestricted
+          # pp "caller_unrestricted: #{@ct_name_body}"
+          return {"check_code"=>"", "user_cannot_callable"=>false}
+      end
+
+      # 
+      #  éè¤ãåé¤
+      #
+      callable_domains.uniq!
+      # 
+      #  ç¡æå±ã«å¯¾ãããã¡ã¤ã³ãã§ãã¯ã¯å®æ½ããªã
+      #  ã«ã¼ãã«ãã¡ã¤ã³ã«å¯¾ãããã¡ã¤ã³ãã§ãã¯ã¯å®æ½ããªã
+      #
+      callable_domains = callable_domains.select { |domain|
+          ((domain.get_domain_type.get_option != "OutOfDomain") && \
+           (domain.get_domain_type.get_option != "kernel"))
+      }
+      # pp "callable_domains"
+      # pp callable_domains.map{|domain| domain.get_name }
+      # 
+      #  ãã¹ã¦ã®ã¦ã¼ã¶ãã¡ã¤ã³ããå¼åºãå¯è½ãªå ´åï¼ãã¡ã¤ã³ãã§ãã¯ã¯
+      #  å®æ½ããªã
+      #
+      all_domain_regions = DomainType.get_domain_regions[:HRP].select { |reg|
+          ((reg.get_domain_type.get_option != "OutOfDomain") && \
+           (reg.get_domain_type.get_option != "kernel"))
+
+      }
+      # pp "all domains"
+      # pp all_domain_regions.map {|reg| reg.get_name}
+      if all_domain_regions.all? {|reg| callable_domains.include?(reg)}
+          all_domain_callable = true
+      end
+
+      # 
+      #  å¼åºãå
+ãã¡ã¤ã³ã®ãã§ãã¯å¦çæ¬ä½ã®çæ
+      #
+      if callable_domains.length == 0
+        dbgPrint "callable_domain.length = 0\n"
+          # 
+          #  ã¦ã¼ã¶ãã¡ã¤ã³ããå¼åºãä¸å¯è½ãªå ´åã¯
+          #  åå¥ã®ã¨ã©ã¼ãã§ãã¯ã¯ããï¼åç­ç¡ç¨ã§E_OACVãè¿ã
+          #
+          user_cannot_callable = true
+      elsif callable_domains.length == 1
+        dbgPrint "callable_domain.length = 1\n"
+          # 
+          #  å¼åºãå¯è½ãªã¦ã¼ã¶ãã¡ã¤ã³ãåä¸ã®å ´åã¯
+          #  cdmid != <domainå> ã®å½¢å¼ã§ãã§ãã¯ãã
+          #
+          check_code += "\t/* HRPSVC0012.1 */\n"
+          check_code += "\tif (cdmid != #{callable_domains[0].get_name}) {\n"
+      elsif callable_domains.length > 1 && !all_domain_callable
+        dbgPrint "callable_domain.length > 1 && not all_domains \n"
+          # 
+          #  å¼åºãå¯è½ãªã¦ã¼ã¶ãã¡ã¤ã³ãè¤æ°ã®å ´åã¯
+          #  TACP(cdmid) & (TACP(<domainå>) | ...) != 0U
+          #  ã®å½¢å¼ã§ãã§ãã¯ãã
+          #
+          check_code += "\t/* HRPSVC0012.2 */\n"
+          check_code += "\tif((TACP(cdmid) & ("
+          check_code += (callable_domains.map { |domain| "TACP(#{domain.get_name})"}).join("|")
+          check_code += ")) != 0U) {\n"
+      else
+        dbgPrint "callable_all_domains\n"
+      end
+      if check_code != ""
+          # 
+          #  å¼åºãå¯è½ãªã¦ã¼ã¶ãã¡ã¤ã³ã®ãã§ãã¯ãããå ´åã¯
+          #  ã¨ã©ã¼ã³ã¼ããè¿ãããã®ã³ã¼ããåºåãã
+          #
+          check_code += <<EOS
+            /* HRPSVC0013 */
+            return E_OACV;
+        }
+EOS
+      end
+
+      return {"check_code"=>check_code, "user_cannot_callable"=>user_cannot_callable}
+  end
+
+  #---------------------------------------------------------#
+  #=== ã·ã°ããã£ã®ãã§ãã¯
+  def check_signature signature
+    signature.get_function_head_array.each{ |fh|
+      type = fh.get_return_type
+      check_return_type signature, fh, type
+      if fh.get_paramlist.get_items.length > NUM_SVC_ARG_MAX then
+        cdl_error( "HSV0005 $1.$2: # of parameter more than #{NUM_SVC_ARG_MAX}", signature.get_name, fh.get_name )
+      end
+      fh.get_paramlist.get_items.each{ |param|
+        check_param signature, fh, param
+      }
+    }
+  end
+  #=== æ»ãå¤ã®åã®ãã§ãã¯
+  # ER, ER_UINT ã¯æ¨å¥¨ãããå
+  # æ´æ°ããã¼ã«ãvoid ã¯å¯è½ãä»ã¯ä¸å¯
+  def check_return_type signature, fh, type
+    ot = type.get_original_type
+    if( type.get_type_str == "ER" || type.get_type_str == "ER_UINT" ) then
+      # OK!
+    elsif ot.kind_of?( IntType ) || ot.kind_of?( VoidType ) || ot.kind_of?( BoolType ) then
+      cdl_warning( "HSW0001 $1.$2: $3 return type cannot get access violation error", signature.get_name, fh.get_name, type.get_type_str.downcase )
+      check_intptr "#{signature.get_name}.#{fh.get_name} return type", type
+    else
+      cdl_error( "HSV0001 $1.$2 return type $3 cannot be used", signature.get_name, fh.get_name, type.get_type_str.to_s+type.get_type_str_post.to_s )
+    end
+  end
+  #=== å¼æ°ã®åã®ãã§ãã¯
+  def check_param signature, fh, param
+    type = param.get_type
+    ot = type.get_original_type
+    dir = param.get_direction
+    case dir
+    when :IN
+      if ot.kind_of?( IntType ) || ot.kind_of?( BoolType ) then
+        # OK!
+        check_intptr "#{signature.get_name}.#{fh.get_name}.#{param.get_name}", type
+      elsif ot.kind_of? PtrType then
+        check_ptr signature, fh, param, dir
+      else
+        cdl_error( "HSV0002 $1.$2.$3 $4 param type cannot be used", signature.get_name, fh.get_name, param.get_name, type.get_type_str.to_s+type.get_type_str_post.to_s )
+      end
+    when :OUT, :INOUT
+      if ot.kind_of? PtrType then
+        check_ptr signature, fh, param, dir
+      else
+        # error
+      end
+    when :SEND, :RECEIVE
+      cdl_error( "HSV0008 $1.$2.$3 param direction '$4' cannot be used", signature.get_name, fh.get_name, param.get_name, param.get_direction.to_s.downcase )
+    end
+  end
+  def check_ptr signature, fh, param, dir
+    type = param.get_type.get_referto
+    ot = type.get_original_type
+    if ot.kind_of?( IntType ) || ot.kind_of?( BoolType ) || ot.kind_of?( FloatType ) then
+      # OK!
+      check_intptr "#{signature.get_name}.#{fh.get_name}.#{param.get_name}", type
+    elsif ot.kind_of? PtrType then
+      cdl_error( "HSV0003 $1.$2.$3 multi-pointer type cannot be used", signature.get_name, fh.get_name, param.get_name, type.get_type_str.to_s+type.get_type_str_post.to_s )
+    elsif  ot.kind_of? StructType then
+      check_struct signature, fh, param
+    else
+      cdl_error( "HSV0004 $1.$2.$3 $4 type cannot be used", signature.get_name, fh.get_name, param.get_name, type.get_type_str.to_s+type.get_type_str_post.to_s )
+    end
+    if ( dir == :OUT || dir == :INOUT) && param.get_string == -1 then
+      cdl_error( "HSV0009 $1.$2.$3 string argment is necessary for out/inout parameter", signature.get_name, fh.get_name, param.get_name )
+    end
+  end
+  def check_struct signature, fh, param
+    type = param.get_type.get_referto
+    ot = type.get_original_type
+    ot.get_members_decl.get_items.each{ |decl|
+      type = decl.get_type
+      ot = type.get_original_type
+      if ot.kind_of?( IntType ) || ot.kind_of?( BoolType ) || ot.kind_of?( FloatType ) then
+        # OK!
+        check_intptr "#{signature.get_name}.#{fh.get_name}.#{param.get_name}.#{decl.get_name} member", type
+      else
+        dbgPrint "struct member #{decl.get_name} #{type} #{decl.get_type} #{decl.get_type.get_original_type}\n"
+        if( decl.get_type.get_original_type.kind_of? ArrayType ) then
+          dbgPrint "member array type #{decl.get_type.get_original_type.get_type} #{decl.get_type.get_original_type.get_type.get_original_type}\n"
+          check_struct_member_array signature, fh, param, decl
+        else
+          cdl_error( "HSV0006 $1.$2.$3 $4 type cannot be used as struct member", signature.get_name, fh.get_name, param.get_name, type.get_type_str.to_s+type.get_type_str_post.to_s )
+        end
+      end
+    }
+  end
+  def check_struct_member_array signature, fh, param, member_decl
+    # p "check_struct_member_array: #{member_decl.get_type.get_type_str}"
+    type = member_decl.get_type.get_type
+    ot = type.get_original_type
+    if ot.kind_of?( IntType ) || ot.kind_of?( BoolType ) || ot.kind_of?( FloatType ) then
+      # OK!
+      check_intptr "#{signature.get_name}.#{fh.get_name}.#{param.get_name}.#{member_decl.get_name} member", type
+    else
+      cdl_error( "HSV0007 $1.$2.$3 $4 type cannot be used as struct member", signature.get_name, fh.get_name, param.get_name, type.get_type_str.to_s+type.get_type_str_post )
+    end
+  end
+  def check_intptr msg, type
+    dbgPrint "check_intptr IN\n"
+    t = type
+    while( t.kind_of? DefinedType )
+      dbgPrint "check_intptr #{msg} #{t.get_type_str} #{t.get_original_type.get_type_str}\n"
+      tstr = t.get_type_str
+      tstr.sub!( /const /, "" )
+      tstr.sub!( /volatile /, "" )
+      if tstr == "intptr_t" || tstr == "uintptr_t" then
+        cdl_info( "HSI0001 $1 type '$2' not checked by plugin", msg, type.get_type_str )
+      end
+      t = t.get_type
+    end
+  end
+end
+
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPTaskPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPTaskPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRPTaskPlugin.rb	(revision 374)
@@ -0,0 +1,127 @@
+# coding: utf-8
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2018 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#  $Id$
+#++
+
+require_tecsgen_lib "HRPKernelObjectPlugin.rb"
+require_tecsgen_lib "HRPKernelObjectManager.rb"
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class HRPTaskPlugin < HRPKernelObjectPlugin
+    ##
+    # oyama: add to avoid Ruby exception in code generation phase.
+    def new_cell cell
+      region = cell.get_region
+      dbgPrint "HRPTaskCelltypePlugin new_cell=#{cell.get_name} region=#{region.get_name}\n"
+      domainOption = cell.get_region.get_domain_root.get_domain_type.get_option
+      if domainOption == "OutOfDomain"
+        cdl_error( "HRP9999 HRP task '$1' must belong to a domain", cell.get_name )
+      end
+    end
+
+    # # ATT_MODãçææ¸ã¿ãã©ãã                   # 2017.8.27
+    # @@generate_memory_module = false
+
+    #
+    #  CRE_TSKã®åºå
+    #  file:: FILE:     åºåå
+ãã¡ã¤ã«
+    #  cell :: Cell ã¿ã¹ã¯ã»ã«ã¤ã³ã¹ã¿ã³ã¹
+    #  val :: Hash {attr => string}:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    #  tab :: string: ã¿ã
+    #
+    def print_cfg_cre(file, cell, val, tab)
+        val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
+        # $cbp$ã®ä»£ãã
+        cell_IDX = @celltype.get_name_array(cell)[7]
+        # CRE_TSKã®çæ
+        dbgPrint "assign task plugin\n"
+        domainOption = cell.get_region.get_domain_root.get_domain_type.get_option
+        # if cell.get_region.get_region_type == :DOMAIN
+        if domainOption != "OutOfDomain"
+            if val[:systemStackSize] == "0"
+                # 
+                #  ã·ã¹ãã ã¹ã¿ãã¯ã®å®ç¾©ãçç¥
+                #
+                file.print <<EOT
+CRE_TSK(#{val[:id]}, { #{val[:attribute]}, #{cell_IDX}, tTask_start, #{val[:priority]}, #{val[:stackSize]}, NULL });
+EOT
+            else
+                # 
+                #  ã·ã¹ãã ã¹ã¿ãã¯ã®å®ç¾©ãè¿½å 
+                #
+                file.print <<EOT
+CRE_TSK(#{val[:id]}, { #{val[:attribute]}, #{cell_IDX}, tTask_start, #{val[:priority]}, #{val[:stackSize]}, NULL, #{val[:systemStackSize]}, NULL });
+EOT
+            end
+        else
+            #
+            #  ç¡æå±ã®ã¿ã¹ã¯ã¯å­å¨ãã¦ã¯ãªããªãããï¼ã¨ã©ã¼ã¨ãã
+            #
+            raise "task #{val[:id]} must belong to a domain."
+        end
+    end
+
+    #
+    #  SAC_TSKã®åºå
+    #  file:: FILE:     åºåå
+ãã¡ã¤ã«
+    #  val :: Hash {attr => string}:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    #  acv :: Hash {accessPatternx => string}:   ã¢ã¯ã»ã¹è¨±å¯ãã¯ã¿
+    #
+    def print_cfg_sac(file, val, acv)
+       # pp "SAC_TSK"
+       # pp val
+       file.puts "SAC_TSK(#{val[:id]}, { #{acv[:accessPattern1]}, #{acv[:accessPattern2]}, #{acv[:accessPattern3]}, #{acv[:accessPattern4]} });"
+    end
+end
+
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeCellPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeCellPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeCellPlugin.rb	(revision 374)
@@ -0,0 +1,284 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2017 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id$
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class MrubyBridgeCellPlugin < CellPlugin
+
+  # ãã©ã°ã¤ã³å¼æ°å => Proc
+  MrubyBridgePluginArgProc = { 
+      "ignoreUnsigned" => Proc.new { |obj,rhs| obj.set_ignoreUnsigned rhs },
+      "exclude_port" => Proc.new { |obj,rhs| obj.set_exclude_port rhs },
+      "exclude_port_func" => Proc.new { |obj,rhs| obj.set_exclude_port_func rhs },
+      "auto_exclude" => Proc.new { |obj,rhs| obj.set_auto_exclude rhs },
+  }
+  @@b_gen_post_code_by_dependent = false  # true if gen_post_code is called by MrubyBridgeCelltypePlugin
+  @@cell_list = {}      # gen_cdl_file'ed list to avoid duplicate generation
+  @@signature_list = {}
+
+  require_tecsgen_lib( "MrubyBridgeSignaturePlugin.rb" )
+
+  #@exclude_port::[ String(port_name) ] : 
+  #@exclude_port_func::{ [ String(port_name) ] => [ String(func_name) ] } : 
+  #@port_list::{ String(port_name) => String(include/exclude=func_name) }  : all included port and opt_string
+
+  #=== CellPlugin# initialize
+  #cell::     Cell        ã»ã«ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  # ãã®ã¡ã½ããã¯ãã»ã«ã®æ§æè§£æãçµãã£ãã¨ããã§å¼ã³åºããã
+  # ãã®æ®µéã§ã¯æå³è§£æãçµãã£ã¦ããªã
+  def initialize( cell, option )
+    dbgPrint "  #{self.class.name}: initialzie=#{cell.get_name} option=#{option}\n"
+    super
+    @cell = cell
+
+    # option
+    @b_ignoreUnsigned = false
+    @exclude_port = []
+    @exclude_port_func = {}
+    @b_auto_exclude = true     # auto_exclude = true by default 
+    MrubyBridgeSignaturePlugin.set_gen_post_code_by_dependent
+
+    @plugin_arg_str = CDLString.remove_dquote option
+    # @plugin_arg_str = option.gsub( /\A"(.*)/, '\1' )    # åå¾ã® "" ãåãé¤ã
+    # @plugin_arg_str.sub!( /(.*)"\z/, '\1' )
+    @plugin_arg_list = {}
+    dbgPrint "#{self.class.name}: initialzie: #{cell.get_name}\n"
+    @plugin_arg_check_proc_tab = MrubyBridgePluginArgProc
+    parse_plugin_arg
+
+    @port_list = {}         # set @port_list before return
+    ct = @cell.get_celltype
+    return if ct == nil     # error case
+
+    port_list = ct.get_port_list
+    if @exclude_port.length > 0 then
+      # ãã®å®è£
+ã§ã¯ãå­å¨ããªã port ãæå®ããã¦ããã§ãã¯ã§ããªã
+      # print "MRBBridgeCellPlugin: exclude list\n"
+      port_list.each{ |port|
+        if ! @exclude_port.include?( port.get_name.to_s ) then
+          # print "MRBBridgeCellPlugin: #{port.get_name} included\n"
+          @port_list[ port ] = ""
+        else
+          # print "MRBBridgeCellPlugin: #{port.get_name} excluded\n"
+        end
+      }
+    else
+      port_list.each{ |port|
+        @port_list[ port ] = ""
+      }
+    end
+
+    if @exclude_port_func.length > 0 then
+      @port_list.each{ |port, opt_str|
+        delim = ""
+        if @exclude_port_func.include?( port.get_name.to_s ) then
+          @exclude_port_func[ port.get_name.to_s ].each{ |func_name|
+            opt_str += delim + "exclude=" + func_name
+            delim = ","
+          }
+        end
+        @port_list[ port ] = opt_str
+      }
+    end
+  end
+
+  def gen_cdl_file file
+    dbgPrint "#{self.class.name}: gen_cdl_file: #{@cell.get_name}\n"
+
+    file.print <<EOT
+/* MrubyBridgeCellPlugin: generate for cell=#{@cell.get_name} */
+EOT
+
+    if @@cell_list[ @cell ] then
+      file.print <<EOT
+
+/*
+ * generate for #{@cell.get_name} duplicate and ignored.
+ * This might comes from generate for celltype.
+ */
+EOT
+      cdl_info( "MrubyBridgeCellPlugin: generate duplicate for cell '$1'", @cell.get_name )
+      return
+    end
+    @@cell_list[ @cell ] = @cell
+                
+    @port_list.each{ |port, opt_str|
+      next if port.get_signature == nil
+
+      case port.get_signature.get_context
+      when "task", "any"
+      else
+        next
+      end
+
+      if port.get_port_type == :ENTRY then
+        print "  MrubyBridgeCellPlugin: [cell.port] #{@cell.get_name}.#{port.get_name} => [mruby instance] TECS::T#{port.get_signature.get_name}.new( '#{@cell.get_name}#{port.get_name}Bridge' ) \n"
+        if @@signature_list[ port.get_signature ] == nil then
+          opt_str = "ignoreUnsigned=#{@b_ignoreUnsigned}, auto_exclude=#{@b_auto_exclude}, " + opt_str
+          # p "opt_str=#{opt_str}"
+
+          file.print <<EOT
+
+/* cell.port=#{@cell.get_name}.#{port.get_name} */
+generate( MrubyBridgePlugin, #{port.get_signature.get_namespace_path}, "#{opt_str}" );
+EOT
+          @@signature_list[ port.get_signature ] = true
+        end
+
+        # mikan option
+        nest = @cell.get_region.gen_region_str_pre file
+        nest_str = "  " * nest
+
+        file.print <<EOT
+#{nest_str}/* BridgeCell */
+#{nest_str}cell nMruby::t#{port.get_signature.get_name} #{@cell.get_name}#{port.get_name}Bridge {
+#{nest_str}    cTECS = #{@cell.get_namespace_path}.#{port.get_name};
+#{nest_str}};
+EOT
+        @cell.get_region.gen_region_str_post file
+      end
+    }
+  end
+
+  #=== å¾ãã® CDL ã³ã¼ããçæ
+  #ãã©ã°ã¤ã³ã®å¾ãã® CDL ã³ã¼ããçæ
+  #file:: File: 
+  def self.gen_post_code( file )
+    dbgPrint "#{self.name}: gen_post_code\n"
+    if ! @@b_gen_post_code_by_dependent then
+      gen_post_code_body file
+    end
+  end
+
+  def self.set_gen_post_code_by_dependent # by MrubyBridgeCelltypePlugin
+    dbgPrint "#{self.name}: set_gen_post_code_by_dependent\n"
+    @@b_gen_post_code_by_dependent = true
+    MrubyBridgeSignaturePlugin.set_gen_post_code_by_dependent
+  end
+
+  def self.gen_post_code_body file
+    # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ãããããä»¥ä¸ã®ãããªè¦åºããã¤ãããã¨
+    # file.print "/* '#{self.class.name}' post code */\n"
+    dbgPrint "#{self.name}: gen_post_code_body\n"
+    MrubyBridgeSignaturePlugin.gen_post_code_body file
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° ignoreUnsigned
+  def set_ignoreUnsigned rhs
+    if rhs == "true" || rhs == nil then
+      @b_ignoreUnsigned = true
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° exclude_port
+  def set_exclude_port rhs
+    ports = rhs.split ','
+    ct = @cell.get_celltype
+    return if ct == nil    # error case
+    ports.each{ |rhs_port|
+      obj = ct.find( rhs_port.to_sym )
+      if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
+        cdl_error( "MRB9999 exclude_port '$1' not found or not entry in celltype '$2'", rhs_port, ct.get_name )
+      else
+        # print "MRBBridgeCellPlugin: exclude #{rhs_port}\n"
+        @exclude_port << rhs_port
+      end
+    }
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° exclude_port_func
+  def set_exclude_port_func rhs
+    port_funcs = rhs.split ','
+    ct = @cell.get_celltype
+    return if ct == nil    # error case
+    port_funcs.each{ |rhs_port_func|
+      port_func = rhs_port_func.split '.'
+      if port_func.length != 2 then
+        cdl_error( "MRB9999 exclude_port_func: '$1' not in 'port.func' form", rhs_port_func )
+      end
+      obj = ct.find( port_func[0].to_sym )
+      if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
+        cdl_error( "MRB9999 exclude_port_func: port '$1' not found in celltype '$2'", rhs_port, ct.get_name )
+      else
+        signature = obj.get_signature
+        next if signature == nil     # error case
+        if signature.get_function_head port_func[1].to_sym
+          # print "MRBBridgeCellPlugin: #{port_func[0]}.#{port_func[1]} exclude\n"
+          if @exclude_port_func[ port_func[0] ] then
+            @exclude_port_func[ port_func[0] ] <<  port_func[1]
+          else
+            @exclude_port_func[ port_func[0] ] = [ port_func[1] ]
+          end
+        else
+          cdl_error( "MRB9999 exclude_port_func: func '$1' not found in port '$2' celltype $3",
+                     port_func[1], port_func[0], ct.get_name )
+        end
+      end
+    }
+  end
+  #=== ãã©ã°ã¤ã³å¼æ° auto_exclude
+  def set_auto_exclude rhs
+    # print "MrubyBridgeCellPlugin: auto_exclude=#{rhs}\n"
+    if rhs == "false" then
+      @b_auto_exclude = false
+    elsif rhs == "true" then
+      @b_auto_exclude = true     # auto_exclude = true by default 
+    else
+      cdl_warning( "MRB9999 auto_exclude: unknown rhs value ignored. specify true or false" )
+    end
+  end
+
+end
+
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeCelltypePlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeCelltypePlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeCelltypePlugin.rb	(revision 374)
@@ -0,0 +1,311 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2017 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id$
+#++
+
+require_tecsgen_lib 'tecslib/plugin/lib/MrubyBridgeCelltypePluginModule.rb'
+
+#== MrubyBridgeCompositePlugin
+class MrubyBridgeCelltypePlugin < CompositePlugin
+  dbgPrint "MrubyBridgeCelltypePlugin loaded\n"
+  include MrubyBridgeCelltypePluginModule
+
+  def self.gen_post_code( file )
+    MrubyBridgeCelltypePluginModule.gen_post_code file
+  end
+end
+
+
+#
+##== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+#class MrubyBridgeCelltypePlugin < CelltypePlugin
+#
+#  # ãã©ã°ã¤ã³å¼æ°å => Proc
+#  MrubyBridgePluginArgProc = { 
+#      "ignoreUnsigned" => Proc.new { |obj,rhs| obj.set_ignoreUnsigned rhs },
+#      "include_inner_cell" => Proc.new { |obj,rhs| obj.set_include_inner_cell rhs },
+#      "exclude_cell" => Proc.new { |obj,rhs| obj.set_exclude_cell rhs },
+#      "exclude_port" => Proc.new { |obj,rhs| obj.set_exclude_port rhs },
+#      "exclude_port_func" => Proc.new { |obj,rhs| obj.set_exclude_port_func rhs },
+#      "auto_exclude" => Proc.new { |obj,rhs| obj.set_auto_exclude rhs },
+#  }
+#
+#  require_tecsgen_lib( "MrubyBridgeCellPlugin.rb" )
+#  @@plugin_list = []
+#  @@count = 1
+#
+#  #celltype::     Celltype        ã»ã«ã¿ã¤ãï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+#  def initialize( celltype, option )
+#    dbgPrint "#{self.class.name}: initialzie: #{celltype.get_name}\n"
+#
+#    super
+#    @celltype = celltype
+#    @cell_list = []
+#    @include_inner_cell = false
+#    @exclude_cells = []
+#    @exclude_port = []
+#    @exclude_port_func = {}
+#    @b_ignoreUnsigned = false
+#    @b_auto_exclude = true     # auto_exclude = true by default 
+#    @@plugin_list << self
+#
+#    @plugin_arg_check_proc_tab = MrubyBridgePluginArgProc
+#    @plugin_arg_str = CDLString.remove_dquote option
+#    parse_plugin_arg
+#
+#    MrubyBridgeCellPlugin.set_gen_post_code_by_dependent
+#  end
+#
+#  #=== æ°ããã»ã«
+#  #cell::        Cell            ã»ã«
+#  #
+#  # celltype ãã©ã°ã¤ã³ãæå®ãããã»ã«ã¿ã¤ãã®ã»ã«ãçæããã
+#  # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ã«å¯¾ããæ°ããã»ã«ã®å ±å
+#  # generate æã«ããå¼ã³åºãããå ´åãããã¾ã§ã«å®ç¾©ããã cell ã«ã¤ãã¦ã¯ãinitialize ã®ã¿ã¤ãã³ã°ã§å¼ã³åºããã
+#  def new_cell( cell )
+#    dbgPrint "MrubyBridgeCelltypePlugin: new_cell: #{cell.get_name}\n"
+#
+#    return if @cell_list.include? cell   # ãã®è¡ã¯ãæ¬æ¥ä¸è¦ã®ã¯ã
+#    if TECSGEN.post_coded?               # post_code ä»¥éã®ã»ã«ã¯å¯¾è±¡ããå¤ã
+#      cdl_info( "I9999 MrubyBridgeCelltypePlugin: $1 is excluded because cell generated after post_coded", cell.get_name )
+#      return
+#    end
+#
+#    # include_inner_cell option
+#    if cell.is_cloned? && @include_inner_cell == false then
+#    #   p "#{cell.get_name} excluded"
+#      cdl_info( "I9999 MrubyBridgeCelltypePlugin: inner cell $1 is excluded", cell.get_name )
+#      return
+#    # else
+#    #   p "#{cell.get_name} included"
+#    end
+#
+#    # exclude_cell option
+#    if @exclude_cells.include?( cell.get_name ) then
+#      return
+#    end
+#
+#    opt_str = "ignoreUnsigned=#{@b_ignoreUnsigned}, auto_exclude=#{@b_auto_exclude}"
+#    @exclude_port.each{ |port|
+#      opt_str += ",exclude_port=#{port}"
+#    }
+#    @exclude_port_func.each{ |port, funcs|
+#      funcs.each{ |func|
+#        opt_str += ",exclude_port_func=#{port}.#{func}"
+#      }
+#    }
+#
+#    # p "MrubyBridgeCelltypePlugin: opt_str=#{opt_str}"
+#
+#    # mikan option, region
+#    fn2 = "#{$gen}/tmp_MrubyBridgeCelltypePlugin_#{@celltype.get_name}_#{@@count}.cdl"
+#    f2 = File.open( fn2, "w" )
+#    f2.print <<EOT
+#/* MrubyBridgeCelltypePlugin: celltype=#{@celltype.get_name} */
+#generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "#{opt_str}" );
+#EOT
+#    f2.close
+#    Import.new "#{fn2}"
+#    @@count += 1
+#  end
+#
+#### æå³è§£ææ®µéã§å¼ã³åºãããã¡ã½ãã ###
+#  #===  CDL ãã¡ã¤ã«ã®çæ
+#  #      typedef, signature, celltype, cell ã®ã³ã¼ããçæ
+#  #      éè¤ãã¦çæãã¦ã¯ãªããªã
+#  #      ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
+#  #      ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
+#  #file::        FILE       çæãããã¡ã¤ã«
+#  def gen_cdl_file file
+##   ãã®æ®µéã§å¼ã³ã ãã¨ generate æãå¼ã³åºãããåã®ã»ã«ã®ã¿ã®åºåã¨ãªã
+#    
+##    dbgPrint "MrubyBridgeCelltypePlugin: gen_cdl_file: #{@celltype.get_name}\n"
+##    file.print <<EOT
+##/* MrubyBridgeCelltypePlugin: celltype=#{@celltype.get_name}
+## *
+## *    cell's generate before celltype's generate
+## */
+##
+##EOT
+##    @celltype.get_cell_list.each { |cell|
+##      @cell_list << cell
+##      # mikan option, region
+##      dbgPrint "MrubyBridgeCelltypePlugin: cell=#{cell.get_name}\n"
+##      file.print <<EOT
+##generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "" );
+##EOT
+##    }
+#
+#  end
+#
+#  #=== tCelltype_factory.h ã«æ¿å
+¥ããã³ã¼ããçæãã
+#  # file ä»¥å¤ã®ä»ã®ãã¡ã¤ã«ã«ãã¡ã¯ããªã³ã¼ããçæãã¦ããã
+#  # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ãæå®ãããã»ã«ã¿ã¤ãã®ã¿å¼ã³åºããã
+#  def gen_factory file
+#  end
+#
+#  def get_celltype
+#    @celltype
+#  end
+#
+#  #=== å¾ãã® CDL ã³ã¼ããçæ
+#  #ãã©ã°ã¤ã³ã®å¾ãã® CDL ã³ã¼ããçæ
+#  #file:: File: 
+#  def self.gen_post_code( file )
+#    dbgPrint "#{self.name}: gen_post_code_body\n"
+#    print "#{self.name}: gen_post_code_body\n"
+##    ãã®æ®µéã§çæããã¨ãåããã¹ãã³ã¼ãã§åºåããã mruby ã®åæåã³ã¼ãã«åæ ãããªã
+#    
+##    # MrubyBridgeCelltypePlugin ã®çæãã generate æã¯ã
+##    fn2 = "#{$gen}/tmp_MrubyBridgeCelltypePlugin_post.cdl"
+##    f2 = File.open( fn2, "w" )
+##    # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ãããããä»¥ä¸ã®ãããªè¦åºããã¤ãããã¨
+##    dbgPrint "MrubyBridgeCelltypePlugin: gen_post_code\n"
+##    f2.print "/* '#{self.name}' post code */\n"
+##    @@plugin_list.each{ |plugin|
+##      plugin.get_celltype.get_cell_list.each{ |cell|
+##        # mikan option, region
+##        f2.print <<EOT
+##generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "" );
+##EOT
+##      }
+##    }
+##    f2.close
+##    p Import
+##    Import.new "#{fn2}"
+#
+#    MrubyBridgeCellPlugin.gen_post_code_body file
+#  end
+#
+#  #=== ãã©ã°ã¤ã³å¼æ° 
+#
+#  #=== ãã©ã°ã¤ã³å¼æ° ignoreUnsigned
+#  def set_ignoreUnsigned rhs
+#    if rhs == "true" || rhs == nil then
+#      @b_ignoreUnsigned = true
+#    end
+#  end
+#
+#  def set_include_inner_cell rhs
+#    if rhs == "true" || rhs == nil then
+#      @include_inner_cell = true
+#    end
+#  end
+#
+#  def set_exclude_cell rhs
+#    cells = rhs.split ','
+#    cells.each{ |rhs_cell|
+#      rhs_cell.gsub!( /\s/, "" )
+#      @exclude_cells << rhs_cell.to_sym
+#    }
+#  end
+#  def set_exclude_port rhs
+#    ports = rhs.split ','
+#    ct = @cell.get_celltype
+#    return if ct == nil    # error case
+#    ports.each{ |rhs_port|
+#      obj = ct.find( rhs_port.to_sym )
+#      if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
+#        cdl_error( "MRB9999 exclude_port '$1' not found or not entry in celltype '$2'", rhs_port, ct.get_name )
+#      else
+#        # print "MRBBridgeCellPlugin: exclude #{rhs_port}\n"
+#        @exclude_port << rhs_port
+#      end
+#    }
+#  end
+#
+#  #=== ãã©ã°ã¤ã³å¼æ° exclude_port_func
+#  def set_exclude_port_func rhs
+#    port_funcs = rhs.split ','
+#    ct = @celltype
+#    return if ct == nil    # error case
+#    port_funcs.each{ |rhs_port_func|
+#      port_func = rhs_port_func.split( '.' )
+#      if port_func.length != 2 then
+#        cdl_error( "MRB9999 exclude_port_func: '$1' not in 'port.func' form", rhs_port_func )
+#      end
+#      obj = ct.find( port_func[0].to_sym )
+#      if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
+#        cdl_error( "MRB9999 exclude_port_func: port '$1' not found in celltype '$2'", rhs_port_func, ct.get_name )
+#      else
+#        signature = obj.get_signature
+#        next if signature == nil     # error case
+#        if signature.get_function_head port_func[1].to_sym
+#          # print "MRBBridgeCellPlugin: #{port_func[0]}.#{port_func[1]} exclude\n"
+#          if @exclude_port_func[ port_func[0] ] then
+#            @exclude_port_func[ port_func[0] ] <<  port_func[1]
+#          else
+#            @exclude_port_func[ port_func[0] ] = [ port_func[1] ]
+#          end
+#        else
+#          cdl_error( "MRB9999 include_port_func: func '$1' not found in port '$2' celltype $3",
+#                     port_func[1], port_func[0], ct.get_name )
+#        end
+#      end
+#    }
+#  end
+#
+#  #=== ãã©ã°ã¤ã³å¼æ° auto_exclude
+#  def set_auto_exclude rhs
+#    # print "MrubyBridgeCellPlugin: auto_exclude=#{rhs}\n"
+#    if rhs == "false" then
+#      @b_auto_exclude = false
+#    elsif rhs == "true" then
+#      @b_auto_exclude = true     # auto_exclude = true by default 
+#    else
+#      cdl_warning( "MRB9999 auto_exclude: unknown rhs value ignored. specify true or false" )
+#    end
+#  end
+#end
+#
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeCompositePlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeCompositePlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeCompositePlugin.rb	(revision 374)
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2017 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id$
+#++
+
+require_tecsgen_lib 'tecslib/plugin/lib/MrubyBridgeCelltypePluginModule.rb'
+
+#== MrubyBridgeCompositePlugin
+class MrubyBridgeCompositePlugin < CompositePlugin
+  dbgPrint "MrubyBridgeCompositePlugin loaded\n"
+  include MrubyBridgeCelltypePluginModule
+
+  def self.gen_post_code( file )
+    MrubyBridgeCelltypePluginModule.gen_post_code file
+  end
+end
+
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgePlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgePlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgePlugin.rb	(revision 374)
@@ -3,5 +3,5 @@
 #  mruby => TECS bridge
 #  
-#   Copyright (C) 2008-2015 by TOPPERS Project
+#   Copyright (C) 2008-2017 by TOPPERS Project
 #
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeSignaturePlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeSignaturePlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeSignaturePlugin.rb	(revision 374)
@@ -0,0 +1,1336 @@
+# -*- coding: utf-8 -*-
+#
+#  mruby => TECS bridge
+#  
+#   Copyright (C) 2008-2017 by TOPPERS Project
+#
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id$
+#
+
+# Todo:
+# çæãããã®
+#  gen_cdl_file
+#    ããªãã¸åæåã»ã«ã¿ã¤ã (ã·ã°ããã£ãã¨)
+#       @@init_celltypes ã«è¨é²
+#    ããªãã¸ã»ã«ã¿ã¤ã (ã·ã°ããã£ãã¨)
+#       @@celltypes ã«è¨é²
+#    æ§é ä½ã»ã«ã¿ã¤ã
+#       @@struct_list ã«è¨é²
+#  new_cell
+#    TECS åæåã»ã«(ãã­ãã¿ã¤ãå®£è¨)
+#       @@VM_init_cells ã«è¨é²
+#       @@VM_struct_list ã«è¨é²
+#       @@VM_ptr_list ã«è¨é²
+#  gen_post_code
+#    æ§é ä½åæåã»ã«
+#    ãã¤ã³ã¿åæåã»ã«
+#    TECS åæåã»ã«
+#
+#   ep_func ã®ä½æ
+#     signature, ãã¤ã³ã¿ãæ§é ä½ â¦ åæååãå£ï¼mruby VM ã¸ã®ç»é²
+#     ãã¤ã³ã¿
+#   preamble ã®ä½æ
+#     ãã¤ã³ã¿ãæ§é ä½ â¦ ã¢ã¯ã»ã¹ç¨ã³ã¼ãã®çæ
+#     signature â¦ ããªãã¸é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨
+#   postamble ã®ä½æ
+#     signature â¦ ããªãã¸é¢æ°ã®å®ç¾©
+
+class MrubyBridgeSignaturePlugin < SignaturePlugin
+
+  # ãã©ã°ã¤ã³å¼æ°å => Proc
+  MrubyBridgePluginArgProc = { 
+      "ignoreUnsigned" => Proc.new { |obj,rhs| obj.set_ignoreUnsigned rhs },
+      "include" => Proc.new { |obj,rhs| obj.set_include rhs },
+      "exclude" => Proc.new { |obj,rhs| obj.set_exclude rhs },
+      "auto_exclude" => Proc.new { |obj,rhs| obj.set_auto_exclude rhs },
+  }
+
+  @@b_no_banner = false         #
+  @@b_gen_post_code_by_dependent = false  # true if gen_post_code is called by MrubyBridgeCellPlugin
+  @@celltypes = { }             # {celltype_name => [ BridgePlugin ã®ã¤ã³ã¹ã¿ã³ã¹ã®é
+å }
+  @@init_celltypes = { }        # {celltype_name => [ BridgePlugin ã®ã¤ã³ã¹ã¿ã³ã¹ã®é
+å }
+  @@struct_list = { }           # {struct_name=>StructType}
+  @@ptr_list = { }              # {ptr_celltype_name=> @@TYPE_MAP ã®å¯¾å¿ãããã®}
+  @@VM_list = { }               # VM_name => true
+  @@VM_celltypes = {  }             # VM_name => { @celltype_name => ã»ã«ã®é
+å }
+  @@VM_struct_list = { }           # {name=>StructType}
+  @@VM_ptr_list = { }              # { VM_name => {name=> @@TYPE_MAP ã®å¯¾å¿ãããã®} }
+  @@TYPE_MAP = {           # type_str   class             GET_SET
+    :char_t            => [:char_t,    "Char",     :Char,  :INT   ],
+    :uchar_t           => [:uchar_t,   "UChar",    :Char,  :INT   ],
+    :schar_t           => [:schar_t,   "SChar",    :Char,  :INT   ],
+
+    :bool_t            => [:bool_t,    "Bool",     :Bool,  :BOOL  ],
+    :int8_t            => [:int8_t,    "Int8",     :Int,   :INT   ],
+    :int16_t           => [:int16_t,   "Int16",    :Int,   :INT   ],
+    :int32_t           => [:int32_t,   "Int32",    :Int,   :INT   ],
+    :int64_t           => [:int64_t,   "Int64",    :Int,   :INT   ],
+    :uint8_t           => [:uint8_t,   "UInt8",    :Int,   :INT   ],
+    :uint16_t          => [:uint16_t,  "UInt16",   :Int,   :INT   ],
+    :uint32_t          => [:uint32_t,  "UInt32",   :Int,   :INT   ],
+    :uint64_t          => [:uint64_t,  "UInt64",   :Int,   :INT   ],
+
+    :int               => [:int,       "Int",      :Int,  :INT   ], 
+    :char              => [:char,      "Char",     :Char, :INT   ],    # char ã¯ char_t ã¨ãã¦æ±ã
+    :short             => [:short,     "Short",    :Int,  :INT   ],
+    :long              => [:long,      "Long",     :Int,  :INT   ],
+
+    :"unsigned char"   => [:uchar_t,   "UChar",         :Char, :INT   ],
+    :"unsigned int"    => [:"unsigned int",   "UInt",   :Int,  :INT   ],
+    :"unsigned short"  => [:"unsigned short", "UShort", :Int,  :INT   ],
+    :"unsigned long"   => [:"unsigned long",  "ULong",  :Int,  :INT   ],
+    :"signed char"     => [:schar_t,   "SChar",    :Char,  :INT   ],
+    :"signed int"      => [:int,       "Int",      :Int,   :INT   ],
+    :"signed short"    => [:short,     "Short",    :Int,   :INT   ],
+    :"signed long"     => [:long,      "Long",     :Int,   :INT   ],
+
+    :float32_t         => [:float32_t, "Float32",  :Float, :FLOAT ],
+    :double64_t        => [:double64_t,"Double64", :Float, :FLOAT ],
+
+    :float             => [:float,     "Float32",  :Float, :FLOAT ],
+    :double            => [:double,    "Double64", :Float, :FLOAT ]
+  }
+
+  # included  or excluded functions
+
+  ### ã­ã¼ããããæç¹ã§å®è¡ããã ###
+
+  # -I ã« $(TECSPATH)/mruby ãè¿½å 
+  # TECSGEN::Makefile.add_obj "$(MRUBY_MAIN_OBJ)"
+  TECSGEN::Makefile.add_ldflag "-lmruby -L$(MRUBYPATH)/lib -lm"
+  TECSGEN::Makefile.add_search_path "$(MRUBYPATH)/include"
+  TECSGEN::Makefile.add_var "MRUBYPATH",      "..",  "CHANGE this to suitable path"
+  # TECSGEN::Makefile.add_var "MRUBY_MAIN_OBJ", "$(_TECS_OBJ_DIR)tecs_mruby.o", "CHANGE this if your have your main"
+
+  #=== ãã©ã°ã¤ã³ã¤ã³ã¹ã¿ã³ã¹ã®åæå
+  # æ»ãå¤ãå¼æ°ã®åãä½¿ç¨å¯è½ãªãã®ããã§ãã¯ãã
+  #
+  def initialize( signature, option )
+    super
+
+    if ! @@b_no_banner
+      STDERR << "MrubyBridgePlugin: version 1.3.0 (Suitable for mruby ver 1.3.0 & ver 1.2.0). \n"
+      @@b_no_banner = true
+    end
+
+    @b_ignoreUnsigned = false
+    @includes = []
+    @excludes = []
+    @struct_list = { }
+    @ptr_list = { }
+    @auto_exclude_list = {}
+    @b_auto_exclude = true     # auto_exclude = true by default 
+
+    @plugin_arg_check_proc_tab = MrubyBridgePluginArgProc
+    parse_plugin_arg
+
+    @celltype_name = :"t#{@signature.get_global_name}"
+    @init_celltype_name = :"#{@celltype_name}_Initializer"
+        # this variable is sometimes not used. rhs coded directry.
+    @class_name = :"T#{@signature.get_global_name}"
+
+    @func_head_array = []
+    fh_array = []
+    if @includes.length > 0 && @excludes.length > 0 then
+      cdl_error( "MRB1011 both include && exclude are specified" )
+    end
+
+    if signature.get_function_head_array == nil then
+      return   # ä»¥åã«ææ³ã¨ã©ã¼çºç
+    end
+
+    signature.get_function_head_array.each{ |func_head|
+      if @includes.length > 0 then
+        if @includes.index func_head.get_name then
+          dbgPrint "MrubyBridgePlugin: #{func_head.get_name} INCLUDED\n"
+          fh_array << func_head
+        else
+          dbgPrint "MrubyBridgePlugin: #{func_head.get_name} NOT included\n"
+        end
+      elsif @excludes.length > 0 then
+        if @excludes.index( func_head.get_name ) == nil then
+          dbgPrint "MrubyBridgePlugin: #{func_head.get_name} NOT excluded\n"
+          fh_array << func_head
+        else
+          dbgPrint "MrubyBridgePlugin: #{func_head.get_name} EXCLUDED\n"
+        end
+      else
+        fh_array << func_head
+      end
+    }
+
+    check_name_and_return_type fh_array
+    check_parameter_type fh_array
+
+    fh_array.each{ |fh|
+      if @auto_exclude_list[ fh.get_name ] == nil then
+        @func_head_array << fh
+      else
+        dbgPrint "MrubyBridgePlugin: auto_exclude #{fh.get_name}\n"
+      end
+    }
+
+    if @func_head_array.length == 0 then
+      cdl_error( "MRB1012 '$1' no function remained by exclude", @signature.get_name )
+    end
+  end
+
+  #=== check function name & return type
+  def check_name_and_return_type func_head_array
+    b_init = false; b_init_cell = false
+    func_head_array.each{ |func_head|
+      if( func_head.get_name == :initialize )then
+        cdl_warning( "MRW2001 initialize: internally defined. change to initialize_cell in ruby" )
+        b_init = true
+      elsif( func_head.get_name == :initialize_cell )then
+        b_init_cell = true
+      end
+      rtype = func_head.get_return_type.get_original_type
+      case rtype
+      when BoolType, IntType, FloatType, VoidType
+      else
+        if @b_auto_exclude then
+          cdl_info( "MRI0001 cannot return type $1, $2 automatcally excluded", rtype.get_type_str, func_head.get_name )
+          @auto_exclude_list[ func_head.get_name ] = func_head
+        else
+          cdl_error( "MRB1001 cannot return type $1", rtype.get_type_str )
+        end
+      end
+    }
+    if( b_init && b_init_cell )then
+      cdl_warning( "MRB1002 initialize: internally defined. change to initialize_cell in ruby" )
+    end
+  end
+
+  #=== check paramter type
+  def check_parameter_type func_head_array
+    # check type of parameters
+    func_head_array.each{ |fh|
+      fh.get_paramlist.get_items.each{ |param_decl|
+        case param_decl.get_direction
+        when :SEND, :RECEIVE
+          if @b_auto_exclude then
+            cdl_info( "MRI0002 $1: $2 parameter cannot be used in mruby Bridge, $3 automatcally excluded",
+                      param_decl.get_name, param_decl.get_direction.to_s.downcase, fh.get_name )
+            @auto_exclude_list[ fh.get_name ] = fh
+          else
+            cdl_error( "MRB1003 $1: $2 parameter cannot be used in mruby Bridge",  param_decl.get_name, param_decl.get_direction.to_s.downcase )
+          end
+        end
+        type = param_decl.get_type
+        type_org = type.get_original_type
+        type_str = type.get_type_str + type.get_type_str_post
+
+        b_ng = false
+        case type_org
+        when IntType
+          case  type_org.get_bit_size
+          when 8, 16, 32, 64
+          when -1, -2, -3, -4, -11
+          else
+            b_ng = true
+          end
+        when BoolType
+        when FloatType
+        when PtrType
+          ttype_org = type_org.get_type       # ãã¤ã³ã¿ã®æãã¦ããå
+ã®å
+          ttype = ttype_org.get_original_type # ä¸è¨ã® typedef ããã¦ããå ´åãå
+ã®å
+          register_ptr_type ttype_org, fh
+
+          if( type_org.get_string.to_s == "-1" ) then
+            case param_decl.get_direction
+            when :OUT, :INOUT
+              if @b_auto_exclude then
+                cdl_info( "MRB9999 string specifier without length cannot be used for out & inout parameter, $1 automatcally excluded", 
+                        fh.get_name )
+                @auto_exclude_list[ fh.get_name ] = fh
+              else
+                cdl_error( "MRB9999 string specifier without length cannot be used for out & inout parameter")
+              end
+            end
+          end
+
+          case ttype
+          when IntType
+            bit_size = ttype.get_bit_size
+            # if  bit_size < 0 && bit_size != -1 then
+            #   b_ng = true
+            # end
+          when FloatType
+          when BoolType
+          when StructType
+            if( type_org.get_size || type_org.get_string || type_org.get_count ) then
+              if @b_auto_exclude then
+                cdl_info( "MRI9999 $1: size_is, count_is, string cannot be specified for struct pointer, $2 automatcally excluded",
+                          param_decl.get_name, fh.get_name )
+                @auto_exclude_list[ fh.get_name ] = fh
+              else
+                cdl_error( "MRB1004 $1: size_is, count_is, string cannot be specified for struct pointer", param_decl.get_name )
+              end
+            end
+            check_struct_member ttype_org, fh
+          else
+            b_ng = true
+          end
+        when StructType
+          check_struct_member type_org, fh
+        else  # ArrayType, FuncType, EnumType, VoidType
+          b_ng = true
+        end
+        if b_ng then
+          if @b_auto_exclude then
+            cdl_info( "MRI9999 $1: type $2 cannot be used in mruby Bridge, $3 automatcally excluded",
+                      param_decl.get_name, type_str, fh.get_name )
+            @auto_exclude_list[ fh.get_name ] = fh
+          else
+            cdl_error( "MRB1005 $1: type $2 cannot be used in mruby Bridge", param_decl.get_name, type_str )
+          end
+        end
+      }
+    }
+  end
+
+  #=== æ§é ä½ã®ã¡ã³ãã¼ã®åã®ãã§ãã¯
+  def check_struct_member struct_type, fh
+    #p "tag name:#{struct_type.get_name}"
+    # sttype = Namespace.find_tag( struct_type.get_name )
+    sttype = struct_type.get_original_type
+    if sttype.get_name == nil then
+      if @b_auto_exclude then
+        cdl_info( "MRI9999 tagless-struct cannot be handled, $1 automatcally excluded", fh.get_name )
+        @auto_exclude_list[ fh.get_name ] = fh
+        return  # ç»é²ããªãããã«æã¡åã
+      else
+        cdl_error( "MRB10007 tagless-struct cannot be handled")
+      end
+    end
+    sttype.get_members_decl.get_items.each { |d|
+      t = d.get_type.get_original_type
+      case t
+      when IntType, FloatType, BoolType
+      else
+        if @b_auto_exclude then
+          cdl_info( "MRI9999 $1: type $2 not allowed for struct member, $3 automatcally excluded",
+                    d.get_name, d.get_type.get_type_str + d.get_type.get_type_str_post, fh.get_name )
+          @auto_exclude_list[ fh.get_name ] = fh
+          return  # ç»é²ããªãããã«æã¡åã
+        else
+          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 )
+        end
+      end
+    }
+    st_name = :"t{}"
+    if @struct_list[ sttype.get_name ] == nil then
+      # print_msg "  MrubyBridgePlugin: [struct]   #{struct_type.get_type_str} => class TECS::Struct#{sttype.get_name}\n"
+      print "  MrubyBridgePlugin: [struct]   #{struct_type.get_type_str} => class TECS::Struct#{sttype.get_name}\n"
+      @struct_list[ sttype.get_name ] = sttype
+    end
+  end
+
+  def register_ptr_type ttype, fh
+    t_org = ttype.get_original_type
+    tment = get_type_map_ent t_org
+    if tment == nil then
+      return
+      # cdl_error( "MRB1008 unknown pointer type '$1'", ttype.get_type_str )
+    end
+    ptr_celltype_name = :"t#{tment[1]}Pointer"
+    if @@ptr_list[ ptr_celltype_name ] == nil then
+      # print_msg "  MrubyBridgePlugin: [pointer]  #{ttype.get_type_str}* => class TECS::#{tment[1]}Pointer\n"
+      print "  MrubyBridgePlugin: [pointer]  #{ttype.get_type_str}* => class TECS::#{tment[1]}Pointer\n"
+      @@ptr_list[ ptr_celltype_name ] = tment
+    end
+    if @ptr_list[ ptr_celltype_name ] == nil then
+      @ptr_list[ ptr_celltype_name ] = tment
+    end
+  end
+
+  def get_type_map_ent ttype
+    # structure type is registerd in check_struct_member
+    if ttype.kind_of? StructType
+      return
+    end
+    tstr = ttype.get_type_str.sub( /const /, "" )    # const ã¯ç¡è¦
+    tstr = tstr.sub( /volatile /, "" )               # volatile ãç¡è¦
+    if @b_ignoreUnsigned then
+      tstr = tstr.sub( /unsigned /, "" )             # volatile ãç¡è¦
+      tstr = tstr.sub( /uint/, "int" )               # volatile ãç¡è¦
+      tstr = tstr.sub( /[cs]char/, "char" )          # volatile ãç¡è¦
+    end
+    return @@TYPE_MAP[ tstr.to_sym ]
+  end
+
+  #===  CDL ãã¡ã¤ã«ã®çæ
+  #      typedef, signature, celltype, cell ã³ã¼ããçæ
+  #file::        FILE       çæãããã¡ã¤ã«
+  def gen_cdl_file(file)
+
+    # ããªãã¸ã»ã«ã¿ã¤ãã®çæ
+    if @@celltypes[ @celltype_name ] == nil then
+      @@celltypes[ @celltype_name ] = [ self ]
+      @@init_celltypes[ @init_celltype_name ] = true
+      print_msg <<EOT
+  MrubyBridgePlugin: [signature] #{@signature.get_namespace_path} => [celltype] nMruby::#{@celltype_name} => [class] TECS::#{@class_name}
+EOT
+
+      file.print <<EOT
+/*
+ * MrubyBridgeSignaturePlugin:
+ *     signature=#{@signature.get_namespace_path}
+ *
+ *   => celltype=nMruby::#{@celltype_name}
+ *      (bridge cell's celltype; generated in this file)
+ *      cell nMruby::#{@celltype_name} BridgeCellName { cTECS = CellName.eEntry; };
+ *        where eEntry's signature must be #{@signature.get_namespace_path}.
+ *      => class=TECS::#{@class_name}
+ *         (mruby's class; accessible from your script)
+ *          bridge = TECS::#{@class_name}.new("BridgeCellName")
+ */
+import( <mruby.cdl> );
+
+/****  Ruby => TECS Bridge Celltype (MBP500) ****/
+namespace nMruby{
+    // bridge celltype
+    [idx_is_id,active]   // not actually active, to avoid warning W1002, W1007
+    celltype #{@celltype_name} {
+        call #{@signature.get_namespace_path.to_s} cTECS;
+        attr {
+            [omit]
+            char_t *VMname = "VM";
+            [omit]
+            char_t *bridgeName = C_EXP( "$cell$" );
+        };
+    };
+    // bridge initializer celltype
+    celltype #{@init_celltype_name} {
+        entry sInitializeTECSBridge eInitialize;
+    };
+};
+EOT
+
+      # æ§é ä½ã»ã«ã¿ã¤ãã®çæ
+      @struct_list.each{ |name, sttype|
+        if @@struct_list[ name ] == nil then
+          file.print <<EOT
+namespace nMruby{
+    [singleton]
+    celltype #{name} {
+        entry sInitializeTECSBridge eInitialize;
+    };
+};
+EOT
+          @@struct_list[ name ] = sttype
+        end
+      }
+
+    else
+      cdl_info( "MRBW001 MrubyBridgePlugin: signature '$1' duplicate. ignored current one", @signature.get_namespace_path )
+      @@celltypes[ @celltype_name ] << self
+    end
+  end
+
+  #=== gen_cdl_file ã§å®ç¾©ããã»ã«ã¿ã¤ãã« æ°ããã»ã«ãå®ç¾©ããã
+  # cell ã®ã»ã«ã¿ã¤ãã®ååã¯ @celltype_name
+  def new_cell cell
+    if cell.get_celltype.get_name != @celltype_name then
+      return
+    end
+
+    join = cell.get_join_list.get_item :VMname
+    if join then
+      vm_name = CDLString.remove_dquote(join.get_rhs.to_s).to_sym
+    else
+      vm_name = :"VM"
+    end
+
+    if @@VM_list[ vm_name ] == nil then
+      @@VM_list[ vm_name ] = true
+
+      initializer_celltype_cdl = "#{$gen}/#{cell.get_name}Initializer.cdl"
+      file = CFile.open( initializer_celltype_cdl, "w" )
+
+      # TECS åæåã»ã«(ãã­ãã¿ã¤ãå®£è¨)
+      print_msg "  MrubyBridgePlugin: join your VM's cInitialize to #{vm_name}_TECSInitializer.eInitialize\n"
+
+      file.print <<EOT
+
+  // prototype of TECSInitializer (MBP510)
+  cell nMruby::tTECSInitializer #{vm_name}_TECSInitializer;
+EOT
+      file.close
+
+      Generator.parse( initializer_celltype_cdl, self )
+    end
+
+    if @@VM_celltypes[ vm_name ] then
+      vma = @@VM_celltypes[ vm_name ]
+
+      if vma[ @celltype_name ] then
+        vma[ @celltype_name ] << cell
+      else
+        vma[ @celltype_name ] = [cell]
+        @@VM_celltypes[ vm_name ] = vma
+      end
+    else
+      vma = { }
+      vma[ @celltype_name ] = [cell]
+      @@VM_celltypes[ vm_name ] = vma
+    end
+
+    @struct_list.each{ |stname, sttype|
+      if @@VM_struct_list[ vm_name ] then
+        @@VM_struct_list[ vm_name ][ sttype.get_name ] = sttype
+      else
+        @@VM_struct_list[ vm_name ] = { sttype.get_name => sttype }
+      end
+    }
+    @ptr_list.each{ |ptr_celltype_name, tment|
+      if @@VM_ptr_list[ vm_name ] then
+        @@VM_ptr_list[ vm_name ][ ptr_celltype_name ] = tment
+      else
+        @@VM_ptr_list[ vm_name ] = { ptr_celltype_name => tment }
+      end
+    }
+
+  end
+
+  #=== ãã©ã°ã¤ã³ã CDL ã® POST ã³ã¼ããçæ
+  # tmp_plugin_post_code.cdl ã¸ã®åºå
+  def self.gen_post_code file
+    dbgPrint "#{self.name}: gen_post_code\n"
+    if ! @@b_gen_post_code_by_dependent then
+      gen_post_code_body file
+    end
+  end
+
+  def self.set_gen_post_code_by_dependent # by MrubyBriddeCellPlugin
+    dbgPrint "#{self.name}: set_gen_post_code_by_dependent\n"
+    @@b_gen_post_code_by_dependent = true
+  end
+
+  def self.gen_post_code_body file
+    dbgPrint "#{self.name}: gen_post_code_body\n"
+
+#     file.print <<EOT
+# namespace nMruby {
+# EOT
+# 
+#     @@ptr_list.each{ |name,tment|
+#       file.print <<EOT
+# 
+#     // MBP600
+#     [singleton]
+#     celltype #{name} {
+#         entry  sInitializeTECSBridge eInitialize;
+#     };
+# EOT
+#     }
+# 
+#     file.print <<EOT
+# };
+# EOT
+
+# gen_post_code ã§çæãã celltype ã¯ gen_ep_func ãå¼ã³åºãããªã #847
+#    @@struct_list.each{ |name,sttype|
+#      file.print <<EOT
+#
+#    [singleton]
+#    celltype #{name} {
+#        entry  sInitializeTECSBridge eInitialize;
+#    };
+#EOT
+#    }
+
+    file.print "\n  // MrubyBridgeSignaturePlugin: MBP601\n"
+    @@VM_celltypes.each{ |vm_name, instance_list|
+      instance_list.each { |celltype_name, array|
+        cell = array[0]
+	if cell.get_celltype then
+	  ct_name = cell.get_celltype.get_name
+        file.print <<EOT
+  cell nMruby::#{ct_name}_Initializer #{vm_name}_#{ct_name}_Initializer{ };
+EOT
+        end
+      }
+    }
+
+    file.print "  // MBP602\n"
+    @@ptr_list.each{ |name,tment|
+      file.print <<EOT
+  cell nMruby::#{name} C#{name} { };
+EOT
+    }
+
+    file.print "  // MBP603\n"
+    @@struct_list.each{ |name,sttype|
+      file.print <<EOT
+  cell nMruby::#{name} C#{name} { };
+EOT
+    }
+
+    if @@VM_celltypes == nil
+      raise "MrubyBridgeSignaturePlugin: are0"
+    end
+    @@VM_celltypes.each{ |vm_name, instance_list|
+      file.print "  /* === VM name is '#{vm_name}' === (MBP610) */\n"
+      init_cell_name = "#{vm_name}_TECSInitializer"
+
+      file.print "  cell nMruby::tTECSInitializer #{init_cell_name} {\n"
+
+      instance_list.each { |celltype_name, array|
+#        array.each{ |cell|
+#          ct_name = cell.get_celltype.get_name
+          ct_name = celltype_name
+          file.print "    cInitialize[] = #{vm_name}_#{ct_name}_Initializer.eInitialize;\n"
+#        }
+      }
+      if @@VM_ptr_list[vm_name] then
+        @@VM_ptr_list[vm_name].each{ |name, tment|
+          file.print "    cInitialize[] = C#{name}.eInitialize;\n"
+        }
+      end
+      if @@VM_struct_list[vm_name] then
+        @@VM_struct_list[vm_name].each{ |name, sttype|
+          file.print "    cInitialize[] = C#{name}.eInitialize;\n"
+        }
+      end
+      file.print "  };"
+    }
+    
+  end
+
+  ####### ä»¥ä¸ã³ã¼ãçææ®µé ######
+
+  #===  åãå£é¢æ°ã®æ¬ä½ã³ã¼ããçæï¼é ­é¨ã¨æ«å°¾ã¯å¥éåºåï¼
+  #ct_name:: Symbol    (ãã©ã°ã¤ã³ã§çæããã) ã»ã«ã¿ã¤ãå ï¼Symbol ã¨ãã¦éããã¦ãã
+  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 )
+    if @@celltypes[ ct_name ] then
+      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 )
+    elsif @@init_celltypes[ ct_name ] then
+      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 )
+    elsif @@ptr_list[ ct_name ] then
+      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 )
+    elsif @@struct_list[ ct_name ] then
+      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 )
+    else
+      raise "MrubyBridgeSignaturePlugin: Unknown #{ct_name}"
+    end
+  end
+
+  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 )
+    raise "MrubyBridgeSignaturePlugin: unexpected "
+  end
+
+  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 )
+    file.print <<EOT
+    // CELLCB *p_cellcb = GET_CELLCB( idx );  /* no error check */     /* MBP700 */
+    struct RClass	*rc;
+
+    rc = mrb_define_class_under( mrb, TECS, \"#{@class_name}\", mrb->object_class );
+    mrb_define_method( mrb, rc, "initialize", MrubyBridge_#{@celltype_name}_initialize, MRB_ARGS_REQ(1) );
+    MRB_SET_INSTANCE_TT(rc, MRB_TT_DATA);
+EOT
+
+    @func_head_array.each{ |f|
+      if ! f.is_function? then
+        next
+      end
+      if f.get_name != :initialize then
+        func_name = f.get_name
+      else
+        func_name = :initialize_cell
+      end
+
+      ret_type = f.get_return_type
+      n_param = 0
+      f.get_paramlist.get_items.each{ |param|
+        case param.get_direction
+        when :IN, :INOUT, :OUT
+          n_param += 1
+        when :SEND, :RECEIVE
+          raise "MrubyBridgeSignaturePlugin: send, receive"
+        end
+      }
+      if n_param > 0 then
+        p_str = "MRB_ARGS_REQ( #{n_param} )"
+      else
+        p_str = "MRB_ARGS_NONE()"
+      end
+      file.print <<EOT
+	mrb_define_method( mrb, rc, "#{func_name}", MrubyBridge_#{@celltype_name}_#{func_name}, #{p_str} );
+EOT
+    }
+  end
+
+  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 )
+    
+    t = @@ptr_list[ct_name]
+    type = t[1]
+    file.print <<EOT
+	struct RClass *a;                                /* MBP710 */
+
+    a = mrb_define_class_under(mrb, TECS, "#{type}Pointer", mrb->object_class);
+    MRB_SET_INSTANCE_TT(a, MRB_TT_DATA);
+
+    mrb_define_method(mrb, a, "initialize",      #{type}Pointer_initialize,   MRB_ARGS_REQ(1));
+    mrb_define_method(mrb, a, "[]",              #{type}Pointer_aget,         MRB_ARGS_REQ(1));
+    mrb_define_method(mrb, a, "value",           #{type}Pointer_get_val,      MRB_ARGS_NONE());
+    mrb_define_method(mrb, a, "[]=",             #{type}Pointer_aset,         MRB_ARGS_REQ(2));
+    mrb_define_method(mrb, a, "value=",          #{type}Pointer_set_val,      MRB_ARGS_REQ(1));
+    mrb_define_method(mrb, a, "size",            #{type}Pointer_size,         MRB_ARGS_NONE());
+    mrb_define_method(mrb, a, "length",          #{type}Pointer_size,         MRB_ARGS_NONE());
+EOT
+
+    if t[2] == :Char then
+      file.print <<EOT
+	mrb_define_method(mrb, a, "to_s",            CharPointer_to_s, MRB_ARGS_NONE());
+	mrb_define_method(mrb, a, "from_s",          CharPointer_from_s, MRB_ARGS_REQ(1));
+EOT
+    end
+  end
+
+  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 )
+    tag = ct_name
+    structType = @@struct_list[ tag ]
+    file.print  <<EOT
+	struct RClass *a;                                /* MBP720 */
+
+	a = mrb_define_class_under(mrb, TECS, "Struct#{tag}", mrb->object_class);
+	MRB_SET_INSTANCE_TT(a, MRB_TT_DATA);
+
+	mrb_define_method(mrb, a, "initialize", Struct_#{tag}_initialize, MRB_ARGS_NONE());
+EOT
+
+      structType.get_members_decl.get_items.each{ |d|
+        file.print "  STRUCT_INIT_MEMBER( #{tag}, #{d.get_name} )\n"
+      }
+  end
+
+  #===  åãå£é¢æ°ã® preamble (Cè¨èª)ãçæãã
+  #     å¿
+è¦ãªã preamble é¨ã«åºåãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  def gen_preamble( file, b_singleton, ct_name, global_ct_name )
+    if @@celltypes[ ct_name ] then
+      gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )
+      gen_preamble_instance( file, b_singleton, ct_name, global_ct_name )
+      gen_preamble_instance_initialize( file, b_singleton, ct_name, global_ct_name )
+      gen_preamble_bridge_func( file, b_singleton, ct_name, global_ct_name )
+    elsif @@init_celltypes[ ct_name ] then
+      gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )
+      gen_preamble_instance_proto( file, b_singleton, ct_name, global_ct_name )
+    elsif @@ptr_list[ ct_name ] then
+      gen_preamble_ptr( file, b_singleton, ct_name, global_ct_name )
+    elsif @@struct_list[ ct_name ] then
+      gen_preamble_struct( file, b_singleton, ct_name, global_ct_name )
+    else
+      raise "MrubyBridgeSignaturePlugin: MrubyBridgeSignaturePlugin: Unknown #{ct_name}"
+    end
+  end
+
+  def gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )
+    file.print <<EOT
+/* MBP: MrubyBridgePlugin: MBP000 */
+#include "mruby.h"
+#include "mruby/class.h"
+#include "mruby/data.h"
+#include "mruby/string.h"
+#include "TECSPointer.h"
+#include "TECSStruct.h"
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#define DLLEXPORT __declspec(dllexport)
+#else
+#define DLLEXPORT
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+EOT
+  end
+
+  def gen_preamble_instance( file, b_singleton, ct_name, global_ct_name )
+    # ã#1005  MrubyBridgePlugin-test ã®ãã«ãã«å¤±æãã«ã¦è¿½å 
+    # ã#1004 idx_is_id ã true ã®å ´å(domain ã®å ´åã¯æªæå®ã§ã true) ã® CBP ã®ãã­ãã¿ã¤ãå®£è¨ãã«ã¦ä¸è¦ã«ãªãè¦è¾¼ã¿
+    nsp = NamespacePath.new( :nMruby, true )
+    nsp.append! ct_name
+    ct = Namespace.find nsp
+    if ct.idx_is_id_act? then
+      if ct.has_CB? then
+        inib_cb = "CB"
+      elsif ct.has_INIB? then
+        inib_cb = "INIB"
+      else
+        inib_cb = nil
+      end
+      if inib_cb then
+        ct.get_cell_list.each{ |cell|
+          if cell.is_generate? then
+            name_array = ct.get_name_array( cell )
+            file.print "extern #{ct.get_global_name}_CB  #{cell.get_global_name}_#{inib_cb};\n"
+          end
+        }
+      end
+    end
+
+    file.print <<EOT
+
+/* RData MBP001 */
+static void 
+#{@celltype_name}_free( mrb_state *mrb, void *p )
+{
+	if( p )
+		(void)mrb_free( mrb, p );
+}
+
+/* RData MBP002 */
+struct mrb_data_type data_type_#{@celltype_name} =
+{
+	"#{@celltype_name}",
+	#{@celltype_name}_free
+};
+
+/* RData MBP003 */
+struct tecs_#{@celltype_name} {
+    CELLCB  *cbp;
+};
+
+/* name_to_cbp MBP010 */
+const struct name_to_cbp_#{@celltype_name} {
+    char   *name;    /* Cell Name */
+    CELLCB *cbp;
+} Name_to_cbp_#{@celltype_name}[] = {
+EOT
+
+    nsp = NamespacePath.new( :nMruby, true )
+    nsp.append! ct_name
+    ct = Namespace.find nsp
+
+    ct.get_cell_list.each{ |cell|
+      if cell.is_generate? then
+        join_list = cell.get_join_list
+        join = join_list.get_item( :bridgeName )
+        if join == nil then
+          name = "\"#{cell.get_name}\""
+        else
+          rhs = join.get_rhs
+          attr_list = cell.get_celltype.get_attribute_list
+          name = rhs.eval_const join_list, attr_list
+        end
+
+        name_array = ct.get_name_array( cell )
+        file.print "\t{ #{name}, #{name_array[8]} },\n"
+      end
+    }
+
+    file.print <<EOT
+\t{ 0, 0 },
+};
+
+EOT
+
+  end
+
+  def gen_preamble_ptr( file, b_singleton, ct_name, global_ct_name )
+    tment = @@ptr_list[ ct_name ]
+    file.print <<EOT
+
+GET_SET_#{tment[3]}( #{tment[1]}, #{tment[0]} )
+POINTER_CLASS( #{tment[1]}, #{tment[0]} )
+EOT
+  end
+
+  def gen_preamble_struct( file, b_singleton, ct_name, global_ct_name )
+    tag = ct_name
+    structType = @@struct_list[ tag ]
+    file.print <<EOT
+/* struct #{tag} */
+STRUCT_CLASS( #{tag} )
+EOT
+
+    structType.get_members_decl.get_items.each{ |d|
+      type = d.get_type.get_original_type
+      case type
+      when IntType, CIntType
+        bit_size = type.get_bit_size
+        case bit_size
+        when -11, -1
+          tType = "Char"
+          ttype = "char"
+        when -2
+          tType = "Short"
+          ttype = "short"
+        when -3
+          tType = "Int"
+          ttype = "int"
+        when -4
+          tType = "Long"
+          ttype = "long"
+        when -5
+          tType = "IntPtr"
+          ttype = "intptr"
+        when 8, 16, 32, 64
+          tType = "Int#{bit_size}"
+          ttype = "int#{bit_size}"
+        else
+            raise "MrubyBridgeSignaturePlugin: MrubyBridgeSignaturePlugin: cannot handle bit_size #{bit_size}"
+        end
+        file.print "MEMBER_GET_SET_INT( #{tag}, #{d.get_name}, #{tType}, #{ttype} )\n"
+      when FloatType, CFloatType
+        file.print "MEMBER_GET_SET_FLOAT( #{tag}, #{d.get_name} )\n"
+      else
+        raise "MrubyBridgeSignaturePlugin: MrubyBridgeSignaturePlugin: cannot handle type"
+      end
+    }
+
+  end
+
+  def gen_preamble_instance_proto( file, b_singleton, ct_name, global_ct_name )
+    file.print <<EOT
+//  Prototype MBP400
+mrb_value  MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self);
+EOT
+
+    @func_head_array.each{ |f|
+      if ! f.is_function? then
+        next
+      end
+      if f.get_name != :initialize then
+        func_name = f.get_name
+      else
+        func_name = :initialize_cell
+      end
+
+      ret_type  = f.get_return_type
+      ret_type0 = f.get_return_type.get_original_type
+      b_void    = ret_type0.is_void?
+      plist     = f.get_paramlist.get_items
+
+      file.print <<EOT
+mrb_value  MrubyBridge_#{@celltype_name}_#{func_name}( mrb_state *mrb, mrb_value self );
+EOT
+    }
+  end
+
+  def gen_preamble_instance_initialize( file, b_singleton, ct_name, global_ct_name )
+    file.print <<EOT
+
+/* MBP100 */
+mrb_value
+MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self)
+{
+	mrb_value	name;
+	struct tecs_#{@celltype_name} *tecs_cb;
+	const struct name_to_cbp_#{@celltype_name} *ntc;
+
+	/* set DATA_TYPE earlier to avoid SEGV */
+	DATA_TYPE( self ) = &data_type_#{@celltype_name};
+
+	mrb_get_args(mrb, "o", &name );
+	if( mrb_type( name ) != MRB_TT_STRING ){
+		mrb_raise(mrb, E_NAME_ERROR, "cell name not string");
+	}
+	for( ntc = &Name_to_cbp_#{@celltype_name}[0]; ntc->name != NULL; ntc++ ){
+		if( strcmp( ntc->name, RSTRING_PTR( name ) ) == 0 )
+			break;
+	}
+	if( ntc->name == 0 ){
+		mrb_raise(mrb, E_ARGUMENT_ERROR, "cell not found");
+	}
+	tecs_cb = (struct tecs_#{@celltype_name} *)mrb_malloc(mrb, sizeof(struct tecs_#{@celltype_name}) );
+	tecs_cb->cbp = ntc->cbp;
+	DATA_PTR( self ) = (void *)tecs_cb;
+
+	return self;
+}
+EOT
+  end
+
+  def gen_preamble_bridge_func( file, b_singleton, ct_name, global_ct_name )
+
+    @func_head_array.each{ |f|
+      if ! f.is_function? then
+        next
+      end
+      if f.get_name != :initialize then
+        func_name = f.get_name
+      else
+        func_name = :initialize_cell
+      end
+
+      ret_type  = f.get_return_type
+      ret_type0 = f.get_return_type.get_original_type
+      b_void    = ret_type0.is_void?
+      plist     = f.get_paramlist.get_items
+
+      file.print <<EOT
+
+/* bridge function (MBP101) */
+mrb_value
+MrubyBridge_#{ct_name}_#{func_name}( mrb_state *mrb, mrb_value self )
+{
+	/* cellcbp (MBP105) */
+	CELLCB	*p_cellcb = ((struct tecs_#{@celltype_name} *)DATA_PTR(self))->cbp;
+EOT
+      
+      file.print "	/* variables for return & parameter (MBP110) */\n"
+      if ! b_void then
+        file.print "	", ret_type.get_type_str, "\tret_val", ret_type.get_type_str_post, ";\n"
+      end
+      arg_str = ""
+      n_param  = 0
+      n_scalar = 0
+      n_ptr    = 0
+      n_struct = 0
+      plist.each{ |param|
+        case param.get_direction
+        when :IN, :INOUT, :OUT
+          type = param.get_type.get_original_type
+          case type
+          when IntType
+            file.print "	mrb_int	mrb_", param.get_name, ";\n"
+            file.print "	#{param.get_type.get_type_str}	#{param.get_name}#{param.get_type.get_type_str_post};\n"
+            arg_str += "i"
+            n_param += 1
+            n_scalar += 1
+          when FloatType
+            file.print "	mrb_float	mrb_", param.get_name, ";\n"
+            file.print "	#{param.get_type.get_type_str}	#{param.get_name}#{param.get_type.get_type_str_post};\n"
+            arg_str += "f"
+            n_param += 1
+            n_scalar += 1
+          when BoolType
+            file.print "	mrb_value	mrb_", param.get_name, ";\n"
+            file.print "	#{param.get_type.get_type_str}	#{param.get_name}#{param.get_type.get_type_str_post};\n"
+            arg_str += "o"
+            n_param += 1
+            n_scalar += 1
+          when PtrType
+            file.print "	mrb_value	mrb_", param.get_name, ";\n"
+            file.print "	#{param.get_type.get_type_str}	#{param.get_name}#{param.get_type.get_type_str_post};\n"
+            arg_str += "o"
+            n_param += 1
+            n_ptr += 1
+          when StructType
+            file.print "	mrb_value	mrb_", param.get_name, ";\n"
+            file.print "	#{param.get_type.get_type_str}	*#{param.get_name}#{param.get_type.get_type_str_post};\n"
+            arg_str += "o"
+            n_param += 1
+            n_struct += 1
+          else
+            raise "MrubyBridgeSignaturePlugin: Unknown type"
+          end
+        end
+      }
+
+      if n_param > 0 then
+        file.print "	/* retrieve arguments (MBP111) */\n"
+        file.print "	mrb_get_args(mrb, \"#{arg_str}\""
+        plist.each{ |param|
+          case param.get_direction
+          when :IN, :INOUT, :OUT
+            type = param.get_type.get_original_type
+            case type
+            when IntType
+              file.print ", &mrb_", param.get_name
+            when FloatType
+              file.print ", &mrb_", param.get_name
+            when BoolType
+              file.print ", &mrb_", param.get_name
+            when PtrType
+              file.print ", &mrb_", param.get_name
+            when StructType
+              file.print ", &mrb_", param.get_name
+            else
+              raise "MrubyBridgeSignaturePlugin: Unknown type"
+            end
+          end
+        }
+        file.print " );\n"
+
+        if n_scalar > 0 || n_struct > 0 then
+          file.print "	/* convert mrb to C (MBP112) */\n"
+        end
+        plist.each{ |param|
+          case param.get_direction
+          when :IN, :INOUT, :OUT
+            type = param.get_type.get_original_type
+            case type
+            when IntType
+              ttype = type.get_original_type
+              tment = get_type_map_ent ttype
+              file.print "	VALCHECK_#{tment[1]}( mrb, mrb_#{param.get_name} );\n"
+              file.print "	#{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"
+            when FloatType
+              file.print "	#{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"
+            when BoolType
+              file.print "	#{param.get_name} = mrb_test( mrb_#{param.get_name} );\n"
+            when PtrType
+              ttype = type.get_type.get_original_type
+              case ttype
+              when StructType
+                file.print "	CHECK_STRUCT( #{ttype.get_name}, mrb_#{param.get_name} );\n"
+                file.print "	#{param.get_name} = (struct #{ttype.get_name}*)DATA_PTR(mrb_#{param.get_name});\n"
+              when IntType
+              when FloatType
+              when BoolType
+              else
+                raise "MrubyBridgeSignaturePlugin: cannot handle type"
+              end
+            when StructType
+              file.print "	CHECK_STRUCT( #{type.get_name}, mrb_#{param.get_name} );\n"
+              file.print "	#{param.get_name} = (struct #{type.get_name}*)DATA_PTR(mrb_#{param.get_name});\n"
+            else
+              raise( "MrubyBridgeSignaturePlugin: canot treat class" )
+            end
+          end
+        }
+
+        if n_ptr > 0 then
+          file.print "	/* convert mrb to C for pointer types (MBP113) */\n"
+        end
+        plist.each{ |param|
+          case param.get_direction
+          when :IN, :INOUT, :OUT
+            type = param.get_type.get_original_type
+            case type
+            when IntType
+            when FloatType
+            when BoolType
+            when PtrType
+              case type.get_type.get_original_type
+              when StructType
+              when IntType
+                ptrMrb2C file, type, param
+              when FloatType
+                ptrMrb2C file, type, param
+              when BoolType
+                ptrMrb2C file, type, param
+              else
+                raise "MrubyBridgeSignaturePlugin: cannot handle type"
+              end
+            when StructType
+            else
+              raise( "MrubyBridgeSignaturePlugin: canot treat class" )
+            end
+          end
+        }
+
+      end
+
+      file.print "	/* calling target (MBP120) */\n"
+      if ! b_void then
+        file.print "	ret_val = "
+      else
+        file.print "	"
+      end
+      delim = ""
+      file.print "cTECS_", f.get_name, "( "
+      plist.each{ |param|
+        if param.get_type.get_original_type.kind_of? StructType then
+          aster = "*"
+        else
+          aster = ""
+        end
+        file.print delim, aster, param.get_name
+        delim = ", "
+      }
+      file.print " );\n"
+      
+      file.print "	/* return (MBP130) */\n"
+      case ret_type0
+      when BoolType
+        file.print "	return ret_val ? mrb_true_value() : mrb_false_value();\n"
+      when IntType
+        file.print "	return mrb_fixnum_value( ret_val );\n"
+      when FloatType
+        file.print "	return mrb_float_value( mrb, ret_val );\n"
+      when VoidType
+        file.print "	return  mrb_nil_value();\n"
+      else
+        raise "MrubyBridgeSignaturePlugin: unknown type"
+      end
+
+      file.print "}\n"
+    }
+  end
+
+  def ptrMrb2C file, type, param
+    ttype = type.get_type.get_original_type
+    tment = get_type_map_ent ttype
+    tstr = tment[1]
+=begin
+    case ttype
+    when IntType
+      bit_size = ttype.get_bit_size
+      case bit_size
+      when -1, -11
+        tstr = "Char"
+      when 8, 16, 32, 64
+        tstr = "Int#{bit_size}"
+      when -2
+        tstr = "Short"
+      when -3
+        tstr = "Int"
+      when -4
+        tstr = "Long"
+      when -5
+        tstr = "IntPtr"
+      else
+        raise "MrubyBridgeSignaturePlugin: not handle type"
+      end
+    when FloatType
+      if ttype.get_bit_size == 32 then
+        tstr = "Float32"
+      else
+        tstr = "Double64"
+      end
+    when BoolType
+      tstr = "Bool"
+    when StructType
+      raise "MrubyBridgeSignaturePlugin: not handle type 2 #{ttype}"
+    else
+      raise "MrubyBridgeSignaturePlugin: not handle type 2 #{ttype}"
+    end
+=end
+    if( param.get_size ) then
+      sz_str = param.get_size.to_s
+    elsif param.get_string then      # mikan ã¨ãããã size_is ã¨ string ã®åææå® (äºéãã¤ã³ã¿) ã¯ãªã
+      sz_str = param.get_string.to_s
+    else
+      sz_str = "1"
+    end
+    # unsigned åã®å ´åã«ã¯ cast ãå¿
+è¦
+    if ttype.get_original_type.get_type_str != param.get_type.get_type.get_type_str then
+      cast_str = "(#{param.get_type.get_type_str})"
+    else
+      cast_str = ""
+    end
+
+    modify = ""
+    case param.get_direction
+    when :OUT, :INOUT
+      case tstr
+      when "Char", "SChar", "UChar"
+        modify = "Mod"
+      end
+    end
+    if param.is_nullable? then
+      nullable = "Nullable"
+    else
+      nullable = ""
+    end
+
+    # file.print "	CHECK_POINTER( #{tstr}, mrb_#{param.get_name}, #{sz_str} );\n"
+    # file.print "	#{param.get_name} = #{cast_str}((struct #{tstr}PointerBody*)(DATA_PTR(mrb_#{param.get_name})))->buf;\n"
+    file.print "	#{param.get_name} = CheckAndGet#{tstr}Pointer#{modify}#{nullable}( mrb, mrb_#{param.get_name}, #{sz_str} );\n"
+  end
+
+  def get_celltype_name
+    @celltype_name
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° ignoreUnsigned
+  def set_ignoreUnsigned rhs
+    if rhs == "true" || rhs == nil then
+      @b_ignoreUnsigned = true
+    end
+  end
+  #=== ãã©ã°ã¤ã³å¼æ° include
+  def set_include rhs
+    funcs = rhs.split ','
+    funcs.each{ |rhs_func|
+      found = false
+      rhs_func.gsub!( /\s/, "" )
+      @signature.get_function_head_array.each{ |a|
+        if rhs_func.to_sym == a.get_name then
+          found = true
+        end
+      }
+      if found == false then
+        cdl_error( "MRB1009 include function '$1' not found in signagture '$2'", rhs, @signature.get_name )
+      else
+        @includes << rhs_func.to_sym
+      end
+    }
+  end
+  #=== ãã©ã°ã¤ã³å¼æ° exclude
+  def set_exclude rhs
+    funcs = rhs.split ','
+    funcs.each{ |rhs_func|
+      rhs_func.gsub!( /\s/, "" )
+      func_head = @signature.get_function_head rhs_func.to_sym
+      if func_head == false then
+        cdl_error( "MRB1010 exclude function '$1' not found in signagture '$2", rhs, @signature.get_name )
+      else
+        @excludes << rhs_func.to_sym
+      end
+    }
+  end
+  #=== ãã©ã°ã¤ã³å¼æ° auto_exclude
+  def set_auto_exclude rhs
+    if rhs == "false" then
+      @b_auto_exclude = false
+    elsif rhs == "true" then
+      @b_auto_exclude = true     # auto_exclude = true by default 
+    else
+      cdl_warning( "MRB9999 auto_exclude: unknown rhs value ignored. specify true or false" )
+    end
+  end
+end
+
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MultiPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MultiPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MultiPlugin.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2008-2014 by TOPPERS Project
+#   Copyright (C) 2008-2017 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/NotifierPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/NotifierPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/NotifierPlugin.rb	(revision 374)
@@ -1,3 +1,6 @@
 # -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
 #
 #  Copyright (C) 2015 by Ushio Laboratory
@@ -5,5 +8,38 @@
 #  Copyright (C) 2015-2016 by Embedded and Real-Time Systems Laboratory
 #              Graduate School of Information Science, Nagoya Univ., JAPAN
+#  Copyright (C) 2015-2018 by TOPPERS Project
 #
+#--
+#   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
+#   ア（本ソフトウェアを改変したものを含む．以下同じ）を使用・複製・改
+#   変・再配布（以下，利用と呼ぶ）することを無償で許諾する．
+#   (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
+#       権表示，この利用条件および下記の無保証規定が，そのままの形でソー
+#       スコード中に含まれていること．
+#   (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
+#       用できる形で再配布する場合には，再配布に伴うドキュメント（利用
+#       者マニュアルなど）に，上記の著作権表示，この利用条件および下記
+#       の無保証規定を掲載すること．
+#   (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
+#       用できない形で再配布する場合には，次のいずれかの条件を満たすこ
+#       と．
+#     (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
+#         作権表示，この利用条件および下記の無保証規定を掲載すること．
+#     (b) 再配布の形態を，別に定める方法によって，TOPPERSプロジェクトに
+#         報告すること．
+#   (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
+#       害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
+#       また，本ソフトウェアのユーザまたはエンドユーザからのいかなる理
+#       由に基づく請求からも，上記著作権者およびTOPPERSプロジェクトを
+#       免責すること．
+#  
+#   本ソフトウェアは，無保証で提供されているものである．上記著作権者お
+#   よびTOPPERSプロジェクトは，本ソフトウェアに関して，特定の使用目的
+#   に対する適合性も含めて，いかなる保証も行わない．また，本ソフトウェ
+#   アの利用により直接的または間接的に生じたいかなる損害に関しても，そ
+#   の責任を負わない．
+#  
+#  $Id$
+#++
 
 NotifierPluginArgProc = {
@@ -128,6 +164,7 @@
 			# @param [Cell, Symbol] cell セル．セルについて一般化する場合は `:generic`
 			# @param [Integer, Symbol, nil] subscript 添字．添字について一般化する場合は `:generic`
+			# @param [Celltype] 呼び先のセルタイプ、cell==:generic の場合のみ有効
 			# @private
-			def generate_inner(context, fn_name, cell, subscript)
+			def generate_inner(context, fn_name, cell, subscript, callee_ct=nil)
 				source_file = context.source_file
 				header_file = context.header_file
@@ -141,5 +178,6 @@
 				unless ct.is_singleton?
 					if cell == :generic
-						params << "(CELLIDX)extinf"
+						params << "(#{callee_ct.get_global_name}_IDX)extinf"
+						# params << "(CELLIDX)extinf"
 					else
 						# セルのCELLIDXを得る
@@ -233,5 +271,5 @@
 
 						generate_inner context, fn_name,
-							:generic, subscript
+							:generic, subscript, ct
 
 						props.each { |prop|
@@ -445,5 +483,5 @@
 	    # join:: Join : 結合 (declarationがPortであるもの)
 		def validate_join(handler, cell, join)
-        	return !generate_attr_map(handler, cell).nil?
+        return !generate_attr_map(handler, cell).nil?
 		end
 
@@ -872,9 +910,9 @@
     	parse_plugin_arg
     	unless @factory
-    		cdl_error("ASP1003 celltype $1: option factory is not specified",
+    		cdl_error("NTF1003 celltype $1: option factory is not specified",
     			celltype.get_name)
     	end
     	unless @output_file
-    		cdl_error("ASP1003 celltype $1: option output_file is not specified",
+    		cdl_error("NTF1003 celltype $1: option output_file is not specified",
     			celltype.get_name)
     	end
@@ -883,5 +921,5 @@
     def set_factory(template_string)
     	unless @factory.nil?
-    		cdl_error("ASP1003 celltype $1: option factory was specified more than once",
+    		cdl_error("NTF1003 celltype $1: option factory was specified more than once",
     			celltype.get_name)
     	end
@@ -891,5 +929,5 @@
     def set_factory_output_file(output_file)
     	unless @output_file.nil?
-    		cdl_error("ASP1003 celltype $1: option output_file was specified more than once",
+    		cdl_error("NTF1003 celltype $1: option output_file was specified more than once",
     			celltype.get_name)
     	end
@@ -898,5 +936,5 @@
 
     def gen_factory file
-        puts "===== begin #{@celltype.get_name.to_s} plugin ====="
+        # puts "===== begin #{@celltype.get_name.to_s} plugin ====="
 
         kernelCfg = AppFile.open( "#{$gen}/#{@output_file}" )
@@ -922,5 +960,5 @@
 			subst_attr = @celltype.find(name)
 			unless subst_attr
-	    		cdl_error( "ASP1007 celltype $1: additional_param: attribute $2 does not exist.",
+	    		cdl_error( "NTF1007 celltype $1: additional_param: attribute $2 does not exist.",
 	    			@celltype.get_name, name)
 			end
@@ -935,8 +973,9 @@
 
         kernelCfg.close
-        puts "===== end #{@celltype.get_name.to_s} plugin ====="
+        # puts "===== end #{@celltype.get_name.to_s} plugin ====="
     end
 
     def gen_factory_for_cell(kernelCfg, cell)
+      # print "########## gen_factory_for_cell cell=#{cell.get_name}\n"
     	handler_flags = []
     	handler_args = []
@@ -959,12 +998,28 @@
 			when 'false' then ignoreErrors = false
 			else
-				cdl_warning( "ASP1005 cell $1: unrecognized value '$2' specified for ignoreErrors",
+				cdl_warning2( cell.get_locale, "NTF1005 cell $1: unrecognized value '$2' specified for ignoreErrors",
 					cell.get_name, ignoreErrors )
 				ignoreErrors = false
 		end
 
+    # ドメイン指定用文字列
+    pre_text  = ""
+    post_text = "\n"
+    indent    = ""
+ 
     	[EVENT_HANDLER, ERROR_HANDLER].each { |handler|
     		# 呼び口の結合を取得
     		call_join = cell.get_join_list.get_item(handler.call_port_name.to_sym)
+        domain_root = cell.get_region.get_domain_root
+        if cell.get_region.get_domain_root.get_domain_type then
+          # 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"
+        else
+          # print "cell=#{cell.get_name} domain_root=#{cell.get_region.get_domain_root.get_name}\n"
+        end
+        if call_join
+          # print "validate_join: hanlder=#{handler.class.name} cell=#{cell.get_name} join=#{call_join.get_name} rhs_cell=#{call_join.get_cell}\n"
+        else
+          # print "validate_join: hanlder=#{handler.class.name} cell=#{cell.get_name}\n"
+        end
 
 	    	# ハンドラタイプを判別する
@@ -974,10 +1029,59 @@
 
 	    	if matches.length == 0
-	    		cdl_error( "ASP1001 cell $1: no matching handler type found for $2", cell.get_name, handler.call_port_name )
+	    		cdl_error2( cell.get_locale, "NTF1001 cell $1: no matching handler type found for $2", cell.get_name, handler.call_port_name )
 	    		next
-	    	end
+        end
 
 			# 最初に見つかった有効なハンドラタイプを使用
 	    	ht = matches[0]
+
+      # ドメインプラグインが指定されている場合、所属ドメインのチェック
+      domain_root = cell.get_region.get_domain_root
+      if domain_root.get_domain_type then
+        if domain_root.get_domain_type.get_name == :HRP then
+          option = domain_root.get_domain_type.get_option
+          matches.each{ |match|
+            # p "match:#{match}"
+            case match
+            when ActivateTaskHandlerType,       WakeUpTaskHandlerType,
+                 SetVariableHandlerType,        SetVariableToErrorCodeHandlerType,
+ 		             IncrementVariableHandlerType,  SignalSemaphoreHandlerType, 
+		             SetEventflagHandlerType,       SendToDataqueueHandlerType,
+		             SendErrorCodeToDataqueueHandlerType
+              if option == "OutOfDomain" then
+                cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 cannot be placed out of domain", cell.get_name )
+              elsif call_join.get_cell.get_region.get_domain_root == nil ||
+                    call_join.get_cell.get_region.get_domain_root != domain_root then
+                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 )
+              end
+              dbgPrint "#{self.class.name}: match pattern 1.\n"
+            when UserHandlerType
+              if option != "kernel" then
+                cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 can be placed in kernel domain only, because notify target is handler", cell.get_name )
+              elsif call_join.get_cell.get_region.get_domain_root == nil ||
+                    call_join.get_cell.get_region.get_domain_root != domain_root then
+                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 )
+              end
+              dbgPrint "#{self.class.name}: match pattern 2.\n"
+		        when NullHandlerType.new  # エラー通知を指定していない
+              dbgPrint "#{self.class.name}: match pattern 3.\n"
+            end
+          }
+
+          # if cell.get_region.get_param == :KERNEL_DOMAIN
+          if option == "kernel"
+            pre_text  = "KERNEL_DOMAIN{\n"
+            post_text = "}\n"
+            indent    =  "\t"
+          elsif option != "OutOfDomain" then
+            pre_text  = "DOMAIN(#{domain_root.get_name.to_s}){\n"
+            post_text = "}\n"
+            indent    =  "\t"
+          end
+        else
+          cdl_error( "NTF9999: NotifierPlugin: unknown domain type $1", domain_root.get_domain_type.get_name )
+        end
+
+      end
 
 			# 通知ハンドラで「エラーが発生するはずがない」のに「エラーハンドラが指定されている」
@@ -986,9 +1090,9 @@
 			#  なため、検出は行わない。)
     		if handler == ERROR_HANDLER && !ht.is_a?(NullHandlerType) && !event_handler_might_fail
-	    		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.",
+	    		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.",
 	    			cell.get_name, handler_flag)
     		end
     		if handler == ERROR_HANDLER && ht.is_a?(NullHandlerType) && event_handler_might_fail && !ignoreErrors
-	    		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.",
+	    		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.",
 	    			cell.get_name, handler_flag)
     		end
@@ -1057,11 +1161,33 @@
 			# $id$等の置換
 			cell.get_celltype.subst_name(subst, name_array)
-    	}
-
-    	# 出力
-    	kernelCfg.puts text
-
-    end
-    private :gen_factory_for_cell
+      }
+
+     # 出力 (CRE_xxx)
+     kernelCfg.print pre_text
+     kernelCfg.print indent, text, "\n"
+     gen_sac kernelCfg, cell, indent
+     kernelCfg.print post_text
+   end
+
+   def gen_sac file, cell, indent
+     domain_root = cell.get_region.get_domain_root
+     if domain_root.get_domain_type then
+       id = (cell.get_attr_initializer :id).to_s
+                 name_array = cell.get_celltype.get_name_array(cell)
+       case cell.get_celltype.get_name
+       when :tCyclicNotifier
+         obj_type = "CYC"
+       when :tAlarmNotifier
+         obj_type = "ALM"
+       else
+         raise "NotifierPlugin: unknown celltype #{cell.get_celltype.get_name}"
+       end
+       id = cell.get_celltype.subst_name(id, name_array)
+       # p obj_type
+       # p HRPPlugin.get_sac_str cell
+       file.print indent, "SAC_#{obj_type}( #{id}, #{HRPPlugin.get_sac_str cell} );\n"
+     end
+   end
+   private :gen_factory_for_cell
 
 end
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/OpaqueRPCPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/OpaqueRPCPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/OpaqueRPCPlugin.rb	(revision 374)
@@ -56,5 +56,5 @@
   #=== RPCPlugin の initialize
   #  説明は ThroughPlugin (plugin.rb) を参照
-  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
     super
     @b_noClientSemaphore = false
@@ -254,4 +254,9 @@
     nest = @end_region.gen_region_str_pre file
     nest_str = "  " * nest
+    if @next_cell_port_subscript then
+      subscript = '[' + @next_cell_port_subscript.to_s + ']'
+    else
+      subscript = ""
+    end
 
     if @serverErrorHandler then
@@ -282,5 +287,5 @@
 #{nest_str}  cell #{@rpc_server_channel_celltype_name} #{@serverChannelCell}_Unmarshaler {
 #{nest_str}    cChannel = #{@serverChannelCell}.eC1;
-#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
 #{serverErrorHandler_str}#{nest_str}  };
 EOT
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/RPCPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/RPCPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/RPCPlugin.rb	(revision 374)
@@ -65,5 +65,5 @@
   #=== RPCPlugin の initialize
   #  説明は ThroughPlugin (plugin.rb) を参照
-  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
     super
     @b_noClientSemaphore = false
@@ -197,4 +197,9 @@
     nest = @region.gen_region_str_pre file
     indent_str = "  " * nest
+    if @next_cell_port_subscript then
+      subscript = '[' + @next_cell_port_subscript.to_s + ']'
+    else
+      subscript = ""
+    end
 
     file.print <<EOT
@@ -233,5 +238,5 @@
     file.print <<EOT
 #{indent_str}cell #{@rpc_channel_celltype_name} #{@cell_name} {
-#{indent_str}  #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name};
+#{indent_str}  #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript};
 #{indent_str}  cTDR         = #{@channelCellName}.eTDR;
 #{indent_str}  cEventflag   = #{@channelCellName}.eEventflag;
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/RepeatCellPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/RepeatCellPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/RepeatCellPlugin.rb	(revision 374)
@@ -0,0 +1,185 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#
+#  Copyright (C) 2015-2018 by TOPPERS Project
+#
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#  $Id$
+#++
+
+#== cell ã count åç¹°ãè¿ãã»ã«ãã©ã°ã¤ã³
+# ä¸å®å
+¨ç¹ï¼
+#    æå®å­ã«å¯¾å¿ãã¦ããªã
+#       cell ã®æå®å­ (allocator, id)
+#       çµåã®æå®å­ (through)
+class RepeatCellPlugin < CellPlugin
+
+  @@plugin_list = []
+  RepeatCellPluginArgProc = {
+    "count" => Proc.new { |obj,rhs| obj.set_count rhs }
+  }
+
+  def initialize( cell, option )
+    super
+    @@plugin_list << self
+    print "RepeatCellPlugin: #{@cell.get_name}\n"
+    # cell.show_tree 0
+    # @cell.get_join_list.get_items.each{ |j|
+    #  print "Join: #{j.get_name} = #{j.get_rhs.to_s}\n"
+    # }
+    @count = 0
+    @plugin_arg_check_proc_tab = RepeatCellPluginArgProc
+    parse_plugin_arg
+  end
+
+  def gen_cdl_file( file )
+    if $verbose then
+      print "#{self.class}: repeat #{@cell.get_name} #(num} times\n"
+    end
+
+    nest = @cell.get_region.gen_region_str_pre file
+    indent_str = "  " * nest
+    @cell.get_name.to_s =~ /.*[^0-9]([0-9]+)\z/
+    if $1 then
+      tail_zero = $1
+      bname = @cell.get_name.to_s.gsub( /[0-9]+\z/, "" )
+    else
+      cdl_error( "#{self.class}: #{@cell.get_name}'s name ends without '0-9'")
+      return
+    end
+    base_count = tail_zero.to_i
+
+    count = 1
+    num = @count
+    file.print "/*  #{num} times repeat of '#{@cell.get_name}' */\n"
+    while count < num
+
+      # ã»ã«åã®ã«ã¦ã³ã
+      count_str = (count + base_count).to_s
+      if tail_zero.length > count_str.length then
+        leading_zero = "0" * ( tail_zero.length - count_str.length )
+      else
+        leading_zero = ""
+      end
+      cname = bname + leading_zero + count_str
+
+      #   "cell tCelltype Cell {" 
+      file.print "#{indent_str}cell #{@cell.get_celltype.get_name} #{cname}{\n"
+
+      # Join ã® CDL æå­åçæ
+      @cell.get_join_list.get_items.each{ |j|
+
+        # Join ã®å³è¾ºã®è§£æ
+        res = j.get_rhs.analyze_cell_join_expression
+        if res then
+          nsp, subscript, port_name = res[0], res[1], res[2]
+        else
+          nsp = j.get_rhs.analyze_single_identifier
+          if nsp then
+            subscript, port_name = nil, nil
+          else
+            file.print "#{indent_str}  #{j.get_name} = #{j.get_rhs.to_s};\n"
+            next
+          end
+        end
+
+        # å³è¾ºã®ã»ã«å (æ«å°¾ã®æ°å­ãã«ã¦ã³ãã¢ãã)
+        nsp.get_name.to_s =~ /(.*[^0-9])([0-9]+)\z/
+        if $2 then
+          rhs_tail_num = $2
+          rhs_name_count = count + rhs_tail_num.to_i
+          if rhs_tail_num.length > rhs_name_count.to_s.length then
+            leading_zero = "0" * ( rhs_tail_num.length - rhs_name_count.to_s.length )
+          else
+            leading_zero = ""
+          end
+          rhs_cname = $1 + leading_zero + rhs_name_count.to_s
+          nsp = nsp.change_name_clone rhs_cname
+        end
+
+        # Join æå­åã®åºå
+        if port_name then
+          # å³è¾ºã¯ ã»ã«ã®çµå
+          if subscript then
+            file.print "#{indent_str}  #{j.get_name} = #{nsp.get_path_str}.#{port_name}[#{(count+subscript).to_s}];\n"
+          else
+            file.print "#{indent_str}  #{j.get_name} = #{nsp.get_path_str}.#{port_name};\n"
+          end
+        else
+          # å³è¾ºã¯åä¸ã®è­å¥å­
+          file.print "#{indent_str}  #{j.get_name} = #{nsp.get_path_str};\n"
+        end
+      }
+
+      file.print "#{indent_str}};\n\n"
+      count += 1
+    end
+
+    @cell.get_region.gen_region_str_post file
+  end
+
+  #=== count ãªãã·ã§ã³ã®è§£æ
+  def set_count rhs
+    if rhs =~ /\A\d+\z/
+      @count = rhs.to_i
+    else
+      nsp = NamespacePath.new( rhs.to_sym, true )
+      expr = Expression.create_single_identifier( nsp, nil )
+      res = expr.eval_const( nil )
+      if res == nil then
+        cdl_error( "count value ($1): not single identifier or integer number", rhs.to_s )
+        @count = 0
+      else
+        @count = res
+      end
+    end
+  end
+
+end
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/RepeatJoinPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/RepeatJoinPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/RepeatJoinPlugin.rb	(revision 374)
@@ -0,0 +1,147 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#
+#  Copyright (C) 2015-2018 by TOPPERS Project
+#
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#  $Id$
+#++
+
+class RepeatJoinPlugin < CellPlugin
+
+  RepeatJoinPluginArgProc = {
+    "count" => Proc.new { |obj,rhs| obj.set_count rhs }
+  }
+
+  def initialize( cell, option )
+    super
+    print "RepeatJoinPlugin: #{@cell.get_name}\n"
+    # cell.show_tree 0
+    @plugin_arg_check_proc_tab = RepeatJoinPluginArgProc
+    parse_plugin_arg
+
+    @cell.get_join_list.get_items.each{ |j|
+      # print "Join: #{j.get_name} = #{j.get_rhs.to_s}\n"
+
+      # Join ã®å³è¾ºãè§£æ
+      ret = j.get_rhs.analyze_cell_join_expression
+      if ret == nil then
+        next
+      end
+      rhs_nsp = ret[0]; rhs_subscript = ret[1]; rhs_port_name = ret[2]
+
+      # å¼ã³å£é
+åã§ãæ·»æ°ã 0 ã®å ´åã«ã®ã¿ã«ã¦ã³ãã¢ããããã
+      if j.get_subscript == 0 then
+        rhs_name = rhs_nsp.get_name.to_s
+        if rhs_name =~ /(.*[^0-9])([0-9]+)\z/ then
+          b_rhs_name_count = true
+          rhs_name = $1
+          n_digits = $2.length
+          rhs_count_base = $2.to_i
+        else
+          b_rhs_name_count = false
+          rhs_count_base = 0
+        end
+
+        if rhs_subscript && rhs_subscript == 0 then
+          b_rhs_subscript_count = true
+        else
+          b_rhs_subscript_count = false
+        end
+
+        count = 1
+        while count < @count
+          count_str = (count+rhs_count_base).to_s
+
+          if b_rhs_subscript_count then
+            rhs_subscript = count
+          end
+
+          if b_rhs_name_count then
+            if n_digits - count_str.length > 0 then
+              leading_zero = "0" * ( n_digits - count_str.length )
+            else
+              leading_zero = ""
+            end
+
+            rhs_name_real = rhs_name + leading_zero + count_str
+          else
+            rhs_name_real = rhs_name
+          end
+          rhs_nsp2 = rhs_nsp.change_name_clone rhs_name_real.to_sym
+
+          rhs = Expression.create_cell_join_expression( rhs_nsp2, rhs_subscript, rhs_port_name )
+          j2 = Join.new( j.get_name, count, rhs )
+          cell.new_join j2
+
+          count += 1
+        end
+      end
+    }
+  end
+
+  #=== count ãªãã·ã§ã³ã®è§£æ
+  def set_count rhs
+    if rhs =~ /\A\d+\z/
+      @count = rhs.to_i
+    else
+      nsp = NamespacePath.new( rhs.to_sym, true )
+      expr = Expression.create_single_identifier( nsp, nil )
+      res = expr.eval_const( nil )
+      if res == nil then
+        cdl_error( "count value ($1): not single identifier or integer number", rhs.to_s )
+        @count = 0
+      else
+        @count = res
+      end
+    end
+  end
+
+end
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedOpaqueRPCPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedOpaqueRPCPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedOpaqueRPCPlugin.rb	(revision 374)
@@ -68,5 +68,5 @@
   #=== RPCPlugin の initialize
   #  説明は ThroughPlugin (plugin.rb) を参照
-  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
     super
     initialize_opaque_marshaler
@@ -221,4 +221,10 @@
     nest = @start_region.gen_region_str_pre file
     indent_str = "  " * nest
+    nest_str = "  " * nest
+    if @next_cell_port_subscript then
+      subscript = '[' + @next_cell_port_subscript.to_s + ']'
+    else
+      subscript = ""
+    end
 
     # セルを探す
@@ -303,5 +309,5 @@
 #{indent_str}cell #{@unmarshaler_celltype_name} #{@cell_name}_Server {
 #{indent_str}  cTDR         = #{@shared_channel_cell}_Server.eTDR;
-#{indent_str}  cServerCall  = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{indent_str}  cServerCall  = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
 #{ppallocator_join}#{indent_str}};
 EOT
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedRPCPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedRPCPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedRPCPlugin.rb	(revision 374)
@@ -62,5 +62,5 @@
   #=== RPCPlugin の initialize
   #  説明は ThroughPlugin (plugin.rb) を参照
-  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
 
     # mikan プラグインオプション指定の不一致のチェック task_priority, 
@@ -236,4 +236,9 @@
     nest = @region.gen_region_str_pre file
     indent_str = "  " * nest
+    if @next_cell_port_subscript then
+      subscript = '[' + @next_cell_port_subscript.to_s + ']'
+    else
+      subscript = ""
+    end
 
     # セルを探す
@@ -291,5 +296,5 @@
     file.print <<EOT
 #{indent_str}cell #{@rpc_channel_celltype_name} #{@cell_name} {
-#{indent_str}  #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name};
+#{indent_str}  #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript};
 #{indent_str}  cTDR         = #{@shared_channel_cell}.eTDR;
 #{indent_str}  cEventflag   = #{@shared_channel_cell}.eEventflag;
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/TECSInfoPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/TECSInfoPlugin.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/TECSInfoPlugin.rb	(revision 374)
@@ -0,0 +1,299 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+# 
+#   Copyright (C) 2017-2018 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id$
+#++
+
+#== CelltypePlugin for tTECSInfo
+class TECSInfoPlugin < CelltypePlugin
+
+  @@cell_list = []
+  #@celltype::Celltype
+  #@plugin_arg_str::String
+  #@plugin_arg_list::{argNameString=>argOptionString}
+  #@cell_list::[Cell]
+
+  #celltype::     Celltype        ã»ã«ã¿ã¤ãï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( celltype, option )
+    super
+    if $unopt_entry == false then
+      cdl_info( "TIF0001 forcely set --unoptimize-entry by TECSInfoPlugin (by importing TECSInfo.cdl)" )
+      $unopt_entry = true
+    end
+  end
+
+  #=== æ°ããã»ã«
+  #cell::        Cell            ã»ã«
+  #
+  # celltype ãã©ã°ã¤ã³ãæå®ãããã»ã«ã¿ã¤ãã®ã»ã«ãçæããã
+  # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ã«å¯¾ããæ°ããã»ã«ã®å ±å
+  def new_cell( cell )
+    @@cell_list << cell
+
+    # AppFile ã¯ãéã­æ¸ããããªã®ã§ãããã
+    # p "import: cell nTECSInfo::tTECSInfoSub #{cell.get_namespace_path.to_s} under #{cell.get_region.get_name}"
+    # cell.show_tree 0
+    # TECSInfoSub ã»ã«ã®ãã­ãã¿ã¤ãå®£è¨
+    fn = "#{$gen}/tmp_#{cell.get_region.get_global_name}_TECSInfoSub.cdl"
+    File.open( fn, "w" ){ |f|
+      f.print "/* prototype declaration of TECSInfoSub */\n"
+      nest = cell.get_region.gen_region_str_pre f
+      indent = "    " * nest
+      f.print <<EOT
+#{indent}[in_through()]
+#{indent}region rTECSInfo {
+#{indent}    cell nTECSInfo::tTECSInfoSub TECSInfoSub;
+#{indent}}; /* rTECSInfo} */
+EOT
+      cell.get_region.gen_region_str_post f
+    }
+    Import.new fn
+
+    # ã»ã«ã« cTECSInfo ã®çµåããããï¼
+    if cell.get_join_list.get_item( :cTECSInfo ) == nil then
+      # cTECSInfo = rTECSInfo::TECSInfosub.eTECSInfo; ã®è¿½å 
+      nsp = NamespacePath.new( :rTECSInfo, false )
+      nsp.append! :TECSInfoSub
+      rhs = Expression.create_cell_join_expression nsp, nil, :eTECSInfo
+      join = Join.new :cTECSInfo, nil, rhs
+      cell.new_join join
+    end
+  end
+
+  #=== tCelltype_factory.h ã«æ¿å
+¥ããã³ã¼ããçæãã
+  # file ä»¥å¤ã®ä»ã®ãã¡ã¤ã«ã«ãã¡ã¯ããªã³ã¼ããçæãã¦ããã
+  # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ãæå®ãããã»ã«ã¿ã¤ãã®ã¿å¼ã³åºããã
+  def gen_factory file
+    File.open( "#{$gen}/include_all_signature_header.h", "w" ){ |f|
+      f.print <<EOT
+#ifndef include_all_signature_header_h
+#define include_all_signature_header_h
+
+EOT
+      Namespace.get_root.travers_all_signature{ |sig|
+        f.print "#include \"#{sig.get_global_name}_tecsgen.h\"\n"
+      }
+      f.print <<EOT
+
+#endif /* include_all_signature_header_h */
+EOT
+    }
+
+    undefs2 = [ :INITIALIZE_CB, :FOREACH_CELL, :END_FOREACH_CELL ]
+    f = AppFile.open( "#{$gen}/nTECSInfo_tVarDeclInfo_factory.h" )
+    Namespace.get_root.print_struct_define f
+
+    undefs = [ :VALID_IDX, :GET_CELLCB, :CELLCB, :CELLIDX,
+               :tVarDeclInfo_IDX, :ATTR_name, :ATTR_sizeIsExpr,
+               :ATTR_declType, :ATTR_offset ]
+
+    f.print <<EOT
+
+/***** Offset of attr & var of celltype  *****/
+#define TOPPERS_CB_TYPE_ONLY
+
+/* In case a celltype has 'inline' entry,
+ * some macros are temporally defined
+ * even if TOPPERS_CB_TYPE_ONLY is defined.
+ * To avoid redefinition warning, undef these macros.
+ */
+#{ str=""; undefs.each{|u| str += "#undef #{u}\n" }; str }
+EOT
+    if $ram_initializer then
+      undefs2.each{|u|
+        f.print "#undef #{u}\n"
+      }
+    end
+    Namespace.get_root.print_celltype_define_offset f
+    f.print <<EOT
+
+/* redefine macros */
+#define tVarDeclInfo_IDX  nTECSInfo_tVarDeclInfo_IDX
+
+EOT
+    if $ram_initializer then
+      f.print <<EOT
+#define FOREACH_CELL(i,p_cb)   { (void)(i);
+#define END_FOREACH_CELL   }
+#define INITIALIZE_CB(p_that)   (void)(p_that);
+#define SET_CB_INIB_POINTER(i,p_that)
+EOT
+    end
+    f.close
+
+    undefs = [ :N_CP_cEntryInfo, :NCP_cEntryInfo, :N_CP_cCallInfo, :NCP_cCallInfo,
+               :N_CP_cAttrInfo, :NCP_cAttrInfo, :N_CP_cVarInfo, :NCP_cVarInfo,
+               :VALID_IDX, :GET_CELLCB, :CELLCB, :CELLIDX, :ATTR_name, :ATTR_b_singleton,
+               :ATTR_b_IDX_is_ID_act, :ATTR_sizeOfCB, :ATTR_sizeOfINIB, :ATTR_n_cellInLinUnit,
+               :ATTR_n_cellInSystem, :cEntryInfo_getName, :cEntryInfo_getNameLength,
+               :cEntryInfo_getSignatureInfo, :cEntryInfo_getArraySize, :cEntryInfo_isInline,
+               :cCallInfo_getName, :cCallInfo_getNameLength, :cCallInfo_getSignatureInfo,
+               :cCallInfo_getArraySize, :cCallInfo_getSpecifierInfo, :cCallInfo_getInternalInfo,
+               :cCallInfo_getLocationInfo, :cCallInfo_getOptimizeInfo, :cAttrInfo_getName,
+               :cAttrInfo_getOffset, :cAttrInfo_getTypeInfo, :cAttrInfo_getSizeIsExpr,
+               :cAttrInfo_getSizeIs, :cVarInfo_getName, :cVarInfo_getOffset, :cVarInfo_getTypeInfo,
+               :cVarInfo_getSizeIsExpr, :cVarInfo_getSizeIs, :cEntryInfo_refer_to_descriptor,
+               :cEntryInfo_ref_desc, :cCallInfo_refer_to_descriptor, :cCallInfo_ref_desc,
+               :cAttrInfo_refer_to_descriptor, :cAttrInfo_ref_desc, :cVarInfo_refer_to_descriptor,
+               :cVarInfo_ref_desc, :is_cEntryInfo_joined, :is_cCallInfo_joined,
+               :is_cAttrInfo_joined, :is_cVarInfo_joined, :eCelltypeInfo_getName,
+               :eCelltypeInfo_getNameLength, :eCelltypeInfo_getNAttr, :eCelltypeInfo_getAttrInfo,
+               :eCelltypeInfo_getNVar, :eCelltypeInfo_getVarInfo, :eCelltypeInfo_getNCall,
+               :eCelltypeInfo_getCallInfo, :eCelltypeInfo_getNEntry, :eCelltypeInfo_getEntryInfo,
+               :eCelltypeInfo_isSingleton, :eCelltypeInfo_isIDX_is_ID, :eCelltypeInfo_hasCB,
+               :eCelltypeInfo_hasINIB, :FOREACH_CELL, :END_FOREACH_CELL ]
+
+    f = AppFile.open( "#{$gen}/nTECSInfo_tCelltypeInfo_factory.h" )
+    undefs.each{ |u|
+      f.print "#undef #{u}\n"
+    }
+    f.print "#define TOPPERS_CB_TYPE_ONLY\n"
+    Namespace.get_root.print_celltype_define f
+    # FOREACH_CELL ãåºããªãã
+    ct = Namespace.find [ "::", :nTECSInfo, :tCelltypeInfo ]
+    ct.gen_ph_foreach_cell f
+    ct.gen_ph_cb_initialize_macro f
+    f.print "\n"
+    f.close
+   
+    undefs = [ :VALID_IDX, :GET_CELLCB, :CELLCB, :CELLIDX,
+               :tCallInfo_IDX, :ATTR_name, :ATTR_offset, :ATTR_b_inCB,
+               :ATTR_b_optional, :ATTR_b_omit, :ATTR_b_dynamic,
+               :ATTR_b_ref_desc, :ATTR_b_allocator_port,
+               :ATTR_b_require_port, :ATTR_b_VMT_useless,
+               :ATTR_b_skelton_useless, :ATTR_b_cell_unique,
+               :cSignatureInfo_getName, :cSignatureInfo_getNameLength,
+               :cSignatureInfo_getNFunction,
+               :cSignatureInfo_getFunctionInfo,
+               :cSignatureInfo_refer_to_descriptor,
+               :cSignatureInfo_ref_desc, :eCallInfo_getName,
+               :eCallInfo_getNameLength, :eCallInfo_getSignatureInfo,
+               :eCallInfo_getArraySize, :eCallInfo_isOptional,
+               :eCallInfo_isDynamic, :eCallInfo_isRefDesc,
+               :eCallInfo_isOmit ]
+
+    f = AppFile.open( "#{$gen}/nTECSInfo_tCallInfo_factory.h" )
+    f.print <<EOT
+
+/***** Offset of attr & var of celltype  *****/
+#define TOPPERS_CB_TYPE_ONLY
+
+/* In case a celltype has 'inline' entry,
+ * some macros are temporally defined
+ * even if TOPPERS_CB_TYPE_ONLY is defined.
+ * To avoid redefinition warning, undef these macros.
+ */
+#{ str=""; undefs.each{|u| str += "#undef #{u}\n" }; str }
+EOT
+    if $ram_initializer then
+      undefs2.each{|u|
+        f.print "#undef #{u}\n"
+      }
+    end
+
+    Namespace.get_root.print_call_define f
+    f.print <<EOT
+
+/* redefine macros */
+#define tCallInfo_IDX  nTECSInfo_tCallInfo_IDX
+
+EOT
+    if $ram_initializer then
+      f.print <<EOT
+#define FOREACH_CELL(i,p_cb)   { (void)(i);
+#define END_FOREACH_CELL   }
+#define INITIALIZE_CB(p_that)   (void)(p_that);
+#define SET_CB_INIB_POINTER(i,p_that)
+
+EOT
+    end
+    f.close
+
+    f = AppFile.open( "#{$gen}/nTECSInfo_tEntryInfo_factory.h" )
+    Namespace.get_root.print_entry_define f
+    f.close
+
+    undefs = [ :GET_CELLCB, :CELLCB, :CELLIDX, :ATTR_name, :INITIALIZE_CB, :FOREACH_CELL ]
+    f = AppFile.open( "#{$gen}/nTECSInfo_tCellInfo_factory.h" )
+    undefs.each{ |u|
+      f.print "#undef #{u}\n"
+    }
+    Region.get_root.print_cell_define f
+    # FOREACH_CELL ãåºããªãã
+    ct = Namespace.find [ "::", :nTECSInfo, :tCellInfo ]
+    ct.gen_ph_foreach_cell f
+    ct.gen_ph_cb_initialize_macro f
+    f.close
+
+    f = AppFile.open( "#{$gen}/nTECSInfo_tRawEntryDescriptorInfo_factory.h" )
+    Region.get_root.print_entry_descriptor_define f
+    f.close
+  end
+
+  #=== å¾ãã® CDL ã³ã¼ããçæ
+  #ãã©ã°ã¤ã³ã®å¾ãã® CDL ã³ã¼ããçæ
+  #file:: File:
+  def self.gen_post_code( file )
+    if Generator.get_n_error > 0 then
+      Generator.info( "I9999 TECSInfoPlugin does not generate TECSInfo code because of early error" )
+      return
+    end
+    # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ãããããä»¥ä¸ã®ãããªè¦åºããã¤ãããã¨
+    file.print <<EOT
+/*------------ #{self.name} post code ------------*/
+EOT
+    @@cell_list.each{|cell|
+      root = cell.get_region # .get_link_root
+      TECSInfo.print_info file, root
+    }
+  end
+end
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ThroughPlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ThroughPlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/ThroughPlugin.rb	(revision 374)
@@ -47,4 +47,5 @@
 #@next_cell:: Cell                    呼び口を結合するセル
 #@next_cell_port_name:: Symbol       呼び口を結合する受口の名前
+#@next_cell_port_subscript::Nil|Integer   呼び口を結合する受口の配列添数．受け口配列でない場合 nil
 #@signature::      Signature          シグニチャ
 #@celltype::       Celltype           呼び先のセルのセルタイプ. through が連接する場合、最終的な呼び先のセルのセルタイプ
@@ -74,8 +75,9 @@
   #next_cell::      Cell               呼び口を接続するセル
   #next_cell_port_name:: Symbol        呼び口を接続する受口の名前
+  #next_cell_port_subscript:: Nil|Integer  呼び口を接続する受口配列添数
   #signature::      Signature          シグニチャ
   #celltype::       Celltype           セルタイプ (呼び先のセルのセルタイプ)
   #caller_cell::    Cell               呼び元のセル．@caller_cell の項を参照
-  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
     super()
     @cell_name = cell_name                      # 生成すべきセル名（受け口側のセル名）
@@ -83,4 +85,5 @@
     @next_cell = next_cell                      # 呼び先のセル
     @next_cell_port_name = next_cell_port_name
+    @next_cell_port_subscript = next_cell_port_subscript
     @signature = signature
     @entry_port_name = :"eThroughEntry"
@@ -136,4 +139,9 @@
   def get_through_entry_port_name
     @entry_port_name
+  end
+
+  #===  生成されたセルの受け口配列添数を得る
+  def get_through_entry_port_subscript
+    @entry_port_subscript
   end
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/TracePlugin.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/TracePlugin.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/TracePlugin.rb	(revision 374)
@@ -44,5 +44,5 @@
   #=== TracePlugin の initialize
   #  説明は ThroughPlugin (plugin.rb) を参照
-  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
 
     @maxArrayDisplay = 16
@@ -141,4 +141,9 @@
       nest = @region.gen_region_str_pre file
       indent_str =  "  " * nest
+      if @next_cell_port_subscript then
+        subscript = '[' + @next_cell_port_subscript.to_s + ']'
+      else
+        subscript = ""
+      end
 
       if @probeName then
@@ -155,5 +160,5 @@
       file.print <<EOT
 #{indent_str}cell #{@ct_name} #{@cell_name} {
-#{indent_str}  #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{indent_str}  #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
 #{probeName_str}#{caller_cell_str}#{indent_str}};
 EOT
@@ -210,8 +215,13 @@
     }
     file.print( " );\n" )
+    if @next_cell_port_subscript then
+      subscript = '[' + @next_cell_port_subscript.to_s + ']'
+    else
+      subscript = ""
+    end
 
     file.print <<EOT
 \tgetMicroTime( &utime );
-\tsyslog( LOG_INFO, \"Leave: %sTime=%d: #{@next_cell.get_name}.#{@next_cell_port_name}.#{func_name}\", ATTR_probeName_str, utime );
+\tsyslog( LOG_INFO, \"Leave: %sTime=%d: #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript}.#{func_name}\", ATTR_probeName_str, utime );
 EOT
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenHRP2Marshaler.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenHRP2Marshaler.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenHRP2Marshaler.rb	(revision 374)
@@ -35,4 +35,5 @@
 #   の責任を負わない．
 #  
+#   $Id$
 #++
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb	(revision 374)
@@ -4,5 +4,5 @@
 #      Generator for TOPPERS Embedded Component System
 #  
-#   Copyright (C) 2008-2014 by TOPPERS Project
+#   Copyright (C) 2008-2018 by TOPPERS Project
 #--
 #   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -464,6 +464,8 @@
 	/* Channel Lock */
 	SET_RPC_STATE( state_, RPCSTATE_CLIENT_GET_SEM );
-	if( is_cLockChannel_joined() )
-		cLockChannel_wait();
+	if( is_cLockChannel_joined() ){
+		if( (ercd_=cLockChannel_wait()) != E_OK )
+			goto error_reset;
+	}
 EOT
 
@@ -554,6 +556,14 @@
 	/* Channel Unlock */
 	SET_RPC_STATE( state_, RPCSTATE_CLIENT_RELEASE_SEM );
-	if( is_cLockChannel_joined() )
-		cLockChannel_signal();
+	if( is_cLockChannel_joined() ){
+		if( (ercd_=cLockChannel_signal()) != E_OK )
+			goto error_reset;
+	}
+EOT
+
+    file.print <<EOT
+	/* state_ is not used in normal case */
+  /* below is to avoid 'set but not used' warnning */
+	(void)state_;
 EOT
 
@@ -630,5 +640,5 @@
         file.print <<EOT
 	}else{
-		return;
+		return E_ID;
 	}
 EOT
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb	(revision 352)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb	(revision 374)
@@ -388,5 +388,5 @@
     };
 #{ppallocator_dealloc_str}
-    return;
+    return E_OK;
 
 error_reset:
@@ -394,4 +394,5 @@
         (void)cTDR_reset();
 #{ppallocator_dealloc_str}
+    return E_OK;
 EOT
 
Index: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/MrubyBridgeCelltypePluginModule.rb
===================================================================
--- asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/MrubyBridgeCelltypePluginModule.rb	(revision 374)
+++ asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/MrubyBridgeCelltypePluginModule.rb	(revision 374)
@@ -0,0 +1,301 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2011 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id$
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+module MrubyBridgeCelltypePluginModule
+
+  # ãã©ã°ã¤ã³å¼æ°å => Proc
+  MrubyBridgePluginArgProc = { 
+      "ignoreUnsigned" => Proc.new { |obj,rhs| obj.set_ignoreUnsigned rhs },
+      "include_inner_cell" => Proc.new { |obj,rhs| obj.set_include_inner_cell rhs },
+      "exclude_cell" => Proc.new { |obj,rhs| obj.set_exclude_cell rhs },
+      "exclude_port" => Proc.new { |obj,rhs| obj.set_exclude_port rhs },
+      "exclude_port_func" => Proc.new { |obj,rhs| obj.set_exclude_port_func rhs },
+      "auto_exclude" => Proc.new { |obj,rhs| obj.set_auto_exclude rhs },
+  }
+
+  require_tecsgen_lib( "MrubyBridgeCellPlugin.rb" )
+  @@plugin_list = []
+  @@count = 1
+
+  #celltype::     Celltype        ã»ã«ã¿ã¤ãï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( celltype, option )
+    dbgPrint "#{self.class.name}: initialzie: #{celltype.get_name}\n"
+
+    super
+    @celltype = celltype
+    @cell_list = []
+    @include_inner_cell = false
+    @exclude_cells = []
+    @exclude_port = []
+    @exclude_port_func = {}
+    @b_ignoreUnsigned = false
+    @b_auto_exclude = true     # auto_exclude = true by default 
+    @@plugin_list << self
+
+    @plugin_arg_check_proc_tab = MrubyBridgePluginArgProc
+    @plugin_arg_str = CDLString.remove_dquote option
+    parse_plugin_arg
+
+    MrubyBridgeCellPlugin.set_gen_post_code_by_dependent
+  end
+
+  #=== æ°ããã»ã«
+  #cell::        Cell            ã»ã«
+  #
+  # celltype ãã©ã°ã¤ã³ãæå®ãããã»ã«ã¿ã¤ãã®ã»ã«ãçæããã
+  # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ã«å¯¾ããæ°ããã»ã«ã®å ±å
+  # generate æã«ããå¼ã³åºãããå ´åãããã¾ã§ã«å®ç¾©ããã cell ã«ã¤ãã¦ã¯ãinitialize ã®ã¿ã¤ãã³ã°ã§å¼ã³åºããã
+  def new_cell( cell )
+    dbgPrint "MrubyBridgeCelltypePluginModule: new_cell: #{cell.get_name}\n"
+
+    return if @cell_list.include? cell   # ãã®è¡ã¯ãæ¬æ¥ä¸è¦ã®ã¯ã
+    if TECSGEN.post_coded?               # post_code ä»¥éã®ã»ã«ã¯å¯¾è±¡ããå¤ã
+      cdl_info( "I9999 MrubyBridgeCelltypePlugin: $1 is excluded because cell generated after post_coded", cell.get_name )
+      return
+    end
+
+    # include_inner_cell option
+    if cell.is_cloned? && @include_inner_cell == false then
+    #   p "#{cell.get_name} excluded"
+      cdl_info( "I9999 MrubyBridgeCelltypePlugin: inner cell $1 is excluded", cell.get_name )
+      return
+    # else
+    #   p "#{cell.get_name} included"
+    end
+
+    # exclude_cell option
+    if @exclude_cells.include?( cell.get_name ) then
+      return
+    end
+
+    opt_str = "ignoreUnsigned=#{@b_ignoreUnsigned}, auto_exclude=#{@b_auto_exclude}"
+    @exclude_port.each{ |port|
+      opt_str += ",exclude_port=#{port}"
+    }
+    @exclude_port_func.each{ |port, funcs|
+      funcs.each{ |func|
+        opt_str += ",exclude_port_func=#{port}.#{func}"
+      }
+    }
+
+    # p "MrubyBridgeCelltypePlugin: opt_str=#{opt_str}"
+
+    fn2 = "#{$gen}/tmp_MrubyBridgeCelltypePluginModule_#{@celltype.get_name}_#{@@count}.cdl"
+    f2 = File.open( fn2, "w" )
+    f2.print <<EOT
+/* MrubyBridgeCelltypePluginModule: celltype=#{@celltype.get_name} */
+generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "#{opt_str}" );
+EOT
+    f2.close
+    dbgPrint "MrubyBridgeCelltypePluginModule new_cell: Import #{fn2}\n"
+    Import.new "#{fn2}"
+    @@count += 1
+  end
+
+### æå³è§£ææ®µéã§å¼ã³åºãããã¡ã½ãã ###
+  #===  CDL ãã¡ã¤ã«ã®çæ
+  #      typedef, signature, celltype, cell ã®ã³ã¼ããçæ
+  #      éè¤ãã¦çæãã¦ã¯ãªããªã
+  #      ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
+  #      ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
+  #file::        FILE       çæãããã¡ã¤ã«
+  def gen_cdl_file file
+#   ãã®æ®µéã§å¼ã³ã ãã¨ generate æãå¼ã³åºãããåã®ã»ã«ã®ã¿ã®åºåã¨ãªã
+    
+#    dbgPrint "MrubyBridgeCelltypePlugin: gen_cdl_file: #{@celltype.get_name}\n"
+#    file.print <<EOT
+#/* MrubyBridgeCelltypePlugin: celltype=#{@celltype.get_name}
+# *
+# *    cell's generate before celltype's generate
+# */
+#
+#EOT
+#    @celltype.get_cell_list.each { |cell|
+#      @cell_list << cell
+#      # mikan option, region
+#      dbgPrint "MrubyBridgeCelltypePlugin: cell=#{cell.get_name}\n"
+#      file.print <<EOT
+#generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "" );
+#EOT
+#    }
+
+  end
+
+  #=== tCelltype_factory.h ã«æ¿å
+¥ããã³ã¼ããçæãã
+  # file ä»¥å¤ã®ä»ã®ãã¡ã¤ã«ã«ãã¡ã¯ããªã³ã¼ããçæãã¦ããã
+  # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ãæå®ãããã»ã«ã¿ã¤ãã®ã¿å¼ã³åºããã
+  def gen_factory file
+  end
+
+  def get_celltype
+    @celltype
+  end
+
+  @@b_gen_post_code_called = false
+  #=== å¾ãã® CDL ã³ã¼ããçæ
+  #ãã©ã°ã¤ã³ã®å¾ãã® CDL ã³ã¼ããçæ
+  #file:: File: 
+  def self.gen_post_code( file )
+    dbgPrint "#{self.name}: gen_post_code_body\n"
+
+    if @@b_gen_post_code_called == false then
+      @@b_gen_post_code_called = true
+      MrubyBridgeCellPlugin.gen_post_code_body file
+    end
+
+#    ãã®æ®µéã§çæããã¨ãåããã¹ãã³ã¼ãã§åºåããã mruby ã®åæåã³ã¼ãã«åæ ãããªã
+    
+#    # MrubyBridgeCelltypePlugin ã®çæãã generate æã¯ã
+#    fn2 = "#{$gen}/tmp_MrubyBridgeCelltypePlugin_post.cdl"
+#    f2 = File.open( fn2, "w" )
+#    # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ãããããä»¥ä¸ã®ãããªè¦åºããã¤ãããã¨
+#    dbgPrint "MrubyBridgeCelltypePlugin: gen_post_code\n"
+#    f2.print "/* '#{self.name}' post code */\n"
+#    @@plugin_list.each{ |plugin|
+#      plugin.get_celltype.get_cell_list.each{ |cell|
+#        # mikan option, region
+#        f2.print <<EOT
+#generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "" );
+#EOT
+#      }
+#    }
+#    f2.close
+#    p Import
+#    Import.new "#{fn2}"
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° 
+
+  #=== ãã©ã°ã¤ã³å¼æ° ignoreUnsigned
+  def set_ignoreUnsigned rhs
+    if rhs == "true" || rhs == nil then
+      @b_ignoreUnsigned = true
+    end
+  end
+
+  def set_include_inner_cell rhs
+    if rhs == "true" || rhs == nil then
+      @include_inner_cell = true
+    end
+  end
+
+  def set_exclude_cell rhs
+    cells = rhs.split ','
+    cells.each{ |rhs_cell|
+      rhs_cell.gsub!( /\s/, "" )
+      @exclude_cells << rhs_cell.to_sym
+    }
+  end
+  def set_exclude_port rhs
+    ports = rhs.split ','
+    ct = @cell.get_celltype
+    return if ct == nil    # error case
+    ports.each{ |rhs_port|
+      obj = ct.find( rhs_port.to_sym )
+      if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
+        cdl_error( "MRB9999 exclude_port '$1' not found or not entry in celltype '$2'", rhs_port, ct.get_name )
+      else
+        # print "MRBBridgeCellPlugin: exclude #{rhs_port}\n"
+        @exclude_port << rhs_port
+      end
+    }
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° exclude_port_func
+  def set_exclude_port_func rhs
+    port_funcs = rhs.split ','
+    ct = @celltype
+    return if ct == nil    # error case
+    port_funcs.each{ |rhs_port_func|
+      port_func = rhs_port_func.split( '.' )
+      if port_func.length != 2 then
+        cdl_error( "MRB9999 exclude_port_func: '$1' not in 'port.func' form", rhs_port_func )
+      end
+      obj = ct.find( port_func[0].to_sym )
+      if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
+        cdl_error( "MRB9999 exclude_port_func: port '$1' not found in celltype '$2'", rhs_port_func, ct.get_name )
+      else
+        signature = obj.get_signature
+        next if signature == nil     # error case
+        if signature.get_function_head port_func[1].to_sym
+          # print "MRBBridgeCellPlugin: #{port_func[0]}.#{port_func[1]} exclude\n"
+          if @exclude_port_func[ port_func[0] ] then
+            @exclude_port_func[ port_func[0] ] <<  port_func[1]
+          else
+            @exclude_port_func[ port_func[0] ] = [ port_func[1] ]
+          end
+        else
+          cdl_error( "MRB9999 include_port_func: func '$1' not found in port '$2' celltype $3",
+                     port_func[1], port_func[0], ct.get_name )
+        end
+      end
+    }
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° auto_exclude
+  def set_auto_exclude rhs
+    # print "MrubyBridgeCellPlugin: auto_exclude=#{rhs}\n"
+    if rhs == "false" then
+      @b_auto_exclude = false
+    elsif rhs == "true" then
+      @b_auto_exclude = true     # auto_exclude = true by default 
+    else
+      cdl_warning( "MRB9999 auto_exclude: unknown rhs value ignored. specify true or false" )
+    end
+  end
+end
+
