Jump to content

hsauro

Members
  • Content Count

    88
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by hsauro

  1. I'd like to add doc strings to functions (or methods) that are in a wrapped Delphi object. I can see how to do it when adding the methods manually using AddDelphiMethod but haven't been able to figure out how to do it when using RegisterDelphiWrapper. I looked at the module RegisterDelphiWrapper creates but I couldn't see the methods in my Delphi object and I could trace where the methods were added, For example, given this class: {$METHODINFO ON} ThostAPI = class (TPersistent) function getVersion() : string; end; {$METHODINFO OFF} and registering via: host := THostAPI.Create (controller); DelphiWrapper.RegisterDelphiWrapper(TPyClassWrapper<THostAPI>).Initialize; DelphiWrapper.DefineVar('host', host); I'd like to add a doc string to getVersion()
  2. hsauro

    Adding docs strings to wrapped functions

    Thanks for the additional information, it would have taken me sometime to figure it out how to do it. The code works as given. One way to make it more manageable, which I might try, is to add the docs as attributes to the methods, then use rtti to pick out the attribute before wrapping, add the information to a dictionary then call the wrapper. The DocSever could then just look up the docs in the dictionary.
  3. hsauro

    Adding docs strings to wrapped functions

    I saw that interface, I wondered if that would be something relevant. I’ll look into it
  4. I particularly like https://www.amazon.com/Delphi-XE2-Foundations-Chris-Rolliston/dp/1477550895
  5. I'm using the WrapDelphiClasses unit to construct a Delphi class whose methods than can be called from Python. I have it working without problem for simple types and lists. However, I can't work out how to construct and return a numpy array to the python call. I'm generating data within delphi but I'd like to do some analysis from with Python. I looked at Demo35 and it describes the construction of a numpy array but I am not sure what to return from Delphi. I am currently testing it with this small test case: function ThostAPI.getNumpy : Variant; var np: Variant; arr: Variant; begin np := Import('numpy'); arr := np.array(BuiltinModule.range(10)); result := arr; end; But when I call this from python it returns None. What is the right way to return a numpy array from Delphi? I'm currently using Delphi 11.3 and the python4delphi that came with getit,. I think however there is a newer version which could be the issue as I know some buffer code has been added.
  6. It works! I can return a numpy array and list easily. Thank you!
  7. I updated the sources yesterday afternoon. I'll take another look at the repo. I see there are some changes from 9 hours ago. I'll update to see if that helps.
  8. Thanks for the reply. I tried a very simple example to try it out with no arguments, a method that just returns a list of NULLs but I'm getting a runtime error (I also used setitem to fill the list in case that was the problem, but same error). This is the method: function ThostAPI.NewList : PPyObject; begin Result := GetPythonEngine.PyList_New(5); end; and here is the runtime error when using this python code from app import host x = host.NewList () TypeError: Call "NewList" returned a value that could not be converted to Python Error: Unsupported conversion from TValue to Python value I couldn't resolve the issue so I started to use the more low level calls (not using the wrapping unit) and I can return lists and numpy arrays to python. But it would be interesting to know what might be the issue with the above code. The class that contains NewList is just: {$METHODINFO ON} ThostAPI = class (TPersistent) function NewList : PPyObject; end; {$METHODINFO OFF} In the FormCreate I just have: initPython; host := THostAPI.Create (); DelphiWrapper.RegisterDelphiWrapper(TPyClassWrapper<THostAPI>).Initialize; DelphiWrapper.DefineVar('host', host);
  9. I updated to the latest 2023 version of delphi4python. It required some changes but it works without issue. The ability to automatically wrap either a class or an instanciated object requires hardly any effort on the Delphi side. I still need to figure out how to return a numpy array from Delphi to python, via a python call at the Python end.
  10. hsauro

    CPas - C for Delphi

    Out of curiosity I checked the original GitHub link, the page has vanished.
  11. I do Windows/Mac tools, so for me I’d like to see improvements to FMX, particularly the grid so that it had some of the same functionality as the VCL version. Some small improvements to the FMX TMemo would be nice as-well. I wish they would open the FMX to others so that the community could help since it seams Embarcadero is resource limited. The last thing that would be nice to have is the ability to generate webassembly. I’m starting to develop more and more client side web tools. I’ve used pas2js with success but Delphi must be one of the last major compilers not to support webassembly.
  12. hsauro

    Opensource scripting language?

    Your best bet given your requirements is lua, mentioned previously. Used a lot in gaming apps.
  13. hsauro

    How to force update to label during a loop

    Label1.refresh should work I think at least on windows it should.
  14. Are you saying that it would be illegal to ask a friend to compile Delphi source code on their own copy and send me the exe?
  15. hsauro

    Access MongoDB Atlas

    Has anyone had any experience in connecting FireDAC to MongoDB Atlas? I can connect to the database easily using the MongoDB atlas compass application and I can also easily connect to it from python using pymongo, but I can't fathom how to connect to it via Delphi. I am using Delphi Pro 11.1, so I assume it has the capabilities to connect. I noticed someone asked a similar question last year on StackOverflow, but there was no response. If I have to I can call python from Delphi. https://stackoverflow.com/questions/68401095/connection-to-mongodb-atlas-with-delphi What I have done is copied over the two monogo specific DLLs I need, added a FDConnection to a VCl windows and double click that to bring up a dialog box and enter the details but I can't seem to get it to work. The main error is failing to resolve mongodb+srv which I believe is the server name
  16. hsauro

    Access MongoDB Atlas

    I managed to get REST API working on MongoDB atlas.
  17. hsauro

    Access MongoDB Atlas

    I just had another thought, MongoDB has a rest API which might do the trick.
  18. hsauro

    Access MongoDB Atlas

    Do you know whether this will work on the Mac? I noticed it needs a couple of DLLs. I wonder if there are equivalent dylibs?
  19. hsauro

    Access MongoDB Atlas

    As an experiment I set up my own mongodb on a spare linux machine. I can connect from other clients except Delphi. My conclusion is that mongo support for Delphi is probably broken.
  20. hsauro

    Community Edition expiring again, no new keys

    Of course it’s their product to do as they wish but I would have thought increasing the developer community would be a priority especially for attracting a younger generation. A student or hobbyist isn’t going to pay $1600 when there are other less expensive options. The alternative options tend however to be less productive but the current generation doesn’t know this. Without a pool of skilled Delphi developers a company will just use other development environments where they can get the expertise. I think the community edition serves an important service and should be directed specifically to those interested in developing open source code or hobbyists who Ike to try out new software. I wholeheartedly agree that if someone makes money out Delphi then they are obliged to purchase the full version. The threshold for making money can be debated, but the current $5000 is a little on the low side I think.
  21. hsauro

    Community Edition expiring again, no new keys

    François Piette wanted me to forward this message from Delphi Developer on facebook, so here it is (note I'm the messenger) "I think that the 3 registrations is for the same serial number that you get for one year. You get a new one each year. Why do you need more than 3 registration? Did you reformat your computer? If you have to reformat so often then consider making a full bakcup right after a fresh install with everything you need and then when you feel necessary to refresh you computer, don't reformat but restore your backup. Your Delphi registration will still be there."
  22. hsauro

    Community Edition expiring again, no new keys

    I agree, what it means is the company hasn’t thought this through properly. I suspect there is a tension between the embarcardero employees we know and who’d like to see the Delphi community to grow and upper management who see the short term loss of dollars and probably would like to see the community edition go away. What we have is a compromise between the two groups.
  23. hsauro

    Community Edition expiring again, no new keys

    Can you create a new user account with a new name or does it check the ip address where the community version is installed?
  24. hsauro

    Interfaces - Time to face my ignorance.

    Most articles will explain the properties of interfaces but rarely why and when you’d use them. Someone pointed me to this article (search for interfaces) and it helped me a lot to understand why they can be useful. http://www.unigui.com/doc/online_help/user-interface.htm?fbclid=IwAR12Yq3agChFOoUvH4OE8K9gHApA6y-p6NdIHejeRKSxjEmmEMwOhpP0CNw
×