Skip to content

Commit 1559b61

Browse files
committed
Removed UNICODE conditional defines. Pre-Unicode Delphi is not supported.
Also removed TinyWideStrings.pas.
1 parent f5906c6 commit 1559b61

File tree

6 files changed

+5
-248
lines changed

6 files changed

+5
-248
lines changed

PythonForDelphi/Components/Sources/Core/PythonEngine.pas

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,6 @@ interface
8383
SysUtils,
8484
SyncObjs,
8585
Variants,
86-
{$IFDEF DELPHI2005_OR_HIGHER}
87-
{$IFNDEF UNICODE}
88-
WideStrings,
89-
{$ENDIF}
90-
{$ELSE}
91-
TinyWideStrings,
92-
{$ENDIF}
9386
MethodCallBack;
9487

9588
//#######################################################
@@ -99,13 +92,6 @@ interface
9992
//#######################################################
10093

10194
type
102-
{$IFNDEF UNICODE}
103-
UnicodeString = WideString;
104-
TUnicodeStringList = TWideStringList;
105-
{$ELSE}
106-
TUnicodeStringList = TStringList;
107-
{$ENDIF}
108-
10995
{$IFNDEF FPC}
11096
{$IF CompilerVersion < 21}
11197
NativeInt = integer;
@@ -1431,7 +1417,7 @@ EPyWindowsError = class (EPyOSError);
14311417
TReceiveUniDataEvent = procedure (Sender: TObject; var Data : UnicodeString ) of object;
14321418
IOChar = WideChar;
14331419
IOString = UnicodeString;
1434-
TIOStringList = TUnicodeStringList;
1420+
TIOStringList = TStringList;
14351421

14361422
{$IF not Defined(FPC) and (CompilerVersion >= 23)}
14371423
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
@@ -5937,7 +5923,6 @@ function TPythonEngine.VariantAsPyObject( const V : Variant ) : PPyObject;
59375923
s := AnsiString(DeRefV);
59385924
Result := PyString_FromStringAndSize(PAnsiChar(s), Length(s));
59395925
end;
5940-
{$IFDEF UNICODE}
59415926
varUString:
59425927
begin
59435928
wStr := DeRefV;
@@ -5948,7 +5933,6 @@ function TPythonEngine.VariantAsPyObject( const V : Variant ) : PPyObject;
59485933
Result := PyString_FromStringAndSize(PAnsiChar(s), Length(s));
59495934
{$ENDIF}
59505935
end;
5951-
{$ENDIF}
59525936
else
59535937
if VarType(DeRefV) and varArray <> 0 then
59545938
begin
@@ -6194,15 +6178,13 @@ function TPythonEngine.VarRecAsPyObject( v : TVarRec ) : PPyObject;
61946178
else
61956179
Result := PyUnicode_FromWideString( '' );
61966180
end;
6197-
{$IFDEF UNICODE}
61986181
vtUnicodeString:
61996182
begin
62006183
if Assigned(v.VUnicodeString) then
62016184
Result := PyUnicode_FromWideString( UnicodeString(v.VUnicodeString) )
62026185
else
62036186
Result := PyUnicode_FromWideString( '' );
62046187
end;
6205-
{$ENDIF}
62066188
else
62076189
Raise Exception.Create('Argument type not allowed');
62086190
end;
@@ -6307,15 +6289,13 @@ function TPythonEngine.ArrayToPyDict( items : array of const) : PPyObject;
63076289
else
63086290
Result := '';
63096291
end;
6310-
{$IFDEF UNICODE}
63116292
vtUnicodeString:
63126293
begin
63136294
if Assigned(v.VUnicodeString) then
63146295
Result := AnsiString(UnicodeString(v.VUnicodeString))
63156296
else
63166297
Result := '';
63176298
end;
6318-
{$ENDIF}
63196299
else
63206300
Raise Exception.Create('Argument type not allowed');
63216301
end;
@@ -9228,9 +9208,7 @@ function TPythonDelphiVar.IsVariantOk( const v : Variant ) : Boolean;
92289208
(t = varOleStr) or
92299209
(t = varBoolean) or
92309210
(t = varByte) or
9231-
{$IFDEF UNICODE}
92329211
(t = varUString) or
9233-
{$ENDIF}
92349212
(t = varString);
92359213
end;
92369214

PythonForDelphi/Components/Sources/Core/PythonGUIInputOutput.pas

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ constructor TPythonGUIInputOutput.Create( AOwner : TComponent );
203203
fWinHandle := Classes.AllocateHWnd(pyGUIOutputWndProc);
204204
{$ENDIF}
205205
{$ENDIF}
206-
{$IFDEF UNICODE}
207206
UnicodeIO := True;
208-
{$ENDIF}
209207
end;
210208

