diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2014-10-30 22:30:01 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-10-31 15:42:42 +0100 |
commit | 0704d2be63b484cb579c1507223db3f914b1338a (patch) | |
tree | 66d4e616545d7f576125e85cc108c7e2988cecdd /src/qml/qml/qqmlxmlhttprequest.cpp | |
parent | e67948823d6810c2de784859da52a261bf80b550 (diff) |
Get rid of !this and similar constructs
The C++ standard doesn't allow calling member functions
on a mull object. Fix all such places, by moving the checks
to the caller where required.
Change-Id: I10fb22acaf0324d8ffd3a6d8e19152e5d32f56bb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlxmlhttprequest.cpp')
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index e374e471e3..0730cbc363 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -203,7 +203,7 @@ public: // JS API static void destroy(Managed *that) { - that->as<NamedNodeMap>()->d()->~Data(); + static_cast<NamedNodeMap *>(that)->d()->~Data(); } static ReturnedValue get(Managed *m, String *name, bool *hasProperty); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); @@ -234,7 +234,7 @@ public: // JS API static void destroy(Managed *that) { - that->as<NodeList>()->d()->~Data(); + static_cast<NodeList *>(that)->d()->~Data(); } static ReturnedValue get(Managed *m, String *name, bool *hasProperty); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); @@ -324,7 +324,7 @@ struct Node : public Object // JS API static void destroy(Managed *that) { - that->as<Node>()->d()->~Data(); + static_cast<Node *>(that)->d()->~Data(); } // C++ API @@ -916,10 +916,9 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty) { - NamedNodeMap *r = m->as<NamedNodeMap>(); + Q_ASSERT(m->as<NamedNodeMap>()); + NamedNodeMap *r = static_cast<NamedNodeMap *>(m); QV4::ExecutionEngine *v4 = m->engine(); - if (!r) - return v4->currentContext()->throwTypeError(); name->makeIdentifier(); if (name->equals(v4->id_length)) @@ -949,13 +948,9 @@ ReturnedValue NamedNodeMap::create(QV8Engine *engine, NodeImpl *data, const QLis ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty) { + Q_ASSERT(m->as<NodeList>()); QV4::ExecutionEngine *v4 = m->engine(); - NodeList *r = m->as<NodeList>(); - if (!r) { - if (hasProperty) - *hasProperty = false; - return v4->currentContext()->throwTypeError(); - } + NodeList *r = static_cast<NodeList *>(m); QV8Engine *engine = v4->v8Engine; @@ -971,10 +966,9 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty) ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty) { + Q_ASSERT(m->as<NodeList>()); QV4::ExecutionEngine *v4 = m->engine(); - NodeList *r = m->as<NodeList>(); - if (!r) - return v4->currentContext()->throwTypeError(); + NodeList *r = static_cast<NodeList *>(m); name->makeIdentifier(); @@ -1608,7 +1602,7 @@ struct QQmlXMLHttpRequestWrapper : public Object V4_OBJECT(Object) static void destroy(Managed *that) { - that->as<QQmlXMLHttpRequestWrapper>()->d()->~Data(); + static_cast<QQmlXMLHttpRequestWrapper *>(that)->d()->~Data(); } }; @@ -1638,7 +1632,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject }; V4_OBJECT(FunctionObject) static void markObjects(Managed *that, ExecutionEngine *e) { - QQmlXMLHttpRequestCtor *c = that->as<QQmlXMLHttpRequestCtor>(); + QQmlXMLHttpRequestCtor *c = static_cast<QQmlXMLHttpRequestCtor *>(that); if (c->d()->proto) c->d()->proto->mark(e); FunctionObject::markObjects(that, e); |