Improve and document PackedDataContainer

This commit is contained in:
kobewi
2023-04-29 00:05:16 +02:00
parent 9f12e7b52d
commit c08e96ef0d
4 changed files with 54 additions and 12 deletions

View File

@ -1,9 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PackedDataContainerRef" inherits="RefCounted" version="4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Reference-counted version of [PackedDataContainer].
Internal class used by [PackedDataContainer].
</brief_description>
<description>
When packing nested containers using [PackedDataContainer], they are recursively packed into [PackedDataContainerRef] (only applies to [Array] and [Dictionary]). Their data can be retrieved the same way as from [PackedDataContainer].
[codeblock]
var packed = PackedDataContainer.new()
packed.pack([1, 2, 3, ["abc", "def"], 4, 5, 6])
for element in packed:
if element is PackedDataContainerRef:
for subelement in element:
print("::", subelement)
else:
print(element)
# Prints:
# 1
# 2
# 3
# ::abc
# ::def
# 4
# 5
# 6
[/codeblock]
</description>
<tutorials>
</tutorials>
@ -11,6 +33,7 @@
<method name="size" qualifiers="const">
<return type="int" />
<description>
Returns the size of the packed container (see [method Array.size] and [method Dictionary.size]).
</description>
</method>
</methods>