diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-05-03 16:30:29 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-04 09:51:26 +0200 |
commit | b24103703c4056d6d299d5625c92f2453eff228e (patch) | |
tree | 124919ccca7ec73adaf11525989815fadc6a5db3 | |
parent | a12e09ff8e1ea37a57d09d87b96b49a8ff97b64a (diff) |
Remove some more v8 API
Change-Id: Ia5283adf7aee697a297b1d1c305b376ff932d341
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/qml/qml/v4/qv4v8.cpp | 63 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4v8_p.h | 104 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8engine.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8engine_p.h | 1 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8typewrapper.cpp | 5 |
5 files changed, 7 insertions, 174 deletions
diff --git a/src/qml/qml/v4/qv4v8.cpp b/src/qml/qml/v4/qv4v8.cpp index 43a1922a92..c8df5b4f64 100644 --- a/src/qml/qml/v4/qv4v8.cpp +++ b/src/qml/qml/v4/qv4v8.cpp @@ -619,35 +619,15 @@ bool String::Equals(char *str, int length) return asQString() == QString::fromLatin1(str, length); } -uint16_t String::GetCharacter(int index) +int String::Write(uint16_t *buffer) const { - return asQString().at(index).unicode(); -} - -int String::Write(uint16_t *buffer, int start, int length, int options) const -{ - if (length < 0) - length = asQString().length(); + uint length = asQString().length(); if (length == 0) return 0; - if (asQString().length() < length) - length = asQString().length(); - // ### do we use options? - memcpy(buffer + start, asQString().constData(), length*sizeof(QChar)); + memcpy(buffer, asQString().constData(), length*sizeof(QChar)); return length; } -v8::Local<String> String::Empty() -{ - return Local<String>::New(v8::Value::fromV4Value(QV4::Value::fromString(currentEngine()->current, QString()))); -} - -bool String::IsExternal() const -{ - Q_UNIMPLEMENTED(); - Q_UNREACHABLE(); -} - String::ExternalStringResource *String::GetExternalStringResource() const { Q_UNIMPLEMENTED(); @@ -740,16 +720,6 @@ Local<Integer> Integer::NewFromUnsigned(uint32_t value) return Local<Integer>::New(Value::fromV4Value(QV4::Value::fromUInt32(value))); } -Local<Integer> Integer::New(int32_t value, Isolate *) -{ - return New(value); -} - -Local<Integer> Integer::NewFromUnsigned(uint32_t value, Isolate *) -{ - return NewFromUnsigned(value); -} - int64_t Integer::Value() const { const QV4::Value *v = ConstValuePtr(this); @@ -1952,11 +1922,6 @@ Isolate *Isolate::GetCurrent() } -void V8::SetFlagsFromString(const char *, int) -{ - // we can safely ignore these -} - static UserObjectComparisonCallback userObjectComparisonCallback = 0; static bool v8ExternalResourceComparison(const QV4::Value &a, const QV4::Value &b) @@ -1992,28 +1957,6 @@ void V8::AddImplicitReferences(Persistent<Object> parent, Persistent<Value> *chi assert(!"AddImplicitReferences();"); } -bool V8::Initialize() -{ - Q_UNIMPLEMENTED(); - Q_UNREACHABLE(); -} - -bool V8::Dispose() -{ - Q_UNIMPLEMENTED(); - Q_UNREACHABLE(); -} - -bool V8::IdleNotification(int hint) -{ - return true; -} - -void V8::LowMemoryNotification() -{ - currentEngine()->memoryManager->runGC(); -} - TryCatch::TryCatch() { diff --git a/src/qml/qml/v4/qv4v8_p.h b/src/qml/qml/v4/qv4v8_p.h index eb5ddd236e..a66c318bfa 100644 --- a/src/qml/qml/v4/qv4v8_p.h +++ b/src/qml/qml/v4/qv4v8_p.h @@ -570,10 +570,6 @@ template <class T> class Persistent : public Handle<T> { HandleOperations<T>::init(this); } - void Dispose(Isolate*) { - Dispose(); - } - /** * Make the reference to this object weak. When only weak handles * refer to the object, the garbage collector will perform a @@ -1093,50 +1089,8 @@ class V8EXPORT String : public Primitive { * enough to hold the entire string and NULL terminator. Copies * the contents of the string and the NULL terminator into the * buffer. - * - * WriteUtf8 will not write partial UTF-8 sequences, preferring to stop - * before the end of the buffer. - * - * Copies up to length characters into the output buffer. - * Only null-terminates if there is enough space in the buffer. - * - * \param buffer The buffer into which the string will be copied. - * \param start The starting position within the string at which - * copying begins. - * \param length The number of characters to copy from the string. For - * WriteUtf8 the number of bytes in the buffer. - * \param nchars_ref The number of characters written, can be NULL. - * \param options Various options that might affect performance of this or - * subsequent operations. - * \return The number of characters copied to the buffer excluding the null - * terminator. For WriteUtf8: The number of bytes copied to the buffer - * including the null terminator (if written). - */ - enum WriteOptions { - NO_OPTIONS = 0, - HINT_MANY_WRITES_EXPECTED = 1, - NO_NULL_TERMINATION = 2, - PRESERVE_ASCII_NULL = 4 - }; - - uint16_t GetCharacter(int index); - - // 16-bit character codes. - int Write(uint16_t* buffer, - int start = 0, - int length = -1, - int options = NO_OPTIONS) const; - - /** - * A zero length string. */ - static v8::Local<v8::String> Empty(); - static v8::Local<v8::String> Empty(Isolate* isolate); - - /** - * Returns true if the string is external - */ - bool IsExternal() const; + int Write(uint16_t* buffer) const; class V8EXPORT ExternalStringResourceBase { // NOLINT public: @@ -1287,8 +1241,6 @@ class V8EXPORT Integer : public Number { public: static Local<Integer> New(int32_t value); static Local<Integer> NewFromUnsigned(uint32_t value); - static Local<Integer> New(int32_t value, Isolate*); - static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); int64_t Value() const; static Integer* Cast(v8::Value* obj); }; @@ -2122,13 +2074,6 @@ Handle<Primitive> V8EXPORT Null(); Handle<Boolean> V8EXPORT True(); Handle<Boolean> V8EXPORT False(); -inline Handle<Primitive> Undefined(Isolate*) { return Undefined(); } -inline Handle<Primitive> Null(Isolate*) { return Null(); } -inline Handle<Boolean> True(Isolate*) { return True(); } -inline Handle<Boolean> False(Isolate*) { return False(); } - - - // --- Exceptions --- @@ -2220,11 +2165,6 @@ class V8EXPORT Isolate { class V8EXPORT V8 { public: - /** - * Sets V8 flags from a string. - */ - static void SetFlagsFromString(const char* str, int length); - /** Callback for user object comparisons */ static void SetUserObjectComparisonCallbackFunction(UserObjectComparisonCallback); @@ -2258,43 +2198,6 @@ class V8EXPORT V8 { Persistent<Value>* children, size_t length); - /** - * Initializes from snapshot if possible. Otherwise, attempts to - * initialize from scratch. This function is called implicitly if - * you use the API without calling it first. - */ - static bool Initialize(); - - /** - * Releases any resources used by v8 and stops any utility threads - * that may be running. Note that disposing v8 is permanent, it - * cannot be reinitialized. - * - * It should generally not be necessary to dispose v8 before exiting - * a process, this should happen automatically. It is only necessary - * to use if the process needs the resources taken up by v8. - */ - static bool Dispose(); - - /** - * Optional notification that the embedder is idle. - * V8 uses the notification to reduce memory footprint. - * This call can be used repeatedly if the embedder remains idle. - * Returns true if the embedder should stop calling IdleNotification - * until real work has been done. This indicates that V8 has done - * as much cleanup as it will be able to do. - * - * The hint argument specifies the amount of work to be done in the function - * on scale from 1 to 1000. There is no guarantee that the actual work will - * match the hint. - */ - static bool IdleNotification(int hint = 1000); - - /** - * Optional notification that the system is running low on memory. - * V8 uses these notifications to attempt to free memory. - */ - static void LowMemoryNotification(); }; /** @@ -2362,9 +2265,6 @@ private: }; -// --- Context --- -class V8EXPORT ExtensionConfiguration; - /** * A sandboxed execution context with its own set of built-in objects * and functions. @@ -2384,8 +2284,6 @@ private: ~Context() {} }; -//DEFINE_HANDLE_OPERATIONS(Context) - template<typename T> void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) { diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 6c305688cc..5295ff9a96 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -141,12 +141,6 @@ QV8Engine::QV8Engine(QJSEngine* qq) qMetaTypeId<QJSValue>(); qMetaTypeId<QList<int> >(); - QByteArray v8args = qgetenv("V8ARGS"); - // change default v8 behaviour to not relocate breakpoints across lines - if (!v8args.contains("breakpoint_relocation")) - v8args.append(" --nobreakpoint_relocation"); - v8::V8::SetFlagsFromString(v8args.constData(), v8args.length()); - ensurePerThreadIsolate(); m_v4Engine = v8::Isolate::GetEngine(); @@ -171,7 +165,6 @@ QV8Engine::QV8Engine(QJSEngine* qq) QV8Engine::~QV8Engine() { - Q_ASSERT_X(v8::Isolate::GetCurrent(), "QV8Engine::~QV8Engine()", "called after v8::Isolate has exited"); for (int ii = 0; ii < m_extensionData.count(); ++ii) delete m_extensionData[ii]; m_extensionData.clear(); @@ -1476,7 +1469,6 @@ void QV8GCCallback::addGcCallbackNode(QV8GCCallback::Node *node) QV8Engine::ThreadData::ThreadData() : gcPrologueCallbackRegistered(false) { - isolate = 0; } QV8Engine::ThreadData::~ThreadData() diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h index e85d027021..e871cd464a 100644 --- a/src/qml/qml/v8/qv8engine_p.h +++ b/src/qml/qml/v8/qv8engine_p.h @@ -415,7 +415,6 @@ public: struct ThreadData { ThreadData(); ~ThreadData(); - v8::Isolate* isolate; bool gcPrologueCallbackRegistered; QIntrusiveList<QV8GCCallback::Node, &QV8GCCallback::Node::node> gcCallbackNodes; }; diff --git a/src/qml/qml/v8/qv8typewrapper.cpp b/src/qml/qml/v8/qv8typewrapper.cpp index 61ac4f9007..00167b5363 100644 --- a/src/qml/qml/v8/qv8typewrapper.cpp +++ b/src/qml/qml/v8/qv8typewrapper.cpp @@ -195,7 +195,7 @@ v8::Handle<v8::Value> QV8TypeWrapper::Getter(v8::Local<v8::String> property, v8::Handle<v8::Value> rv = v8engine->qobjectWrapper()->getProperty(qobjectSingleton, propertystring, context, QV8QObjectWrapper::IgnoreRevision); return rv; } else if (!siinfo->scriptApi(e).isUndefined()) { - QV4::ExecutionEngine *engine = v8::Isolate::GetEngine(); + QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine); // NOTE: if used in a binding, changes will not trigger re-evaluation since non-NOTIFYable. QV4::Object *o = QJSValuePrivate::get(siinfo->scriptApi(e))->getValue(engine).asObject(); if (!o) @@ -297,7 +297,8 @@ v8::Handle<v8::Value> QV8TypeWrapper::Setter(v8::Local<v8::String> property, property->v4Value().toQString() + QLatin1Char('\"'); v8::ThrowException(v8::Exception::Error(v8engine->toString(error))); } else { - apiprivate->put(v8::Isolate::GetEngine()->current, property.get()->v4Value().stringValue(), setVal); + QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine); + apiprivate->put(engine->current, property.get()->v4Value().stringValue(), setVal); } } } |