From 98f6ec4a0523df508303a9d4aa6e38ca9017d7ae Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 23 Sep 2011 02:50:40 +0000 Subject: [PATCH] rtl: raise EContructException in TCharacter constructor (compatible to delphi behavior) git-svn-id: trunk@19189 - --- rtl/objpas/character.pas | 7 +++++++ rtl/objpas/rtlconst.inc | 1 + rtl/objpas/sysutils/sysutilh.inc | 2 ++ 3 files changed, 10 insertions(+) diff --git a/rtl/objpas/character.pas b/rtl/objpas/character.pas index 33fcc7d6bc..1cc58d2aba 100644 --- a/rtl/objpas/character.pas +++ b/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 diff --git a/rtl/objpas/rtlconst.inc b/rtl/objpas/rtlconst.inc index dcba66ba52..368dcad5cc 100644 --- a/rtl/objpas/rtlconst.inc +++ b/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 diff --git a/rtl/objpas/sysutils/sysutilh.inc b/rtl/objpas/sysutils/sysutilh.inc index ec7ae50f4a..ffdc56f9ca 100644 --- a/rtl/objpas/sysutils/sysutilh.inc +++ b/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;