Jump to content

shineworld

Members
  • Content Count

    343
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by shineworld


  1. 3 hours ago, Uwe Raabe said:

    GetIt only installs in the current IDE. Not in any other registry node nor in the 64-bit one.

     

    Nevertheless, the packages exist and you can simply add them via Components - Install packages.

    Manually installed and works fine.
    Thanks.


  2. In a Python program, with DelphiVCL, I'm trying to use the TreeNode.Data field to contain extra node infos.


     

            def add_node_recursive(treeview: TreeView, parent_node: TreeNode, data: dict):
                axis_label = ''
                axis_id = data['id']
                if axis_id in ['X', 'Y', 'Z', 'A', 'B', 'C']:
                    axis_label = f'{axis_id}-axis'
                elif axis_id == 'TP':
                    axis_label = f'Toolpath'
                elif axis_id == 'MCS':
                    axis_label = f'Machine Zero Point'
                else:
                    axis_label = f'{axis_id}'
                axis_node = treeview.Items.AddChild(parent_node, axis_label)
                print(type(axis_node))
                print(type(axis_node.Data))
    
                
    [Dbg]>> print(type(axis_node))
    <class 'TreeNode'>
    [Dbg]>> print(type(axis_node.Data)) 
    <class 'NoneType'>
    [Dbg]>>> dir(axis_node)
    ['AbsoluteIndex', 'AfterConstruction', 'AlphaSort', 'Assign', 'BeforeDestruction', 'CPP_ABI_1', 'CPP_ABI_2', 'CPP_ABI_3', 'CheckState', 'Checked', 'ClassInfo', 'ClassName', 'ClassNameIs', 'ClassParent', 'ClassType', 'CleanupInstance', 'Collapse', 'Count', 'Create', 'CustomSort', 'Cut', 'Data', 'DefaultHandler', 'Delete', 'DeleteChildren', 'Deleting', 'Destroy', 'Dispatch', 'DisplayRect', 'DisposeOf', 'DropHighlighted', 'DropTarget', 'EditText', 'Enabled', 'EndEdit', 'Equals', 'Expand', 'Expanded', 'ExpandedImageIndex', 'FieldAddress', 'Focused', 'Free', 'FreeInstance', 'GetHandle', 'GetHashCode', 'GetInterface', 'GetInterfaceEntry', 'GetInterfaceTable', 'GetLastChild', 'GetNamePath', 'GetNext', 'GetNextChild', 'GetNextVisible', 'GetPrev', 'GetPrevChild', 'GetPrevVisible', 'Handle', 'HasAsParent', 'HasChildren', 'ImageIndex', 'Index', 'IndexOf', 'InheritsFrom', 'InitInstance', 'InstanceSize', 'IsFirstNode', 'IsVisible', 'Item', 'ItemId', 'Level', 'MakeVisible', 'MethodAddress', 'MethodName', 'MoveTo', 'NewInstance', 'OverlayIndex', 'Owner', 'Parent', 'QualifiedClassName', 'SafeCallException', 'Selected', 'SelectedIndex', 'SetProps', 'StateIndex', 'Text', 'ToList', 'ToString', 'ToTuple', 'TreeView', 'UnitName', 'UnitScope', '__bound__', '__class__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__owned__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'getFirstChild', 'getNextSibling', 'getPrevSibling']

    Initially node Data is set to NoneType but If I try to assign something I get:
     

    AttributeError: Error in setting property Data
    Error: Expected a PPyObject

     


  3. I'm using TreeView and I'm trying to disable the node collapsing with event OnCollapsing(Sender, Node, AllowCollapse).

    The Python method is called when a TreeView node is clicked for collapse:

        def TreeViewCollapsing(self, Sender, Node, AllowCollapse):
            AllowCollapse = False

    In the event I've set AllowCollapse to False, but in engine code the AllowCollapse := PyObject_IsTrue(LVarParam.Value) = 1; returns True:

    procedure TTVCollapsingEventHandler.DoEvent(Sender: TObject; Node: TTreeNode;
      var AllowCollapse: Boolean);
    var
      LPyObject, LPyNode, LPyTuple, LPyResult, LPyAllowCollapse: PPyObject;
      LVarParam: TPyDelphiVarParameter;
    begin
      Assert(Assigned(PyDelphiWrapper));
      if Assigned(Callable) and PythonOK() then
        with GetPythonEngine() do begin
          LPyObject := PyDelphiWrapper.Wrap(Sender);
          LPyNode := PyDelphiWrapper.Wrap(Node);
          LPyAllowCollapse := CreateVarParam(PyDelphiWrapper, AllowCollapse);
          LVarParam := PythonToDelphi(LPyAllowCollapse) as TPyDelphiVarParameter;
          LPyTuple := PyTuple_New(3);
          PyTuple_SetItem(LPyTuple, 0, LPyObject);
          PyTuple_SetItem(LPyTuple, 1, LPyNode);
          PyTuple_SetItem(LPyTuple, 2, LPyAllowCollapse);
          try
            LPyResult := PyObject_CallObject(Callable, LPyTuple);
            if Assigned(LPyResult) then begin
              Py_DECREF(LPyResult);
              AllowCollapse := PyObject_IsTrue(LVarParam.Value) = 1;
            end;
          finally
            Py_DECREF(LPyTuple);
          end;
          CheckError();
        end;
    end;

     


  4. I have always used and will always continue to use Delphi, as long as I am allowed in the company.

    Other languages and IDE environments have been added but it will be out of affection, I find the Delphi one very friendly, complex to the point and with things that are really needed.

    Of course, this depends a lot on the scope of the software, but in mine it is perfectly apt, where other environments become scattershot (too many things and not congruent with each other).

    What I admire about the Delphi RAD developers is their dedication.

    It has been dozens of years, that despite the fact that for many it is an outdated environment and language that they are dedicated to keeping it active, to meet new needs, limited as they all are by budget problems.

    But Delphi is still alive, and I easily shame the final products made by other colleagues with “newer” environments.

    Like everyone I would like to have more and more, and think that every problem it has can be magically solved in a short time, but you know, that is not the case for any of us who develop code for a living.

    You always look for a compromise between investment availability and goals to be achieved.

     

    • Like 2
    • Thanks 1

  5. Actually I've installaed Eclipse Temurin JDK with Hostspot 17.0.9+9 (x64) and shoud go fine ?
    PS: I'm used with RAD ISO which does not install JDK so it's necessary to be in the OS before to start.
    I don't know if web install does things to install also required JDK.


  6. Mmmm,
    I've tried a simple console program in Athens 12:
     

    program Project4;
    
    {$APPTYPE CONSOLE}
    
    {$R *.res}
    
    uses
      System.SysUtils,
      System.DateUtils,
      Winapi.Windows;
    
    var
      I: Integer;
      T1: Int64;
      T2: Int64;
      TD: Double;
      D1: TDateTime;
      D2: TDateTime;
      DiffMs: Int64;
      Frequency: Int64;
    
    function Delay: Integer;
    var
      I: Integer;
    begin
      Result := 0;
      for I := 0 to 1000000 do
        Inc(Result);
    end;
    
    begin
      FormatSettings.DecimalSeparator := '.';
      FormatSettings.ThousandSeparator := ',';
      try
        QueryPerformanceFrequency(Frequency);
    
        D1 := Now();
        QueryPerformanceCounter(T1);
        Delay;
        D2 := Now();
        QueryPerformanceCounter(T2);
    
        TD := (T2 - T1) * 1000 / Frequency;
        DiffMs := MilliSecondsBetween(D2, D1);
        Writeln(Format('Now() delta            = %d ms', [DiffMs]));
        Writeln(Format('QueryPerformance delta = %f ms', [TD]));
    
    
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
    end.

    Result:

    Now() delta            = 2 ms
    QueryPerformance delta = 2.15 ms
    

    The Delay is empirical, necessary just to have a little delay.
    Now() seems to capture 2ms of delta.


    Increasing delay of 10:

    Now() delta            = 17 ms
    QueryPerformance delta = 16.42 ms

    I don't know why they report 1 sec of precision in the documentation, but if it can be so, is terribile, because my OPC UA server timings are based on TDateTime and 1ms of resolutions is already 10 time bigger than OPC-UA tick of 100ns.

    • Like 1

  7. I work only on Windows but to get precise timings (below 1ms of accuracy) I use QueryPerformanceFrequency() and QueryPerformanceCounter().
    In case precise timings are not available I switch to timeGetTime()

    A messy unit is in attachment.

    PS:
    You can improve Windwos timeGetTime, gettickcount and sleep (DELPHI IDE does that) with:

    program XXX;
    
    uses
      System.SysUtils,
      Winapi.MMSystem,
      ...;
    
    {$R *.res}
    
    var
      TimeCaps: TTimeCaps;
      NeedToChangeTimerPrecsion: Boolean;
    
    begin
      // starts high precision timer
      if timeGetDevCaps(@TimeCaps, SizeOf(TTimeCaps)) = TIMERR_NOERROR then
        NeedToChangeTimerPrecsion := timeBeginPeriod(TimeCaps.wPeriodMin) = TIMERR_NOERROR
      else
        NeedToChangeTimerPrecsion := False;
    
      // initializes and runs application
      Application.Initialize;
      ...;
      Application.Run;
    
      // stops high precision timer
      if NeedToChangeTimerPrecsion then
        timeEndPeriod(TimeCaps.wPeriodMin);
    end.


     

    osTimeUtils.pas


  8. I use UPX by decade without any issue also with Virustotal and installed BitDefender. I guess it expand program in RAM.
    My 38.681.088 byte exe are compressed with LZMA to 10.189.312 byte with "upx-4.2.2.exe --best --lzma normal-version.exe upx-version.exe"


  9. 11 hours ago, DelphiUdIT said:

    The bundle compiled files (Bpl, Dcu, etc ...) are in the same paths of delphi system libraries, I think you must move them from there. So you must maintain them and the github version switching the windows registry.

    I think that @shineworld has done those steps.

    I've downloaded (cloned) Indy repository from github (https://github.com/IndySockets/Indy.git).
    Manually copied needed file in a source folder of my project.
    Added that folder in the project search path.
    Created the class only with code (no IDE objects placement) so I use only custom sources for Indy.

    This permitted me to add changes and work with latest git repository code, without remove native Indy tools from IDE.

    • Like 1

  10. 4 hours ago, Lars Fosdal said:

    @shineworld That is bigger than "fairly large", I'd say. 

    May I ask how much of the code is generated vs hand-crafted?

    I use a lot of third-party libraries and exclusively from source so the compiled code grows a lot. I may not have understood what is meant by “code is generated” but it is almost all hand-made code. This also includes compilers of various languages used by the system, for which, yes some of it is auto-generated (I use Gold Parser), but a few thousand lines. The program also different script languages, server types, and there the code grows. Empirically maybe I wrote 40% by hand, the rest is libraries, data, and different versions of UI.

     


  11. On 1/8/2025 at 7:03 AM, Tommi Prami said:

    And Delphi 64bit compiler is slow (at compiling) and resulted ASM is not too fast either.

    Personally, I held out as long as I could with BDS2006, whose problems I knew very well, which I had circumvented with tricks of all kinds. In the meantime, however, I always updated (purchased) the sucessive versions without ever using them. At a certain point I gave up, as, tired of using third-party libraries to have a partially Unicode program and of the memory limitations imposed by the 32-bit system (I use a lot of memory), I paid the price for years of dormancy and switched to Sydney and now Athens. Developing has become much easier, and all the things added to the language over the years allow me to greatly reduce the time required in going from concept to final code. I have fairly large projects (22 million lines of code) that I compile in both 32-bit and 64-bit, although recently I have been distributing only 64-bit versions, customers stick to the streetcar with their Win7 (it has not been supported by MS for years, and there is no point in persevering). Yes, 32-bit compilation is faster but as you can see from the image a complete build of the project I am working on, it is not that unbearable. The additional cost (twice the time) is worth the effort.

    image.thumb.png.59e795ea13421b5a5daaa901e96c9a12.png

×