~ubuntu-branches/ubuntu/wily/qtdeclarative-opensource-src/wily-proposed

« back to all changes in this revision

Viewing changes to src/qml/jsruntime/qv4dateobject.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Ricardo Salveti de Araujo, Timo Jyrinki
  • Date: 2014-06-19 02:39:21 UTC
  • mfrom: (0.1.18 experimental)
  • Revision ID: package-import@ubuntu.com-20140619023921-yb2oasnuetz9b0fc
Tags: 5.3.0-3ubuntu4
[ Ricardo Salveti de Araujo ]
* debian/control:
  - Updating dependencies as we now also have libqt5quickwidgets5-gles
* libqt5quickwidgets5.symbols: updating to allow gles variant

[ Timo Jyrinki ]
* Update libqt5quickparticles5.symbols from build logs

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
#include <cmath>
52
52
#include <qmath.h>
53
53
#include <qnumeric.h>
54
 
#include <cassert>
55
54
#include <time.h>
56
55
 
57
56
#include <private/qqmljsengine_p.h>
157
156
    if (x == 365)
158
157
        return 0;
159
158
 
160
 
    assert(x == 366);
 
159
    Q_ASSERT(x == 366);
161
160
    return 1;
162
161
}
163
162
 
489
488
    QDateTime dt = QDateTime::fromString(s, Qt::TextDate);
490
489
    if (!dt.isValid())
491
490
        dt = QDateTime::fromString(s, Qt::ISODate);
492
 
    if (!dt.isValid())
493
 
        dt = QDateTime::fromString(s, Qt::RFC2822Date);
494
491
    if (!dt.isValid()) {
495
492
        QStringList formats;
496
493
        formats << QStringLiteral("M/d/yyyy")
644
641
#endif
645
642
}
646
643
 
647
 
DEFINE_MANAGED_VTABLE(DateObject);
 
644
DEFINE_OBJECT_VTABLE(DateObject);
648
645
 
649
646
DateObject::DateObject(ExecutionEngine *engine, const QDateTime &date)
650
647
    : Object(engine->dateClass)
651
648
{
652
 
    setVTable(&static_vtbl);
653
 
    type = Type_DateObject;
 
649
    setVTable(staticVTable());
654
650
    value.setDouble(date.isValid() ? date.toMSecsSinceEpoch() : qSNaN());
655
651
}
656
652
 
659
655
    return ToDateTime(value.asDouble(), Qt::LocalTime);
660
656
}
661
657
 
662
 
DEFINE_MANAGED_VTABLE(DateCtor);
 
658
DEFINE_OBJECT_VTABLE(DateCtor);
663
659
 
664
660
DateCtor::DateCtor(ExecutionContext *scope)
665
661
    : FunctionObject(scope, QStringLiteral("Date"))
666
662
{
667
 
    setVTable(&static_vtbl);
 
663
    setVTable(staticVTable());
668
664
}
669
665
 
670
666
ReturnedValue DateCtor::construct(Managed *m, CallData *callData)
680
676
        if (DateObject *d = arg->asDateObject())
681
677
            arg = d->value;
682
678
        else
683
 
            arg = __qmljs_to_primitive(arg, PREFERREDTYPE_HINT);
 
679
            arg = RuntimeHelpers::toPrimitive(arg, PREFERREDTYPE_HINT);
684
680
 
685
681
        if (arg->isString())
686
682
            t = ParseString(arg->stringValue()->toQString());
1311
1307
ReturnedValue DatePrototype::method_toJSON(CallContext *ctx)
1312
1308
{
1313
1309
    Scope scope(ctx);
1314
 
    ScopedValue O(scope, __qmljs_to_object(ctx, ValueRef(&ctx->callData->thisObject)));
1315
 
    ScopedValue tv(scope, __qmljs_to_primitive(O, NUMBER_HINT));
 
1310
    ScopedValue O(scope, RuntimeHelpers::toObject(ctx, ValueRef(&ctx->callData->thisObject)));
 
1311
    ScopedValue tv(scope, RuntimeHelpers::toPrimitive(O, NUMBER_HINT));
1316
1312
 
1317
1313
    if (tv->isNumber() && !std::isfinite(tv->toNumber()))
1318
1314
        return Encode::null();