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

package body Jwa is

   ----------------
   -- Boolean_32 --
   ----------------
   
   function "+" (Item : Boolean_32) return Boolean is
   begin
      return Integer_32 (Item) /= 0;
   end "+";

   function "+" (Item : Boolean_32) return Integer_32 is
   begin
      return Integer_32 (Item);
   end "+";

   function "+" (Item : Boolean) return Boolean_32 is
   begin
      return Boolean'Pos (Item);
   end "+";
      
   function "+" (Item : Integer_32) return Boolean_32 is
   begin
      return Boolean_32 (Item);
   end "+";

   function "=" (Left : Boolean_32; Right : Boolean) return Boolean is
   begin
      return Right = (Integer_32 (Left) /= 0);
   end "=";

   function "=" (Left : Boolean; Right : Boolean_32) return Boolean is
   begin
      return Left = (Integer_32 (Right) /= 0);
   end "=";

   function "=" (Left, Right : Boolean_32) return Boolean is
   begin
      return (Integer_32 (Left) /= 0)
           = (Integer_32 (Right) /= 0);
   end "=";

   function "and" (Left : Boolean_32; Right : Boolean) return Boolean is
   begin
      return Right and (Integer_32 (Left) /= 0);
   end "and";

   function "and" (Left : Boolean; Right : Boolean_32) return Boolean is
   begin
      return Left and (Integer_32 (Right) /= 0);
   end "and";

   function "and" (Left, Right : Boolean_32) return Boolean is
   begin
      return Integer_32 (Left) /= 0
         and Integer_32 (Right) /= 0;
   end "and";
      
   function "or" (Left : Boolean_32; Right : Boolean) return Boolean is
   begin
      return Right or (Integer_32 (Left) /= 0);
   end "or";

   function "or" (Left : Boolean; Right : Boolean_32) return Boolean is
   begin
      return Left or (Integer_32 (Right) /= 0);
   end "or";

   function "or" (Left, Right : Boolean_32) return Boolean is
   begin
      return Integer_32 (Left) /= 0
          or Integer_32 (Right) /= 0;
   end "or";

   function "xor" (Left : Boolean_32; Right : Boolean) return Boolean is
   begin
      return Right xor (Integer_32 (Left) /= 0);
   end "xor";

   function "xor" (Left : Boolean; Right : Boolean_32) return Boolean is
   begin
      return Left xor (Integer_32 (Right) /= 0);
   end "xor";
      
   function "xor" (Left, Right : Boolean_32) return Boolean is
   begin
      return Integer_32 (Left) /= 0
         xor Integer_32 (Right) /= 0;
   end "xor";

   function "not" (Item : Boolean_32) return Boolean is
   begin
      return Integer_32 (Item) = 0;
   end "not";

   ---------------
   -- Boolean_8 --
   ---------------
   
   function "+" (Item : Boolean_8) return Boolean is
   begin
      return Integer_8 (Item) /= 0;
   end "+";

   function "+" (Item : Boolean_8) return Integer_8 is
   begin
      return Integer_8 (Item);
   end "+";

   function "+" (Item : Boolean) return Boolean_8 is
   begin
      return Boolean'Pos (Item);
   end "+";
      
   function "+" (Item : Integer_8) return Boolean_8 is
   begin
      return Boolean_8 (Item);
   end "+";

   function "=" (Left : Boolean_8; Right : Boolean) return Boolean is
   begin
      return Right = (Integer_8 (Left) /= 0);
   end "=";

   function "=" (Left : Boolean; Right : Boolean_8) return Boolean is
   begin
      return Left = (Integer_8 (Right) /= 0);
   end "=";

   function "=" (Left, Right : Boolean_8) return Boolean is
   begin
      return (Integer_8 (Left) /= 0)
           = (Integer_8 (Right) /= 0);
   end "=";

   function "and" (Left : Boolean_8; Right : Boolean) return Boolean is
   begin
      return Right and (Integer_8 (Left) /= 0);
   end "and";

   function "and" (Left : Boolean; Right : Boolean_8) return Boolean is
   begin
      return Left and (Integer_8 (Right) /= 0);
   end "and";

   function "and" (Left, Right : Boolean_8) return Boolean is
   begin
      return Integer_8 (Left) /= 0
         and Integer_8 (Right) /= 0;
   end "and";
      
   function "or" (Left : Boolean_8; Right : Boolean) return Boolean is
   begin
      return Right or (Integer_8 (Left) /= 0);
   end "or";

   function "or" (Left : Boolean; Right : Boolean_8) return Boolean is
   begin
      return Left or (Integer_8 (Right) /= 0);
   end "or";

   function "or" (Left, Right : Boolean_8) return Boolean is
   begin
      return Integer_8 (Left) /= 0
          or Integer_8 (Right) /= 0;
   end "or";

   function "xor" (Left : Boolean_8; Right : Boolean) return Boolean is
   begin
      return Right xor (Integer_8 (Left) /= 0);
   end "xor";

   function "xor" (Left : Boolean; Right : Boolean_8) return Boolean is
   begin
      return Left xor (Integer_8 (Right) /= 0);
   end "xor";
      
   function "xor" (Left, Right : Boolean_8) return Boolean is
   begin
      return Integer_8 (Left) /= 0
         xor Integer_8 (Right) /= 0;
   end "xor";

   function "not" (Item : Boolean_8) return Boolean is
   begin
      return Integer_8 (Item) = 0;
   end "not";

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

   function "+" (Source : String) return access String is
   begin
      return new String'(Source & Character'Val (0));
   end "+";

end Jwa;
