source: azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb@ 388

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

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • 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$
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 E_OK;
414
415error_reset:
416 if( ercd_ != ERCD( E_RPC, E_RESET ) )
417 (void)cTDR_reset();
418#{ppallocator_dealloc_str}
419 return E_OK;
420EOT
421
422 end
423
424 # IN b_marshal, b_get
425 # b_marshal = true && b_get == false : マーシャラでå…
426¥åŠ›å¼•æ•°é€å‡º
427 # b_marshal = true && b_get == true : マーシャラで出力引数受取
428 # b_marshal = false && b_get == true : アンマーシャラでå…
429¥åŠ›å¼•æ•°å—取
430 # b_marshal = false && b_get == get : アンマーシャラで出力引数送出
431 def print_params( params, file, nest, b_marshal, b_get, b_referenced, b_oneway = false )
432 params.each{ |param|
433# p "#{param.get_name}: b_marshal: #{b_marshal} b_get: #{b_get}"
434 if ! ( b_referenced == param.is_referenced? ) then
435 next
436 end
437
438 dir = param.get_direction
439 type = param.get_type
440 if b_oneway && dir == :IN && type.get_original_type.kind_of?( PtrType ) || type.get_original_type.kind_of?( ArrayType ) then
441 # oneway, in, PtrType の場合コピー
442 alloc_cp = "cPPAllocator_alloc"
443 alloc_cp_extra = nil
444 print_param( param.get_name, type, file, nest, dir, nil, nil, b_marshal, b_get, alloc_cp, alloc_cp_extra )
445 else
446 if( b_get == false && b_marshal == true || b_get == true && b_marshal == false )then
447 case dir
448# when :IN, :INOUT, :SEND
449 when :IN, :INOUT, :OUT, :SEND, :RECEIVE
450 print_param_nc( param.get_name, type, file, nest, b_marshal, nil, nil, b_get )
451 end
452 else
453# case dir
454# when :OUT, :INOUT, :RECEIVE
455# when :RECEIVE
456# print_param_nc( param.get_name, type, file, nest, b_marshal, nil, nil, b_get )
457# end
458 end
459 end
460 }
461 end
462
463 #=== コピーしない引数渡しコードの出力
464 def print_param_nc( name, type, file, nest, b_marshal, outer, outer2, b_get )
465 indent = " " * ( nest + 1 )
466
467 case type
468 when DefinedType
469 print_param_nc( name, type.get_type, file, nest, b_marshal, outer, outer2, b_get )
470 when BoolType, IntType, FloatType, PtrType, ArrayType
471 case type
472 when BoolType
473 type_str = "Int8"
474 cast_str = "int8_t"
475 when IntType
476 bit_size = type.get_bit_size
477 case type.get_sign
478 when :UNSIGNED
479 signC = "U"
480 sign = "u"
481 when :SIGNED
482 if bit_size == -1 || bit_size == -11 then
483 # signed char の場合、signed を指定する
484 signC = "S"
485 sign = "s"
486 else
487 signC = ""
488 sign = ""
489 end
490 else
491 signC = ""
492 sign = ""
493 end
494
495 # p "pn:: #{name} #{bit_size} #{type.get_type_str}"
496 case bit_size
497 when -1, -11 # -1: char_t, -11: char
498 type_str = "#{signC}Char"
499 cast_str = "#{sign}char_t"
500 when -2
501 type_str = "#{signC}Short"
502 cast_str = "#{sign}short_t"
503 when -3
504 type_str = "#{signC}Int"
505 cast_str = "#{sign}int_t"
506 when -4
507 type_str = "#{signC}Long"
508 cast_str = "#{sign}long_t"
509 when -5
510 type_str = "Intptr"
511 cast_str = "intptr_t"
512 when 8, 16, 32, 64, 128
513 type_str = "#{signC}Int#{bit_size}"
514 cast_str = "#{sign}int#{bit_size}_t"
515 else
516 raise "unknown bit_size '#{bit_size}' for int type "
517 end
518
519 when FloatType
520 bit_size = type.get_bit_size
521 if bit_size == 32 then
522 type_str = "Float32"
523 cast_str = "float32_t"
524 else
525 type_str = "Double64"
526 cast_str = "double64_t"
527 end
528
529 when PtrType
530 type_str = "Intptr"
531 cast_str = "intptr_t"
532 when ArrayType
533 type_str = "Intptr"
534 cast_str = "intptr_t"
535 end
536
537 if type.get_type_str == cast_str then
538 cast_str = ""
539 else
540 cast_str = "(" + cast_str + ")"
541 end
542
543 if( b_get )then
544 cast_str.gsub!( /\)$/, "*)" )
545 file.print " " * nest
546 file.print "if( ( ercd_ = cTDR_get#{type_str}( #{cast_str}&(#{outer}#{name}#{outer2}) ) ) != E_OK )\n"
547 file.print " " * nest
548 file.print " goto error_reset;\n"
549 else
550 file.print " " * nest
551 file.print "if( ( ercd_ = cTDR_put#{type_str}( #{cast_str}#{outer}#{name}#{outer2} ) ) != E_OK )\n"
552 file.print " " * nest
553 file.print " goto error_reset;\n"
554 end
555
556 when StructType
557 members_decl =type.get_members_decl
558 members_decl.get_items.each { |m|
559 if m.is_referenced? then
560 print_param_nc( m.get_name, m.get_type, file, nest, b_marshal, "#{outer}#{name}#{outer2}.", nil, b_get )
561 end
562 }
563 members_decl.get_items.each { |m|
564 if ! m.is_referenced? then
565 print_param_nc( m.get_name, m.get_type, file, nest, b_marshal, "#{outer}#{name}#{outer2}.", nil, b_get )
566 end
567 }
568
569 when VoidType
570 when EnumType # mikan EnumType
571 when FuncType # mikan FuncType
572 end
573 end
574
575
576 #=== PREAMBLE 部のコード生成
577 # アンマーシャラセルタイプの場合、アンマーシャラ関数のプロトタイプ宣言を生成
578 def gen_preamble file, b_singleton, ct_name, global_name
579 if ct_name != @unmarshaler_celltype_name.to_sym then
580 return
581 end
582
583 file.print "/* アンマーシャラ関数のプロトタイプ宣言 */\n"
584 # signature に含まれる すべての関数について
585 @signature.get_function_head_array.each { |f|
586 f_name = f.get_name
587 f_type = f.get_declarator.get_type
588 id = @signature.get_id_from_func_name( f_name )
589 file.print "static ER tTransparentUnmarshaler_#{@signature.get_global_name}_#{f_name}();\t/* func_id: #{id} */\n"
590 }
591 file.print "\n"
592 end
593
594 #=== POSTAMBLE 部のコード生成
595 # アンマーシャラセルタイプの場合、アンマーシャラ関数の生成
596 def gen_postamble file, b_singleton, ct_name, global_name
597 if ct_name != @unmarshaler_celltype_name.to_sym then
598 return
599 end
600
601 file.print "\n/*** アンマーシャラ関数 ***/\n\n"
602 @signature.get_function_head_array.each { |f|
603 f_name = f.get_name
604 f_type = f.get_declarator.get_type
605 id = @signature.get_id_from_func_name( f_name )
606
607 # 関数は返り値を持つか?
608 if f_type.get_type.is_void? then
609 b_void = true
610 else
611 b_void = false
612 end
613
614 file.print <<EOT
615/*
616 * name: #{f_name}
617 * func_id: #{id}
618 */
619EOT
620 file.print "static ER\n"
621 file.print "tTransparentUnmarshaler_#{@signature.get_global_name}_#{f_name}()\n"
622 file.print "{\n"
623 file.print " ER ercd_;\n"
624 file.print " CELLCB *p_cellcb;\n"
625
626 # 引数を受取る変数の定義
627 param_list = f.get_declarator.get_type.get_paramlist.get_items
628 # FuncHead-> Decl-> FuncType->ParamList
629 param_list.each{ |par|
630 name = par.get_name
631 type = par.get_type
632 if type.kind_of? ArrayType then
633 type = type.get_type
634 aster = "(*"
635 aster2 = ")"
636 else
637 aster = ""
638 aster2 = ""
639 end
640
641 type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" を外す
642
643 file.printf( " %-12s %s%s%s%s;\n", type_str, aster, name, aster2, type.get_type_str_post )
644 }
645
646 # 戻り値を受け取る変数の定義
647 if ! b_void then
648 if f.is_oneway? then
649 retval_ptr = "" # oneway の場合、受け取るが捨てられる
650 else
651 retval_ptr = "*"
652 end
653 file.printf( " %-12s #{retval_ptr}retval_%s;\n", f_type.get_type.get_type_str, f_type.get_type.get_type_str_post )
654 end
655
656 # in 方向のå…
657¥å‡ºåŠ›ã‚’å…
658¥åŠ›
659 file.print "\n /* å…
660¥åŠ›å¼•æ•°å—取 */\n"
661 b_get = true # unmarshal では get
662 b_marshal = false
663 print_params( param_list, file, 1, b_marshal, b_get, true, f.is_oneway? )
664 print_params( param_list, file, 1, b_marshal, b_get, false, f.is_oneway? )
665 if ! b_void && ! f.is_oneway? then
666 ret_ptr_type = PtrType.new( f_type.get_type )
667 print_param_nc( "retval_", ret_ptr_type, file, 2, :RETURN, nil, nil, b_get )
668 end
669
670 # パケットの受信完了
671 # mikan 本当は、対象関数を呼出す後に実施したい.呼出しパケットの使用終わりを宣言する目的として
672 file.print " /* パケット終わりをチェック */\n"
673 if ! f.is_oneway? then
674 b_continue = "true"
675 else
676 b_continue = "false"
677 end
678 file.print " if( (ercd_=cTDR_receiveEOP(#{b_continue})) != E_OK )\n"
679 file.print " goto error_reset;\n\n"
680
681 # 対象関数を呼出す
682 file.print " /* 対象関数の呼出し */\n"
683 if b_void then
684 file.print( " cServerCall_#{f_name}(" )
685 else
686 file.print( " #{retval_ptr}retval_ = cServerCall_#{f_name}(" )
687 end
688
689 delim = " "
690 param_list.each{ |par|
691 file.print delim
692 delim = ", "
693 file.print "#{par.get_name}"
694 }
695 file.print( " );\n" )
696
697 # 戻り値、出力引数の受取コードの生成
698
699 # oneway の場合出力、戻り値が無く、受取を待
700たない(非同期な呼出し)
701 if ! f.is_oneway? then
702 file.print <<EOT
703 /* 関数処理の終了を通知 */
704 if( ( ercd_ = cEventflag_set( 0x01 ) ) != E_OK ){
705 goto error_reset;
706 }
707EOT
708 end # ! f.is_oneway?
709 file.print <<EOT
710 return E_OK;
711error_reset:
712 return ercd_;
713}
714
715EOT
716
717 }
718
719 end
720
721end
Note: See TracBrowser for help on using the repository browser.