lib/win/library.rb in win-0.3.24 vs lib/win/library.rb in win-0.3.25

- old
+ new

@@ -240,16 +240,16 @@ ULONG32: :uint32, # Unsigned INT32. The range is 0 through 4294967295 decimal. ULONG64: :uint64, # Unsigned LONG64. The range is 0 through 18446744073709551615 decimal. UNICODE_STRING: :pointer, # Pointer to some string structure?? USHORT: :ushort, # Unsigned SHORT. The range is 0 through 65535 decimal. USN: :ulong_long, # Update sequence number (USN). - VOID: [], # Any type ? Only use it to indicate no arguments or no return value WCHAR: :ushort, # 16-bit Unicode character. For more information, see Character Sets Used By Fonts. # In WinNT.h: typedef wchar_t WCHAR; #WINAPI: K, # Calling convention for system functions. WinDef.h: define WINAPI __stdcall WORD: :ushort, # 16-bit unsigned integer. The range is 0 through 65535 decimal. - WPARAM: :uint # Message parameter. WinDef.h as follows: typedef UINT_PTR WPARAM; + WPARAM: :uint, # Message parameter. WinDef.h as follows: typedef UINT_PTR WPARAM; + VOID: [], # Any type ? Only use it to indicate no arguments or no return value } ## # Defines new method wrappers for Windows API function call: # - Defines method with original (CamelCase) API function name and original signature (matches MSDN description) @@ -257,11 +257,11 @@ # When defined snake_case method is called, it converts the arguments you provided into ones required by # original API (adding defaults, mute and transitory args as necessary), executes API function call # and (optionally) transforms the result before returning it. If a block is attached to # method invocation, raw result is yielded to this block before final transformation take place # - Defines aliases for enhanced method with more Rubyesque names for getters, setters and tests: - # GetWindowText -> window_test, SetWindowText -> window_text=, IsZoomed -> zoomed? + # GetWindowText -> window_text, SetWindowText -> window_text=, IsZoomed -> zoomed? # --- # You may modify default behavior of defined method by providing optional *def_block* to function definition. # If you do so, snake_case method is defined based on your *def_block*. It receives callable API # object for function being defined, arguments and (optional) runtime block with which the method # will be called. Results coming from &def_block are then transformed and returned. @@ -280,10 +280,11 @@ # :camel_name:: Overrides default CamelCase name for function being attached # :camel_only:: If true, no snake_case method is defined # :alias(es):: Provides additional alias(es) for defined method # :boolean:: Forces method to return true/false instead of nonzero/zero # :fails:: Forces method to return nil if function result is equal to following error code + # :alternative:: Alternative signature for this function # def function(name, params, returns, options={}, &def_block) snake_name, camel_name, effective_names, aliases = generate_names(name, options) api = define_api(name, camel_name, effective_names, params, returns, options) @@ -295,11 +296,11 @@ # Try to define platform-specific function, rescue error, return message # def try_function(name, params, returns, options={}, &def_block) begin - function name, params, returns, options={}, &def_block + function name, params, returns, options, &def_block rescue Win::Errors::NotFoundError "This platform does not support function #{name}" end end @@ -357,10 +358,14 @@ define_method snake_name, &method_body module_function snake_name public snake_name # Define (instance method!) aliases, if any - aliases.each {|ali| alias_method ali, snake_name } + aliases.each do |ali| + alias_method ali, snake_name + module_function ali + public ali + end end # Generates possible effective names for function in Win32 dll (name+A/W), # camel_case, snake_case and aliases method names # \ No newline at end of file