Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 01/30/19 in all areas

  1. jbg

    IDE Fix pack for Rio

    The attached IDEFixPack development snapshot fixes this TCustomListBox IDEFixPack bug. IDEFixPackD103Reg64.7z
  2. DevExpress has published their potential road map for 2019 with an important question: do you need a FireMonkey Grid in 2019? https://community.devexpress.com/blogs/vcl/archive/2019/01/28/vcl-controls-2019-roadmap-your-vote-counts.aspx
  3. Attila Kovacs

    Caching with class variables

    I've lost the thread after this line "As it turns out, we can fix both problems simply by using class variables, properties, and methods functionality of the Delphi language:" The same code follows as already above the paragraph was., instead of the declaration of "TypeInfoCache" I think.
  4. Change "%minSdkVersion%" with "23"
  5. Primož Gabrijelčič

    Caching with class variables

    Exactly - I somehow deleted that line from the gist, while still keeping it in my local copy of the code. 😞 😞 😞 (Actually, this Move should not be 'if'-ed. Just always execute it.) I'll fix my blog, gist example and this post when I come home later today. Thank you for finding the bug!
  6. Dave Nottage

    Cross-platform discovery of device name and user name?

    The DW.OSDevice.xxx units here have implementations for GetDeviceName for iOS, Android, macOS, Windows and Linux: https://github.com/DelphiWorlds/KastriFree/tree/master/Core I could add something like GetUserName - which would likely return blank for iOS and Android
  7. Uwe Raabe

    Add Indexer problem

    I wonder how this folder is going to be used as Shared folder. For a non-admin installation that should rather be %APPDATA%\Raabe Software\Shared and not %APPDATA%\Raabe Software\MMX Code Explorer. On the other hand I can imagine some buggy setup scheme from my side. So whatever that registry RootDir entry points to, copy the Indexers folder into that folder and you should be done. I will investigate the setup for any glitches - or better - rethink the folder architecture in general.
  8. TiGü

    Caching with class variables

    Hi Primož, that's a nice piece of code, but i notice in my Delphi Tokyo, that the ens-Result for the TEnumSet (for valid values) is empty. But if you add a untyped Move, than it works: program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.TypInfo, System.Rtti, System.SysUtils; resourcestring SValueLiesOutsideAllowedRange = 'Value %d lies outside allowed range for %s (%d .. %d)'; type TypeInfoCache<T> = class class var FMinIntVal: Integer; FMaxIntVal: Integer; FIsSet: Boolean; public class constructor Create; class property MaxIntVal: Integer read FMaxIntVal; class property MinIntVal: Integer read FMinIntVal; class property IsSet: Boolean read FIsSet; end; Range<T> = record private class function MaxIntVal: Integer; static; inline; class function MinIntVal: Integer; static; inline; class procedure RaiseException(const Value: Integer); static; public class function Check(const Value: Integer): T; static; end; { Range<T> } class function Range<T>.Check(const Value: Integer): T; begin if (Value < MinIntVal) or (Value > MaxIntVal) then RaiseException(Value); if TypeInfoCache<T>.IsSet then begin Move(Value, Result, SizeOf(T)); // here is the magic end; end; class function Range<T>.MaxIntVal: Integer; begin Result := TypeInfoCache<T>.MaxIntVal; end; class function Range<T>.MinIntVal: Integer; begin Result := TypeInfoCache<T>.MinIntVal; end; class procedure Range<T>.RaiseException(const Value: Integer); begin raise Exception.CreateFmt(SValueLiesOutsideAllowedRange, [Value, PTypeInfo(TypeInfo(T)).Name, MinIntVal, MaxIntVal]); end; { TypeInfoCache<T> } class constructor TypeInfoCache<T>.Create; var ti: PTypeInfo; typeData: PTypeData; i: Integer; begin ti := TypeInfo(T); FIsSet := ti.Kind = tkSet; if FIsSet then ti := GetTypeData(ti).CompType^; typeData := GetTypeData(ti); FMinIntVal := typeData.MinValue; if FIsSet then begin FMaxIntVal := 0; for i := typeData.MinValue to typeData.MaxValue do FMaxIntVal := FMaxIntVal or (1 shl i); end else FMaxIntVal := typeData.MaxValue; end; type TEnum = (en1, en2, en3); TEnumSet = set of TEnum; var en: TEnum; ens: TEnumSet; begin try try en := Range<TEnum>.Check(0); en := Range<TEnum>.Check(2); en := Range<TEnum>.Check(3); except on E: Exception do Writeln('Expected exception: ', E.ClassName, ' ', E.Message); end; try ens := Range<TEnumSet>.Check(0); ens := Range<TEnumSet>.Check(2); ens := Range<TEnumSet>.Check(7); ens := Range<TEnumSet>.Check(8); except on E: Exception do Writeln('Expected exception: ', E.ClassName, ' ', E.Message); end; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; if DebugHook <> 0 then Readln; end.
  9. Very bad idea to use the distance since that involves sqrt. Do the searching with sqr distance and only call sqrt when you have the closest point.
  10. jbg

    IDE Fix pack for Rio

    That's because the bug is only fixed for the IDE. Your applications don't get the fix from the IDEFixPack.
×