Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templated and custom-named classes support and test #1362

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

IvanInventor
Copy link

Support for template classes, and, as side effect, classes with custom name, different for actual name.
To add template class:

  • Replace GDCLASS() macro with GDCLASS_TEMPLATE()
template <class T>
class ExampleTemplated : public Object {
	GDCLASS_TEMPLATE(ExampleTemplated, Object);
};
  • For each template instantiation, set name of this class, and optionally explicitly instantiate them
template <>
const char *ExampleTemplated<int>::_template_class_name = "ExampleTemplatedInt";
template class ExampleTemplated<int>;

template <>
const char *ExampleTemplated<float>::_template_class_name = "ExampleTemplatedFloat";
template class ExampleTemplated<float>;

As a side effect after changes, classes with custom name are now also easily created with GDCLASS_NAME(ExampleCustom, Object, "CustomExample"); macro

@IvanInventor IvanInventor requested a review from a team as a code owner January 18, 2024 00:20
@dsnopek
Copy link
Collaborator

dsnopek commented Jan 19, 2024

Thanks!

This is an interesting feature. However, one of the design goals of godot-cpp is to provide the same API as is available internally in Godot itself. So, for this to be added to godot-cpp, it'd need to be added first to Godot, so you'd need to propose it there first.

@dsnopek dsnopek added the enhancement This is an enhancement on the current functionality label Jan 19, 2024
@dsnopek dsnopek added this to the 4.x milestone Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement on the current functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants