--------------------------------------------------
-- This package was written by OCTAGRAM in 2009 --
--------------------------------------------------

with
  Interfaces, System;

use
  Interfaces;

package Jwa is
   pragma Preelaborate;

   ------------------------------------
   -- Pointer types for Interfaces.* --
   ------------------------------------

   type Integer_8_Ptr is access all Integer_8;
   type Integer_8_CPtr is access constant Integer_8;

   type Integer_16_Ptr is access all Integer_16;
   type Integer_16_CPtr is access constant Integer_16;

   type Integer_32_Ptr is access all Integer_32;
   type Integer_32_CPtr is access constant Integer_32;

   type Integer_64_Ptr is access all Integer_64;
   type Integer_64_CPtr is access constant Integer_64;


   type Unsigned_8_Ptr is access all Unsigned_8;
   type Unsigned_8_CPtr is access constant Unsigned_8;

   type Unsigned_16_Ptr is access all Unsigned_16;
   type Unsigned_16_CPtr is access constant Unsigned_16;

   type Unsigned_32_Ptr is access all Unsigned_32;
   type Unsigned_32_CPtr is access constant Unsigned_32;

   type Unsigned_64_Ptr is access all Unsigned_64;
   type Unsigned_64_CPtr is access constant Unsigned_64;

   ----------------
   -- Boolean_32 --
   ----------------

   type Boolean_32 is private;
   type Boolean_32_Ptr is access all Boolean_32;
   type Boolean_32_CPtr is access constant Boolean_32;

   False_32 : constant Boolean_32;
   True_32  : constant Boolean_32;

   function "+" (Item : Boolean_32) return Boolean;

   function "+" (Item : Boolean_32) return Integer_32;

   function "+" (Item : Boolean) return Boolean_32;

   function "+" (Item : Integer_32) return Boolean_32;

   function "=" (Left : Boolean_32; Right : Boolean) return Boolean;
   function "=" (Left : Boolean; Right : Boolean_32) return Boolean;
   function "=" (Left, Right : Boolean_32) return Boolean;

   function "and" (Left : Boolean_32; Right : Boolean) return Boolean;
   function "and" (Left : Boolean; Right : Boolean_32) return Boolean;
   function "and" (Left, Right : Boolean_32) return Boolean;

   function "or" (Left : Boolean_32; Right : Boolean) return Boolean;
   function "or" (Left : Boolean; Right : Boolean_32) return Boolean;
   function "or" (Left, Right : Boolean_32) return Boolean;

   function "xor" (Left : Boolean_32; Right : Boolean) return Boolean;
   function "xor" (Left : Boolean; Right : Boolean_32) return Boolean;
   function "xor" (Left, Right : Boolean_32) return Boolean;

   function "not" (Item : Boolean_32) return Boolean;

   pragma Inline ("=", "+", "and", "or", "xor", "not");

   ---------------
   -- Boolean_8 --
   ---------------

   type Boolean_8 is private;
   type Boolean_8_Ptr is access all Boolean_8;
   type Boolean_8_CPtr is access constant Boolean_8;

   False_8 : constant Boolean_8;
   True_8  : constant Boolean_8;

   function "+" (Item : Boolean_8) return Boolean;

   function "+" (Item : Boolean_8) return Integer_8;

   function "+" (Item : Boolean) return Boolean_8;

   function "+" (Item : Integer_8) return Boolean_8;

   function "=" (Left : Boolean_8; Right : Boolean) return Boolean;
   function "=" (Left : Boolean; Right : Boolean_8) return Boolean;
   function "=" (Left, Right : Boolean_8) return Boolean;

   function "and" (Left : Boolean_8; Right : Boolean) return Boolean;
   function "and" (Left : Boolean; Right : Boolean_8) return Boolean;
   function "and" (Left, Right : Boolean_8) return Boolean;

   function "or" (Left : Boolean_8; Right : Boolean) return Boolean;
   function "or" (Left : Boolean; Right : Boolean_8) return Boolean;
   function "or" (Left, Right : Boolean_8) return Boolean;

   function "xor" (Left : Boolean_8; Right : Boolean) return Boolean;
   function "xor" (Left : Boolean; Right : Boolean_8) return Boolean;
   function "xor" (Left, Right : Boolean_8) return Boolean;

   function "not" (Item : Boolean_8) return Boolean;

   pragma Inline ("=", "+", "and", "or", "xor", "not");

   -------------
   -- Strings --
   -------------

--     function "+" (Source : String) return access String;

   type String_8_Buffer is new String;
   type String_16_Buffer is new Wide_String;

   subtype Char_8 is Character;
   subtype Char_16 is Character;

   NUL_8 : constant Char_8 := Char_8'Val (0);
   NUL_16 : constant Char_16 := Char_16'Val (0);

   type Char_8_Ptr is new System.Address;
   type Char_16_Ptr is new System.Address;

   type Char_8_Ptr_Ptr is access all Char_8_Ptr;
   type Char_16_Ptr_Ptr is access all Char_16_Ptr;

   -----------------
   -- Address_Ptr --
   -----------------

   type Address_Ptr is access all System.Address;
--     type Address_Ptr_Ptr is access all Address_Ptr;

   ----------
   -- GUID --
   ----------

   type GUID_D4_Type is
     array (0 .. 7) of Unsigned_8;
   pragma Pack (GUID_D4_Type);

   type GUID_Type is record
      D1 : Unsigned_32;
      D2 : Unsigned_16;
      D3 : Unsigned_16;
      D4 : GUID_D4_Type;
   end record;
   pragma Pack (GUID_Type);

   type GUID_Ptr is access all GUID_Type;

   ------------
   -- Handle --
   ------------

   type Handle_Type is new System.Address;
   type Handle_Ptr is access all Handle_Type;

private

   type Boolean_32 is new Integer_32;

   False_32 : constant Boolean_32 := 0;
   True_32  : constant Boolean_32 := 1;

   type Boolean_8 is new Integer_8;

   False_8 : constant Boolean_8 := 0;
   True_8  : constant Boolean_8 := 1;

end Jwa;
