Ybalrid / Annwvyn

Annwvyn C++ Open Source designed-for-VR game engine and application developement framework
MIT License
41 stars 7 forks source link

Subsystem access is relying too heavilly in pre-processed C-style macros #59

Closed Ybalrid closed 7 years ago

Ybalrid commented 7 years ago

Every AnnGetXXX() "function" in code is actually a macro that will be evaluated to "AnnEngine::Instance()-getXXX()". This makes some part of the code a bit hard to debug and it a bit ugly.

To be fair, it's not a huge deal and huge stuff like OpenGL are working exactly like this on most implementations. Theses functions exist for the sake of simplifying the code while keeping things somewhat encapsulated and organized under the hood.

Re-writing theses as a bunch of function in this style could do the trick :

#include<functional>

//...

std::function<returnTypeXXX()> AnnGetXXX = []()
    {return AnnEngine::Instance()->getXXX();}; 

Would be nicer. It may also permit a simpler integration of these getters into the ChaiScript bindings

Ybalrid commented 7 years ago

Having a bunch of std::function declared in a header cause link problems. And looking at it, it's a silly way to do it.

The fixMacros branch has a more sane solution by declaring a bunch of function globally (in the Annwyvn namespace) and implementing them like in C.