-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Discern between VIRTUAL and ABSTRACT class bindings #58972
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -557,6 +557,19 @@ bool ClassDB::can_instantiate(const StringName &p_class) { | |
return (!ti->disabled && ti->creation_func != nullptr && !(ti->native_extension && !ti->native_extension->create_instance)); | ||
} | ||
|
||
bool ClassDB::is_virtual(const StringName &p_class) { | ||
OBJTYPE_RLOCK; | ||
|
||
ClassInfo *ti = classes.getptr(p_class); | ||
ERR_FAIL_COND_V_MSG(!ti, false, "Cannot get class '" + String(p_class) + "'."); | ||
#ifdef TOOLS_ENABLED | ||
if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) { | ||
return false; | ||
} | ||
#endif | ||
return (!ti->disabled && ti->creation_func != nullptr && !(ti->native_extension && !ti->native_extension->create_instance) && ti->is_virtual); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see you adapted this from Just wondering if all checks from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I am not sure. For the time being I only made this changes to affect the editor, but not more. We can improve it towards the future I suppose. |
||
} | ||
|
||
void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherits) { | ||
OBJTYPE_WLOCK; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,42 +141,42 @@ void register_core_types() { | |
|
||
GDREGISTER_CLASS(Object); | ||
|
||
GDREGISTER_VIRTUAL_CLASS(Script); | ||
GDREGISTER_ABSTRACT_CLASS(Script); | ||
|
||
GDREGISTER_CLASS(RefCounted); | ||
GDREGISTER_CLASS(WeakRef); | ||
GDREGISTER_CLASS(Resource); | ||
GDREGISTER_CLASS(Image); | ||
|
||
GDREGISTER_CLASS(Shortcut); | ||
GDREGISTER_VIRTUAL_CLASS(InputEvent); | ||
GDREGISTER_VIRTUAL_CLASS(InputEventWithModifiers); | ||
GDREGISTER_VIRTUAL_CLASS(InputEventFromWindow); | ||
GDREGISTER_ABSTRACT_CLASS(InputEvent); | ||
GDREGISTER_ABSTRACT_CLASS(InputEventWithModifiers); | ||
GDREGISTER_ABSTRACT_CLASS(InputEventFromWindow); | ||
GDREGISTER_CLASS(InputEventKey); | ||
GDREGISTER_CLASS(InputEventShortcut); | ||
GDREGISTER_VIRTUAL_CLASS(InputEventMouse); | ||
GDREGISTER_ABSTRACT_CLASS(InputEventMouse); | ||
GDREGISTER_CLASS(InputEventMouseButton); | ||
GDREGISTER_CLASS(InputEventMouseMotion); | ||
GDREGISTER_CLASS(InputEventJoypadButton); | ||
GDREGISTER_CLASS(InputEventJoypadMotion); | ||
GDREGISTER_CLASS(InputEventScreenDrag); | ||
GDREGISTER_CLASS(InputEventScreenTouch); | ||
GDREGISTER_CLASS(InputEventAction); | ||
GDREGISTER_VIRTUAL_CLASS(InputEventGesture); | ||
GDREGISTER_ABSTRACT_CLASS(InputEventGesture); | ||
GDREGISTER_CLASS(InputEventMagnifyGesture); | ||
GDREGISTER_CLASS(InputEventPanGesture); | ||
GDREGISTER_CLASS(InputEventMIDI); | ||
|
||
// Network | ||
GDREGISTER_VIRTUAL_CLASS(IP); | ||
GDREGISTER_ABSTRACT_CLASS(IP); | ||
|
||
GDREGISTER_VIRTUAL_CLASS(StreamPeer); | ||
GDREGISTER_ABSTRACT_CLASS(StreamPeer); | ||
GDREGISTER_CLASS(StreamPeerExtension); | ||
Comment on lines
+173
to
174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But that's probably stuff for a future PR so it might be good to keep it as is in this one. CC @Faless There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extension makes sense if its something very large, so I guess it is up to Fabio to change. |
||
GDREGISTER_CLASS(StreamPeerBuffer); | ||
GDREGISTER_CLASS(StreamPeerTCP); | ||
GDREGISTER_CLASS(TCPServer); | ||
|
||
GDREGISTER_VIRTUAL_CLASS(PacketPeer); | ||
GDREGISTER_ABSTRACT_CLASS(PacketPeer); | ||
GDREGISTER_CLASS(PacketPeerExtension); | ||
GDREGISTER_CLASS(PacketPeerStream); | ||
GDREGISTER_CLASS(PacketPeerUDP); | ||
|
@@ -200,7 +200,7 @@ void register_core_types() { | |
resource_format_loader_crypto.instantiate(); | ||
ResourceLoader::add_resource_format_loader(resource_format_loader_crypto); | ||
|
||
GDREGISTER_VIRTUAL_CLASS(MultiplayerPeer); | ||
GDREGISTER_ABSTRACT_CLASS(MultiplayerPeer); | ||
GDREGISTER_CLASS(MultiplayerPeerExtension); | ||
GDREGISTER_CLASS(MultiplayerAPI); | ||
GDREGISTER_CLASS(MainLoop); | ||
|
@@ -226,19 +226,19 @@ void register_core_types() { | |
GDREGISTER_CLASS(PCKPacker); | ||
|
||
GDREGISTER_CLASS(PackedDataContainer); | ||
GDREGISTER_VIRTUAL_CLASS(PackedDataContainerRef); | ||
GDREGISTER_ABSTRACT_CLASS(PackedDataContainerRef); | ||
GDREGISTER_CLASS(AStar); | ||
GDREGISTER_CLASS(AStar2D); | ||
GDREGISTER_CLASS(EncodedObjectAsID); | ||
GDREGISTER_CLASS(RandomNumberGenerator); | ||
|
||
GDREGISTER_VIRTUAL_CLASS(ResourceImporter); | ||
GDREGISTER_ABSTRACT_CLASS(ResourceImporter); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't that something that might typically make sense to implement as virtual? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I completely forgot about these, I will add them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at them, this will require likely another PR because its a lot of code. |
||
|
||
GDREGISTER_CLASS(NativeExtension); | ||
|
||
GDREGISTER_VIRTUAL_CLASS(NativeExtensionManager); | ||
GDREGISTER_ABSTRACT_CLASS(NativeExtensionManager); | ||
|
||
GDREGISTER_VIRTUAL_CLASS(ResourceUID); | ||
GDREGISTER_ABSTRACT_CLASS(ResourceUID); | ||
|
||
GDREGISTER_CLASS(EngineProfiler); | ||
|
||
|
@@ -276,7 +276,7 @@ void register_core_settings() { | |
|
||
void register_core_singletons() { | ||
GDREGISTER_CLASS(ProjectSettings); | ||
GDREGISTER_VIRTUAL_CLASS(IP); | ||
GDREGISTER_ABSTRACT_CLASS(IP); | ||
GDREGISTER_CLASS(core_bind::Geometry2D); | ||
GDREGISTER_CLASS(core_bind::Geometry3D); | ||
GDREGISTER_CLASS(core_bind::ResourceLoader); | ||
|
@@ -286,7 +286,7 @@ void register_core_singletons() { | |
GDREGISTER_CLASS(core_bind::special::ClassDB); | ||
GDREGISTER_CLASS(core_bind::Marshalls); | ||
GDREGISTER_CLASS(TranslationServer); | ||
GDREGISTER_VIRTUAL_CLASS(Input); | ||
GDREGISTER_ABSTRACT_CLASS(Input); | ||
GDREGISTER_CLASS(InputMap); | ||
GDREGISTER_CLASS(Expression); | ||
GDREGISTER_CLASS(core_bind::EngineDebugger); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, does it actually need the
::
scope here? Just above there'sClassDB::bind_method
without extra scoping.