Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

Location:
EcnlProtoTool/trunk/mruby-1.3.0
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-hash-ext/mrblib/hash.rb

    r321 r331  
    2929      o = object[0]
    3030      if o.respond_to?(:to_hash)
    31         h = Hash.new
     31        h = self.new
    3232        object[0].to_hash.each { |k, v| h[k] = v }
    3333        return h
    3434      elsif o.respond_to?(:to_a)
    35         h = Hash.new
     35        h = self.new
    3636        o.to_a.each do |i|
    3737          raise ArgumentError, "wrong element type #{i.class} (expected array)" unless i.respond_to?(:to_a)
     
    5454      raise ArgumentError, 'odd number of arguments for Hash'
    5555    end
    56     h = Hash.new
     56    h = self.new
    5757    0.step(length - 2, 2) do |i|
    5858      h[object[i]] = object[i + 1]
    5959    end
    6060    h
     61  end
     62
     63  ##
     64  # call-seq:
     65  #     Hash.try_convert(obj) -> hash or nil
     66  #
     67  # Try to convert <i>obj</i> into a hash, using to_hash method.
     68  # Returns converted hash or nil if <i>obj</i> cannot be converted
     69  # for any reason.
     70  #
     71  #     Hash.try_convert({1=>2})   # => {1=>2}
     72  #     Hash.try_convert("1=>2")   # => nil
     73  #
     74  def self.try_convert(obj)
     75    if obj.respond_to?(:to_hash)
     76      obj.to_hash
     77    else
     78      nil
     79    end
    6180  end
    6281
     
    193212
    194213  def invert
    195     h = Hash.new
     214    h = self.class.new
    196215    self.each {|k, v| h[v] = k }
    197216    h
     
    347366    }
    348367  end
     368
     369  ##
     370  # call-seq:
     371  #   hsh.dig(key,...)                 -> object
     372  #
     373  # Extracts the nested value specified by the sequence of <i>key</i>
     374  # objects by calling +dig+ at each step, returning +nil+ if any
     375  # intermediate step is +nil+.
     376  #
     377  def dig(idx,*args)
     378    n = self[idx]
     379    if args.size > 0
     380      n&.dig(*args)
     381    else
     382      n
     383    end
     384  end
    349385end
Note: See TracChangeset for help on using the changeset viewer.