home *** CD-ROM | disk | FTP | other *** search
/ Hacker / Hacker.iso / HACKER / DECOMP / DECAF / cp-utf8.ads < prev    next >
Encoding:
Text File  |  1996-09-19  |  2.5 KB  |  81 lines

  1. --
  2. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  3. -- Author: Gilles Demailly
  4. --
  5. --
  6. -- Permission to use, copy, modify, and distribute this software and its
  7. -- documentation for any purpose and without fee is hereby granted,
  8. -- provided that the above copyright and authorship notice appear in all
  9. -- copies and that both that copyright notice and this permission notice
  10. -- appear in supporting documentation.
  11. -- 
  12. -- The ARA makes no representations about the suitability of this software
  13. -- for any purpose.  It is provided "as is" without express
  14. -- or implied warranty.
  15. -- 
  16.  
  17. -- This child package provides the class Classes :
  18. -- a constant pool Utf8 information is used to represent a String
  19. -- coded with a kind-of Utf8 Standard.
  20. --
  21. -- For more information about Java Class file format check :
  22. --    The Java Virtual Machine Specification
  23. --    (Release 1.0 Beta - Draft - August 21, 1995)
  24.  
  25. with Basic_Definitions;
  26. use Basic_Definitions;
  27.  
  28. with Byte_Utilities;
  29.  
  30. with Ada.Strings.Wide_Unbounded;
  31.  
  32. package CP.Utf8 is
  33.  
  34.    -- the class Tag value in Java files
  35.    ------------------------------------
  36.    C_Class_Tag : constant Unsigned_8 := 1;
  37.  
  38.    type Utf8 is new CP_Info with private;
  39.       
  40.    type Acc_Utf8 is access all Utf8'Class;
  41.    
  42.    -- Decode a Constant Pool information
  43.    -------------------------------------
  44.    procedure Decode (From_File : Byte_Utilities.File_Type;
  45.                      Some_Info : access Utf8);
  46.  
  47.    -- Display a Constant Pool information
  48.    --------------------------------------
  49.    procedure Display (Some_Info : access Utf8;
  50.                       Context   : in Acc_CP_Infos);
  51.  
  52.    --
  53.    -- Differents Constant Pool information to string conversion functions
  54.    --
  55.    
  56.    function As_String
  57.                (Some_Info : access Utf8) return Wide_String;
  58.    
  59.    function Print_String
  60.                (Some_Info : access Utf8;
  61.                 Context   : in Acc_CP_Infos) return String;
  62.  
  63.    function Java_Decoded_String
  64.                (Some_Info : access Utf8;
  65.                 Context   : Acc_CP_Infos;
  66.                 Purpose   : Decoding_Purpose) return String;
  67.  
  68. private
  69.  
  70.    -- the Utf8 String is first coded as an array of Bytes and
  71.    -- then decoded to an Ada Wide_String
  72.    ----------------------------------------------------------
  73.    type Utf8 is new CP_Info with
  74.       record
  75.          Length   : Unsigned_16;
  76.          bytes    : Byte_Utilities.Acc_Bytes;
  77.          Contents : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String;
  78.       end record;
  79.       
  80. end CP.Utf8;
  81.