ObjFW  Check-in [72c71c4eb2]

Overview
Comment:JSON: Make it possible to get the invalid line.

This introduces OFInvalidJSONException, which has a property line to get
the line in which the parsing error occurred.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 72c71c4eb2ec4099808d296c0f625086507a1ee7d0e8b327b4b435c10ff56278
User & Date: js on 2012-06-10 16:07:33
Other Links: manifest | tags
Context
2012-06-11
11:08
Improve -[OFNumber description]. check-in: 0db281bf03 user: js tags: trunk
2012-06-10
16:07
JSON: Make it possible to get the invalid line. check-in: 72c71c4eb2 user: js tags: trunk
16:03
Add a few array methods. check-in: 95e8e1e486 user: js tags: trunk
Changes

Modified ObjFW.xcodeproj/project.pbxproj from [0481245247] to [f8de28e17c].

296
297
298
299
300
301
302


303
304
305
306
307
308
309
		4BB25E89139C388A00F574EA /* OFObject+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB25E83139C388A00F574EA /* OFObject+Serialization.m */; };
		4BB25E8A139C388A00F574EA /* OFString+Serialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB25E84139C388A00F574EA /* OFString+Serialization.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BB25E8B139C388A00F574EA /* OFString+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB25E85139C388A00F574EA /* OFString+Serialization.m */; };
		4BB25E8C139C388A00F574EA /* OFXMLElement+Serialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB25E86139C388A00F574EA /* OFXMLElement+Serialization.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BB25E8D139C388A00F574EA /* OFXMLElement+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB25E87139C388A00F574EA /* OFXMLElement+Serialization.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, ); }; };


		4BD653C5143B8489006182F0 /* OFTCPSocket+SOCKS5.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD653C3143B8489006182F0 /* OFTCPSocket+SOCKS5.h */; };
		4BD653C6143B8489006182F0 /* OFTCPSocket+SOCKS5.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */; };
		4BD98C03133814220048DD5B /* objfw-defs.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD98C011338140B0048DD5B /* objfw-defs.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BDF37B51338055600F9A81A /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDF37B41338055600F9A81A /* config.h */; };
		4BF33AFB133807590059CEF7 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B3D23761337FBC800DD29B8 /* ObjFW.framework */; };
		4BF33AFC133807A20059CEF7 /* OFArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF66E1235358D0076B512 /* OFArrayTests.m */; };
		4BF33AFD133807A20059CEF7 /* OFBlockTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0E412DF4259005C7A0C /* OFBlockTests.m */; };







>
>







296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
		4BB25E89139C388A00F574EA /* OFObject+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB25E83139C388A00F574EA /* OFObject+Serialization.m */; };
		4BB25E8A139C388A00F574EA /* OFString+Serialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB25E84139C388A00F574EA /* OFString+Serialization.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BB25E8B139C388A00F574EA /* OFString+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB25E85139C388A00F574EA /* OFString+Serialization.m */; };
		4BB25E8C139C388A00F574EA /* OFXMLElement+Serialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB25E86139C388A00F574EA /* OFXMLElement+Serialization.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BB25E8D139C388A00F574EA /* OFXMLElement+Serialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB25E87139C388A00F574EA /* OFXMLElement+Serialization.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, ); }; };
		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 */; };
		4BD653C6143B8489006182F0 /* OFTCPSocket+SOCKS5.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */; };
		4BD98C03133814220048DD5B /* objfw-defs.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD98C011338140B0048DD5B /* objfw-defs.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BDF37B51338055600F9A81A /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDF37B41338055600F9A81A /* config.h */; };
		4BF33AFB133807590059CEF7 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B3D23761337FBC800DD29B8 /* ObjFW.framework */; };
		4BF33AFC133807A20059CEF7 /* OFArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF66E1235358D0076B512 /* OFArrayTests.m */; };
		4BF33AFD133807A20059CEF7 /* OFBlockTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0E412DF4259005C7A0C /* OFBlockTests.m */; };
659
660
661
662
663
664
665


