diff options
Diffstat (limited to 'src/script/api/qscriptengine_p.h')
-rw-r--r-- | src/script/api/qscriptengine_p.h | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index d0d020a..5166d89 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -123,6 +123,9 @@ namespace QScript inline QScriptEnginePrivate *scriptEngineFromExec(const JSC::ExecState *exec); bool isFunction(JSC::JSValue value); + inline void convertToLatin1_helper(const UChar *i, int length, char *s); + inline QByteArray convertToLatin1(const JSC::UString &str); + class UStringSourceProviderWithFeedback; struct GlobalClientData : public JSC::JSGlobalData::ClientData @@ -165,7 +168,7 @@ public: static inline qint32 toInt32(JSC::ExecState *, JSC::JSValue); static inline quint32 toUInt32(JSC::ExecState *, JSC::JSValue); static inline quint16 toUInt16(JSC::ExecState *, JSC::JSValue); - static inline QString toString(JSC::ExecState *, JSC::JSValue); + static inline JSC::UString toString(JSC::ExecState *, JSC::JSValue); static inline QDateTime toDateTime(JSC::ExecState *, JSC::JSValue); #ifndef QT_NO_REGEXP @@ -181,8 +184,8 @@ public: static inline JSC::JSValue property(JSC::ExecState*, JSC::JSValue, quint32 index, int resolveMode = QScriptValue::ResolvePrototype); static JSC::JSValue propertyHelper(JSC::ExecState*, JSC::JSValue, quint32, int resolveMode); - static inline JSC::JSValue property(JSC::ExecState*, JSC::JSValue, const QString &, int resolveMode); - static inline void setProperty(JSC::ExecState*, JSC::JSValue object, const QString &name, JSC::JSValue, + static inline JSC::JSValue property(JSC::ExecState*, JSC::JSValue, const JSC::UString &, int resolveMode); + static inline void setProperty(JSC::ExecState*, JSC::JSValue object, const JSC::UString &name, JSC::JSValue, const QScriptValue::PropertyFlags &flags = QScriptValue::KeepExistingFlags); static void setProperty(JSC::ExecState*, JSC::JSValue object, const JSC::Identifier &id, JSC::JSValue, const QScriptValue::PropertyFlags &flags = QScriptValue::KeepExistingFlags); @@ -191,7 +194,7 @@ public: static QScriptValue::PropertyFlags propertyFlags(JSC::ExecState*, JSC::JSValue value, const JSC::Identifier &id, const QScriptValue::ResolveFlags &mode); static inline QScriptValue::PropertyFlags propertyFlags(JSC::ExecState*, JSC::JSValue value, - const QString &name, const QScriptValue::ResolveFlags &mode); + const JSC::UString &name, const QScriptValue::ResolveFlags &mode); static bool convertValue(JSC::ExecState*, JSC::JSValue value, int type, void *ptr); @@ -516,6 +519,21 @@ inline bool ToBool(const QString &value) return !value.isEmpty(); } +inline void convertToLatin1_helper(const UChar *i, int length, char *s) +{ + const UChar *e = i + length; + while (i != e) + *(s++) = (uchar) *(i++); + *s = '\0'; +} + +inline QByteArray convertToLatin1(const JSC::UString &str) +{ + QByteArray ba(str.size(), Qt::Uninitialized); + convertToLatin1_helper(str.data(), str.size(), ba.data()); + return ba; +} + } // namespace QScript inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(size_t size) @@ -629,7 +647,7 @@ inline void QScriptValuePrivate::initFrom(const QString &value) engine->registerScriptValue(this); } -inline JSC::JSValue QScriptEnginePrivate::property(JSC::ExecState *exec, JSC::JSValue value, const QString &name, int resolveMode) +inline JSC::JSValue QScriptEnginePrivate::property(JSC::ExecState *exec, JSC::JSValue value, const JSC::UString &name, int resolveMode) { return property(exec, value, JSC::Identifier(exec, name), resolveMode); } @@ -655,13 +673,13 @@ inline JSC::JSValue QScriptEnginePrivate::property(JSC::ExecState *exec, JSC::JS } inline QScriptValue::PropertyFlags QScriptEnginePrivate::propertyFlags(JSC::ExecState *exec, JSC::JSValue value, - const QString &name, + const JSC::UString &name, const QScriptValue::ResolveFlags &mode) { return propertyFlags(exec, value, JSC::Identifier(exec, name), mode); } -inline void QScriptEnginePrivate::setProperty(JSC::ExecState *exec, JSC::JSValue objectValue, const QString &name, +inline void QScriptEnginePrivate::setProperty(JSC::ExecState *exec, JSC::JSValue objectValue, const JSC::UString &name, JSC::JSValue value, const QScriptValue::PropertyFlags &flags) { setProperty(exec, objectValue, JSC::Identifier(exec, name), value, flags); @@ -677,7 +695,7 @@ inline JSC::JSValue QScriptValuePrivate::property(quint32 index, int resolveMode return QScriptEnginePrivate::property(engine->currentFrame, jscValue, index, resolveMode); } -inline JSC::JSValue QScriptValuePrivate::property(const QString &name, int resolveMode) const +inline JSC::JSValue QScriptValuePrivate::property(const JSC::UString &name, int resolveMode) const { JSC::ExecState *exec = engine->currentFrame; return QScriptEnginePrivate::property(exec, jscValue, JSC::Identifier(exec, name), resolveMode); @@ -701,7 +719,7 @@ inline void QScriptValuePrivate::setProperty(quint32 index, const JSC::JSValue & QScriptEnginePrivate::setProperty(engine->currentFrame, jscValue, index, value, flags); } -inline void QScriptValuePrivate::setProperty(const QString &name, const JSC::JSValue &value, +inline void QScriptValuePrivate::setProperty(const JSC::UString &name, const JSC::JSValue &value, const QScriptValue::PropertyFlags &flags) { JSC::ExecState *exec = engine->currentFrame; @@ -919,7 +937,7 @@ inline quint16 QScriptEnginePrivate::toUInt16(JSC::ExecState *exec, JSC::JSValue return QScript::ToUInt16(toNumber(exec, value)); } -inline QString QScriptEnginePrivate::toString(JSC::ExecState *exec, JSC::JSValue value) +inline JSC::UString QScriptEnginePrivate::toString(JSC::ExecState *exec, JSC::JSValue value) { JSC::JSValue savedException; saveException(exec, &savedException); |