godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

ClassDB macros and class registration

Open Kehom opened this issue 1 year ago • 3 comments
trafficstars

Godot version

4.3 beta 1

godot-cpp version

master

System information

Windows 10 and Linux Mint

Issue description

I recently updated the godot-cpp for my project and noticed now that abstract classes require register_abstract_class<>(). Yet, if we want an internal abstract class we can't with any of the public functions. Would there be a problem if a public function could be provided allowing any possible combination? Or in other words, make the _register_class() template function public.

While taking a look at the class_db.hpp file I noticed there are a few macros meant for class registration, however none of them takes into account a project that doesn't use the godot namespace.

Steps to reproduce

Minimal reproduction project

Kehom avatar May 31 '24 15:05 Kehom

In the engine itself classes can only be internal or abstract, this should be matched in extensions, so if it's not by design it has to be changed there first and then here

AThousandShips avatar Jun 01 '24 08:06 AThousandShips

While taking a look at the class_db.hpp file I noticed there are a few macros meant for class registration, however none of them takes into account a project that doesn't use the godot namespace.

I just made PR https://github.com/godotengine/godot-cpp/pull/1477 to address the namespace issue

dsnopek avatar Jun 01 '24 13:06 dsnopek

In the engine itself classes can only be internal or abstract, this should be matched in extensions, so if it's not by design it has to be changed there first and then here

It's not that big of a deal. I have an internal class that provides a lot of common code for two different use cases. It would be "better" if it could be abstract, but since I'm not exposing it I know the base class will not be directly used either.

Kehom avatar Jun 01 '24 16:06 Kehom