1. ----------------------------------------------------------------------- 
  2. --          GtkAda - Ada95 binding for the Gimp Toolkit              -- 
  3. --                                                                   -- 
  4. --                        Copyright (C) 2000                         -- 
  5. --        Emmanuel Briot, Joel Brobecker and Arnaud Charlet          -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- As a special exception, if other files instantiate generics from  -- 
  23. -- this unit, or you link this unit with other files to produce an   -- 
  24. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  25. -- executable to be covered by the GNU General Public License. This  -- 
  26. -- exception does not however invalidate any other reasons why the   -- 
  27. -- executable file  might be covered by the  GNU Public License.     -- 
  28. ----------------------------------------------------------------------- 
  29.  
  30. --  <description> 
  31. --  This package provides wrapper code for dynamic module loading 
  32. --  </description> 
  33. --  <group>Glib, the general-purpose library</group> 
  34.  
  35. package Glib.Module is 
  36.    pragma Preelaborate; 
  37.  
  38.    type Module_Flags is mod 2 ** 32; 
  39.    Module_Bind_Lazy : constant Module_Flags := 2 ** 0; 
  40.    Module_Bind_Mask : constant Module_Flags := 16#1#; 
  41.  
  42.    type G_Module is new C_Proxy; 
  43.  
  44.    function Module_Supported return Boolean; 
  45.    --  Return True if dynamic module loading is supported 
  46.  
  47.    function Module_Open 
  48.      (File_Name : String; 
  49.       Flags     : Module_Flags := Module_Bind_Lazy) return G_Module; 
  50.    --  Open a module `file_name' and return handle, which is null on error. 
  51.  
  52.    function Module_Close (Module : G_Module) return Boolean; 
  53.    --  Close a previously opened module, return True on success. 
  54.  
  55.    procedure Module_Make_Resident (Module : G_Module); 
  56.    --  Make a module resident so Module_Close on it will be ignored 
  57.  
  58.    function Module_Error return String; 
  59.    --  Query the last module error as a string 
  60.  
  61.    generic 
  62.       type Pointer is private; 
  63.       --  This is typically a pointer to procedure/function. 
  64.  
  65.    procedure Generic_Module_Symbol 
  66.      (Module      : G_Module; 
  67.       Symbol_Name : String; 
  68.       Symbol      : out Pointer; 
  69.       Success     : out Boolean); 
  70.    --  Retrieve a symbol pointer from `module'. 
  71.    --  Success is set to True on success. 
  72.  
  73.    function Module_Name (Module : G_Module) return String; 
  74.    --  Retrieve the file name from an existing module 
  75.  
  76.    function Module_Build_Path 
  77.      (Directory   : String; 
  78.       Module_Name : String) return String; 
  79.    --  Build the actual file name containing a module. 
  80.    --  `directory' is the directory where the module file is supposed to be, or 
  81.    --  the null string in which case it should either be in the current 
  82.    --  directory or, on some operating systems, in some standard place, for 
  83.    --  instance on the PATH. Hence, to be absolutely sure to get the correct 
  84.    --  module, always pass in a directory. The file name consists of the 
  85.    --  directory, if supplied, and `module_name' suitably decorated accoring to 
  86.    --  the operating system's conventions (for instance lib*.so or *.dll). 
  87.    -- 
  88.    --  No checks are made that the file exists, or is of correct type. 
  89.  
  90. private 
  91.    pragma Import (C, Module_Make_Resident, "g_module_make_resident"); 
  92. end Glib.Module;