summaryrefslogtreecommitdiff
path: root/ext/dl/lib
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dl/lib')
-rw-r--r--ext/dl/lib/dl/import.rb16
-rw-r--r--ext/dl/lib/dl/struct.rb2
2 files changed, 15 insertions, 3 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
diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb
index 4272b3960cd..dc116f3be5f 100644
--- a/ext/dl/lib/dl/struct.rb
+++ b/ext/dl/lib/dl/struct.rb
@@ -29,7 +29,7 @@ module DL
}
}
size = klass.entity_class.size(types)
- new_class.module_eval(<<-EOS)
+ new_class.module_eval(<<-EOS, __FILE__, __LINE__+1)
def new_class.size()
#{size}
end