From 0a9ac8567304e1e295d400dd038c726ec8d7caa1 Mon Sep 17 00:00:00 2001 From: ck Date: Thu, 26 Aug 2010 06:41:03 +0000 Subject: [PATCH] =?UTF-8?q?Patch=20from=20Fr=C3=A9d=C3=A9ric=20Hannes=20fo?= =?UTF-8?q?r=20PS=5FNOWIDESTRING=20support.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.remobjects.com/svn/pascalscript@234 5c9d2617-0215-0410-a2ee-e80e04d1c6d8 --- Source/uPSCompiler.pas | 11 +++++--- Source/uPSRuntime.pas | 58 +++++++++++++++++++++++++++++++----------- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/Source/uPSCompiler.pas b/Source/uPSCompiler.pas index 42b3fda..92b711b 100644 --- a/Source/uPSCompiler.pas +++ b/Source/uPSCompiler.pas @@ -12313,9 +12313,14 @@ begin AddType('UnicodeString', btUnicodeString); {$ENDIF} AddType('AnsiString', btString); - {$IFDEF DELPHI2009UP} - AddType('String', btUnicodeString); - ADdType('NativeString', btUnicodeString); + {$IFNDEF PS_NOWIDESTRING} + {$IFDEF DELPHI2009UP} + AddType('String', btUnicodeString); + AddType('NativeString', btUnicodeString); + {$ELSE} + AddType('String', btString); + AddType('NativeString', btString); + {$ENDIF} {$ELSE} AddType('String', btString); AddType('NativeString', btString); diff --git a/Source/uPSRuntime.pas b/Source/uPSRuntime.pas index 2bf12d8..cedb4fd 100644 --- a/Source/uPSRuntime.pas +++ b/Source/uPSRuntime.pas @@ -3131,8 +3131,12 @@ end; function VNGetString(const Src: TPSVariantIFC): String; begin - {$IFDEF DELPHI2009UP} - Result := VNGetUnicodeString(Src); + {$IFNDEF PS_NOWIDESTRING} + {$IFDEF DELPHI2009UP} + Result := VNGetUnicodeString(Src); + {$ELSE} + Result := VNGetAnsiString(Src); + {$ENDIF} {$ELSE} Result := VNGetAnsiString(Src); {$ENDIF} @@ -3140,8 +3144,12 @@ end; procedure VNSetString(const Src: TPSVariantIFC; const Val: String); begin - {$IFDEF DELPHI2009UP} - VNSetUnicodeString(Src, Val); + {$IFNDEF PS_NOWIDESTRING} + {$IFDEF DELPHI2009UP} + VNSetUnicodeString(Src, Val); + {$ELSE} + VNSetAnsiString(Src, Val); + {$ENDIF} {$ELSE} VNSetAnsiString(Src, Val); {$ENDIF} @@ -3267,8 +3275,12 @@ end; function VGetString(const Src: PIFVariant): String; begin - {$IFDEF DELPHI2009UP} - Result := PSGetUnicodeString(@PPSVariantData(src).Data, src.FType); + {$IFNDEF PS_NOWIDESTRING} + {$IFDEF DELPHI2009UP} + Result := PSGetUnicodeString(@PPSVariantData(src).Data, src.FType); + {$ELSE} + Result := PSGetAnsiString(@PPSVariantData(src).Data, src.FType); + {$ENDIF} {$ELSE} Result := PSGetAnsiString(@PPSVariantData(src).Data, src.FType); {$ENDIF} @@ -3278,8 +3290,12 @@ procedure VSetString(const Src: PIFVariant; const Val: string); var Dummy: Boolean; begin - {$IFDEF DELPHI2009UP} - PSSetUnicodeString(@PPSVariantData(src).Data, src.FType, Dummy, Val); + {$IFNDEF PS_NOWIDESTRING} + {$IFDEF DELPHI2009UP} + PSSetUnicodeString(@PPSVariantData(src).Data, src.FType, Dummy, Val); + {$ELSE} + PSSetAnsiString(@PPSVariantData(src).Data, src.FType, Dummy, Val); + {$ENDIF} {$ELSE} PSSetAnsiString(@PPSVariantData(src).Data, src.FType, Dummy, Val); {$ENDIF} @@ -3814,8 +3830,12 @@ end; function PSGetString(Src: Pointer; aType: TPSTypeRec): string; begin - {$IFDEF DELPHI2009UP} - result := PSGetUnicodeString(Src, aType); + {$IFNDEF PS_NOWIDESTRING} + {$IFDEF DELPHI2009UP} + result := PSGetUnicodeString(Src, aType); + {$ELSE} + result := PSGetAnsiString(Src, aType); + {$ENDIF} {$ELSE} result := PSGetAnsiString(Src, aType); {$ENDIF} @@ -3823,8 +3843,12 @@ end; procedure PSSetString(Src: Pointer; aType: TPSTypeRec; var Ok: Boolean; const Val: String); begin - {$IFDEF DELPHI2009UP} - PSSetUnicodeString(Src, aType, Ok, Val); + {$IFNDEF PS_NOWIDESTRING} + {$IFDEF DELPHI2009UP} + PSSetUnicodeString(Src, aType, Ok, Val); + {$ELSE} + PSSetAnsiString(Src, aType, Ok, Val); + {$ENDIF} {$ELSE} PSSetAnsiString(Src, aType, Ok, Val); {$ENDIF} @@ -12126,7 +12150,7 @@ end; function TPSStack.GetString(ItemNo: Longint): string; // calls the native method begin - result := {$IFDEF DELPHI2009UP}GetUnicodeString(ItemNo){$ELSE}GetAnsiString(ItemNo){$ENDIF}; + result := {$IFNDEF PS_NOWIDESTRING}{$IFDEF DELPHI2009UP}GetUnicodeString(ItemNo){$ELSE}GetAnsiString(ItemNo){$ENDIF}{$ELSE}GetAnsiString(ItemNo){$ENDIF}; end; function TPSStack.GetUInt(ItemNo: Longint): Cardinal; @@ -12346,8 +12370,12 @@ end; procedure TPSStack.SetString(ItemNo: Longint; const Data: string); begin - {$IFDEF DELPHI2009UP} - SetUnicodeString(ItemNo, Data); + {$IFNDEF PS_NOWIDESTRING} + {$IFDEF DELPHI2009UP} + SetUnicodeString(ItemNo, Data); + {$ELSE} + SetAnsiString(ItemNo, Data); + {$ENDIF} {$ELSE} SetAnsiString(ItemNo, Data); {$ENDIF}