666
667
668
669
670
671
672
		4BB25E87139C388A00F574EA /* OFXMLElement+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFXMLElement+Serialization.m"; path = "src/OFXMLElement+Serialization.m"; sourceTree = "<group>"; };
		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 = "<group>"; };
		4BB524C0143D1E4E0085FBCC /* OFProcess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFProcess.m; path = src/OFProcess.m; sourceTree = "<group>"; };
		4BBA36C411406AB700CBA3AC /* atomic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atomic.h; path = src/atomic.h; sourceTree = "<group>"; };
		4BBA36C511406AB700CBA3AC /* macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = macros.h; path = src/macros.h; sourceTree = "<group>"; };


		4BD653C3143B8489006182F0 /* OFTCPSocket+SOCKS5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFTCPSocket+SOCKS5.h"; path = "src/OFTCPSocket+SOCKS5.h"; sourceTree = "<group>"; };
		4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFTCPSocket+SOCKS5.m"; path = "src/OFTCPSocket+SOCKS5.m"; sourceTree = "<group>"; };
		4BD86D801237A6C600ED9912 /* OFBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBlock.h; path = src/OFBlock.h; sourceTree = SOURCE_ROOT; };
		4BD86D811237A6C600ED9912 /* OFBlock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBlock.m; path = src/OFBlock.m; sourceTree = SOURCE_ROOT; };
		4BD98C011338140B0048DD5B /* objfw-defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "objfw-defs.h"; path = "src/objfw-defs.h"; sourceTree = SOURCE_ROOT; };
		4BDF37B41338055600F9A81A /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = SOURCE_ROOT; };
		4BE17AD812FD744C002CEB0B /* foundation-compat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "foundation-compat.m"; path = "src/foundation-compat.m"; sourceTree = SOURCE_ROOT; };







>
>







661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
		4BB25E87139C388A00F574EA /* OFXMLElement+Serialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFXMLElement+Serialization.m"; path = "src/OFXMLElement+Serialization.m"; sourceTree = "<group>"; };
		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 = "<group>"; };
		4BB524C0143D1E4E0085FBCC /* OFProcess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFProcess.m; path = src/OFProcess.m; sourceTree = "<group>"; };
		4BBA36C411406AB700CBA3AC /* atomic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atomic.h; path = src/atomic.h; sourceTree = "<group>"; };
		4BBA36C511406AB700CBA3AC /* macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = macros.h; path = src/macros.h; sourceTree = "<group>"; };
		4BC090421584F6760040640F /* OFInvalidJSONException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFInvalidJSONException.h; path = src/exceptions/OFInvalidJSONException.h; sourceTree = "<group>"; };
		4BC090431584F6760040640F /* OFInvalidJSONException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFInvalidJSONException.m; path = src/exceptions/OFInvalidJSONException.m; sourceTree = "<group>"; };
		4BD653C3143B8489006182F0 /* OFTCPSocket+SOCKS5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFTCPSocket+SOCKS5.h"; path = "src/OFTCPSocket+SOCKS5.h"; sourceTree = "<group>"; };
		4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFTCPSocket+SOCKS5.m"; path = "src/OFTCPSocket+SOCKS5.m"; sourceTree = "<group>"; };
		4BD86D801237A6C600ED9912 /* OFBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBlock.h; path = src/OFBlock.h; sourceTree = SOURCE_ROOT; };
		4BD86D811237A6C600ED9912 /* OFBlock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBlock.m; path = src/OFBlock.m; sourceTree = SOURCE_ROOT; };
		4BD98C011338140B0048DD5B /* objfw-defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "objfw-defs.h"; path = "src/objfw-defs.h"; sourceTree = SOURCE_ROOT; };
		4BDF37B41338055600F9A81A /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = SOURCE_ROOT; };
		4BE17AD812FD744C002CEB0B /* foundation-compat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "foundation-compat.m"; path = "src/foundation-compat.m"; sourceTree = SOURCE_ROOT; };
790
791
792
793
794
795
796


797
798
799
800
801
802
803
				4B17FFA4133A340D003E6DCD /* OFInitializationFailedException.m */,
				4B17FF91133A317A003E6DCD /* OFInvalidArgumentException.h */,
				4B17FF92133A317B003E6DCD /* OFInvalidArgumentException.m */,
				4B17FF97133A3242003E6DCD /* OFInvalidEncodingException.h */,
				4B17FF98133A3243003E6DCD /* OFInvalidEncodingException.m */,
				4B17FF9B133A32B7003E6DCD /* OFInvalidFormatException.h */,
				4B17FF9C133A32B8003E6DCD /* OFInvalidFormatException.m */,


				4B17FFB7133A380F003E6DCD /* OFInvalidServerReplyException.h */,
				4B17FFB8133A3813003E6DCD /* OFInvalidServerReplyException.m */,
				4B29BC5D133AC9C40004B236 /* OFLinkFailedException.h */,
				4B29BC5E133AC9C40004B236 /* OFLinkFailedException.m */,
				4B90B79C133AD87D00BD33CB /* OFListenFailedException.h */,
				4B90B79D133AD87D00BD33CB /* OFListenFailedException.m */,
				4B17FF9F133A3331003E6DCD /* OFMalformedXMLException.h */,







>
>







