Class: Win::Library::API

Inherits:
Object
  • Object
show all
Defined in:
lib/win/library.rb

Overview

Win::Library::API is a wrapper for callable function API object that mimics Win32::API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, function_name, effective_name, prototype, return_type, dll) ⇒ API

Returns a new instance of API.



490
491
492
493
494
495
496
497
# File 'lib/win/library.rb', line 490

def initialize( namespace, function_name, effective_name, prototype, return_type, dll )
  @namespace = namespace
  @function_name = function_name.to_sym
  @effective_name = effective_name.to_sym
  @prototype = prototype
  @return_type = return_type
  @dll = dll
end

Instance Attribute Details

#dllObject (readonly) Also known as: dll_name

The name of the DLL(s) that export this API function. dll_name alias needed for compatibility with Win32::API interface



469
470
471
# File 'lib/win/library.rb', line 469

def dll
  @dll
end

#effective_nameObject Also known as: effective_function_name

The name of the actual Windows API function. For example, if you passed ‘GetUserName’ to the constructor, then the effective function name would be either ‘GetUserNameA’ or ‘GetUserNameW’. effective_function_name alias needed for compatibility with Win32::API interface



481
482
483
# File 'lib/win/library.rb', line 481

def effective_name
  @effective_name
end

#function_nameObject (readonly)

The name of the (CamelCase) function passed to the constructor



476
477
478
# File 'lib/win/library.rb', line 476

def function_name
  @function_name
end

#namespaceObject (readonly)

Ruby namespace (module) where this API function is attached



473
474
475
# File 'lib/win/library.rb', line 473

def namespace
  @namespace
end

#prototypeObject (readonly)

The prototype, returned as an array of FFI types



485
486
487
# File 'lib/win/library.rb', line 485

def prototype
  @prototype
end

#return_typeObject (readonly)

The return type (:void for no return value)



488
489
490
# File 'lib/win/library.rb', line 488

def return_type
  @return_type
end

Instance Method Details

#call(*args) ⇒ Object

Calls underlying CamelCase Windows API function with supplied args



500
501
502
# File 'lib/win/library.rb', line 500

def call( *args )
  @namespace.send(@function_name, *args)
end