Skip to content

Commit

Permalink
enhance variant.duplicate() [wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomShaper committed Dec 17, 2024
1 parent 487eb09 commit cfb5688
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
10 changes: 3 additions & 7 deletions core/variant/variant_setget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1940,14 +1940,10 @@ Variant Variant::duplicate(bool p_deep) const {
Variant Variant::recursive_duplicate(bool p_deep, int recursion_count) const {
switch (type) {
case OBJECT: {
/* breaks stuff :(
if (p_deep && !_get_obj().ref.is_null()) {
Ref<Resource> resource = _get_obj().ref;
if (resource.is_valid()) {
return resource->duplicate(true);
}
Resource *res = Object::cast_to<Resource>(_get_obj().obj);

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🌐 Web / Template w/o threads (target=template_release, threads=no)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🌐 Web / Template w/o threads (target=template_release, threads=no)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🌐 Web / Template w/ threads (target=template_release, threads=yes)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🌐 Web / Template w/ threads (target=template_release, threads=yes)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🤖 Android / Editor (target=editor)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🤖 Android / Editor (target=editor)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🤖 Android / Template arm64 (target=template_release, arch=arm64)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🤖 Android / Template arm64 (target=template_release, arch=arm64)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🍏 iOS / Template (target=template_release)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🍏 iOS / Template (target=template_release)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🤖 Android / Template arm32 (target=template_release, arch=arm32)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🤖 Android / Template arm32 (target=template_release, arch=arm32)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🍎 macOS / Template (target=template_release, tests=yes)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🍎 macOS / Template (target=template_release, tests=yes)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🍎 macOS / Editor (target=editor, tests=yes)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🍎 macOS / Editor (target=editor, tests=yes)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, tests=yes, everything disabled)

'Resource' was not declared in this scope

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, tests=yes, everything disabled)

'res' was not declared in this scope

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, tests=yes, everything disabled)

no matching function for call to 'Object::cast_to<Resource>(Object* const&)'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release, tests=yes)

'Resource' was not declared in this scope

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release, tests=yes)

'res' was not declared in this scope

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release, tests=yes)

no matching function for call to 'Object::cast_to<Resource>(Object* const&)'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template w/ GCC (target=template_release, tests=yes, use_mingw=yes)

'Resource' was not declared in this scope

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template w/ GCC (target=template_release, tests=yes, use_mingw=yes)

'res' was not declared in this scope

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template w/ GCC (target=template_release, tests=yes, use_mingw=yes)

no matching function for call to 'Object::cast_to<Resource>(Object* const&) const'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor w/ clang-cl (target=editor, tests=yes, use_llvm=yes)

unknown type name 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor w/ clang-cl (target=editor, tests=yes, use_llvm=yes)

use of undeclared identifier 'Resource'

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor (target=editor, tests=yes)

'Resource': undeclared identifier

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor (target=editor, tests=yes)

'res': undeclared identifier

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor (target=editor, tests=yes)

'Resource': undeclared identifier

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor (target=editor, tests=yes)

'Object::cast_to': no matching overloaded function found

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template (target=template_release, tests=yes)

'Resource': undeclared identifier

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template (target=template_release, tests=yes)

'res': undeclared identifier

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template (target=template_release, tests=yes)

'Resource': undeclared identifier

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template (target=template_release, tests=yes)

'Object::cast_to': no matching overloaded function found

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor w/ Mono (target=editor)

'Resource' was not declared in this scope

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor w/ Mono (target=editor)

'res' was not declared in this scope

Check failure on line 1943 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor w/ Mono (target=editor)

no matching function for call to 'Object::cast_to<Resource>(Object* const&)'
if (res) {

Check failure on line 1944 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor (target=editor, tests=yes)

'res': undeclared identifier

Check failure on line 1944 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template (target=template_release, tests=yes)

'res': undeclared identifier
return res->duplicate(p_deep);

Check failure on line 1945 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor (target=editor, tests=yes)

'res': undeclared identifier

Check failure on line 1945 in core/variant/variant_setget.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Template (target=template_release, tests=yes)

'res': undeclared identifier
}
*/
return *this;
} break;
case DICTIONARY:
Expand Down
5 changes: 3 additions & 2 deletions doc/classes/Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,9 @@
<return type="Array" />
<param index="0" name="deep" type="bool" default="false" />
<description>
Returns a new copy of the array.
By default, a [b]shallow[/b] copy is returned: all nested [Array] and [Dictionary] elements are shared with the original array. Modifying them in one array will also affect them in the other.[br]If [param deep] is [code]true[/code], a [b]deep[/b] copy is returned: all nested arrays and dictionaries are also duplicated (recursively).
Creates and returns a new copy of the array.
By default, a [b]shallow[/b] copy is returned: all nested [Array], [Dictionary] and [Resource] elements are shared with the original array. Modifying them in one array will also affect them in the other.
If [param deep] is [code]true[/code], a [b]deep[/b] copy is returned: all nested arrays, dictionaries and resources are also duplicated (recursively). See [method Dictionary.duplicate] and [Resource.duplicate] for more information.
</description>
</method>
<method name="erase">
Expand Down
4 changes: 3 additions & 1 deletion doc/classes/Dictionary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@
<return type="Dictionary" />
<param index="0" name="deep" type="bool" default="false" />
<description>
Creates and returns a new copy of the dictionary. If [param deep] is [code]true[/code], inner [Dictionary] and [Array] keys and values are also copied, recursively.
Creates and returns a new copy of the dictionary.
By default, a [b]shallow[/b] copy is returned: all nested [Array], [Dictionary] and [Resource] elements are shared with the original dictionary. Modifying them in one array will also affect them in the other.
If [param deep] is [code]true[/code], a [b]deep[/b] copy is returned: all nested arrays, dictionaries and resources are also duplicated (recursively). See [method Array.duplicate] and [Resource.duplicate] for more information.
</description>
</method>
<method name="erase">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/Resource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<description>
Duplicates this resource, returning a new resource with its [code]export[/code]ed or [constant PROPERTY_USAGE_STORAGE] properties copied from the original.
If [param subresources] is [code]false[/code], a shallow copy is returned; nested resources within subresources are not duplicated and are shared with the original resource (with one exception; see below).
If [param subresources] is [code]true[/code], a deep copy is returned; nested subresources will be duplicated and are not shared (with two exceptions; see below). Nested arrays and dictionaries will also be recursively duplicated.
If [param subresources] is [code]true[/code], a deep copy is returned; nested subresources will be duplicated and are not shared (with two exceptions; see below). Nested arrays and dictionaries will also be recursively duplicated. See [method Array.duplicate] and [Dictionary.duplicate] for more information.
[param subresources] is usually respected, with the following exceptions:
- Subresource properties with the [constant PROPERTY_USAGE_ALWAYS_DUPLICATE] flag are always duplicated (recursively).
- Subresource properties with the [constant PROPERTY_USAGE_NEVER_DUPLICATE] flag are never duplicated.
Expand Down

0 comments on commit cfb5688

Please sign in to comment.