'How to call a method from the delphi library in a python script and pass an object that implements the interface as an argument?

I have a library written in delphi and compiled into .so format. I want to include this library in my python code and call several methods from it. OS Linux Mint. When calling a method, you must pass an object that implements a specific interface (and may contain other objects that also implement their interfaces). The main problem is that I cannot transfer an object from python to a delphi module without additional transformations on the delphi side.

On the Internet I found the python ctypes module for working with dll and so, but it (as far as I understand) works with C libs and can only convert types to C types. Working with it did not give me any results. I also found the delphi module python4delphi (https://github.com/pyscripter/python4delphi) which should solve my problem, but I can't figure out how I need to change the source code of my library to delphi so that I can pass in python objects. I looked at demo examples and various guides, but everything that I found does not give me an understanding of how to do this with more complex objects.

Maybe someone faced such a task and can share a toy example of how you can implement the conversion of python objects to delphi objects inside delphi code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source