From 28001c849d8823c8bac79b9e53705cf247b99e65 Mon Sep 17 00:00:00 2001 From: yugui Date: Sun, 28 Dec 2008 12:13:24 +0000 Subject: * ext/dl/lib/dl/import.rb (DL::Importer#extern): adds filename and line number to module_eval'ing for readability of backtrace. (DL::Importer#bind): ditto. * ext/dl/lib/dl/struct.rb (DL::CStructBuilder#create): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/dl/lib/dl/import.rb | 16 ++++++++++++++-- ext/dl/lib/dl/struct.rb | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 416d04a82c..6ce7709d47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sun Dec 28 21:03:07 2008 Yuki Sonoda (Yugui) + + * ext/dl/lib/dl/import.rb (DL::Importer#extern): adds filename and + line number to module_eval'ing for readability of backtrace. + (DL::Importer#bind): ditto. + + * ext/dl/lib/dl/struct.rb (DL::CStructBuilder#create): ditto. + Sun Dec 28 19:11:03 2008 Nobuyoshi Nakada * win32/Makefile.sub (config.h): do not use snprintf/vsnprintf in diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb index f6fb35944d..aab0a38d52 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 4272b3960c..dc116f3be5 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 -- cgit v1.2.3