Fix create instance func#1431
Fix create instance func#1431dsnopek merged 1 commit intogodotengine:masterfrom pupil1337:fix-create-instance-func
Conversation
|
Thanks! The goal here sounds great: cause a compilation error if trying to register an abstract class with However, I think the implementation here will be confusing for developers (the error they get when using the wrong macros doesn't point to the solution) and for maintainers (my brain has trouble with the What if we added another Something like: |
Thank you for your suggestion, it's very useful! I had change last commit. |
|
Thanks! Two additional notes:
|
| template <typename T, bool is_abstract> | ||
| void ClassDB::_register_class(bool p_virtual, bool p_exposed, bool p_runtime) { | ||
| static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS."); | ||
| static_assert(!std::is_abstract_v<T> || is_abstract, "Class is abstract, please use GDREGISTER_ABSTRACT_CLASS."); |
There was a problem hiding this comment.
- if this class is real a no-abstract class, not check, so it can register by
GDREGISTER_CLASSGDREGISTER_VIRTUAL_CLASSGDREGISTER_ABSTRACT_CLASSGDREGISTER_INTERNAL_CLASSGDREGISTER_RUNTIME_CLASSetc.. (all register methods) - and if this class is real an abstract class, check
is_abstractparam, make this class must register byGDREGISTER_ABSTRACT_CLASS
dsnopek
left a comment
There was a problem hiding this comment.
Thanks, this looks great to me now!
|
Congrats on your first merged Godot contribution 🎉 |
|
Thanks🌹 |
|
Cherry-picked for 4.2 in PR #1465 |
|
Cherry-picked for 4.1 in PR #1466 |
To Fix #1425
This PR is a resubmission of #1427 , as the repository submitted that time was my master branch it looked bad. So I want to resubmit it.