Fix build of the rest of v4vm against WTF/JSC update
authorSimon Hausmann <simon.hausmann@digia.com>
Fri, 12 Apr 2013 13:51:47 +0000 (15:51 +0200)
committerLars Knoll <lars.knoll@digia.com>
Fri, 12 Apr 2013 15:30:58 +0000 (17:30 +0200)
* Add missing functions to our WTF stubs
* Some of the math functions wrapped with MathExtras.h are back in the std:: namespace
  they belong to

Change-Id: I9da43e8344ab8c95edc8db19f44ccdbd91b4ac70
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/3rdparty/masm/stubs/wtf/PassOwnPtr.h
src/3rdparty/masm/stubs/wtf/Vector.h
src/v4/qv4dateobject.cpp
src/v4/qv4globalobject.cpp
src/v4/qv4jsonobject.cpp
src/v4/qv4value.cpp

index f9b84e7..601d278 100644 (file)
@@ -54,6 +54,10 @@ struct OwnPtr : public QScopedPointer<T>
         : QScopedPointer<T>(ptr.leakRef())
     {}
 
+    OwnPtr(const OwnPtr<T>& other)
+        : QScopedPointer<T>(const_cast<OwnPtr<T> &>(other).take())
+    {}
+
     OwnPtr& operator=(const OwnPtr<T>& other)
     {
         this->reset(const_cast<OwnPtr<T> &>(other).take());
index 1feea85..39742d8 100644 (file)
 #include <wtf/NotFound.h>
 #include <qalgorithms.h>
 
+enum WTF_UnusedOverflowMode {
+    UnsafeVectorOverflow
+};
+
 namespace WTF {
 
-template <typename T, int capacity = 1>
+template <typename T, int capacity = 1, int overflowMode = UnsafeVectorOverflow>
 class Vector : public std::vector<T> {
 public:
     Vector() {}
@@ -64,6 +68,8 @@ public:
 
     using std::vector<T>::insert;
 
+    inline void reserveInitialCapacity(size_t size) { this->reserve(size); }
+
     inline void insert(size_t position, T value)
     { this->insert(this->begin() + position, value); }
 
@@ -73,6 +79,9 @@ public:
     inline void shrink(size_t size)
     { this->erase(this->begin() + size, this->end()); }
 
+    inline void shrinkToFit()
+    { this->shrink_to_fit(); }
+
     inline void remove(size_t position)
     { this->erase(this->begin() + position); }
 
index a8e7e8c..ed74c72 100644 (file)
@@ -1268,7 +1268,7 @@ Value DatePrototype::method_toISOString(SimpleCallContext *ctx)
         ctx->throwTypeError();
 
     double t = self->value.asDouble();
-    if (!isfinite(t))
+    if (!std::isfinite(t))
         ctx->throwRangeError(ctx->thisObject);
 
     QString result;
@@ -1304,7 +1304,7 @@ Value DatePrototype::method_toJSON(SimpleCallContext *ctx)
     Value O = __qmljs_to_object(ctx, ctx->thisObject);
     Value tv = __qmljs_to_primitive(O, ctx, NUMBER_HINT);
 
-    if (tv.isNumber() && !isfinite(tv.toNumber(ctx)))
+    if (tv.isNumber() && !std::isfinite(tv.toNumber(ctx)))
         return Value::nullValue();
 
     FunctionObject *toIso = O.objectValue()->get(ctx, ctx->engine->newString(QStringLiteral("toISOString"))).asFunctionObject();
index be243cc..3396ec3 100644 (file)
@@ -649,7 +649,7 @@ Value GlobalFunctions::method_isFinite(SimpleCallContext *context)
         return Value::fromBoolean(true);
 
     double d = v.toNumber(context);
-    return Value::fromBoolean(isfinite(d));
+    return Value::fromBoolean(std::isfinite(d));
 }
 
 /// decodeURI [15.1.3.1]
index 5282b7e..fd7eaca 100644 (file)
@@ -736,7 +736,7 @@ QString Stringify::Str(const QString &key, Value value)
 
     if (value.isNumber()) {
         double d = value.toNumber(ctx);
-        return isfinite(d) ? value.toString(ctx)->toQString() : QStringLiteral("null");
+        return std::isfinite(d) ? value.toString(ctx)->toQString() : QStringLiteral("null");
     }
 
     if (Object *o = value.asObject()) {
index 7ced70d..78769bd 100644 (file)
@@ -60,11 +60,11 @@ int Value::toUInt16(ExecutionContext *ctx) const
     if ((number >= 0 && number < D16))
         return static_cast<ushort>(number);
 
-    if (!isfinite(number))
+    if (!std::isfinite(number))
         return +0;
 
     double d = ::floor(::fabs(number));
-    if (signbit(number))
+    if (std::signbit(number))
         d = -d;
 
     number = ::fmod(d , D16);
@@ -114,11 +114,11 @@ int Value::toInt32(double number)
         return static_cast<int>(number);
 
 
-    if (!isfinite(number))
+    if (!std::isfinite(number))
         return 0;
 
     double d = ::floor(::fabs(number));
-    if (signbit(number))
+    if (std::signbit(number))
         d = -d;
 
     number = ::fmod(d , D32);
@@ -137,11 +137,11 @@ unsigned int Value::toUInt32(double number)
     if ((number >= 0 && number < D32))
         return static_cast<uint>(number);
 
-    if (!isfinite(number))
+    if (!std::isfinite(number))
         return +0;
 
     double d = ::floor(::fabs(number));
-    if (signbit(number))
+    if (std::signbit(number))
         d = -d;
 
     number = ::fmod(d , D32);
@@ -159,7 +159,7 @@ double Value::toInteger(double number)
     else if (! number || isinf(number))
         return number;
     const double v = floor(fabs(number));
-    return signbit(number) ? -v : v;
+    return std::signbit(number) ? -v : v;
 }
 
 Value Value::property(ExecutionContext *ctx, String *name) const