Browse Source

* fix by Inoussa OUEDRAOGO to improve UnicodeString property handling, resolves #12224

git-svn-id: trunk@11832 -
florian 17 years ago
parent
commit
50012c2357
3 changed files with 56 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 8 0
      rtl/objpas/typinfo.pp
  3. 47 0
      tests/webtbs/tw12224.pp

+ 1 - 0
.gitattributes

@@ -8561,6 +8561,7 @@ tests/webtbs/tw12186.pp svneol=native#text/plain
 tests/webtbs/tw12202.pp svneol=native#text/plain
 tests/webtbs/tw12202.pp svneol=native#text/plain
 tests/webtbs/tw12214.pp svneol=native#text/plain
 tests/webtbs/tw12214.pp svneol=native#text/plain
 tests/webtbs/tw1222.pp svneol=native#text/plain
 tests/webtbs/tw1222.pp svneol=native#text/plain
+tests/webtbs/tw12224.pp svneol=native#text/plain
 tests/webtbs/tw1223.pp svneol=native#text/plain
 tests/webtbs/tw1223.pp svneol=native#text/plain
 tests/webtbs/tw12233.pp svneol=native#text/plain
 tests/webtbs/tw12233.pp svneol=native#text/plain
 tests/webtbs/tw1228.pp svneol=native#text/plain
 tests/webtbs/tw1228.pp svneol=native#text/plain

+ 8 - 0
rtl/objpas/typinfo.pp

@@ -1216,6 +1216,8 @@ begin
   case Propinfo^.PropType^.Kind of
   case Propinfo^.PropType^.Kind of
     tkWString:
     tkWString:
       Result:=GetWideStrProp(Instance,PropInfo);
       Result:=GetWideStrProp(Instance,PropInfo);
+    tkUString :
+      Result := GetUnicodeStrProp(Instance,PropInfo);
     tkSString:
     tkSString:
       begin
       begin
         case (PropInfo^.PropProcs) and 3 of
         case (PropInfo^.PropProcs) and 3 of
@@ -1272,6 +1274,8 @@ begin
   case Propinfo^.PropType^.Kind of
   case Propinfo^.PropType^.Kind of
     tkWString:
     tkWString:
       SetWideStrProp(Instance,PropInfo,Value);
       SetWideStrProp(Instance,PropInfo,Value);
+    tkUString:
+       SetUnicodeStrProp(Instance,PropInfo,Value);
     tkSString:
     tkSString:
       begin
       begin
         case (PropInfo^.PropProcs shr 2) and 3 of
         case (PropInfo^.PropProcs shr 2) and 3 of
@@ -1351,6 +1355,8 @@ begin
   case Propinfo^.PropType^.Kind of
   case Propinfo^.PropType^.Kind of
     tkSString,tkAString:
     tkSString,tkAString:
       Result:=GetStrProp(Instance,PropInfo);
       Result:=GetStrProp(Instance,PropInfo);
+    tkUString :
+      Result := GetUnicodeStrProp(Instance,PropInfo);
     tkWString:
     tkWString:
       begin
       begin
         case (PropInfo^.PropProcs) and 3 of
         case (PropInfo^.PropProcs) and 3 of
@@ -1385,6 +1391,8 @@ begin
   case Propinfo^.PropType^.Kind of
   case Propinfo^.PropType^.Kind of
     tkSString,tkAString:
     tkSString,tkAString:
        SetStrProp(Instance,PropInfo,Value);
        SetStrProp(Instance,PropInfo,Value);
+    tkUString:
+       SetUnicodeStrProp(Instance,PropInfo,Value);
     tkWString:
     tkWString:
       begin
       begin
         case (PropInfo^.PropProcs shr 2) and 3 of
         case (PropInfo^.PropProcs shr 2) and 3 of

+ 47 - 0
tests/webtbs/tw12224.pp

@@ -0,0 +1,47 @@
+program test_widestrprop_p2;
+{$mode objfpc}{$H+}
+uses
+  Classes, SysUtils, TypInfo;
+
+type
+  TClass_A = class(TPersistent)
+  private
+    Fwsp: UnicodeString;
+  published
+    property wsp : UnicodeString read Fwsp write Fwsp;
+  end;
+
+var
+  x : TClass_A;
+begin
+  x := TClass_A.Create();
+  WriteLn('Reading :');
+  x.wsp := 'azerty';
+  WriteLn(' Using GetUnicodeStrProp() : ',GetUnicodeStrProp(x,'wsp'));
+  if GetUnicodeStrProp(x,'wsp')<>'azerty' then
+    halt(1);
+  WriteLn(' Using GetStrProp() : ',GetStrProp(x,'wsp'));
+  if GetStrProp(x,'wsp')<>'azerty' then
+    halt(1);
+  WriteLn(' Using GetWideStrProp() : ',GetWideStrProp(x,'wsp'));
+  if GetWideStrProp(x,'wsp')<>'azerty' then
+    halt(1);
+
+  WriteLn('Writing :');
+  x.wsp := '';
+  SetUnicodeStrProp(x,'wsp','azerty');
+  WriteLn(' Using SetUnicodeStrPr() : ',x.wsp);
+  if x.wsp<>'azerty' then
+    halt(1);
+  x.wsp := '';
+  SetStrProp(x,'wsp','azerty');
+  WriteLn(' Using SetStrPr() : ',x.wsp);
+  if x.wsp<>'azerty' then
+    halt(1);
+  x.wsp := '';
+  SetWideStrProp(x,'wsp','azerty');
+  WriteLn(' Using SetWideStrPr() : ',x.wsp);
+  if x.wsp<>'azerty' then
+    halt(1);
+  writeln('ok');
+end.