source: asp3_tinet_ecnl_arm/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgeCelltypePlugin.rb@ 374

Last change on this file since 374 was 374, checked in by coas-nagasima, 5 years ago

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

  • Property charset set to UTF-8
  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-ruby
File size: 11.3 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# TECS Generator
4# Generator for TOPPERS Embedded Component System
5#
6# Copyright (C) 2008-2017 by TOPPERS Project
7#--
8# 上記著作権者
9は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
10# ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
11# 変・再é…
12å¸ƒï¼ˆä»¥ä¸‹ï¼Œåˆ©ç”¨ã¨å‘¼ã¶ï¼‰ã™ã‚‹ã“とを無償で許諾する.
13# (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
14# 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
15# スコード中に含まれていること.
16# (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
17# 用できる形で再é…
18å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œå†é…
19å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨
20# 者
21マニュアルなど)に,上記の著作権表示,この利用条件および下記
22# の無保証規定を掲載すること.
23# (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
24# 用できない形で再é…
25å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œæ¬¡ã®ã„ずれかの条件を満たすこ
26# と.
27# (a) 再é…
28å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨è€…
29マニュアルなど)に,上記の著
30# 作権表示,この利用条件および下記の無保証規定を掲載すること.
31# (b) 再é…
32å¸ƒã®å½¢æ…
33‹ã‚’,別に定める方法によって,TOPPERSプロジェクトに
34# 報告すること.
35# (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
36# 害からも,上記著作権者
37およびTOPPERSプロジェクトをå…
38è²¬ã™ã‚‹ã“と.
39# また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
40# 由に基づく請求からも,上記著作権者
41およびTOPPERSプロジェクトを
42# å…
43è²¬ã™ã‚‹ã“と.
44#
45# 本ソフトウェアは,無保証で提供されているものである.上記著作権者
46お
47# よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
48# に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
49# アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
50# の責任を負わない.
51#
52# $Id$
53#++
54
55require_tecsgen_lib 'tecslib/plugin/lib/MrubyBridgeCelltypePluginModule.rb'
56
57#== MrubyBridgeCompositePlugin
58class MrubyBridgeCelltypePlugin < CompositePlugin
59 dbgPrint "MrubyBridgeCelltypePlugin loaded\n"
60 include MrubyBridgeCelltypePluginModule
61
62 def self.gen_post_code( file )
63 MrubyBridgeCelltypePluginModule.gen_post_code file
64 end
65end
66
67
68#
69##== celltype プラグインのå…
70±é€šã®è¦ªã‚¯ãƒ©ã‚¹
71#class MrubyBridgeCelltypePlugin < CelltypePlugin
72#
73# # プラグイン引数名 => Proc
74# MrubyBridgePluginArgProc = {
75# "ignoreUnsigned" => Proc.new { |obj,rhs| obj.set_ignoreUnsigned rhs },
76# "include_inner_cell" => Proc.new { |obj,rhs| obj.set_include_inner_cell rhs },
77# "exclude_cell" => Proc.new { |obj,rhs| obj.set_exclude_cell rhs },
78# "exclude_port" => Proc.new { |obj,rhs| obj.set_exclude_port rhs },
79# "exclude_port_func" => Proc.new { |obj,rhs| obj.set_exclude_port_func rhs },
80# "auto_exclude" => Proc.new { |obj,rhs| obj.set_auto_exclude rhs },
81# }
82#
83# require_tecsgen_lib( "MrubyBridgeCellPlugin.rb" )
84# @@plugin_list = []
85# @@count = 1
86#
87# #celltype:: Celltype セルタイプ(インスタンス)
88# def initialize( celltype, option )
89# dbgPrint "#{self.class.name}: initialzie: #{celltype.get_name}\n"
90#
91# super
92# @celltype = celltype
93# @cell_list = []
94# @include_inner_cell = false
95# @exclude_cells = []
96# @exclude_port = []
97# @exclude_port_func = {}
98# @b_ignoreUnsigned = false
99# @b_auto_exclude = true # auto_exclude = true by default
100# @@plugin_list << self
101#
102# @plugin_arg_check_proc_tab = MrubyBridgePluginArgProc
103# @plugin_arg_str = CDLString.remove_dquote option
104# parse_plugin_arg
105#
106# MrubyBridgeCellPlugin.set_gen_post_code_by_dependent
107# end
108#
109# #=== 新しいセル
110# #cell:: Cell セル
111# #
112# # celltype プラグインを指定されたセルタイプのセルが生成された
113# # セルタイププラグインに対する新しいセルの報告
114# # generate 文により呼び出された場合、それまでに定義された cell については、initialize のタイミングで呼び出される
115# def new_cell( cell )
116# dbgPrint "MrubyBridgeCelltypePlugin: new_cell: #{cell.get_name}\n"
117#
118# return if @cell_list.include? cell # この行は、本来不要のはず
119# if TECSGEN.post_coded? # post_code 以降のセルは対象から外す
120# cdl_info( "I9999 MrubyBridgeCelltypePlugin: $1 is excluded because cell generated after post_coded", cell.get_name )
121# return
122# end
123#
124# # include_inner_cell option
125# if cell.is_cloned? && @include_inner_cell == false then
126# # p "#{cell.get_name} excluded"
127# cdl_info( "I9999 MrubyBridgeCelltypePlugin: inner cell $1 is excluded", cell.get_name )
128# return
129# # else
130# # p "#{cell.get_name} included"
131# end
132#
133# # exclude_cell option
134# if @exclude_cells.include?( cell.get_name ) then
135# return
136# end
137#
138# opt_str = "ignoreUnsigned=#{@b_ignoreUnsigned}, auto_exclude=#{@b_auto_exclude}"
139# @exclude_port.each{ |port|
140# opt_str += ",exclude_port=#{port}"
141# }
142# @exclude_port_func.each{ |port, funcs|
143# funcs.each{ |func|
144# opt_str += ",exclude_port_func=#{port}.#{func}"
145# }
146# }
147#
148# # p "MrubyBridgeCelltypePlugin: opt_str=#{opt_str}"
149#
150# # mikan option, region
151# fn2 = "#{$gen}/tmp_MrubyBridgeCelltypePlugin_#{@celltype.get_name}_#{@@count}.cdl"
152# f2 = File.open( fn2, "w" )
153# f2.print <<EOT
154#/* MrubyBridgeCelltypePlugin: celltype=#{@celltype.get_name} */
155#generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "#{opt_str}" );
156#EOT
157# f2.close
158# Import.new "#{fn2}"
159# @@count += 1
160# end
161#
162#### 意味解析段階で呼び出されるメソッド ###
163# #=== CDL ファイルの生成
164# # typedef, signature, celltype, cell のコードを生成
165# # 重複して生成してはならない
166# # すでに生成されている場合は出力しないこと。
167# # もしくは同名の import により、重複を避けること。
168# #file:: FILE 生成するファイル
169# def gen_cdl_file file
170## この段階で呼びだすと generate 文が呼び出される前のセルのみの出力となる
171#
172## dbgPrint "MrubyBridgeCelltypePlugin: gen_cdl_file: #{@celltype.get_name}\n"
173## file.print <<EOT
174##/* MrubyBridgeCelltypePlugin: celltype=#{@celltype.get_name}
175## *
176## * cell's generate before celltype's generate
177## */
178##
179##EOT
180## @celltype.get_cell_list.each { |cell|
181## @cell_list << cell
182## # mikan option, region
183## dbgPrint "MrubyBridgeCelltypePlugin: cell=#{cell.get_name}\n"
184## file.print <<EOT
185##generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "" );
186##EOT
187## }
188#
189# end
190#
191# #=== tCelltype_factory.h に挿å…
192¥ã™ã‚‹ã‚³ãƒ¼ãƒ‰ã‚’生成する
193# # file 以外の他のファイルにファクトリコードを生成してもよい
194# # セルタイププラグインが指定されたセルタイプのみ呼び出される
195# def gen_factory file
196# end
197#
198# def get_celltype
199# @celltype
200# end
201#
202# #=== 後ろの CDL コードを生成
203# #プラグインの後ろの CDL コードを生成
204# #file:: File:
205# def self.gen_post_code( file )
206# dbgPrint "#{self.name}: gen_post_code_body\n"
207# print "#{self.name}: gen_post_code_body\n"
208## この段階で生成すると、同じポストコードで出力される mruby の初期化コードに反映されない
209#
210## # MrubyBridgeCelltypePlugin の生成する generate 文は、
211## fn2 = "#{$gen}/tmp_MrubyBridgeCelltypePlugin_post.cdl"
212## f2 = File.open( fn2, "w" )
213## # 複数のプラグインの post_code が一つのファイルに含まれるため、以下のような見出しをつけること
214## dbgPrint "MrubyBridgeCelltypePlugin: gen_post_code\n"
215## f2.print "/* '#{self.name}' post code */\n"
216## @@plugin_list.each{ |plugin|
217## plugin.get_celltype.get_cell_list.each{ |cell|
218## # mikan option, region
219## f2.print <<EOT
220##generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "" );
221##EOT
222## }
223## }
224## f2.close
225## p Import
226## Import.new "#{fn2}"
227#
228# MrubyBridgeCellPlugin.gen_post_code_body file
229# end
230#
231# #=== プラグイン引数
232#
233# #=== プラグイン引数 ignoreUnsigned
234# def set_ignoreUnsigned rhs
235# if rhs == "true" || rhs == nil then
236# @b_ignoreUnsigned = true
237# end
238# end
239#
240# def set_include_inner_cell rhs
241# if rhs == "true" || rhs == nil then
242# @include_inner_cell = true
243# end
244# end
245#
246# def set_exclude_cell rhs
247# cells = rhs.split ','
248# cells.each{ |rhs_cell|
249# rhs_cell.gsub!( /\s/, "" )
250# @exclude_cells << rhs_cell.to_sym
251# }
252# end
253# def set_exclude_port rhs
254# ports = rhs.split ','
255# ct = @cell.get_celltype
256# return if ct == nil # error case
257# ports.each{ |rhs_port|
258# obj = ct.find( rhs_port.to_sym )
259# if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
260# cdl_error( "MRB9999 exclude_port '$1' not found or not entry in celltype '$2'", rhs_port, ct.get_name )
261# else
262# # print "MRBBridgeCellPlugin: exclude #{rhs_port}\n"
263# @exclude_port << rhs_port
264# end
265# }
266# end
267#
268# #=== プラグイン引数 exclude_port_func
269# def set_exclude_port_func rhs
270# port_funcs = rhs.split ','
271# ct = @celltype
272# return if ct == nil # error case
273# port_funcs.each{ |rhs_port_func|
274# port_func = rhs_port_func.split( '.' )
275# if port_func.length != 2 then
276# cdl_error( "MRB9999 exclude_port_func: '$1' not in 'port.func' form", rhs_port_func )
277# end
278# obj = ct.find( port_func[0].to_sym )
279# if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
280# cdl_error( "MRB9999 exclude_port_func: port '$1' not found in celltype '$2'", rhs_port_func, ct.get_name )
281# else
282# signature = obj.get_signature
283# next if signature == nil # error case
284# if signature.get_function_head port_func[1].to_sym
285# # print "MRBBridgeCellPlugin: #{port_func[0]}.#{port_func[1]} exclude\n"
286# if @exclude_port_func[ port_func[0] ] then
287# @exclude_port_func[ port_func[0] ] << port_func[1]
288# else
289# @exclude_port_func[ port_func[0] ] = [ port_func[1] ]
290# end
291# else
292# cdl_error( "MRB9999 include_port_func: func '$1' not found in port '$2' celltype $3",
293# port_func[1], port_func[0], ct.get_name )
294# end
295# end
296# }
297# end
298#
299# #=== プラグイン引数 auto_exclude
300# def set_auto_exclude rhs
301# # print "MrubyBridgeCellPlugin: auto_exclude=#{rhs}\n"
302# if rhs == "false" then
303# @b_auto_exclude = false
304# elsif rhs == "true" then
305# @b_auto_exclude = true # auto_exclude = true by default
306# else
307# cdl_warning( "MRB9999 auto_exclude: unknown rhs value ignored. specify true or false" )
308# end
309# end
310#end
311#
Note: See TracBrowser for help on using the repository browser.