Changeset 61635 in webkit
- Timestamp:
- Jun 22, 2010 4:35:44 PM (14 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r61634 r61635 1 2010-06-22 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Use the ArgumentCoder class template for decoding 6 https://bugs.webkit.org/show_bug.cgi?id=41021 7 8 * Platform/CoreIPC/ArgumentCoder.h: 9 (CoreIPC::ArgumentCoder::decode): 10 * Platform/CoreIPC/ArgumentDecoder.h: 11 (CoreIPC::ArgumentDecoder::decode): 12 * Shared/WebCoreTypeArgumentMarshalling.h: 13 (CoreIPC::): 14 1 15 2010-06-22 Anders Carlsson <andersca@apple.com> 2 16 -
trunk/WebKit2/Platform/CoreIPC/ArgumentCoder.h
r61634 r61635 39 39 t.encode(*encoder); 40 40 } 41 42 static bool decode(ArgumentDecoder* decoder, T& t) 43 { 44 return T::decode(*decoder, t); 45 } 41 46 }; 42 47 -
trunk/WebKit2/Platform/CoreIPC/ArgumentDecoder.h
r57454 r61635 27 27 #define ArgumentDecoder_h 28 28 29 #include "ArgumentCoder.h" 29 30 #include "Attachment.h" 30 31 #include <wtf/Deque.h> 31 #include <wtf/TypeTraits.h>32 32 #include <wtf/Vector.h> 33 33 34 34 namespace CoreIPC { 35 36 class ArgumentDecoder;37 class Attachment;38 39 namespace ArgumentCoders {40 41 template<typename T> bool decode(ArgumentDecoder& decoder, T& t)42 {43 return WTF::RemovePointer<T>::Type::decode(decoder, t);44 }45 46 }47 35 48 36 class ArgumentDecoder { … … 68 56 template<typename T> bool decode(T& t) 69 57 { 70 return ArgumentCoder s::decode<T>(*this, t);58 return ArgumentCoder<T>::decode(this, t); 71 59 } 72 60 -
trunk/WebKit2/Shared/WebCoreTypeArgumentMarshalling.h
r61634 r61635 41 41 encoder->encode(CoreIPC::In(p.x(), p.y())); 42 42 }; 43 44 static bool decode(ArgumentDecoder* decoder, WebCore::IntPoint& p) 45 { 46 int x; 47 int y; 48 if (!decoder->decode(CoreIPC::Out(x, y))) 49 return false; 50 51 p.setX(x); 52 p.setY(y); 53 return true; 54 } 43 55 }; 44 56 … … 48 60 encoder->encode(CoreIPC::In(s.width(), s.height())); 49 61 }; 62 63 static bool decode(ArgumentDecoder* decoder, WebCore::IntSize& s) 64 { 65 int width; 66 int height; 67 if (!decoder->decode(CoreIPC::Out(width, height))) 68 return false; 69 70 s.setWidth(width); 71 s.setHeight(height); 72 return true; 73 } 74 50 75 }; 51 76 … … 55 80 encoder->encode(CoreIPC::In(r.location(), r.size())); 56 81 }; 82 83 static bool decode(ArgumentDecoder* decoder, WebCore::IntRect& r) 84 { 85 WebCore::IntPoint location; 86 WebCore::IntSize size; 87 if (!decoder->decode(CoreIPC::Out(location, size))) 88 return false; 89 90 r.setLocation(location); 91 r.setSize(size); 92 return true; 93 } 57 94 }; 58 95 … … 64 101 encoder->encodeBytes(reinterpret_cast<const uint8_t*>(string.characters()), length * sizeof(UChar)); 65 102 } 103 104 static bool decode(ArgumentDecoder* decoder, WebCore::String& s) 105 { 106 uint32_t length; 107 if (!decoder->decode(length)) 108 return false; 109 110 UChar* buffer; 111 WebCore::String string = WebCore::String::createUninitialized(length, buffer); 112 if (!decoder->decodeBytes(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar))) 113 return false; 114 115 s = string; 116 return true; 117 } 66 118 }; 67 119 68 namespace ArgumentCoders {69 70 // FIXME: IntPoint/IntSize/IntRect/FloatPoint/FloatSize/FloatRect should all71 // be able to be treated as POD-like types and thus memcpy-able.72 73 // WebCore::IntPoint74 template<> inline bool decode(ArgumentDecoder& decoder, WebCore::IntPoint& p)75 {76 int x;77 int y;78 if (!decoder.decode(CoreIPC::Out(x, y)))79 return false;80 81 p.setX(x);82 p.setY(y);83 return true;84 }85 86 // WebCore::IntSize87 template<> inline bool decode(ArgumentDecoder& decoder, WebCore::IntSize& s)88 {89 int width;90 int height;91 if (!decoder.decode(CoreIPC::Out(width, height)))92 return false;93 94 s.setWidth(width);95 s.setHeight(height);96 return true;97 }98 99 // WebCore::IntRect100 template<> inline bool decode(ArgumentDecoder& decoder, WebCore::IntRect& r)101 {102 WebCore::IntPoint location;103 WebCore::IntSize size;104 if (!decoder.decode(CoreIPC::Out(location, size)))105 return false;106 107 r.setLocation(location);108 r.setSize(size);109 return true;110 }111 112 // WebCore::FloatPoint113 template<> inline bool decode(ArgumentDecoder& decoder, WebCore::FloatPoint& p)114 {115 float x;116 float y;117 if (!decoder.decode(CoreIPC::Out(x, y)))118 return false;119 120 p.setX(x);121 p.setY(y);122 return true;123 }124 125 // WebCore::FloatSize126 template<> inline bool decode(ArgumentDecoder& decoder, WebCore::FloatSize& s)127 {128 float width;129 float height;130 if (!decoder.decode(CoreIPC::Out(width, height)))131 return false;132 133 s.setWidth(width);134 s.setHeight(height);135 return true;136 }137 138 // WebCore::FloatRect139 template<> inline bool decode(ArgumentDecoder& decoder, WebCore::FloatRect& r)140 {141 WebCore::FloatPoint location;142 WebCore::FloatSize size;143 if (!decoder.decode(CoreIPC::Out(location, size)))144 return false;145 146 r.setLocation(location);147 r.setSize(size);148 return true;149 }150 151 // WebCore::String152 template<> inline bool decode(ArgumentDecoder& decoder, WebCore::String& s)153 {154 uint32_t length;155 if (!decoder.decode(length))156 return false;157 158 UChar* buffer;159 WebCore::String string = WebCore::String::createUninitialized(length, buffer);160 if (!decoder.decodeBytes(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar)))161 return false;162 163 s = string;164 return true;165 }166 167 } // namespace ArgumentCoders168 120 } // namespace CoreIPC 169 121
Note: See TracChangeset
for help on using the changeset viewer.