CMakePP / CMakePPLang

Object-oriented extension to the CMake language.
http://cmakepp.github.io/CMakePPLang/
Apache License 2.0
11 stars 4 forks source link

Allow Multiple Ctors #4

Closed ryanmrichard closed 4 years ago

ryanmrichard commented 4 years ago

Right now objects have to rely on the default ctor, we should register this ctor with the Object class instance like we do equal and serialize so that derived classes can overload and override the ctor as well. We'll also need an easier way to call a base class's implementation because we usually want to bootstrap ctors.

ryanmrichard commented 4 years ago

Also need to make sure that something like:

cpp_member(ctor MyClass)
function("${ctor}" _c_this)
    # Intent is to bootstrap by calling bases' ctors 
    BaseClass1(CTOR "${_c_this}")
    BaseClass2(CTOR "${_c_this}")
endfunction()

will work. Currently this will lead to infinite recursion because BaseClass1(CTOR ...) will call the function we are defining and not BaseClass1's ctor. Assuming that is corrected there still exists the very likely scenario in which BaseClass2's ctor will overwrite, instead of add to, the state prepared by BaseClass1's ctor.