summaryrefslogtreecommitdiff
path: root/ext/dl/lib/dl/import.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dl/lib/dl/import.rb')
-rw-r--r--ext/dl/lib/dl/import.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb
index f6fb35944d0..aab0a38d521 100644
--- a/ext/dl/lib/dl/import.rb
+++ b/ext/dl/lib/dl/import.rb
@@ -119,7 +119,13 @@ module DL
name = symname.gsub(/@.+/,'')
@func_map[name] = f
# define_method(name){|*args,&block| f.call(*args,&block)}
- module_eval(<<-EOS)
+ begin
+ /^(.+?):(\d+)/ =~ caller.first
+ file, line = $1, $2.to_i
+ rescue
+ file, line = __FILE__, __LINE__+3
+ end
+ module_eval(<<-EOS, file, line)
def #{name}(*args, &block)
@func_map['#{name}'].call(*args,&block)
end
@@ -143,7 +149,13 @@ module DL
end
@func_map[name] = f
#define_method(name){|*args,&block| f.call(*args,&block)}
- module_eval(<<-EOS)
+ begin
+ /^(.+?):(\d+)/ =~ caller.first
+ file, line = $1, $2.to_i
+ rescue
+ file, line = __FILE__, __LINE__+3
+ end
+ module_eval(<<-EOS, file, line)
def #{name}(*args,&block)
@func_map['#{name}'].call(*args,&block)
end