Browse Source

rtl: raise EContructException in TCharacter constructor (compatible to delphi behavior)

git-svn-id: trunk@19189 -
paul 14 years ago
parent
commit
98f6ec4a05
3 changed files with 10 additions and 0 deletions
  1. 7 0
      rtl/objpas/character.pas
  2. 1 0
      rtl/objpas/rtlconst.inc
  3. 2 0
      rtl/objpas/sysutils/sysutilh.inc

+ 7 - 0
rtl/objpas/character.pas

@@ -52,6 +52,8 @@ type
 
   TCharacter = class sealed
   public
+    constructor Create;
+
     class function ConvertFromUtf32(AChar : UCS4Char) : UnicodeString; static;
     class function ConvertToUtf32(const AString : UnicodeString; AIndex : Integer) : UCS4Char; overload; static;
     class function ConvertToUtf32(const AString : UnicodeString; AIndex : Integer; out ACharLength : Integer) : UCS4Char; overload; static;
@@ -184,6 +186,11 @@ end;
 
 { TCharacter }
 
+constructor TCharacter.Create;
+begin
+  raise ENoConstructException.CreateFmt(SClassCantBeConstructed, [ClassName]);
+end;
+
 class function TCharacter.ConvertFromUtf32(AChar : UCS4Char) : UnicodeString; static;
 begin
   if AChar < UCS4_HALF_BASE then

+ 1 - 0
rtl/objpas/rtlconst.inc

@@ -294,6 +294,7 @@ ResourceString
   SLowSurrogateOutOfRange       = 'Low surrogate $%x out of range [$DC00 - $DFFF]';
   SInvalidUTF32Char             = 'Invalid UTF32 character $%x. Valid UTF32 character must be in range [$0 - $10FFFF] except surrogate range [$D800-$DFFF]';
   SInvalidHighSurrogate         = 'Invalid high surrogate at index %d. High surrogate must be followed by a low surrogate pair';
+  SClassCantBeConstructed       = 'Class %s can not be constructed';
 
 { ---------------------------------------------------------------------
     Keysim Names

+ 2 - 0
rtl/objpas/sysutils/sysutilh.inc

@@ -202,6 +202,8 @@ type
    EArgumentException = class(Exception);
    EArgumentOutOfRangeException = class(EArgumentException);
 
+   ENoConstructException = class(Exception);
+
    { Exception handling routines }
    function ExceptObject: TObject;
    function ExceptAddr: Pointer;