- Timestamp:
- Aug 23, 2017, 9:27:43 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r270 r321 6 6 # Copyright (C) 2008-2014 by TOPPERS Project 7 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 責ãããã¨ï¼ 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 9 # ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 10 # 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. 11 # (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 12 # 権表示,この利用条件および下記の無保証規定が,そのままの形でソー 13 # スコード中に含まれていること. 14 # (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 15 # 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 16 # 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 17 # の無保証規定を掲載すること. 18 # (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 19 # 用できない形で再配布する場合には,次のいずれかの条件を満たすこ 20 # と. 21 # (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 22 # 作権表示,この利用条件および下記の無保証規定を掲載すること. 23 # (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに 24 # 報告すること. 25 # (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 26 # 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. 27 # また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 28 # 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 29 # 免責すること. 44 30 # 45 # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è 46 ã 47 # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç 48 # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ 49 # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã 50 # ã®è²¬ä»»ãè² ããªãï¼ 31 # 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 32 # よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 33 # に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ 34 # アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 35 # の責任を負わない. 51 36 # 52 # $Id : GenOpaqueMarshaler.rb 1011 2016-07-11 02:20:01Z coas-nagasima$37 # $Id$ 53 38 #++ 54 39 55 40 #== GenOpaqueMarshaler 56 # OpaqueRPCPlugin, sharedOpaqueRPCPlugin å 57 ±éã®è¦ç´ ãéããã¢ã¸ã¥ã¼ã« 41 # OpaqueRPCPlugin, sharedOpaqueRPCPlugin 共通の要素を集めたモジュール 58 42 module GenOpaqueMarshaler 59 43 60 # ãã©ã°ã¤ã³å¼æ°åã¨Proc44 # プラグイン引数名と Proc 61 45 RPCPluginArgProc = { 62 46 "clientChannelCelltype" => Proc.new { |obj,rhs| obj.set_clientChannelCelltype rhs }, … … 79 63 } 80 64 81 ##### ãã©ã°ã¤ã³å¼æ°ãã§ãã¯é¢æ°82 83 #=== ãã©ã°ã¤ã³å¼æ° taskPriority ã®ãã§ãã¯65 ##### プラグイン引数チェック関数 66 67 #=== プラグイン引数 taskPriority のチェック 84 68 def set_taskPriority( rhs ) 85 69 @taskPriority = rhs 86 70 end 87 71 88 #=== ãã©ã°ã¤ã³å¼æ° serverChannelCelltype ã®ãã§ãã¯72 #=== プラグイン引数 serverChannelCelltype のチェック 89 73 def set_serverChannelCelltype( rhs ) 90 74 @serverChannelCelltype = rhs.to_sym … … 98 82 end 99 83 100 #=== ãã©ã°ã¤ã³å¼æ° clientChannelCelltype ã®ãã§ãã¯84 #=== プラグイン引数 clientChannelCelltype のチェック 101 85 def set_clientChannelCelltype( rhs ) 102 86 @clientChannelCelltype = rhs.to_sym … … 110 94 end 111 95 112 #=== ãã©ã°ã¤ã³å¼æ° serverChannelCell ã®ãã§ãã¯96 #=== プラグイン引数 serverChannelCell のチェック 113 97 def set_serverChannelCell( rhs ) 114 98 @serverChannelCell = rhs.to_sym 115 # ChannelCell ã¯ãã©ã°ã¤ã³ã§çæããããããããã§ã¯ãã§ãã¯ã§ããªã99 # ChannelCell はプラグインで生成されるため、ここではチェックできない 116 100 # path = [ "::", @serverChannelCell ] 117 101 # obj = Namespace.find( path ) … … 121 105 end 122 106 123 #=== ãã©ã°ã¤ã³å¼æ° clientChannelCell ã®ãã§ãã¯107 #=== プラグイン引数 clientChannelCell のチェック 124 108 def set_clientChannelCell( rhs ) 125 109 @clientChannelCell = rhs.to_sym 126 # ChannelCell ã¯ãã©ã°ã¤ã³ã§çæããããããããã§ã¯ãã§ãã¯ã§ããªã110 # ChannelCell はプラグインで生成されるため、ここではチェックできない 127 111 # path = [ "::", @clientChannelCell ] 128 112 # obj = Namespace.find( path ) … … 132 116 end 133 117 134 #=== ãã©ã°ã¤ã³å¼æ° serverChannelInitializer ã®ãã§ãã¯118 #=== プラグイン引数 serverChannelInitializer のチェック 135 119 def set_serverChannelInitializer( rhs ) 136 120 @serverChannelInitializer = rhs.to_sym 137 121 end 138 122 139 #=== ãã©ã°ã¤ã³å¼æ° clientChannelInitializer ã®ãã§ãã¯123 #=== プラグイン引数 clientChannelInitializer のチェック 140 124 def set_clientChannelInitializer( rhs ) 141 125 @clientChannelInitializer = rhs.to_sym 142 126 end 143 127 144 #=== ã¿ã¹ã¯ã¿ã¤ã taskCellype ã®ãã§ãã¯128 #=== タスクタイプ taskCellype のチェック 145 129 def set_taskCelltype( rhs ) 146 130 @taskCelltype = rhs.to_sym … … 154 138 end 155 139 156 #=== ã¿ã¹ã¯ã¿ã¤ã stack\size ã®ãã§ãã¯140 #=== タスクタイプ stack\size のチェック 157 141 def set_stackSize( rhs ) 158 142 @stackSize = rhs 159 143 end 160 144 161 #=== ãã©ã°ã¤ã³å¼æ° PPAllocatorSize ã®ãã§ãã¯145 #=== プラグイン引数 PPAllocatorSize のチェック 162 146 def set_PPAllocatorSize( rhs ) 163 147 @PPAllocatorSize = rhs 164 148 end 165 149 166 #=== ãã©ã°ã¤ã³å¼æ° TDRCelltype ã®ãã§ãã¯150 #=== プラグイン引数 TDRCelltype のチェック 167 151 def set_TDRCelltype( rhs ) 168 152 @TDRCelltype = rhs.to_sym … … 176 160 end 177 161 178 #=== ãã©ã°ã¤ã³å¼æ° substituteAllocator ã®ãã§ãã¯179 # ãªãã·ã§ã³å¼æ°ãã以ä¸ã®å½¢å¼ã§ãããã¨ããã§ãã¯162 #=== プラグイン引数 substituteAllocator のチェック 163 # オプション引数が、以下の形式であることをチェック 180 164 # substituteAllocator(Alloc.eAlloc=>Subst.eAlloc,Alloc2.eAlloc=>Subst2.eAlloc) 181 165 def set_substituteAllocator( rhs ) 182 #str::String : ç ´å£ãããï¼ãããããæ®ãã«ãªãï¼ãstr.empty? ã§ç©ºã«ãªã£ããã¨ããã§ãã¯ã§ãã 183 #regexp::Regexp : æå¾ 184 ãããã¼ã¯ã³ã«ãããããæ£è¦è¡¨ç¾ã "\A" åºå§ãã 185 #expected::String: æå¾ 186 ãããã¼ã¯ã³ãregexp ãåºç¾ããªãã£ãå ´åã«ã¨ã©ã¼ã¡ãã»ã¼ã¸ã¨ãã¦è¡¨ç¤º 166 #str::String : 破壊される(マッチした残りになる)。str.empty? で空になったことをチェックできる 167 #regexp::Regexp : 期待するトークンにマッチする正規表現。 "\A" 出始める 168 #expected::String: 期待するトークン、regexp が出現しなかった場合にエラーメッセージとして表示 187 169 def optparse (str,regexp,expected) 188 170 str.strip! … … 198 180 ident_rexpr = /\A(\w[\w\d]*)/ 199 181 200 # "Alloc.eAlloc=>CAlloc.eAlloc" ã®å½¢å¼ã«ãªã£ã¦ãããã¨ããã§ãã¯182 # "Alloc.eAlloc=>CAlloc.eAlloc" の形式になっていることをチェック 201 183 while true 202 184 lhs_alloc_cell = optparse( opt, ident_rexpr, "allocator cell name" ) … … 221 203 break if ! rhs_alloc_ent 222 204 223 # ããã§ã¯ãå³è¾ºã®ãã§ãã¯ã¯ã§ããªããå³è¾ºã®ã»ã«ã¯åæ¹åç 224 §ã¨ãªã 205 # ここでは、右辺のチェックはできない。右辺のセルは前方参照となる 225 206 # path = [ "::", rhs_alloc_cell.to_sym ] # mikan namespace 226 207 # obj = Namespace.find( path ) … … 229 210 # else 230 211 # ct = obj.get_celltype 231 # if ct # nil ãªãæ¢ã«ã¨ã©ã¼212 # if ct # nil なら既にエラー 232 213 # ent = ct.find rhs_alloc_ent 233 214 # if ! ent.instance_of? Port || ent.get_port_type != :ENTRY || ent.get_signature == nil || ! ent.get_signature.is_allocator? … … 250 231 end 251 232 252 #=== ãã©ã°ã¤ã³å¼æ° noServerChannelOpenerCode ã®ãã§ãã¯233 #=== プラグイン引数 noServerChannelOpenerCode のチェック 253 234 def set_noServerChannelOpenerCode( rhs ) 254 235 rhs = rhs.to_sym … … 262 243 end 263 244 264 #=== ãã©ã°ã¤ã³å¼æ° clientSemaphoreCelltype ã®ãã§ãã¯245 #=== プラグイン引数 clientSemaphoreCelltype のチェック 265 246 def set_clientSemaphoreCelltype rhs 266 247 @semaphoreCelltype = rhs.to_sym … … 272 253 end 273 254 274 #=== ãã©ã°ã¤ã³å¼æ° clientSemaphoreInitializer ã®ãã§ãã¯255 #=== プラグイン引数 clientSemaphoreInitializer のチェック 275 256 def set_clientSemaphoreInitializer rhs 276 257 @semaphoreInitializer = rhs.to_sym 277 258 end 278 259 279 #=== ãã©ã°ã¤ã³å¼æ° clientErrorHandler ã®ãã§ãã¯260 #=== プラグイン引数 clientErrorHandler のチェック 280 261 def set_clientErrorHandler rhs 281 262 @clientErrorHandler = rhs.to_sym 282 263 end 283 264 284 #=== ãã©ã°ã¤ã³å¼æ° serverErrorHandler ã®ãã§ãã¯265 #=== プラグイン引数 serverErrorHandler のチェック 285 266 def set_serverErrorHandler rhs 286 267 @serverErrorHandler = rhs.to_sym … … 288 269 289 270 290 #=== ã»ã«ã®ååãå¾ã291 # ThroughPlugin::get_cell_name plugin.rb ããªã¼ãã¼ã©ã¤ã271 #=== セルの名前を得る 272 # ThroughPlugin::get_cell_name plugin.rb をオーバーライド 292 273 def get_cell_name 293 274 @cell_name … … 295 276 end 296 277 297 #=== marshaler ã®ã»ã«ã¿ã¤ãåãè¨å®ãã278 #=== marshaler のセルタイプ名を設定する 298 279 def initialize_opaque_marshaler 299 280 300 # ãªãã·ã§ã³è¨å®ãããå¤æ°ã®ããã©ã«ããè¨å®281 # オプション設定される変数のデフォルトを設定 301 282 @taskPriority = 11 302 283 @stackSize = 4096 … … 309 290 @taskCelltype = :"tTask" 310 291 @PPAllocatorSize = nil 311 # @TDRCelltype = :"tTDR" # "tNBOTDR" ã«å¤æ´ã®äºå®292 # @TDRCelltype = :"tTDR" # "tNBOTDR" に変更の予定 312 293 @TDRCelltype = :"tNBOTDR" 313 294 @substituteAllocator = {} … … 324 305 @marshaler_celltype_file_name = "#{$gen}/#{@marshaler_celltype_name}.cdl" 325 306 326 # signature ã§å¯¾å¿ã§ããªããã®ããã§ãã¯307 # signature で対応できないものをチェック 327 308 @signature.each_param{ |func_decl, param_decl| 328 309 if param_decl.get_direction == :OUT then … … 337 318 end 338 319 339 #=== GenOpaqueMarshaler# Opener Code ã®çææã®ãã§ãã¯320 #=== GenOpaqueMarshaler# Opener Code の生成時のチェック 340 321 def check_opener_code 341 # ãµã¼ãã¼ãã£ã³ãã«ã»ã«ã¿ã¤ãã entry sServerChannelOpener eOpener ãæã¤ãã©ããããã§ãã¯342 # mikan entry ã (call ã§ãªãã) ããã§ãã¯ãã¦ããªã322 # サーバーチャンネルセルタイプが entry sServerChannelOpener eOpener を持つかどうかをチェック 323 # mikan entry か (call でないか) をチェックしていない 343 324 # scct = Namespace.find ["::", @serverChannelCelltype] # mikan namespace 344 325 nsp = NamespacePath.analyze( @serverChannelCelltype.to_s ) … … 360 341 end 361 342 362 #=== GenOpaqueMarshaler# PPAllocator ã®å¿ 363 è¦æ§ããã§ãã¯ãã 343 #=== GenOpaqueMarshaler# PPAllocator の必要性をチェックする 364 344 def check_PPAllocator 365 345 if @signature.need_PPAllocator?(true) then … … 374 354 def gen_marshaler_celltype 375 355 f = CFile.open( @marshaler_celltype_file_name, "w" ) 376 # åãå 377 容ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯) 356 # 同じ内容を二度書く可能性あり (AppFile は不可) 378 357 379 358 if @PPAllocatorSize then … … 404 383 end 405 384 406 #=== åãå£é¢æ°ã®æ¬ä½ã³ã¼ããçæï¼é é¨ã¨æ«å°¾ã¯å¥éåºåï¼407 #ct_name:: Symbol (through ãã©ã°ã¤ã³ã§çæããã) ã»ã«ã¿ã¤ãå ï¼Symbol ã¨ãã¦éããã¦ããï¼ãããï¼385 #=== 受け口関数の本体コードを生成(頭部と末尾は別途出力) 386 #ct_name:: Symbol (through プラグインで生成された) セルタイプ名 .Symbol として送られてくる(らしい) 408 387 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 ) 409 388 410 # unmarshaler ã¯ã©ã¹ã?389 # unmarshaler クラスか? 411 390 if ct_name == @unmarshaler_celltype_name.to_sym then 412 391 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 ) … … 416 395 end 417 396 418 #=== marshal ã³ã¼ãã®çæ397 #=== marshal コードの生成 419 398 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 ) 420 399 … … 422 401 b_ret_er = false 423 402 424 # é¢æ°ã®æ»ãå¤ã®å 425 ã®åãå¾ã(typedef ããã¦ããå ´å) 403 # 関数の戻り値の元の型を得る(typedef されている場合) 426 404 type = func_type.get_type.get_original_type 427 405 428 # æ»ãå¤è¨æ¶ç¨ã®å¤æ°ãåºåï¼void åã®é¢æ°ã§ã¯åºåããªãï¼406 # 戻り値記憶用の変数を出力(void 型の関数では出力しない) 429 407 if ! type.is_void? then 430 408 file.print( "\t#{func_type.get_type.get_type_str}\t\tretval_;\n" ) … … 439 417 file.print( "\tint16_t\tstate_;\n" ) 440 418 441 # é¢æ° ID ï¼æ´æ°å¤ï¼419 # 関数 ID (整数値) 442 420 func_id = "FUNCID_#{@signature.get_global_name}_#{func_name}".upcase 443 421 fid = @signature.get_id_from_func_name( func_name ) 444 422 file.print( "\tint16_t\tfunc_id_ = #{func_id}; /* (id of '#{func_name}') = #{fid}*/\n" ) 445 423 446 # ã·ã³ã°ã«ãã³ã§ãªããï¼424 # シングルトンでないか? 447 425 if ! b_singleton then 448 426 449 # singleton ã§ãªããã° p_cellcb åå¾ã³ã¼ããåºå427 # singleton でなければ p_cellcb 取得コードを出力 450 428 file.print <<EOT 451 429 #{ct_name}_CB *p_cellcb; … … 455 433 EOT 456 434 457 # ã¨ã©ã¼ãè¿ããï¼435 # エラーを返すか? 458 436 if b_ret_er then 459 437 file.print <<EOT … … 465 443 file.print <<EOT 466 444 }else{ 467 /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿°*/445 /* エラー処理コードをここに記述 */ 468 446 } 469 447 … … 481 459 end 482 460 483 # channel lock ã³ã¼ã461 # channel lock コード 484 462 file.print <<EOT 485 463 … … 490 468 EOT 491 469 492 # SOP ãéä¿¡493 file.print " /* SOP ã®éåº*/\n"470 # SOP を送信 471 file.print " /* SOPの送出 */\n" 494 472 file.print " SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_SOP );\n" 495 473 file.print " if( ( ercd_ = cTDR_sendSOP( true ) ) != E_OK )\n" 496 474 file.print " goto error_reset;\n" 497 475 498 # func_id ãéä¿¡499 file.print " /* é¢æ° id ã®éåº*/\n"476 # func_id を送信 477 file.print " /* 関数 id の送出 */\n" 500 478 file.print " if( ( ercd_ = cTDR_putInt16( func_id_ ) ) != E_OK )\n" 501 479 file.print " goto error_reset;\n" … … 504 482 # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}" 505 483 506 b_get = false # marshal ãªãput484 b_get = false # marshal なら put 507 485 b_marshal = true # marshal 508 486 509 # in æ¹åã®å 510 ¥åºåãåºå 487 # in 方向の入出力を出力 511 488 if func_type.has_inward? then 512 file.print " /* å 513 ¥åå¼æ°éåº */\n" 489 file.print " /* 入力引数送出 */\n" 514 490 file.print " SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_BODY );\n" 515 491 print_params( params, file, 1, b_marshal, b_get, true, "eClientEntry", func_name ) … … 523 499 b_continue = "false" 524 500 end 525 file.print " /* EOP ã®éåºï¼ãã±ããã®æãã ãï¼*/\n"501 file.print " /* EOPの送出(パケットの掃きだし) */\n" 526 502 file.print " SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_EOP );\n" 527 503 file.print " if( (ercd_=cTDR_sendEOP(#{b_continue})) != E_OK )\n" 528 504 file.print " goto error_reset;\n\n" 529 505 530 # send ã®ã¡ã¢ãªããã¢ãã±ã¼ã506 # send のメモリをデアロケート 531 507 if func_type.has_send? then 532 508 file.print " /* dealloc send parameter while executing */\n" … … 539 515 if ! func_type.is_oneway? then 540 516 541 file.print " /* ãã±ããã®å§ã¾ãããã§ãã¯*/\n"517 file.print " /* パケットの始まりをチェック */\n" 542 518 file.print " SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_SOP );\n" 543 519 file.print " if( (ercd_=cTDR_receiveSOP( true )) != E_OK )\n" 544 520 file.print " goto error_reset;\n" 545 521 546 b_get = true # marshaler ã¯get547 file.print " /* æ»ãå¤ã®åãåã*/\n"522 b_get = true # marshaler は get 523 file.print " /* 戻り値の受け取り */\n" 548 524 print_param( "retval_", func_type.get_type, file, 1, :RETURN, nil, nil, b_marshal, b_get ) 549 525 … … 557 533 indent = " " * indent_level 558 534 559 file.print "#{indent}/* åºåå¤ã®åãåã*/\n"535 file.print "#{indent}/* 出力値の受け取り */\n" 560 536 file.print "#{indent}SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_BODY );\n" 561 537 print_params( params, file, indent_level, b_marshal, b_get, true, "eClientEntry", func_name ) … … 567 543 end 568 544 569 file.print "\n /* ãã±ããã®çµããããã§ãã¯*/\n"545 file.print "\n /* パケットの終わりをチェック */\n" 570 546 file.print " SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_EOP );\n" 571 547 file.print " if( (ercd_=cTDR_receiveEOP(false)) != E_OK )\n" # b_continue = false … … 574 550 end # ! func_type.is_oneway? 575 551 576 # channel lock ã³ã¼ã552 # channel lock コード 577 553 file.print <<EOT 578 554 /* Channel Unlock */ … … 583 559 584 560 if( b_void == false )then 585 # å¼ã³å 586 ã«æ»ãå¤ããªã¿ã¼ã³ 561 # 呼び元に戻り値をリターン 587 562 file.print( " return retval_;\n" ) 588 563 else … … 594 569 error_reset: 595 570 EOT 596 # send ã®ã¡ã¢ãªããã¢ãã±ã¼ã571 # send のメモリをデアロケート 597 572 if func_type.has_send? then 598 573 file.print " /* dealloc send parameter */\n" … … 603 578 end 604 579 605 # receive ã®ã¡ã¢ãªããã¢ãã±ã¼ã580 # receive のメモリをデアロケート 606 581 if func_type.has_receive? then 607 582 file.print( " /* receive parameter */\n" ) … … 615 590 EOT 616 591 617 # channel lock ã³ã¼ã592 # channel lock コード 618 593 file.print <<EOT 619 594 /* Channel Unlock */ … … 626 601 627 602 if( b_ret_er != false )then 628 # å¼ã³å 629 ã«æ»ãå¤ããªã¿ã¼ã³ 603 # 呼び元に戻り値をリターン 630 604 file.print( " return ERCD( E_RPC, MERCD( ercd_ ) );\n" ) 631 605 else … … 635 609 end 636 610 637 #=== unmarshal ã³ã¼ãã®çæ611 #=== unmarshal コードの生成 638 612 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 ) 639 613 640 614 b_ret_er = true 641 615 642 # func_id ãå¾ãã³ã¼ããçæ616 # func_id を得るコードを生成 643 617 file.print <<EOT 644 618 … … 662 636 file.print <<EOT 663 637 }else{ 664 /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿°*/638 /* エラー処理コードをここに記述 */ 665 639 } 666 640 EOT … … 673 647 #endif 674 648 675 /* SOP ã®ãã§ãã¯*/649 /* SOPのチェック */ 676 650 SET_RPC_STATE( state_, RPCSTATE_SERVER_RECV_SOP ); 677 651 if( (ercd_=cTDR_receiveSOP( false )) != E_OK ) 678 652 goto error_reset; 679 /* func_id ã®åå¾*/653 /* func_id の取得 */ 680 654 if( (ercd_=cTDR_getInt16( &func_id_ )) != E_OK ) 681 655 goto error_reset; … … 687 661 EOT 688 662 689 # signature ã«å«ã¾ãã ãã¹ã¦ã®é¢æ°ã«ã¤ãã¦663 # signature に含まれる すべての関数について 690 664 @signature.get_function_head_array.each { |f| 691 665 f_name = f.get_name … … 701 675 702 676 if @PPAllocatorSize then 703 ppallocator_dealloc_str = " /* PPAllocator ã®ãã¹ã¦ã解æ¾*/\n cPPAllocator_dealloc_all();"677 ppallocator_dealloc_str = " /* PPAllocator のすべてを解放 */\n cPPAllocator_dealloc_all();" 704 678 else 705 679 ppallocator_dealloc_str = "" … … 724 698 end 725 699 726 #=== PREAMBLE é¨ã®ã³ã¼ãçæ727 # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ãã®å ´åãã¢ã³ãã¼ã·ã£ã©é¢æ°ã®ãããã¿ã¤ã宣è¨ãçæ700 #=== PREAMBLE 部のコード生成 701 # アンマーシャラセルタイプの場合、アンマーシャラ関数のプロトタイプ宣言を生成 728 702 def gen_preamble file, b_singleton, ct_name, global_name 729 703 if ct_name != @unmarshaler_celltype_name.to_sym then … … 731 705 end 732 706 733 # string.h ã® include (memset, strlen ã®ãã)707 # string.h の include (memset, strlen のため) 734 708 file.print "/* header file (strlen, memset) */\n" 735 709 file.print "#include\t<string.h>\n\n" 736 710 737 file.print "/* ã¢ã³ãã¼ã·ã£ã©é¢æ°ã®ãããã¿ã¤ã宣è¨*/\n"738 # signature ã«å«ã¾ãã ãã¹ã¦ã®é¢æ°ã«ã¤ãã¦711 file.print "/* アンマーシャラ関数のプロトタイプ宣言 */\n" 712 # signature に含まれる すべての関数について 739 713 @signature.get_function_head_array.each { |f| 740 714 f_name = f.get_name … … 746 720 end 747 721 748 #=== POSTAMBLE é¨ã®ã³ã¼ãçæ 749 # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ãã®å ´åãåã 750 ã®ã¢ã³ãã¼ã·ã£ã©é¢æ°ã®çæ 722 #=== POSTAMBLE 部のコード生成 723 # アンマーシャラセルタイプの場合、個々のアンマーシャラ関数の生成 751 724 def gen_postamble file, b_singleton, ct_name, global_name 752 725 if ct_name != @unmarshaler_celltype_name.to_sym then … … 754 727 end 755 728 756 file.print "\n/*** ã¢ã³ãã¼ã·ã£ã©é¢æ°***/\n\n"729 file.print "\n/*** アンマーシャラ関数 ***/\n\n" 757 730 @signature.get_function_head_array.each { |f| 758 731 f_name = f.get_name … … 760 733 id = @signature.get_id_from_func_name( f_name ) 761 734 762 # é¢æ°ã¯è¿ãå¤ãæã¤ã?735 # 関数は返り値を持つか? 763 736 b_ret_er = false 764 737 init_retval = "" … … 784 757 file.print " ER ercd_;\n" 785 758 786 # å¼æ°ãååãå¤æ°ã®å®ç¾©759 # 引数を受取る変数の定義 787 760 params = f.get_declarator.get_type.get_paramlist.get_items 788 761 # FuncHead-> Decl-> FuncType->ParamList … … 793 766 dir = par.get_direction 794 767 if( dir == :RECEIVE )then 795 # type 㯠PtrType ã§ããããåãé¤ããå768 # type は PtrType で、それを取り除いた型 796 769 type = type.get_type 797 770 end … … 811 784 end 812 785 813 type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" ãå¤ã786 type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" を外す 814 787 file.printf( " %-12s %s%s%s%s%s;\n", type_str, aster, name, aster2, type.get_type_str_post, init ) 815 788 … … 823 796 end 824 797 825 # in æ¹åã®å 826 ¥åºåãå 827 ¥å 828 file.print "\n /* å 829 ¥åå¼æ°åå */\n" 798 # in 方向の入出力を入力 799 file.print "\n /* 入力引数受取 */\n" 830 800 file.print " SET_RPC_STATE( *state_, RPCSTATE_SERVER_RECV_BODY );\n" 831 b_get = true # unmarshal ã§ã¯get801 b_get = true # unmarshal では get 832 802 b_marshal = false 833 803 print_params( params, file, 1, b_marshal, b_get, true, "cServerCall", f_name ) … … 836 806 837 807 838 # ãã±ããã®åä¿¡å®äº839 file.print " /* ãã±ããçµããããã§ãã¯*/\n"808 # パケットの受信完了 809 file.print " /* パケット終わりをチェック */\n" 840 810 file.print " SET_RPC_STATE( *state_, RPCSTATE_SERVER_RECV_EOP );\n" 841 811 if ! f_type.is_oneway? then … … 847 817 file.print " goto error_reset;\n\n" 848 818 849 # out ã®ã¡ã¢ãªãã¢ãã±ã¼ã819 # out のメモリをアロケート 850 820 dir = :OUT; alloc_cp = "cPPAllocator_alloc"; alloc_cp_extra = nil; nest = 1 851 821 alloc_for_out_params( params, file, nest, dir, alloc_cp, alloc_cp_extra ) 852 822 853 # 対象é¢æ°ãå¼åºã854 file.print " /* 対象é¢æ°ã®å¼åºã*/\n"823 # 対象関数を呼出す 824 file.print " /* 対象関数の呼出し */\n" 855 825 file.print " SET_RPC_STATE( *state_, RPCSTATE_SERVER_EXEC );\n" 856 826 if b_void then … … 871 841 file.print( " );\n" ) 872 842 873 # æ»ãå¤ãåºåå¼æ°ã®ååã³ã¼ãã®çæ 874 875 # oneway ã®å ´ååºåãæ»ãå¤ãç¡ããååãå¾ 876 ããªãï¼éåæãªå¼åºãï¼ 843 # 戻り値、出力引数の受取コードの生成 844 845 # oneway の場合出力、戻り値が無く、受取を待たない(非同期な呼出し) 877 846 if ! f.is_oneway? then 878 847 879 file.print "\n /* SOP ã®éåº*/\n"848 file.print "\n /* SOPの送出 */\n" 880 849 file.print " SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_SOP );\n" 881 850 … … 883 852 file.print " goto error_reset;\n" 884 853 885 b_get = false # unmarshaler ã¯put854 b_get = false # unmarshaler は put 886 855 if( ! b_void )then 887 file.print " /* æ»ãå¤ã®éåº*/\n"856 file.print " /* 戻り値の送出 */\n" 888 857 print_param( "retval_", f_type.get_type, file, 1, :RETURN, nil, nil, b_marshal, b_get ) 889 858 end … … 898 867 indent = " " * indent_level 899 868 900 file.print "#{indent}/* åºåå¤ã®éåº*/\n"869 file.print "#{indent}/* 出力値の送出 */\n" 901 870 file.print "#{indent}SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_BODY );\n" 902 871 print_params( params, file, indent_level, b_marshal, b_get, true, "cServerCall", f_name ) 903 872 print_params( params, file, indent_level, b_marshal, b_get, false, "cServerCall", f_name ) 904 873 905 # receive ã®ã¡ã¢ãªããã¢ãã±ã¼ã874 # receive のメモリをデアロケート 906 875 if f_type.has_receive? then 907 876 file.print "#{indent}/* dealloc receive parameter */\n" … … 915 884 end 916 885 917 file.print " /* ãã±ããã®çµããï¼æãã ãï¼*/\n"886 file.print " /* パケットの終わり(掃きだし) */\n" 918 887 file.print " SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_EOP );\n" 919 888 file.print " if( (ercd_=cTDR_sendEOP(false)) != E_OK )\n" # b_continue = false … … 926 895 error_reset: 927 896 EOT 928 # send ã®ãªã»ããç¨ãã¢ãã±ã¼ã897 # send のリセット用デアロケート 929 898 if f_type.has_send? then 930 899 file.print " /* dealloc send parameter */\n" … … 935 904 end 936 905 937 # receive ã®ã¡ã¢ãªããã¢ãã±ã¼ã906 # receive のメモリをデアロケート 938 907 if f_type.has_receive? && b_ret_er then 939 908 file.print " /* dealloc receive parameter */\n" … … 947 916 file.print "}\n\n" 948 917 949 # ããï¼åã 950 ã®é¢æ°ï¼ã§ã¯ã¨ã©ã¼ãã³ãã©ã¼ã¯å¼ã³åºããªããå¼ã³å 951 ï¼ãµã¼ãã¼ã®ã¡ã¤ã³é¢æ°ï¼ã§å¼ã³åºãã 918 # ここ(個々の関数)ではエラーハンドラーは呼び出さない。呼び元(サーバーのメイン関数)で呼び出す。 952 919 } 953 920 end … … 956 923 #b_marshal:: bool 957 924 #b_get:: bool 958 # b_marshal = true && b_get == false : ãã¼ã·ã£ã©ã§å 959 ¥åå¼æ°éåº 960 # b_marshal = true && b_get == true : ãã¼ã·ã£ã©ã§åºåå¼æ°åå 961 # b_marshal = false && b_get == false : ã¢ã³ãã¼ã·ã£ã©ã§å 962 ¥åå¼æ°åå 963 # b_marshal = false && b_get == true : ã¢ã³ãã¼ã·ã£ã©ã§åºåå¼æ°éåº 964 #b_referenced:: size_is, count_is, string ã§åç 965 §ããã¦ãããã®ãåºå 925 # b_marshal = true && b_get == false : マーシャラで入力引数送出 926 # b_marshal = true && b_get == true : マーシャラで出力引数受取 927 # b_marshal = false && b_get == false : アンマーシャラで入力引数受取 928 # b_marshal = false && b_get == true : アンマーシャラで出力引数送出 929 #b_referenced:: size_is, count_is, string で参照されているものを出力 966 930 def print_params( params, file, nest, b_marshal, b_get, b_referenced, port_name, func_name ) 967 931 params.each{ |param| … … 986 950 case dir 987 951 when :OUT, :INOUT 988 alloc_cp = nil # inout ã® b_get==true&&b_marsha==true ã®ã¨ãã¢ãã±ã¼ã¿ã³ã¼ãã¯ä¸ç¨952 alloc_cp = nil # inout の b_get==true&&b_marsha==true のときアロケータコードは不用 989 953 alloc_cp_extra = nil 990 954 print_param( param.get_name, param.get_type, file, nest, dir, nil, nil, b_marshal, b_get, alloc_cp, alloc_cp_extra ) … … 993 957 alloc_cp_extra = nil 994 958 if b_get then 995 outer = "(*" # ãã¼ã·ã£ã©å´ã§ã¯ããã¤ã³ã¿ã (send ã¨æ¯ã¹) ä¸ã¤å¤ã959 outer = "(*" # マーシャラ側では、ポインタが (send と比べ) 一つ多い 996 960 outer2 = ")" 997 961 else 998 outer = nil # ã¢ã³ãã¼ã·ã£ã©å´ã§ã¯ããã¤ã³ã¿ãä¸ã¤å¤ããã¦ãã962 outer = nil # アンマーシャラ側では、ポインタが一つ外されている 999 963 outer2 = nil 1000 964 end … … 1006 970 end 1007 971 1008 #=== ã¢ãã±ã¼ã¿ã³ã¼ããçæ (out ã®ã¢ã³ãã¼ã·ã£ã©ç¨)972 #=== アロケータコードを生成 (out のアンマーシャラ用) 1009 973 def alloc_for_out_params( params, file, nest, dir, alloc_cp, alloc_cp_extra ) 1010 974 params.each{ |param| … … 1016 980 end 1017 981 1018 #=== ã¢ãã±ã¼ã¿ã³ã¼ããçæ (out ã®ã¢ã³ãã¼ã·ã£ã©ç¨åå¥ãã©ã¡ã¼ã¿ã®çæ)982 #=== アロケータコードを生成 (out のアンマーシャラ用個別パラメータの生成) 1019 983 def alloc_for_out_param( name, type, file, nest, outer, outer2, alloc_cp, alloc_cp_extra ) 1020 984 org_type = type.get_original_type … … 1029 993 count = type.get_count; size = type.get_size; string = type.get_string 1030 994 if count || size || string then 1031 loop_counter_type = IntType.new(16) # mikan æ¹ã size_is, count_is ã®å¼æ°ã®åã¨ãã995 loop_counter_type = IntType.new(16) # mikan 方を size_is, count_is の引数の型とする 1032 996 if count then 1033 997 len = type.get_count.to_s … … 1042 1006 end 1043 1007 1044 # size_is ã« max æå®ãããå ´åãlength ã max ãè¶ 1045 ãã¦ããããã§ãã¯ããã³ã¼ããçæ 1008 # size_is に max 指定がある場合、length が max を超えているかチェックするコードを生成 1046 1009 if org_type.get_max != nil && string == nil then 1047 1010 file.print "#{indent}if( #{len} > #{type.get_max} ){\t/* GenOpaqueMarshaler max check 2 */\n" … … 1082 1045 end 1083 1046 1084 #=== å¼æ°ã®ä¸æ¬ãã¢ãã±ã¼ãã³ã¼ãã®çæ1085 # send ï¼ãã¼ã·ã£ã©ã®æå¾ãreceiveï¼ã¢ã³ãã¼ã·ã£ã©ã®æå¾ã§ä¸æ¬ãã¦å¼æ°ããã¢ãã±ã¼ããã1047 #=== 引数の一括デアロケートコードの生成 1048 # send:マーシャラの最後、receive:アンマーシャラの最後で一括して引数をデアロケートする 1086 1049 def dealloc_for_params( params, file, nest, dir, dealloc_cp, b_reset = false ) 1087 1050 if b_reset then … … 1097 1060 aster = "" 1098 1061 if dir == :RECEIVE then 1099 type = type.get_type.get_original_type # ãã¤ã³ã¿ãä¸ã¤å¤ã1062 type = type.get_type.get_original_type # ポインタを一つ外す 1100 1063 if b_reset then 1101 1064 aster = "*" … … 1118 1081 end 1119 1082 1120 #== out 㧠nullable ãªå¼æ°ã®æ 1121 å ±ã渡ã 1122 # out nullable ã®å ´åãin, send, receive ã®ããã«ãå¤ã渡ãç´åã§ã¯ãªããå¼åºãæã«æ¸¡ã 1083 #== out で nullable な引数の情報を渡す 1084 # out nullable の場合、in, send, receive のように、値を渡す直前ではなく、呼出し時に渡す 1123 1085 def print_out_nullable( params, file, nest, b_marshal ); 1124 1086 indent = "\t" * nest … … 1130 1092 file.print "#{indent}\tgoto error_reset;\n" 1131 1093 else 1132 # å¼ã³å 1133 㯠alloc_for_out_param 㧠nullable ã®å¯¾å¿ãã 1094 # 呼び先は alloc_for_out_param で nullable の対応する 1134 1095 file.print "#{indent}if( (ercd_=cTDR_getInt8( &b_#{param.get_name}_null_)) != E_OK )\n" 1135 1096 file.print "#{indent}\tgoto error_reset;\n" -
Property svn:mime-type
changed from
Note:
See TracChangeset
for help on using the changeset viewer.