794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
				4B17FFA4133A340D003E6DCD /* OFInitializationFailedException.m */,
				4B17FF91133A317A003E6DCD /* OFInvalidArgumentException.h */,
				4B17FF92133A317B003E6DCD /* OFInvalidArgumentException.m */,
				4B17FF97133A3242003E6DCD /* OFInvalidEncodingException.h */,
				4B17FF98133A3243003E6DCD /* OFInvalidEncodingException.m */,
				4B17FF9B133A32B7003E6DCD /* OFInvalidFormatException.h */,
				4B17FF9C133A32B8003E6DCD /* OFInvalidFormatException.m */,
				4BC090421584F6760040640F /* OFInvalidJSONException.h */,
				4BC090431584F6760040640F /* OFInvalidJSONException.m */,
				4B17FFB7133A380F003E6DCD /* OFInvalidServerReplyException.h */,
				4B17FFB8133A3813003E6DCD /* OFInvalidServerReplyException.m */,
				4B29BC5D133AC9C40004B236 /* OFLinkFailedException.h */,
				4B29BC5E133AC9C40004B236 /* OFLinkFailedException.m */,
				4B90B79C133AD87D00BD33CB /* OFListenFailedException.h */,
				4B90B79D133AD87D00BD33CB /* OFListenFailedException.m */,
				4B17FF9F133A3331003E6DCD /* OFMalformedXMLException.h */,
1227
1228
1229
1230
1231
1232
1233

1234
1235
1236
1237
1238
1239
1240
				4B17FF87133A2E7B003E6DCD /* OFEnumerationMutationException.h in Headers */,
				4B8B16FE133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.h in Headers */,
				4B17FFAD133A3591003E6DCD /* OFHTTPRequestFailedException.h in Headers */,
				4B17FFA5133A3411003E6DCD /* OFInitializationFailedException.h in Headers */,
				4B17FF93133A317C003E6DCD /* OFInvalidArgumentException.h in Headers */,
				4B17FF99133A3245003E6DCD /* OFInvalidEncodingException.h in Headers */,
				4B17FF9D133A32BA003E6DCD /* OFInvalidFormatException.h in Headers */,

				4B17FFB9133A381D003E6DCD /* OFInvalidServerReplyException.h in Headers */,
				4B29BC61133AC9CB0004B236 /* OFLinkFailedException.h in Headers */,
				4B90B7A6133AD87D00BD33CB /* OFListenFailedException.h in Headers */,
				4B17FFA1133A3335003E6DCD /* OFMalformedXMLException.h in Headers */,
				4B17FF8F133A3036003E6DCD /* OFMemoryNotPartOfObjectException.h in Headers */,
				4B8B1719133A3D04007CD8B3 /* OFMutexLockFailedException.h in Headers */,
				4B7FF3B0133CE6DE00000324 /* OFMutexStillLockedException.h in Headers */,







>







1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
				4B17FF87133A2E7B003E6DCD /* OFEnumerationMutationException.h in Headers */,
				4B8B16FE133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.h in Headers */,
				4B17FFAD133A3591003E6DCD /* OFHTTPRequestFailedException.h in Headers */,
				4B17FFA5133A3411003E6DCD /* OFInitializationFailedException.h in Headers */,
				4B17FF93133A317C003E6DCD /* OFInvalidArgumentException.h in Headers */,
				4B17FF99133A3245003E6DCD /* OFInvalidEncodingException.h in Headers */,
				4B17FF9D133A32BA003E6DCD /* OFInvalidFormatException.h in Headers */,
				4BC090441584F6760040640F /* OFInvalidJSONException.h in Headers */,
				4B17FFB9133A381D003E6DCD /* OFInvalidServerReplyException.h in Headers */,
				4B29BC61133AC9CB0004B236 /* OFLinkFailedException.h in Headers */,
				4B90B7A6133AD87D00BD33CB /* OFListenFailedException.h in Headers */,
				4B17FFA1133A3335003E6DCD /* OFMalformedXMLException.h in Headers */,
				4B17FF8F133A3036003E6DCD /* OFMemoryNotPartOfObjectException.h in Headers */,
				4B8B1719133A3D04007CD8B3 /* OFMutexLockFailedException.h in Headers */,
				4B7FF3B0133CE6DE00000324 /* OFMutexStillLockedException.h in Headers */,
1520
1521
1522
1523
1524
1525
1526

1527
1528
1529
1530
1531
1532
1533
				4B17FF73133A2A76003E6DCD /* OFException.m in Sources */,
				4B8B16FF133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.m in Sources */,
				4B17FFAE133A3591003E6DCD /* OFHTTPRequestFailedException.m in Sources */,
				4B17FFA6133A3411003E6DCD /* OFInitializationFailedException.m in Sources */,
				4B17FF94133A317C003E6DCD /* OFInvalidArgumentException.m in Sources */,
				4B17FF9A133A3245003E6DCD /* OFInvalidEncodingException.m in Sources */,
				4B17FF9E133A32BA003E6DCD /* OFInvalidFormatException.m in Sources */,

				4B17FFBA133A381D003E6DCD /* OFInvalidServerReplyException.m in Sources */,
				4B29BC62133AC9CB0004B236 /* OFLinkFailedException.m in Sources */,
				4B90B7A7133AD87D00BD33CB /* OFListenFailedException.m in Sources */,
				4B17FFA2133A3335003E6DCD /* OFMalformedXMLException.m in Sources */,
				4B17FF90133A3036003E6DCD /* OFMemoryNotPartOfObjectException.m in Sources */,
				4B8B171A133A3D04007CD8B3 /* OFMutexLockFailedException.m in Sources */,
				4B7FF3B1133CE6DE00000324 /* OFMutexStillLockedException.m in Sources */,







