diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-10-07 09:55:11 +0200 |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-10-07 09:55:11 +0200 |
commit | 087b624c616bc1b3dbe850a74d0737fffc08bec2 (patch) | |
tree | b362c857f8dff3742277e2d8d5af604432d0f988 /src/script | |
parent | 8b7e766aa42739df8998ec9c1e94087b965ac87b (diff) | |
download | qt4-tools-087b624c616bc1b3dbe850a74d0737fffc08bec2.tar.gz |
implement qHash function for QScriptString
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/qscriptstring.cpp | 8 | ||||
-rw-r--r-- | src/script/api/qscriptstring.h | 2 | ||||
-rw-r--r-- | src/script/api/qscriptstring_p.h | 7 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp index 65bd818185..c2362da081 100644 --- a/src/script/api/qscriptstring.cpp +++ b/src/script/api/qscriptstring.cpp @@ -195,4 +195,12 @@ QScriptString::operator QString() const return toString(); } +uint qHash(const QScriptString &key) +{ + QScriptStringPrivate *d = QScriptStringPrivate::get(key); + if (!d) + return 0; + return qHash(d->identifier.ustring().rep()); +} + QT_END_NAMESPACE diff --git a/src/script/api/qscriptstring.h b/src/script/api/qscriptstring.h index e0a808e729..40d156c0b6 100644 --- a/src/script/api/qscriptstring.h +++ b/src/script/api/qscriptstring.h @@ -76,6 +76,8 @@ private: Q_DECLARE_PRIVATE(QScriptString) }; +Q_SCRIPT_EXPORT uint qHash(const QScriptString &key); + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/script/api/qscriptstring_p.h b/src/script/api/qscriptstring_p.h index 25ce702769..d3bb47d82b 100644 --- a/src/script/api/qscriptstring_p.h +++ b/src/script/api/qscriptstring_p.h @@ -73,6 +73,8 @@ public: inline ~QScriptStringPrivate(); static inline void init(QScriptString &q, QScriptStringPrivate *d); + static inline QScriptStringPrivate *get(const QScriptString &q); + inline void detachFromEngine(); QBasicAtomicInt ref; @@ -101,6 +103,11 @@ inline void QScriptStringPrivate::init(QScriptString &q, QScriptStringPrivate *d q.d_ptr = d; } +inline QScriptStringPrivate *QScriptStringPrivate::get(const QScriptString &q) +{ + return const_cast<QScriptStringPrivate*>(q.d_func()); +} + inline void QScriptStringPrivate::detachFromEngine() { engine = 0; |