diff options
author | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2008-09-10 19:06:57 +0000 |
---|---|---|
committer | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2008-09-10 19:06:57 +0000 |
commit | 7a0675e6de018dcf839eccfae7d8c1326173c5c0 (patch) | |
tree | 18f6e098e3841ea2ac2e300dc7e5ba497042acb7 | |
parent | 781c662ddcebe3384afdc713f941ee960100892e (diff) | |
download | fpc-unicodestring.tar.gz |
* fixed unicodestring <-> variant handlingunicodestring
* fixed unicodestring property reading
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/unicodestring@11737 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r-- | compiler/htypechk.pas | 12 | ||||
-rw-r--r-- | compiler/symconst.pas | 2 | ||||
-rw-r--r-- | rtl/objpas/classes/classes.inc | 29 | ||||
-rw-r--r-- | rtl/objpas/classes/reader.inc | 12 |
4 files changed, 43 insertions, 12 deletions
diff --git a/compiler/htypechk.pas b/compiler/htypechk.pas index 3b455532aa..5eec724079 100644 --- a/compiler/htypechk.pas +++ b/compiler/htypechk.pas @@ -2238,7 +2238,7 @@ implementation (tve_single,tve_dblcurrency,tve_extended, tve_dblcurrency,tve_dblcurrency,tve_extended); variantstringdef_cl: array[tstringtype] of tvariantequaltype = - (tve_sstring,tve_astring,tve_astring,tve_wstring,tve_unicodestring); + (tve_sstring,tve_astring,tve_astring,tve_wstring,tve_ustring); begin case def.typ of orddef: @@ -2437,9 +2437,9 @@ implementation else if (currvcl=tve_boolformal) or (bestvcl=tve_boolformal) then if (currvcl=tve_boolformal) then - result:=ord(bestvcl in [tve_chari64,tve_sstring,tve_astring,tve_wstring]) + result:=ord(bestvcl in [tve_chari64,tve_sstring,tve_astring,tve_wstring,tve_ustring]) else - result:=-ord(currvcl in [tve_chari64,tve_sstring,tve_astring,tve_wstring]) + result:=-ord(currvcl in [tve_chari64,tve_sstring,tve_astring,tve_wstring,tve_ustring]) { byte is better than everything else (we assume both aren't byte, } { since there's only one parameter and that one can't be the same) } else if (currvcl=tve_byte) or @@ -2497,7 +2497,11 @@ implementation { widestring is better than everything left } else if (currvcl=tve_wstring) or (bestvcl=tve_wstring) then - result:=1-2*ord(bestvcl=tve_wstring); + result:=1-2*ord(bestvcl=tve_wstring) + { unicodestring is better than everything left } + else if (currvcl=tve_ustring) or + (bestvcl=tve_ustring) then + result:=1-2*ord(bestvcl=tve_ustring); { all possibilities should have been checked now } if (result=-5) then diff --git a/compiler/symconst.pas b/compiler/symconst.pas index d04bd25da9..12c1a911df 100644 --- a/compiler/symconst.pas +++ b/compiler/symconst.pas @@ -448,7 +448,7 @@ type tvariantequaltype = ( tve_incompatible, tve_chari64, - tve_unicodestring, + tve_ustring, tve_wstring, tve_astring, tve_sstring, diff --git a/rtl/objpas/classes/classes.inc b/rtl/objpas/classes/classes.inc index c9c508b7a4..74f0c55b76 100644 --- a/rtl/objpas/classes/classes.inc +++ b/rtl/objpas/classes/classes.inc @@ -893,13 +893,16 @@ procedure ObjectBinaryToText(Input, Output: TStream); end; procedure OutString(s: String); - begin OutChars(Pointer(S),PChar(S)+Length(S),@CharToOrd); end; procedure OutWString(W: WideString); + begin + OutChars(Pointer(W),pwidechar(W)+Length(W),@WideCharToOrd); + end; + procedure OutUString(W: UnicodeString); begin OutChars(Pointer(W),pwidechar(W)+Length(W),@WideCharToOrd); end; @@ -1043,6 +1046,25 @@ procedure ObjectBinaryToText(Input, Output: TStream); end; end; + function ReadUStr: UnicodeString; + var + len: DWord; + {$IFDEF ENDIAN_BIG} + i : integer; + {$ENDIF} + begin + len := ReadDWord; + SetLength(Result, len); + if (len > 0) then + begin + Input.ReadBuffer(Pointer(@Result[1])^, len*2); + {$IFDEF ENDIAN_BIG} + for i:=1 to len do + Result[i]:=widechar(SwapEndian(word(Result[i]))); + {$ENDIF} + end; + end; + procedure ReadPropList(indent: String); procedure ProcessValue(ValueType: TValueType; Indent: String); @@ -1134,6 +1156,11 @@ procedure ObjectBinaryToText(Input, Output: TStream); OutWString(ReadWStr); OutLn(''); end; + vaUString: + begin + OutWString(ReadWStr); + OutLn(''); + end; vaNil: OutLn('nil'); vaCollection: begin diff --git a/rtl/objpas/classes/reader.inc b/rtl/objpas/classes/reader.inc index 38123b27fd..57f54cedda 100644 --- a/rtl/objpas/classes/reader.inc +++ b/rtl/objpas/classes/reader.inc @@ -1248,12 +1248,12 @@ begin end; end; tkSString, tkLString, tkAString: - begin - TmpStr:=ReadString; - if Assigned(FOnReadStringProperty) then - FOnReadStringProperty(Self,Instance,PropInfo,TmpStr); - SetStrProp(Instance, PropInfo, TmpStr); - end; + begin + TmpStr:=ReadString; + if Assigned(FOnReadStringProperty) then + FOnReadStringProperty(Self,Instance,PropInfo,TmpStr); + SetStrProp(Instance, PropInfo, TmpStr); + end; tkUstring: SetUnicodeStrProp(Instance,PropInfo,ReadUnicodeString); tkWString: |