Title: [235673] trunk/Source/WebCore
Revision
235673
Author
[email protected]
Date
2018-09-05 10:03:02 -0700 (Wed, 05 Sep 2018)

Log Message

Add functionality to encode and decode a uint64_t in KeyedCoding
https://bugs.webkit.org/show_bug.cgi?id=189216

Patch by Woodrow Wang <[email protected]> on 2018-09-05
Reviewed by Daniel Bates.

I've added this functionality in order to be able to encode and decode the raw uint64_t
representation of an OptionSet for my patch here <https://bugs.webkit.org/show_bug.cgi?id=187773>.

The changes in the KeyedEncoder/KeyedDecoder for Glib were made because they are derived classes
of KeyedCoding which contains pure virtual functions that need to be implemented.

* platform/KeyedCoding.h:
* platform/cf/KeyedDecoderCF.cpp:
(WebCore::KeyedDecoderCF::decodeUInt64):
* platform/cf/KeyedDecoderCF.h:
* platform/cf/KeyedEncoderCF.cpp:
(WebCore::KeyedEncoderCF::encodeUInt64):
* platform/cf/KeyedEncoderCF.h:
* platform/glib/KeyedDecoderGlib.cpp:
(WebCore::KeyedDecoderGlib::decodeUInt64):
* platform/glib/KeyedDecoderGlib.h:
* platform/glib/KeyedEncoderGlib.cpp:
(WebCore::KeyedEncoderGlib::encodeUInt64):
* platform/glib/KeyedEncoderGlib.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (235672 => 235673)


--- trunk/Source/WebCore/ChangeLog	2018-09-05 16:49:38 UTC (rev 235672)
+++ trunk/Source/WebCore/ChangeLog	2018-09-05 17:03:02 UTC (rev 235673)
@@ -1,3 +1,30 @@
+2018-09-05  Woodrow Wang  <[email protected]>
+
+        Add functionality to encode and decode a uint64_t in KeyedCoding
+        https://bugs.webkit.org/show_bug.cgi?id=189216
+
+        Reviewed by Daniel Bates.
+
+        I've added this functionality in order to be able to encode and decode the raw uint64_t 
+        representation of an OptionSet for my patch here <https://bugs.webkit.org/show_bug.cgi?id=187773>. 
+
+        The changes in the KeyedEncoder/KeyedDecoder for Glib were made because they are derived classes
+        of KeyedCoding which contains pure virtual functions that need to be implemented.
+
+        * platform/KeyedCoding.h:
+        * platform/cf/KeyedDecoderCF.cpp:
+        (WebCore::KeyedDecoderCF::decodeUInt64):
+        * platform/cf/KeyedDecoderCF.h:
+        * platform/cf/KeyedEncoderCF.cpp:
+        (WebCore::KeyedEncoderCF::encodeUInt64):
+        * platform/cf/KeyedEncoderCF.h:
+        * platform/glib/KeyedDecoderGlib.cpp:
+        (WebCore::KeyedDecoderGlib::decodeUInt64):
+        * platform/glib/KeyedDecoderGlib.h:
+        * platform/glib/KeyedEncoderGlib.cpp:
+        (WebCore::KeyedEncoderGlib::encodeUInt64):
+        * platform/glib/KeyedEncoderGlib.h:
+
 2018-09-05  Zan Dobersek  <[email protected]>
 
         [GTK] ASSERT(!m_nicosia.imageBacking) when starting any YouTube video

Modified: trunk/Source/WebCore/platform/KeyedCoding.h (235672 => 235673)


--- trunk/Source/WebCore/platform/KeyedCoding.h	2018-09-05 16:49:38 UTC (rev 235672)
+++ trunk/Source/WebCore/platform/KeyedCoding.h	2018-09-05 17:03:02 UTC (rev 235673)
@@ -42,6 +42,7 @@
     virtual bool decodeBytes(const String& key, const uint8_t*&, size_t&) = 0;
     virtual bool decodeBool(const String& key, bool&) = 0;
     virtual bool decodeUInt32(const String& key, uint32_t&) = 0;
