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

ruby-changes:42460

From: nobu <ko1@a...>
Date: Mon, 11 Apr 2016 12:31:42 +0900 (JST)
Subject: [ruby-changes:42460] nobu:r54534 (trunk): fiddle/import.rb: suppress warnings

nobu	2016-04-11 13:28:16 +0900 (Mon, 11 Apr 2016)

  New Revision: 54534

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

  Log:
    fiddle/import.rb: suppress warnings
    
    * ext/fiddle/lib/fiddle/import.rb (type_alias, handler): suppress
      "not initialized instance variable" warnings.

  Modified files:
    trunk/ext/fiddle/lib/fiddle/import.rb
Index: ext/fiddle/lib/fiddle/import.rb
===================================================================
--- ext/fiddle/lib/fiddle/import.rb	(revision 54533)
+++ ext/fiddle/lib/fiddle/import.rb	(revision 54534)
@@ -63,6 +63,9 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/lib/fiddle/import.rb#L63
     include CParser
     extend Importer
 
+    attr_reader :type_alias
+    private :type_alias
+
     # Creates an array of handlers for the given +libs+, can be an instance of
     # Fiddle::Handle, Fiddle::Importer, or will create a new instance of
     # Fiddle::Handle using Fiddle.dlopen
@@ -102,7 +105,7 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/lib/fiddle/import.rb#L105
     def sizeof(ty)
       case ty
       when String
-        ty = parse_ctype(ty, @type_alias).abs()
+        ty = parse_ctype(ty, type_alias).abs()
         case ty
         when TYPE_CHAR
           return SIZEOF_CHAR
@@ -160,7 +163,7 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/lib/fiddle/import.rb#L163
 
     # Creates a global method from the given C +signature+.
     def extern(signature, *opts)
-      symname, ctype, argtype = parse_signature(signature, @type_alias)
+      symname, ctype, argtype = parse_signature(signature, type_alias)
       opt = parse_bind_options(opts)
       f = import_function(symname, ctype, argtype, opt[:call_type])
       name = symname.gsub(/@.+/,'')
@@ -184,7 +187,7 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/lib/fiddle/import.rb#L187
     # Creates a global method from the given C +signature+ using the given
     # +opts+ as bind parameters with the given block.
     def bind(signature, *opts, &blk)
-      name, ctype, argtype = parse_signature(signature, @type_alias)
+      name, ctype, argtype = parse_signature(signature, type_alias)
       h = parse_bind_options(opts)
       case h[:callback_type]
       when :bind, nil
@@ -213,7 +216,7 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/lib/fiddle/import.rb#L216
     #
     #   MyStruct = struct ['int i', 'char c']
     def struct(signature)
-      tys, mems = parse_struct_signature(signature, @type_alias)
+      tys, mems = parse_struct_signature(signature, type_alias)
       Fiddle::CStructBuilder.create(CStruct, tys, mems)
     end
 
@@ -221,7 +224,7 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/lib/fiddle/import.rb#L224
     #
     #   MyUnion = union ['int i', 'char c']
     def union(signature)
-      tys, mems = parse_struct_signature(signature, @type_alias)
+      tys, mems = parse_struct_signature(signature, type_alias)
       Fiddle::CStructBuilder.create(CUnion, tys, mems)
     end
 
@@ -257,7 +260,7 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/lib/fiddle/import.rb#L260
     #
     # Will raise an error if no handlers are open.
     def handler
-      @handler or raise "call dlload before importing symbols and functions"
+      (@handler ||= nil) or raise "call dlload before importing symbols and functions"
     end
 
     # Returns a new Fiddle::Pointer instance at the memory address of the given

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

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