1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2016-04-11 04:28:16 +00:00
parent e9bb167bfb
commit bf6a8134f8

View file

@ -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