[前][次][番号順一覧][スレッド一覧]

ruby-changes:45193

From: nobu <ko1@a...>
Date: Wed, 4 Jan 2017 20:06:22 +0900 (JST)
Subject: [ruby-changes:45193] nobu:r57266 (trunk): win32/registry.rb: registry type names

nobu	2017-01-04 20:06:16 +0900 (Wed, 04 Jan 2017)

  New Revision: 57266

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57266

  Log:
    win32/registry.rb: registry type names
    
    * ext/win32/lib/win32/registry.rb (Win32::Registry#read): show
      registry type names instead of numeric values.

  Modified files:
    trunk/ext/win32/lib/win32/registry.rb
Index: ext/win32/lib/win32/registry.rb
===================================================================
--- ext/win32/lib/win32/registry.rb	(revision 57265)
+++ ext/win32/lib/win32/registry.rb	(revision 57266)
@@ -643,7 +643,9 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/registry.rb#L643
     def read(name, *rtype)
       type, data = API.QueryValue(@hkey, name)
       unless rtype.empty? or rtype.include?(type)
-        raise TypeError, "Type mismatch (expect #{rtype.inspect} but #{type} present)"
+        raise TypeError, "Type mismatch (expect [#{
+          rtype.map{|t|Registry.type2name(t)}.join(', ')}] but #{
+          Registry.type2name(type)} present)"
       end
       case type
       when REG_SZ, REG_EXPAND_SZ
@@ -659,7 +661,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/registry.rb#L661
       when REG_QWORD
         [ type, API.unpackqw(data) ]
       else
-        raise TypeError, "Type #{type} is not supported."
+        raise TypeError, "Type #{Registry.type2name(type)} is not supported."
       end
     end
 
@@ -682,7 +684,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/registry.rb#L684
       when REG_EXPAND_SZ
         Registry.expand_environ(data)
       else
-        raise TypeError, "Type #{type} is not supported."
+        raise TypeError, "Type #{Registry.type2name(type)} is not supported."
       end
     end
 
@@ -755,7 +757,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/registry.rb#L757
       when REG_QWORD
         data = API.packqw(data.to_i)
       else
-        raise TypeError, "Unsupported type #{type}"
+        raise TypeError, "Unsupported type #{Registry.type2name(type)}"
       end
       API.SetValue(@hkey, name, type, data, data.bytesize + termsize)
     end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]