summaryrefslogtreecommitdiff
path: root/ext/fiddle
diff options
context:
space:
mode:
authorngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-06 16:21:43 +0000
committerngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-06 16:21:43 +0000
commit0bc733d9e3cf49c67b79a120ba08f1433ce82c7b (patch)
tree9a261389b1848e1ee95d2717eaad19852e33bf5f /ext/fiddle
parent5f912e7e2fe9e952f07abdd850e24f61afaa9c56 (diff)
* ext/fiddle/lib/fiddle/function.rb (Fiddle::Function#name): new
attribute needed to switch Win32::Registry from DL to Fiddle. * ext/fiddle/lib/fiddle/import.rb (import_function, bind_function): set function name to the returned Fiddle::Function object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/fiddle')
-rw-r--r--ext/fiddle/lib/fiddle/function.rb3
-rw-r--r--ext/fiddle/lib/fiddle/import.rb8
2 files changed, 9 insertions, 2 deletions
diff --git a/ext/fiddle/lib/fiddle/function.rb b/ext/fiddle/lib/fiddle/function.rb
index 07a072e..ab7496e 100644
--- a/ext/fiddle/lib/fiddle/function.rb
+++ b/ext/fiddle/lib/fiddle/function.rb
@@ -6,6 +6,9 @@ module Fiddle
# The address of this function
attr_reader :ptr
+ # The name of this function
+ attr_reader :name
+
# The integer memory location of this function
def to_i
ptr.to_i
diff --git a/ext/fiddle/lib/fiddle/import.rb b/ext/fiddle/lib/fiddle/import.rb
index f5a069b..faf7cb3 100644
--- a/ext/fiddle/lib/fiddle/import.rb
+++ b/ext/fiddle/lib/fiddle/import.rb
@@ -290,7 +290,9 @@ module Fiddle
if( !addr )
raise(DLError, "cannot find the function: #{name}()")
end
- Function.new(addr, argtype, ctype, CALL_TYPE_TO_ABI[call_type])
+ f = Function.new(addr, argtype, ctype, CALL_TYPE_TO_ABI[call_type])
+ f.instance_eval { @name = name }
+ f
end
# Returns a new closure wrapper for the +name+ function.
@@ -307,7 +309,9 @@ module Fiddle
define_method(:call, block)
}.new(ctype, argtype, abi)
- Function.new(closure, argtype, ctype, abi)
+ f = Function.new(closure, argtype, ctype, abi)
+ f.instance_eval { @name = name }
+ f
end
end
end