Index: ObjFW.xcodeproj/project.pbxproj ================================================================== --- ObjFW.xcodeproj/project.pbxproj +++ ObjFW.xcodeproj/project.pbxproj @@ -268,12 +268,10 @@ 4B55A115133AC24600B58A93 /* OFReadOrWriteFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A10F133AC24500B58A93 /* OFReadOrWriteFailedException.m */; }; 4B55A116133AC24600B58A93 /* OFWriteFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A110133AC24500B58A93 /* OFWriteFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B55A117133AC24600B58A93 /* OFWriteFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A111133AC24600B58A93 /* OFWriteFailedException.m */; }; 4B5CF8F914940BD2007AA324 /* OFString+JSONValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B5CF8F614940BD2007AA324 /* OFString+JSONValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B5CF8FA14940BD2007AA324 /* OFString+JSONValue.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B5CF8F714940BD2007AA324 /* OFString+JSONValue.m */; }; - 4B6330ED16D67C4400187B8E /* OFDataArray+BinaryPackValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6330EB16D67C4400187B8E /* OFDataArray+BinaryPackValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4B6330EE16D67C4400187B8E /* OFDataArray+BinaryPackValue.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6330EC16D67C4400187B8E /* OFDataArray+BinaryPackValue.m */; }; 4B64D6EF1425381E007BDFB1 /* OFStreamObserver_poll.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B64D6EB1425381E007BDFB1 /* OFStreamObserver_poll.h */; }; 4B64D6F01425381E007BDFB1 /* OFStreamObserver_poll.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B64D6EC1425381E007BDFB1 /* OFStreamObserver_poll.m */; }; 4B64D6F11425381E007BDFB1 /* OFStreamObserver_select.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B64D6ED1425381E007BDFB1 /* OFStreamObserver_select.h */; }; 4B64D6F21425381E007BDFB1 /* OFStreamObserver_select.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B64D6EE1425381E007BDFB1 /* OFStreamObserver_select.m */; }; 4B6743F1163C384A00EB1E59 /* OFLockFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6743EB163C384A00EB1E59 /* OFLockFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -297,10 +295,13 @@ 4B7FF3B5133CED6200000324 /* OFConditionStillWaitingException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B7FF3B3133CED6100000324 /* OFConditionStillWaitingException.m */; }; 4B837D7916829C5F007A3E83 /* block.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B837D7716829C5F007A3E83 /* block.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B837D7A16829C5F007A3E83 /* instance.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B837D7816829C5F007A3E83 /* instance.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B83F0F4142FDEFD00E4A821 /* OFStreamObserver_kqueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B83F0F2142FDEFD00E4A821 /* OFStreamObserver_kqueue.h */; }; 4B83F0F5142FDEFD00E4A821 /* OFStreamObserver_kqueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B83F0F3142FDEFD00E4A821 /* OFStreamObserver_kqueue.m */; }; + 4B879A8C177231F000EBCEA4 /* OFDataArray+MessagePackValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B879A89177231F000EBCEA4 /* OFDataArray+MessagePackValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4B879A8D177231F000EBCEA4 /* OFDataArray+MessagePackValue.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B879A8A177231F000EBCEA4 /* OFDataArray+MessagePackValue.m */; }; + 4B879A8E177231F000EBCEA4 /* OFMessagePackRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B879A8B177231F000EBCEA4 /* OFMessagePackRepresentation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B8B16FE133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B16FC133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B8B16FF133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B16FD133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.m */; }; 4B8B170D133A3C11007CD8B3 /* OFConditionBroadcastFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1702133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.m */; }; 4B8B170E133A3C11007CD8B3 /* OFConditionSignalFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1704133A3B8E007CD8B3 /* OFConditionSignalFailedException.m */; }; 4B8B170F133A3C11007CD8B3 /* OFConditionWaitFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1706133A3B8E007CD8B3 /* OFConditionWaitFailedException.m */; }; @@ -357,11 +358,10 @@ 4BB4B54616775FF4002A2DCE /* OFHTTPServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB4B54116775FF4002A2DCE /* OFHTTPServer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BB4B54716775FF4002A2DCE /* OFHTTPServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4B54216775FF4002A2DCE /* OFHTTPServer.m */; }; 4BB4B54A16776094002A2DCE /* OFHTTPClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4B54916776094002A2DCE /* OFHTTPClientTests.m */; }; 4BB524C1143D1E4E0085FBCC /* OFProcess.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB524BF143D1E4E0085FBCC /* OFProcess.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BB524C2143D1E4E0085FBCC /* OFProcess.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB524C0143D1E4E0085FBCC /* OFProcess.m */; settings = {ATTRIBUTES = (Public, ); }; }; - 4BB61D4916DA2AB700986DE1 /* OFBinaryPackRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB61D4816DA2AB700986DE1 /* OFBinaryPackRepresentation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BC090441584F6760040640F /* OFInvalidJSONException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC090421584F6760040640F /* OFInvalidJSONException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BC090451584F6760040640F /* OFInvalidJSONException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC090431584F6760040640F /* OFInvalidJSONException.m */; }; 4BD653C5143B8489006182F0 /* OFTCPSocket+SOCKS5.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD653C3143B8489006182F0 /* OFTCPSocket+SOCKS5.h */; settings = {ATTRIBUTES = (); }; }; 4BD653C6143B8489006182F0 /* OFTCPSocket+SOCKS5.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */; }; 4BD77FDE176E4BC40031C497 /* OFUnboundPrefixException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD77FDC176E4BC40031C497 /* OFUnboundPrefixException.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -617,12 +617,10 @@ 4B55A10F133AC24500B58A93 /* OFReadOrWriteFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFReadOrWriteFailedException.m; path = src/exceptions/OFReadOrWriteFailedException.m; sourceTree = ""; }; 4B55A110133AC24500B58A93 /* OFWriteFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFWriteFailedException.h; path = src/exceptions/OFWriteFailedException.h; sourceTree = ""; }; 4B55A111133AC24600B58A93 /* OFWriteFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFWriteFailedException.m; path = src/exceptions/OFWriteFailedException.m; sourceTree = ""; }; 4B5CF8F614940BD2007AA324 /* OFString+JSONValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFString+JSONValue.h"; path = "src/OFString+JSONValue.h"; sourceTree = ""; }; 4B5CF8F714940BD2007AA324 /* OFString+JSONValue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFString+JSONValue.m"; path = "src/OFString+JSONValue.m"; sourceTree = ""; }; - 4B6330EB16D67C4400187B8E /* OFDataArray+BinaryPackValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFDataArray+BinaryPackValue.h"; path = "src/OFDataArray+BinaryPackValue.h"; sourceTree = ""; }; - 4B6330EC16D67C4400187B8E /* OFDataArray+BinaryPackValue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFDataArray+BinaryPackValue.m"; path = "src/OFDataArray+BinaryPackValue.m"; sourceTree = ""; }; 4B64D6EB1425381E007BDFB1 /* OFStreamObserver_poll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFStreamObserver_poll.h; path = src/OFStreamObserver_poll.h; sourceTree = ""; }; 4B64D6EC1425381E007BDFB1 /* OFStreamObserver_poll.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFStreamObserver_poll.m; path = src/OFStreamObserver_poll.m; sourceTree = ""; }; 4B64D6ED1425381E007BDFB1 /* OFStreamObserver_select.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFStreamObserver_select.h; path = src/OFStreamObserver_select.h; sourceTree = ""; }; 4B64D6EE1425381E007BDFB1 /* OFStreamObserver_select.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFStreamObserver_select.m; path = src/OFStreamObserver_select.m; sourceTree = ""; }; 4B6743EB163C384A00EB1E59 /* OFLockFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFLockFailedException.h; path = src/exceptions/OFLockFailedException.h; sourceTree = ""; }; @@ -709,10 +707,13 @@ 4B7FF3B3133CED6100000324 /* OFConditionStillWaitingException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionStillWaitingException.m; path = src/exceptions/OFConditionStillWaitingException.m; sourceTree = ""; }; 4B837D7716829C5F007A3E83 /* block.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = block.h; path = src/block.h; sourceTree = ""; }; 4B837D7816829C5F007A3E83 /* instance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = instance.h; path = src/instance.h; sourceTree = ""; }; 4B83F0F2142FDEFD00E4A821 /* OFStreamObserver_kqueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFStreamObserver_kqueue.h; path = src/OFStreamObserver_kqueue.h; sourceTree = ""; }; 4B83F0F3142FDEFD00E4A821 /* OFStreamObserver_kqueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFStreamObserver_kqueue.m; path = src/OFStreamObserver_kqueue.m; sourceTree = ""; }; + 4B879A89177231F000EBCEA4 /* OFDataArray+MessagePackValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFDataArray+MessagePackValue.h"; path = "src/OFDataArray+MessagePackValue.h"; sourceTree = ""; }; + 4B879A8A177231F000EBCEA4 /* OFDataArray+MessagePackValue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFDataArray+MessagePackValue.m"; path = "src/OFDataArray+MessagePackValue.m"; sourceTree = ""; }; + 4B879A8B177231F000EBCEA4 /* OFMessagePackRepresentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMessagePackRepresentation.h; path = src/OFMessagePackRepresentation.h; sourceTree = ""; }; 4B8B16FC133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFHashAlreadyCalculatedException.h; path = src/exceptions/OFHashAlreadyCalculatedException.h; sourceTree = ""; }; 4B8B16FD133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFHashAlreadyCalculatedException.m; path = src/exceptions/OFHashAlreadyCalculatedException.m; sourceTree = ""; }; 4B8B1701133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConditionBroadcastFailedException.h; path = src/exceptions/OFConditionBroadcastFailedException.h; sourceTree = ""; }; 4B8B1702133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionBroadcastFailedException.m; path = src/exceptions/OFConditionBroadcastFailedException.m; sourceTree = ""; }; 4B8B1703133A3B8E007CD8B3 /* OFConditionSignalFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConditionSignalFailedException.h; path = src/exceptions/OFConditionSignalFailedException.h; sourceTree = ""; }; @@ -783,11 +784,10 @@ 4BB4B54916776094002A2DCE /* OFHTTPClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFHTTPClientTests.m; path = tests/OFHTTPClientTests.m; sourceTree = ""; }; 4BB50DCF12F863C700C9393F /* of_asprintf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = of_asprintf.h; path = src/of_asprintf.h; sourceTree = SOURCE_ROOT; }; 4BB50DD012F863C700C9393F /* of_asprintf.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = of_asprintf.m; path = src/of_asprintf.m; sourceTree = SOURCE_ROOT; }; 4BB524BF143D1E4E0085FBCC /* OFProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFProcess.h; path = src/OFProcess.h; sourceTree = ""; }; 4BB524C0143D1E4E0085FBCC /* OFProcess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFProcess.m; path = src/OFProcess.m; sourceTree = ""; }; - 4BB61D4816DA2AB700986DE1 /* OFBinaryPackRepresentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBinaryPackRepresentation.h; path = src/OFBinaryPackRepresentation.h; sourceTree = ""; }; 4BBA36C411406AB700CBA3AC /* atomic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atomic.h; path = src/atomic.h; sourceTree = ""; }; 4BBA36C511406AB700CBA3AC /* macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = macros.h; path = src/macros.h; sourceTree = ""; }; 4BC090421584F6760040640F /* OFInvalidJSONException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFInvalidJSONException.h; path = src/exceptions/OFInvalidJSONException.h; sourceTree = ""; }; 4BC090431584F6760040640F /* OFInvalidJSONException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFInvalidJSONException.m; path = src/exceptions/OFInvalidJSONException.m; sourceTree = ""; }; 4BD653C3143B8489006182F0 /* OFTCPSocket+SOCKS5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFTCPSocket+SOCKS5.h"; path = "src/OFTCPSocket+SOCKS5.h"; sourceTree = ""; }; @@ -1083,11 +1083,10 @@ 4B9BB7BA141CDE2D000AD1CC /* OFArray_adjacentSubarray.m */, 4B9BB7BB141CDE2D000AD1CC /* OFArray_subarray.h */, 4B9BB7BC141CDE2D000AD1CC /* OFArray_subarray.m */, 4B67995C1099E7C50041064A /* OFAutoreleasePool.h */, 4B67995D1099E7C50041064A /* OFAutoreleasePool.m */, - 4BB61D4816DA2AB700986DE1 /* OFBinaryPackRepresentation.h */, 4BD86D801237A6C600ED9912 /* OFBlock.h */, 4BD86D811237A6C600ED9912 /* OFBlock.m */, 4BAF5F46123460C900F4E111 /* OFCollection.h */, 4B6743F7163C395900EB1E59 /* OFCondition.h */, 4B6743F8163C395900EB1E59 /* OFCondition.m */, @@ -1097,14 +1096,14 @@ 4B45355213DCFE1E0037AB4D /* OFCountedSet.m */, 4BA85BC4140ECCE800E91D51 /* OFCountedSet_hashtable.h */, 4BA85BC5140ECCE800E91D51 /* OFCountedSet_hashtable.m */, 4B6799601099E7C50041064A /* OFDataArray.h */, 4B6799611099E7C50041064A /* OFDataArray.m */, - 4B6330EB16D67C4400187B8E /* OFDataArray+BinaryPackValue.h */, - 4B6330EC16D67C4400187B8E /* OFDataArray+BinaryPackValue.m */, 4BE17AD912FD746D002CEB0B /* OFDataArray+Hashing.h */, 4BE17ADA12FD746D002CEB0B /* OFDataArray+Hashing.m */, + 4B879A89177231F000EBCEA4 /* OFDataArray+MessagePackValue.h */, + 4B879A8A177231F000EBCEA4 /* OFDataArray+MessagePackValue.m */, 4BE5F0D912DF4225005C7A0C /* OFDate.h */, 4BE5F0DA12DF4225005C7A0C /* OFDate.m */, 4B6799621099E7C50041064A /* OFDictionary.h */, 4B6799631099E7C50041064A /* OFDictionary.m */, 4B2B3E75140D430500EC2F7C /* OFDictionary_hashtable.h */, @@ -1130,10 +1129,11 @@ 4B6743F9163C395900EB1E59 /* OFLocking.h */, 4B3B0796166978780044E634 /* OFMapTable.h */, 4B3B0797166978780044E634 /* OFMapTable.m */, 4BF1BCC211C9663F0025511F /* OFMD5Hash.h */, 4BF1BCC311C9663F0025511F /* OFMD5Hash.m */, + 4B879A8B177231F000EBCEA4 /* OFMessagePackRepresentation.h */, 4B67996F1099E7C50041064A /* OFMutableArray.h */, 4B6799701099E7C50041064A /* OFMutableArray.m */, 4B2B3E77140D430500EC2F7C /* OFMutableArray_adjacent.h */, 4B2B3E78140D430500EC2F7C /* OFMutableArray_adjacent.m */, 4B6799711099E7C50041064A /* OFMutableDictionary.h */, @@ -1379,19 +1379,18 @@ files = ( 4B3D23BC1337FC8300DD29B8 /* OFApplication.h in Headers */, 4B3D23BD1337FC8300DD29B8 /* OFArray.h in Headers */, 4B9BB7BF141CDE2D000AD1CC /* OFArray_subarray.h in Headers */, 4B3D23BE1337FC8300DD29B8 /* OFAutoreleasePool.h in Headers */, - 4BB61D4916DA2AB700986DE1 /* OFBinaryPackRepresentation.h in Headers */, 4B3D23BF1337FC8300DD29B8 /* OFBlock.h in Headers */, 4B3D23C01337FC8300DD29B8 /* OFCollection.h in Headers */, 4B674400163C395900EB1E59 /* OFCondition.h in Headers */, 4B3D23C11337FC8300DD29B8 /* OFConstantString.h in Headers */, 4B45355313DCFE1E0037AB4D /* OFCountedSet.h in Headers */, 4B3D23C21337FC8300DD29B8 /* OFDataArray.h in Headers */, - 4B6330ED16D67C4400187B8E /* OFDataArray+BinaryPackValue.h in Headers */, 4B3D23C31337FC8300DD29B8 /* OFDataArray+Hashing.h in Headers */, + 4B879A8C177231F000EBCEA4 /* OFDataArray+MessagePackValue.h in Headers */, 4B3D23C41337FC8300DD29B8 /* OFDate.h in Headers */, 4B3D23C51337FCB000DD29B8 /* OFDictionary.h in Headers */, 4B3D23C61337FCB000DD29B8 /* OFEnumerator.h in Headers */, 4B17FF74133A2AAB003E6DCD /* OFException.h in Headers */, 4B3D23C81337FCB000DD29B8 /* OFFile.h in Headers */, @@ -1404,10 +1403,11 @@ 4BA02BA115041F5900002F84 /* OFJSONRepresentation.h in Headers */, 4B3D23CB1337FCB000DD29B8 /* OFList.h in Headers */, 4B674402163C395900EB1E59 /* OFLocking.h in Headers */, 4B3B0798166978780044E634 /* OFMapTable.h in Headers */, 4B3D23CC1337FCB000DD29B8 /* OFMD5Hash.h in Headers */, + 4B879A8E177231F000EBCEA4 /* OFMessagePackRepresentation.h in Headers */, 4B3D23CD1337FCB000DD29B8 /* OFMutableArray.h in Headers */, 4B3D23CE1337FCB000DD29B8 /* OFMutableDictionary.h in Headers */, 4B39844713D3AFB400E6F825 /* OFMutableSet.h in Headers */, 4B3D23CF1337FCB000DD29B8 /* OFMutableString.h in Headers */, 4B674403163C395900EB1E59 /* OFMutex.h in Headers */, @@ -1738,11 +1738,10 @@ 4B674401163C395900EB1E59 /* OFCondition.m in Sources */, 4B3D238F1337FC0D00DD29B8 /* OFConstantString.m in Sources */, 4B45355413DCFE1E0037AB4D /* OFCountedSet.m in Sources */, 4BA85BCB140ECCE800E91D51 /* OFCountedSet_hashtable.m in Sources */, 4B3D23901337FC0D00DD29B8 /* OFDataArray.m in Sources */, - 4B6330EE16D67C4400187B8E /* OFDataArray+BinaryPackValue.m in Sources */, 4B3D23911337FC0D00DD29B8 /* OFDataArray+Hashing.m in Sources */, 4B3D23921337FC0D00DD29B8 /* OFDate.m in Sources */, 4B3D23931337FC0D00DD29B8 /* OFDictionary.m in Sources */, 4B2B3E80140D430500EC2F7C /* OFDictionary_hashtable.m in Sources */, 4B3D23941337FC0D00DD29B8 /* OFEnumerator.m in Sources */, @@ -1870,10 +1869,11 @@ 4BD77FDF176E4BC40031C497 /* OFUnboundPrefixException.m in Sources */, 4B6743F6163C384A00EB1E59 /* OFUnlockFailedException.m in Sources */, 4B17FFB2133A3664003E6DCD /* OFUnsupportedProtocolException.m in Sources */, 4BA4846315CC9F1E00D75360 /* OFUnsupportedVersionException.m in Sources */, 4B55A117133AC24600B58A93 /* OFWriteFailedException.m in Sources */, + 4B879A8D177231F000EBCEA4 /* OFDataArray+MessagePackValue.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 4BF33AEC133807310059CEF7 /* Sources */ = { isa = PBXSourcesBuildPhase; Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -13,12 +13,12 @@ OFAutoreleasePool.m \ OFBlock.m \ OFConstantString.m \ OFCountedSet.m \ OFDataArray.m \ - OFDataArray+BinaryPackValue.m \ OFDataArray+Hashing.m \ + OFDataArray+MessagePackValue.m \ OFDate.m \ OFDictionary.m \ OFEnumerator.m \ OFFile.m \ OFIntrospection.m \ @@ -83,15 +83,15 @@ OFThreadPool.m \ OFTLSKey.m INCLUDES_THREADS = threading.h INCLUDES := ${SRCS:.m=.h} \ - OFBinaryPackRepresentation.h \ OFCollection.h \ OFHash.h \ OFJSONRepresentation.h \ OFLocking.h \ + OFMessagePackRepresentation.h \ OFSerialization.h \ OFTLSSocket.h \ ObjFW.h \ asprintf.h \ autorelease.h \ Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -26,11 +26,11 @@ #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" #import "OFSerialization.h" #import "OFJSONRepresentation.h" -#import "OFBinaryPackRepresentation.h" +#import "OFMessagePackRepresentation.h" /*! @file */ @class OFString; @@ -80,11 +80,11 @@ /*! * @brief An abstract class for storing objects in an array. */ @interface OFArray: OFObject + OFSerialization, OFJSONRepresentation, OFMessagePackRepresentation> #ifdef OF_HAVE_PROPERTIES @property (readonly) size_t count; #endif /*! Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -561,11 +561,11 @@ objc_autoreleasePoolPop(pool); return [JSON autorelease]; } -- (OFDataArray*)binaryPackRepresentation +- (OFDataArray*)messagePackRepresentation { OFDataArray *data; size_t i, count; void *pool; OFEnumerator *enumerator; @@ -602,11 +602,11 @@ void *pool2 = objc_autoreleasePoolPush(); OFDataArray *child; i++; - child = [object binaryPackRepresentation]; + child = [object messagePackRepresentation]; [data addItems: [child items] count: [child count]]; objc_autoreleasePoolPop(pool2); } DELETED src/OFBinaryPackRepresentation.h Index: src/OFBinaryPackRepresentation.h ================================================================== --- src/OFBinaryPackRepresentation.h +++ src/OFBinaryPackRepresentation.h @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -@class OFDataArray; - -/*! - * @brief A protocol implemented by classes that support encoding to a - * BinaryPack representation. - */ -@protocol OFBinaryPackRepresentation -/*! - * @brief Returns the BinaryPack representation of the object as an OFDataArray. - * - * @return The BinaryPack representation of the object as an OFDataArray. - */ -- (OFDataArray*)binaryPackRepresentation; -@end DELETED src/OFDataArray+BinaryPackValue.h Index: src/OFDataArray+BinaryPackValue.h ================================================================== --- src/OFDataArray+BinaryPackValue.h +++ src/OFDataArray+BinaryPackValue.h @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#import "OFDataArray.h" - -#ifdef __cplusplus -extern "C" { -#endif -extern int _OFDataArray_BinaryPackValue_reference; -#ifdef __cplusplus -} -#endif - -@interface OFDataArray (BinaryPackValue) -- (id)binaryPackValue; -@end DELETED src/OFDataArray+BinaryPackValue.m Index: src/OFDataArray+BinaryPackValue.m ================================================================== --- src/OFDataArray+BinaryPackValue.m +++ src/OFDataArray+BinaryPackValue.m @@ -1,409 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#import "OFDataArray+BinaryPackValue.h" -#import "OFNumber.h" -#import "OFNull.h" -#import "OFDataArray.h" -#import "OFString.h" -#import "OFArray.h" -#import "OFDictionary.h" - -#import "OFInvalidFormatException.h" - -#import "autorelease.h" -#import "macros.h" - -int _OFDataArray_BinaryPackValue_reference; - -static size_t parse_object(const uint8_t*, size_t, id*); - -static uint16_t -read_uint16(const uint8_t *buffer) -{ - return ((uint16_t)buffer[0] << 8) | buffer[1]; -} - -static uint32_t -read_uint32(const uint8_t *buffer) -{ - return ((uint32_t)buffer[0] << 24) | ((uint32_t)buffer[1] << 16) | - ((uint32_t)buffer[2] << 8) | buffer[3]; -} - -static uint64_t -read_uint64(const uint8_t *buffer) -{ - return ((uint64_t)buffer[0] << 56) | ((uint64_t)buffer[1] << 48) | - ((uint64_t)buffer[2] << 40) | ((uint64_t)buffer[3] << 32) | - ((uint64_t)buffer[4] << 24) | ((uint64_t)buffer[5] << 16) | - ((uint64_t)buffer[6] << 8) | buffer[7]; -} - -static size_t -parse_array(const uint8_t *buffer, size_t length, id *object, size_t count) -{ - void *pool; - size_t i, pos; - - /* - * Don't use capacity! For data and strings, this is safe, as we can - * check if we still have enough bytes left. For an array however, we - * can't know this, as every child can be more than one byte. - */ - *object = [OFMutableArray array]; - pos = 0; - - for (i = 0; i < count; i++) { - id child; - size_t childLength; - - pool = objc_autoreleasePoolPush(); - - childLength = parse_object(buffer + pos, length - pos, &child); - if (childLength == 0 || child == nil) { - objc_autoreleasePoolPop(pool); - - *object = nil; - return 0; - } - pos += childLength; - - [*object addObject: child]; - - objc_autoreleasePoolPop(pool); - } - - return pos; -} - -static size_t -parse_table(const uint8_t *buffer, size_t length, id *object, size_t count) -{ - void *pool; - size_t i, pos; - - /* - * Don't use capacity! For data and strings, this is safe, as we can - * check if we still have enough bytes left. For a dictionary however, - * we can't know this, as every key / value can be more than one byte. - */ - *object = [OFMutableDictionary dictionary]; - pos = 0; - - for (i = 0; i < count; i++) { - id key, value; - size_t keyLength, valueLength; - - pool = objc_autoreleasePoolPush(); - - keyLength = parse_object(buffer + pos, length - pos, &key); - if (keyLength == 0 || key == nil) { - objc_autoreleasePoolPop(pool); - - *object = nil; - return 0; - } - pos += keyLength; - - valueLength = parse_object(buffer + pos, length - pos, &value); - if (valueLength == 0 || value == nil) { - objc_autoreleasePoolPop(pool); - - *object = nil; - return 0; - } - pos += valueLength; - - [*object setObject: value - forKey: key]; - - objc_autoreleasePoolPop(pool); - } - - return pos; -} - -static size_t -parse_object(const uint8_t *buffer, size_t length, id *object) -{ - size_t i, count; - - if (length < 1) - goto error; - - /* Integers */ - if ((buffer[0] & 0x80) == 0) { - *object = [OFNumber numberWithUInt8: buffer[0] & 0x7F]; - return 1; - } - if ((buffer[0] & 0xE0) == 0xE0) { - *object = [OFNumber numberWithInt8: - ((int8_t)(buffer[0] & 0x1F)) - 32]; - return 1; - } - - /* String */ - if ((buffer[0] & 0xE0) == 0xA0) { - count = buffer[0] & 0x1F; - - if (length < count + 1) - goto error; - - *object = [OFString - stringWithUTF8String: (const char*)buffer + 1 - length: count]; - return count + 1; - } - - /* Array */ - if ((buffer[0] & 0xF0) == 0x90) - return parse_array(buffer + 1, length - 1, object, - buffer[0] & 0xF) + 1; - - /* Table */ - if ((buffer[0] & 0xF0) == 0x80) - return parse_table(buffer + 1, length - 1, object, - buffer[0] & 0xF) + 1; - - /* Prefix byte */ - switch (*buffer) { - /* Unsigned integers */ - case 0xCC: - if (length < 2) - goto error; - - *object = [OFNumber numberWithUInt8: buffer[1]]; - return 2; - case 0xCD: - if (length < 3) - goto error; - - *object = [OFNumber numberWithUInt16: read_uint16(buffer + 1)]; - return 3; - case 0xCE: - if (length < 5) - goto error; - - *object = [OFNumber numberWithUInt32: read_uint32(buffer + 1)]; - return 5; - case 0xCF: - if (length < 9) - goto error; - - *object = [OFNumber numberWithUInt64: read_uint64(buffer + 1)]; - return 9; - /* Signed integers */ - case 0xD0: - if (length < 2) - goto error; - - *object = [OFNumber numberWithInt8: buffer[1]]; - return 2; - case 0xD1: - if (length < 3) - goto error; - - *object = [OFNumber numberWithInt16: read_uint16(buffer + 1)]; - return 3; - case 0xD2: - if (length < 5) - goto error; - - *object = [OFNumber numberWithInt32: read_uint32(buffer + 1)]; - return 5; - case 0xD3: - if (length < 9) - goto error; - - *object = [OFNumber numberWithInt64: read_uint64(buffer + 1)]; - return 9; - /* Float */ - case 0xCA:; - union { - uint8_t u8[4]; - float f; - } f; - - if (length < 5) - goto error; - - for (i = 0; i < 4; i++) - f.u8[i] = buffer[i + 1]; - - *object = [OFNumber numberWithFloat: OF_BSWAP_FLOAT_IF_LE(f.f)]; - return 5; - /* Double */ - case 0xCB:; - union { - uint8_t u8[8]; - double d; - } d; - - if (length < 9) - goto error; - - for (i = 0; i < 8; i++) - d.u8[i] = buffer[i + 1]; - - *object = [OFNumber numberWithDouble: - OF_BSWAP_DOUBLE_IF_LE(d.d)]; - return 9; - /* nil */ - case 0xC0: - *object = [OFNull null]; - return 1; - /* false */ - case 0xC2: - *object = [OFNumber numberWithBool: false]; - return 1; - /* true */ - case 0xC3: - *object = [OFNumber numberWithBool: true]; - return 1; - /* Data */ - case 0xD5: - if (length < 2) - goto error; - - count = buffer[1]; - - if (length < count + 2) - goto error; - - *object = [OFDataArray dataArrayWithItemSize: 1 - capacity: count]; - [*object addItems: buffer + 2 - count: count]; - - return count + 2; - case 0xD6: - if (length < 3) - goto error; - - count = read_uint16(buffer + 1); - - if (length < count + 3) - goto error; - - *object = [OFDataArray dataArrayWithItemSize: 1 - capacity: count]; - [*object addItems: buffer + 3 - count: count]; - - return count + 3; - case 0xD7: - if (length < 5) - goto error; - - count = read_uint32(buffer + 1); - - if (length < count + 5) - goto error; - - *object = [OFDataArray dataArrayWithItemSize: 1 - capacity: count]; - [*object addItems: buffer + 5 - count: count]; - - return count + 5; - /* Strings */ - case 0xD9: - if (length < 2) - goto error; - - count = buffer[1]; - - if (length < count + 2) - goto error; - - *object = [OFString - stringWithUTF8String: (const char*)buffer + 2 - length: count]; - return count + 2; - case 0xDA: - if (length < 3) - goto error; - - count = read_uint16(buffer + 1); - - if (length < count + 3) - goto error; - - *object = [OFString - stringWithUTF8String: (const char*)buffer + 3 - length: count]; - return count + 3; - case 0xDB: - if (length < 5) - goto error; - - count = read_uint32(buffer + 1); - - if (length < count + 5) - goto error; - - *object = [OFString - stringWithUTF8String: (const char*)buffer + 5 - length: count]; - return count + 5; - /* Arrays */ - case 0xDC: - if (length < 3) - goto error; - - return parse_array(buffer + 3, length - 3, object, - read_uint16(buffer + 1)) + 3; - case 0xDD: - if (length < 5) - goto error; - - return parse_array(buffer + 5, length - 5, object, - read_uint32(buffer + 1)) + 5; - /* Tables */ - case 0xDE: - if (length < 3) - goto error; - - return parse_table(buffer + 3, length - 3, object, - read_uint16(buffer + 1)) + 3; - case 0xDF: - if (length < 5) - goto error; - - return parse_table(buffer + 5, length - 5, object, - read_uint32(buffer + 1)) + 5; - } - -error: - *object = nil; - return 0; -} - -@implementation OFDataArray (BinaryPackValue) -- (id)binaryPackValue -{ - size_t count = [self count]; - id object; - - if (parse_object([self items], count, &object) != count || - object == nil) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; - - return object; -} -@end ADDED src/OFDataArray+MessagePackValue.h Index: src/OFDataArray+MessagePackValue.h ================================================================== --- src/OFDataArray+MessagePackValue.h +++ src/OFDataArray+MessagePackValue.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFDataArray.h" + +#ifdef __cplusplus +extern "C" { +#endif +extern int _OFDataArray_MessagePackValue_reference; +#ifdef __cplusplus +} +#endif + +@interface OFDataArray (MessagePackValue) +- (id)messagePackValue; +@end ADDED src/OFDataArray+MessagePackValue.m Index: src/OFDataArray+MessagePackValue.m ================================================================== --- src/OFDataArray+MessagePackValue.m +++ src/OFDataArray+MessagePackValue.m @@ -0,0 +1,409 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFDataArray+MessagePackValue.h" +#import "OFNumber.h" +#import "OFNull.h" +#import "OFDataArray.h" +#import "OFString.h" +#import "OFArray.h" +#import "OFDictionary.h" + +#import "OFInvalidFormatException.h" + +#import "autorelease.h" +#import "macros.h" + +int _OFDataArray_MessagePackValue_reference; + +static size_t parse_object(const uint8_t*, size_t, id*); + +static uint16_t +read_uint16(const uint8_t *buffer) +{ + return ((uint16_t)buffer[0] << 8) | buffer[1]; +} + +static uint32_t +read_uint32(const uint8_t *buffer) +{ + return ((uint32_t)buffer[0] << 24) | ((uint32_t)buffer[1] << 16) | + ((uint32_t)buffer[2] << 8) | buffer[3]; +} + +static uint64_t +read_uint64(const uint8_t *buffer) +{ + return ((uint64_t)buffer[0] << 56) | ((uint64_t)buffer[1] << 48) | + ((uint64_t)buffer[2] << 40) | ((uint64_t)buffer[3] << 32) | + ((uint64_t)buffer[4] << 24) | ((uint64_t)buffer[5] << 16) | + ((uint64_t)buffer[6] << 8) | buffer[7]; +} + +static size_t +parse_array(const uint8_t *buffer, size_t length, id *object, size_t count) +{ + void *pool; + size_t i, pos; + + /* + * Don't use capacity! For data and strings, this is safe, as we can + * check if we still have enough bytes left. For an array however, we + * can't know this, as every child can be more than one byte. + */ + *object = [OFMutableArray array]; + pos = 0; + + for (i = 0; i < count; i++) { + id child; + size_t childLength; + + pool = objc_autoreleasePoolPush(); + + childLength = parse_object(buffer + pos, length - pos, &child); + if (childLength == 0 || child == nil) { + objc_autoreleasePoolPop(pool); + + *object = nil; + return 0; + } + pos += childLength; + + [*object addObject: child]; + + objc_autoreleasePoolPop(pool); + } + + return pos; +} + +static size_t +parse_table(const uint8_t *buffer, size_t length, id *object, size_t count) +{ + void *pool; + size_t i, pos; + + /* + * Don't use capacity! For data and strings, this is safe, as we can + * check if we still have enough bytes left. For a dictionary however, + * we can't know this, as every key / value can be more than one byte. + */ + *object = [OFMutableDictionary dictionary]; + pos = 0; + + for (i = 0; i < count; i++) { + id key, value; + size_t keyLength, valueLength; + + pool = objc_autoreleasePoolPush(); + + keyLength = parse_object(buffer + pos, length - pos, &key); + if (keyLength == 0 || key == nil) { + objc_autoreleasePoolPop(pool); + + *object = nil; + return 0; + } + pos += keyLength; + + valueLength = parse_object(buffer + pos, length - pos, &value); + if (valueLength == 0 || value == nil) { + objc_autoreleasePoolPop(pool); + + *object = nil; + return 0; + } + pos += valueLength; + + [*object setObject: value + forKey: key]; + + objc_autoreleasePoolPop(pool); + } + + return pos; +} + +static size_t +parse_object(const uint8_t *buffer, size_t length, id *object) +{ + size_t i, count; + + if (length < 1) + goto error; + + /* positive fixint */ + if ((buffer[0] & 0x80) == 0) { + *object = [OFNumber numberWithUInt8: buffer[0] & 0x7F]; + return 1; + } + /* negative fixint */ + if ((buffer[0] & 0xE0) == 0xE0) { + *object = [OFNumber numberWithInt8: + ((int8_t)(buffer[0] & 0x1F)) - 32]; + return 1; + } + + /* fixstr */ + if ((buffer[0] & 0xE0) == 0xA0) { + count = buffer[0] & 0x1F; + + if (length < count + 1) + goto error; + + *object = [OFString + stringWithUTF8String: (const char*)buffer + 1 + length: count]; + return count + 1; + } + + /* fixarray */ + if ((buffer[0] & 0xF0) == 0x90) + return parse_array(buffer + 1, length - 1, object, + buffer[0] & 0xF) + 1; + + /* fixmap */ + if ((buffer[0] & 0xF0) == 0x80) + return parse_table(buffer + 1, length - 1, object, + buffer[0] & 0xF) + 1; + + /* Prefix byte */ + switch (*buffer) { + /* Unsigned integers */ + case 0xCC: /* uint8 */ + if (length < 2) + goto error; + + *object = [OFNumber numberWithUInt8: buffer[1]]; + return 2; + case 0xCD: /* uint 16 */ + if (length < 3) + goto error; + + *object = [OFNumber numberWithUInt16: read_uint16(buffer + 1)]; + return 3; + case 0xCE: /* uint 32 */ + if (length < 5) + goto error; + + *object = [OFNumber numberWithUInt32: read_uint32(buffer + 1)]; + return 5; + case 0xCF: /* uint 64 */ + if (length < 9) + goto error; + + *object = [OFNumber numberWithUInt64: read_uint64(buffer + 1)]; + return 9; + /* Signed integers */ + case 0xD0: /* int 8 */ + if (length < 2) + goto error; + + *object = [OFNumber numberWithInt8: buffer[1]]; + return 2; + case 0xD1: /* int 16 */ + if (length < 3) + goto error; + + *object = [OFNumber numberWithInt16: read_uint16(buffer + 1)]; + return 3; + case 0xD2: /* int 32 */ + if (length < 5) + goto error; + + *object = [OFNumber numberWithInt32: read_uint32(buffer + 1)]; + return 5; + case 0xD3: /* int 64 */ + if (length < 9) + goto error; + + *object = [OFNumber numberWithInt64: read_uint64(buffer + 1)]; + return 9; + /* Floating point */ + case 0xCA:; /* float 32 */ + union { + uint8_t u8[4]; + float f; + } f; + + if (length < 5) + goto error; + + for (i = 0; i < 4; i++) + f.u8[i] = buffer[i + 1]; + + *object = [OFNumber numberWithFloat: OF_BSWAP_FLOAT_IF_LE(f.f)]; + return 5; + case 0xCB:; /* float 64 */ + union { + uint8_t u8[8]; + double d; + } d; + + if (length < 9) + goto error; + + for (i = 0; i < 8; i++) + d.u8[i] = buffer[i + 1]; + + *object = [OFNumber numberWithDouble: + OF_BSWAP_DOUBLE_IF_LE(d.d)]; + return 9; + /* nil */ + case 0xC0: + *object = [OFNull null]; + return 1; + /* false */ + case 0xC2: + *object = [OFNumber numberWithBool: false]; + return 1; + /* true */ + case 0xC3: + *object = [OFNumber numberWithBool: true]; + return 1; + /* Data */ + case 0xC4: /* bin 8 */ + if (length < 2) + goto error; + + count = buffer[1]; + + if (length < count + 2) + goto error; + + *object = [OFDataArray dataArrayWithItemSize: 1 + capacity: count]; + [*object addItems: buffer + 2 + count: count]; + + return count + 2; + case 0xC5: /* bin 16 */ + if (length < 3) + goto error; + + count = read_uint16(buffer + 1); + + if (length < count + 3) + goto error; + + *object = [OFDataArray dataArrayWithItemSize: 1 + capacity: count]; + [*object addItems: buffer + 3 + count: count]; + + return count + 3; + case 0xC6: /* bin 32 */ + if (length < 5) + goto error; + + count = read_uint32(buffer + 1); + + if (length < count + 5) + goto error; + + *object = [OFDataArray dataArrayWithItemSize: 1 + capacity: count]; + [*object addItems: buffer + 5 + count: count]; + + return count + 5; + /* Strings */ + case 0xD9: /* str 8 */ + if (length < 2) + goto error; + + count = buffer[1]; + + if (length < count + 2) + goto error; + + *object = [OFString + stringWithUTF8String: (const char*)buffer + 2 + length: count]; + return count + 2; + case 0xDA: /* str 16 */ + if (length < 3) + goto error; + + count = read_uint16(buffer + 1); + + if (length < count + 3) + goto error; + + *object = [OFString + stringWithUTF8String: (const char*)buffer + 3 + length: count]; + return count + 3; + case 0xDB: /* str 32 */ + if (length < 5) + goto error; + + count = read_uint32(buffer + 1); + + if (length < count + 5) + goto error; + + *object = [OFString + stringWithUTF8String: (const char*)buffer + 5 + length: count]; + return count + 5; + /* Arrays */ + case 0xDC: /* array 16 */ + if (length < 3) + goto error; + + return parse_array(buffer + 3, length - 3, object, + read_uint16(buffer + 1)) + 3; + case 0xDD: /* array 32 */ + if (length < 5) + goto error; + + return parse_array(buffer + 5, length - 5, object, + read_uint32(buffer + 1)) + 5; + /* Maps */ + case 0xDE: /* map 16 */ + if (length < 3) + goto error; + + return parse_table(buffer + 3, length - 3, object, + read_uint16(buffer + 1)) + 3; + case 0xDF: /* map 32 */ + if (length < 5) + goto error; + + return parse_table(buffer + 5, length - 5, object, + read_uint32(buffer + 1)) + 5; + } + +error: + *object = nil; + return 0; +} + +@implementation OFDataArray (MessagePackValue) +- (id)messagePackValue +{ + size_t count = [self count]; + id object; + + if (parse_object([self items], count, &object) != count || + object == nil) + @throw [OFInvalidFormatException + exceptionWithClass: [self class]]; + + return object; +} +@end Index: src/OFDataArray.h ================================================================== --- src/OFDataArray.h +++ src/OFDataArray.h @@ -14,11 +14,11 @@ * file. */ #import "OFObject.h" #import "OFSerialization.h" -#import "OFBinaryPackRepresentation.h" +#import "OFMessagePackRepresentation.h" @class OFString; @class OFURL; /*! @@ -29,11 +29,11 @@ * * For security reasons, serialization and deserialization is only implemented * for OFDataArrays with item size 1. */ @interface OFDataArray: OFObject + OFMessagePackRepresentation> { uint8_t *_items; size_t _count, _itemSize, _capacity; } @@ -305,6 +305,6 @@ size_t _size; } @end #import "OFDataArray+Hashing.h" -#import "OFDataArray+BinaryPackValue.h" +#import "OFDataArray+MessagePackValue.h" Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -48,11 +48,11 @@ #import "macros.h" /* References for static linking */ void _references_to_categories_of_OFDataArray(void) { - _OFDataArray_BinaryPackValue_reference = 1; + _OFDataArray_MessagePackValue_reference = 1; _OFDataArray_Hashing_reference = 1; } @implementation OFDataArray + (instancetype)dataArray @@ -626,40 +626,40 @@ objc_autoreleasePoolPop(pool); return [element autorelease]; } -- (OFDataArray*)binaryPackRepresentation +- (OFDataArray*)messagePackRepresentation { OFDataArray *data; if (_itemSize != 1) @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; if (_count <= UINT8_MAX) { - uint8_t type = 0xD5; + uint8_t type = 0xC4; uint8_t tmp = (uint8_t)_count; data = [OFDataArray dataArrayWithItemSize: 1 capacity: _count + 2]; [data addItem: &type]; [data addItem: &tmp]; } else if (_count <= UINT16_MAX) { - uint8_t type = 0xD6; + uint8_t type = 0xC5; uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)_count); data = [OFDataArray dataArrayWithItemSize: 1 capacity: _count + 3]; [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else if (_count <= UINT32_MAX) { - uint8_t type = 0xD7; + uint8_t type = 0xC6; uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)_count); data = [OFDataArray dataArrayWithItemSize: 1 capacity: _count + 5]; Index: src/OFDictionary.h ================================================================== --- src/OFDictionary.h +++ src/OFDictionary.h @@ -26,11 +26,11 @@ #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" #import "OFSerialization.h" #import "OFJSONRepresentation.h" -#import "OFBinaryPackRepresentation.h" +#import "OFMessagePackRepresentation.h" @class OFArray; #ifdef OF_HAVE_BLOCKS typedef void (^of_dictionary_enumeration_block_t)(id key, id object, @@ -46,11 +46,11 @@ * * Note: Fast enumeration on a dictionary enumerates through the keys of the * dictionary. */ @interface OFDictionary: OFObject + OFSerialization, OFJSONRepresentation, OFMessagePackRepresentation> /*! * @brief Creates a new OFDictionary. * * @return A new autoreleased OFDictionary */ Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -644,11 +644,11 @@ objc_autoreleasePoolPop(pool); return JSON; } -- (OFDataArray*)binaryPackRepresentation +- (OFDataArray*)messagePackRepresentation { OFDataArray *data; size_t i, count; void *pool; OFEnumerator *keyEnumerator, *objectEnumerator; @@ -687,15 +687,15 @@ void *pool2 = objc_autoreleasePoolPush(); OFDataArray *child; i++; - child = [key binaryPackRepresentation]; + child = [key messagePackRepresentation]; [data addItems: [child items] count: [child count]]; - child = [object binaryPackRepresentation]; + child = [object messagePackRepresentation]; [data addItems: [child items] count: [child count]]; objc_autoreleasePoolPop(pool2); } ADDED src/OFMessagePackRepresentation.h Index: src/OFMessagePackRepresentation.h ================================================================== --- src/OFMessagePackRepresentation.h +++ src/OFMessagePackRepresentation.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +@class OFDataArray; + +/*! + * @brief A protocol implemented by classes that support encoding to a + * MessagePack representation. + */ +@protocol OFMessagePackRepresentation +/*! + * @brief Returns the MessagePack representation of the object as an + * OFDataArray. + * + * @return The MessagePack representation of the object as an OFDataArray. + */ +- (OFDataArray*)messagePackRepresentation; +@end Index: src/OFNull.h ================================================================== --- src/OFNull.h +++ src/OFNull.h @@ -15,19 +15,19 @@ */ #import "OFObject.h" #import "OFSerialization.h" #import "OFJSONRepresentation.h" -#import "OFBinaryPackRepresentation.h" +#import "OFMessagePackRepresentation.h" /*! * @brief A class for representing null values in collections. */ @interface OFNull: OFObject + OFMessagePackRepresentation> /*! * @brief Returns an OFNull singleton. * * @return An OFNull singleton */ + (OFNull*)null; @end Index: src/OFNull.m ================================================================== --- src/OFNull.m +++ src/OFNull.m @@ -87,11 +87,11 @@ - (OFString*)JSONRepresentation { return @"null"; } -- (OFDataArray*)binaryPackRepresentation +- (OFDataArray*)messagePackRepresentation { OFDataArray *data = [OFDataArray dataArrayWithItemSize: 1 capacity: 1]; uint8_t type = 0xC0; Index: src/OFNumber.h ================================================================== --- src/OFNumber.h +++ src/OFNumber.h @@ -24,11 +24,11 @@ #include #import "OFObject.h" #import "OFSerialization.h" #import "OFJSONRepresentation.h" -#import "OFBinaryPackRepresentation.h" +#import "OFMessagePackRepresentation.h" /*! @file */ /*! * @brief The C type of a number stored in an OFNumber. @@ -95,11 +95,11 @@ /*! * @brief Provides a way to store a number in an object. */ @interface OFNumber: OFObject + OFJSONRepresentation, OFMessagePackRepresentation> { union of_number_value { bool bool_; signed char schar; signed short sshort; Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -1427,11 +1427,11 @@ } return [self description]; } -- (OFDataArray*)binaryPackRepresentation +- (OFDataArray*)messagePackRepresentation { OFDataArray *data; if (_type == OF_NUMBER_BOOL) { uint8_t type; Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -25,11 +25,11 @@ #include #import "OFObject.h" #import "OFSerialization.h" #import "OFJSONRepresentation.h" -#import "OFBinaryPackRepresentation.h" +#import "OFMessagePackRepresentation.h" /*! @file */ @class OFConstantString; @@ -84,11 +84,11 @@ /*! * @brief A class for handling strings. */ @interface OFString: OFObject + OFSerialization, OFJSONRepresentation, OFMessagePackRepresentation> #ifdef OF_HAVE_PROPERTIES @property (readonly) size_t length; #endif /*! Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -1614,11 +1614,11 @@ [JSON makeImmutable]; return JSON; } -- (OFDataArray*)binaryPackRepresentation +- (OFDataArray*)messagePackRepresentation { OFDataArray *data; size_t length; length = [self UTF8StringLength];