211209
{------------------------------------------------------------------------------}

PythonForDelphi/Components/Sources/Core/TinyWideStrings.pas

Lines changed: 0 additions & 187 deletions
This file was deleted.

PythonForDelphi/Components/Sources/Core/VarPyth.pas

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ procedure TPythonVariantType.BinaryOp(var Left: TVarData;
771771
begin
772772
if Right.VType = VarType then
773773
case Left.VType of
774-
varString {$IFDEF UNICODE}, varUString {$ENDIF}:
774+
varString, varUString:
775775
case AOperator of
776776
opAdd:
777777
Variant(Left) := Variant(Left) + TPythonVarData(Right).VPython.AsString;
@@ -833,15 +833,11 @@ procedure TPythonVariantType.CastTo(var Dest: TVarData;
833833
begin
834834
if Source.VType = VarType then
835835
case AVarType of
836-
varOleStr {$IFDEF UNICODE}, varUString {$ENDIF} :
836+
varOleStr, varUString:
837837
VarDataFromOleStr(Dest, TPythonVarData(Source).VPython.AsWideString);
838838
varString:
839-
{$IFDEF UNICODE}
840839
// Preserve AnsiStrings
841840
VarDataFromLStr(Dest, TPythonVarData(Source).VPython.AsAnsiString);
842-
{$ELSE}
843-
VarDataFromStr(Dest, TPythonVarData(Source).VPython.AsString);
844-
{$ENDIF}
845841
else
846842
if AVarType and varTypeMask = varBoolean then
847843
begin
@@ -1188,9 +1184,7 @@ TStringDesc = record
11881184
begin
11891185
if (LArgType = varVariant) and
11901186
(PVarData(LParamPtr^)^.VType = varString)
1191-
{$IFDEF UNICODE}
11921187
or (PVarData(LParamPtr)^.VType = varUString)
1193-
{$ENDIF}
11941188
then
11951189
//VarCast(PVariant(ParamPtr^)^, PVariant(ParamPtr^)^, varOleStr);
11961190
VarDataCastTo(PVarData(LParamPtr^)^, PVarData(LParamPtr^)^, varOleStr);
@@ -1201,22 +1195,16 @@ TStringDesc = record
12011195
// value is a variant
12021196
else if LArgType = varVariant then
12031197
if (PVarData(LParamPtr)^.VType = varString)
1204-
{$IFDEF UNICODE}
12051198
or (PVarData(LParamPtr)^.VType = varUString)
1206-
{$ENDIF}
12071199
then
12081200
begin
12091201
with LStrings[LStrCount] do
12101202
begin
12111203
//BStr := StringToOleStr(AnsiString(PVarData(LParamPtr)^.VString));
1212-
{$IFDEF UNICODE}
12131204
if (PVarData(LParamPtr)^.VType = varString) then
12141205
BStr := WideString(System.Copy(AnsiString(PVarData(LParamPtr)^.VString), 1, MaxInt))
12151206
else
12161207
BStr := System.Copy(UnicodeString(PVarData(LParamPtr)^.VUString), 1, MaxInt);
1217-
{$ELSE}
1218-
BStr := System.Copy(AnsiString(PVarData(LParamPtr)^.VString), 1, MaxInt);
1219-
{$ENDIF}
12201208
PStr := nil;
12211209
LArguments[I].VType := varOleStr;
12221210
LArguments[I].VOleStr := PWideChar(BStr);
@@ -1821,11 +1809,7 @@ function TPythonVariantType.LeftPromotion(const V: TVarData;
18211809
begin
18221810
{ TypeX Op Python }
18231811
if (AOperator = opAdd) and VarDataIsStr(V) then
1824-
{$IFDEF UNICODE}
18251812
RequiredVarType := varUString
1826-
{$ELSE}
1827-
RequiredVarType := varString
1828-
{$ENDIF}
18291813
else
18301814
RequiredVarType := VarType;
18311815

PythonForDelphi/Demos/Demo25/fmMain.dfm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ object Main: TMain
3737
end
3838
object Panel1: TPanel
3939
Left = 0
40-
Top = 421
40+
Top = 420
4141
Width = 753
4242
Height = 102
4343
Align = alBottom
@@ -232,7 +232,7 @@ object Main: TMain
232232
Left = 0
233233
Top = 254
234234
Width = 753
235-
Height = 167
235+
Height = 166
236236
Align = alClient
237237
Lines.Strings = (
238238
'class XYZ(object):'

0 commit comments

Comments
 (0)