Ignore:
Timestamp:
Jul 3, 2020, 7:19:17 PM (4 years ago)
Author:
coas-nagasima
Message:

ASP3, TINET, mbed を更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/pluginModule.rb

    r321 r429  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    4545
    4646  #=== プラグインをロードする
    47   #return:: true : 成功、 false : 失敗
     47  # return:: PluginClass
     48  # V1.4.1 まで return:: true : 成功、 false : 失敗
     49  #
     50  # #{plugin_name}.rb をロードし、plugin_name クラスのオブジェクトを生成する.
     51  # plugin_name が MultiPlugin の場合、get_plugin により、superClass のプラグインオブジェクトをロードする.
    4852  #
    4953  # すでにロードされているものは、重複してロードしない
     
    5963        end
    6064        # "#{plugin_name}.rb" をロード(システム用ではないので、fatal エラーにしない)
    61         if require_tecsgen_lib( "#{plugin_name}.rb", false ) == false
     65        if require_tecsgen_lib( "#{plugin_name}.rb", false ) == false then
    6266          cdl_error( "P2001 $1.rb : fail to load plugin" , plugin_name )
    63           return false
     67          return nil
    6468        end
    6569      end
    6670
    67       plSuper = nil
    68       # eval( "plSuper = #{plugin_name}.superclass" )
    69       eval( "plSuper = #{plugin_name}" )
    70       while plSuper != superClass && plSuper != nil
    71         plSuper = plSuper.superclass
    72       end
    73       if plSuper == nil then
     71      plClass = Object.const_get plugin_name
     72      if ( plClass <= superClass ) then       # plClass inherits superClass
     73        return plClass
     74      elsif (plClass <= MultiPlugin) then     # plClass inherits MultiPlugin
     75        dbgPrint "pluginClass=#{plClass}\n"
     76        plugin_object = plClass.get_plugin superClass
     77        dbgPrint "pluginClass=#{plugin_object}\n"
     78        if plugin_object == nil then
     79          cdl_error( "P9999 '$1': MultiPlugin not support '$2'", plugin_name, superClass.name )
     80        end
     81        @@loaded_plugin_list[ plugin_name.to_sym ] = :MultiPlugin
     82        return plugin_object
     83      else
    7484        cdl_error( "P2002 $1: not kind of $2" ,  plugin_name, superClass.name )
    75         return false
     85        return nil
    7686      end
    7787    rescue Exception => evar
     
    8191      end
    8292      cdl_error( "P2003 $1: load failed" , plugin_name )
    83       return false
     93      return nil
    8494    end
    85     return true
     95    # ここへは来ない
     96    return nil
    8697  end
    8798
     
    92103    end
    93104    plugin_name = plugin_object.class.name.to_sym
    94     if @@loaded_plugin_list[ plugin_name ] == nil
    95       raise "#{plugin_name} might have different name "
    96       # プラグインのファイル名と、プラグインのクラス名が相違する場合
     105    if @@loaded_plugin_list[ plugin_name ] == :MultiPlugin then
     106      p "#{plugin_name}: MultiPlugin"
     107      return
     108    elsif @@loaded_plugin_list[ plugin_name ] == nil then
     109      #raise "#{plugin_name} might have different name "
     110      ## プラグインのファイル名と、プラグインのクラス名が相違する場合
     111      #MultiPlugin の get_plugin で返されたケースでは nil になっている
     112      @@loaded_plugin_list[ plugin_name ] = 0
    97113    end
    98114    count = @@loaded_plugin_list[ plugin_name ]
     
    131147    dbgPrint "PluginModule #{@@loaded_plugin_list}\n"
    132148    @@loaded_plugin_list.each{ |plugin_name,count|
     149      if count == :MultiPlugin then
     150        next
     151      end
    133152      dbgPrint "PluginModule: #{plugin_name}\n"
    134153      eval_str = "#{plugin_name}.gen_post_code( file )"
Note: See TracChangeset for help on using the changeset viewer.