ObjFW  Check-in [f59977a0aa]

Overview
Comment:JSON5: Update to new version of the spec.

This adds support for Infinity and leading + signs.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f59977a0aa204f8210ed7088a1f58cd6baa9fed8048a0ec7a2738f3a11306936
User & Date: js on 2013-01-28 21:12:57
Other Links: manifest | tags
Context
2013-01-28
22:40
OFHTTPServer: Fix missing #import. check-in: fe4a1fb193 user: js tags: trunk
21:12
JSON5: Update to new version of the spec. check-in: f59977a0aa user: js tags: trunk
20:55
OFHTTPClientTests: Fix a Clang 3.3 warning. check-in: 5ce6d067f1 user: js tags: trunk
Changes

Modified src/OFNumber.m from [35a9158982] to [35e3a3658c].

1387
1388
1389
1390
1391
1392
1393


1394
1395








1396
1397
1398
1399
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409







+
+


+
+
+
+
+
+
+
+




	objc_autoreleasePoolPop(pool);

	return [element autorelease];
}

- (OFString*)JSONRepresentation
{
	double doubleValue;

	if (type == OF_NUMBER_BOOL)
		return (value.bool_ ? @"true" : @"false");

	doubleValue = [self doubleValue];
	if (isinf(doubleValue)) {
		if (doubleValue > 0)
			return @"Infinity";
		else
			return @"-Infinity";
	}

	return [self description];
}
@end

Modified src/OFString+JSONValue.m from [c3668fbf8e] to [534d095364].

14
15
16
17
18
19
20


21
22
23
24
25
26
27
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







+
+







 * file.
 */

#include "config.h"

#include <stdlib.h>
#include <string.h>

#include <math.h>

#include <assert.h>

#import "OFString+JSONValue.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFNumber.h"
558
559
560
561
562
563
564




565
566
567
568
569
570
571
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577







+
+
+
+







	@try {
		if (hasDecimal)
			number = [OFNumber numberWithDouble:
			    [string doubleValue]];
		else if (isHex)
			number = [OFNumber numberWithIntMax:
			    [string hexadecimalValue]];
		else if ([string isEqual: @"Infinity"])
			number = [OFNumber numberWithDouble: INFINITY];
		else if ([string isEqual: @"-Infinity"])
			number = [OFNumber numberWithDouble: -INFINITY];
		else
			number = [OFNumber numberWithIntMax:
			    [string decimalValue]];
	} @finally {
		[string release];
	}

625
626
627
628
629
630
631

632
633

634
635
636
637
638
639
640
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648







+


+







	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case '+':
	case '-':
	case '.':
	case 'I':
		return parseNumber(pointer, stop, line);
	default:
		return nil;
	}
}

@implementation OFString (JSONValue)