tecscde 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +125 -0
- data/.rubocop_todo.yml +188 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +6 -0
- data/LICENSE +46 -0
- data/LICENSE.ja +32 -0
- data/README.ja.md +200 -0
- data/README.md +35 -0
- data/Rakefile +27 -0
- data/bin/tecscde +64 -0
- data/glade/tecscde-cell-property.glade +205 -0
- data/glade/tecscde-celltype-property.glade +172 -0
- data/glade/tecscde-celltype.glade +414 -0
- data/glade/tecscde-export.glade +161 -0
- data/glade/test-cell-plugin.rb +51 -0
- data/glade/test-cell-property.rb +35 -0
- data/glade/test-export.rb +35 -0
- data/glade/test-palette.rb +26 -0
- data/lib/tcflow.rb +148 -0
- data/lib/tecscde.rb +65 -0
- data/lib/tecscde/NewCell.png +0 -0
- data/lib/tecscde/SelectArrow.png +0 -0
- data/lib/tecscde/attr_tree_view.rb +253 -0
- data/lib/tecscde/cell_plugin_dialog.glade +294 -0
- data/lib/tecscde/cell_plugin_dialog.rb +89 -0
- data/lib/tecscde/celltype_tree_view.rb +105 -0
- data/lib/tecscde/change_set_control.rb +35 -0
- data/lib/tecscde/change_set_control/change_set.rb +32 -0
- data/lib/tecscde/change_set_control/change_set_manager.rb +62 -0
- data/lib/tecscde/command.rb +35 -0
- data/lib/tecscde/control.rb +491 -0
- data/lib/tecscde/highlighted_objects.rb +180 -0
- data/lib/tecscde/logger.rb +74 -0
- data/lib/tecscde/main_view_and_model.rb +80 -0
- data/lib/tecscde/palette.glade +553 -0
- data/lib/tecscde/palette.rb +174 -0
- data/lib/tecscde/preferences.glade +117 -0
- data/lib/tecscde/preferences.rb +44 -0
- data/lib/tecscde/tecs_model.rb +1137 -0
- data/lib/tecscde/tecs_model/hbar.rb +68 -0
- data/lib/tecscde/tecs_model/tm_c_port.rb +122 -0
- data/lib/tecscde/tecs_model/tm_c_port_array.rb +98 -0
- data/lib/tecscde/tecs_model/tm_cell.rb +496 -0
- data/lib/tecscde/tecs_model/tm_e_port.rb +126 -0
- data/lib/tecscde/tecs_model/tm_e_port_array.rb +78 -0
- data/lib/tecscde/tecs_model/tm_join.rb +293 -0
- data/lib/tecscde/tecs_model/tm_join_bar.rb +146 -0
- data/lib/tecscde/tecs_model/tm_port.rb +238 -0
- data/lib/tecscde/tecs_model/tm_port_array.rb +246 -0
- data/lib/tecscde/tecs_model/tm_region.rb +107 -0
- data/lib/tecscde/tecs_model/tm_uneditable.rb +68 -0
- data/lib/tecscde/tecs_model/vbar.rb +68 -0
- data/lib/tecscde/templates/_cell_info.cde.erb +15 -0
- data/lib/tecscde/templates/_join_info.cde.erb +28 -0
- data/lib/tecscde/templates/main.cde.erb +49 -0
- data/lib/tecscde/tm_object.rb +91 -0
- data/lib/tecscde/version.rb +4 -0
- data/lib/tecscde/view.rb +58 -0
- data/lib/tecscde/view/cairo_matrix.rb +90 -0
- data/lib/tecscde/view/canvas.rb +59 -0
- data/lib/tecscde/view/constants.rb +114 -0
- data/lib/tecscde/view/main_view.rb +1245 -0
- data/lib/tecsflow.rb +475 -0
- data/lib/tecsflow/C_parser.tab.rb +2471 -0
- data/lib/tecsflow/C_parser.y.rb +1087 -0
- data/lib/tecsflow/classes.rb +421 -0
- data/lib/tecsgen.rb +581 -0
- data/lib/tecsgen/core/C_parser.tab.rb +2477 -0
- data/lib/tecsgen/core/C_parser.y +1032 -0
- data/lib/tecsgen/core/bnf-deb.tab.rb +5193 -0
- data/lib/tecsgen/core/bnf.tab.rb +5193 -0
- data/lib/tecsgen/core/bnf.y +2211 -0
- data/lib/tecsgen/core/componentobj.rb +7901 -0
- data/lib/tecsgen/core/ctypes.rb +226 -0
- data/lib/tecsgen/core/expression.rb +1031 -0
- data/lib/tecsgen/core/gen_xml.rb +374 -0
- data/lib/tecsgen/core/generate.rb +5206 -0
- data/lib/tecsgen/core/location.rb +116 -0
- data/lib/tecsgen/core/messages.rb +101 -0
- data/lib/tecsgen/core/optimize.rb +456 -0
- data/lib/tecsgen/core/plugin.rb +332 -0
- data/lib/tecsgen/core/pluginModule.rb +165 -0
- data/lib/tecsgen/core/syntaxobj.rb +1234 -0
- data/lib/tecsgen/core/tecs_lang.rb +306 -0
- data/lib/tecsgen/core/tecsgen.rb +453 -0
- data/lib/tecsgen/core/tecsinfo.rb +860 -0
- data/lib/tecsgen/core/tool_info.rb +258 -0
- data/lib/tecsgen/core/types.rb +1632 -0
- data/lib/tecsgen/core/unjoin_plugin.rb +218 -0
- data/lib/tecsgen/core/value.rb +650 -0
- data/lib/tecsgen/messages/messages_console_en_US.rb +1171 -0
- data/lib/tecsgen/messages/messages_console_ja_JP.rb +1171 -0
- data/lib/tecsgen/messages/messages_file_en_US.rb +334 -0
- data/lib/tecsgen/messages/messages_file_ja_JP.rb +163 -0
- data/lib/tecsgen/plugin/ATK1AlarmPlugin.rb +196 -0
- data/lib/tecsgen/plugin/ATK1DelayTaskPlugin.rb +106 -0
- data/lib/tecsgen/plugin/ATK1EventPlugin.rb +147 -0
- data/lib/tecsgen/plugin/ATK1ISRPlugin.rb +174 -0
- data/lib/tecsgen/plugin/ATK1KernelPlugin.rb +287 -0
- data/lib/tecsgen/plugin/ATK1ResourcePlugin.rb +124 -0
- data/lib/tecsgen/plugin/ATK1TaskPlugin.rb +220 -0
- data/lib/tecsgen/plugin/C2TECSBridgePlugin.rb +210 -0
- data/lib/tecsgen/plugin/CellPlugin.rb +61 -0
- data/lib/tecsgen/plugin/CelltypePlugin.rb +72 -0
- data/lib/tecsgen/plugin/CompositePlugin.rb +66 -0
- data/lib/tecsgen/plugin/DomainPlugin.rb +89 -0
- data/lib/tecsgen/plugin/HRP2AlarmHandlerPlugin.rb +76 -0
- data/lib/tecsgen/plugin/HRP2Cache.rb +1 -0
- data/lib/tecsgen/plugin/HRP2CyclicHandlerPlugin.rb +75 -0
- data/lib/tecsgen/plugin/HRP2DataqueuePlugin.rb +68 -0
- data/lib/tecsgen/plugin/HRP2EventflagPlugin.rb +68 -0
- data/lib/tecsgen/plugin/HRP2FixedSizeMemoryPoolPlugin.rb +68 -0
- data/lib/tecsgen/plugin/HRP2HandlerPlugin.rb +117 -0
- data/lib/tecsgen/plugin/HRP2KernelObjectPlugin.rb +372 -0
- data/lib/tecsgen/plugin/HRP2ObjectPlugin.rb +94 -0
- data/lib/tecsgen/plugin/HRP2Plugin.rb +140 -0
- data/lib/tecsgen/plugin/HRP2PostHook.rb +111 -0
- data/lib/tecsgen/plugin/HRP2PriorityDataqueuePlugin.rb +66 -0
- data/lib/tecsgen/plugin/HRP2RPCPlugin.rb +319 -0
- data/lib/tecsgen/plugin/HRP2SVCPlugin.rb +473 -0
- data/lib/tecsgen/plugin/HRP2SemaphorePlugin.rb +67 -0
- data/lib/tecsgen/plugin/HRP2TaskPlugin.rb +200 -0
- data/lib/tecsgen/plugin/HRPHandlerPlugin.rb +125 -0
- data/lib/tecsgen/plugin/HRPKernelObjectManager.rb +72 -0
- data/lib/tecsgen/plugin/HRPKernelObjectPlugin.rb +333 -0
- data/lib/tecsgen/plugin/HRPObjectPlugin.rb +93 -0
- data/lib/tecsgen/plugin/HRPPlugin.rb +356 -0
- data/lib/tecsgen/plugin/HRPRPCPlugin.rb +407 -0
- data/lib/tecsgen/plugin/HRPSVCPlugin.rb +859 -0
- data/lib/tecsgen/plugin/HRPTaskPlugin.rb +107 -0
- data/lib/tecsgen/plugin/Mruby2CBridgePlugin.rb +86 -0
- data/lib/tecsgen/plugin/MrubyBridgeCellPlugin.rb +264 -0
- data/lib/tecsgen/plugin/MrubyBridgeCelltypePlugin.rb +293 -0
- data/lib/tecsgen/plugin/MrubyBridgeCompositePlugin.rb +49 -0
- data/lib/tecsgen/plugin/MrubyBridgePlugin.rb +67 -0
- data/lib/tecsgen/plugin/MrubyBridgeSignaturePlugin.rb +1307 -0
- data/lib/tecsgen/plugin/MrubyInfoBridgePlugin.rb +14 -0
- data/lib/tecsgen/plugin/MrubyInfoBridgeSignaturePlugin.rb +994 -0
- data/lib/tecsgen/plugin/MultiPlugin.rb +57 -0
- data/lib/tecsgen/plugin/NotifierPlugin.rb +1217 -0
- data/lib/tecsgen/plugin/OpaqueMarshalerPlugin.rb +81 -0
- data/lib/tecsgen/plugin/OpaqueRPCPlugin.rb +323 -0
- data/lib/tecsgen/plugin/RPCPlugin.rb +266 -0
- data/lib/tecsgen/plugin/RepeatCellPlugin.rb +166 -0
- data/lib/tecsgen/plugin/RepeatJoinPlugin.rb +130 -0
- data/lib/tecsgen/plugin/SharedOpaqueRPCPlugin.rb +357 -0
- data/lib/tecsgen/plugin/SharedRPCPlugin.rb +329 -0
- data/lib/tecsgen/plugin/SignaturePlugin.rb +77 -0
- data/lib/tecsgen/plugin/TECS2CBridgePlugin.rb +178 -0
- data/lib/tecsgen/plugin/TECSInfoPlugin.rb +280 -0
- data/lib/tecsgen/plugin/ThroughPlugin.rb +333 -0
- data/lib/tecsgen/plugin/TracePlugin.rb +484 -0
- data/lib/tecsgen/plugin/lib/GenHRP2Marshaler.rb +761 -0
- data/lib/tecsgen/plugin/lib/GenOpaqueMarshaler.rb +1107 -0
- data/lib/tecsgen/plugin/lib/GenParamCopy.rb +365 -0
- data/lib/tecsgen/plugin/lib/GenTransparentMarshaler.rb +683 -0
- data/lib/tecsgen/plugin/lib/MrubyBridgeCelltypePluginModule.rb +283 -0
- data/lib/tecsgen/plugin/lib/MrubyBridgeSignaturePluginModule.rb +277 -0
- data/lib/tecsgen/version.rb +6 -0
- data/samples/FigureSamples/active/active.cde +104 -0
- data/samples/FigureSamples/active/active.cdl +20 -0
- data/samples/FigureSamples/active/active.pdf +0 -0
- data/samples/FigureSamples/active/active.png +0 -0
- data/samples/FigureSamples/active/gen/tmp_C_src.c +36 -0
- data/samples/FigureSamples/active/gen/tmp_cygwin_tecs.h +1908 -0
- data/samples/FigureSamples/active/gen/tmp_plugin_post_code.cdl +0 -0
- data/samples/FigureSamples/allocator/allocator-internal.png +0 -0
- data/samples/FigureSamples/allocator/allocator.cde +171 -0
- data/samples/FigureSamples/allocator/allocator.cdl +58 -0
- data/samples/FigureSamples/allocator/allocator.png +0 -0
- data/samples/FigureSamples/basic/Makefile +87 -0
- data/samples/FigureSamples/basic/SimpleSample-trace.cdl +50 -0
- data/samples/FigureSamples/basic/SimpleSample.cde +91 -0
- data/samples/FigureSamples/basic/SimpleSample.cdl +47 -0
- data/samples/FigureSamples/basic/basic.cde +93 -0
- data/samples/FigureSamples/basic/basic.cdl +46 -0
- data/samples/FigureSamples/basic/basic.png +0 -0
- data/samples/FigureSamples/callback/callback.cde +130 -0
- data/samples/FigureSamples/callback/callback.cdl +29 -0
- data/samples/FigureSamples/callback/callback.png +0 -0
- data/samples/FigureSamples/carray/carray.cde +144 -0
- data/samples/FigureSamples/carray/carray.cdl +38 -0
- data/samples/FigureSamples/carray/carray.png +0 -0
- data/samples/FigureSamples/cearray/cearray.cde +314 -0
- data/samples/FigureSamples/cearray/cearray.cdl +60 -0
- data/samples/FigureSamples/cearray/cearray.png +0 -0
- data/samples/FigureSamples/composite/composite-internal.png +0 -0
- data/samples/FigureSamples/composite/composite.cde +216 -0
- data/samples/FigureSamples/composite/composite.cdl +95 -0
- data/samples/FigureSamples/composite/composite.png +0 -0
- data/samples/FigureSamples/earray/earray.cde +142 -0
- data/samples/FigureSamples/earray/earray.cdl +38 -0
- data/samples/FigureSamples/earray/earray.png +0 -0
- data/samples/FigureSamples/join/Makefile +87 -0
- data/samples/FigureSamples/join/join.cde +132 -0
- data/samples/FigureSamples/join/join.cdl +40 -0
- data/samples/FigureSamples/join/join.png +0 -0
- data/samples/FigureSamples/relay/Makefile +99 -0
- data/samples/FigureSamples/relay/relay-internal.png +0 -0
- data/samples/FigureSamples/relay/relay.cde +284 -0
- data/samples/FigureSamples/relay/relay.cdl +52 -0
- data/samples/FigureSamples/relay/relay.png +0 -0
- data/samples/FigureSamples/rpc/Makefile +123 -0
- data/samples/FigureSamples/rpc/rpc-expand.png +0 -0
- data/samples/FigureSamples/rpc/rpc.cde +245 -0
- data/samples/FigureSamples/rpc/rpc.png +0 -0
- data/samples/FigureSamples/rpc/rpc_sample.cdl +53 -0
- data/samples/SimpleSample/Makefile +25 -0
- data/samples/SimpleSample/SimpleSample/Makefile +86 -0
- data/samples/SimpleSample/SimpleSample/Makefile-trace +91 -0
- data/samples/SimpleSample/SimpleSample/README.txt +106 -0
- data/samples/SimpleSample/SimpleSample/SimpleSample-trace.cdl +50 -0
- data/samples/SimpleSample/SimpleSample/SimpleSample.cdl +45 -0
- data/samples/SimpleSample/SimpleSample/src/tSample.c +77 -0
- data/samples/SimpleSample/SimpleSample/src/tSimple.c +48 -0
- data/samples/SimpleSample/SimpleSample/src/tecs-types.h +27 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/Makefile +51 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/Makefile-trace +91 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/README.txt +106 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/SimpleSample-trace.cdl +80 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/SimpleSample.cdl +77 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/rSample/Makefile +112 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/rSimple/Makefile +109 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tSample.c +80 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tSimple.c +47 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tTaskMain.c +66 -0
- data/samples/SimpleSample/SimpleSampleOpaqueRPC/src/tecs-types.h +27 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/Makefile +125 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/Makefile-trace +130 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/SimpleSample-trace.cdl +54 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/SimpleSample.cdl +53 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/src/tSample.c +80 -0
- data/samples/SimpleSample/SimpleSampleTransparentRPC/src/tSimple.c +54 -0
- data/tecscde.gemspec +41 -0
- metadata +353 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
#
|
|
2
|
+
# TECS Generator
|
|
3
|
+
# Generator for TOPPERS Embedded Component System
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2008-2017 by TOPPERS Project
|
|
6
|
+
#--
|
|
7
|
+
# 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
|
|
8
|
+
# ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
|
9
|
+
# 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
|
10
|
+
# (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
|
11
|
+
# 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
|
12
|
+
# スコード中に含まれていること.
|
|
13
|
+
# (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
|
14
|
+
# 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
|
15
|
+
# 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
|
16
|
+
# の無保証規定を掲載すること.
|
|
17
|
+
# (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
|
18
|
+
# 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
|
19
|
+
# と.
|
|
20
|
+
# (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
|
21
|
+
# 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
|
22
|
+
# (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
|
23
|
+
# 報告すること.
|
|
24
|
+
# (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
|
25
|
+
# 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
|
26
|
+
# また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
|
27
|
+
# 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
|
28
|
+
# 免責すること.
|
|
29
|
+
#
|
|
30
|
+
# 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
|
31
|
+
# よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
|
32
|
+
# に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
|
33
|
+
# アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
|
34
|
+
# の責任を負わない.
|
|
35
|
+
#
|
|
36
|
+
# $Id: MrubyBridgeCelltypePlugin.rb 2952 2018-05-07 10:19:07Z okuma-top $
|
|
37
|
+
#++
|
|
38
|
+
|
|
39
|
+
require_tecsgen_lib "tecslib/plugin/lib/MrubyBridgeCelltypePluginModule.rb"
|
|
40
|
+
|
|
41
|
+
#== MrubyBridgeCompositePlugin
|
|
42
|
+
class MrubyBridgeCelltypePlugin < CompositePlugin
|
|
43
|
+
dbgPrint "MrubyBridgeCelltypePlugin loaded\n"
|
|
44
|
+
include MrubyBridgeCelltypePluginModule
|
|
45
|
+
|
|
46
|
+
def self.gen_post_code(file)
|
|
47
|
+
MrubyBridgeCelltypePluginModule.gen_post_code file
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
#
|
|
53
|
+
##== celltype プラグインの共通の親クラス
|
|
54
|
+
# class MrubyBridgeCelltypePlugin < CelltypePlugin
|
|
55
|
+
#
|
|
56
|
+
# # プラグイン引数名 => Proc
|
|
57
|
+
# MrubyBridgePluginArgProc = {
|
|
58
|
+
# "ignoreUnsigned" => Proc.new { |obj,rhs| obj.set_ignoreUnsigned rhs },
|
|
59
|
+
# "include_inner_cell" => Proc.new { |obj,rhs| obj.set_include_inner_cell rhs },
|
|
60
|
+
# "exclude_cell" => Proc.new { |obj,rhs| obj.set_exclude_cell rhs },
|
|
61
|
+
# "exclude_port" => Proc.new { |obj,rhs| obj.set_exclude_port rhs },
|
|
62
|
+
# "exclude_port_func" => Proc.new { |obj,rhs| obj.set_exclude_port_func rhs },
|
|
63
|
+
# "auto_exclude" => Proc.new { |obj,rhs| obj.set_auto_exclude rhs },
|
|
64
|
+
# }
|
|
65
|
+
#
|
|
66
|
+
# require_tecsgen_lib( "MrubyBridgeCellPlugin.rb" )
|
|
67
|
+
# @@plugin_list = []
|
|
68
|
+
# @@count = 1
|
|
69
|
+
#
|
|
70
|
+
# #celltype:: Celltype セルタイプ(インスタンス)
|
|
71
|
+
# def initialize( celltype, option )
|
|
72
|
+
# dbgPrint "#{self.class.name}: initialzie: #{celltype.get_name}\n"
|
|
73
|
+
#
|
|
74
|
+
# super
|
|
75
|
+
# @celltype = celltype
|
|
76
|
+
# @cell_list = []
|
|
77
|
+
# @include_inner_cell = false
|
|
78
|
+
# @exclude_cells = []
|
|
79
|
+
# @exclude_port = []
|
|
80
|
+
# @exclude_port_func = {}
|
|
81
|
+
# @b_ignoreUnsigned = false
|
|
82
|
+
# @b_auto_exclude = true # auto_exclude = true by default
|
|
83
|
+
# @@plugin_list << self
|
|
84
|
+
#
|
|
85
|
+
# @plugin_arg_check_proc_tab = MrubyBridgePluginArgProc
|
|
86
|
+
# @plugin_arg_str = CDLString.remove_dquote option
|
|
87
|
+
# parse_plugin_arg
|
|
88
|
+
#
|
|
89
|
+
# MrubyBridgeCellPlugin.set_gen_post_code_by_dependent
|
|
90
|
+
# end
|
|
91
|
+
#
|
|
92
|
+
# #=== 新しいセル
|
|
93
|
+
# #cell:: Cell セル
|
|
94
|
+
# #
|
|
95
|
+
# # celltype プラグインを指定されたセルタイプのセルが生成された
|
|
96
|
+
# # セルタイププラグインに対する新しいセルの報告
|
|
97
|
+
# # generate 文により呼び出された場合、それまでに定義された cell については、initialize のタイミングで呼び出される
|
|
98
|
+
# def new_cell( cell )
|
|
99
|
+
# dbgPrint "MrubyBridgeCelltypePlugin: new_cell: #{cell.get_name}\n"
|
|
100
|
+
#
|
|
101
|
+
# return if @cell_list.include? cell # この行は、本来不要のはず
|
|
102
|
+
# if TECSGEN.post_coded? # post_code 以降のセルは対象から外す
|
|
103
|
+
# cdl_info( "I9999 MrubyBridgeCelltypePlugin: $1 is excluded because cell generated after post_coded", cell.get_name )
|
|
104
|
+
# return
|
|
105
|
+
# end
|
|
106
|
+
#
|
|
107
|
+
# # include_inner_cell option
|
|
108
|
+
# if cell.is_cloned? && @include_inner_cell == false then
|
|
109
|
+
# # p "#{cell.get_name} excluded"
|
|
110
|
+
# cdl_info( "I9999 MrubyBridgeCelltypePlugin: inner cell $1 is excluded", cell.get_name )
|
|
111
|
+
# return
|
|
112
|
+
# # else
|
|
113
|
+
# # p "#{cell.get_name} included"
|
|
114
|
+
# end
|
|
115
|
+
#
|
|
116
|
+
# # exclude_cell option
|
|
117
|
+
# if @exclude_cells.include?( cell.get_name ) then
|
|
118
|
+
# return
|
|
119
|
+
# end
|
|
120
|
+
#
|
|
121
|
+
# opt_str = "ignoreUnsigned=#{@b_ignoreUnsigned}, auto_exclude=#{@b_auto_exclude}"
|
|
122
|
+
# @exclude_port.each{ |port|
|
|
123
|
+
# opt_str += ",exclude_port=#{port}"
|
|
124
|
+
# }
|
|
125
|
+
# @exclude_port_func.each{ |port, funcs|
|
|
126
|
+
# funcs.each{ |func|
|
|
127
|
+
# opt_str += ",exclude_port_func=#{port}.#{func}"
|
|
128
|
+
# }
|
|
129
|
+
# }
|
|
130
|
+
#
|
|
131
|
+
# # p "MrubyBridgeCelltypePlugin: opt_str=#{opt_str}"
|
|
132
|
+
#
|
|
133
|
+
# # mikan option, region
|
|
134
|
+
# fn2 = "#{$gen}/tmp_MrubyBridgeCelltypePlugin_#{@celltype.get_name}_#{@@count}.cdl"
|
|
135
|
+
# f2 = File.open( fn2, "w" )
|
|
136
|
+
# f2.print <<EOT
|
|
137
|
+
# /* MrubyBridgeCelltypePlugin: celltype=#{@celltype.get_name} */
|
|
138
|
+
# generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "#{opt_str}" );
|
|
139
|
+
# EOT
|
|
140
|
+
# f2.close
|
|
141
|
+
# Import.new "#{fn2}"
|
|
142
|
+
# @@count += 1
|
|
143
|
+
# end
|
|
144
|
+
#
|
|
145
|
+
#### 意味解析段階で呼び出されるメソッド ###
|
|
146
|
+
# #=== CDL ファイルの生成
|
|
147
|
+
# # typedef, signature, celltype, cell のコードを生成
|
|
148
|
+
# # 重複して生成してはならない
|
|
149
|
+
# # すでに生成されている場合は出力しないこと。
|
|
150
|
+
# # もしくは同名の import により、重複を避けること。
|
|
151
|
+
# #file:: FILE 生成するファイル
|
|
152
|
+
# def gen_cdl_file file
|
|
153
|
+
## この段階で呼びだすと generate 文が呼び出される前のセルのみの出力となる
|
|
154
|
+
#
|
|
155
|
+
## dbgPrint "MrubyBridgeCelltypePlugin: gen_cdl_file: #{@celltype.get_name}\n"
|
|
156
|
+
## file.print <<EOT
|
|
157
|
+
# #/* MrubyBridgeCelltypePlugin: celltype=#{@celltype.get_name}
|
|
158
|
+
## *
|
|
159
|
+
## * cell's generate before celltype's generate
|
|
160
|
+
## */
|
|
161
|
+
##
|
|
162
|
+
# #EOT
|
|
163
|
+
## @celltype.get_cell_list.each { |cell|
|
|
164
|
+
## @cell_list << cell
|
|
165
|
+
## # mikan option, region
|
|
166
|
+
## dbgPrint "MrubyBridgeCelltypePlugin: cell=#{cell.get_name}\n"
|
|
167
|
+
## file.print <<EOT
|
|
168
|
+
# #generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "" );
|
|
169
|
+
# #EOT
|
|
170
|
+
## }
|
|
171
|
+
#
|
|
172
|
+
# end
|
|
173
|
+
#
|
|
174
|
+
# #=== tCelltype_factory.h に挿入するコードを生成する
|
|
175
|
+
# # file 以外の他のファイルにファクトリコードを生成してもよい
|
|
176
|
+
# # セルタイププラグインが指定されたセルタイプのみ呼び出される
|
|
177
|
+
# def gen_factory file
|
|
178
|
+
# end
|
|
179
|
+
#
|
|
180
|
+
# def get_celltype
|
|
181
|
+
# @celltype
|
|
182
|
+
# end
|
|
183
|
+
#
|
|
184
|
+
# #=== 後ろの CDL コードを生成
|
|
185
|
+
# #プラグインの後ろの CDL コードを生成
|
|
186
|
+
# #file:: File:
|
|
187
|
+
# def self.gen_post_code( file )
|
|
188
|
+
# dbgPrint "#{self.name}: gen_post_code_body\n"
|
|
189
|
+
# print "#{self.name}: gen_post_code_body\n"
|
|
190
|
+
## この段階で生成すると、同じポストコードで出力される mruby の初期化コードに反映されない
|
|
191
|
+
#
|
|
192
|
+
## # MrubyBridgeCelltypePlugin の生成する generate 文は、
|
|
193
|
+
## fn2 = "#{$gen}/tmp_MrubyBridgeCelltypePlugin_post.cdl"
|
|
194
|
+
## f2 = File.open( fn2, "w" )
|
|
195
|
+
## # 複数のプラグインの post_code が一つのファイルに含まれるため、以下のような見出しをつけること
|
|
196
|
+
## dbgPrint "MrubyBridgeCelltypePlugin: gen_post_code\n"
|
|
197
|
+
## f2.print "/* '#{self.name}' post code */\n"
|
|
198
|
+
## @@plugin_list.each{ |plugin|
|
|
199
|
+
## plugin.get_celltype.get_cell_list.each{ |cell|
|
|
200
|
+
## # mikan option, region
|
|
201
|
+
## f2.print <<EOT
|
|
202
|
+
# #generate( MrubyBridgeCellPlugin, #{cell.get_namespace_path}, "" );
|
|
203
|
+
# #EOT
|
|
204
|
+
## }
|
|
205
|
+
## }
|
|
206
|
+
## f2.close
|
|
207
|
+
## p Import
|
|
208
|
+
## Import.new "#{fn2}"
|
|
209
|
+
#
|
|
210
|
+
# MrubyBridgeCellPlugin.gen_post_code_body file
|
|
211
|
+
# end
|
|
212
|
+
#
|
|
213
|
+
# #=== プラグイン引数
|
|
214
|
+
#
|
|
215
|
+
# #=== プラグイン引数 ignoreUnsigned
|
|
216
|
+
# def set_ignoreUnsigned rhs
|
|
217
|
+
# if rhs == "true" || rhs == nil then
|
|
218
|
+
# @b_ignoreUnsigned = true
|
|
219
|
+
# end
|
|
220
|
+
# end
|
|
221
|
+
#
|
|
222
|
+
# def set_include_inner_cell rhs
|
|
223
|
+
# if rhs == "true" || rhs == nil then
|
|
224
|
+
# @include_inner_cell = true
|
|
225
|
+
# end
|
|
226
|
+
# end
|
|
227
|
+
#
|
|
228
|
+
# def set_exclude_cell rhs
|
|
229
|
+
# cells = rhs.split ','
|
|
230
|
+
# cells.each{ |rhs_cell|
|
|
231
|
+
# rhs_cell.gsub!( /\s/, "" )
|
|
232
|
+
# @exclude_cells << rhs_cell.to_sym
|
|
233
|
+
# }
|
|
234
|
+
# end
|
|
235
|
+
# def set_exclude_port rhs
|
|
236
|
+
# ports = rhs.split ','
|
|
237
|
+
# ct = @cell.get_celltype
|
|
238
|
+
# return if ct == nil # error case
|
|
239
|
+
# ports.each{ |rhs_port|
|
|
240
|
+
# obj = ct.find( rhs_port.to_sym )
|
|
241
|
+
# if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
|
|
242
|
+
# cdl_error( "MRB9999 exclude_port '$1' not found or not entry in celltype '$2'", rhs_port, ct.get_name )
|
|
243
|
+
# else
|
|
244
|
+
# # print "MRBBridgeCellPlugin: exclude #{rhs_port}\n"
|
|
245
|
+
# @exclude_port << rhs_port
|
|
246
|
+
# end
|
|
247
|
+
# }
|
|
248
|
+
# end
|
|
249
|
+
#
|
|
250
|
+
# #=== プラグイン引数 exclude_port_func
|
|
251
|
+
# def set_exclude_port_func rhs
|
|
252
|
+
# port_funcs = rhs.split ','
|
|
253
|
+
# ct = @celltype
|
|
254
|
+
# return if ct == nil # error case
|
|
255
|
+
# port_funcs.each{ |rhs_port_func|
|
|
256
|
+
# port_func = rhs_port_func.split( '.' )
|
|
257
|
+
# if port_func.length != 2 then
|
|
258
|
+
# cdl_error( "MRB9999 exclude_port_func: '$1' not in 'port.func' form", rhs_port_func )
|
|
259
|
+
# end
|
|
260
|
+
# obj = ct.find( port_func[0].to_sym )
|
|
261
|
+
# if( ( ! obj.instance_of? Port ) || obj.get_port_type != :ENTRY ) then
|
|
262
|
+
# cdl_error( "MRB9999 exclude_port_func: port '$1' not found in celltype '$2'", rhs_port_func, ct.get_name )
|
|
263
|
+
# else
|
|
264
|
+
# signature = obj.get_signature
|
|
265
|
+
# next if signature == nil # error case
|
|
266
|
+
# if signature.get_function_head port_func[1].to_sym
|
|
267
|
+
# # print "MRBBridgeCellPlugin: #{port_func[0]}.#{port_func[1]} exclude\n"
|
|
268
|
+
# if @exclude_port_func[ port_func[0] ] then
|
|
269
|
+
# @exclude_port_func[ port_func[0] ] << port_func[1]
|
|
270
|
+
# else
|
|
271
|
+
# @exclude_port_func[ port_func[0] ] = [ port_func[1] ]
|
|
272
|
+
# end
|
|
273
|
+
# else
|
|
274
|
+
# cdl_error( "MRB9999 include_port_func: func '$1' not found in port '$2' celltype $3",
|
|
275
|
+
# port_func[1], port_func[0], ct.get_name )
|
|
276
|
+
# end
|
|
277
|
+
# end
|
|
278
|
+
# }
|
|
279
|
+
# end
|
|
280
|
+
#
|
|
281
|
+
# #=== プラグイン引数 auto_exclude
|
|
282
|
+
# def set_auto_exclude rhs
|
|
283
|
+
# # print "MrubyBridgeCellPlugin: auto_exclude=#{rhs}\n"
|
|
284
|
+
# if rhs == "false" then
|
|
285
|
+
# @b_auto_exclude = false
|
|
286
|
+
# elsif rhs == "true" then
|
|
287
|
+
# @b_auto_exclude = true # auto_exclude = true by default
|
|
288
|
+
# else
|
|
289
|
+
# cdl_warning( "MRB9999 auto_exclude: unknown rhs value ignored. specify true or false" )
|
|
290
|
+
# end
|
|
291
|
+
# end
|
|
292
|
+
# end
|
|
293
|
+
#
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#
|
|
2
|
+
# TECS Generator
|
|
3
|
+
# Generator for TOPPERS Embedded Component System
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2008-2017 by TOPPERS Project
|
|
6
|
+
#--
|
|
7
|
+
# 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
|
|
8
|
+
# ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
|
9
|
+
# 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
|
10
|
+
# (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
|
11
|
+
# 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
|
12
|
+
# スコード中に含まれていること.
|
|
13
|
+
# (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
|
14
|
+
# 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
|
15
|
+
# 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
|
16
|
+
# の無保証規定を掲載すること.
|
|
17
|
+
# (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
|
18
|
+
# 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
|
19
|
+
# と.
|
|
20
|
+
# (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
|
21
|
+
# 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
|
22
|
+
# (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
|
23
|
+
# 報告すること.
|
|
24
|
+
# (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
|
25
|
+
# 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
|
26
|
+
# また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
|
27
|
+
# 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
|
28
|
+
# 免責すること.
|
|
29
|
+
#
|
|
30
|
+
# 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
|
31
|
+
# よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
|
32
|
+
# に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
|
33
|
+
# アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
|
34
|
+
# の責任を負わない.
|
|
35
|
+
#
|
|
36
|
+
# $Id: MrubyBridgeCompositePlugin.rb 2952 2018-05-07 10:19:07Z okuma-top $
|
|
37
|
+
#++
|
|
38
|
+
|
|
39
|
+
require_tecsgen_lib "tecslib/plugin/lib/MrubyBridgeCelltypePluginModule.rb"
|
|
40
|
+
|
|
41
|
+
#== MrubyBridgeCompositePlugin
|
|
42
|
+
class MrubyBridgeCompositePlugin < CompositePlugin
|
|
43
|
+
dbgPrint "MrubyBridgeCompositePlugin loaded\n"
|
|
44
|
+
include MrubyBridgeCelltypePluginModule
|
|
45
|
+
|
|
46
|
+
def self.gen_post_code(file)
|
|
47
|
+
MrubyBridgeCelltypePluginModule.gen_post_code file
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#
|
|
2
|
+
# mruby => TECS bridge
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2008-2017 by TOPPERS Project
|
|
5
|
+
#
|
|
6
|
+
# 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
|
|
7
|
+
# ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
|
8
|
+
# 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
|
9
|
+
# (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
|
10
|
+
# 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
|
11
|
+
# スコード中に含まれていること.
|
|
12
|
+
# (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
|
13
|
+
# 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
|
14
|
+
# 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
|
15
|
+
# の無保証規定を掲載すること.
|
|
16
|
+
# (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
|
17
|
+
# 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
|
18
|
+
# と.
|
|
19
|
+
# (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
|
20
|
+
# 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
|
21
|
+
# (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
|
22
|
+
# 報告すること.
|
|
23
|
+
# (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
|
24
|
+
# 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
|
25
|
+
# また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
|
26
|
+
# 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
|
27
|
+
# 免責すること.
|
|
28
|
+
#
|
|
29
|
+
# 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
|
30
|
+
# よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
|
31
|
+
# に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
|
32
|
+
# アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
|
33
|
+
# の責任を負わない.
|
|
34
|
+
#
|
|
35
|
+
# $Id: MrubyBridgePlugin.rb 2952 2018-05-07 10:19:07Z okuma-top $
|
|
36
|
+
#
|
|
37
|
+
|
|
38
|
+
#== MrubyBridgePlugin クラス
|
|
39
|
+
class MrubyBridgePlugin < MultiPlugin
|
|
40
|
+
def self.get_plugin(superClass)
|
|
41
|
+
# case when (つまりは ===) では、期待したように一致しない模様
|
|
42
|
+
if superClass == SignaturePlugin
|
|
43
|
+
dbgPrint "MrubyBridgePlugin: SignaturePlugin"
|
|
44
|
+
require_tecsgen_lib "tecslib/plugin/MrubyBridgeSignaturePlugin.rb"
|
|
45
|
+
return MrubyBridgeSignaturePlugin
|
|
46
|
+
elsif superClass == CelltypePlugin
|
|
47
|
+
dbgPrint "MrubyBridgePlugin: CelltypePlugin"
|
|
48
|
+
require_tecsgen_lib "tecslib/plugin/MrubyBridgeCelltypePlugin.rb"
|
|
49
|
+
return MrubyBridgeCelltypePlugin
|
|
50
|
+
elsif superClass == CompositePlugin
|
|
51
|
+
dbgPrint "MrubyBridgePlugin: CompositePlugin"
|
|
52
|
+
require_tecsgen_lib "tecslib/plugin/MrubyBridgeCompositePlugin.rb"
|
|
53
|
+
return MrubyBridgeCompositePlugin
|
|
54
|
+
elsif superClass == CellPlugin
|
|
55
|
+
dbgPrint "MrubyBridgePlugin: CellPlugin"
|
|
56
|
+
require_tecsgen_lib "tecslib/plugin/MrubyBridgeCellPlugin.rb"
|
|
57
|
+
return MrubyBridgeCellPlugin
|
|
58
|
+
# elsif superClass == ThroughPlugin
|
|
59
|
+
# return ThroughPlugin
|
|
60
|
+
# elsif superClass == DomainPlugin
|
|
61
|
+
# return DomainPlugin
|
|
62
|
+
else
|
|
63
|
+
dbgPrint "MrubyBridgePlugin: unsupported"
|
|
64
|
+
return nil
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,1307 @@
|
|
|
1
|
+
#
|
|
2
|
+
# mruby => TECS bridge
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2008-2017 by TOPPERS Project
|
|
5
|
+
#
|
|
6
|
+
# 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
|
|
7
|
+
# ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
|
8
|
+
# 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
|
9
|
+
# (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
|
10
|
+
# 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
|
11
|
+
# スコード中に含まれていること.
|
|
12
|
+
# (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
|
13
|
+
# 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
|
14
|
+
# 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
|
15
|
+
# の無保証規定を掲載すること.
|
|
16
|
+
# (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
|
17
|
+
# 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
|
18
|
+
# と.
|
|
19
|
+
# (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
|
20
|
+
# 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
|
21
|
+
# (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
|
22
|
+
# 報告すること.
|
|
23
|
+
# (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
|
24
|
+
# 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
|
25
|
+
# また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
|
26
|
+
# 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
|
27
|
+
# 免責すること.
|
|
28
|
+
#
|
|
29
|
+
# 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
|
30
|
+
# よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
|
31
|
+
# に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
|
32
|
+
# アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
|
33
|
+
# の責任を負わない.
|
|
34
|
+
#
|
|
35
|
+
# $Id: MrubyBridgeSignaturePlugin.rb 2952 2018-05-07 10:19:07Z okuma-top $
|
|
36
|
+
#
|
|
37
|
+
|
|
38
|
+
# Todo:
|
|
39
|
+
# 生成するもの
|
|
40
|
+
# gen_cdl_file
|
|
41
|
+
# ブリッジ初期化セルタイプ (シグニチャごと)
|
|
42
|
+
# @@init_celltypes に記録
|
|
43
|
+
# ブリッジセルタイプ (シグニチャごと)
|
|
44
|
+
# @@celltypes に記録
|
|
45
|
+
# 構造体セルタイプ
|
|
46
|
+
# @@struct_list に記録
|
|
47
|
+
# new_cell
|
|
48
|
+
# TECS 初期化セル(プロトタイプ宣言)
|
|
49
|
+
# @@VM_init_cells に記録
|
|
50
|
+
# @@VM_struct_list に記録
|
|
51
|
+
# @@VM_ptr_list に記録
|
|
52
|
+
# gen_post_code
|
|
53
|
+
# 構造体初期化セル
|
|
54
|
+
# ポインタ初期化セル
|
|
55
|
+
# TECS 初期化セル
|
|
56
|
+
#
|
|
57
|
+
# ep_func の作成
|
|
58
|
+
# signature, ポインタ、構造体 … 初期化受け口=mruby VM への登録
|
|
59
|
+
# ポインタ
|
|
60
|
+
# preamble の作成
|
|
61
|
+
# ポインタ、構造体 … アクセス用コードの生成
|
|
62
|
+
# signature … ブリッジ関数のプロトタイプ宣言
|
|
63
|
+
# postamble の作成
|
|
64
|
+
# signature … ブリッジ関数の定義
|
|
65
|
+
|
|
66
|
+
class MrubyBridgeSignaturePlugin < SignaturePlugin
|
|
67
|
+
# プラグイン引数名 => Proc
|
|
68
|
+
MrubyBridgePluginArgProc = {
|
|
69
|
+
"ignoreUnsigned" => Proc.new {|obj, rhs| obj.set_ignoreUnsigned rhs },
|
|
70
|
+
"include" => Proc.new {|obj, rhs| obj.set_include rhs },
|
|
71
|
+
"exclude" => Proc.new {|obj, rhs| obj.set_exclude rhs },
|
|
72
|
+
"auto_exclude" => Proc.new {|obj, rhs| obj.set_auto_exclude rhs },
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@@b_no_banner = false #
|
|
76
|
+
@@b_gen_post_code_by_dependent = false # true if gen_post_code is called by MrubyBridgeCellPlugin
|
|
77
|
+
@@celltypes = { } # {celltype_name => [ BridgePlugin のインスタンスの配列 }
|
|
78
|
+
@@init_celltypes = { } # {celltype_name => [ BridgePlugin のインスタンスの配列 }
|
|
79
|
+
@@struct_list = { } # {struct_name=>StructType}
|
|
80
|
+
@@ptr_list = { } # {ptr_celltype_name=> @@TYPE_MAP の対応するもの}
|
|
81
|
+
@@VM_list = { } # VM_name => true
|
|
82
|
+
@@VM_celltypes = { } # VM_name => { @celltype_name => セルの配列 }
|
|
83
|
+
@@VM_struct_list = { } # {name=>StructType}
|
|
84
|
+
@@VM_ptr_list = { } # { VM_name => {name=> @@TYPE_MAP の対応するもの} }
|
|
85
|
+
@@TYPE_MAP = { # type_str class GET_SET
|
|
86
|
+
:char_t => [:char_t, "Char", :Char, :INT],
|
|
87
|
+
:uchar_t => [:uchar_t, "UChar", :Char, :INT],
|
|
88
|
+
:schar_t => [:schar_t, "SChar", :Char, :INT],
|
|
89
|
+
|
|
90
|
+
:bool_t => [:bool_t, "Bool", :Bool, :BOOL],
|
|
91
|
+
:int8_t => [:int8_t, "Int8", :Int, :INT],
|
|
92
|
+
:int16_t => [:int16_t, "Int16", :Int, :INT],
|
|
93
|
+
:int32_t => [:int32_t, "Int32", :Int, :INT],
|
|
94
|
+
:int64_t => [:int64_t, "Int64", :Int, :INT],
|
|
95
|
+
:uint8_t => [:uint8_t, "UInt8", :Int, :INT],
|
|
96
|
+
:uint16_t => [:uint16_t, "UInt16", :Int, :INT],
|
|
97
|
+
:uint32_t => [:uint32_t, "UInt32", :Int, :INT],
|
|
98
|
+
:uint64_t => [:uint64_t, "UInt64", :Int, :INT],
|
|
99
|
+
|
|
100
|
+
:int => [:int, "Int", :Int, :INT],
|
|
101
|
+
:char => [:char, "Char", :Char, :INT], # char は char_t として扱う
|
|
102
|
+
:short => [:short, "Short", :Int, :INT],
|
|
103
|
+
:long => [:long, "Long", :Int, :INT],
|
|
104
|
+
|
|
105
|
+
:"unsigned char" => [:uchar_t, "UChar", :Char, :INT],
|
|
106
|
+
:"unsigned int" => [:"unsigned int", "UInt", :Int, :INT],
|
|
107
|
+
:"unsigned short" => [:"unsigned short", "UShort", :Int, :INT],
|
|
108
|
+
:"unsigned long" => [:"unsigned long", "ULong", :Int, :INT],
|
|
109
|
+
:"signed char" => [:schar_t, "SChar", :Char, :INT],
|
|
110
|
+
:"signed int" => [:int, "Int", :Int, :INT],
|
|
111
|
+
:"signed short" => [:short, "Short", :Int, :INT],
|
|
112
|
+
:"signed long" => [:long, "Long", :Int, :INT],
|
|
113
|
+
|
|
114
|
+
:float32_t => [:float32_t, "Float32", :Float, :FLOAT],
|
|
115
|
+
:double64_t => [:double64_t, "Double64", :Float, :FLOAT],
|
|
116
|
+
|
|
117
|
+
:float => [:float, "Float32", :Float, :FLOAT],
|
|
118
|
+
:double => [:double, "Double64", :Float, :FLOAT]
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
# included or excluded functions
|
|
122
|
+
|
|
123
|
+
### ロードされた時点で実行される ###
|
|
124
|
+
|
|
125
|
+
# -I に $(TECSPATH)/mruby を追加
|
|
126
|
+
# TECSGEN::Makefile.add_obj "$(MRUBY_MAIN_OBJ)"
|
|
127
|
+
TECSGEN::Makefile.add_ldflag "-lmruby -L$(MRUBYPATH)/lib -lm"
|
|
128
|
+
TECSGEN::Makefile.add_search_path "$(MRUBYPATH)/include"
|
|
129
|
+
TECSGEN::Makefile.add_var "MRUBYPATH", "..", "CHANGE this to suitable path"
|
|
130
|
+
# TECSGEN::Makefile.add_var "MRUBY_MAIN_OBJ", "$(_TECS_OBJ_DIR)tecs_mruby.o", "CHANGE this if your have your main"
|
|
131
|
+
|
|
132
|
+
#=== プラグインインスタンスの初期化
|
|
133
|
+
# 戻り値、引数の型が使用可能なものかチェックする
|
|
134
|
+
#
|
|
135
|
+
def initialize(signature, option)
|
|
136
|
+
super
|
|
137
|
+
|
|
138
|
+
if !@@b_no_banner
|
|
139
|
+
STDERR << "MrubyBridgePlugin: version 1.3.0 (Suitable for mruby ver 1.3.0 & ver 1.2.0). \n"
|
|
140
|
+
@@b_no_banner = true
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
@b_ignoreUnsigned = false
|
|
144
|
+
@includes = []
|
|
145
|
+
@excludes = []
|
|
146
|
+
@struct_list = { }
|
|
147
|
+
@ptr_list = { }
|
|
148
|
+
@auto_exclude_list = {}
|
|
149
|
+
@b_auto_exclude = true # auto_exclude = true by default
|
|
150
|
+
|
|
151
|
+
@plugin_arg_check_proc_tab = MrubyBridgePluginArgProc
|
|
152
|
+
parse_plugin_arg
|
|
153
|
+
|
|
154
|
+
@celltype_name = :"t#{@signature.get_global_name}"
|
|
155
|
+
@init_celltype_name = :"#{@celltype_name}_Initializer"
|
|
156
|
+
# this variable is sometimes not used. rhs coded directry.
|
|
157
|
+
@class_name = :"T#{@signature.get_global_name}"
|
|
158
|
+
|
|
159
|
+
@func_head_array = []
|
|
160
|
+
fh_array = []
|
|
161
|
+
if @includes.length > 0 && @excludes.length > 0
|
|
162
|
+
cdl_error("MRB1011 both include && exclude are specified")
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
if signature.get_function_head_array.nil?
|
|
166
|
+
return # 以前に文法エラー発生
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
signature.get_function_head_array.each{|func_head|
|
|
170
|
+
if @includes.length > 0
|
|
171
|
+
if @includes.index func_head.get_name
|
|
172
|
+
dbgPrint "MrubyBridgePlugin: #{func_head.get_name} INCLUDED\n"
|
|
173
|
+
fh_array << func_head
|
|
174
|
+
else
|
|
175
|
+
dbgPrint "MrubyBridgePlugin: #{func_head.get_name} NOT included\n"
|
|
176
|
+
end
|
|
177
|
+
elsif @excludes.length > 0
|
|
178
|
+
if @excludes.index(func_head.get_name).nil?
|
|
179
|
+
dbgPrint "MrubyBridgePlugin: #{func_head.get_name} NOT excluded\n"
|
|
180
|
+
fh_array << func_head
|
|
181
|
+
else
|
|
182
|
+
dbgPrint "MrubyBridgePlugin: #{func_head.get_name} EXCLUDED\n"
|
|
183
|
+
end
|
|
184
|
+
else
|
|
185
|
+
fh_array << func_head
|
|
186
|
+
end
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
check_name_and_return_type fh_array
|
|
190
|
+
check_parameter_type fh_array
|
|
191
|
+
|
|
192
|
+
fh_array.each{|fh|
|
|
193
|
+
if @auto_exclude_list[fh.get_name].nil?
|
|
194
|
+
@func_head_array << fh
|
|
195
|
+
else
|
|
196
|
+
dbgPrint "MrubyBridgePlugin: auto_exclude #{fh.get_name}\n"
|
|
197
|
+
end
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if @func_head_array.length == 0
|
|
201
|
+
cdl_error("MRB1012 '$1' no function remained by exclude", @signature.get_name)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
#=== check function name & return type
|
|
206
|
+
def check_name_and_return_type(func_head_array)
|
|
207
|
+
b_init = false
|
|
208
|
+
b_init_cell = false
|
|
209
|
+
func_head_array.each{|func_head|
|
|
210
|
+
if func_head.get_name == :initialize
|
|
211
|
+
cdl_warning("MRW2001 initialize: internally defined. change to initialize_cell in ruby")
|
|
212
|
+
b_init = true
|
|
213
|
+
elsif func_head.get_name == :initialize_cell
|
|
214
|
+
b_init_cell = true
|
|
215
|
+
end
|
|
216
|
+
rtype = func_head.get_return_type.get_original_type
|
|
217
|
+
case rtype
|
|
218
|
+
when BoolType, IntType, FloatType, VoidType
|
|
219
|
+
else
|
|
220
|
+
if @b_auto_exclude
|
|
221
|
+
cdl_info("MRI0001 cannot return type $1, $2 automatcally excluded", rtype.get_type_str, func_head.get_name)
|
|
222
|
+
@auto_exclude_list[func_head.get_name] = func_head
|
|
223
|
+
else
|
|
224
|
+
cdl_error("MRB1001 cannot return type $1", rtype.get_type_str)
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
}
|
|
228
|
+
if b_init && b_init_cell
|
|
229
|
+
cdl_warning("MRB1002 initialize: internally defined. change to initialize_cell in ruby")
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
#=== check paramter type
|
|
234
|
+
def check_parameter_type(func_head_array)
|
|
235
|
+
# check type of parameters
|
|
236
|
+
func_head_array.each{|fh|
|
|
237
|
+
fh.get_paramlist.get_items.each{|param_decl|
|
|
238
|
+
case param_decl.get_direction
|
|
239
|
+
when :SEND, :RECEIVE
|
|
240
|
+
if @b_auto_exclude
|
|
241
|
+
cdl_info("MRI0002 $1: $2 parameter cannot be used in mruby Bridge, $3 automatcally excluded",
|
|
242
|
+
param_decl.get_name, param_decl.get_direction.to_s.downcase, fh.get_name)
|
|
243
|
+
@auto_exclude_list[fh.get_name] = fh
|
|
244
|
+
else
|
|
245
|
+
cdl_error("MRB1003 $1: $2 parameter cannot be used in mruby Bridge", param_decl.get_name, param_decl.get_direction.to_s.downcase)
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
type = param_decl.get_type
|
|
249
|
+
type_org = type.get_original_type
|
|
250
|
+
type_str = type.get_type_str + type.get_type_str_post
|
|
251
|
+
|
|
252
|
+
b_ng = false
|
|
253
|
+
case type_org
|
|
254
|
+
when IntType
|
|
255
|
+
case type_org.get_bit_size
|
|
256
|
+
when 8, 16, 32, 64
|
|
257
|
+
when -1, -2, -3, -4, -11
|
|
258
|
+
else
|
|
259
|
+
b_ng = true
|
|
260
|
+
end
|
|
261
|
+
when BoolType
|
|
262
|
+
when FloatType
|
|
263
|
+
when PtrType
|
|
264
|
+
ttype_org = type_org.get_type # ポインタの指している先の型
|
|
265
|
+
ttype = ttype_org.get_original_type # 上記の typedef されている場合、元の型
|
|
266
|
+
register_ptr_type ttype_org, fh
|
|
267
|
+
|
|
268
|
+
if type_org.get_string.to_s == "-1"
|
|
269
|
+
case param_decl.get_direction
|
|
270
|
+
when :OUT, :INOUT
|
|
271
|
+
if @b_auto_exclude
|
|
272
|
+
cdl_info("MRB9999 string specifier without length cannot be used for out & inout parameter, $1 automatcally excluded",
|
|
273
|
+
fh.get_name)
|
|
274
|
+
@auto_exclude_list[fh.get_name] = fh
|
|
275
|
+
else
|
|
276
|
+
cdl_error("MRB9999 string specifier without length cannot be used for out & inout parameter")
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
case ttype
|
|
282
|
+
when IntType
|
|
283
|
+
bit_size = ttype.get_bit_size
|
|
284
|
+
# if bit_size < 0 && bit_size != -1 then
|
|
285
|
+
# b_ng = true
|
|
286
|
+
# end
|
|
287
|
+
when FloatType
|
|
288
|
+
when BoolType
|
|
289
|
+
when StructType
|
|
290
|
+
if type_org.get_size || type_org.get_string || type_org.get_count
|
|
291
|
+
if @b_auto_exclude
|
|
292
|
+
cdl_info("MRI9999 $1: size_is, count_is, string cannot be specified for struct pointer, $2 automatcally excluded",
|
|
293
|
+
param_decl.get_name, fh.get_name)
|
|
294
|
+
@auto_exclude_list[fh.get_name] = fh
|
|
295
|
+
else
|
|
296
|
+
cdl_error("MRB1004 $1: size_is, count_is, string cannot be specified for struct pointer", param_decl.get_name)
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
check_struct_member ttype_org, fh
|
|
300
|
+
else
|
|
301
|
+
b_ng = true
|
|
302
|
+
end
|
|
303
|
+
when StructType
|
|
304
|
+
check_struct_member type_org, fh
|
|
305
|
+
else # ArrayType, FuncType, EnumType, VoidType
|
|
306
|
+
b_ng = true
|
|
307
|
+
end
|
|
308
|
+
if b_ng
|
|
309
|
+
if @b_auto_exclude
|
|
310
|
+
cdl_info("MRI9999 $1: type $2 cannot be used in mruby Bridge, $3 automatcally excluded",
|
|
311
|
+
param_decl.get_name, type_str, fh.get_name)
|
|
312
|
+
@auto_exclude_list[fh.get_name] = fh
|
|
313
|
+
else
|
|
314
|
+
cdl_error("MRB1005 $1: type $2 cannot be used in mruby Bridge", param_decl.get_name, type_str)
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
#=== 構造体のメンバーの型のチェック
|
|
322
|
+
def check_struct_member(struct_type, fh)
|
|
323
|
+
# p "tag name:#{struct_type.get_name}"
|
|
324
|
+
# sttype = Namespace.find_tag( struct_type.get_name )
|
|
325
|
+
sttype = struct_type.get_original_type
|
|
326
|
+
if sttype.get_name.nil?
|
|
327
|
+
if @b_auto_exclude
|
|
328
|
+
cdl_info("MRI9999 tagless-struct cannot be handled, $1 automatcally excluded", fh.get_name)
|
|
329
|
+
@auto_exclude_list[fh.get_name] = fh
|
|
330
|
+
return # 登録しないように打ち切る
|
|
331
|
+
else
|
|
332
|
+
cdl_error("MRB10007 tagless-struct cannot be handled")
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
sttype.get_members_decl.get_items.each {|d|
|
|
336
|
+
t = d.get_type.get_original_type
|
|
337
|
+
case t
|
|
338
|
+
when IntType, FloatType, BoolType
|
|
339
|
+
else
|
|
340
|
+
if @b_auto_exclude
|
|
341
|
+
cdl_info("MRI9999 $1: type $2 not allowed for struct member, $3 automatcally excluded",
|
|
342
|
+
d.get_name, d.get_type.get_type_str + d.get_type.get_type_str_post, fh.get_name)
|
|
343
|
+
@auto_exclude_list[fh.get_name] = fh
|
|
344
|
+
return # 登録しないように打ち切る
|
|
345
|
+
else
|
|
346
|
+
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)
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
}
|
|
350
|
+
st_name = :"t{}"
|
|
351
|
+
if @struct_list[sttype.get_name].nil?
|
|
352
|
+
# print_msg " MrubyBridgePlugin: [struct] #{struct_type.get_type_str} => class TECS::Struct#{sttype.get_name}\n"
|
|
353
|
+
print " MrubyBridgePlugin: [struct] #{struct_type.get_type_str} => class TECS::Struct#{sttype.get_name}\n"
|
|
354
|
+
@struct_list[sttype.get_name] = sttype
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
def register_ptr_type(ttype, fh)
|
|
359
|
+
t_org = ttype.get_original_type
|
|
360
|
+
tment = get_type_map_ent t_org
|
|
361
|
+
if tment.nil?
|
|
362
|
+
return
|
|
363
|
+
# cdl_error( "MRB1008 unknown pointer type '$1'", ttype.get_type_str )
|
|
364
|
+
end
|
|
365
|
+
ptr_celltype_name = :"t#{tment[1]}Pointer"
|
|
366
|
+
if @@ptr_list[ptr_celltype_name].nil?
|
|
367
|
+
# print_msg " MrubyBridgePlugin: [pointer] #{ttype.get_type_str}* => class TECS::#{tment[1]}Pointer\n"
|
|
368
|
+
print " MrubyBridgePlugin: [pointer] #{ttype.get_type_str}* => class TECS::#{tment[1]}Pointer\n"
|
|
369
|
+
@@ptr_list[ptr_celltype_name] = tment
|
|
370
|
+
end
|
|
371
|
+
if @ptr_list[ptr_celltype_name].nil?
|
|
372
|
+
@ptr_list[ptr_celltype_name] = tment
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
def get_type_map_ent(ttype)
|
|
377
|
+
# structure type is registerd in check_struct_member
|
|
378
|
+
if ttype.is_a? StructType
|
|
379
|
+
return
|
|
380
|
+
end
|
|
381
|
+
tstr = ttype.get_type_str.sub(/const /, "") # const は無視
|
|
382
|
+
tstr = tstr.sub(/volatile /, "") # volatile も無視
|
|
383
|
+
if @b_ignoreUnsigned
|
|
384
|
+
tstr = tstr.sub(/unsigned /, "") # volatile も無視
|
|
385
|
+
tstr = tstr.sub(/uint/, "int") # volatile も無視
|
|
386
|
+
tstr = tstr.sub(/[cs]char/, "char") # volatile も無視
|
|
387
|
+
end
|
|
388
|
+
return @@TYPE_MAP[tstr.to_sym]
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
#=== CDL ファイルの生成
|
|
392
|
+
# typedef, signature, celltype, cell コードを生成
|
|
393
|
+
# file:: FILE 生成するファイル
|
|
394
|
+
def gen_cdl_file(file)
|
|
395
|
+
# ブリッジセルタイプの生成
|
|
396
|
+
if @@celltypes[@celltype_name].nil?
|
|
397
|
+
@@celltypes[@celltype_name] = [self]
|
|
398
|
+
@@init_celltypes[@init_celltype_name] = true
|
|
399
|
+
print_msg <<EOT
|
|
400
|
+
MrubyBridgePlugin: [signature] #{@signature.get_namespace_path} => [celltype] nMruby::#{@celltype_name} => [class] TECS::#{@class_name}
|
|
401
|
+
EOT
|
|
402
|
+
|
|
403
|
+
file.print <<EOT
|
|
404
|
+
/*
|
|
405
|
+
* MrubyBridgeSignaturePlugin:
|
|
406
|
+
* signature=#{@signature.get_namespace_path}
|
|
407
|
+
*
|
|
408
|
+
* => celltype=nMruby::#{@celltype_name}
|
|
409
|
+
* (bridge cell's celltype; generated in this file)
|
|
410
|
+
* cell nMruby::#{@celltype_name} BridgeCellName { cTECS = CellName.eEntry; };
|
|
411
|
+
* where eEntry's signature must be #{@signature.get_namespace_path}.
|
|
412
|
+
* => class=TECS::#{@class_name}
|
|
413
|
+
* (mruby's class; accessible from your script)
|
|
414
|
+
* bridge = TECS::#{@class_name}.new("BridgeCellName")
|
|
415
|
+
*/
|
|
416
|
+
import( <mruby.cdl> );
|
|
417
|
+
|
|
418
|
+
/**** Ruby => TECS Bridge Celltype (MBP500) ****/
|
|
419
|
+
namespace nMruby{
|
|
420
|
+
// bridge celltype
|
|
421
|
+
[idx_is_id,active] // not actually active, to avoid warning W1002, W1007
|
|
422
|
+
celltype #{@celltype_name} {
|
|
423
|
+
call #{@signature.get_namespace_path} cTECS;
|
|
424
|
+
attr {
|
|
425
|
+
[omit]
|
|
426
|
+
char_t *VMname = "VM";
|
|
427
|
+
[omit]
|
|
428
|
+
char_t *bridgeName = C_EXP( "$cell$" );
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
// bridge initializer celltype
|
|
432
|
+
celltype #{@init_celltype_name} {
|
|
433
|
+
entry sInitializeTECSBridge eInitialize;
|
|
434
|
+
};
|
|
435
|
+
};
|
|
436
|
+
EOT
|
|
437
|
+
|
|
438
|
+
# 構造体セルタイプの生成
|
|
439
|
+
@struct_list.each{|name, sttype|
|
|
440
|
+
if @@struct_list[name].nil?
|
|
441
|
+
file.print <<EOT
|
|
442
|
+
namespace nMruby{
|
|
443
|
+
[singleton]
|
|
444
|
+
celltype #{name} {
|
|
445
|
+
entry sInitializeTECSBridge eInitialize;
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
EOT
|
|
449
|
+
@@struct_list[name] = sttype
|
|
450
|
+
end
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
else
|
|
454
|
+
cdl_info("MRBW001 MrubyBridgePlugin: signature '$1' duplicate. ignored current one", @signature.get_namespace_path)
|
|
455
|
+
@@celltypes[@celltype_name] << self
|
|
456
|
+
end
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
#=== gen_cdl_file で定義したセルタイプに 新しいセルが定義された
|
|
460
|
+
# cell のセルタイプの名前は @celltype_name
|
|
461
|
+
def new_cell(cell)
|
|
462
|
+
if cell.get_celltype.get_name != @celltype_name
|
|
463
|
+
return
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
join = cell.get_join_list.get_item :VMname
|
|
467
|
+
if join
|
|
468
|
+
vm_name = CDLString.remove_dquote(join.get_rhs.to_s).to_sym
|
|
469
|
+
else
|
|
470
|
+
vm_name = :VM
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
if @@VM_list[vm_name].nil?
|
|
474
|
+
@@VM_list[vm_name] = true
|
|
475
|
+
|
|
476
|
+
initializer_celltype_cdl = "#{$gen}/#{cell.get_name}Initializer.cdl"
|
|
477
|
+
file = CFile.open(initializer_celltype_cdl, "w")
|
|
478
|
+
|
|
479
|
+
# TECS 初期化セル(プロトタイプ宣言)
|
|
480
|
+
print_msg " MrubyBridgePlugin: join your VM's cInitialize to #{vm_name}_TECSInitializer.eInitialize\n"
|
|
481
|
+
|
|
482
|
+
file.print <<EOT
|
|
483
|
+
|
|
484
|
+
// prototype of TECSInitializer (MBP510)
|
|
485
|
+
cell nMruby::tTECSInitializer #{vm_name}_TECSInitializer;
|
|
486
|
+
EOT
|
|
487
|
+
file.close
|
|
488
|
+
|
|
489
|
+
Generator.parse(initializer_celltype_cdl, self)
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
if @@VM_celltypes[vm_name]
|
|
493
|
+
vma = @@VM_celltypes[vm_name]
|
|
494
|
+
|
|
495
|
+
if vma[@celltype_name]
|
|
496
|
+
vma[@celltype_name] << cell
|
|
497
|
+
else
|
|
498
|
+
vma[@celltype_name] = [cell]
|
|
499
|
+
@@VM_celltypes[vm_name] = vma
|
|
500
|
+
end
|
|
501
|
+
else
|
|
502
|
+
vma = { }
|
|
503
|
+
vma[@celltype_name] = [cell]
|
|
504
|
+
@@VM_celltypes[vm_name] = vma
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
@struct_list.each{|stname, sttype|
|
|
508
|
+
if @@VM_struct_list[vm_name]
|
|
509
|
+
@@VM_struct_list[vm_name][ sttype.get_name ] = sttype
|
|
510
|
+
else
|
|
511
|
+
@@VM_struct_list[vm_name] = { sttype.get_name => sttype }
|
|
512
|
+
end
|
|
513
|
+
}
|
|
514
|
+
@ptr_list.each{|ptr_celltype_name, tment|
|
|
515
|
+
if @@VM_ptr_list[vm_name]
|
|
516
|
+
@@VM_ptr_list[vm_name][ ptr_celltype_name ] = tment
|
|
517
|
+
else
|
|
518
|
+
@@VM_ptr_list[vm_name] = { ptr_celltype_name => tment }
|
|
519
|
+
end
|
|
520
|
+
}
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
#=== プラグインが CDL の POST コードを生成
|
|
524
|
+
# tmp_plugin_post_code.cdl への出力
|
|
525
|
+
def self.gen_post_code(file)
|
|
526
|
+
dbgPrint "#{self.name}: gen_post_code\n"
|
|
527
|
+
if !@@b_gen_post_code_by_dependent
|
|
528
|
+
gen_post_code_body file
|
|
529
|
+
end
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
def self.set_gen_post_code_by_dependent # by MrubyBriddeCellPlugin
|
|
533
|
+
dbgPrint "#{self.name}: set_gen_post_code_by_dependent\n"
|
|
534
|
+
@@b_gen_post_code_by_dependent = true
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
def self.gen_post_code_body(file)
|
|
538
|
+
dbgPrint "#{self.name}: gen_post_code_body\n"
|
|
539
|
+
|
|
540
|
+
# file.print <<EOT
|
|
541
|
+
# namespace nMruby {
|
|
542
|
+
# EOT
|
|
543
|
+
#
|
|
544
|
+
# @@ptr_list.each{ |name,tment|
|
|
545
|
+
# file.print <<EOT
|
|
546
|
+
#
|
|
547
|
+
# // MBP600
|
|
548
|
+
# [singleton]
|
|
549
|
+
# celltype #{name} {
|
|
550
|
+
# entry sInitializeTECSBridge eInitialize;
|
|
551
|
+
# };
|
|
552
|
+
# EOT
|
|
553
|
+
# }
|
|
554
|
+
#
|
|
555
|
+
# file.print <<EOT
|
|
556
|
+
# };
|
|
557
|
+
# EOT
|
|
558
|
+
|
|
559
|
+
# gen_post_code で生成した celltype は gen_ep_func が呼び出されない #847
|
|
560
|
+
# @@struct_list.each{ |name,sttype|
|
|
561
|
+
# file.print <<EOT
|
|
562
|
+
#
|
|
563
|
+
# [singleton]
|
|
564
|
+
# celltype #{name} {
|
|
565
|
+
# entry sInitializeTECSBridge eInitialize;
|
|
566
|
+
# };
|
|
567
|
+
# EOT
|
|
568
|
+
# }
|
|
569
|
+
|
|
570
|
+
file.print "\n // MrubyBridgeSignaturePlugin: MBP601\n"
|
|
571
|
+
@@VM_celltypes.each{|vm_name, instance_list|
|
|
572
|
+
instance_list.each {|celltype_name, array|
|
|
573
|
+
cell = array[0]
|
|
574
|
+
if cell.get_celltype
|
|
575
|
+
ct_name = cell.get_celltype.get_name
|
|
576
|
+
file.print <<EOT
|
|
577
|
+
cell nMruby::#{ct_name}_Initializer #{vm_name}_#{ct_name}_Initializer{ };
|
|
578
|
+
EOT
|
|
579
|
+
end
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
file.print " // MBP602\n"
|
|
584
|
+
@@ptr_list.each{|name, tment|
|
|
585
|
+
file.print <<EOT
|
|
586
|
+
cell nMruby::#{name} C#{name} { };
|
|
587
|
+
EOT
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
file.print " // MBP603\n"
|
|
591
|
+
@@struct_list.each{|name, sttype|
|
|
592
|
+
file.print <<EOT
|
|
593
|
+
cell nMruby::#{name} C#{name} { };
|
|
594
|
+
EOT
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if @@VM_celltypes.nil?
|
|
598
|
+
raise "MrubyBridgeSignaturePlugin: are0"
|
|
599
|
+
end
|
|
600
|
+
@@VM_celltypes.each{|vm_name, instance_list|
|
|
601
|
+
file.print " /* === VM name is '#{vm_name}' === (MBP610) */\n"
|
|
602
|
+
init_cell_name = "#{vm_name}_TECSInitializer"
|
|
603
|
+
|
|
604
|
+
file.print " cell nMruby::tTECSInitializer #{init_cell_name} {\n"
|
|
605
|
+
|
|
606
|
+
instance_list.each {|celltype_name, array|
|
|
607
|
+
# array.each{ |cell|
|
|
608
|
+
# ct_name = cell.get_celltype.get_name
|
|
609
|
+
ct_name = celltype_name
|
|
610
|
+
file.print " cInitialize[] = #{vm_name}_#{ct_name}_Initializer.eInitialize;\n"
|
|
611
|
+
# }
|
|
612
|
+
}
|
|
613
|
+
if @@VM_ptr_list[vm_name]
|
|
614
|
+
@@VM_ptr_list[vm_name].each{|name, tment|
|
|
615
|
+
file.print " cInitialize[] = C#{name}.eInitialize;\n"
|
|
616
|
+
}
|
|
617
|
+
end
|
|
618
|
+
if @@VM_struct_list[vm_name]
|
|
619
|
+
@@VM_struct_list[vm_name].each{|name, sttype|
|
|
620
|
+
file.print " cInitialize[] = C#{name}.eInitialize;\n"
|
|
621
|
+
}
|
|
622
|
+
end
|
|
623
|
+
file.print " };"
|
|
624
|
+
}
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
####### 以下コード生成段階 ######
|
|
628
|
+
|
|
629
|
+
#=== 受け口関数の本体コードを生成(頭部と末尾は別途出力)
|
|
630
|
+
# ct_name:: Symbol (プラグインで生成された) セルタイプ名 .Symbol として送られてくる
|
|
631
|
+
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)
|
|
632
|
+
if @@celltypes[ct_name]
|
|
633
|
+
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)
|
|
634
|
+
elsif @@init_celltypes[ct_name]
|
|
635
|
+
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)
|
|
636
|
+
elsif @@ptr_list[ct_name]
|
|
637
|
+
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)
|
|
638
|
+
elsif @@struct_list[ct_name]
|
|
639
|
+
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)
|
|
640
|
+
else
|
|
641
|
+
raise "MrubyBridgeSignaturePlugin: Unknown #{ct_name}"
|
|
642
|
+
end
|
|
643
|
+
end
|
|
644
|
+
|
|
645
|
+
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)
|
|
646
|
+
raise "MrubyBridgeSignaturePlugin: unexpected "
|
|
647
|
+
end
|
|
648
|
+
|
|
649
|
+
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)
|
|
650
|
+
file.print <<EOT
|
|
651
|
+
// CELLCB *p_cellcb = GET_CELLCB( idx ); /* no error check */ /* MBP700 */
|
|
652
|
+
struct RClass *rc;
|
|
653
|
+
|
|
654
|
+
rc = mrb_define_class_under( mrb, TECS, \"#{@class_name}\", mrb->object_class );
|
|
655
|
+
mrb_define_method( mrb, rc, "initialize", MrubyBridge_#{@celltype_name}_initialize, MRB_ARGS_REQ(1) );
|
|
656
|
+
MRB_SET_INSTANCE_TT(rc, MRB_TT_DATA);
|
|
657
|
+
EOT
|
|
658
|
+
|
|
659
|
+
@func_head_array.each{|f|
|
|
660
|
+
if !f.is_function?
|
|
661
|
+
next
|
|
662
|
+
end
|
|
663
|
+
if f.get_name != :initialize
|
|
664
|
+
func_name = f.get_name
|
|
665
|
+
else
|
|
666
|
+
func_name = :initialize_cell
|
|
667
|
+
end
|
|
668
|
+
|
|
669
|
+
ret_type = f.get_return_type
|
|
670
|
+
n_param = 0
|
|
671
|
+
f.get_paramlist.get_items.each{|param|
|
|
672
|
+
case param.get_direction
|
|
673
|
+
when :IN, :INOUT, :OUT
|
|
674
|
+
n_param += 1
|
|
675
|
+
when :SEND, :RECEIVE
|
|
676
|
+
raise "MrubyBridgeSignaturePlugin: send, receive"
|
|
677
|
+
end
|
|
678
|
+
}
|
|
679
|
+
if n_param > 0
|
|
680
|
+
p_str = "MRB_ARGS_REQ( #{n_param} )"
|
|
681
|
+
else
|
|
682
|
+
p_str = "MRB_ARGS_NONE()"
|
|
683
|
+
end
|
|
684
|
+
file.print <<EOT
|
|
685
|
+
mrb_define_method( mrb, rc, "#{func_name}", MrubyBridge_#{@celltype_name}_#{func_name}, #{p_str} );
|
|
686
|
+
EOT
|
|
687
|
+
}
|
|
688
|
+
end
|
|
689
|
+
|
|
690
|
+
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)
|
|
691
|
+
t = @@ptr_list[ct_name]
|
|
692
|
+
type = t[1]
|
|
693
|
+
file.print <<EOT
|
|
694
|
+
struct RClass *a; /* MBP710 */
|
|
695
|
+
|
|
696
|
+
a = mrb_define_class_under(mrb, TECS, "#{type}Pointer", mrb->object_class);
|
|
697
|
+
MRB_SET_INSTANCE_TT(a, MRB_TT_DATA);
|
|
698
|
+
|
|
699
|
+
mrb_define_method(mrb, a, "initialize", #{type}Pointer_initialize, MRB_ARGS_REQ(1));
|
|
700
|
+
mrb_define_method(mrb, a, "[]", #{type}Pointer_aget, MRB_ARGS_REQ(1));
|
|
701
|
+
mrb_define_method(mrb, a, "value", #{type}Pointer_get_val, MRB_ARGS_NONE());
|
|
702
|
+
mrb_define_method(mrb, a, "[]=", #{type}Pointer_aset, MRB_ARGS_REQ(2));
|
|
703
|
+
mrb_define_method(mrb, a, "value=", #{type}Pointer_set_val, MRB_ARGS_REQ(1));
|
|
704
|
+
mrb_define_method(mrb, a, "size", #{type}Pointer_size, MRB_ARGS_NONE());
|
|
705
|
+
mrb_define_method(mrb, a, "length", #{type}Pointer_size, MRB_ARGS_NONE());
|
|
706
|
+
EOT
|
|
707
|
+
|
|
708
|
+
if t[2] == :Char
|
|
709
|
+
file.print <<EOT
|
|
710
|
+
mrb_define_method(mrb, a, "to_s", CharPointer_to_s, MRB_ARGS_NONE());
|
|
711
|
+
mrb_define_method(mrb, a, "from_s", CharPointer_from_s, MRB_ARGS_REQ(1));
|
|
712
|
+
EOT
|
|
713
|
+
end
|
|
714
|
+
end
|
|
715
|
+
|
|
716
|
+
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)
|
|
717
|
+
tag = ct_name
|
|
718
|
+
structType = @@struct_list[tag]
|
|
719
|
+
file.print <<EOT
|
|
720
|
+
struct RClass *a; /* MBP720 */
|
|
721
|
+
|
|
722
|
+
a = mrb_define_class_under(mrb, TECS, "Struct#{tag}", mrb->object_class);
|
|
723
|
+
MRB_SET_INSTANCE_TT(a, MRB_TT_DATA);
|
|
724
|
+
|
|
725
|
+
mrb_define_method(mrb, a, "initialize", Struct_#{tag}_initialize, MRB_ARGS_NONE());
|
|
726
|
+
EOT
|
|
727
|
+
|
|
728
|
+
structType.get_members_decl.get_items.each{|d|
|
|
729
|
+
file.print " STRUCT_INIT_MEMBER( #{tag}, #{d.get_name} )\n"
|
|
730
|
+
}
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
#=== 受け口関数の preamble (C言語)を生成する
|
|
734
|
+
# 必要なら preamble 部に出力する
|
|
735
|
+
# file:: FILE 出力先ファイル
|
|
736
|
+
# b_singleton:: bool true if singleton
|
|
737
|
+
# ct_name:: Symbol
|
|
738
|
+
# global_ct_name:: string
|
|
739
|
+
def gen_preamble(file, b_singleton, ct_name, global_ct_name)
|
|
740
|
+
if @@celltypes[ct_name]
|
|
741
|
+
gen_preamble_mruby(file, b_singleton, ct_name, global_ct_name)
|
|
742
|
+
gen_preamble_instance(file, b_singleton, ct_name, global_ct_name)
|
|
743
|
+
gen_preamble_instance_initialize(file, b_singleton, ct_name, global_ct_name)
|
|
744
|
+
gen_preamble_bridge_func(file, b_singleton, ct_name, global_ct_name)
|
|
745
|
+
elsif @@init_celltypes[ct_name]
|
|
746
|
+
gen_preamble_mruby(file, b_singleton, ct_name, global_ct_name)
|
|
747
|
+
gen_preamble_instance_proto(file, b_singleton, ct_name, global_ct_name)
|
|
748
|
+
elsif @@ptr_list[ct_name]
|
|
749
|
+
gen_preamble_ptr(file, b_singleton, ct_name, global_ct_name)
|
|
750
|
+
elsif @@struct_list[ct_name]
|
|
751
|
+
gen_preamble_struct(file, b_singleton, ct_name, global_ct_name)
|
|
752
|
+
else
|
|
753
|
+
raise "MrubyBridgeSignaturePlugin: MrubyBridgeSignaturePlugin: Unknown #{ct_name}"
|
|
754
|
+
end
|
|
755
|
+
end
|
|
756
|
+
|
|
757
|
+
def gen_preamble_mruby(file, b_singleton, ct_name, global_ct_name)
|
|
758
|
+
file.print <<EOT
|
|
759
|
+
/* MBP: MrubyBridgePlugin: MBP000 */
|
|
760
|
+
#include "mruby.h"
|
|
761
|
+
#include "mruby/class.h"
|
|
762
|
+
#include "mruby/data.h"
|
|
763
|
+
#include "mruby/string.h"
|
|
764
|
+
#include "TECSPointer.h"
|
|
765
|
+
#include "TECSStruct.h"
|
|
766
|
+
|
|
767
|
+
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
|
768
|
+
#define DLLEXPORT __declspec(dllexport)
|
|
769
|
+
#else
|
|
770
|
+
#define DLLEXPORT
|
|
771
|
+
#endif
|
|
772
|
+
|
|
773
|
+
#ifndef NULL
|
|
774
|
+
#define NULL 0
|
|
775
|
+
#endif
|
|
776
|
+
EOT
|
|
777
|
+
end
|
|
778
|
+
|
|
779
|
+
def gen_preamble_instance(file, b_singleton, ct_name, global_ct_name)
|
|
780
|
+
# 「#1005 MrubyBridgePlugin-test のビルドに失敗」にて追加
|
|
781
|
+
# 「#1004 idx_is_id が true の場合(domain の場合は未指定でも true) の CBP のプロトタイプ宣言」にて不要になる見込み
|
|
782
|
+
nsp = NamespacePath.new(:nMruby, true)
|
|
783
|
+
nsp.append! ct_name
|
|
784
|
+
ct = Namespace.find nsp
|
|
785
|
+
if ct.idx_is_id_act?
|
|
786
|
+
if ct.has_CB?
|
|
787
|
+
inib_cb = "CB"
|
|
788
|
+
elsif ct.has_INIB?
|
|
789
|
+
inib_cb = "INIB"
|
|
790
|
+
else
|
|
791
|
+
inib_cb = nil
|
|
792
|
+
end
|
|
793
|
+
if inib_cb
|
|
794
|
+
ct.get_cell_list.each{|cell|
|
|
795
|
+
if cell.is_generate?
|
|
796
|
+
name_array = ct.get_name_array(cell)
|
|
797
|
+
file.print "extern #{ct.get_global_name}_CB #{cell.get_global_name}_#{inib_cb};\n"
|
|
798
|
+
end
|
|
799
|
+
}
|
|
800
|
+
end
|
|
801
|
+
end
|
|
802
|
+
|
|
803
|
+
file.print <<EOT
|
|
804
|
+
|
|
805
|
+
/* RData MBP001 */
|
|
806
|
+
static void
|
|
807
|
+
#{@celltype_name}_free( mrb_state *mrb, void *p )
|
|
808
|
+
{
|
|
809
|
+
if( p )
|
|
810
|
+
(void)mrb_free( mrb, p );
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/* RData MBP002 */
|
|
814
|
+
struct mrb_data_type data_type_#{@celltype_name} =
|
|
815
|
+
{
|
|
816
|
+
"#{@celltype_name}",
|
|
817
|
+
#{@celltype_name}_free
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
/* RData MBP003 */
|
|
821
|
+
struct tecs_#{@celltype_name} {
|
|
822
|
+
CELLCB *cbp;
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
/* name_to_cbp MBP010 */
|
|
826
|
+
const struct name_to_cbp_#{@celltype_name} {
|
|
827
|
+
char *name; /* Cell Name */
|
|
828
|
+
CELLCB *cbp;
|
|
829
|
+
} Name_to_cbp_#{@celltype_name}[] = {
|
|
830
|
+
EOT
|
|
831
|
+
|
|
832
|
+
nsp = NamespacePath.new(:nMruby, true)
|
|
833
|
+
nsp.append! ct_name
|
|
834
|
+
ct = Namespace.find nsp
|
|
835
|
+
|
|
836
|
+
ct.get_cell_list.each{|cell|
|
|
837
|
+
if cell.is_generate?
|
|
838
|
+
join_list = cell.get_join_list
|
|
839
|
+
join = join_list.get_item(:bridgeName)
|
|
840
|
+
if join.nil?
|
|
841
|
+
name = "\"#{cell.get_name}\""
|
|
842
|
+
else
|
|
843
|
+
rhs = join.get_rhs
|
|
844
|
+
attr_list = cell.get_celltype.get_attribute_list
|
|
845
|
+
name = rhs.eval_const join_list, attr_list
|
|
846
|
+
end
|
|
847
|
+
|
|
848
|
+
name_array = ct.get_name_array(cell)
|
|
849
|
+
file.print "\t{ #{name}, #{name_array[8]} },\n"
|
|
850
|
+
end
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
file.print <<EOT
|
|
854
|
+
\t{ 0, 0 },
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
EOT
|
|
858
|
+
end
|
|
859
|
+
|
|
860
|
+
def gen_preamble_ptr(file, b_singleton, ct_name, global_ct_name)
|
|
861
|
+
tment = @@ptr_list[ct_name]
|
|
862
|
+
file.print <<EOT
|
|
863
|
+
|
|
864
|
+
GET_SET_#{tment[3]}( #{tment[1]}, #{tment[0]} )
|
|
865
|
+
POINTER_CLASS( #{tment[1]}, #{tment[0]} )
|
|
866
|
+
EOT
|
|
867
|
+
end
|
|
868
|
+
|
|
869
|
+
def gen_preamble_struct(file, b_singleton, ct_name, global_ct_name)
|
|
870
|
+
tag = ct_name
|
|
871
|
+
structType = @@struct_list[tag]
|
|
872
|
+
file.print <<EOT
|
|
873
|
+
/* struct #{tag} */
|
|
874
|
+
STRUCT_CLASS( #{tag} )
|
|
875
|
+
EOT
|
|
876
|
+
|
|
877
|
+
structType.get_members_decl.get_items.each{|d|
|
|
878
|
+
type = d.get_type.get_original_type
|
|
879
|
+
case type
|
|
880
|
+
when IntType, CIntType
|
|
881
|
+
bit_size = type.get_bit_size
|
|
882
|
+
case bit_size
|
|
883
|
+
when -11, -1
|
|
884
|
+
tType = "Char"
|
|
885
|
+
ttype = "char"
|
|
886
|
+
when -2
|
|
887
|
+
tType = "Short"
|
|
888
|
+
ttype = "short"
|
|
889
|
+
when -3
|
|
890
|
+
tType = "Int"
|
|
891
|
+
ttype = "int"
|
|
892
|
+
when -4
|
|
893
|
+
tType = "Long"
|
|
894
|
+
ttype = "long"
|
|
895
|
+
when -5
|
|
896
|
+
tType = "IntPtr"
|
|
897
|
+
ttype = "intptr"
|
|
898
|
+
when 8, 16, 32, 64
|
|
899
|
+
tType = "Int#{bit_size}"
|
|
900
|
+
ttype = "int#{bit_size}"
|
|
901
|
+
else
|
|
902
|
+
raise "MrubyBridgeSignaturePlugin: MrubyBridgeSignaturePlugin: cannot handle bit_size #{bit_size}"
|
|
903
|
+
end
|
|
904
|
+
file.print "MEMBER_GET_SET_INT( #{tag}, #{d.get_name}, #{tType}, #{ttype} )\n"
|
|
905
|
+
when FloatType, CFloatType
|
|
906
|
+
file.print "MEMBER_GET_SET_FLOAT( #{tag}, #{d.get_name} )\n"
|
|
907
|
+
else
|
|
908
|
+
raise "MrubyBridgeSignaturePlugin: MrubyBridgeSignaturePlugin: cannot handle type"
|
|
909
|
+
end
|
|
910
|
+
}
|
|
911
|
+
end
|
|
912
|
+
|
|
913
|
+
def gen_preamble_instance_proto(file, b_singleton, ct_name, global_ct_name)
|
|
914
|
+
file.print <<EOT
|
|
915
|
+
// Prototype MBP400
|
|
916
|
+
mrb_value MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self);
|
|
917
|
+
EOT
|
|
918
|
+
|
|
919
|
+
@func_head_array.each{|f|
|
|
920
|
+
if !f.is_function?
|
|
921
|
+
next
|
|
922
|
+
end
|
|
923
|
+
if f.get_name != :initialize
|
|
924
|
+
func_name = f.get_name
|
|
925
|
+
else
|
|
926
|
+
func_name = :initialize_cell
|
|
927
|
+
end
|
|
928
|
+
|
|
929
|
+
ret_type = f.get_return_type
|
|
930
|
+
ret_type0 = f.get_return_type.get_original_type
|
|
931
|
+
b_void = ret_type0.is_void?
|
|
932
|
+
plist = f.get_paramlist.get_items
|
|
933
|
+
|
|
934
|
+
file.print <<EOT
|
|
935
|
+
mrb_value MrubyBridge_#{@celltype_name}_#{func_name}( mrb_state *mrb, mrb_value self );
|
|
936
|
+
EOT
|
|
937
|
+
}
|
|
938
|
+
end
|
|
939
|
+
|
|
940
|
+
def gen_preamble_instance_initialize(file, b_singleton, ct_name, global_ct_name)
|
|
941
|
+
file.print <<EOT
|
|
942
|
+
|
|
943
|
+
/* MBP100 */
|
|
944
|
+
mrb_value
|
|
945
|
+
MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self)
|
|
946
|
+
{
|
|
947
|
+
mrb_value name;
|
|
948
|
+
struct tecs_#{@celltype_name} *tecs_cb;
|
|
949
|
+
const struct name_to_cbp_#{@celltype_name} *ntc;
|
|
950
|
+
|
|
951
|
+
/* set DATA_TYPE earlier to avoid SEGV */
|
|
952
|
+
DATA_TYPE( self ) = &data_type_#{@celltype_name};
|
|
953
|
+
|
|
954
|
+
mrb_get_args(mrb, "o", &name );
|
|
955
|
+
if( mrb_type( name ) != MRB_TT_STRING ){
|
|
956
|
+
mrb_raise(mrb, E_NAME_ERROR, "cell name not string");
|
|
957
|
+
}
|
|
958
|
+
for( ntc = &Name_to_cbp_#{@celltype_name}[0]; ntc->name != NULL; ntc++ ){
|
|
959
|
+
if( strcmp( ntc->name, RSTRING_PTR( name ) ) == 0 )
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
if( ntc->name == 0 ){
|
|
963
|
+
mrb_raise(mrb, E_ARGUMENT_ERROR, "cell not found");
|
|
964
|
+
}
|
|
965
|
+
tecs_cb = (struct tecs_#{@celltype_name} *)mrb_malloc(mrb, sizeof(struct tecs_#{@celltype_name}) );
|
|
966
|
+
tecs_cb->cbp = ntc->cbp;
|
|
967
|
+
DATA_PTR( self ) = (void *)tecs_cb;
|
|
968
|
+
|
|
969
|
+
return self;
|
|
970
|
+
}
|
|
971
|
+
EOT
|
|
972
|
+
end
|
|
973
|
+
|
|
974
|
+
def gen_preamble_bridge_func(file, b_singleton, ct_name, global_ct_name)
|
|
975
|
+
@func_head_array.each{|f|
|
|
976
|
+
if !f.is_function?
|
|
977
|
+
next
|
|
978
|
+
end
|
|
979
|
+
if f.get_name != :initialize
|
|
980
|
+
func_name = f.get_name
|
|
981
|
+
else
|
|
982
|
+
func_name = :initialize_cell
|
|
983
|
+
end
|
|
984
|
+
|
|
985
|
+
ret_type = f.get_return_type
|
|
986
|
+
ret_type0 = f.get_return_type.get_original_type
|
|
987
|
+
b_void = ret_type0.is_void?
|
|
988
|
+
plist = f.get_paramlist.get_items
|
|
989
|
+
|
|
990
|
+
file.print <<EOT
|
|
991
|
+
|
|
992
|
+
/* bridge function (MBP101) */
|
|
993
|
+
mrb_value
|
|
994
|
+
MrubyBridge_#{ct_name}_#{func_name}( mrb_state *mrb, mrb_value self )
|
|
995
|
+
{
|
|
996
|
+
/* cellcbp (MBP105) */
|
|
997
|
+
CELLCB *p_cellcb = ((struct tecs_#{@celltype_name} *)DATA_PTR(self))->cbp;
|
|
998
|
+
EOT
|
|
999
|
+
|
|
1000
|
+
file.print " /* variables for return & parameter (MBP110) */\n"
|
|
1001
|
+
if !b_void
|
|
1002
|
+
file.print " ", ret_type.get_type_str, "\tret_val", ret_type.get_type_str_post, ";\n"
|
|
1003
|
+
end
|
|
1004
|
+
arg_str = ""
|
|
1005
|
+
n_param = 0
|
|
1006
|
+
n_scalar = 0
|
|
1007
|
+
n_ptr = 0
|
|
1008
|
+
n_struct = 0
|
|
1009
|
+
plist.each{|param|
|
|
1010
|
+
case param.get_direction
|
|
1011
|
+
when :IN, :INOUT, :OUT
|
|
1012
|
+
type = param.get_type.get_original_type
|
|
1013
|
+
case type
|
|
1014
|
+
when IntType
|
|
1015
|
+
file.print " mrb_int mrb_", param.get_name, ";\n"
|
|
1016
|
+
file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"
|
|
1017
|
+
arg_str += "i"
|
|
1018
|
+
n_param += 1
|
|
1019
|
+
n_scalar += 1
|
|
1020
|
+
when FloatType
|
|
1021
|
+
file.print " mrb_float mrb_", param.get_name, ";\n"
|
|
1022
|
+
file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"
|
|
1023
|
+
arg_str += "f"
|
|
1024
|
+
n_param += 1
|
|
1025
|
+
n_scalar += 1
|
|
1026
|
+
when BoolType
|
|
1027
|
+
file.print " mrb_value mrb_", param.get_name, ";\n"
|
|
1028
|
+
file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"
|
|
1029
|
+
arg_str += "o"
|
|
1030
|
+
n_param += 1
|
|
1031
|
+
n_scalar += 1
|
|
1032
|
+
when PtrType
|
|
1033
|
+
file.print " mrb_value mrb_", param.get_name, ";\n"
|
|
1034
|
+
file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"
|
|
1035
|
+
arg_str += "o"
|
|
1036
|
+
n_param += 1
|
|
1037
|
+
n_ptr += 1
|
|
1038
|
+
when StructType
|
|
1039
|
+
file.print " mrb_value mrb_", param.get_name, ";\n"
|
|
1040
|
+
file.print " #{param.get_type.get_type_str} *#{param.get_name}#{param.get_type.get_type_str_post};\n"
|
|
1041
|
+
arg_str += "o"
|
|
1042
|
+
n_param += 1
|
|
1043
|
+
n_struct += 1
|
|
1044
|
+
else
|
|
1045
|
+
raise "MrubyBridgeSignaturePlugin: Unknown type"
|
|
1046
|
+
end
|
|
1047
|
+
end
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
if n_param > 0
|
|
1051
|
+
file.print " /* retrieve arguments (MBP111) */\n"
|
|
1052
|
+
file.print " mrb_get_args(mrb, \"#{arg_str}\""
|
|
1053
|
+
plist.each{|param|
|
|
1054
|
+
case param.get_direction
|
|
1055
|
+
when :IN, :INOUT, :OUT
|
|
1056
|
+
type = param.get_type.get_original_type
|
|
1057
|
+
case type
|
|
1058
|
+
when IntType
|
|
1059
|
+
file.print ", &mrb_", param.get_name
|
|
1060
|
+
when FloatType
|
|
1061
|
+
file.print ", &mrb_", param.get_name
|
|
1062
|
+
when BoolType
|
|
1063
|
+
file.print ", &mrb_", param.get_name
|
|
1064
|
+
when PtrType
|
|
1065
|
+
file.print ", &mrb_", param.get_name
|
|
1066
|
+
when StructType
|
|
1067
|
+
file.print ", &mrb_", param.get_name
|
|
1068
|
+
else
|
|
1069
|
+
raise "MrubyBridgeSignaturePlugin: Unknown type"
|
|
1070
|
+
end
|
|
1071
|
+
end
|
|
1072
|
+
}
|
|
1073
|
+
file.print " );\n"
|
|
1074
|
+
|
|
1075
|
+
if n_scalar > 0 || n_struct > 0
|
|
1076
|
+
file.print " /* convert mrb to C (MBP112) */\n"
|
|
1077
|
+
end
|
|
1078
|
+
plist.each{|param|
|
|
1079
|
+
case param.get_direction
|
|
1080
|
+
when :IN, :INOUT, :OUT
|
|
1081
|
+
type = param.get_type.get_original_type
|
|
1082
|
+
case type
|
|
1083
|
+
when IntType
|
|
1084
|
+
ttype = type.get_original_type
|
|
1085
|
+
tment = get_type_map_ent ttype
|
|
1086
|
+
file.print " VALCHECK_#{tment[1]}( mrb, mrb_#{param.get_name} );\n"
|
|
1087
|
+
file.print " #{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"
|
|
1088
|
+
when FloatType
|
|
1089
|
+
file.print " #{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"
|
|
1090
|
+
when BoolType
|
|
1091
|
+
file.print " #{param.get_name} = mrb_test( mrb_#{param.get_name} );\n"
|
|
1092
|
+
when PtrType
|
|
1093
|
+
ttype = type.get_type.get_original_type
|
|
1094
|
+
case ttype
|
|
1095
|
+
when StructType
|
|
1096
|
+
file.print " CHECK_STRUCT( #{ttype.get_name}, mrb_#{param.get_name} );\n"
|
|
1097
|
+
file.print " #{param.get_name} = (struct #{ttype.get_name}*)DATA_PTR(mrb_#{param.get_name});\n"
|
|
1098
|
+
when IntType
|
|
1099
|
+
when FloatType
|
|
1100
|
+
when BoolType
|
|
1101
|
+
else
|
|
1102
|
+
raise "MrubyBridgeSignaturePlugin: cannot handle type"
|
|
1103
|
+
end
|
|
1104
|
+
when StructType
|
|
1105
|
+
file.print " CHECK_STRUCT( #{type.get_name}, mrb_#{param.get_name} );\n"
|
|
1106
|
+
file.print " #{param.get_name} = (struct #{type.get_name}*)DATA_PTR(mrb_#{param.get_name});\n"
|
|
1107
|
+
else
|
|
1108
|
+
raise("MrubyBridgeSignaturePlugin: canot treat class")
|
|
1109
|
+
end
|
|
1110
|
+
end
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
if n_ptr > 0
|
|
1114
|
+
file.print " /* convert mrb to C for pointer types (MBP113) */\n"
|
|
1115
|
+
end
|
|
1116
|
+
plist.each{|param|
|
|
1117
|
+
case param.get_direction
|
|
1118
|
+
when :IN, :INOUT, :OUT
|
|
1119
|
+
type = param.get_type.get_original_type
|
|
1120
|
+
case type
|
|
1121
|
+
when IntType
|
|
1122
|
+
when FloatType
|
|
1123
|
+
when BoolType
|
|
1124
|
+
when PtrType
|
|
1125
|
+
case type.get_type.get_original_type
|
|
1126
|
+
when StructType
|
|
1127
|
+
when IntType
|
|
1128
|
+
ptrMrb2C file, type, param
|
|
1129
|
+
when FloatType
|
|
1130
|
+
ptrMrb2C file, type, param
|
|
1131
|
+
when BoolType
|
|
1132
|
+
ptrMrb2C file, type, param
|
|
1133
|
+
else
|
|
1134
|
+
raise "MrubyBridgeSignaturePlugin: cannot handle type"
|
|
1135
|
+
end
|
|
1136
|
+
when StructType
|
|
1137
|
+
else
|
|
1138
|
+
raise("MrubyBridgeSignaturePlugin: canot treat class")
|
|
1139
|
+
end
|
|
1140
|
+
end
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
end
|
|
1144
|
+
|
|
1145
|
+
file.print " /* calling target (MBP120) */\n"
|
|
1146
|
+
if !b_void
|
|
1147
|
+
file.print " ret_val = "
|
|
1148
|
+
else
|
|
1149
|
+
file.print " "
|
|
1150
|
+
end
|
|
1151
|
+
delim = ""
|
|
1152
|
+
file.print "cTECS_", f.get_name, "( "
|
|
1153
|
+
plist.each{|param|
|
|
1154
|
+
if param.get_type.get_original_type.is_a? StructType
|
|
1155
|
+
aster = "*"
|
|
1156
|
+
else
|
|
1157
|
+
aster = ""
|
|
1158
|
+
end
|
|
1159
|
+
file.print delim, aster, param.get_name
|
|
1160
|
+
delim = ", "
|
|
1161
|
+
}
|
|
1162
|
+
file.print " );\n"
|
|
1163
|
+
|
|
1164
|
+
file.print " /* return (MBP130) */\n"
|
|
1165
|
+
case ret_type0
|
|
1166
|
+
when BoolType
|
|
1167
|
+
file.print " return ret_val ? mrb_true_value() : mrb_false_value();\n"
|
|
1168
|
+
when IntType
|
|
1169
|
+
file.print " return mrb_fixnum_value( ret_val );\n"
|
|
1170
|
+
when FloatType
|
|
1171
|
+
file.print " return mrb_float_value( mrb, ret_val );\n"
|
|
1172
|
+
when VoidType
|
|
1173
|
+
file.print " return mrb_nil_value();\n"
|
|
1174
|
+
else
|
|
1175
|
+
raise "MrubyBridgeSignaturePlugin: unknown type"
|
|
1176
|
+
end
|
|
1177
|
+
|
|
1178
|
+
file.print "}\n"
|
|
1179
|
+
}
|
|
1180
|
+
end
|
|
1181
|
+
|
|
1182
|
+
def ptrMrb2C(file, type, param)
|
|
1183
|
+
ttype = type.get_type.get_original_type
|
|
1184
|
+
tment = get_type_map_ent ttype
|
|
1185
|
+
tstr = tment[1]
|
|
1186
|
+
=begin
|
|
1187
|
+
case ttype
|
|
1188
|
+
when IntType
|
|
1189
|
+
bit_size = ttype.get_bit_size
|
|
1190
|
+
case bit_size
|
|
1191
|
+
when -1, -11
|
|
1192
|
+
tstr = "Char"
|
|
1193
|
+
when 8, 16, 32, 64
|
|
1194
|
+
tstr = "Int#{bit_size}"
|
|
1195
|
+
when -2
|
|
1196
|
+
tstr = "Short"
|
|
1197
|
+
when -3
|
|
1198
|
+
tstr = "Int"
|
|
1199
|
+
when -4
|
|
1200
|
+
tstr = "Long"
|
|
1201
|
+
when -5
|
|
1202
|
+
tstr = "IntPtr"
|
|
1203
|
+
else
|
|
1204
|
+
raise "MrubyBridgeSignaturePlugin: not handle type"
|
|
1205
|
+
end
|
|
1206
|
+
when FloatType
|
|
1207
|
+
if ttype.get_bit_size == 32 then
|
|
1208
|
+
tstr = "Float32"
|
|
1209
|
+
else
|
|
1210
|
+
tstr = "Double64"
|
|
1211
|
+
end
|
|
1212
|
+
when BoolType
|
|
1213
|
+
tstr = "Bool"
|
|
1214
|
+
when StructType
|
|
1215
|
+
raise "MrubyBridgeSignaturePlugin: not handle type 2 #{ttype}"
|
|
1216
|
+
else
|
|
1217
|
+
raise "MrubyBridgeSignaturePlugin: not handle type 2 #{ttype}"
|
|
1218
|
+
end
|
|
1219
|
+
=end
|
|
1220
|
+
if param.get_size
|
|
1221
|
+
sz_str = param.get_size.to_s
|
|
1222
|
+
elsif param.get_string # mikan とりあえず size_is と string の同時指定 (二重ポインタ) はなし
|
|
1223
|
+
sz_str = param.get_string.to_s
|
|
1224
|
+
else
|
|
1225
|
+
sz_str = "1"
|
|
1226
|
+
end
|
|
1227
|
+
# unsigned 型の場合には cast が必要
|
|
1228
|
+
if ttype.get_original_type.get_type_str != param.get_type.get_type.get_type_str
|
|
1229
|
+
cast_str = "(#{param.get_type.get_type_str})"
|
|
1230
|
+
else
|
|
1231
|
+
cast_str = ""
|
|
1232
|
+
end
|
|
1233
|
+
|
|
1234
|
+
modify = ""
|
|
1235
|
+
case param.get_direction
|
|
1236
|
+
when :OUT, :INOUT
|
|
1237
|
+
case tstr
|
|
1238
|
+
when "Char", "SChar", "UChar"
|
|
1239
|
+
modify = "Mod"
|
|
1240
|
+
end
|
|
1241
|
+
end
|
|
1242
|
+
if param.is_nullable?
|
|
1243
|
+
nullable = "Nullable"
|
|
1244
|
+
else
|
|
1245
|
+
nullable = ""
|
|
1246
|
+
end
|
|
1247
|
+
|
|
1248
|
+
# file.print " CHECK_POINTER( #{tstr}, mrb_#{param.get_name}, #{sz_str} );\n"
|
|
1249
|
+
# file.print " #{param.get_name} = #{cast_str}((struct #{tstr}PointerBody*)(DATA_PTR(mrb_#{param.get_name})))->buf;\n"
|
|
1250
|
+
file.print " #{param.get_name} = CheckAndGet#{tstr}Pointer#{modify}#{nullable}( mrb, mrb_#{param.get_name}, #{sz_str} );\n"
|
|
1251
|
+
end
|
|
1252
|
+
|
|
1253
|
+
def get_celltype_name
|
|
1254
|
+
@celltype_name
|
|
1255
|
+
end
|
|
1256
|
+
|
|
1257
|
+
#=== プラグイン引数 ignoreUnsigned
|
|
1258
|
+
def set_ignoreUnsigned(rhs)
|
|
1259
|
+
if rhs == "true" || rhs.nil?
|
|
1260
|
+
@b_ignoreUnsigned = true
|
|
1261
|
+
end
|
|
1262
|
+
end
|
|
1263
|
+
|
|
1264
|
+
#=== プラグイン引数 include
|
|
1265
|
+
def set_include(rhs)
|
|
1266
|
+
funcs = rhs.split ","
|
|
1267
|
+
funcs.each{|rhs_func|
|
|
1268
|
+
found = false
|
|
1269
|
+
rhs_func.gsub!(/\s/, "")
|
|
1270
|
+
@signature.get_function_head_array.each{|a|
|
|
1271
|
+
if rhs_func.to_sym == a.get_name
|
|
1272
|
+
found = true
|
|
1273
|
+
end
|
|
1274
|
+
}
|
|
1275
|
+
if found == false
|
|
1276
|
+
cdl_error("MRB1009 include function '$1' not found in signagture '$2'", rhs, @signature.get_name)
|
|
1277
|
+
else
|
|
1278
|
+
@includes << rhs_func.to_sym
|
|
1279
|
+
end
|
|
1280
|
+
}
|
|
1281
|
+
end
|
|
1282
|
+
|
|
1283
|
+
#=== プラグイン引数 exclude
|
|
1284
|
+
def set_exclude(rhs)
|
|
1285
|
+
funcs = rhs.split ","
|
|
1286
|
+
funcs.each{|rhs_func|
|
|
1287
|
+
rhs_func.gsub!(/\s/, "")
|
|
1288
|
+
func_head = @signature.get_function_head rhs_func.to_sym
|
|
1289
|
+
if func_head == false
|
|
1290
|
+
cdl_error("MRB1010 exclude function '$1' not found in signagture '$2", rhs, @signature.get_name)
|
|
1291
|
+
else
|
|
1292
|
+
@excludes << rhs_func.to_sym
|
|
1293
|
+
end
|
|
1294
|
+
}
|
|
1295
|
+
end
|
|
1296
|
+
|
|
1297
|
+
#=== プラグイン引数 auto_exclude
|
|
1298
|
+
def set_auto_exclude(rhs)
|
|
1299
|
+
if rhs == "false"
|
|
1300
|
+
@b_auto_exclude = false
|
|
1301
|
+
elsif rhs == "true"
|
|
1302
|
+
@b_auto_exclude = true # auto_exclude = true by default
|
|
1303
|
+
else
|
|
1304
|
+
cdl_warning("MRB9999 auto_exclude: unknown rhs value ignored. specify true or false")
|
|
1305
|
+
end
|
|
1306
|
+
end
|
|
1307
|
+
end
|