aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4string_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-04-06 13:53:34 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-02 14:18:10 +0000
commite4a2b2885d1847624dcbc6b9e4dfdedf04767fe3 (patch)
treef6727f68c0ee36100eb429e0898a7c507439b62e /src/qml/jsruntime/qv4string_p.h
parentb58711804e9cca641927dbdebe281488e475352b (diff)
Add a StringOrSymbol intermediate class between Managed and String
This introduces a common base class for Strings and Symbols giving us a unified approach to handling object properties for both. Change-Id: Ic9e5a18b084c8b730e134db990f101d47af224e3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4string_p.h')
-rw-r--r--src/qml/jsruntime/qv4string_p.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h
index 200d979f24..0a316d85b5 100644
--- a/src/qml/jsruntime/qv4string_p.h
+++ b/src/qml/jsruntime/qv4string_p.h
@@ -64,7 +64,13 @@ struct Identifier;
namespace Heap {
-struct Q_QML_PRIVATE_EXPORT String : Base {
+struct Q_QML_PRIVATE_EXPORT StringOrSymbol : Base
+{
+ mutable QStringData *text;
+ mutable Identifier identifier;
+};
+
+struct Q_QML_PRIVATE_EXPORT String : StringOrSymbol {
static void markObjects(Heap::Base *that, MarkStack *markStack);
enum StringType {
StringType_Regular,
@@ -118,8 +124,6 @@ struct Q_QML_PRIVATE_EXPORT String : Base {
bool startsWithUpper() const;
- mutable QStringData *text;
- mutable Identifier identifier;
mutable uint subtype;
mutable uint stringHash;
private:
@@ -150,9 +154,18 @@ int String::length() const {
}
-struct Q_QML_PRIVATE_EXPORT String : public Managed {
+struct Q_QML_PRIVATE_EXPORT StringOrSymbol : public Managed {
+#ifndef V4_BOOTSTRAP
+ V4_MANAGED(StringOrSymbol, Managed)
+ enum {
+ IsStringOrSymbol = true
+ };
+#endif
+};
+
+struct Q_QML_PRIVATE_EXPORT String : public StringOrSymbol {
#ifndef V4_BOOTSTRAP
- V4_MANAGED(String, Managed)
+ V4_MANAGED(String, StringOrSymbol)
Q_MANAGED_TYPE(String)
V4_INTERNALCLASS(String)
V4_NEEDS_DESTROY
@@ -285,6 +298,11 @@ struct ComplexString : String {
};
template<>
+inline const StringOrSymbol *Value::as() const {
+ return isManaged() && m()->internalClass->vtable->isStringOrSymbol ? static_cast<const String *>(this) : nullptr;
+}
+
+template<>
inline const String *Value::as() const {
return isManaged() && m()->internalClass->vtable->isString ? static_cast<const String *>(this) : nullptr;
}