Skip to content

Commit 84c6fb3

Browse files
committed
Fix all examples for Delphi
1 parent 171cc36 commit 84c6fb3

13 files changed

+41
-13
lines changed

code-samples/generics_dictionary.dpr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ type
88
Name: string;
99
end;
1010

11-
TAppleDictionary = {$ifdef FPC}specialize{$endif} TDictionary<string, TApple>;
11+
TAppleDictionary = {$ifdef FPC}specialize{$endif} TDictionary<String, TApple>;
1212

1313
var
1414
Apples: TAppleDictionary;
1515
A, FoundA: TApple;
16-
ApplePair: TAppleDictionary.TDictionaryPair;
16+
ApplePair: {$ifdef FPC} TAppleDictionary.TDictionaryPair {$else} TPair<String, TApple> {$endif};
1717
AppleKey: string;
1818
begin
1919
Apples := TAppleDictionary.Create;

code-samples/generics_object_dictionary.dpr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ type
88
Name: string;
99
end;
1010

11-
TAppleDictionary = {$ifdef FPC}specialize{$endif} TObjectDictionary<string, TApple>;
11+
TAppleDictionary = {$ifdef FPC}specialize{$endif} TObjectDictionary<String, TApple>;
1212

1313
var
1414
Apples: TAppleDictionary;
1515
A: TApple;
16-
ApplePair: TAppleDictionary.TDictionaryPair;
16+
ApplePair: {$ifdef FPC} TAppleDictionary.TDictionaryPair {$else} TPair<String, TApple> {$endif};
1717
begin
1818
Apples := TAppleDictionary.Create([doOwnsValues]);
1919
try

code-samples/interfaces_com_with_ref_counting.dpr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ begin
5757
try
5858
UseThroughInterface(C1); // no need to use "as" operator
5959
UseThroughInterface(C2);
60-
if C3 is IMyInterface then
60+
if Supports(C3, IMyInterface) then
6161
UseThroughInterface(C3 as IMyInterface); // this will not execute
6262
finally
6363
{ C1 and C2 variables go out of scope and will be auto-destroyed now.

code-samples/interfaces_corba_test.dpr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{$ifdef FPC}
22
{$mode objfpc}{$H+}{$J-}
33
{$interfaces corba} // See below why we recommend CORBA interfaces
4+
{$else}
5+
{$message warn 'Delphi does not support CORBA interfaces, only COM, that change how memory is managed. This example is not valid in Delphi.'}
6+
begin end.
47
{$endif}
58
{$ifdef MSWINDOWS} {$apptype CONSOLE} {$endif}
69

code-samples/operator_overloading.dpr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{$ifdef FPC} {$mode objfpc}{$H+}{$J-} {$endif}
22
{$ifdef MSWINDOWS} {$apptype CONSOLE} {$endif}
33

4+
{$ifndef FPC}
5+
{$message warn 'Delphi does not support global operator overloading'}
6+
begin end.
7+
{$endif}
8+
49
uses
510
StrUtils;
611

code-samples/operator_overloading_classes.dpr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{$ifdef FPC} {$mode objfpc}{$H+}{$J-} {$endif}
22
{$ifdef MSWINDOWS} {$apptype CONSOLE} {$endif}
33

4+
{$ifndef FPC}
5+
{$message warn 'Delphi does not support global operator overloading'}
6+
begin end.
7+
{$endif}
8+
49
uses
510
SysUtils;
611

code-samples/operator_overloading_records.dpr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{$ifdef FPC} {$mode objfpc}{$H+}{$J-} {$endif}
22
{$ifdef MSWINDOWS} {$apptype CONSOLE} {$endif}
33

4-
uses
5-
SysUtils;
4+
{$ifndef FPC}
5+
{$message warn 'Delphi does not support global operator overloading'}
6+
begin end.
7+
{$endif}
8+
9+
uses SysUtils;
610

711
type
812
TMyRecord = record

code-samples/operator_overloading_records_lists.dpr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
{$endif}
55
{$ifdef MSWINDOWS} {$apptype CONSOLE} {$endif}
66

7+
{$ifndef FPC}
8+
{$message warn 'Delphi does not have FGL unit'}
9+
begin end.
10+
{$endif}
11+
712
uses
813
SysUtils, FGL;
914

code-samples_bg/generics_dictionary.dpr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ type
66
Name: string;
77
end;
88

9-
TAppleDictionary = {$ifdef FPC}specialize{$endif} TDictionary<string, TApple>;
9+
TAppleDictionary = {$ifdef FPC}specialize{$endif} TDictionary<String, TApple>;
1010

1111
var
1212
Apples: TAppleDictionary;
1313
A, FoundA: TApple;
14-
ApplePair: TAppleDictionary.TDictionaryPair;
14+
ApplePair: {$ifdef FPC} TAppleDictionary.TDictionaryPair {$else} TPair<String, TApple> {$endif};
1515
AppleKey: string;
1616
begin
1717
Apples := TAppleDictionary.Create;

code-samples_russian/interfaces_corba_test.dpr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{$ifdef FPC}
22
{$mode objfpc}{$H+}{$J-}
33
{$interfaces corba}
4+
{$else}
5+
{$message warn 'Delphi does not support CORBA interfaces, only COM, that change how memory is managed. This example is not valid in Delphi.'}
6+
begin end.
47
{$endif}
58
{$ifdef MSWINDOWS} {$apptype CONSOLE} {$endif}
69

0 commit comments

Comments
 (0)