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.



485
486
487
488
489
490
491
492
# File 'lib/win/library.rb', line 485

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



464
465
466
# File 'lib/win/library.rb', line 464

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



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

def effective_name
  @effective_name
end

#function_nameObject (readonly)

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



471
472
473
# File 'lib/win/library.rb', line 471

def function_name
  @function_name
end

#namespaceObject (readonly)

Ruby namespace (module) where this API function is attached



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

def namespace
  @namespace
end

#prototypeObject (readonly)

The prototype, returned as an array of FFI types



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

def prototype
  @prototype
end

#return_typeObject (readonly)

The return type (:void for no return value)



483
484
485
# File 'lib/win/library.rb', line 483

def return_type
  @return_type
end

Instance Method Details

#call(*args) ⇒ Object

Calls underlying CamelCase Windows API function with supplied args



495
496
497
# File 'lib/win/library.rb', line 495

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