+    virtual bool decodeUInt64(const String& key, uint64_t&) = 0;
     virtual bool decodeInt32(const String& key, int32_t&) = 0;
     virtual bool decodeInt64(const String& key, int64_t&) = 0;
     virtual bool decodeFloat(const String& key, float&) = 0;
@@ -150,6 +151,7 @@
     virtual void encodeBytes(const String& key, const uint8_t*, size_t) = 0;
     virtual void encodeBool(const String& key, bool) = 0;
     virtual void encodeUInt32(const String& key, uint32_t) = 0;
+    virtual void encodeUInt64(const String& key, uint64_t) = 0;
     virtual void encodeInt32(const String& key, int32_t) = 0;
     virtual void encodeInt64(const String& key, int64_t) = 0;
     virtual void encodeFloat(const String& key, float) = 0;

Modified: trunk/Source/WebCore/platform/cf/KeyedDecoderCF.cpp (235672 => 235673)


--- trunk/Source/WebCore/platform/cf/KeyedDecoderCF.cpp	2018-09-05 16:49:38 UTC (rev 235672)
+++ trunk/Source/WebCore/platform/cf/KeyedDecoderCF.cpp	2018-09-05 17:03:02 UTC (rev 235673)
@@ -81,6 +81,11 @@
 {
     return decodeInt32(key, reinterpret_cast<int32_t&>(result));
 }
+    
+bool KeyedDecoderCF::decodeUInt64(const String& key, uint64_t& result)
+{
+    return decodeInt64(key, reinterpret_cast<int64_t&>(result));
+}
 
 bool KeyedDecoderCF::decodeInt32(const String& key, int32_t& result)
 {

Modified: trunk/Source/WebCore/platform/cf/KeyedDecoderCF.h (235672 => 235673)


--- trunk/Source/WebCore/platform/cf/KeyedDecoderCF.h	2018-09-05 16:49:38 UTC (rev 235672)
+++ trunk/Source/WebCore/platform/cf/KeyedDecoderCF.h	2018-09-05 17:03:02 UTC (rev 235673)
@@ -41,6 +41,7 @@
     bool decodeBytes(const String& key, const uint8_t*&, size_t&) override;
     bool decodeBool(const String& key, bool&) override;
     bool decodeUInt32(const String& key, uint32_t&) override;
+    bool decodeUInt64(const String& key, uint64_t&) override;
     bool decodeInt32(const String& key, int32_t&) override;
     bool decodeInt64(const String& key, int64_t&) override;
     bool decodeFloat(const String& key, float&) override;

Modified: trunk/Source/WebCore/platform/cf/KeyedEncoderCF.cpp (235672 => 235673)


--- trunk/Source/WebCore/platform/cf/KeyedEncoderCF.cpp	2018-09-05 16:49:38 UTC (rev 235672)
+++ trunk/Source/WebCore/platform/cf/KeyedEncoderCF.cpp	2018-09-05 17:03:02 UTC (rev 235673)
@@ -71,6 +71,12 @@
     auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
     CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get());
 }
