-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Core: Migrate typed container logic #96741
base: master
Are you sure you want to change the base?
Conversation
2ddb82f
to
ab869ab
Compare
Made another minor addition because I couldn't justify an entirely separate PR for it: |
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.
Looks good to me, makes typed collections be more directly used by Variant.
@@ -41,8 +41,7 @@ | |||
#include "core/variant/dictionary.h" | |||
#include "core/variant/variant.h" | |||
|
|||
class ArrayPrivate { | |||
public: | |||
struct Array::ArrayPrivate { |
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.
OK, Private collection headers moved inside their collections.
@@ -199,4 +199,13 @@ class Array { | |||
~Array(); | |||
}; | |||
|
|||
template <typename T> | |||
class TypedArray : public Array { |
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.
Typed collections have been moved inside their generic collection headers.
// This is for typed containers. | ||
|
||
template <typename T> | ||
struct PtrToArg<TypedArray<T>> { |
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.
Variants can now be casted directly to their internal typed collections.
3295642
to
c63cf08
Compare
c63cf08
to
0ab9667
Compare
0ab9667
to
0add01b
Compare
• Dedicated typed container files entirely removed • Typed container classes now defined in their base headers; methods declared in `variant.h` • Consolidate to a single template for both typed containers, thanks to `constexpr` • Nest private containers in their base classes
0add01b
to
0bbc059
Compare
type_info
properties to detect & identify Variant types #88567This PR aims to significantly streamline the use of typed arrays/dictionaries across the repo by making their include chains much more reasonable. Instead of requiring dedicated files, they're instead declared right in the base files for each respective container. The templated logic is handled in
variant.h
, similar to how it's already handling array iterator functions. Because everything is now consolidated into a single location, this entirely removes the need to forward-declare the structs in various classes or require including the typed header with extra baggage; within reason, anything can just use typed containers right away.As part of the transition, this PR also integrates the ideas originally conceived in #88567: consolidating the typed container templates to a single instance. This was done with
constexpr
to allow for conditional checks right in the templates themselves, but the biggest improvement since then was to handle this logic invariant.h
rather thantype_info.h
. While I still fully believe that a refactor oftype_info.h
is an inevitability in the near-ish future, that's not required for this scenario that only concerns itself with mapping types toVariant::Type
.The main other thing this PR does is explicitly disallow
TypedArray<Variant>
andTypedDictionary<Variant, Variant>
by declaring them as undefined behavior. This won't likely be something that we stick with long-term, but for now their specifics simply haven't been discussed and, unlike GDScript, they would behave differently than the base containers. Whether this will have an actual impact is anyone's guess, but this was already adding static conditional logic to a system that was fundamentally incompatible with it previously, so no harm done.