Add encoding and decoding of ints to WKRemoteObjectCoder
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Apr 2015 22:47:26 +0000 (22:47 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Apr 2015 22:47:26 +0000 (22:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143538

Reviewed by Tim Horton.

* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(-[WKRemoteObjectEncoder encodeInt:forKey:]):
(-[WKRemoteObjectDecoder decodeIntForKey:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182572 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm

index 844fa886a36e8f09fcf9998039116276950dba70..e09dd1abdc601d07f38a8f022678211c81c1baef 100644 (file)
@@ -1,3 +1,14 @@
+2015-04-08  Anders Carlsson  <andersca@apple.com>
+
+        Add encoding and decoding of ints to WKRemoteObjectCoder
+        https://bugs.webkit.org/show_bug.cgi?id=143538
+
+        Reviewed by Tim Horton.
+
+        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+        (-[WKRemoteObjectEncoder encodeInt:forKey:]):
+        (-[WKRemoteObjectDecoder decodeIntForKey:]):
+
 2015-04-08  Anders Carlsson  <andersca@apple.com>
 
         Delete ApplicationCache static member functions
index 480a33cef63f2894ebc7ff15a50fa11481166f23..f597a366571726d1f7818293ea941e9ea12756ac 100644 (file)
@@ -297,6 +297,11 @@ static NSString *escapeKey(NSString *key)
     _currentDictionary->set(escapeKey(key), API::Boolean::create(value));
 }
 
+- (void)encodeInt:(int)value forKey:(NSString *)key
+{
+    _currentDictionary->set(escapeKey(key), API::UInt64::create(value));
+}
+
 - (void)encodeInt32:(int32_t)value forKey:(NSString *)key
 {
     _currentDictionary->set(escapeKey(key), API::UInt64::create(value));
@@ -596,6 +601,14 @@ static id decodeObject(WKRemoteObjectDecoder *decoder, const API::Dictionary* di
     return value->value();
 }
 
+- (int)decodeIntForKey:(NSString *)key
+{
+    const API::UInt64* value = _currentDictionary->get<API::UInt64>(escapeKey(key));
+    if (!value)
+        return 0;
+    return static_cast<int>(value->value());
+}
+
 - (int32_t)decodeInt32ForKey:(NSString *)key
 {
     const API::UInt64* value = _currentDictionary->get<API::UInt64>(escapeKey(key));