>







1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
				4B17FF73133A2A76003E6DCD /* OFException.m in Sources */,
				4B8B16FF133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.m in Sources */,
				4B17FFAE133A3591003E6DCD /* OFHTTPRequestFailedException.m in Sources */,
				4B17FFA6133A3411003E6DCD /* OFInitializationFailedException.m in Sources */,
				4B17FF94133A317C003E6DCD /* OFInvalidArgumentException.m in Sources */,
				4B17FF9A133A3245003E6DCD /* OFInvalidEncodingException.m in Sources */,
				4B17FF9E133A32BA003E6DCD /* OFInvalidFormatException.m in Sources */,
				4BC090451584F6760040640F /* OFInvalidJSONException.m in Sources */,
				4B17FFBA133A381D003E6DCD /* OFInvalidServerReplyException.m in Sources */,
				4B29BC62133AC9CB0004B236 /* OFLinkFailedException.m in Sources */,
				4B90B7A7133AD87D00BD33CB /* OFListenFailedException.m in Sources */,
				4B17FFA2133A3335003E6DCD /* OFMalformedXMLException.m in Sources */,
				4B17FF90133A3036003E6DCD /* OFMemoryNotPartOfObjectException.m in Sources */,
				4B8B171A133A3D04007CD8B3 /* OFMutexLockFailedException.m in Sources */,
				4B7FF3B1133CE6DE00000324 /* OFMutexStillLockedException.m in Sources */,

Modified src/OFString+JSONValue.m from [06182df9e0] to [291a080964].

23
24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39

40
41
42



43

44
45
46
47

48
49
50
51
52
53
54

#import "OFString+JSONValue.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFNull.h"

#import "OFInvalidEncodingException.h"

#import "macros.h"

int _OFString_JSONValue_reference;

static id nextObject(const char *restrict *, const char*);


static void
skipWhitespaces(const char *restrict *pointer, const char *stop)

{
	while (*pointer < stop && (**pointer == ' ' || **pointer == '\t' ||
	    **pointer == '\r' || **pointer == '\n'))



		(*pointer)++;

}

static void
skipComment(const char *restrict *pointer, const char *stop)

{
	if (**pointer != '/')
		return;

	if (*pointer + 1 >= stop)
		return;








|





|
>


|
>


|
>
>
>

>



|
>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

#import "OFString+JSONValue.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFNull.h"

#import "OFInvalidJSONException.h"

#import "macros.h"

int _OFString_JSONValue_reference;

static id nextObject(const char *restrict *, const char*,
    size_t *restrict line);

static void
skipWhitespaces(const char *restrict *pointer, const char *stop,
    size_t *restrict line)
{
	while (*pointer < stop && (**pointer == ' ' || **pointer == '\t' ||
	    **pointer == '\r' || **pointer == '\n')) {
		if (**pointer == '\n')
			(*line)++;

		(*pointer)++;
	}
}

static void
skipComment(const char *restrict *pointer, const char *stop,
    size_t *restrict line)
{
	if (**pointer != '/')
		return;

	if (*pointer + 1 >= stop)
		return;

62
63
64
65
66
67
68



69
70
71
72
73
74
75
76
77

78
79
80
81
82
83

84
85
86
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
		while (*pointer < stop) {
			if (lastIsAsterisk && **pointer == '/') {
				(*pointer)++;
				return;
			}

			lastIsAsterisk = (**pointer == '*');




			(*pointer)++;
		}
	} else {
		(*pointer)++;

		while (*pointer < stop) {
			if (**pointer == '\r' || **pointer == '\n') {
				(*pointer)++;

				return;
			}

			(*pointer)++;
		}
	}

}

static void
skipWhitespacesAndComments(const char *restrict *pointer, const char *stop)

{
	const char *old = NULL;

	while (old != *pointer) {
		old = *pointer;

		skipWhitespaces(pointer, stop);
		skipComment(pointer, stop);
	}
}

static inline uint16_t
parseUnicodeEscape(const char *pointer, const char *stop)
{
	uint16_t ret = 0;







>
>
>



|





>





|
>



|
>






|
|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
		while (*pointer < stop) {
			if (lastIsAsterisk && **pointer == '/') {
				(*pointer)++;
				return;
			}

			lastIsAsterisk = (**pointer == '*');

			if (**pointer == '\n')
				(*line)++;

			(*pointer)++;
		}
	} else if (**pointer == '/') {
		(*pointer)++;

		while (*pointer < stop) {
			if (**pointer == '\r' || **pointer == '\n') {
				(*pointer)++;
				(*line)++;
				return;
			}

			(*pointer)++;
		}
	} else
		(*pointer)--;
}

