1------------------------------------------------------------------------------ 2-- GtkAda - Ada95 binding for the Gimp Toolkit -- 3-- -- 4-- Copyright (C) 2000-2015, AdaCore -- 5-- -- 6-- This library is free software; you can redistribute it and/or modify it -- 7-- under terms of the GNU General Public License as published by the Free -- 8-- Software Foundation; either version 3, or (at your option) any later -- 9-- version. This library is distributed in the hope that it will be useful, -- 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- 11-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- 12-- -- 13-- As a special exception under Section 7 of GPL version 3, you are granted -- 14-- additional permissions described in the GCC Runtime Library Exception, -- 15-- version 3.1, as published by the Free Software Foundation. -- 16-- -- 17-- You should have received a copy of the GNU General Public License and -- 18-- a copy of the GCC Runtime Library Exception along with this program; -- 19-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 20-- <http://www.gnu.org/licenses/>. -- 21-- -- 22------------------------------------------------------------------------------ 23 24with Interfaces.C.Strings; use Interfaces.C.Strings; 25 26package body Glib.Module is 27 28 ---------------------- 29 -- Module_Supported -- 30 ---------------------- 31 32 function Module_Supported return Boolean is 33 function Internal return Gint; 34 pragma Import (C, Internal, "ada_g_module_supported"); 35 36 begin 37 return Internal /= 0; 38 end Module_Supported; 39 40 ----------------- 41 -- Module_Open -- 42 ----------------- 43 44 function Module_Open 45 (File_Name : String; 46 Flags : Module_Flags := Module_Bind_Lazy) return G_Module 47 is 48 function Internal 49 (File_Name : String; 50 Flags : Module_Flags) return G_Module; 51 pragma Import (C, Internal, "ada_g_module_open"); 52 53 begin 54 return Internal (File_Name & ASCII.NUL, Flags); 55 end Module_Open; 56 57 ------------------ 58 -- Module_Close -- 59 ------------------ 60 61 function Module_Close (Module : G_Module) return Boolean is 62 function Internal (Module : G_Module) return Gint; 63 pragma Import (C, Internal, "ada_g_module_close"); 64 65 begin 66 return Internal (Module) /= 0; 67 end Module_Close; 68 69 ------------------ 70 -- Module_Error -- 71 ------------------ 72 73 function Module_Error return String is 74 function Internal return chars_ptr; 75 pragma Import (C, Internal, "ada_g_module_error"); 76 77 begin 78 return Value (Internal); 79 end Module_Error; 80 81 --------------------------- 82 -- Generic_Module_Symbol -- 83 --------------------------- 84 85 procedure Generic_Module_Symbol 86 (Module : G_Module; 87 Symbol_Name : String; 88 Symbol : out Pointer; 89 Success : out Boolean) 90 is 91 function Internal 92 (Module : G_Module; 93 Symbol_Name : String; 94 Symbol : System.Address) return Gint; 95 pragma Import (C, Internal, "ada_g_module_symbol"); 96 97 Tmp : aliased Pointer; 98 99 begin 100 Success := Internal (Module, Symbol_Name & ASCII.NUL, Tmp'Address) /= 0; 101 Symbol := Tmp; 102 end Generic_Module_Symbol; 103 104 ----------------- 105 -- Module_Name -- 106 ----------------- 107 108 function Module_Name (Module : G_Module) return String is 109 function Internal (Module : G_Module) return chars_ptr; 110 pragma Import (C, Internal, "ada_g_module_name"); 111 112 begin 113 return Value (Internal (Module)); 114 end Module_Name; 115 116 ----------------------- 117 -- Module_Build_Path -- 118 ----------------------- 119 120 function Module_Build_Path 121 (Directory : String; 122 Module_Name : String) return String 123 is 124 function Internal 125 (Directory : String; Module_Name : String) return chars_ptr; 126 pragma Import (C, Internal, "ada_g_module_build_path"); 127 128 begin 129 return Value (Internal (Directory & ASCII.NUL, Module_Name & ASCII.NUL)); 130 end Module_Build_Path; 131 132end Glib.Module; 133