summaryrefslogtreecommitdiff
path: root/ext/fiddle/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-11 04:28:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-11 04:28:16 +0000
commitbf6a8134f8abb6c6a57cf297ab126267b43b5c24 (patch)
treeb5f8733075860765e211621aa7d2b079702fbbd1 /ext/fiddle/lib
parente9bb167bfb16c63099af8d0a16d297beffd5184b (diff)
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
Diffstat (limited to 'ext/fiddle/lib')
-rw-r--r--ext/fiddle/lib/fiddle/import.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/ext/fiddle/lib/fiddle/import.rb b/ext/fiddle/lib/fiddle/import.rb
index 7f959ed..09429f6 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