static void
skipWhitespacesAndComments(const char *restrict *pointer, const char *stop,
    size_t *restrict line)
{
	const char *old = NULL;

	while (old != *pointer) {
		old = *pointer;

		skipWhitespaces(pointer, stop, line);
		skipComment(pointer, stop, line);
	}
}

static inline uint16_t
parseUnicodeEscape(const char *pointer, const char *stop)
{
	uint16_t ret = 0;
122
123
124
125
126
127
128
129

130
131
132
133
134
135
136
			return 0xFFFF;
	}

	return ret;
}

static inline OFString*
parseString(const char *restrict *pointer, const char *stop)

{
	char *buffer;
	size_t i = 0;
	char delimiter = **pointer;

	if (++(*pointer) + 1 >= stop)
		return nil;







|
>







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
			return 0xFFFF;
	}

	return ret;
}

static inline OFString*
parseString(const char *restrict *pointer, const char *stop,
    size_t *restrict line)
{
	char *buffer;
	size_t i = 0;
	char delimiter = **pointer;

	if (++(*pointer) + 1 >= stop)
		return nil;
229
230
231
232
233
234
235
236
237


238
239
240
241

242
243
244
245
246
247
248
				i += l;
				*pointer += 11;

				break;
			case '\r':
				(*pointer)++;

				if (*pointer < stop && **pointer == '\n')
					(*pointer)++;



				break;
			case '\n':
				(*pointer)++;

				break;
			default:
				free(buffer);
				return nil;
			}
		/* End of string found */
		} else if (**pointer == delimiter) {







|

>
>




>







243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
				i += l;
				*pointer += 11;

				break;
			case '\r':
				(*pointer)++;

				if (*pointer < stop && **pointer == '\n') {
					(*pointer)++;
					(*line)++;
				}

				break;
			case '\n':
				(*pointer)++;
				(*line)++;
				break;
			default:
				free(buffer);
				return nil;
			}
		/* End of string found */
		} else if (**pointer == delimiter) {
256
257
258
259
260
261
262

263
264
265
266
267
268
269
			}

			(*pointer)++;

			return ret;
		/* Newlines in strings are disallowed */
		} else if (**pointer == '\n' || **pointer == '\r') {

			free(buffer);
			return nil;
		} else {
			buffer[i++] = **pointer;
			(*pointer)++;
		}
	}







>







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
			}

			(*pointer)++;

			return ret;
		/* Newlines in strings are disallowed */
		} else if (**pointer == '\n' || **pointer == '\r') {
			(*line)++;
			free(buffer);
			return nil;
		} else {
			buffer[i++] = **pointer;
			(*pointer)++;
		}
	}
369
370
371
372
373
374
375
376

377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428

429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501

502
503
504
505
506
507
508
509
510
511
512
513
514
515
516



517

518
519
520
521
522
523
524
	 * It is never possible to end with an identifier, thus we should never
	 * reach stop.
	 */
	return nil;
}

static inline OFMutableArray*
parseArray(const char *restrict *pointer, const char *stop)

{
	OFMutableArray *array = [OFMutableArray array];

	if (++(*pointer) >= stop)
		return nil;

	while (**pointer != ']') {
		id object;

		skipWhitespacesAndComments(pointer, stop);
		if (*pointer >= stop)
			return nil;

		if (**pointer == ']')
			break;

		if (**pointer == ',') {
			(*pointer)++;
			skipWhitespacesAndComments(pointer, stop);

			if (*pointer >= stop || **pointer != ']')
				return nil;

			break;
		}

		if ((object = nextObject(pointer, stop)) == nil)
			return nil;

		[array addObject: object];

		skipWhitespacesAndComments(pointer, stop);
		if (*pointer >= stop)
			return nil;

		if (**pointer == ',') {
			(*pointer)++;
			skipWhitespacesAndComments(pointer, stop);

			if (*pointer >= stop)
				return nil;
		} else if (**pointer != ']')
			return nil;
	}

	(*pointer)++;

	return array;
}

static inline OFMutableDictionary*
parseDictionary(const char *restrict *pointer, const char *stop)

