summaryrefslogtreecommitdiffstats
path: root/doc/src/examples/qtscriptcustomclass.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/examples/qtscriptcustomclass.qdoc')
-rw-r--r--doc/src/examples/qtscriptcustomclass.qdoc13
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/src/examples/qtscriptcustomclass.qdoc b/doc/src/examples/qtscriptcustomclass.qdoc
index f825ad9..028c7a6 100644
--- a/doc/src/examples/qtscriptcustomclass.qdoc
+++ b/doc/src/examples/qtscriptcustomclass.qdoc
@@ -120,6 +120,8 @@
this ByteArrayClass object, so that the constructor, when it is invoked, can extract the
pointer and use it to create a new \c{ByteArray} object.
+ \snippet examples/script/customclass/bytearrayclass.cpp 10
+
\snippet examples/script/customclass/bytearrayclass.cpp 1
The newInstance() function isn't part of the QScriptClass API; its purpose is to offer
@@ -128,6 +130,11 @@
QScriptEngine::newObject() will call the prototype() function of our class, ensuring that
the prototype of the new object will be the standard \c{ByteArray} prototype.
+ QScriptEngine::reportAdditionalMemoryCost() is called to inform the script engine of the
+ memory occupied by the QByteArray. This gives the garbage collector a hint that it should
+ perhaps trigger more frequently, possibly freeing up memory associated with large ByteArray
+ objects that are no longer in use.
+
\snippet examples/script/customclass/bytearrayclass.cpp 2
construct() is the native function that will act as a constructor for \c{ByteArray}
@@ -159,6 +166,12 @@
array index that was calculated in the queryProperty() function, enlarge the array if necessary,
and write the given value to the array.
+ \snippet examples/script/customclass/bytearrayclass.cpp 9
+
+ The resize() function is a helper function that resizes the QByteArray to a new size, and,
+ if the new size is greater than the old, reports the additional memory cost to the script
+ engine.
+
\snippet examples/script/customclass/bytearrayclass.cpp 6
The propertyFlags() reimplementation specifies that the \c{length} property can't be deleted,