summaryrefslogtreecommitdiff
path: root/ext/dl/lib
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dl/lib')
-rw-r--r--ext/dl/lib/dl/callback.rb26
-rw-r--r--ext/dl/lib/dl/import.rb16
-rw-r--r--ext/dl/lib/dl/types.rb31
3 files changed, 66 insertions, 7 deletions
diff --git a/ext/dl/lib/dl/callback.rb b/ext/dl/lib/dl/callback.rb
index 0863c70d4d..1722d3c6b9 100644
--- a/ext/dl/lib/dl/callback.rb
+++ b/ext/dl/lib/dl/callback.rb
@@ -2,13 +2,29 @@ require 'dl'
require 'thread'
module DL
- SEM = Mutex.new
+ # The mutual exclusion (Mutex) semaphore for the DL module
+ SEM = Mutex.new # :nodoc:
if DL.fiddle?
- CdeclCallbackProcs = {}
- CdeclCallbackAddrs = {}
- StdcallCallbackProcs = {}
- StdcallCallbackAddrs = {}
+ # A Hash of callback Procs
+ #
+ # Uses Fiddle
+ CdeclCallbackProcs = {} # :nodoc:
+
+ # A Hash of the addresses of callback Proc
+ #
+ # Uses Fiddle
+ CdeclCallbackAddrs = {} # :nodoc:
+
+ # A Hash of Stdcall callback Procs
+ #
+ # Uses Fiddle on win32
+ StdcallCallbackProcs = {} # :nodoc:
+
+ # A Hash of the addresses of Stdcall callback Procs
+ #
+ # Uses Fiddle on win32
+ StdcallCallbackAddrs = {} # :nodoc:
end
def set_callback_internal(proc_entry, addr_entry, argc, ty, abi = nil, &cbp)
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb
index f22a53aa84..eec65cdfd6 100644
--- a/ext/dl/lib/dl/import.rb
+++ b/ext/dl/lib/dl/import.rb
@@ -31,6 +31,22 @@ module DL
end
end
+ # DL::Importer includes the means to dynamically load libraries and build
+ # modules around them including calling extern functions within the C
+ # library that has been loaded.
+ #
+ # == Example
+ #
+ # require 'dl'
+ # require 'dl/import'
+ #
+ # module LibSum
+ # extend DL::Importer
+ # dlload './libsum.so'
+ # extern 'double sum(double*, int)'
+ # extern 'double split(double)'
+ # end
+ #
module Importer
include DL
include CParser
diff --git a/ext/dl/lib/dl/types.rb b/ext/dl/lib/dl/types.rb
index b85ac890cd..c79f74f95c 100644
--- a/ext/dl/lib/dl/types.rb
+++ b/ext/dl/lib/dl/types.rb
@@ -1,6 +1,29 @@
module DL
+ # Adds Windows type aliases to the including class for use with
+ # DL::Importer.
+ #
+ # The aliases added are:
+ # * ATOM
+ # * BOOL
+ # * BYTE
+ # * DWORD
+ # * HANDLE
+ # * HDC
+ # * HINSTANCE
+ # * HWND
+ # * LPCSTR
+ # * LPSTR
+ # * PBYTE
+ # * PDWORD
+ # * PHANDLE
+ # * PVOID
+ # * PWORD
+ # * UCHAR
+ # * UINT
+ # * ULONG
+ # * WORD
module Win32Types
- def included(m)
+ def included(m) # :nodoc:
m.module_eval{
typealias "DWORD", "unsigned long"
typealias "PDWORD", "unsigned long *"
@@ -26,8 +49,12 @@ module DL
module_function :included
end
+ # Adds basic type aliases to the including class for use with DL::Importer.
+ #
+ # The aliases added are +uint+ and +u_int+ (<tt>unsigned int</tt>) and
+ # +ulong+ and +u_long+ (<tt>unsigned long</tt>)
module BasicTypes
- def included(m)
+ def included(m) # :nodoc:
m.module_eval{
typealias "uint", "unsigned int"
typealias "u_int", "unsigned int"