Ignore:
Timestamp:
Aug 23, 2017, 9:27:43 AM (7 years ago)
Author:
coas-nagasima
Message:

文字コードを設定

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 to text/x-ruby;charset=UTF-8
    r270 r321  
    66#   Copyright (C) 2008-2014 by TOPPERS Project
    77#--
    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#       免責すること.
    4430
    45 #   æœ¬ã‚½ãƒ•ãƒˆã‚¦ã‚§ã‚¢ã¯ï¼Œç„¡ä¿è¨¼ã§æä¾›ã•ã‚Œã¦ã„るものである.上記著作権è€
    46 ãŠ
    47 #   ã‚ˆã³TOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
    48 #   ã«å¯¾ã™ã‚‹é©åˆæ€§ã‚‚含めて,いかなる保証も行わない.また,本ソフトウェ
    49 #   ã‚¢ã®åˆ©ç”¨ã«ã‚ˆã‚Šç›´æŽ¥çš„または間接的に生じたいかなる損害に関しても,そ
    50 #   ã®è²¬ä»»ã‚’負わない.
     31#   本ソフトウェアは,無保証で提供されているものである.上記著作権者お
     32#   よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     33#   に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
     34#   アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
     35#   の責任を負わない.
    5136
    52 #   $Id: GenOpaqueMarshaler.rb 1011 2016-07-11 02:20:01Z coas-nagasima $
     37#   $Id$
    5338#++
    5439
    5540#== GenOpaqueMarshaler
    56 # OpaqueRPCPlugin, sharedOpaqueRPCPlugin å
    57 ±é€šã®è¦ç´ ã‚’集めたモジュール
     41# OpaqueRPCPlugin, sharedOpaqueRPCPlugin 共通の要素を集めたモジュール
    5842module GenOpaqueMarshaler
    5943
    60   # プラグイン引数名と Proc
     44  # プラグイン引数名と Proc
    6145  RPCPluginArgProc = {
    6246    "clientChannelCelltype" => Proc.new { |obj,rhs| obj.set_clientChannelCelltype rhs },
     
    7963  }
    8064
    81   ##### プラグイン引数チェック関数
    82 
    83   #=== プラグイン引数 taskPriority のチェック
     65  ##### プラグイン引数チェック関数
     66
     67  #=== プラグイン引数 taskPriority のチェック
    8468  def set_taskPriority( rhs )
    8569    @taskPriority = rhs
    8670  end
    8771
    88   #=== プラグイン引数 serverChannelCelltype のチェック
     72  #=== プラグイン引数 serverChannelCelltype のチェック
    8973  def set_serverChannelCelltype( rhs )
    9074    @serverChannelCelltype = rhs.to_sym
     
    9882  end
    9983
    100   #=== プラグイン引数 clientChannelCelltype のチェック
     84  #=== プラグイン引数 clientChannelCelltype のチェック
    10185  def set_clientChannelCelltype( rhs )
    10286    @clientChannelCelltype = rhs.to_sym
     
    11094  end
    11195
    112   #=== プラグイン引数 serverChannelCell のチェック
     96  #=== プラグイン引数 serverChannelCell のチェック
    11397  def set_serverChannelCell( rhs )
    11498    @serverChannelCell = rhs.to_sym
    115     # ChannelCell はプラグインで生成されるため、ここではチェックできない
     99    # ChannelCell はプラグインで生成されるため、ここではチェックできない
    116100    # path = [ "::", @serverChannelCell ]
    117101    # obj = Namespace.find( path )
     
    121105  end
    122106
    123   #=== プラグイン引数 clientChannelCell のチェック
     107  #=== プラグイン引数 clientChannelCell のチェック
    124108  def set_clientChannelCell( rhs )
    125109    @clientChannelCell = rhs.to_sym
    126     # ChannelCell はプラグインで生成されるため、ここではチェックできない
     110    # ChannelCell はプラグインで生成されるため、ここではチェックできない
    127111    # path = [ "::", @clientChannelCell ]
    128112    # obj = Namespace.find( path )
     
    132116  end
    133117
    134   #=== プラグイン引数 serverChannelInitializer のチェック
     118  #=== プラグイン引数 serverChannelInitializer のチェック
    135119  def set_serverChannelInitializer( rhs )
    136120    @serverChannelInitializer = rhs.to_sym
    137121  end
    138122
    139   #=== プラグイン引数 clientChannelInitializer のチェック
     123  #=== プラグイン引数 clientChannelInitializer のチェック
    140124  def set_clientChannelInitializer( rhs )
    141125    @clientChannelInitializer = rhs.to_sym
    142126  end
    143127
    144   #=== タスクタイプ taskCellype のチェック
     128  #=== タスクタイプ taskCellype のチェック
    145129  def set_taskCelltype( rhs )
    146130    @taskCelltype = rhs.to_sym
     
    154138  end
    155139
    156   #=== タスクタイプ stack\size のチェック
     140  #=== タスクタイプ stack\size のチェック
    157141  def set_stackSize( rhs )
    158142    @stackSize = rhs
    159143  end
    160144
    161   #=== プラグイン引数 PPAllocatorSize のチェック
     145  #=== プラグイン引数 PPAllocatorSize のチェック
    162146  def set_PPAllocatorSize( rhs )
    163147    @PPAllocatorSize = rhs
    164148  end
    165149
    166   #=== プラグイン引数 TDRCelltype のチェック
     150  #=== プラグイン引数 TDRCelltype のチェック
    167151  def set_TDRCelltype( rhs )
    168152    @TDRCelltype = rhs.to_sym
     
    176160  end
    177161
    178   #=== プラグイン引数 substituteAllocator のチェック
    179   # オプション引数が、以下の形式であることをチェック
     162  #=== プラグイン引数 substituteAllocator のチェック
     163  # オプション引数が、以下の形式であることをチェック
    180164  #     substituteAllocator(Alloc.eAlloc=>Subst.eAlloc,Alloc2.eAlloc=>Subst2.eAlloc)
    181165  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 が出現しなかった場合にエラーメッセージとして表示
    187169    def optparse (str,regexp,expected)
    188170      str.strip!
     
    198180    ident_rexpr = /\A(\w[\w\d]*)/
    199181
    200     # "Alloc.eAlloc=>CAlloc.eAlloc" の形式になっていることをチェック
     182    # "Alloc.eAlloc=>CAlloc.eAlloc" の形式になっていることをチェック
    201183    while true
    202184      lhs_alloc_cell = optparse( opt, ident_rexpr, "allocator cell name" )
     
    221203      break if ! rhs_alloc_ent
    222204
    223 #  ここでは、右辺のチェックはできない。右辺のセルは前方参ç
    224 §ã¨ãªã‚‹
     205#  ここでは、右辺のチェックはできない。右辺のセルは前方参照となる
    225206#      path = [ "::", rhs_alloc_cell.to_sym ]   # mikan namespace
    226207#      obj = Namespace.find( path )
     
    229210#      else
    230211#        ct = obj.get_celltype
    231 #        if ct #  nil なら既にエラー
     212#        if ct #  nil なら既にエラー
    232213#          ent = ct.find rhs_alloc_ent
    233214#          if ! ent.instance_of? Port || ent.get_port_type != :ENTRY || ent.get_signature == nil || ! ent.get_signature.is_allocator?
     
    250231  end
    251232
    252   #=== プラグイン引数 noServerChannelOpenerCode のチェック
     233  #=== プラグイン引数 noServerChannelOpenerCode のチェック
    253234  def set_noServerChannelOpenerCode( rhs )
    254235    rhs = rhs.to_sym
     
    262243  end
    263244
    264   #=== プラグイン引数 clientSemaphoreCelltype のチェック
     245  #=== プラグイン引数 clientSemaphoreCelltype のチェック
    265246  def set_clientSemaphoreCelltype rhs
    266247    @semaphoreCelltype = rhs.to_sym
     
    272253  end
    273254
    274   #=== プラグイン引数 clientSemaphoreInitializer のチェック
     255  #=== プラグイン引数 clientSemaphoreInitializer のチェック
    275256  def set_clientSemaphoreInitializer rhs
    276257    @semaphoreInitializer = rhs.to_sym
    277258  end
    278259
    279   #=== プラグイン引数 clientErrorHandler のチェック
     260  #=== プラグイン引数 clientErrorHandler のチェック
    280261  def set_clientErrorHandler rhs
    281262    @clientErrorHandler = rhs.to_sym
    282263  end
    283264
    284   #=== プラグイン引数 serverErrorHandler のチェック
     265  #=== プラグイン引数 serverErrorHandler のチェック
    285266  def set_serverErrorHandler rhs
    286267    @serverErrorHandler = rhs.to_sym
     
    288269
    289270
    290   #===  セルの名前を得る
    291   # ThroughPlugin::get_cell_name plugin.rb をオーバーライド
     271  #===  セルの名前を得る
     272  # ThroughPlugin::get_cell_name plugin.rb をオーバーライド
    292273  def get_cell_name
    293274    @cell_name
     
    295276  end
    296277
    297   #=== marshaler のセルタイプ名を設定する
     278  #=== marshaler のセルタイプ名を設定する
    298279  def initialize_opaque_marshaler
    299280
    300     # オプション設定される変数のデフォルトを設定
     281    # オプション設定される変数のデフォルトを設定
    301282    @taskPriority = 11
    302283    @stackSize  = 4096
     
    309290    @taskCelltype = :"tTask"
    310291    @PPAllocatorSize = nil
    311     # @TDRCelltype  = :"tTDR"   # "tNBOTDR" に変更の予定
     292    # @TDRCelltype  = :"tTDR"   # "tNBOTDR" に変更の予定
    312293    @TDRCelltype  = :"tNBOTDR"
    313294    @substituteAllocator = {}
     
    324305    @marshaler_celltype_file_name = "#{$gen}/#{@marshaler_celltype_name}.cdl"
    325306
    326     # signature で対応できないものをチェック
     307    # signature で対応できないものをチェック
    327308    @signature.each_param{ |func_decl, param_decl|
    328309      if param_decl.get_direction == :OUT then
     
    337318  end
    338319
    339   #=== GenOpaqueMarshaler# Opener Code の生成時のチェック
     320  #=== GenOpaqueMarshaler# Opener Code の生成時のチェック
    340321  def check_opener_code
    341     # サーバーチャンネルセルタイプが entry sServerChannelOpener eOpener を持つかどうかをチェック
    342     # mikan entry か (call でないか) をチェックしていない
     322    # サーバーチャンネルセルタイプが entry sServerChannelOpener eOpener を持つかどうかをチェック
     323    # mikan entry か (call でないか) をチェックしていない
    343324    # scct = Namespace.find ["::", @serverChannelCelltype] # mikan namespace
    344325    nsp = NamespacePath.analyze( @serverChannelCelltype.to_s )
     
    360341  end
    361342
    362   #=== GenOpaqueMarshaler# PPAllocator のå¿
    363 è¦æ€§ã‚’チェックする
     343  #=== GenOpaqueMarshaler# PPAllocator の必要性をチェックする
    364344  def check_PPAllocator
    365345    if @signature.need_PPAllocator?(true) then
     
    374354  def gen_marshaler_celltype
    375355    f = CFile.open( @marshaler_celltype_file_name, "w" )
    376     # 同じå†
    377 å®¹ã‚’二度書く可能性あり (AppFile は不可)
     356    # 同じ内容を二度書く可能性あり (AppFile は不可)
    378357
    379358    if @PPAllocatorSize then
     
    404383  end
    405384
    406   #===  受け口関数の本体コードを生成(頭部と末尾は別途出力)
    407   #ct_name:: Symbol    (through プラグインで生成された) セルタイプ名 .Symbol として送られてくる(らしい)
     385  #===  受け口関数の本体コードを生成(頭部と末尾は別途出力)
     386  #ct_name:: Symbol    (through プラグインで生成された) セルタイプ名 .Symbol として送られてくる(らしい)
    408387  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 )
    409388
    410     # unmarshaler クラスか?
     389    # unmarshaler クラスか?
    411390    if ct_name == @unmarshaler_celltype_name.to_sym then
    412391      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 )
     
    416395  end
    417396
    418   #===  marshal コードの生成
     397  #===  marshal コードの生成
    419398  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 )
    420399
     
    422401    b_ret_er = false
    423402
    424     # 関数の戻り値のå
    425 ƒã®åž‹ã‚’å¾—ã‚‹(typedef されている場合)
     403    # 関数の戻り値の元の型を得る(typedef されている場合)
    426404    type = func_type.get_type.get_original_type
    427405
    428     # 戻り値記憶用の変数を出力(void 型の関数では出力しない)
     406    # 戻り値記憶用の変数を出力(void 型の関数では出力しない)
    429407    if ! type.is_void? then
    430408      file.print( "\t#{func_type.get_type.get_type_str}\t\tretval_;\n" )
     
    439417    file.print( "\tint16_t\tstate_;\n" )
    440418
    441     # 関数 ID (整数値)
     419    # 関数 ID (整数値)
    442420    func_id = "FUNCID_#{@signature.get_global_name}_#{func_name}".upcase
    443421    fid = @signature.get_id_from_func_name( func_name )
    444422    file.print( "\tint16_t\tfunc_id_ = #{func_id};      /* (id of '#{func_name}') = #{fid}*/\n" )
    445423
    446     # シングルトンでないか?
     424    # シングルトンでないか?
    447425    if ! b_singleton then
    448426
    449       # singleton でなければ p_cellcb 取得コードを出力
     427      # singleton でなければ p_cellcb 取得コードを出力
    450428      file.print <<EOT
    451429        #{ct_name}_CB *p_cellcb;
     
    455433EOT
    456434
    457       # エラーを返すか?
     435      # エラーを返すか?
    458436      if b_ret_er then
    459437        file.print <<EOT
     
    465443        file.print <<EOT
    466444        }else{
    467                 /* エラー処理コードをここに記述 */
     445                /* エラー処理コードをここに記述 */
    468446        }
    469447
     
    481459    end
    482460
    483     # channel lock コード
     461    # channel lock コード
    484462    file.print <<EOT
    485463
     
    490468EOT
    491469
    492     # SOP を送信
    493     file.print "        /* SOPの送出 */\n"
     470    # SOP を送信
     471    file.print "        /* SOPの送出 */\n"
    494472    file.print "        SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_SOP );\n"
    495473    file.print "        if( ( ercd_ = cTDR_sendSOP( true ) ) != E_OK )\n"
    496474    file.print "                goto error_reset;\n"
    497475
    498     # func_id を送信
    499     file.print "        /* 関数 id の送出 */\n"
     476    # func_id を送信
     477    file.print "        /* 関数 id の送出 */\n"
    500478    file.print "        if( ( ercd_ = cTDR_putInt16( func_id_ ) ) != E_OK )\n"
    501479    file.print "                goto error_reset;\n"
     
    504482    # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
    505483
    506     b_get = false    # marshal なら put
     484    b_get = false    # marshal なら put
    507485    b_marshal = true  # marshal
    508486
    509     # in 方向のå
    510 ¥å‡ºåŠ›ã‚’出力
     487    # in 方向の入出力を出力
    511488    if func_type.has_inward? then
    512       file.print "      /* å
    513 ¥åŠ›å¼•æ•°é€å‡º */\n"
     489      file.print "      /* 入力引数送出 */\n"
    514490      file.print "      SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_BODY );\n"
    515491      print_params( params, file, 1, b_marshal, b_get, true, "eClientEntry", func_name )
     
    523499      b_continue = "false"
    524500    end
    525     file.print "        /* EOPの送出(パケットの掃きだし) */\n"
     501    file.print "        /* EOPの送出(パケットの掃きだし) */\n"
    526502    file.print "        SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_EOP );\n"
    527503    file.print "        if( (ercd_=cTDR_sendEOP(#{b_continue})) != E_OK )\n"
    528504    file.print "                goto error_reset;\n\n"
    529505
    530     # send のメモリをデアロケート
     506    # send のメモリをデアロケート
    531507    if func_type.has_send? then
    532508      file.print "      /* dealloc send parameter while executing */\n"
     
    539515    if ! func_type.is_oneway? then
    540516
    541       file.print "      /* パケットの始まりをチェック */\n"
     517      file.print "      /* パケットの始まりをチェック */\n"
    542518      file.print "      SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_SOP );\n"
    543519      file.print "      if( (ercd_=cTDR_receiveSOP( true )) != E_OK )\n"
    544520      file.print "              goto error_reset;\n"
    545521
    546       b_get = true     # marshaler は get
    547       file.print "      /* 戻り値の受け取り */\n"
     522      b_get = true     # marshaler get
     523      file.print "      /* 戻り値の受け取り */\n"
    548524      print_param( "retval_", func_type.get_type, file, 1, :RETURN, nil, nil, b_marshal, b_get )
    549525
     
    557533        indent = "      " * indent_level
    558534
    559         file.print "#{indent}/* 出力値の受け取り */\n"
     535        file.print "#{indent}/* 出力値の受け取り */\n"
    560536        file.print "#{indent}SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_BODY );\n"
    561537        print_params( params, file, indent_level, b_marshal, b_get, true, "eClientEntry", func_name )
     
    567543      end
    568544
    569       file.print "\n    /* パケットの終わりをチェック */\n"
     545      file.print "\n    /* パケットの終わりをチェック */\n"
    570546      file.print "      SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_EOP );\n"
    571547      file.print "      if( (ercd_=cTDR_receiveEOP(false)) != E_OK )\n"  # b_continue = false
     
    574550    end # ! func_type.is_oneway?
    575551
    576     # channel lock コード
     552    # channel lock コード
    577553    file.print <<EOT
    578554        /* Channel Unlock */
     
    583559
    584560    if( b_void == false )then
    585       # 呼びå
    586 ƒã«æˆ»ã‚Šå€¤ã‚’リターン
     561      # 呼び元に戻り値をリターン
    587562      file.print( "     return retval_;\n" )
    588563    else
     
    594569error_reset:
    595570EOT
    596     # send のメモリをデアロケート
     571    # send のメモリをデアロケート
    597572    if func_type.has_send? then
    598573      file.print "      /* dealloc send parameter */\n"
     
    603578    end
    604579
    605     # receive のメモリをデアロケート
     580    # receive のメモリをデアロケート
    606581    if func_type.has_receive? then
    607582      file.print( "     /* receive parameter */\n" )
     
    615590EOT
    616591
    617     # channel lock コード
     592    # channel lock コード
    618593    file.print <<EOT
    619594        /* Channel Unlock */
     
    626601
    627602    if( b_ret_er != false )then
    628       # 呼びå
    629 ƒã«æˆ»ã‚Šå€¤ã‚’リターン
     603      # 呼び元に戻り値をリターン
    630604      file.print( "     return ERCD( E_RPC, MERCD( ercd_ ) );\n" )
    631605    else
     
    635609  end
    636610
    637   #===  unmarshal コードの生成
     611  #===  unmarshal コードの生成
    638612  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 )
    639613
    640614    b_ret_er = true
    641615
    642     # func_id を得るコードを生成
     616    # func_id を得るコードを生成
    643617    file.print <<EOT
    644618
     
    662636        file.print <<EOT
    663637        }else{
    664                 /* エラー処理コードをここに記述 */
     638                /* エラー処理コードをここに記述 */
    665639        }
    666640EOT
     
    673647#endif
    674648
    675         /* SOPのチェック */
     649        /* SOPのチェック */
    676650        SET_RPC_STATE( state_, RPCSTATE_SERVER_RECV_SOP );
    677651        if( (ercd_=cTDR_receiveSOP( false )) != E_OK )
    678652                goto error_reset;
    679         /* func_id の取得 */
     653        /* func_id の取得 */
    680654        if( (ercd_=cTDR_getInt16( &func_id_ )) != E_OK )
    681655                goto error_reset;
     
    687661EOT
    688662
    689     # signature に含まれる すべての関数について
     663    # signature に含まれる すべての関数について
    690664    @signature.get_function_head_array.each { |f|
    691665      f_name = f.get_name
     
    701675
    702676    if @PPAllocatorSize then
    703       ppallocator_dealloc_str = "       /* PPAllocator のすべてを解放 */\n       cPPAllocator_dealloc_all();"
     677      ppallocator_dealloc_str = "       /* PPAllocator のすべてを解放 */\n     cPPAllocator_dealloc_all();"
    704678    else
    705679      ppallocator_dealloc_str = ""
     
    724698  end
    725699
    726   #=== PREAMBLE 部のコード生成
    727   # アンマーシャラセルタイプの場合、アンマーシャラ関数のプロトタイプ宣言を生成
     700  #=== PREAMBLE 部のコード生成
     701  # アンマーシャラセルタイプの場合、アンマーシャラ関数のプロトタイプ宣言を生成
    728702  def gen_preamble file, b_singleton, ct_name, global_name
    729703    if ct_name != @unmarshaler_celltype_name.to_sym then
     
    731705    end
    732706
    733     # string.h の include (memset, strlen のため)
     707    # string.h の include (memset, strlen のため)
    734708    file.print "/* header file (strlen, memset) */\n"
    735709    file.print "#include\t<string.h>\n\n"
    736710
    737     file.print "/* アンマーシャラ関数のプロトタイプ宣言 */\n"
    738     # signature に含まれる すべての関数について
     711    file.print "/* アンマーシャラ関数のプロトタイプ宣言 */\n"
     712    # signature に含まれる すべての関数について
    739713    @signature.get_function_head_array.each { |f|
    740714      f_name = f.get_name
     
    746720  end
    747721
    748   #=== POSTAMBLE 部のコード生成
    749   # アンマーシャラセルタイプの場合、個ã€
    750 ã®ã‚¢ãƒ³ãƒžãƒ¼ã‚·ãƒ£ãƒ©é–¢æ•°ã®ç”Ÿæˆ
     722  #=== POSTAMBLE 部のコード生成
     723  # アンマーシャラセルタイプの場合、個々のアンマーシャラ関数の生成
    751724  def gen_postamble file, b_singleton, ct_name, global_name
    752725    if ct_name != @unmarshaler_celltype_name.to_sym then
     
    754727    end
    755728
    756     file.print "\n/*** アンマーシャラ関数 ***/\n\n"
     729    file.print "\n/*** アンマーシャラ関数 ***/\n\n"
    757730    @signature.get_function_head_array.each { |f|
    758731      f_name = f.get_name
     
    760733      id = @signature.get_id_from_func_name( f_name )
    761734
    762       # 関数は返り値を持つか?
     735      # 関数は返り値を持つか?
    763736      b_ret_er = false
    764737      init_retval = ""
     
    784757      file.print "      ER      ercd_;\n"
    785758
    786       # 引数を受取る変数の定義
     759      # 引数を受取る変数の定義
    787760      params = f.get_declarator.get_type.get_paramlist.get_items
    788761           # FuncHead->  Decl->    FuncType->ParamList
     
    793766        dir = par.get_direction
    794767        if( dir == :RECEIVE )then
    795           # type は PtrType で、それを取り除いた型
     768          # type は PtrType で、それを取り除いた型
    796769          type = type.get_type
    797770        end
     
    811784        end
    812785
    813         type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" を外す
     786        type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" を外す
    814787        file.printf( "  %-12s %s%s%s%s%s;\n", type_str, aster, name, aster2, type.get_type_str_post, init )
    815788
     
    823796      end
    824797
    825       # in 方向のå
    826 ¥å‡ºåŠ›ã‚’å
    827 ¥åŠ›
    828       file.print "\n    /* å
    829 ¥åŠ›å¼•æ•°å—取 */\n"
     798      # in 方向の入出力を入力
     799      file.print "\n    /* 入力引数受取 */\n"
    830800      file.print "      SET_RPC_STATE( *state_, RPCSTATE_SERVER_RECV_BODY );\n"
    831       b_get = true    # unmarshal では get
     801      b_get = true    # unmarshal では get
    832802      b_marshal  = false
    833803      print_params( params, file, 1, b_marshal, b_get, true, "cServerCall", f_name )
     
    836806
    837807
    838       # パケットの受信完了
    839       file.print "      /* パケット終わりをチェック */\n"
     808      # パケットの受信完了
     809      file.print "      /* パケット終わりをチェック */\n"
    840810      file.print "      SET_RPC_STATE( *state_, RPCSTATE_SERVER_RECV_EOP );\n"
    841811      if ! f_type.is_oneway? then
     
    847817      file.print "              goto error_reset;\n\n"
    848818
    849       # out のメモリをアロケート
     819      # out のメモリをアロケート
    850820      dir = :OUT; alloc_cp = "cPPAllocator_alloc"; alloc_cp_extra = nil; nest = 1
    851821      alloc_for_out_params( params, file, nest, dir, alloc_cp, alloc_cp_extra )
    852822
    853       # 対象関数を呼出す
    854       file.print "      /* 対象関数の呼出し */\n"
     823      # 対象関数を呼出す
     824      file.print "      /* 対象関数の呼出し */\n"
    855825      file.print "      SET_RPC_STATE( *state_, RPCSTATE_SERVER_EXEC );\n"
    856826      if b_void then
     
    871841      file.print( " );\n" )
    872842
    873       # 戻り値、出力引数の受取コードの生成
    874 
    875       # oneway の場合出力、戻り値が無く、受取をå¾
    876 ãŸãªã„(非同期な呼出し)
     843      # 戻り値、出力引数の受取コードの生成
     844
     845      # oneway の場合出力、戻り値が無く、受取を待たない(非同期な呼出し)
    877846      if ! f.is_oneway? then
    878847
    879         file.print "\n  /* SOPの送出 */\n"
     848        file.print "\n  /* SOPの送出 */\n"
    880849        file.print "    SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_SOP );\n"
    881850
     
    883852        file.print "            goto error_reset;\n"
    884853
    885         b_get = false     # unmarshaler は put
     854        b_get = false     # unmarshaler put
    886855        if( ! b_void )then
    887           file.print "  /* 戻り値の送出 */\n"
     856          file.print "  /* 戻り値の送出 */\n"
    888857          print_param( "retval_", f_type.get_type, file, 1, :RETURN, nil, nil, b_marshal, b_get )
    889858        end
     
    898867          indent = "    " * indent_level
    899868
    900           file.print "#{indent}/* 出力値の送出 */\n"
     869          file.print "#{indent}/* 出力値の送出 */\n"
    901870          file.print "#{indent}SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_BODY );\n"
    902871          print_params( params, file, indent_level, b_marshal, b_get, true, "cServerCall", f_name )
    903872          print_params( params, file, indent_level, b_marshal, b_get, false, "cServerCall", f_name )
    904873
    905           # receive のメモリをデアロケート
     874          # receive のメモリをデアロケート
    906875          if f_type.has_receive? then
    907876            file.print "#{indent}/* dealloc receive parameter */\n"
     
    915884        end
    916885
    917         file.print "    /* パケットの終わり(掃きだし) */\n"
     886        file.print "    /* パケットの終わり(掃きだし) */\n"
    918887        file.print "    SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_EOP );\n"
    919888        file.print "    if( (ercd_=cTDR_sendEOP(false)) != E_OK )\n"  # b_continue = false
     
    926895error_reset:
    927896EOT
    928       # send のリセット用デアロケート
     897      # send のリセット用デアロケート
    929898      if f_type.has_send? then
    930899        file.print "    /* dealloc send parameter */\n"
     
    935904      end
    936905
    937       # receive のメモリをデアロケート
     906      # receive のメモリをデアロケート
    938907      if f_type.has_receive? && b_ret_er then
    939908        file.print "    /* dealloc receive parameter */\n"
     
    947916      file.print "}\n\n"
    948917
    949       # ここ(個ã€
    950 ã®é–¢æ•°ï¼‰ã§ã¯ã‚¨ãƒ©ãƒ¼ãƒãƒ³ãƒ‰ãƒ©ãƒ¼ã¯å‘¼ã³å‡ºã•ãªã„。呼びå
    951 ƒï¼ˆã‚µãƒ¼ãƒãƒ¼ã®ãƒ¡ã‚¤ãƒ³é–¢æ•°ï¼‰ã§å‘¼ã³å‡ºã™ã€‚
     918      # ここ(個々の関数)ではエラーハンドラーは呼び出さない。呼び元(サーバーのメイン関数)で呼び出す。
    952919    }
    953920  end
     
    956923  #b_marshal:: bool
    957924  #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 で参照されているものを出力
    966930  def print_params( params, file, nest, b_marshal, b_get, b_referenced, port_name, func_name )
    967931    params.each{ |param|
     
    986950        case dir
    987951        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 のときアロケータコードは不用
    989953          alloc_cp_extra = nil
    990954          print_param( param.get_name, param.get_type, file, nest, dir, nil, nil, b_marshal, b_get, alloc_cp, alloc_cp_extra )
     
    993957          alloc_cp_extra = nil
    994958          if b_get then
    995             outer = "(*"         # マーシャラ側では、ポインタが (send と比べ) 一つ多い
     959            outer = "(*"         # マーシャラ側では、ポインタが (send と比べ) 一つ多い
    996960            outer2 = ")"
    997961          else
    998             outer = nil          # アンマーシャラ側では、ポインタが一つ外されている
     962            outer = nil          # アンマーシャラ側では、ポインタが一つ外されている
    999963            outer2 = nil
    1000964          end
     
    1006970  end
    1007971
    1008   #=== アロケータコードを生成 (out のアンマーシャラ用)
     972  #=== アロケータコードを生成 (out のアンマーシャラ用)
    1009973  def alloc_for_out_params( params, file, nest, dir, alloc_cp, alloc_cp_extra )
    1010974    params.each{ |param|
     
    1016980  end
    1017981
    1018   #=== アロケータコードを生成 (out のアンマーシャラ用個別パラメータの生成)
     982  #=== アロケータコードを生成 (out のアンマーシャラ用個別パラメータの生成)
    1019983  def alloc_for_out_param( name, type, file, nest, outer, outer2, alloc_cp, alloc_cp_extra )
    1020984    org_type = type.get_original_type
     
    1029993      count = type.get_count; size = type.get_size; string = type.get_string
    1030994      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 の引数の型とする
    1032996        if count then
    1033997          len = type.get_count.to_s
     
    10421006        end
    10431007
    1044         # size_is に max 指定がある場合、length が max をè¶
    1045 ãˆã¦ã„るかチェックするコードを生成
     1008        # size_is に max 指定がある場合、length が max を超えているかチェックするコードを生成
    10461009        if org_type.get_max != nil && string == nil then
    10471010          file.print "#{indent}if( #{len} > #{type.get_max} ){\t/* GenOpaqueMarshaler max check 2 */\n"
     
    10821045  end
    10831046
    1084   #=== 引数の一括デアロケートコードの生成
    1085   # send:マーシャラの最後、receive:アンマーシャラの最後で一括して引数をデアロケートする
     1047  #=== 引数の一括デアロケートコードの生成
     1048  # send:マーシャラの最後、receive:アンマーシャラの最後で一括して引数をデアロケートする
    10861049  def dealloc_for_params( params, file, nest, dir, dealloc_cp, b_reset = false )
    10871050    if b_reset then
     
    10971060        aster = ""
    10981061        if dir == :RECEIVE then
    1099           type = type.get_type.get_original_type   # ポインタを一つ外す
     1062          type = type.get_type.get_original_type   # ポインタを一つ外す
    11001063          if b_reset then
    11011064            aster = "*"
     
    11181081  end
    11191082
    1120   #== out で nullable な引数のæƒ
    1121 å ±ã‚’渡す
    1122   # out nullable の場合、in, send, receive のように、値を渡す直前ではなく、呼出し時に渡す
     1083  #== out で nullable な引数の情報を渡す
     1084  # out nullable の場合、in, send, receive のように、値を渡す直前ではなく、呼出し時に渡す
    11231085  def  print_out_nullable( params, file, nest, b_marshal );
    11241086    indent = "\t" * nest
     
    11301092        file.print "#{indent}\tgoto error_reset;\n"
    11311093      else
    1132         # 呼びå
    1133 ˆã¯ alloc_for_out_param で nullable の対応する
     1094        # 呼び先は alloc_for_out_param で nullable の対応する
    11341095        file.print "#{indent}if( (ercd_=cTDR_getInt8( &b_#{param.get_name}_null_)) != E_OK )\n"
    11351096        file.print "#{indent}\tgoto error_reset;\n"
Note: See TracChangeset for help on using the changeset viewer.