summaryrefslogtreecommitdiff
path: root/ext/fiddle
diff options
context:
space:
mode:
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