From bf6a8134f8abb6c6a57cf297ab126267b43b5c24 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 11 Apr 2016 04:28:16 +0000 Subject: fiddle/import.rb: suppress warnings * ext/fiddle/lib/fiddle/import.rb (type_alias, handler): suppress "not initialized instance variable" warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/fiddle/lib/fiddle/import.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'ext/fiddle/lib') diff --git a/ext/fiddle/lib/fiddle/import.rb b/ext/fiddle/lib/fiddle/import.rb index 7f959ed20b..09429f6631 100644 --- a/ext/fiddle/lib/fiddle/import.rb +++ b/ext/fiddle/lib/fiddle/import.rb @@ -63,6 +63,9 @@ module Fiddle 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 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 # 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 # 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 # # 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 # # 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 # # 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 -- cgit v1.2.3