- Timestamp:
- May 22, 2019, 10:03:37 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb
-
Property svn:mime-type
changed from
text/x-ruby
totext/x-ruby;charset=UTF-8
r388 r389 6 6 # Copyright (C) 2008-2018 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 37 # $Id$ … … 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 … … 492 470 EOT 493 471 494 # SOP ãéä¿¡495 file.print " /* SOP ã®éåº*/\n"472 # SOP を送信 473 file.print " /* SOPの送出 */\n" 496 474 file.print " SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_SOP );\n" 497 475 file.print " if( ( ercd_ = cTDR_sendSOP( true ) ) != E_OK )\n" 498 476 file.print " goto error_reset;\n" 499 477 500 # func_id ãéä¿¡501 file.print " /* é¢æ° id ã®éåº*/\n"478 # func_id を送信 479 file.print " /* 関数 id の送出 */\n" 502 480 file.print " if( ( ercd_ = cTDR_putInt16( func_id_ ) ) != E_OK )\n" 503 481 file.print " goto error_reset;\n" … … 506 484 # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}" 507 485 508 b_get = false # marshal ãªãput486 b_get = false # marshal なら put 509 487 b_marshal = true # marshal 510 488 511 # in æ¹åã®å 512 ¥åºåãåºå 489 # in 方向の入出力を出力 513 490 if func_type.has_inward? then 514 file.print " /* å 515 ¥åå¼æ°éåº */\n" 491 file.print " /* 入力引数送出 */\n" 516 492 file.print " SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_BODY );\n" 517 493 print_params( params, file, 1, b_marshal, b_get, true, "eClientEntry", func_name ) … … 525 501 b_continue = "false" 526 502 end 527 file.print " /* EOP ã®éåºï¼ãã±ããã®æãã ãï¼*/\n"503 file.print " /* EOPの送出(パケットの掃きだし) */\n" 528 504 file.print " SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_EOP );\n" 529 505 file.print " if( (ercd_=cTDR_sendEOP(#{b_continue})) != E_OK )\n" 530 506 file.print " goto error_reset;\n\n" 531 507 532 # send ã®ã¡ã¢ãªããã¢ãã±ã¼ã508 # send のメモリをデアロケート 533 509 if func_type.has_send? then 534 510 file.print " /* dealloc send parameter while executing */\n" … … 541 517 if ! func_type.is_oneway? then 542 518 543 file.print " /* ãã±ããã®å§ã¾ãããã§ãã¯*/\n"519 file.print " /* パケットの始まりをチェック */\n" 544 520 file.print " SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_SOP );\n" 545 521 file.print " if( (ercd_=cTDR_receiveSOP( true )) != E_OK )\n" 546 522 file.print " goto error_reset;\n" 547 523 548 b_get = true # marshaler ã¯get549 file.print " /* æ»ãå¤ã®åãåã*/\n"524 b_get = true # marshaler は get 525 file.print " /* 戻り値の受け取り */\n" 550 526 print_param( "retval_", func_type.get_type, file, 1, :RETURN, nil, nil, b_marshal, b_get ) 551 527 … … 559 535 indent = " " * indent_level 560 536 561 file.print "#{indent}/* åºåå¤ã®åãåã*/\n"537 file.print "#{indent}/* 出力値の受け取り */\n" 562 538 file.print "#{indent}SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_BODY );\n" 563 539 print_params( params, file, indent_level, b_marshal, b_get, true, "eClientEntry", func_name ) … … 569 545 end 570 546 571 file.print "\n /* ãã±ããã®çµããããã§ãã¯*/\n"547 file.print "\n /* パケットの終わりをチェック */\n" 572 548 file.print " SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_EOP );\n" 573 549 file.print " if( (ercd_=cTDR_receiveEOP(false)) != E_OK )\n" # b_continue = false … … 576 552 end # ! func_type.is_oneway? 577 553 578 # channel lock ã³ã¼ã554 # channel lock コード 579 555 file.print <<EOT 580 556 /* Channel Unlock */ … … 593 569 594 570 if( b_void == false )then 595 # å¼ã³å 596 ã«æ»ãå¤ããªã¿ã¼ã³ 571 # 呼び元に戻り値をリターン 597 572 file.print( " return retval_;\n" ) 598 573 else … … 604 579 error_reset: 605 580 EOT 606 # send ã®ã¡ã¢ãªããã¢ãã±ã¼ã581 # send のメモリをデアロケート 607 582 if func_type.has_send? then 608 583 file.print " /* dealloc send parameter */\n" … … 613 588 end 614 589 615 # receive ã®ã¡ã¢ãªããã¢ãã±ã¼ã590 # receive のメモリをデアロケート 616 591 if func_type.has_receive? then 617 592 file.print( " /* receive parameter */\n" ) … … 625 600 EOT 626 601 627 # channel lock ã³ã¼ã602 # channel lock コード 628 603 file.print <<EOT 629 604 /* Channel Unlock */ … … 636 611 637 612 if( b_ret_er != false )then 638 # å¼ã³å 639 ã«æ»ãå¤ããªã¿ã¼ã³ 613 # 呼び元に戻り値をリターン 640 614 file.print( " return ERCD( E_RPC, MERCD( ercd_ ) );\n" ) 641 615 else … … 645 619 end 646 620 647 #=== unmarshal ã³ã¼ãã®çæ621 #=== unmarshal コードの生成 648 622 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 ) 649 623 650 624 b_ret_er = true 651 625 652 # func_id ãå¾ãã³ã¼ããçæ626 # func_id を得るコードを生成 653 627 file.print <<EOT 654 628 … … 672 646 file.print <<EOT 673 647 }else{ 674 /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿°*/648 /* エラー処理コードをここに記述 */ 675 649 } 676 650 EOT … … 683 657 #endif 684 658 685 /* SOP ã®ãã§ãã¯*/659 /* SOPのチェック */ 686 660 SET_RPC_STATE( state_, RPCSTATE_SERVER_RECV_SOP ); 687 661 if( (ercd_=cTDR_receiveSOP( false )) != E_OK ) 688 662 goto error_reset; 689 /* func_id ã®åå¾*/663 /* func_id の取得 */ 690 664 if( (ercd_=cTDR_getInt16( &func_id_ )) != E_OK ) 691 665 goto error_reset; … … 697 671 EOT 698 672 699 # signature ã«å«ã¾ãã ãã¹ã¦ã®é¢æ°ã«ã¤ãã¦673 # signature に含まれる すべての関数について 700 674 @signature.get_function_head_array.each { |f| 701 675 f_name = f.get_name … … 711 685 712 686 if @PPAllocatorSize then 713 ppallocator_dealloc_str = " /* PPAllocator ã®ãã¹ã¦ã解æ¾*/\n cPPAllocator_dealloc_all();"687 ppallocator_dealloc_str = " /* PPAllocator のすべてを解放 */\n cPPAllocator_dealloc_all();" 714 688 else 715 689 ppallocator_dealloc_str = "" … … 734 708 end 735 709 736 #=== PREAMBLE é¨ã®ã³ã¼ãçæ737 # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ãã®å ´åãã¢ã³ãã¼ã·ã£ã©é¢æ°ã®ãããã¿ã¤ã宣è¨ãçæ710 #=== PREAMBLE 部のコード生成 711 # アンマーシャラセルタイプの場合、アンマーシャラ関数のプロトタイプ宣言を生成 738 712 def gen_preamble file, b_singleton, ct_name, global_name 739 713 if ct_name != @unmarshaler_celltype_name.to_sym then … … 741 715 end 742 716 743 # string.h ã® include (memset, strlen ã®ãã)717 # string.h の include (memset, strlen のため) 744 718 file.print "/* header file (strlen, memset) */\n" 745 719 file.print "#include\t<string.h>\n\n" 746 720 747 file.print "/* ã¢ã³ãã¼ã·ã£ã©é¢æ°ã®ãããã¿ã¤ã宣è¨*/\n"748 # signature ã«å«ã¾ãã ãã¹ã¦ã®é¢æ°ã«ã¤ãã¦721 file.print "/* アンマーシャラ関数のプロトタイプ宣言 */\n" 722 # signature に含まれる すべての関数について 749 723 @signature.get_function_head_array.each { |f| 750 724 f_name = f.get_name … … 756 730 end 757 731 758 #=== POSTAMBLE é¨ã®ã³ã¼ãçæ 759 # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ãã®å ´åãåã 760 ã®ã¢ã³ãã¼ã·ã£ã©é¢æ°ã®çæ 732 #=== POSTAMBLE 部のコード生成 733 # アンマーシャラセルタイプの場合、個々のアンマーシャラ関数の生成 761 734 def gen_postamble file, b_singleton, ct_name, global_name 762 735 if ct_name != @unmarshaler_celltype_name.to_sym then … … 764 737 end 765 738 766 file.print "\n/*** ã¢ã³ãã¼ã·ã£ã©é¢æ°***/\n\n"739 file.print "\n/*** アンマーシャラ関数 ***/\n\n" 767 740 @signature.get_function_head_array.each { |f| 768 741 f_name = f.get_name … … 770 743 id = @signature.get_id_from_func_name( f_name ) 771 744 772 # é¢æ°ã¯è¿ãå¤ãæã¤ã?745 # 関数は返り値を持つか? 773 746 b_ret_er = false 774 747 init_retval = "" … … 794 767 file.print " ER ercd_;\n" 795 768 796 # å¼æ°ãååãå¤æ°ã®å®ç¾©769 # 引数を受取る変数の定義 797 770 params = f.get_declarator.get_type.get_paramlist.get_items 798 771 # FuncHead-> Decl-> FuncType->ParamList … … 803 776 dir = par.get_direction 804 777 if( dir == :RECEIVE )then 805 # type 㯠PtrType ã§ããããåãé¤ããå778 # type は PtrType で、それを取り除いた型 806 779 type = type.get_type 807 780 end … … 821 794 end 822 795 823 type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" ãå¤ã796 type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" を外す 824 797 file.printf( " %-12s %s%s%s%s%s;\n", type_str, aster, name, aster2, type.get_type_str_post, init ) 825 798 … … 833 806 end 834 807 835 # in æ¹åã®å 836 ¥åºåãå 837 ¥å 838 file.print "\n /* å 839 ¥åå¼æ°åå */\n" 808 # in 方向の入出力を入力 809 file.print "\n /* 入力引数受取 */\n" 840 810 file.print " SET_RPC_STATE( *state_, RPCSTATE_SERVER_RECV_BODY );\n" 841 b_get = true # unmarshal ã§ã¯get811 b_get = true # unmarshal では get 842 812 b_marshal = false 843 813 print_params( params, file, 1, b_marshal, b_get, true, "cServerCall", f_name ) … … 846 816 847 817 848 # ãã±ããã®åä¿¡å®äº849 file.print " /* ãã±ããçµããããã§ãã¯*/\n"818 # パケットの受信完了 819 file.print " /* パケット終わりをチェック */\n" 850 820 file.print " SET_RPC_STATE( *state_, RPCSTATE_SERVER_RECV_EOP );\n" 851 821 if ! f_type.is_oneway? then … … 857 827 file.print " goto error_reset;\n\n" 858 828 859 # out ã®ã¡ã¢ãªãã¢ãã±ã¼ã829 # out のメモリをアロケート 860 830 dir = :OUT; alloc_cp = "cPPAllocator_alloc"; alloc_cp_extra = nil; nest = 1 861 831 alloc_for_out_params( params, file, nest, dir, alloc_cp, alloc_cp_extra ) 862 832 863 # 対象é¢æ°ãå¼åºã864 file.print " /* 対象é¢æ°ã®å¼åºã*/\n"833 # 対象関数を呼出す 834 file.print " /* 対象関数の呼出し */\n" 865 835 file.print " SET_RPC_STATE( *state_, RPCSTATE_SERVER_EXEC );\n" 866 836 if b_void then … … 881 851 file.print( " );\n" ) 882 852 883 # æ»ãå¤ãåºåå¼æ°ã®ååã³ã¼ãã®çæ 884 885 # oneway ã®å ´ååºåãæ»ãå¤ãç¡ããååãå¾ 886 ããªãï¼éåæãªå¼åºãï¼ 853 # 戻り値、出力引数の受取コードの生成 854 855 # oneway の場合出力、戻り値が無く、受取を待たない(非同期な呼出し) 887 856 if ! f.is_oneway? then 888 857 889 file.print "\n /* SOP ã®éåº*/\n"858 file.print "\n /* SOPの送出 */\n" 890 859 file.print " SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_SOP );\n" 891 860 … … 893 862 file.print " goto error_reset;\n" 894 863 895 b_get = false # unmarshaler ã¯put864 b_get = false # unmarshaler は put 896 865 if( ! b_void )then 897 file.print " /* æ»ãå¤ã®éåº*/\n"866 file.print " /* 戻り値の送出 */\n" 898 867 print_param( "retval_", f_type.get_type, file, 1, :RETURN, nil, nil, b_marshal, b_get ) 899 868 end … … 908 877 indent = " " * indent_level 909 878 910 file.print "#{indent}/* åºåå¤ã®éåº*/\n"879 file.print "#{indent}/* 出力値の送出 */\n" 911 880 file.print "#{indent}SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_BODY );\n" 912 881 print_params( params, file, indent_level, b_marshal, b_get, true, "cServerCall", f_name ) 913 882 print_params( params, file, indent_level, b_marshal, b_get, false, "cServerCall", f_name ) 914 883 915 # receive ã®ã¡ã¢ãªããã¢ãã±ã¼ã884 # receive のメモリをデアロケート 916 885 if f_type.has_receive? then 917 886 file.print "#{indent}/* dealloc receive parameter */\n" … … 925 894 end 926 895 927 file.print " /* ãã±ããã®çµããï¼æãã ãï¼*/\n"896 file.print " /* パケットの終わり(掃きだし) */\n" 928 897 file.print " SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_EOP );\n" 929 898 file.print " if( (ercd_=cTDR_sendEOP(false)) != E_OK )\n" # b_continue = false … … 936 905 error_reset: 937 906 EOT 938 # send ã®ãªã»ããç¨ãã¢ãã±ã¼ã907 # send のリセット用デアロケート 939 908 if f_type.has_send? then 940 909 file.print " /* dealloc send parameter */\n" … … 945 914 end 946 915 947 # receive ã®ã¡ã¢ãªããã¢ãã±ã¼ã916 # receive のメモリをデアロケート 948 917 if f_type.has_receive? && b_ret_er then 949 918 file.print " /* dealloc receive parameter */\n" … … 957 926 file.print "}\n\n" 958 927 959 # ããï¼åã 960 ã®é¢æ°ï¼ã§ã¯ã¨ã©ã¼ãã³ãã©ã¼ã¯å¼ã³åºããªããå¼ã³å 961 ï¼ãµã¼ãã¼ã®ã¡ã¤ã³é¢æ°ï¼ã§å¼ã³åºãã 928 # ここ(個々の関数)ではエラーハンドラーは呼び出さない。呼び元(サーバーのメイン関数)で呼び出す。 962 929 } 963 930 end … … 966 933 #b_marshal:: bool 967 934 #b_get:: bool 968 # b_marshal = true && b_get == false : ãã¼ã·ã£ã©ã§å 969 ¥åå¼æ°éåº 970 # b_marshal = true && b_get == true : ãã¼ã·ã£ã©ã§åºåå¼æ°åå 971 # b_marshal = false && b_get == false : ã¢ã³ãã¼ã·ã£ã©ã§å 972 ¥åå¼æ°åå 973 # b_marshal = false && b_get == true : ã¢ã³ãã¼ã·ã£ã©ã§åºåå¼æ°éåº 974 #b_referenced:: size_is, count_is, string ã§åç 975 §ããã¦ãããã®ãåºå 935 # b_marshal = true && b_get == false : マーシャラで入力引数送出 936 # b_marshal = true && b_get == true : マーシャラで出力引数受取 937 # b_marshal = false && b_get == false : アンマーシャラで入力引数受取 938 # b_marshal = false && b_get == true : アンマーシャラで出力引数送出 939 #b_referenced:: size_is, count_is, string で参照されているものを出力 976 940 def print_params( params, file, nest, b_marshal, b_get, b_referenced, port_name, func_name ) 977 941 params.each{ |param| … … 996 960 case dir 997 961 when :OUT, :INOUT 998 alloc_cp = nil # inout ã® b_get==true&&b_marsha==true ã®ã¨ãã¢ãã±ã¼ã¿ã³ã¼ãã¯ä¸ç¨962 alloc_cp = nil # inout の b_get==true&&b_marsha==true のときアロケータコードは不用 999 963 alloc_cp_extra = nil 1000 964 print_param( param.get_name, param.get_type, file, nest, dir, nil, nil, b_marshal, b_get, alloc_cp, alloc_cp_extra ) … … 1003 967 alloc_cp_extra = nil 1004 968 if b_get then 1005 outer = "(*" # ãã¼ã·ã£ã©å´ã§ã¯ããã¤ã³ã¿ã (send ã¨æ¯ã¹) ä¸ã¤å¤ã969 outer = "(*" # マーシャラ側では、ポインタが (send と比べ) 一つ多い 1006 970 outer2 = ")" 1007 971 else 1008 outer = nil # ã¢ã³ãã¼ã·ã£ã©å´ã§ã¯ããã¤ã³ã¿ãä¸ã¤å¤ããã¦ãã972 outer = nil # アンマーシャラ側では、ポインタが一つ外されている 1009 973 outer2 = nil 1010 974 end … … 1016 980 end 1017 981 1018 #=== ã¢ãã±ã¼ã¿ã³ã¼ããçæ (out ã®ã¢ã³ãã¼ã·ã£ã©ç¨)982 #=== アロケータコードを生成 (out のアンマーシャラ用) 1019 983 def alloc_for_out_params( params, file, nest, dir, alloc_cp, alloc_cp_extra ) 1020 984 params.each{ |param| … … 1026 990 end 1027 991 1028 #=== ã¢ãã±ã¼ã¿ã³ã¼ããçæ (out ã®ã¢ã³ãã¼ã·ã£ã©ç¨åå¥ãã©ã¡ã¼ã¿ã®çæ)992 #=== アロケータコードを生成 (out のアンマーシャラ用個別パラメータの生成) 1029 993 def alloc_for_out_param( name, type, file, nest, outer, outer2, alloc_cp, alloc_cp_extra ) 1030 994 org_type = type.get_original_type … … 1039 1003 count = type.get_count; size = type.get_size; string = type.get_string 1040 1004 if count || size || string then 1041 loop_counter_type = IntType.new(16) # mikan æ¹ã size_is, count_is ã®å¼æ°ã®åã¨ãã1005 loop_counter_type = IntType.new(16) # mikan 方を size_is, count_is の引数の型とする 1042 1006 if count then 1043 1007 len = type.get_count.to_s … … 1052 1016 end 1053 1017 1054 # size_is ã« max æå®ãããå ´åãlength ã max ãè¶ 1055 ãã¦ããããã§ãã¯ããã³ã¼ããçæ 1018 # size_is に max 指定がある場合、length が max を超えているかチェックするコードを生成 1056 1019 if org_type.get_max != nil && string == nil then 1057 1020 file.print "#{indent}if( #{len} > #{type.get_max} ){\t/* GenOpaqueMarshaler max check 2 */\n" … … 1092 1055 end 1093 1056 1094 #=== å¼æ°ã®ä¸æ¬ãã¢ãã±ã¼ãã³ã¼ãã®çæ1095 # send ï¼ãã¼ã·ã£ã©ã®æå¾ãreceiveï¼ã¢ã³ãã¼ã·ã£ã©ã®æå¾ã§ä¸æ¬ãã¦å¼æ°ããã¢ãã±ã¼ããã1057 #=== 引数の一括デアロケートコードの生成 1058 # send:マーシャラの最後、receive:アンマーシャラの最後で一括して引数をデアロケートする 1096 1059 def dealloc_for_params( params, file, nest, dir, dealloc_cp, b_reset = false ) 1097 1060 if b_reset then … … 1107 1070 aster = "" 1108 1071 if dir == :RECEIVE then 1109 type = type.get_type.get_original_type # ãã¤ã³ã¿ãä¸ã¤å¤ã1072 type = type.get_type.get_original_type # ポインタを一つ外す 1110 1073 if b_reset then 1111 1074 aster = "*" … … 1128 1091 end 1129 1092 1130 #== out 㧠nullable ãªå¼æ°ã®æ 1131 å ±ã渡ã 1132 # out nullable ã®å ´åãin, send, receive ã®ããã«ãå¤ã渡ãç´åã§ã¯ãªããå¼åºãæã«æ¸¡ã 1093 #== out で nullable な引数の情報を渡す 1094 # out nullable の場合、in, send, receive のように、値を渡す直前ではなく、呼出し時に渡す 1133 1095 def print_out_nullable( params, file, nest, b_marshal ); 1134 1096 indent = "\t" * nest … … 1140 1102 file.print "#{indent}\tgoto error_reset;\n" 1141 1103 else 1142 # å¼ã³å 1143 㯠alloc_for_out_param 㧠nullable ã®å¯¾å¿ãã 1104 # 呼び先は alloc_for_out_param で nullable の対応する 1144 1105 file.print "#{indent}if( (ercd_=cTDR_getInt8( &b_#{param.get_name}_null_)) != E_OK )\n" 1145 1106 file.print "#{indent}\tgoto error_reset;\n" -
Property svn:mime-type
changed from
Note:
See TracChangeset
for help on using the changeset viewer.