{
	OFMutableDictionary *dictionary = [OFMutableDictionary dictionary];

	if (++(*pointer) >= stop)
		return nil;

	while (**pointer != '}') {
		id key, object;

		skipWhitespacesAndComments(pointer, stop);
		if (*pointer >= stop)
			return nil;

		if (**pointer == '}')
			break;

		if (**pointer == ',') {
			(*pointer)++;
			skipWhitespacesAndComments(pointer, stop);

			if (*pointer >= stop || **pointer != '}')
				return nil;

			break;
		}

		skipWhitespacesAndComments(pointer, stop);
		if (*pointer + 1 >= stop)
			return nil;

		if ((**pointer >= 'a' && **pointer <= 'z') ||
		    (**pointer >= 'A' && **pointer <= 'Z') ||
		    **pointer == '_' || **pointer == '$' || **pointer == '\\')
			key = parseIdentifier(pointer, stop);
		else
			key = nextObject(pointer, stop);

		if (key == nil)
			return nil;

		skipWhitespacesAndComments(pointer, stop);
		if (*pointer + 1 >= stop || **pointer != ':')
			return nil;

		(*pointer)++;

		if ((object = nextObject(pointer, stop)) == nil)
			return nil;

		[dictionary setObject: object
			       forKey: key];

		skipWhitespacesAndComments(pointer, stop);
		if (*pointer >= stop)
			return nil;

		if (**pointer == ',') {
			(*pointer)++;
			skipWhitespacesAndComments(pointer, stop);

			if (*pointer >= stop)
				return nil;
		} else if (**pointer != '}')
			return nil;
	}

	(*pointer)++;

	return dictionary;
}

static inline OFNumber*
parseNumber(const char *restrict *pointer, const char *stop)

{
	BOOL isHex = (*pointer + 1 < stop && (*pointer)[1] == 'x');
	BOOL hasDecimal = NO;
	size_t i;
	OFString *string;
	OFNumber *number;

	for (i = 0; *pointer + i < stop; i++) {
		if ((*pointer)[i] == '.')
			hasDecimal = YES;

		if ((*pointer)[i] == ' ' || (*pointer)[i] == '\t' ||
		    (*pointer)[i] == '\r' || (*pointer)[i] == '\n' ||
		    (*pointer)[i] == ',' || (*pointer)[i] == ']' ||
		    (*pointer)[i] == '}')



			break;

	}

	string = [[OFString alloc] initWithUTF8String: *pointer
					       length: i];
	*pointer += i;

	@try {







|
>









|








|







|




|





|













|
>









|








|







|








|




|





|





|





|













|
>














|
>
>
>

>







387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
	 * It is never possible to end with an identifier, thus we should never
	 * reach stop.
	 */
	return nil;
}

static inline OFMutableArray*
parseArray(const char *restrict *pointer, const char *stop,
    size_t *restrict line)
{
	OFMutableArray *array = [OFMutableArray array];

	if (++(*pointer) >= stop)
		return nil;

	while (**pointer != ']') {
		id object;

		skipWhitespacesAndComments(pointer, stop, line);
		if (*pointer >= stop)
			return nil;

		if (**pointer == ']')
			break;

		if (**pointer == ',') {
			(*pointer)++;
			skipWhitespacesAndComments(pointer, stop, line);

			if (*pointer >= stop || **pointer != ']')
				return nil;

			break;
		}

		if ((object = nextObject(pointer, stop, line)) == nil)
			return nil;

		[array addObject: object];

		skipWhitespacesAndComments(pointer, stop, line);
		if (*pointer >= stop)
			return nil;

		if (**pointer == ',') {
			(*pointer)++;
			skipWhitespacesAndComments(pointer, stop, line);

			if (*pointer >= stop)
				return nil;
		} else if (**pointer != ']')
			return nil;
	}

	(*pointer)++;

	return array;
}

static inline OFMutableDictionary*
parseDictionary(const char *restrict *pointer, const char *stop,
    size_t *restrict line)
{
	OFMutableDictionary *dictionary = [OFMutableDictionary dictionary];

	if (++(*pointer) >= stop)
		return nil;

	while (**pointer != '}') {
		id key, object;

		skipWhitespacesAndComments(pointer, stop, line);
		if (*pointer >= stop)
			return nil;

		if (**pointer == '}')
			break;

		if (**pointer == ',') {
			(*pointer)++;
			skipWhitespacesAndComments(pointer, stop, line);

			if (*pointer >= stop || **pointer != '}')
				return nil;

			break;
		}

		skipWhitespacesAndComments(pointer, stop, line);
		if (*pointer + 1 >= stop)
			return nil;

		if ((**pointer >= 'a' && **pointer <= 'z') ||
		    (**pointer >= 'A' && **pointer <= 'Z') ||
		    **pointer == '_' || **pointer == '$' || **pointer == '\\')
			key = parseIdentifier(pointer, stop);
		else
			key = nextObject(pointer, stop, line);

		if (key == nil)
			return nil;

		skipWhitespacesAndComments(pointer, stop, line);
		if (*pointer + 1 >= stop || **pointer != ':')
			return nil;

		(*pointer)++;

		if ((object = nextObject(pointer, stop, line)) == nil)
			return nil;

		[dictionary setObject: object
			       forKey: key];

		skipWhitespacesAndComments(pointer, stop, line);
		if (*pointer >= stop)
			return nil;

		if (**pointer == ',') {
			(*pointer)++;
			skipWhitespacesAndComments(pointer, stop, line);

			if (*pointer >= stop)
				return nil;
		} else if (**pointer != '}')
			return nil;
	}

	(*pointer)++;

	return dictionary;
}

static inline OFNumber*
parseNumber(const char *restrict *pointer, const char *stop,
    size_t *restrict line)
{
	BOOL isHex = (*pointer + 1 < stop && (*pointer)[1] == 'x');
	BOOL hasDecimal = NO;
	size_t i;
	OFString *string;
	OFNumber *number;

	for (i = 0; *pointer + i < stop; i++) {
		if ((*pointer)[i] == '.')
			hasDecimal = YES;

		if ((*pointer)[i] == ' ' || (*pointer)[i] == '\t' ||
		    (*pointer)[i] == '\r' || (*pointer)[i] == '\n' ||
		    (*pointer)[i] == ',' || (*pointer)[i] == ']' ||
		    (*pointer)[i] == '}') {
			if ((*pointer)[i] == '\n')
				(*line)++;

			break;
		}
	}

	string = [[OFString alloc] initWithUTF8String: *pointer
					       length: i];
	*pointer += i;

	@try {
535
536
537
538
539
540
541
542

543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
		[string release];
	}

	return number;
}

static id
nextObject(const char *restrict *pointer, const char *stop)

{
	skipWhitespacesAndComments(pointer, stop);

	if (*pointer >= stop)
		return nil;

	switch (**pointer) {
	case '"':
	case '\'':
		return parseString(pointer, stop);
	case '[':
		return parseArray(pointer, stop);
	case '{':
		return parseDictionary(pointer, stop);
	case 't':
		if (*pointer + 3 >= stop)
			return nil;

		if (memcmp(*pointer, "true", 4))
			return nil;








|
>

|







|

|

|







560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
		[string release];
	}

	return number;
}

static id
nextObject(const char *restrict *pointer, const char *stop,
    size_t *restrict line)
{
	skipWhitespacesAndComments(pointer, stop, line);

	if (*pointer >= stop)
		return nil;

	switch (**pointer) {
	case '"':
	case '\'':
		return parseString(pointer, stop, line);
	case '[':
		return parseArray(pointer, stop, line);
	case '{':
		return parseDictionary(pointer, stop, line);
	case 't':
		if (*pointer + 3 >= stop)
			return nil;

		if (memcmp(*pointer, "true", 4))
			return nil;

592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610

611
612
613
614
615
616

617
618
619
620
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case '-':
	case '.':
		return parseNumber(pointer, stop);
	default:
		return nil;
	}
}

@implementation OFString (JSONValue)
- (id)JSONValue
{
	const char *pointer = [self UTF8String];
	const char *stop = pointer + [self UTF8StringLength];
	id object;


	object = nextObject(&pointer, stop);
	skipWhitespacesAndComments(&pointer, stop);

	if (pointer < stop || object == nil)
		@throw [OFInvalidEncodingException exceptionWithClass: isa];


	return object;
}
@end







|











>

|
|


|
>




618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case '-':
	case '.':
		return parseNumber(pointer, stop, line);
	default:
		return nil;
	}
}

