In Delphi there is a native function call functionality (http://docwiki.embarcadero.com/Libraries/Rio/en/System.Rtti.Invoke) that is not in FreePascal. There is also the ability to create a virtual interface (http://docwiki.embarcadero.com/CodeExamples/Rio/en/Rtti.TVirtualInterface_(Delphi)). I want to create the same functionality in Tiny.Invoke (https://github.com/d-mozulyov/Tiny.Rtti/blob/master/Tiny.Invoke.pas), but faster, available for FreePascal and with support for a wider list of calling conventions. I need a person who is well versed in assembler for different platforms and could take on the development of this functionality. I think it’s not necessary to write everything in pure assembler, you can take Clang or GCC and use the built-in assembly capabilities.As MvC wrote FPC trunk already supports both Invoke and TVirtualInterface though on most platforms the use of the libffi library is required as a function call manager (simply include unit ffi.manager in your project file), exceptions are Win64 as well as the register calling convention on i386 (patches are welcome to implement more platforms directly in FPC). I plan to have most of the work for that merged into the upcoming 3.2 before it's released.
FPC Trunk already has Invoke and TVirtualInterface
In Delphi there is a native function call functionality (http://docwiki.embarcadero.com/Libraries/Rio/en/System.Rtti.Invoke) that is not in FreePascal. There is also the ability to create a virtual interface (http://docwiki.embarcadero.com/CodeExamples/Rio/en/Rtti.TVirtualInterface_(Delphi)). I want to create the same functionality in Tiny.Invoke (https://github.com/d-mozulyov/Tiny.Rtti/blob/master/Tiny.Invoke.pas), but faster, available for FreePascal and with support for a wider list of calling conventions. I need a person who is well versed in assembler for different platforms and could take on the development of this functionality. I think it’s not necessary to write everything in pure assembler, you can take Clang or GCC and use the built-in assembly capabilities.As MvC wrote FPC trunk already supports both Invoke and TVirtualInterface though on most platforms the use of the libffi library is required as a function call manager (simply include unit ffi.manager in your project file), exceptions are Win64 as well as the register calling convention on i386 (patches are welcome to implement more platforms directly in FPC). I plan to have most of the work for that merged into the upcoming 3.2 before it's released.
Oh and just because I noticed it in your Tiny.Rtti: FPC 3.2 and newer use PPTypeInfo instead of PTypeInfo (like Delphi does) in preparation for dynamic packages (same also goes for some other such references). So you should recheck your code with FPC 3.2. And maybe also recheck with Trunk, cause some structures changed due to the addition of attributes (which we added in non-Delphi-compatible way). And you should also check your code on non-x86 platforms as these have different alignment requirements and at least FPC (don't know about Delphi) does not use packed record for the Rtti there.
And I provided information about the current state of affairs in reply to your request for help. ;)In Delphi there is a native function call functionality (http://docwiki.embarcadero.com/Libraries/Rio/en/System.Rtti.Invoke) that is not in FreePascal. There is also the ability to create a virtual interface (http://docwiki.embarcadero.com/CodeExamples/Rio/en/Rtti.TVirtualInterface_(Delphi)). I want to create the same functionality in Tiny.Invoke (https://github.com/d-mozulyov/Tiny.Rtti/blob/master/Tiny.Invoke.pas), but faster, available for FreePascal and with support for a wider list of calling conventions. I need a person who is well versed in assembler for different platforms and could take on the development of this functionality. I think it’s not necessary to write everything in pure assembler, you can take Clang or GCC and use the built-in assembly capabilities.As MvC wrote FPC trunk already supports both Invoke and TVirtualInterface though on most platforms the use of the libffi library is required as a function call manager (simply include unit ffi.manager in your project file), exceptions are Win64 as well as the register calling convention on i386 (patches are welcome to implement more platforms directly in FPC). I plan to have most of the work for that merged into the upcoming 3.2 before it's released.
Oh and just because I noticed it in your Tiny.Rtti: FPC 3.2 and newer use PPTypeInfo instead of PTypeInfo (like Delphi does) in preparation for dynamic packages (same also goes for some other such references). So you should recheck your code with FPC 3.2. And maybe also recheck with Trunk, cause some structures changed due to the addition of attributes (which we added in non-Delphi-compatible way). And you should also check your code on non-x86 platforms as these have different alignment requirements and at least FPC (don't know about Delphi) does not use packed record for the Rtti there.
I publish information in order to help me, and not be overloaded with new work :)
But I do not mind if the operating time will be used in FPC or libffi.
P.S. It is PTypeInfoRef type using - universal RTTI type for both Delphi and FPC.But your PTypeInfoRef is wrong for FPC 3.2 and newer. There you need to use PPTypeInfo for the value as well.
I know
But "faster, available for FreePascal and with support for a wider list of calling conventions".
And I provided information about the current state of affairs in reply to your request for help.
But your PTypeInfoRef is wrong for FPC 3.2 and newer. There you need to use PPTypeInfo for the value as well.I understood. Thanks. But I do not support compatibility with the FPC. Perhaps someone will be interested in this compatibility and send a merge request.
I know
But "faster, available for FreePascal and with support for a wider list of calling conventions".
Any numbers there? How much faster is it then using (FPC trunk's) rtti unit ?
May I suggest that the speed of software is equivalent to the driver (programmer). Some drivers can not handle the speed. They crash.
If you are interested, there is already some Invoke mechanism in our Open Source https://github.com/synopse/mORMot/blob/master/SQLite3/mORMot.pas unit.
Some distinctive info:
- It allows to execute interface methods - not class methods (it is used internally for SOA or MVC calls) - and with the default calling convention
- It doesn't use TValue (or anything like a temporary storage), but directly some JSON as input/output
- It doesn't use the rtti.pas unit at all
- It works since Delphi 6 and up to latest 10.3.2 on Win32 and Win64
- It works with FPC trunk on Win32, Win64, Linux-386, Linux-x64, Darwin-386, Darwin-x64, Linux-Arm, Linux-Arm64 (currently some problems with ARM, but we will fix the regressions)
- It is thread-safe and fast
- There is interface stubbing/mocking, and some advanced features like call interception (e.g. for logging into a text file or a db)
May be useful in your work.
Sorry, but no, I'm busy enough working on FPC.And I provided information about the current state of affairs in reply to your request for help.
I will be glad if the extended RTTI appears in the FPC. But I do not use FPC. Perhaps you would be interested in investing in the development of this project. Perhaps work on this project will help in correcting FPC RTTI bugs.
But your PTypeInfoRef is wrong for FPC 3.2 and newer. There you need to use PPTypeInfo for the value as well.I understood. Thanks. But I do not support compatibility with the FPC. Perhaps someone will be interested in this compatibility and send a merge request.
I want to create the same functionality in Tiny.Invoke, but faster, available for FreePascal and with support for a wider list of calling conventions.So why do you say now that you don't support compatibility with FPC?
Honestly, I'm a Delphi developer, and I only make sure that the code compiles in Lazarus. I know that the FreePascal community is large, and it would be interesting for them to use native binding with scripts. Therefore, firstly, I urge all interested parties to contribute to the development of these libraries. And secondly, I would like to ask for help in the development of functionality that applies not only to scripts, but also to programming in general.
:: compile.bat
clang -target x86_64-windows-gnu -c -O3 test.c -o"test.o"
pause
Project1.dpr(14,1) Error: Undefined symbol: P$PROJECT1_$$_ADD$LONGINT$LONGINT$LONGINT$$LONGINT
This design works great in Delphi, but it doesn’t link in FreePascal:Add cdecl; before (important!) external; ?QuoteProject1.dpr(14,1) Error: Undefined symbol: P$PROJECT1_$$_ADD$LONGINT$LONGINT$LONGINT$$LONGINT
Tell me, please, how to fix this?