⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 175299 in webkit


Ignore:
Timestamp:
Oct 28, 2014, 9:04:19 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Cast std::chrono::duration.count() to int64_t in ArgumentCoder
https://bugs.webkit.org/show_bug.cgi?id=136981

Patch by Ting-Wei Lan <Ting-Wei Lan> on 2014-10-28
Reviewed by Alexey Proskuryakov.

Explicitly cast the return value of std::chrono::duration.count() to
a fixed-size interger type, which prevents compilation error when
the return value type matches neither int32_t nor int64_t.

  • Platform/IPC/ArgumentCoders.h:
Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r175288 r175299  
     12014-10-28  Ting-Wei Lan  <lantw44@gmail.com>
     2
     3        Cast std::chrono::duration.count() to int64_t in ArgumentCoder
     4        https://bugs.webkit.org/show_bug.cgi?id=136981
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Explicitly cast the return value of std::chrono::duration.count() to
     9        a fixed-size interger type, which prevents compilation error when
     10        the return value type matches neither int32_t nor int64_t.
     11
     12        * Platform/IPC/ArgumentCoders.h:
     13
    1142014-10-28  Jer Noble  <jer.noble@apple.com>
    215
  • trunk/Source/WebKit2/Platform/IPC/ArgumentCoders.h

    r173394 r175299  
    108108    static void encode(ArgumentEncoder& encoder, const std::chrono::duration<Rep, Period>& duration)
    109109    {
    110         encoder << duration.count();
     110        static_assert(std::is_integral<Rep>::value && std::is_signed<Rep>::value && sizeof(Rep) <= sizeof(int64_t), "Serialization of this Rep type is not supported yet. Only signed integer type which can be fit in an int64_t is currently supported.");
     111        encoder << static_cast<int64_t>(duration.count());
    111112    }
    112113
    113114    static bool decode(ArgumentDecoder& decoder, std::chrono::duration<Rep, Period>& result)
    114115    {
    115         Rep count;
     116        int64_t count;
    116117        if (!decoder.decode(count))
    117118            return false;
    118         result = std::chrono::duration<Rep, Period>(count);
     119        result = std::chrono::duration<Rep, Period>(static_cast<Rep>(count));
    119120        return true;
    120121    }
Note: See TracChangeset for help on using the changeset viewer.