@implementation OFString (JSONValue)
- (id)JSONValue
{
	const char *pointer = [self UTF8String];
	const char *stop = pointer + [self UTF8StringLength];
	id object;
	size_t line = 1;

	object = nextObject(&pointer, stop, &line);
	skipWhitespacesAndComments(&pointer, stop, &line);

	if (pointer < stop || object == nil)
		@throw [OFInvalidJSONException exceptionWithClass: isa
							     line: line];

	return object;
}
@end

Modified src/ObjFW.h from [951501aebd] to [d4c97a2a17].

91
92
93
94
95
96
97

98
99
100
101
102
103
104
#import "OFEnumerationMutationException.h"
#import "OFHashAlreadyCalculatedException.h"
#import "OFHTTPRequestFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"

#import "OFInvalidServerReplyException.h"
#import "OFLinkFailedException.h"
#import "OFListenFailedException.h"
#import "OFMalformedXMLException.h"
#import "OFMemoryNotPartOfObjectException.h"
#import "OFMutexLockFailedException.h"
#import "OFMutexStillLockedException.h"







>







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#import "OFEnumerationMutationException.h"
#import "OFHashAlreadyCalculatedException.h"
#import "OFHTTPRequestFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFInvalidJSONException.h"
#import "OFInvalidServerReplyException.h"
#import "OFLinkFailedException.h"
#import "OFListenFailedException.h"
#import "OFMalformedXMLException.h"
#import "OFMemoryNotPartOfObjectException.h"
#import "OFMutexLockFailedException.h"
#import "OFMutexStillLockedException.h"

Modified src/exceptions/Makefile from [f45b67542a] to [5ef5063419].

24
25
26
27
28
29
30

