source: EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb@ 270

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

mruby版ECNLプロトタイピング・ツールを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-ruby
File size: 22.4 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# TECS Generator
4# Generator for TOPPERS Embedded Component System
5#
6# Copyright (C) 2008-2014 by TOPPERS Project
7#--
8# 上記著作権者
9は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
10# ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
11# 変・再é…
12å¸ƒï¼ˆä»¥ä¸‹ï¼Œåˆ©ç”¨ã¨å‘¼ã¶ï¼‰ã™ã‚‹ã“とを無償で許諾する.
13# (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
14# 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
15# スコード中に含まれていること.
16# (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
17# 用できる形で再é…
18å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œå†é…
19å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨
20# 者
21マニュアルなど)に,上記の著作権表示,この利用条件および下記
22# の無保証規定を掲載すること.
23# (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
24# 用できない形で再é…
25å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œæ¬¡ã®ã„ずれかの条件を満たすこ
26# と.
27# (a) 再é…
28å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨è€…
29マニュアルなど)に,上記の著
30# 作権表示,この利用条件および下記の無保証規定を掲載すること.
31# (b) 再é…
32å¸ƒã®å½¢æ…
33‹ã‚’,別に定める方法によって,TOPPERSプロジェクトに
34# 報告すること.
35# (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
36# 害からも,上記著作権者
37およびTOPPERSプロジェクトをå…
38è²¬ã™ã‚‹ã“と.
39# また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
40# 由に基づく請求からも,上記著作権者
41およびTOPPERSプロジェクトを
42# å…
43è²¬ã™ã‚‹ã“と.
44#
45# 本ソフトウェアは,無保証で提供されているものである.上記著作権者
46お
47# よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
48# に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
49# アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
50# の責任を負わない.
51#
52# $Id: GenTransparentMarshaler.rb 1011 2016-07-11 02:20:01Z coas-nagasima $
53#++
54
55#プラグインオプション用変数
56#@task_priority:: Integer
57#@channelCelltype:: String
58#@channelCellName:: String
59#@PPAllocatorSize:: Integer
60module GenTransparentMarshaler
61
62 # プラグイン引数名と Proc
63 RPCPluginArgProc = {
64 "taskPriority" => Proc.new { |obj,rhs| obj.set_taskPriority rhs },
65 "channelCelltype" => Proc.new { |obj,rhs| obj.set_channelCelltype rhs },
66 "TDRCelltype" => Proc.new { |obj,rhs| obj.set_TDRCelltype rhs },
67 "channelCell" => Proc.new { |obj,rhs| obj.set_channelCellName rhs },
68 "PPAllocatorSize" => Proc.new { |obj,rhs| obj.set_PPAllocatorSize rhs },
69 }
70
71 #=== プラグイン引数 taskPriority のチェック
72 def set_taskPriority( rhs )
73 @task_priority = rhs
74 end
75
76 #=== プラグイン引数 channelCelltype のチェック
77 def set_channelCelltype( rhs )
78 @channelCelltype = rhs.to_sym
79 # path = [ "::", @channelCelltype ]
80 # obj = Namespace.find( path )
81 nsp = NamespacePath.analyze( @channelCelltype.to_s )
82 obj = Namespace.find( nsp )
83 if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
84 cdl_error( "RPCPlugin: channeclCelltype '#{rhs}' not celltype or not found" )
85 end
86 end
87
88 #=== プラグイン引数 TDRCelltype のチェック
89 def set_TDRCelltype( rhs )
90 @TDRCelltype = rhs.to_sym
91 # path = [ "::", @TDRCelltype ]
92 # obj = Namespace.find( path )
93 nsp = NamespacePath.analyze( @TDRCelltype.to_s )
94 obj = Namespace.find( nsp )
95 if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
96 cdl_error( "RPCPlugin: TDRCelltype '#{rhs}' not celltype or not found" )
97 end
98 end
99
100 #=== プラグイン引数 channelCellName のチェック
101 def set_channelCellName( rhs )
102 @channelCellName = rhs
103 if @channelCellName =~ /\A[a-zA-Z_]\w*/ then
104 # OK
105 else
106 cdl_error( "RPCPlugin: channeclCellName '#{rhs}' unsuitable for identifier" )
107 end
108 end
109
110 #=== プラグイン引数 PPAllocatorSize のチェック
111 def set_PPAllocatorSize( rhs )
112 @PPAllocatorSize = rhs
113 end
114
115 #=== marshaler のセルタイプ名を設定する
116 def initialize_transparent_marshaler cell_name
117 @task_priority = 8
118 @channelCelltype = "tDataqueueOWChannel"
119 @TDRCelltype = "tTDR"
120 @channelCellName = "#{cell_name}_Channel"
121 @PPAllocatorSize = nil
122
123 @marshaler_celltype_name = "tMarshaler_#{@signature.get_global_name}"
124 @unmarshaler_celltype_name = "tUnmarshaler_#{@signature.get_global_name}"
125 @marshaler_celltype_file_name = "#{$gen}/#{@marshaler_celltype_name}.cdl"
126 end
127
128 def gen_marshaler_celltype
129
130 if @PPAllocatorSize then
131 alloc_call_port = " call sPPAllocator cPPAllocator;\n"
132 else
133 alloc_call_port = ""
134 end
135
136 f = CFile.open( @marshaler_celltype_file_name, "w" )
137 # 同じ内
138容を二度書く可能性あり (AppFile は不可)
139
140 f.print <<EOT
141
142celltype #{@marshaler_celltype_name} {
143 entry #{@signature.get_namespace_path} eClientEntry;
144 call sTDR cTDR;
145 call sEventflag cEventflag;
146 [optional]
147 call sSemaphore cLockChannel; // this port is eliminated by optimize
148};
149celltype #{@unmarshaler_celltype_name} {
150 call #{@signature.get_namespace_path} cServerCall;
151 call sTDR cTDR;
152 call sEventflag cEventflag;
153 entry sUnmarshalerMain eUnmarshalAndCallFunction;
154#{alloc_call_port}};
155EOT
156 f.close
157 end
158
159 #=== 受け口関数の本体コードを生成(頭部と末尾は別途出力)
160 #ct_name:: Symbol (through プラグインで生成された) セルタイプ名 .Symbol として送られてくる(らしい)
161 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 )
162
163 # unmarshaler クラスか?
164 if ct_name == @unmarshaler_celltype_name.to_sym then
165 gen_ep_func_body_unmarshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
166 else
167 gen_ep_func_body_marshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
168 end
169 end
170
171 #=== marshal コードの生成
172 def gen_ep_func_body_marshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
173
174 b_void = false
175 b_ret_er = false
176
177 # 関数の戻り値のå…
178ƒã®åž‹ã‚’å¾—ã‚‹(typedef されている場合)
179 type = func_type.get_type.get_original_type
180
181 # 戻り値記憶用の変数を出力(void 型の関数では出力しない)
182 if ! type.is_void? then
183 if func_type.get_type.kind_of?( DefinedType ) && ( func_type.get_type.get_type_str == "ER" || func_type.get_type.get_type_str == "ER_INT" ) then
184 file.print( " #{func_type.get_type.get_type_str} retval_ = E_OK;\n" )
185 b_ret_er = true
186 else
187 file.print( " #{func_type.get_type.get_type_str} retval_;\n" )
188 end
189 else
190 b_void = true
191 end
192
193 file.print( " ER ercd_;\n" )
194 file.print( " FLGPTN flgptn;\n" )
195
196 # 呼びå…
197ˆã® signature を取り出す
198 signature = @signature
199
200 # 関数 ID (整数値)
201 func_id = signature.get_id_from_func_name( func_name )
202 file.print( " int16_t func_id_ = #{func_id}; /* id of #{func_name}: #{func_id} */\n" )
203
204 # シングルトンでないか?
205 if ! b_singleton then
206
207 # singleton でなければ p_cellcb 取得コードを出力
208 file.print <<EOT
209 #{ct_name}_CB *p_cellcb;
210
211 if( VALID_IDX( idx ) ){
212 p_cellcb = GET_CELLCB(idx);
213EOT
214
215 # エラーを返すか?
216 if b_ret_er then
217 file.print <<EOT
218 }else{
219 return ERCD( E_RPC, E_ID );
220 }
221EOT
222 else
223 file.print <<EOT
224 }else{
225 /* エラー処理コードをここに記述 */
226 }
227EOT
228 end
229 end
230
231 # channel lock コード
232 file.print <<EOT
233 /* Channel Lock */
234 if( is_cLockChannel_joined() )
235 cLockChannel_wait();
236
237EOT
238
239 # SOP を送信
240 file.print " /* SOPの送出 */\n"
241 file.print " if( ( ercd_ = cTDR_sendSOP( true ) ) != E_OK )\n"
242 file.print " goto error_reset;\n"
243
244 # func_id を送信
245 file.print " /* 関数 id の送出 */\n"
246 file.print " if( ( ercd_ = cTDR_putInt16( func_id_ ) ) != E_OK )\n"
247 file.print " goto error_reset;\n"
248
249 # p "celltype_name, sig_name, func_name, func_global_name"
250 # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
251
252 b_get = false # marshal なら put
253 b_marshal = true # marshal
254
255 # in 方向のå…
256¥å‡ºåŠ›ã‚’出力
257 file.print " /* å…
258¥åŠ›å¼•æ•°é€å‡º */\n"
259 print_params( params, file, 1, b_marshal, b_get, true, func_type.is_oneway? )
260 print_params( params, file, 1, b_marshal, b_get, false, func_type.is_oneway? )
261 if ! b_void && ! func_type.is_oneway? then
262 ret_ptr_type = PtrType.new( func_type.get_type )
263 print_param_nc( "retval_", ret_ptr_type, file, 1, :RETURN, "&", nil, b_get )
264 end
265
266 file.print " /* EOPの送出(パケットの掃きだし) */\n"
267 if ! func_type.is_oneway? then
268 b_continue = "true"
269 else
270 b_continue = "false"
271 end
272 file.print " if( (ercd_=cTDR_sendEOP(#{b_continue})) != E_OK )\n"
273 file.print " goto error_reset;\n\n"
274
275 if ! func_type.is_oneway? then
276 file.print <<EOT
277 if( (ercd_=cEventflag_wait( 0x01, TWF_ANDW, &flgptn )) != E_OK ){
278 ercd_ = ERCD(E_RPC,ercd_);
279 goto error_reset;
280 }
281 if( (ercd_=cEventflag_clear( 0x00 ) ) != E_OK ){
282 ercd_ = ERCD(E_RPC,ercd_);
283 goto error_reset;
284 }
285EOT
286 end # ! func_type.is_oneway?
287
288 file.print <<EOT
289 /* Channel Lock */
290 if( is_cLockChannel_joined() )
291 cLockChannel_signal();
292EOT
293
294 if( b_void == false )then
295 # 呼びå…
296ƒã«æˆ»ã‚Šå€¤ã‚’リターン
297 file.print( " return retval_;\n" )
298 else
299 file.print( " return;\n" )
300 end
301
302 file.print <<EOT
303
304error_reset:
305 if( ercd_ != ERCD( E_RPC, E_RESET ) )
306 (void)cTDR_reset();
307EOT
308
309 # channel lock コード
310 file.print <<EOT
311 /* Channel Lock */
312 if( is_cLockChannel_joined() )
313 cLockChannel_signal();
314
315EOT
316
317 if( b_ret_er != false )then
318 # 呼びå…
319ƒã«æˆ»ã‚Šå€¤ã‚’リターン
320 file.print( " return ercd_;\n" )
321 else
322 file.print( " return;\n" )
323 end
324
325 end
326
327 #=== unmarshal コードの生成
328 def gen_ep_func_body_unmarshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
329
330# b_ret_er = true
331 b_ret_er = false
332
333 # func_id を得るコードを生成
334 file.print <<EOT
335
336 int16_t func_id_;
337 ER ercd_;
338
339 #{ct_name}_CB *p_cellcb;
340
341 if( VALID_IDX( idx ) ){
342 p_cellcb = GET_CELLCB(idx);
343EOT
344
345 if b_ret_er then
346 file.print <<EOT
347 }else{
348 return ERCD( E_RPC, E_ID );
349 }
350EOT
351 else
352 file.print <<EOT
353 }else{
354 /* エラー処理コードをここに記述 */
355 }
356EOT
357 end
358
359 file.print <<EOT
360
361 /* SOPのチェック */
362 if( (ercd_=cTDR_receiveSOP( false )) != E_OK )
363 goto error_reset;
364 /* func_id の取得 */
365 if( (ercd_=cTDR_getInt16( &func_id_ )) != E_OK )
366 goto error_reset;
367
368#ifdef RPC_DEBUG
369 syslog(LOG_INFO, "unmarshaler task: func_id: %d", func_id_ );
370#endif
371 switch( func_id_ ){
372EOT
373
374 # 呼びå…
375ˆã® signature を取り出す
376 # port = @celltype.find( @next_cell_port_name )
377 # signature = port.get_signature
378 signature = @signature
379
380 # through の signature に含まれる すべての関数について
381 signature.get_function_head_array.each { |f|
382 f_name = f.get_name
383 f_type = f.get_declarator.get_type
384 id = signature.get_id_from_func_name( f_name )
385
386 # 関数は返り値を持つか?
387 if f_type.get_type.is_void? then
388 b_void = true
389 else
390 b_void = false
391 end
392
393 # パケットの終わりをチェック(未受け取りのデータが残っていないかチェック)
394 file.print " case #{id}: /*** #{f_name} ***/ \n"
395 file.print " if( tTransparentUnmarshaler_#{@signature.get_global_name}_#{f_name}() != E_OK )\n"
396 file.print " goto error_reset;\n"
397 file.print " break;\n"
398
399 } #
400
401 if @PPAllocatorSize then
402 ppallocator_dealloc_str = " /* PPAllocator のすべてを解放 */\n cPPAllocator_dealloc_all();"
403 else
404 ppallocator_dealloc_str = ""
405 end
406
407
408 file.print <<EOT
409 default:
410 syslog(LOG_INFO, "unmarshaler task: ERROR: unknown func_id: %d", func_id_ );
411 };
412#{ppallocator_dealloc_str}
413 return;
414
415error_reset:
416 if( ercd_ != ERCD( E_RPC, E_RESET ) )
417 (void)cTDR_reset();
418#{ppallocator_dealloc_str}
419EOT
420
421 end
422
423 # IN b_marshal, b_get
424 # b_marshal = true && b_get == false : マーシャラでå…
425¥åŠ›å¼•æ•°é€å‡º
426 # b_marshal = true && b_get == true : マーシャラで出力引数受取
427 # b_marshal = false && b_get == true : アンマーシャラでå…
428¥åŠ›å¼•æ•°å—取
429 # b_marshal = false && b_get == get : アンマーシャラで出力引数送出
430 def print_params( params, file, nest, b_marshal, b_get, b_referenced, b_oneway = false )
431 params.each{ |param|
432# p "#{param.get_name}: b_marshal: #{b_marshal} b_get: #{b_get}"
433 if ! ( b_referenced == param.is_referenced? ) then
434 next
435 end
436
437 dir = param.get_direction
438 type = param.get_type
439 if b_oneway && dir == :IN && type.get_original_type.kind_of?( PtrType ) || type.get_original_type.kind_of?( ArrayType ) then
440 # oneway, in, PtrType の場合コピー
441 alloc_cp = "cPPAllocator_alloc"
442 alloc_cp_extra = nil
443 print_param( param.get_name, type, file, nest, dir, nil, nil, b_marshal, b_get, alloc_cp, alloc_cp_extra )
444 else
445 if( b_get == false && b_marshal == true || b_get == true && b_marshal == false )then
446 case dir
447# when :IN, :INOUT, :SEND
448 when :IN, :INOUT, :OUT, :SEND, :RECEIVE
449 print_param_nc( param.get_name, type, file, nest, b_marshal, nil, nil, b_get )
450 end
451 else
452# case dir
453# when :OUT, :INOUT, :RECEIVE
454# when :RECEIVE
455# print_param_nc( param.get_name, type, file, nest, b_marshal, nil, nil, b_get )
456# end
457 end
458 end
459 }
460 end
461
462 #=== コピーしない引数渡しコードの出力
463 def print_param_nc( name, type, file, nest, b_marshal, outer, outer2, b_get )
464 indent = " " * ( nest + 1 )
465
466 case type
467 when DefinedType
468 print_param_nc( name, type.get_type, file, nest, b_marshal, outer, outer2, b_get )
469 when BoolType, IntType, FloatType, PtrType, ArrayType
470 case type
471 when BoolType
472 type_str = "Int8"
473 cast_str = "int8_t"
474 when IntType
475 bit_size = type.get_bit_size
476 case type.get_sign
477 when :UNSIGNED
478 signC = "U"
479 sign = "u"
480 when :SIGNED
481 if bit_size == -1 || bit_size == -11 then
482 # signed char の場合、signed を指定する
483 signC = "S"
484 sign = "s"
485 else
486 signC = ""
487 sign = ""
488 end
489 else
490 signC = ""
491 sign = ""
492 end
493
494 # p "pn:: #{name} #{bit_size} #{type.get_type_str}"
495 case bit_size
496 when -1, -11 # -1: char_t, -11: char
497 type_str = "#{signC}Char"
498 cast_str = "#{sign}char_t"
499 when -2
500 type_str = "#{signC}Short"
501 cast_str = "#{sign}short_t"
502 when -3
503 type_str = "#{signC}Int"
504 cast_str = "#{sign}int_t"
505 when -4
506 type_str = "#{signC}Long"
507 cast_str = "#{sign}long_t"
508 when -5
509 type_str = "Intptr"
510 cast_str = "intptr_t"
511 when 8, 16, 32, 64, 128
512 type_str = "#{signC}Int#{bit_size}"
513 cast_str = "#{sign}int#{bit_size}_t"
514 else
515 raise "unknown bit_size '#{bit_size}' for int type "
516 end
517
518 when FloatType
519 bit_size = type.get_bit_size
520 if bit_size == 32 then
521 type_str = "Float32"
522 cast_str = "float32_t"
523 else
524 type_str = "Double64"
525 cast_str = "double64_t"
526 end
527
528 when PtrType
529 type_str = "Intptr"
530 cast_str = "intptr_t"
531 when ArrayType
532 type_str = "Intptr"
533 cast_str = "intptr_t"
534 end
535
536 if type.get_type_str == cast_str then
537 cast_str = ""
538 else
539 cast_str = "(" + cast_str + ")"
540 end
541
542 if( b_get )then
543 cast_str.gsub!( /\)$/, "*)" )
544 file.print " " * nest
545 file.print "if( ( ercd_ = cTDR_get#{type_str}( #{cast_str}&(#{outer}#{name}#{outer2}) ) ) != E_OK )\n"
546 file.print " " * nest
547 file.print " goto error_reset;\n"
548 else
549 file.print " " * nest
550 file.print "if( ( ercd_ = cTDR_put#{type_str}( #{cast_str}#{outer}#{name}#{outer2} ) ) != E_OK )\n"
551 file.print " " * nest
552 file.print " goto error_reset;\n"
553 end
554
555 when StructType
556 members_decl =type.get_members_decl
557 members_decl.get_items.each { |m|
558 if m.is_referenced? then
559 print_param_nc( m.get_name, m.get_type, file, nest, b_marshal, "#{outer}#{name}#{outer2}.", nil, b_get )
560 end
561 }
562 members_decl.get_items.each { |m|
563 if ! m.is_referenced? then
564 print_param_nc( m.get_name, m.get_type, file, nest, b_marshal, "#{outer}#{name}#{outer2}.", nil, b_get )
565 end
566 }
567
568 when VoidType
569 when EnumType # mikan EnumType
570 when FuncType # mikan FuncType
571 end
572 end
573
574
575 #=== PREAMBLE 部のコード生成
576 # アンマーシャラセルタイプの場合、アンマーシャラ関数のプロトタイプ宣言を生成
577 def gen_preamble file, b_singleton, ct_name, global_name
578 if ct_name != @unmarshaler_celltype_name.to_sym then
579 return
580 end
581
582 file.print "/* アンマーシャラ関数のプロトタイプ宣言 */\n"
583 # signature に含まれる すべての関数について
584 @signature.get_function_head_array.each { |f|
585 f_name = f.get_name
586 f_type = f.get_declarator.get_type
587 id = @signature.get_id_from_func_name( f_name )
588 file.print "static ER tTransparentUnmarshaler_#{@signature.get_global_name}_#{f_name}();\t/* func_id: #{id} */\n"
589 }
590 file.print "\n"
591 end
592
593 #=== POSTAMBLE 部のコード生成
594 # アンマーシャラセルタイプの場合、アンマーシャラ関数の生成
595 def gen_postamble file, b_singleton, ct_name, global_name
596 if ct_name != @unmarshaler_celltype_name.to_sym then
597 return
598 end
599
600 file.print "\n/*** アンマーシャラ関数 ***/\n\n"
601 @signature.get_function_head_array.each { |f|
602 f_name = f.get_name
603 f_type = f.get_declarator.get_type
604 id = @signature.get_id_from_func_name( f_name )
605
606 # 関数は返り値を持つか?
607 if f_type.get_type.is_void? then
608 b_void = true
609 else
610 b_void = false
611 end
612
613 file.print <<EOT
614/*
615 * name: #{f_name}
616 * func_id: #{id}
617 */
618EOT
619 file.print "static ER\n"
620 file.print "tTransparentUnmarshaler_#{@signature.get_global_name}_#{f_name}()\n"
621 file.print "{\n"
622 file.print " ER ercd_;\n"
623 file.print " CELLCB *p_cellcb;\n"
624
625 # 引数を受取る変数の定義
626 param_list = f.get_declarator.get_type.get_paramlist.get_items
627 # FuncHead-> Decl-> FuncType->ParamList
628 param_list.each{ |par|
629 name = par.get_name
630 type = par.get_type
631 if type.kind_of? ArrayType then
632 type = type.get_type
633 aster = "(*"
634 aster2 = ")"
635 else
636 aster = ""
637 aster2 = ""
638 end
639
640 type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" を外す
641
642 file.printf( " %-12s %s%s%s%s;\n", type_str, aster, name, aster2, type.get_type_str_post )
643 }
644
645 # 戻り値を受け取る変数の定義
646 if ! b_void then
647 if f.is_oneway? then
648 retval_ptr = "" # oneway の場合、受け取るが捨てられる
649 else
650 retval_ptr = "*"
651 end
652 file.printf( " %-12s #{retval_ptr}retval_%s;\n", f_type.get_type.get_type_str, f_type.get_type.get_type_str_post )
653 end
654
655 # in 方向のå…
656¥å‡ºåŠ›ã‚’å…
657¥åŠ›
658 file.print "\n /* å…
659¥åŠ›å¼•æ•°å—取 */\n"
660 b_get = true # unmarshal では get
661 b_marshal = false
662 print_params( param_list, file, 1, b_marshal, b_get, true, f.is_oneway? )
663 print_params( param_list, file, 1, b_marshal, b_get, false, f.is_oneway? )
664 if ! b_void && ! f.is_oneway? then
665 ret_ptr_type = PtrType.new( f_type.get_type )
666 print_param_nc( "retval_", ret_ptr_type, file, 2, :RETURN, nil, nil, b_get )
667 end
668
669 # パケットの受信完了
670 # mikan 本当は、対象関数を呼出す後に実施したい.呼出しパケットの使用終わりを宣言する目的として
671 file.print " /* パケット終わりをチェック */\n"
672 if ! f.is_oneway? then
673 b_continue = "true"
674 else
675 b_continue = "false"
676 end
677 file.print " if( (ercd_=cTDR_receiveEOP(#{b_continue})) != E_OK )\n"
678 file.print " goto error_reset;\n\n"
679
680 # 対象関数を呼出す
681 file.print " /* 対象関数の呼出し */\n"
682 if b_void then
683 file.print( " cServerCall_#{f_name}(" )
684 else
685 file.print( " #{retval_ptr}retval_ = cServerCall_#{f_name}(" )
686 end
687
688 delim = " "
689 param_list.each{ |par|
690 file.print delim
691 delim = ", "
692 file.print "#{par.get_name}"
693 }
694 file.print( " );\n" )
695
696 # 戻り値、出力引数の受取コードの生成
697
698 # oneway の場合出力、戻り値が無く、受取を待
699たない(非同期な呼出し)
700 if ! f.is_oneway? then
701 file.print <<EOT
702 /* 関数処理の終了を通知 */
703 if( ( ercd_ = cEventflag_set( 0x01 ) ) != E_OK ){
704 goto error_reset;
705 }
706EOT
707 end # ! f.is_oneway?
708 file.print <<EOT
709 return E_OK;
710error_reset:
711 return ercd_;
712}
713
714EOT
715
716 }
717
718 end
719
720end
Note: See TracBrowser for help on using the repository browser.