Godot version
4.2 beta3
godot-cpp version
4.2 beta3
System information
Windows 11
Issue description
When trying to create a GDExtension abstract class, the compiler fails to allow pure virtual functions, reporting:
error C2259: 'ParentClass': cannot instantiate abstract class
This is because the GDCLASS macro explicitly makes two references to where it attempts to create the class object, specifically in these two static methods:
static GDExtensionObjectPtr create(void *data) {
m_class *new_object = memnew(m_class);
return new_object->_owner;
}
static GDExtensionClassInstancePtr recreate(void *data, GDExtensionObjectPtr obj) {
_GDCLASS_RECREATE(m_class, m_inherits);
}
The ability to use GDCLASS in GDNative and construct abstract classes exists. I would suggest that GDCLASS function like it does in GDNative and these two specific methods be added to either a separate macro or we introduce a new GDCLASS_ABSTRACT macro that can be used specifically for abstract class construction with all but the above 2 functions defined.
Steps to reproduce
Create a class hierarchy as follows
class ParentClass : public Resource {
GDCLASS(ParentClass, Resource);
static void _bind_methods() {}
virtual void pure_virtual_method() = 0;
}
class ChildClass : public ParentClass {
GDCLASS(ChildClass, ParentClass);
static void _bind_methods() { }
void pure_virtual_method() override { }
}
Minimal reproduction project
N/A
Godot version
4.2 beta3
godot-cpp version
4.2 beta3
System information
Windows 11
Issue description
When trying to create a GDExtension abstract class, the compiler fails to allow pure virtual functions, reporting:
This is because the
GDCLASSmacro explicitly makes two references to where it attempts to create the class object, specifically in these two static methods:The ability to use
GDCLASSin GDNative and construct abstract classes exists. I would suggest thatGDCLASSfunction like it does in GDNative and these two specific methods be added to either a separate macro or we introduce a newGDCLASS_ABSTRACTmacro that can be used specifically for abstract class construction with all but the above 2 functions defined.Steps to reproduce
Create a class hierarchy as follows
Minimal reproduction project
N/A