Unchecked/Checked keyword

Seems this isn’t supported by Oxygene? Why?

https://msdn.microsoft.com/en-us/library/khy08726.aspx

Thanks, logged as bugs://74557

It is supported. Oxidizer doesn’t currently translate it though, I’ve logged a bug for that. It can use the standard pascal {$R+}/{$R-} range operators.

So these work fine in Oxygene?

{$R-}
{$Q-}

Yep. Also note that those are the defaults. R- and Q-

How is the syntax for unchecked conversion?
I currently have the problem that I need to cast a parameter which need to pass and access as Reflection.PropertyInfo and access the value through the GetValue and SetValue from an int into an UInt32 and back.
In C# I would simply do an unchecked conversion. (By the way, {$Q-} and {$R-} did not help - as anyway the default, as you have said before ;))

You don’t need to do that at all then. Casting from uint to int won’t cause overflows in {$Q-}{$R-} (the default). What will fail is casting an Object that hold int to uint, because of boxing. You’ll have to do something like UInt32(Int32(GetValueThatReturnsABoxedInt))

Sorry, I did not read your answer properly :slightly_smiling:

Together with your hint of boxing/unboxing I found a solution. But as the problem is, I don’t know, what type I get (it can be any int), I came up with the following solution:

function BIT(code: Tuple<System.Reflection.PropertyInfo, ToolboxCS.Base.SpezplaStructure>; item:Varying):Boolean;

begin
  var i:= Convert.ToUInt32(code.Item1.GetValue(code.Item2, nil));
  result := BIT(var i, item);
  var r := Convert.ChangeType(i, code.Item1.PropertyType);
  code.Item1.SetValue(code.Item2, r, nil);
end;

Maybe you have a better idea?

bugs://74557 got closed with status fixed.