home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / packages / win32ada / data.z / win32-assert.adb < prev    next >
Encoding:
Text File  |  1995-11-17  |  2.0 KB  |  58 lines

  1. -- $Source: /home/harp/1/proto/monoBANK/winnt/win32-assert.adb,v $ 
  2. -- $Revision: 1.4 $ $Date: 95/02/07 12:56:58 $ $Author: mg $ 
  3. -------------------------------------------------------------------------------
  4. --
  5. -- THIS FILE AND ANY ASSOCIATED DOCUMENTATION IS FURNISHED "AS IS" WITHOUT 
  6. -- WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
  7. -- TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR 
  8. -- PURPOSE.  The user assumes the entire risk as to the accuracy and the 
  9. -- use of this file.
  10. --
  11. -- Copyright (c) Intermetrics, Inc. 1995
  12. -- Royalty-free, unlimited, worldwide, non-exclusive use, modification, 
  13. -- reproduction and further distribution of this file is permitted.
  14. --
  15. -------------------------------------------------------------------------------
  16.  
  17.  
  18. with Interfaces.C,
  19.      Interfaces.C.Strings;
  20.  
  21. package body Win32.Assert is
  22.  
  23.     procedure Fail (
  24.         Message,
  25.         Source_File: Interfaces.C.Strings.chars_ptr;
  26.         Line_Number: Interfaces.C.Unsigned);
  27.  
  28.     pragma Import(C, Fail, "_assert");
  29.  
  30.     procedure Fail_Assertion (
  31.         Message,
  32.         Source_File : String;
  33.         Line_Number : Natural) is
  34.  
  35.         C_Message: aliased constant Interfaces.C.char_array := 
  36.             Interfaces.C.To_C(Message, Append_NUL => Standard.True);
  37.  
  38.         C_Source: aliased constant Interfaces.C.char_array := 
  39.             Interfaces.C.To_C(Source_File, Append_NUL => Standard.True);
  40.     begin
  41.         Fail(Interfaces.C.Strings.New_String(Message),
  42.              Interfaces.C.Strings.New_String(Source_File),
  43.              Interfaces.C.Unsigned(Line_Number));
  44.     end Fail_Assertion;
  45.  
  46.     procedure Assert (
  47.         Condition   : Boolean;
  48.         Message     : String := "(no message)";
  49.         Source_File : String := "(no source file)";
  50.         Line_Number : Natural := 0) is
  51.     begin
  52.         if DEBUG and then not Condition then
  53.             Fail_Assertion(Message, Source_File, Line_Number);
  54.         end if;
  55.     end Assert;
  56.  
  57. end Win32.Assert;
  58.