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,14 @@
|
|
|
1
|
+
#== MrubyBridgePlugin クラス
|
|
2
|
+
class MrubyInfoBridgePlugin < CelltypePlugin
|
|
3
|
+
|
|
4
|
+
# TECSInfo の生成
|
|
5
|
+
# すべてのシグニチャについて、ブリッジセルを生成
|
|
6
|
+
# 動的結合可能とする
|
|
7
|
+
# TECSInfo から RawDescriptor を得て mruby オブジェクトに記憶
|
|
8
|
+
# 呼出し時
|
|
9
|
+
class MrubyInfoBridge
|
|
10
|
+
def factory cell_entry
|
|
11
|
+
find_cell
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,994 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# mruby => TECS bridge
|
|
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: MrubyInfoBridgeSignaturePlugin.rb 3050 2019-02-26 14:35:29Z okuma-top $
|
|
37
|
+
#
|
|
38
|
+
|
|
39
|
+
class MrubyInfoBridgeSignaturePlugin < SignaturePlugin
|
|
40
|
+
|
|
41
|
+
# require_tecsgen_lib 'tecslib/plugin/lib/MrubyBridgeSignaturePlugin.rb'
|
|
42
|
+
require_tecsgen_lib 'lib/MrubyBridgeSignaturePluginModule.rb'
|
|
43
|
+
include MrubyBridgeSignaturePluginModule
|
|
44
|
+
|
|
45
|
+
@@b_no_banner = false #
|
|
46
|
+
@@b_gen_post_code_by_dependent = false # true if gen_post_code is called by MrubyBridgeCellPlugin
|
|
47
|
+
|
|
48
|
+
# included or excluded functions
|
|
49
|
+
|
|
50
|
+
### ロードされた時点で実行される ###
|
|
51
|
+
|
|
52
|
+
# -I に $(TECSPATH)/mruby を追加
|
|
53
|
+
# TECSGEN::Makefile.add_obj "$(MRUBY_MAIN_OBJ)"
|
|
54
|
+
TECSGEN::Makefile.add_ldflag "-lmruby -L$(MRUBYPATH)/lib -lm"
|
|
55
|
+
TECSGEN::Makefile.add_search_path "$(MRUBYPATH)/include"
|
|
56
|
+
TECSGEN::Makefile.add_var "MRUBYPATH", "..", "CHANGE this to suitable path"
|
|
57
|
+
# TECSGEN::Makefile.add_var "MRUBY_MAIN_OBJ", "$(_TECS_OBJ_DIR)tecs_mruby.o", "CHANGE this if your have your main"
|
|
58
|
+
|
|
59
|
+
#=== プラグインインスタンスの初期化
|
|
60
|
+
# 戻り値、引数の型が使用可能なものかチェックする
|
|
61
|
+
#
|
|
62
|
+
def initialize( signature, option )
|
|
63
|
+
super
|
|
64
|
+
|
|
65
|
+
if ! @@b_no_banner
|
|
66
|
+
STDERR << "MrubyInfoBridgeSignaturePlugin: version 1.3.0 (Suitable for mruby ver 1.3.0 & ver 1.2.0). \n"
|
|
67
|
+
@@b_no_banner = true
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
@b_ignoreUnsigned = false
|
|
71
|
+
@includes = []
|
|
72
|
+
@excludes = []
|
|
73
|
+
@struct_list = { }
|
|
74
|
+
@ptr_list = { }
|
|
75
|
+
@auto_exclude_list = {}
|
|
76
|
+
@b_auto_exclude = true # auto_exclude = true by default
|
|
77
|
+
|
|
78
|
+
@plugin_arg_check_proc_tab = MrubyBridgePluginArgProc
|
|
79
|
+
parse_plugin_arg
|
|
80
|
+
|
|
81
|
+
@celltype_name = :"t#{@signature.get_global_name}"
|
|
82
|
+
@init_celltype_name = :"#{@celltype_name}_Initializer"
|
|
83
|
+
# this variable is sometimes not used. rhs coded directry.
|
|
84
|
+
@class_name = :"T#{@signature.get_global_name}"
|
|
85
|
+
|
|
86
|
+
@func_head_array = []
|
|
87
|
+
fh_array = []
|
|
88
|
+
if @includes.length > 0 && @excludes.length > 0 then
|
|
89
|
+
cdl_error( "MRB1011 both include && exclude are specified" )
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
if signature.get_function_head_array == nil then
|
|
93
|
+
return # 以前に文法エラー発生
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
signature.get_function_head_array.each{ |func_head|
|
|
97
|
+
if @includes.length > 0 then
|
|
98
|
+
if @includes.index func_head.get_name then
|
|
99
|
+
dbgPrint "MrubyBridgePlugin: #{func_head.get_name} INCLUDED\n"
|
|
100
|
+
fh_array << func_head
|
|
101
|
+
else
|
|
102
|
+
dbgPrint "MrubyBridgePlugin: #{func_head.get_name} NOT included\n"
|
|
103
|
+
end
|
|
104
|
+
elsif @excludes.length > 0 then
|
|
105
|
+
if @excludes.index( func_head.get_name ) == nil then
|
|
106
|
+
dbgPrint "MrubyBridgePlugin: #{func_head.get_name} NOT excluded\n"
|
|
107
|
+
fh_array << func_head
|
|
108
|
+
else
|
|
109
|
+
dbgPrint "MrubyBridgePlugin: #{func_head.get_name} EXCLUDED\n"
|
|
110
|
+
end
|
|
111
|
+
else
|
|
112
|
+
fh_array << func_head
|
|
113
|
+
end
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
check_name_and_return_type fh_array
|
|
117
|
+
check_parameter_type fh_array
|
|
118
|
+
|
|
119
|
+
fh_array.each{ |fh|
|
|
120
|
+
if @auto_exclude_list[ fh.get_name ] == nil then
|
|
121
|
+
@func_head_array << fh
|
|
122
|
+
else
|
|
123
|
+
dbgPrint "MrubyBridgePlugin: auto_exclude #{fh.get_name}\n"
|
|
124
|
+
end
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if @func_head_array.length == 0 then
|
|
128
|
+
cdl_error( "MRB1012 '$1' no function remained by exclude", @signature.get_name )
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
#=== check function name & return type
|
|
133
|
+
def check_name_and_return_type func_head_array
|
|
134
|
+
b_init = false; b_init_cell = false
|
|
135
|
+
func_head_array.each{ |func_head|
|
|
136
|
+
if( func_head.get_name == :initialize )then
|
|
137
|
+
cdl_warning( "MRW2001 initialize: internally defined. change to initialize_cell in ruby" )
|
|
138
|
+
b_init = true
|
|
139
|
+
elsif( func_head.get_name == :initialize_cell )then
|
|
140
|
+
b_init_cell = true
|
|
141
|
+
end
|
|
142
|
+
rtype = func_head.get_return_type.get_original_type
|
|
143
|
+
case rtype
|
|
144
|
+
when BoolType, IntType, FloatType, VoidType
|
|
145
|
+
else
|
|
146
|
+
if @b_auto_exclude then
|
|
147
|
+
cdl_info( "MRI0001 cannot return type $1, $2 automatcally excluded", rtype.get_type_str, func_head.get_name )
|
|
148
|
+
@auto_exclude_list[ func_head.get_name ] = func_head
|
|
149
|
+
else
|
|
150
|
+
cdl_error( "MRB1001 cannot return type $1", rtype.get_type_str )
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
}
|
|
154
|
+
if( b_init && b_init_cell )then
|
|
155
|
+
cdl_warning( "MRB1002 initialize: internally defined. change to initialize_cell in ruby" )
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
#=== check paramter type
|
|
160
|
+
def check_parameter_type func_head_array
|
|
161
|
+
# check type of parameters
|
|
162
|
+
func_head_array.each{ |fh|
|
|
163
|
+
fh.get_paramlist.get_items.each{ |param_decl|
|
|
164
|
+
case param_decl.get_direction
|
|
165
|
+
when :SEND, :RECEIVE
|
|
166
|
+
if @b_auto_exclude then
|
|
167
|
+
cdl_info( "MRI0002 $1: $2 parameter cannot be used in mruby Bridge, $3 automatcally excluded",
|
|
168
|
+
param_decl.get_name, param_decl.get_direction.to_s.downcase, fh.get_name )
|
|
169
|
+
@auto_exclude_list[ fh.get_name ] = fh
|
|
170
|
+
else
|
|
171
|
+
cdl_error( "MRB1003 $1: $2 parameter cannot be used in mruby Bridge", param_decl.get_name, param_decl.get_direction.to_s.downcase )
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
type = param_decl.get_type
|
|
175
|
+
type_org = type.get_original_type
|
|
176
|
+
type_str = type.get_type_str + type.get_type_str_post
|
|
177
|
+
|
|
178
|
+
b_ng = false
|
|
179
|
+
case type_org
|
|
180
|
+
when IntType
|
|
181
|
+
case type_org.get_bit_size
|
|
182
|
+
when 8, 16, 32, 64
|
|
183
|
+
when -1, -2, -3, -4, -11
|
|
184
|
+
else
|
|
185
|
+
b_ng = true
|
|
186
|
+
end
|
|
187
|
+
when BoolType
|
|
188
|
+
when FloatType
|
|
189
|
+
when PtrType
|
|
190
|
+
ttype_org = type_org.get_type # ポインタの指している先の型
|
|
191
|
+
ttype = ttype_org.get_original_type # 上記の typedef されている場合、元の型
|
|
192
|
+
register_ptr_type ttype_org, fh
|
|
193
|
+
|
|
194
|
+
if( type_org.get_string.to_s == "-1" ) then
|
|
195
|
+
case param_decl.get_direction
|
|
196
|
+
when :OUT, :INOUT
|
|
197
|
+
if @b_auto_exclude then
|
|
198
|
+
cdl_info( "MRB9999 string specifier without length cannot be used for out & inout parameter, $1 automatcally excluded",
|
|
199
|
+
fh.get_name )
|
|
200
|
+
@auto_exclude_list[ fh.get_name ] = fh
|
|
201
|
+
else
|
|
202
|
+
cdl_error( "MRB9999 string specifier without length cannot be used for out & inout parameter")
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
case ttype
|
|
208
|
+
when IntType
|
|
209
|
+
bit_size = ttype.get_bit_size
|
|
210
|
+
# if bit_size < 0 && bit_size != -1 then
|
|
211
|
+
# b_ng = true
|
|
212
|
+
# end
|
|
213
|
+
when FloatType
|
|
214
|
+
when BoolType
|
|
215
|
+
when StructType
|
|
216
|
+
if( type_org.get_size || type_org.get_string || type_org.get_count ) then
|
|
217
|
+
if @b_auto_exclude then
|
|
218
|
+
cdl_info( "MRI9999 $1: size_is, count_is, string cannot be specified for struct pointer, $2 automatcally excluded",
|
|
219
|
+
param_decl.get_name, fh.get_name )
|
|
220
|
+
@auto_exclude_list[ fh.get_name ] = fh
|
|
221
|
+
else
|
|
222
|
+
cdl_error( "MRB1004 $1: size_is, count_is, string cannot be specified for struct pointer", param_decl.get_name )
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
check_struct_member ttype_org, fh
|
|
226
|
+
else
|
|
227
|
+
b_ng = true
|
|
228
|
+
end
|
|
229
|
+
when StructType
|
|
230
|
+
check_struct_member type_org, fh
|
|
231
|
+
else # ArrayType, FuncType, EnumType, VoidType
|
|
232
|
+
b_ng = true
|
|
233
|
+
end
|
|
234
|
+
if b_ng then
|
|
235
|
+
if @b_auto_exclude then
|
|
236
|
+
cdl_info( "MRI9999 $1: type $2 cannot be used in mruby Bridge, $3 automatcally excluded",
|
|
237
|
+
param_decl.get_name, type_str, fh.get_name )
|
|
238
|
+
@auto_exclude_list[ fh.get_name ] = fh
|
|
239
|
+
else
|
|
240
|
+
cdl_error( "MRB1005 $1: type $2 cannot be used in mruby Bridge", param_decl.get_name, type_str )
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
#=== 構造体のメンバーの型のチェック
|
|
248
|
+
def check_struct_member struct_type, fh
|
|
249
|
+
#p "tag name:#{struct_type.get_name}"
|
|
250
|
+
# sttype = Namespace.find_tag( struct_type.get_name )
|
|
251
|
+
sttype = struct_type.get_original_type
|
|
252
|
+
if sttype.get_name == nil then
|
|
253
|
+
if @b_auto_exclude then
|
|
254
|
+
cdl_info( "MRI9999 tagless-struct cannot be handled, $1 automatcally excluded", fh.get_name )
|
|
255
|
+
@auto_exclude_list[ fh.get_name ] = fh
|
|
256
|
+
return # 登録しないように打ち切る
|
|
257
|
+
else
|
|
258
|
+
cdl_error( "MRB10007 tagless-struct cannot be handled")
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
sttype.get_members_decl.get_items.each { |d|
|
|
262
|
+
t = d.get_type.get_original_type
|
|
263
|
+
case t
|
|
264
|
+
when IntType, FloatType, BoolType
|
|
265
|
+
else
|
|
266
|
+
if @b_auto_exclude then
|
|
267
|
+
cdl_info( "MRI9999 $1: type $2 not allowed for struct member, $3 automatcally excluded",
|
|
268
|
+
d.get_name, d.get_type.get_type_str + d.get_type.get_type_str_post, fh.get_name )
|
|
269
|
+
@auto_exclude_list[ fh.get_name ] = fh
|
|
270
|
+
return # 登録しないように打ち切る
|
|
271
|
+
else
|
|
272
|
+
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 )
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
}
|
|
276
|
+
st_name = :"t{}"
|
|
277
|
+
if @struct_list[ sttype.get_name ] == nil then
|
|
278
|
+
# print_msg " MrubyBridgePlugin: [struct] #{struct_type.get_type_str} => class TECS::Struct#{sttype.get_name}\n"
|
|
279
|
+
print " MrubyBridgePlugin: [struct] #{struct_type.get_type_str} => class TECS::Struct#{sttype.get_name}\n"
|
|
280
|
+
@struct_list[ sttype.get_name ] = sttype
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def register_ptr_type ttype, fh
|
|
285
|
+
t_org = ttype.get_original_type
|
|
286
|
+
tment = get_type_map_ent t_org
|
|
287
|
+
if tment == nil then
|
|
288
|
+
return
|
|
289
|
+
# cdl_error( "MRB1008 unknown pointer type '$1'", ttype.get_type_str )
|
|
290
|
+
end
|
|
291
|
+
ptr_celltype_name = :"t#{tment[1]}Pointer"
|
|
292
|
+
if @@ptr_list[ ptr_celltype_name ] == nil then
|
|
293
|
+
# print_msg " MrubyBridgePlugin: [pointer] #{ttype.get_type_str}* => class TECS::#{tment[1]}Pointer\n"
|
|
294
|
+
print " MrubyBridgePlugin: [pointer] #{ttype.get_type_str}* => class TECS::#{tment[1]}Pointer\n"
|
|
295
|
+
@@ptr_list[ ptr_celltype_name ] = tment
|
|
296
|
+
end
|
|
297
|
+
if @ptr_list[ ptr_celltype_name ] == nil then
|
|
298
|
+
@ptr_list[ ptr_celltype_name ] = tment
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def get_type_map_ent ttype
|
|
303
|
+
# structure type is registerd in check_struct_member
|
|
304
|
+
if ttype.kind_of? StructType
|
|
305
|
+
return
|
|
306
|
+
end
|
|
307
|
+
tstr = ttype.get_type_str.sub( /const /, "" ) # const は無視
|
|
308
|
+
tstr = tstr.sub( /volatile /, "" ) # volatile も無視
|
|
309
|
+
if @b_ignoreUnsigned then
|
|
310
|
+
tstr = tstr.sub( /unsigned /, "" ) # volatile も無視
|
|
311
|
+
tstr = tstr.sub( /uint/, "int" ) # volatile も無視
|
|
312
|
+
tstr = tstr.sub( /[cs]char/, "char" ) # volatile も無視
|
|
313
|
+
end
|
|
314
|
+
return @@TYPE_MAP[ tstr.to_sym ]
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
#=== CDL ファイルの生成
|
|
318
|
+
# typedef, signature, celltype, cell コードを生成
|
|
319
|
+
#file:: FILE 生成するファイル
|
|
320
|
+
def gen_cdl_file(file)
|
|
321
|
+
|
|
322
|
+
# ブリッジセルタイプの生成
|
|
323
|
+
if @@celltypes[ @celltype_name ] == nil then
|
|
324
|
+
@@celltypes[ @celltype_name ] = [ self ]
|
|
325
|
+
@@init_celltypes[ @init_celltype_name ] = true
|
|
326
|
+
print_msg <<EOT
|
|
327
|
+
MrubyBridgePlugin: [signature] #{@signature.get_namespace_path} => [celltype] nMrubyInfo::#{@celltype_name} => [class] TECS::#{@class_name}
|
|
328
|
+
EOT
|
|
329
|
+
|
|
330
|
+
file.print <<EOT
|
|
331
|
+
/*
|
|
332
|
+
* MrubyBridgeSignaturePlugin:
|
|
333
|
+
* signature=#{@signature.get_namespace_path}
|
|
334
|
+
*
|
|
335
|
+
* => celltype=nMrubyInfo::#{@celltype_name}
|
|
336
|
+
* (bridge cell 's celltype; generated in this file)
|
|
337
|
+
* cell nMrubyInfo::#{@celltype_name} BridgeCellName { cTECS = CellName.eEntry; };
|
|
338
|
+
* where eEntry's signature must be #{@signature.get_namespace_path}.
|
|
339
|
+
* => class=TECS::#{@class_name}
|
|
340
|
+
* (mruby’s class; accessible from your script)
|
|
341
|
+
* bridge = TECS::#{@class_name}.new("BridgeCellName")
|
|
342
|
+
*/
|
|
343
|
+
import( <mruby.cdl> );
|
|
344
|
+
|
|
345
|
+
/**** Ruby => TECS Bridge Celltype (MBP500) ****/
|
|
346
|
+
namespace nMrubyInfo{
|
|
347
|
+
// bridge celltype
|
|
348
|
+
[singleton, idx_is_id,active] // not actually active, to avoid warning W1002, W1007
|
|
349
|
+
celltype #{@celltype_name} {
|
|
350
|
+
[dynamic,optional]
|
|
351
|
+
call #{@signature.get_namespace_path.to_s} cTECS;
|
|
352
|
+
call nTECSInfo::sTECSInfo cTECSInfo;
|
|
353
|
+
[dynamic,optional]
|
|
354
|
+
call nTECSInfo::sEntryInfo cEntryInfo;
|
|
355
|
+
[dynamic,optional]
|
|
356
|
+
call nTECSInfo::sSignatureInfo cSignatureInfo;
|
|
357
|
+
[dynamic,optional]
|
|
358
|
+
call nTECSInfo::sRawEntryDescriptorInfo cRawEntryDescriptorInfo;
|
|
359
|
+
attr {
|
|
360
|
+
[omit]
|
|
361
|
+
char_t *VMname = "VM";
|
|
362
|
+
[omit]
|
|
363
|
+
char_t *bridgeName = C_EXP( "$cell$" );
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
// bridge initializer celltype
|
|
367
|
+
celltype #{@init_celltype_name} {
|
|
368
|
+
entry nMruby::sInitializeTECSBridge eInitialize;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// Bridge Cell
|
|
373
|
+
cell nMrubyInfo::t#{@signature.get_global_name} MrubyInfoBridge_#{@signature.get_global_name} {
|
|
374
|
+
// cTECS = Sample.eEnt;
|
|
375
|
+
cTECSInfo = TECSInfo.eTECSInfo;
|
|
376
|
+
// bridgeName = "Simple";
|
|
377
|
+
};
|
|
378
|
+
EOT
|
|
379
|
+
|
|
380
|
+
# 構造体セルタイプの生成
|
|
381
|
+
@struct_list.each{ |name, sttype|
|
|
382
|
+
if @@struct_list[ name ] == nil then
|
|
383
|
+
file.print <<EOT
|
|
384
|
+
namespace nMrubyInfo{
|
|
385
|
+
[singleton]
|
|
386
|
+
celltype #{name} {
|
|
387
|
+
entry sInitializeTECSBridge eInitialize;
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
EOT
|
|
391
|
+
@@struct_list[ name ] = sttype
|
|
392
|
+
end
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
else
|
|
396
|
+
cdl_info( "MRBW001 MrubyBridgePlugin: signature '$1' duplicate. ignored current one", @signature.get_namespace_path )
|
|
397
|
+
@@celltypes[ @celltype_name ] << self
|
|
398
|
+
end
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
#=== gen_cdl_file で定義したセルタイプに 新しいセルが定義された
|
|
402
|
+
# cell のセルタイプの名前は @celltype_name
|
|
403
|
+
def new_cell cell
|
|
404
|
+
if cell.get_celltype.get_name != @celltype_name then
|
|
405
|
+
return
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
join = cell.get_join_list.get_item :VMname
|
|
409
|
+
if join then
|
|
410
|
+
vm_name = CDLString.remove_dquote(join.get_rhs.to_s).to_sym
|
|
411
|
+
else
|
|
412
|
+
vm_name = :"VM"
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
if @@VM_list[ vm_name ] == nil then
|
|
416
|
+
@@VM_list[ vm_name ] = true
|
|
417
|
+
|
|
418
|
+
initializer_celltype_cdl = "#{$gen}/#{cell.get_name}Initializer.cdl"
|
|
419
|
+
file = CFile.open( initializer_celltype_cdl, "w" )
|
|
420
|
+
|
|
421
|
+
# TECS 初期化セル(プロトタイプ宣言)
|
|
422
|
+
print_msg " MrubyBridgePlugin: join your VM's cInitialize to #{vm_name}_TECSInitializer.eInitialize\n"
|
|
423
|
+
|
|
424
|
+
file.print <<EOT
|
|
425
|
+
|
|
426
|
+
// prototype of TECSInitializer (MBP510)
|
|
427
|
+
cell nMruby::tTECSInitializer #{vm_name}_TECSInitializer;
|
|
428
|
+
EOT
|
|
429
|
+
file.close
|
|
430
|
+
|
|
431
|
+
Generator.parse( initializer_celltype_cdl, self )
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
if @@VM_celltypes[ vm_name ] then
|
|
435
|
+
vma = @@VM_celltypes[ vm_name ]
|
|
436
|
+
|
|
437
|
+
if vma[ @celltype_name ] then
|
|
438
|
+
vma[ @celltype_name ] << cell
|
|
439
|
+
else
|
|
440
|
+
vma[ @celltype_name ] = [cell]
|
|
441
|
+
@@VM_celltypes[ vm_name ] = vma
|
|
442
|
+
end
|
|
443
|
+
else
|
|
444
|
+
vma = { }
|
|
445
|
+
vma[ @celltype_name ] = [cell]
|
|
446
|
+
@@VM_celltypes[ vm_name ] = vma
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
@struct_list.each{ |stname, sttype|
|
|
450
|
+
if @@VM_struct_list[ vm_name ] then
|
|
451
|
+
@@VM_struct_list[ vm_name ][ sttype.get_name ] = sttype
|
|
452
|
+
else
|
|
453
|
+
@@VM_struct_list[ vm_name ] = { sttype.get_name => sttype }
|
|
454
|
+
end
|
|
455
|
+
}
|
|
456
|
+
@ptr_list.each{ |ptr_celltype_name, tment|
|
|
457
|
+
if @@VM_ptr_list[ vm_name ] then
|
|
458
|
+
@@VM_ptr_list[ vm_name ][ ptr_celltype_name ] = tment
|
|
459
|
+
else
|
|
460
|
+
@@VM_ptr_list[ vm_name ] = { ptr_celltype_name => tment }
|
|
461
|
+
end
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
#=== プラグインが CDL の POST コードを生成
|
|
467
|
+
# tmp_plugin_post_code.cdl への出力
|
|
468
|
+
def self.gen_post_code file
|
|
469
|
+
dbgPrint "#{self.name}: gen_post_code\n"
|
|
470
|
+
if ! @@b_gen_post_code_by_dependent then
|
|
471
|
+
gen_post_code_body file
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
def self.set_gen_post_code_by_dependent # by MrubyBriddeCellPlugin
|
|
476
|
+
dbgPrint "#{self.name}: set_gen_post_code_by_dependent\n"
|
|
477
|
+
@@b_gen_post_code_by_dependent = true
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
def self.gen_post_code_body file
|
|
481
|
+
dbgPrint "#{self.name}: gen_post_code_body\n"
|
|
482
|
+
|
|
483
|
+
file.print "\n // MrubyBridgeSignaturePlugin: MBP601\n"
|
|
484
|
+
@@VM_celltypes.each{ |vm_name, instance_list|
|
|
485
|
+
instance_list.each { |celltype_name, array|
|
|
486
|
+
cell = array[0]
|
|
487
|
+
if cell.get_celltype then
|
|
488
|
+
ct_name = cell.get_celltype.get_name
|
|
489
|
+
file.print <<EOT
|
|
490
|
+
cell nMrubyInfo::#{ct_name}_Initializer #{vm_name}_#{ct_name}_Initializer{ };
|
|
491
|
+
EOT
|
|
492
|
+
end
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
file.print " // MBP602\n"
|
|
497
|
+
@@ptr_list.each{ |name,tment|
|
|
498
|
+
file.print <<EOT
|
|
499
|
+
cell nMruby::#{name} C#{name} { };
|
|
500
|
+
EOT
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
file.print " // MBP603\n"
|
|
504
|
+
@@struct_list.each{ |name,sttype|
|
|
505
|
+
file.print <<EOT
|
|
506
|
+
cell nMruby::#{name} C#{name} { };
|
|
507
|
+
EOT
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
if @@VM_celltypes == nil
|
|
511
|
+
raise "MrubyBridgeSignaturePlugin: are0"
|
|
512
|
+
end
|
|
513
|
+
@@VM_celltypes.each{ |vm_name, instance_list|
|
|
514
|
+
file.print " /* === VM name is '#{vm_name}' === (MBP610) */\n"
|
|
515
|
+
init_cell_name = "#{vm_name}_TECSInitializer"
|
|
516
|
+
|
|
517
|
+
file.print " cell nMruby::tTECSInitializer #{init_cell_name} {\n"
|
|
518
|
+
|
|
519
|
+
instance_list.each { |celltype_name, array|
|
|
520
|
+
ct_name = celltype_name
|
|
521
|
+
file.print " cInitialize[] = #{vm_name}_#{ct_name}_Initializer.eInitialize;\n"
|
|
522
|
+
}
|
|
523
|
+
if @@VM_ptr_list[vm_name] then
|
|
524
|
+
@@VM_ptr_list[vm_name].each{ |name, tment|
|
|
525
|
+
file.print " cInitialize[] = C#{name}.eInitialize;\n"
|
|
526
|
+
}
|
|
527
|
+
end
|
|
528
|
+
if @@VM_struct_list[vm_name] then
|
|
529
|
+
@@VM_struct_list[vm_name].each{ |name, sttype|
|
|
530
|
+
file.print " cInitialize[] = C#{name}.eInitialize;\n"
|
|
531
|
+
}
|
|
532
|
+
end
|
|
533
|
+
file.print " };"
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
####### 以下コード生成段階 ######
|
|
539
|
+
|
|
540
|
+
#=== 受け口関数の本体コードを生成(頭部と末尾は別途出力)
|
|
541
|
+
#ct_name:: Symbol (プラグインで生成された) セルタイプ名 .Symbol として送られてくる
|
|
542
|
+
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 )
|
|
543
|
+
if @@celltypes[ ct_name ] then
|
|
544
|
+
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 )
|
|
545
|
+
elsif @@init_celltypes[ ct_name ] then
|
|
546
|
+
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 )
|
|
547
|
+
elsif @@ptr_list[ ct_name ] then
|
|
548
|
+
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 )
|
|
549
|
+
elsif @@struct_list[ ct_name ] then
|
|
550
|
+
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 )
|
|
551
|
+
else
|
|
552
|
+
raise "MrubyBridgeSignaturePlugin: Unknown #{ct_name}"
|
|
553
|
+
end
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
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 )
|
|
557
|
+
raise "MrubyBridgeSignaturePlugin: unexpected "
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
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 )
|
|
561
|
+
file.print <<EOT
|
|
562
|
+
// CELLCB *p_cellcb = GET_CELLCB( idx ); /* no error check */ /* MBP700 */
|
|
563
|
+
struct RClass *rc;
|
|
564
|
+
|
|
565
|
+
rc = mrb_define_class_under( mrb, TECS, \"#{@class_name}\", mrb->object_class );
|
|
566
|
+
mrb_define_method( mrb, rc, "initialize", MrubyBridge_#{@celltype_name}_initialize, MRB_ARGS_REQ(1) );
|
|
567
|
+
MRB_SET_INSTANCE_TT(rc, MRB_TT_DATA);
|
|
568
|
+
EOT
|
|
569
|
+
|
|
570
|
+
@func_head_array.each{ |f|
|
|
571
|
+
if ! f.is_function? then
|
|
572
|
+
next
|
|
573
|
+
end
|
|
574
|
+
if f.get_name != :initialize then
|
|
575
|
+
func_name = f.get_name
|
|
576
|
+
else
|
|
577
|
+
func_name = :initialize_cell
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
ret_type = f.get_return_type
|
|
581
|
+
n_param = 0
|
|
582
|
+
f.get_paramlist.get_items.each{ |param|
|
|
583
|
+
case param.get_direction
|
|
584
|
+
when :IN, :INOUT, :OUT
|
|
585
|
+
n_param += 1
|
|
586
|
+
when :SEND, :RECEIVE
|
|
587
|
+
raise "MrubyBridgeSignaturePlugin: send, receive"
|
|
588
|
+
end
|
|
589
|
+
}
|
|
590
|
+
if n_param > 0 then
|
|
591
|
+
p_str = "MRB_ARGS_REQ( #{n_param} )"
|
|
592
|
+
else
|
|
593
|
+
p_str = "MRB_ARGS_NONE()"
|
|
594
|
+
end
|
|
595
|
+
file.print <<EOT
|
|
596
|
+
mrb_define_method( mrb, rc, "#{func_name}", MrubyBridge_#{@celltype_name}_#{func_name}, #{p_str} );
|
|
597
|
+
EOT
|
|
598
|
+
}
|
|
599
|
+
end
|
|
600
|
+
|
|
601
|
+
#=== 受け口関数の preamble (C言語)を生成する
|
|
602
|
+
# 必要なら preamble 部に出力する
|
|
603
|
+
#file:: FILE 出力先ファイル
|
|
604
|
+
#b_singleton:: bool true if singleton
|
|
605
|
+
#ct_name:: Symbol
|
|
606
|
+
#global_ct_name:: string
|
|
607
|
+
def gen_preamble( file, b_singleton, ct_name, global_ct_name )
|
|
608
|
+
if @@celltypes[ ct_name ] then
|
|
609
|
+
gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )
|
|
610
|
+
gen_preamble_instance( file, b_singleton, ct_name, global_ct_name )
|
|
611
|
+
gen_preamble_instance_initialize( file, b_singleton, ct_name, global_ct_name )
|
|
612
|
+
gen_preamble_bridge_func( file, b_singleton, ct_name, global_ct_name )
|
|
613
|
+
elsif @@init_celltypes[ ct_name ] then
|
|
614
|
+
gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )
|
|
615
|
+
gen_preamble_instance_proto( file, b_singleton, ct_name, global_ct_name )
|
|
616
|
+
elsif @@ptr_list[ ct_name ] then
|
|
617
|
+
gen_preamble_ptr( file, b_singleton, ct_name, global_ct_name )
|
|
618
|
+
elsif @@struct_list[ ct_name ] then
|
|
619
|
+
gen_preamble_struct( file, b_singleton, ct_name, global_ct_name )
|
|
620
|
+
else
|
|
621
|
+
raise "MrubyBridgeSignaturePlugin: MrubyBridgeSignaturePlugin: Unknown #{ct_name}"
|
|
622
|
+
end
|
|
623
|
+
end
|
|
624
|
+
|
|
625
|
+
def gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )
|
|
626
|
+
file.print <<EOT
|
|
627
|
+
/* MBP: MrubyBridgePlugin: MBP000 */
|
|
628
|
+
#include "mruby.h"
|
|
629
|
+
#include "mruby/class.h"
|
|
630
|
+
#include "mruby/data.h"
|
|
631
|
+
#include "mruby/string.h"
|
|
632
|
+
#include "TECSPointer.h"
|
|
633
|
+
#include "TECSStruct.h"
|
|
634
|
+
#include "t_syslog.h"
|
|
635
|
+
|
|
636
|
+
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
|
637
|
+
#define DLLEXPORT __declspec(dllexport)
|
|
638
|
+
#else
|
|
639
|
+
#define DLLEXPORT
|
|
640
|
+
#endif
|
|
641
|
+
|
|
642
|
+
#ifndef NULL
|
|
643
|
+
#define NULL 0
|
|
644
|
+
#endif
|
|
645
|
+
EOT
|
|
646
|
+
end
|
|
647
|
+
|
|
648
|
+
def gen_preamble_instance( file, b_singleton, ct_name, global_ct_name )
|
|
649
|
+
# 「#1005 MrubyBridgePlugin-test のビルドに失敗」にて追加
|
|
650
|
+
# 「#1004 idx_is_id が true の場合(domain の場合は未指定でも true) の CBP のプロトタイプ宣言」にて不要になる見込み
|
|
651
|
+
nsp = NamespacePath.new( :nMrubyInfo, true )
|
|
652
|
+
nsp.append! ct_name
|
|
653
|
+
ct = Namespace.find nsp
|
|
654
|
+
if ct.idx_is_id_act? then
|
|
655
|
+
if ct.has_CB? then
|
|
656
|
+
inib_cb = "CB"
|
|
657
|
+
elsif ct.has_INIB? then
|
|
658
|
+
inib_cb = "INIB"
|
|
659
|
+
else
|
|
660
|
+
inib_cb = nil
|
|
661
|
+
end
|
|
662
|
+
if inib_cb then
|
|
663
|
+
ct.get_cell_list.each{ |cell|
|
|
664
|
+
if cell.is_generate? then
|
|
665
|
+
name_array = ct.get_name_array( cell )
|
|
666
|
+
file.print "extern #{ct.get_global_name}_CB #{cell.get_global_name}_#{inib_cb};\n"
|
|
667
|
+
end
|
|
668
|
+
}
|
|
669
|
+
end
|
|
670
|
+
end
|
|
671
|
+
|
|
672
|
+
file.print <<EOT
|
|
673
|
+
|
|
674
|
+
/* RData MBP001 */
|
|
675
|
+
static void
|
|
676
|
+
#{@celltype_name}_free( mrb_state *mrb, void *p )
|
|
677
|
+
{
|
|
678
|
+
if( p )
|
|
679
|
+
(void)mrb_free( mrb, p );
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/* RData MBP002 */
|
|
683
|
+
struct mrb_data_type data_type_#{@celltype_name} =
|
|
684
|
+
{
|
|
685
|
+
"#{@celltype_name}",
|
|
686
|
+
#{@celltype_name}_free
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
/* RData MBP003 */
|
|
690
|
+
struct tecs_#{@celltype_name} {
|
|
691
|
+
Descriptor( #{@signature.get_global_name} ) desc;
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
#ifndef MRUBYINFOBRIDGE_NAME_LEN
|
|
695
|
+
#define MRUBYINFOBRIDGE_NAME_LEN 256
|
|
696
|
+
#endif
|
|
697
|
+
EOT
|
|
698
|
+
end
|
|
699
|
+
|
|
700
|
+
def gen_preamble_instance_proto( file, b_singleton, ct_name, global_ct_name )
|
|
701
|
+
file.print <<EOT
|
|
702
|
+
// Prototype MBP400
|
|
703
|
+
mrb_value MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self);
|
|
704
|
+
EOT
|
|
705
|
+
|
|
706
|
+
@func_head_array.each{ |f|
|
|
707
|
+
if ! f.is_function? then
|
|
708
|
+
next
|
|
709
|
+
end
|
|
710
|
+
if f.get_name != :initialize then
|
|
711
|
+
func_name = f.get_name
|
|
712
|
+
else
|
|
713
|
+
func_name = :initialize_cell
|
|
714
|
+
end
|
|
715
|
+
|
|
716
|
+
ret_type = f.get_return_type
|
|
717
|
+
ret_type0 = f.get_return_type.get_original_type
|
|
718
|
+
b_void = ret_type0.is_void?
|
|
719
|
+
plist = f.get_paramlist.get_items
|
|
720
|
+
|
|
721
|
+
file.print <<EOT
|
|
722
|
+
mrb_value MrubyBridge_#{@celltype_name}_#{func_name}( mrb_state *mrb, mrb_value self );
|
|
723
|
+
EOT
|
|
724
|
+
}
|
|
725
|
+
end
|
|
726
|
+
|
|
727
|
+
def gen_preamble_instance_initialize( file, b_singleton, ct_name, global_ct_name )
|
|
728
|
+
file.print <<EOT
|
|
729
|
+
|
|
730
|
+
/* MBP100 */
|
|
731
|
+
mrb_value
|
|
732
|
+
MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self)
|
|
733
|
+
{
|
|
734
|
+
mrb_value name;
|
|
735
|
+
struct tecs_#{@celltype_name} *tecs_desc;
|
|
736
|
+
Descriptor( nTECSInfo_sRawEntryDescriptorInfo ) rawEntryDescDesc;
|
|
737
|
+
Descriptor( nTECSInfo_sEntryInfo ) entryDesc;
|
|
738
|
+
Descriptor( nTECSInfo_sSignatureInfo ) signatureDesc;
|
|
739
|
+
Descriptor( #{@signature.get_global_name} ) cellEntryDesc;
|
|
740
|
+
char_t tecs_name[ MRUBYINFOBRIDGE_NAME_LEN ];
|
|
741
|
+
void *rawDesc;
|
|
742
|
+
|
|
743
|
+
/* set DATA_TYPE earlier to avoid SEGV */
|
|
744
|
+
DATA_TYPE( self ) = &data_type_#{@celltype_name};
|
|
745
|
+
|
|
746
|
+
mrb_get_args(mrb, "o", &name );
|
|
747
|
+
if( mrb_type( name ) != MRB_TT_STRING ){
|
|
748
|
+
mrb_raise(mrb, E_NAME_ERROR, "cell name not string");
|
|
749
|
+
}
|
|
750
|
+
if( cTECSInfo_findRawEntryDescriptor( RSTRING_PTR( name ), 0, &rawEntryDescDesc, &entryDesc ) != E_OK ){
|
|
751
|
+
mrb_raise( mrb, E_ARGUMENT_ERROR, "MrubyInfoBridgeSignaturePlugin: path not found" );
|
|
752
|
+
}
|
|
753
|
+
else{
|
|
754
|
+
syslog( LOG_NOTICE, "MrubyInfoBridgePlugin: %s: found", RSTRING_PTR( name ) );
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// retrieve Signature Name from EntryInfo to check
|
|
758
|
+
cEntryInfo_set_descriptor( entryDesc );
|
|
759
|
+
cEntryInfo_getSignatureInfo( &signatureDesc );
|
|
760
|
+
cSignatureInfo_set_descriptor( signatureDesc );
|
|
761
|
+
cSignatureInfo_getName( tecs_name, MRUBYINFOBRIDGE_NAME_LEN );
|
|
762
|
+
if( strncmp( tecs_name, "#{@signature.get_name}", MRUBYINFOBRIDGE_NAME_LEN ) != 0 ){
|
|
763
|
+
mrb_raise( mrb, E_ARGUMENT_ERROR, "MrubyInfoBridgeSignaturePlugin: signature name mismatch" );
|
|
764
|
+
}
|
|
765
|
+
else{
|
|
766
|
+
syslog( LOG_NOTICE, "MrubyInfoBridgePlugin: signature name matched: %s", "#{@signature.get_name}" );
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// retrieve Cell's Entry Descriptor
|
|
770
|
+
cRawEntryDescriptorInfo_set_descriptor( rawEntryDescDesc );
|
|
771
|
+
cRawEntryDescriptorInfo_getRawDescriptor( 0, &rawDesc );
|
|
772
|
+
cellEntryDesc.vdes = (struct tag_#{@signature.get_global_name}_VDES *)rawDesc;
|
|
773
|
+
|
|
774
|
+
tecs_desc = (struct tecs_#{@celltype_name} *)mrb_malloc(mrb, sizeof(struct tecs_#{@celltype_name}) );
|
|
775
|
+
tecs_desc->desc = cellEntryDesc;
|
|
776
|
+
DATA_PTR( self ) = (void *)tecs_desc;
|
|
777
|
+
|
|
778
|
+
return self;
|
|
779
|
+
}
|
|
780
|
+
EOT
|
|
781
|
+
end
|
|
782
|
+
|
|
783
|
+
def gen_preamble_bridge_func( file, b_singleton, ct_name, global_ct_name )
|
|
784
|
+
|
|
785
|
+
@func_head_array.each{ |f|
|
|
786
|
+
if ! f.is_function? then
|
|
787
|
+
next
|
|
788
|
+
end
|
|
789
|
+
if f.get_name != :initialize then
|
|
790
|
+
func_name = f.get_name
|
|
791
|
+
else
|
|
792
|
+
func_name = :initialize_cell
|
|
793
|
+
end
|
|
794
|
+
|
|
795
|
+
ret_type = f.get_return_type
|
|
796
|
+
ret_type0 = f.get_return_type.get_original_type
|
|
797
|
+
b_void = ret_type0.is_void?
|
|
798
|
+
plist = f.get_paramlist.get_items
|
|
799
|
+
|
|
800
|
+
file.print <<EOT
|
|
801
|
+
|
|
802
|
+
/* bridge function (MBP101) */
|
|
803
|
+
mrb_value
|
|
804
|
+
MrubyBridge_#{ct_name}_#{func_name}( mrb_state *mrb, mrb_value self )
|
|
805
|
+
{
|
|
806
|
+
/* cellcbp (MBP105) */
|
|
807
|
+
// CELLCB *p_cellcb = ((struct tecs_#{@celltype_name} *)DATA_PTR(self))->cbp;
|
|
808
|
+
EOT
|
|
809
|
+
|
|
810
|
+
file.print " /* variables for return & parameter (MBP110) */\n"
|
|
811
|
+
if ! b_void then
|
|
812
|
+
file.print " ", ret_type.get_type_str, "\tret_val", ret_type.get_type_str_post, ";\n"
|
|
813
|
+
end
|
|
814
|
+
arg_str = ""
|
|
815
|
+
n_param = 0
|
|
816
|
+
n_scalar = 0
|
|
817
|
+
n_ptr = 0
|
|
818
|
+
n_struct = 0
|
|
819
|
+
plist.each{ |param|
|
|
820
|
+
case param.get_direction
|
|
821
|
+
when :IN, :INOUT, :OUT
|
|
822
|
+
type = param.get_type.get_original_type
|
|
823
|
+
case type
|
|
824
|
+
when IntType
|
|
825
|
+
file.print " mrb_int mrb_", param.get_name, ";\n"
|
|
826
|
+
file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"
|
|
827
|
+
arg_str += "i"
|
|
828
|
+
n_param += 1
|
|
829
|
+
n_scalar += 1
|
|
830
|
+
when FloatType
|
|
831
|
+
file.print " mrb_float mrb_", param.get_name, ";\n"
|
|
832
|
+
file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"
|
|
833
|
+
arg_str += "f"
|
|
834
|
+
n_param += 1
|
|
835
|
+
n_scalar += 1
|
|
836
|
+
when BoolType
|
|
837
|
+
file.print " mrb_value mrb_", param.get_name, ";\n"
|
|
838
|
+
file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"
|
|
839
|
+
arg_str += "o"
|
|
840
|
+
n_param += 1
|
|
841
|
+
n_scalar += 1
|
|
842
|
+
when PtrType
|
|
843
|
+
file.print " mrb_value mrb_", param.get_name, ";\n"
|
|
844
|
+
file.print " #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post};\n"
|
|
845
|
+
arg_str += "o"
|
|
846
|
+
n_param += 1
|
|
847
|
+
n_ptr += 1
|
|
848
|
+
when StructType
|
|
849
|
+
file.print " mrb_value mrb_", param.get_name, ";\n"
|
|
850
|
+
file.print " #{param.get_type.get_type_str} *#{param.get_name}#{param.get_type.get_type_str_post};\n"
|
|
851
|
+
arg_str += "o"
|
|
852
|
+
n_param += 1
|
|
853
|
+
n_struct += 1
|
|
854
|
+
else
|
|
855
|
+
raise "MrubyBridgeSignaturePlugin: Unknown type"
|
|
856
|
+
end
|
|
857
|
+
end
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
if n_param > 0 then
|
|
861
|
+
file.print " /* retrieve arguments (MBP111) */\n"
|
|
862
|
+
file.print " mrb_get_args(mrb, \"#{arg_str}\""
|
|
863
|
+
plist.each{ |param|
|
|
864
|
+
case param.get_direction
|
|
865
|
+
when :IN, :INOUT, :OUT
|
|
866
|
+
type = param.get_type.get_original_type
|
|
867
|
+
case type
|
|
868
|
+
when IntType
|
|
869
|
+
file.print ", &mrb_", param.get_name
|
|
870
|
+
when FloatType
|
|
871
|
+
file.print ", &mrb_", param.get_name
|
|
872
|
+
when BoolType
|
|
873
|
+
file.print ", &mrb_", param.get_name
|
|
874
|
+
when PtrType
|
|
875
|
+
file.print ", &mrb_", param.get_name
|
|
876
|
+
when StructType
|
|
877
|
+
file.print ", &mrb_", param.get_name
|
|
878
|
+
else
|
|
879
|
+
raise "MrubyBridgeSignaturePlugin: Unknown type"
|
|
880
|
+
end
|
|
881
|
+
end
|
|
882
|
+
}
|
|
883
|
+
file.print " );\n"
|
|
884
|
+
|
|
885
|
+
if n_scalar > 0 || n_struct > 0 then
|
|
886
|
+
file.print " /* convert mrb to C (MBP112) */\n"
|
|
887
|
+
end
|
|
888
|
+
plist.each{ |param|
|
|
889
|
+
case param.get_direction
|
|
890
|
+
when :IN, :INOUT, :OUT
|
|
891
|
+
type = param.get_type.get_original_type
|
|
892
|
+
case type
|
|
893
|
+
when IntType
|
|
894
|
+
ttype = type.get_original_type
|
|
895
|
+
tment = get_type_map_ent ttype
|
|
896
|
+
file.print " VALCHECK_#{tment[1]}( mrb, mrb_#{param.get_name} );\n"
|
|
897
|
+
file.print " #{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"
|
|
898
|
+
when FloatType
|
|
899
|
+
file.print " #{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"
|
|
900
|
+
when BoolType
|
|
901
|
+
file.print " #{param.get_name} = mrb_test( mrb_#{param.get_name} );\n"
|
|
902
|
+
when PtrType
|
|
903
|
+
ttype = type.get_type.get_original_type
|
|
904
|
+
case ttype
|
|
905
|
+
when StructType
|
|
906
|
+
file.print " CHECK_STRUCT( #{ttype.get_name}, mrb_#{param.get_name} );\n"
|
|
907
|
+
file.print " #{param.get_name} = (struct #{ttype.get_name}*)DATA_PTR(mrb_#{param.get_name});\n"
|
|
908
|
+
when IntType
|
|
909
|
+
when FloatType
|
|
910
|
+
when BoolType
|
|
911
|
+
else
|
|
912
|
+
raise "MrubyBridgeSignaturePlugin: cannot handle type"
|
|
913
|
+
end
|
|
914
|
+
when StructType
|
|
915
|
+
file.print " CHECK_STRUCT( #{type.get_name}, mrb_#{param.get_name} );\n"
|
|
916
|
+
file.print " #{param.get_name} = (struct #{type.get_name}*)DATA_PTR(mrb_#{param.get_name});\n"
|
|
917
|
+
else
|
|
918
|
+
raise( "MrubyBridgeSignaturePlugin: canot treat class" )
|
|
919
|
+
end
|
|
920
|
+
end
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
if n_ptr > 0 then
|
|
924
|
+
file.print " /* convert mrb to C for pointer types (MBP113) */\n"
|
|
925
|
+
end
|
|
926
|
+
plist.each{ |param|
|
|
927
|
+
case param.get_direction
|
|
928
|
+
when :IN, :INOUT, :OUT
|
|
929
|
+
type = param.get_type.get_original_type
|
|
930
|
+
case type
|
|
931
|
+
when IntType
|
|
932
|
+
when FloatType
|
|
933
|
+
when BoolType
|
|
934
|
+
when PtrType
|
|
935
|
+
case type.get_type.get_original_type
|
|
936
|
+
when StructType
|
|
937
|
+
when IntType
|
|
938
|
+
ptrMrb2C file, type, param
|
|
939
|
+
when FloatType
|
|
940
|
+
ptrMrb2C file, type, param
|
|
941
|
+
when BoolType
|
|
942
|
+
ptrMrb2C file, type, param
|
|
943
|
+
else
|
|
944
|
+
raise "MrubyBridgeSignaturePlugin: cannot handle type"
|
|
945
|
+
end
|
|
946
|
+
when StructType
|
|
947
|
+
else
|
|
948
|
+
raise( "MrubyBridgeSignaturePlugin: canot treat class" )
|
|
949
|
+
end
|
|
950
|
+
end
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
end
|
|
954
|
+
|
|
955
|
+
file.print <<EOT
|
|
956
|
+
/* calling target (MBP120) */
|
|
957
|
+
cTECS_set_descriptor( ((struct tecs_tsSample *)DATA_PTR(self))->desc );
|
|
958
|
+
EOT
|
|
959
|
+
if ! b_void then
|
|
960
|
+
file.print " ret_val = "
|
|
961
|
+
else
|
|
962
|
+
file.print " "
|
|
963
|
+
end
|
|
964
|
+
delim = ""
|
|
965
|
+
file.print "cTECS_", f.get_name, "( "
|
|
966
|
+
plist.each{ |param|
|
|
967
|
+
if param.get_type.get_original_type.kind_of? StructType then
|
|
968
|
+
aster = "*"
|
|
969
|
+
else
|
|
970
|
+
aster = ""
|
|
971
|
+
end
|
|
972
|
+
file.print delim, aster, param.get_name
|
|
973
|
+
delim = ", "
|
|
974
|
+
}
|
|
975
|
+
file.print " );\n"
|
|
976
|
+
|
|
977
|
+
file.print " /* return (MBP130) */\n"
|
|
978
|
+
case ret_type0
|
|
979
|
+
when BoolType
|
|
980
|
+
file.print " return ret_val ? mrb_true_value() : mrb_false_value();\n"
|
|
981
|
+
when IntType
|
|
982
|
+
file.print " return mrb_fixnum_value( ret_val );\n"
|
|
983
|
+
when FloatType
|
|
984
|
+
file.print " return mrb_float_value( mrb, ret_val );\n"
|
|
985
|
+
when VoidType
|
|
986
|
+
file.print " return mrb_nil_value();\n"
|
|
987
|
+
else
|
|
988
|
+
raise "MrubyBridgeSignaturePlugin: unknown type"
|
|
989
|
+
end
|
|
990
|
+
|
|
991
|
+
file.print "}\n"
|
|
992
|
+
}
|
|
993
|
+
end
|
|
994
|
+
end
|