31
32
33
34
35
36
37
       OFException.m				\
       OFHTTPRequestFailedException.m		\
       OFHashAlreadyCalculatedException.m	\
       OFInitializationFailedException.m	\
       OFInvalidArgumentException.m		\
       OFInvalidEncodingException.m		\
       OFInvalidFormatException.m		\

       OFInvalidServerReplyException.m		\
       OFLinkFailedException.m			\
       OFListenFailedException.m		\
       OFMalformedXMLException.m		\
       OFMemoryNotPartOfObjectException.m	\
       OFMutexLockFailedException.m		\
       OFMutexStillLockedException.m		\







>







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
       OFException.m				\
       OFHTTPRequestFailedException.m		\
       OFHashAlreadyCalculatedException.m	\
       OFInitializationFailedException.m	\
       OFInvalidArgumentException.m		\
       OFInvalidEncodingException.m		\
       OFInvalidFormatException.m		\
       OFInvalidJSONException.m			\
       OFInvalidServerReplyException.m		\
       OFLinkFailedException.m			\
       OFListenFailedException.m		\
       OFMalformedXMLException.m		\
       OFMemoryNotPartOfObjectException.m	\
       OFMutexLockFailedException.m		\
       OFMutexStillLockedException.m		\

Added src/exceptions/OFInvalidJSONException.h version [28abef2a60].











































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * 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 "OFException.h"

/**
 * \brief An exception indicating a JSON representation is invalid.
 */
@interface OFInvalidJSONException: OFException
{
	size_t line;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) size_t line;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param line The line in which the parsing error encountered
 * \return A new invalid JSON exception
 */
+ exceptionWithClass: (Class)class_
		line: (size_t)line;

/**
 * Initializes an already allocated invalid JSON exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param line The line in which the parsing error encountered
 * \return An initialized invalid JSON exception
 */
- initWithClass: (Class)class_
	   line: (size_t)line;

/**
 * \return The line in which parsing the JSON representation failed
 */
- (size_t)line;
@end

Added src/exceptions/OFInvalidJSONException.m version [cae65c6e83].





































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * 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.
 */

#include "config.h"

#import "OFInvalidJSONException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

@implementation OFInvalidJSONException
+ exceptionWithClass: (Class)class_
		line: (size_t)line
{
	return [[[self alloc] initWithClass: class_
				       line: line] autorelease];
}

- initWithClass: (Class)class_
	   line: (size_t)line_
{
	self = [super initWithClass: class_];

	line = line_;

	return self;
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"The JSON representation class %@ tried to parse is invalid in "
	    @"line %zd!", inClass, line];

	return description;
}

- (size_t)line
{
	return line;
}
@end

Modified tests/OFJSONTests.m from [ae9d04304d] to [c4b49139b1].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFNull.h"
#import "OFAutoreleasePool.h"

#import "OFInvalidEncodingException.h"

#import "TestsAppDelegate.h"

static OFString *module = @"OFJSON";

@implementation TestsAppDelegate (JSONTests)
- (void)JSONTests







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFNull.h"
#import "OFAutoreleasePool.h"

#import "OFInvalidJSONException.h"

#import "TestsAppDelegate.h"

static OFString *module = @"OFJSON";

@implementation TestsAppDelegate (JSONTests)
- (void)JSONTests
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
	    nil];

	TEST(@"-[JSONValue #1]", [[s JSONValue] isEqual: d])

	TEST(@"-[JSONRepresentation]", [[d JSONRepresentation] isEqual:
	    @"{\"foo\":\"ba\\r\",\"x\":[0.5,15,null,\"foo\",false]}"])

	EXPECT_EXCEPTION(@"-[JSONValue #2]", OFInvalidEncodingException,
	    [@"{" JSONValue])
	EXPECT_EXCEPTION(@"-[JSONValue #3]", OFInvalidEncodingException,
	    [@"]" JSONValue])
	EXPECT_EXCEPTION(@"-[JSONValue #4]", OFInvalidEncodingException,
	    [@"bar" JSONValue])
	EXPECT_EXCEPTION(@"-[JSONValue #5]", OFInvalidEncodingException,
	    [@"[\"a\" \"b\"]" JSONValue])

	[pool drain];
}
@end







|

|

|

|





47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
	    nil];

	TEST(@"-[JSONValue #1]", [[s JSONValue] isEqual: d])

	TEST(@"-[JSONRepresentation]", [[d JSONRepresentation] isEqual:
	    @"{\"foo\":\"ba\\r\",\"x\":[0.5,15,null,\"foo\",false]}"])

	EXPECT_EXCEPTION(@"-[JSONValue #2]", OFInvalidJSONException,
	    [@"{" JSONValue])
	EXPECT_EXCEPTION(@"-[JSONValue #3]", OFInvalidJSONException,
	    [@"]" JSONValue])
	EXPECT_EXCEPTION(@"-[JSONValue #4]", OFInvalidJSONException,
	    [@"bar" JSONValue])
	EXPECT_EXCEPTION(@"-[JSONValue #5]", OFInvalidJSONException,
	    [@"[\"a\" \"b\"]" JSONValue])

	[pool drain];
}
@end