+    
+void KeyedEncoderCF::encodeUInt64(const String& key, uint64_t value)
+{
+    auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value));
+    CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get());
+}
 
 void KeyedEncoderCF::encodeInt32(const String& key, int32_t value)
 {

Modified: trunk/Source/WebCore/platform/cf/KeyedEncoderCF.h (235672 => 235673)


--- trunk/Source/WebCore/platform/cf/KeyedEncoderCF.h	2018-09-05 16:49:38 UTC (rev 235672)
+++ trunk/Source/WebCore/platform/cf/KeyedEncoderCF.h	2018-09-05 17:03:02 UTC (rev 235673)
@@ -42,6 +42,7 @@
     void encodeBytes(const String& key, const uint8_t*, size_t) final;
     void encodeBool(const String& key, bool) final;
     void encodeUInt32(const String& key, uint32_t) final;
+    void encodeUInt64(const String& key, uint64_t) final;
     void encodeInt32(const String& key, int32_t) final;
     void encodeInt64(const String& key, int64_t) final;
     void encodeFloat(const String& key, float) final;

Modified: trunk/Source/WebCore/platform/glib/KeyedDecoderGlib.cpp (235672 => 235673)


--- trunk/Source/WebCore/platform/glib/KeyedDecoderGlib.cpp	2018-09-05 16:49:38 UTC (rev 235672)
+++ trunk/Source/WebCore/platform/glib/KeyedDecoderGlib.cpp	2018-09-05 17:03:02 UTC (rev 235673)
@@ -93,6 +93,11 @@
     return decodeSimpleValue(key, result, g_variant_get_uint32);
 }
 
+bool KeyedDecoderGlib::decodeUInt64(const String& key, uint64_t& result)
+{
+    return decodeSimpleValue(key, result, g_variant_get_uint64);
+}
+
 bool KeyedDecoderGlib::decodeInt32(const String& key, int32_t& result)
 {
     return decodeSimpleValue(key, result, g_variant_get_int32);

Modified: trunk/Source/WebCore/platform/glib/KeyedDecoderGlib.h (235672 => 235673)


--- trunk/Source/WebCore/platform/glib/KeyedDecoderGlib.h	2018-09-05 16:49:38 UTC (rev 235672)
+++ trunk/Source/WebCore/platform/glib/KeyedDecoderGlib.h	2018-09-05 17:03:02 UTC (rev 235673)
@@ -44,6 +44,7 @@
     bool decodeBytes(const String& key, const uint8_t*&, size_t&) override;
     bool decodeBool(const String& key, bool&) override;
     bool decodeUInt32(const String& key, uint32_t&) override;
+    bool decodeUInt64(const String& key, uint64_t&) override;
     bool decodeInt32(const String& key, int32_t&) override;
     bool decodeInt64(const String& key, int64_t&) override;
     bool decodeFloat(const String& key, float&) override;

Modified: trunk/Source/WebCore/platform/glib/KeyedEncoderGlib.cpp (235672 => 235673)


--- trunk/Source/WebCore/platform/glib/KeyedEncoderGlib.cpp	2018-09-05 16:49:38 UTC (rev 235672)
+++ trunk/Source/WebCore/platform/glib/KeyedEncoderGlib.cpp	2018-09-05 17:03:02 UTC (rev 235673)
@@ -65,6 +65,11 @@
 {
     g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", key.utf8().data(), g_variant_new_uint32(value));
 }
+    
+void KeyedEncoderGlib::encodeUInt64(const String& key, uint64_t value)
+{
+    g_variant_builder_add(m_variantBuilderStack.last(), "{sv}", key.utf8().data(), g_variant_new_uint64(value));
+}
 
 void KeyedEncoderGlib::encodeInt32(const String& key, int32_t value)
 {

Modified: trunk/Source/WebCore/platform/glib/KeyedEncoderGlib.h (235672 => 235673)


--- trunk/Source/WebCore/platform/glib/KeyedEncoderGlib.h	2018-09-05 16:49:38 UTC (rev 235672)
+++ trunk/Source/WebCore/platform/glib/KeyedEncoderGlib.h	2018-09-05 17:03:02 UTC (rev 235673)
@@ -44,6 +44,7 @@
     void encodeBytes(const String& key, const uint8_t*, size_t) final;
     void encodeBool(const String& key, bool) final;
     void encodeUInt32(const String& key, uint32_t) final;
+    void encodeUInt64(const String& key, uint64_t) final;
     void encodeInt32(const String& key, int32_t) final;
     void encodeInt64(const String& key, int64_t) final;
     void encodeFloat(const String& key, float) final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to