linksplatform / Interfaces

LinksPlatform's Platform.Interfaces Class Library
https://linksplatform.github.io/Interfaces
The Unlicense
3 stars 2 forks source link

Create DIRECT_METHOD_CALL macro #106

Closed Konard closed 1 year ago

Konard commented 1 year ago

https://github.com/linksplatform/Data.Doublets/blob/22d79feaef5438c6f4684fa6105583e56129ff79/cpp/Platform.Data.Doublets/ILinksExtensions.h#L527-L531

Macro should simplify direct usage of methods for both static and dynamic polymorphism and the mix of them. When we have concrete class we should prioritize calling exact method over calling virtual method. If we don’t do that in the case of mixed polymorphism, we can end up with a infinite recursion because call to concrete method might be interpreted as a virtual call. When we have only abstract class we should just call its virtual method.

It is possible to use variadiac arguments for macro: https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html

First argument should be a type of class, the second argument should be an instance of the class, the third argument will be the name of the method and rest variadic arguments would be arguments for the method.

Macro should be placed in Macros.h file.

Konard commented 1 year ago

Done at https://github.com/linksplatform/Interfaces/commit/6e8234e7ece8ed6e46a8fee2c85e89b92792e1f9