We share code between Delphi and Oxygene and use the following construct to simulate .Net enums in Delphi.
$IFDEF DELPHI}
TRunMode = record
class operator LogicalOr(const L: TRunMode; const R: TRunMode) : TRunMode;
class operator LogicalAnd(const L: TRunMode; const R: TRunMode) : TRunMode;
end;
{$ELSE}
TRunMode = public flags (none,ServerOnly,Normal,Offline,ReadDatabase);
{$ENDIF}
This enables us to write:
var r := TRunMode.Normal;
if r and TRunMode.Normal = TRunMode.Normal then
Unfortunately Oxygene fails to recognize LogicalOr and LogicalAnd and raises and error: (E55) Invalid operator name: “LogicalAnd”.
Two questions:
How can I tell Oxygene to completely ignore the LogicalOr and LogicalAnd lines?
Could you add support for these operators into Oxygene?
Thanks, Kees Vermeulen
mh
(marc hoffman)
May 8, 2020, 1:01pm
2
Kees,
.NET (and borrowing from that, for now, all of Oxygene on all platforms) has a specific and well-defined set of operators that can be overloaded; unfortunately there is no distinction between bitwise and logical and/or provided.
Please see Custom Operators for the complete list
surrounding the entire oprrarior declaration in an undefined IFDEF should suffice — does it not?
I’m not sure if that is feasible for .NET; it might be for other platforms. what is your target platform(s)?
yours,
marc
Unfortunately surrounding the entire declaration in an undefined IFDEF does not suffer. Still get the same error.
mh
(marc hoffman)
May 8, 2020, 1:34pm
4
Curious, that seems like a bug. can you send me a small test case? so ic an log an issue for the compiler team? thanx!
Thanks, logged as bugs://84275
Thanks, will follow this issue
1 Like
bugs://84275 got closed with status fixed.