Hi,

At Sat, 3 Jul 2010 00:37:00 +0900,
Aston wrote in [ruby-core:30996]:
> module Win32
> extend DL::Importer
  dlload "kernel32"	# is this correct DLL?
> extern "int SetEnvironmentVariableA( char* lpName, char* lpValue)"
> extern "int GetEnvironmentVariableA( char* lpName, char* lpValue, int size)"
> end

The following patch refines the error messages.


diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb index fd23bc9..f9e8faf 100644 --- a/ext/dl/lib/dl/import.rb +++ b/ext/dl/lib/dl/import.rb @@ -194,8 +194,12 @@ module DL return ptr end + def handler + @handler or raise "call dlload before importing symbols and functions" + end + def import_symbol(name) - addr = @handler.sym(name) + addr = handler.sym(name) if( !addr ) raise(DLError, "cannot find the symbol: #{name}") end @@ -203,7 +207,7 @@ module DL end def import_function(name, ctype, argtype, call_type = nil) - addr = @handler.sym(name) + addr = handler.sym(name) if( !addr ) raise(DLError, "cannot find the function: #{name}()") end
-- Nobu Nakada