ObjFW  Check-in [5b80a003bd]

Overview
Comment:Add -[OFCharacterSet invertedSet]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5b80a003bd8ee6e7d802eba1a5cdec793ba90f0782206b2f54295f4c001fbe34
User & Date: js on 2017-11-13 22:59:23
Other Links: manifest | tags
Context
2017-11-13
23:02
OFCharacterSet_*: Make init unavailable check-in: 36607ff68e user: js tags: trunk
22:59
Add -[OFCharacterSet invertedSet] check-in: 5b80a003bd user: js tags: trunk
22:26
OFLocalization: Fix type mismatch check-in: 209ea679c0 user: js tags: trunk
Changes

Modified ObjFW.xcodeproj/project.pbxproj from [0f8eb910da] to [6fc100fb0f].

1070
1071
1072
1073
1074
1075
1076




1077
1078
1079
1080
1081
1082
1083
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087







+
+
+
+







		4BF69CE61BD44F8B00DFFC1B /* platform.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF69CE51BD44F8B00DFFC1B /* platform.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BF8FE561F9A97E100CB9F9C /* OFException+Swift.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF8FE541F9A97E100CB9F9C /* OFException+Swift.m */; };
		4BF8FE571F9A97E100CB9F9C /* OFException+Swift.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BF8FE541F9A97E100CB9F9C /* OFException+Swift.m */; };
		4BF8FE581F9A97E100CB9F9C /* OFException+Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF8FE551F9A97E100CB9F9C /* OFException+Swift.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BF8FE591F9A97E100CB9F9C /* OFException+Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF8FE551F9A97E100CB9F9C /* OFException+Swift.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BFC37BD1E50E11C00EE1269 /* common.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BFC37BC1E50E11C00EE1269 /* common.h */; };
		4BFC37BE1E50E11C00EE1269 /* common.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BFC37BC1E50E11C00EE1269 /* common.h */; };
		4BFD0B9A1FBA59CB009895D7 /* OFCharacterSet_invertedSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BFD0B981FBA59CB009895D7 /* OFCharacterSet_invertedSet.h */; };
		4BFD0B9B1FBA59CB009895D7 /* OFCharacterSet_invertedSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BFD0B981FBA59CB009895D7 /* OFCharacterSet_invertedSet.h */; };
		4BFD0B9C1FBA59CB009895D7 /* OFCharacterSet_invertedSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BFD0B991FBA59CB009895D7 /* OFCharacterSet_invertedSet.m */; };
		4BFD0B9D1FBA59CB009895D7 /* OFCharacterSet_invertedSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BFD0B991FBA59CB009895D7 /* OFCharacterSet_invertedSet.m */; };
		4BFF3714177E17C100192782 /* OFRemoveItemFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BFF3710177E17C100192782 /* OFRemoveItemFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BFF3715177E17C100192782 /* OFRemoveItemFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BFF3711177E17C100192782 /* OFRemoveItemFailedException.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
		4B23CA8E133811B20047A1D9 /* PBXContainerItemProxy */ = {
			isa = PBXContainerItemProxy;
1781
1782
1783
1784
1785
1786
1787


1788
1789
1790
1791
1792
1793
1794
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800







+
+







		4BF3A2281E25EA48002EA46F /* windows-1251.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "windows-1251.m"; path = "src/encodings/windows-1251.m"; sourceTree = "<group>"; };
		4BF5CB8F1E2DC1D800CF7584 /* iso_8859-2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "iso_8859-2.m"; path = "src/encodings/iso_8859-2.m"; sourceTree = "<group>"; };
		4BF69CE51BD44F8B00DFFC1B /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = platform.h; path = src/platform.h; sourceTree = "<group>"; };
		4BF8FE541F9A97E100CB9F9C /* OFException+Swift.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFException+Swift.m"; path = "src/bridge/OFException+Swift.m"; sourceTree = "<group>"; };
		4BF8FE551F9A97E100CB9F9C /* OFException+Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFException+Swift.h"; path = "src/bridge/OFException+Swift.h"; sourceTree = "<group>"; };
		4BFBDD1610A0724800051AFB /* unicode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = unicode.m; path = src/unicode.m; sourceTree = "<group>"; };
		4BFC37BC1E50E11C00EE1269 /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = common.h; path = src/encodings/common.h; sourceTree = "<group>"; };
		4BFD0B981FBA59CB009895D7 /* OFCharacterSet_invertedSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFCharacterSet_invertedSet.h; path = src/OFCharacterSet_invertedSet.h; sourceTree = "<group>"; };
		4BFD0B991FBA59CB009895D7 /* OFCharacterSet_invertedSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFCharacterSet_invertedSet.m; path = src/OFCharacterSet_invertedSet.m; sourceTree = "<group>"; };
		4BFF3710177E17C100192782 /* OFRemoveItemFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFRemoveItemFailedException.h; path = src/exceptions/OFRemoveItemFailedException.h; sourceTree = "<group>"; };
		4BFF3711177E17C100192782 /* OFRemoveItemFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFRemoveItemFailedException.m; path = src/exceptions/OFRemoveItemFailedException.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
		4B0E29761DA2A8A400323A76 /* Frameworks */ = {
			isa = PBXFrameworksBuildPhase;
2147
2148
2149
2150
2151
2152
2153


2154
2155
2156
2157
2158
2159
2160
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168







+
+







				4B1473CA17E6391900B46BB8 /* OFAutoreleasePool+Private.h */,
				4BD86D801237A6C600ED9912 /* OFBlock.h */,
				4BD86D811237A6C600ED9912 /* OFBlock.m */,
				4BB99CD91FAEC9DA00CC79A9 /* OFCharacterSet.h */,
				4BB99CD61FAEC9D900CC79A9 /* OFCharacterSet.m */,
				4BB99CD71FAEC9D900CC79A9 /* OFCharacterSet_bitset.h */,
				4BB99CD81FAEC9DA00CC79A9 /* OFCharacterSet_bitset.m */,
				4BFD0B981FBA59CB009895D7 /* OFCharacterSet_invertedSet.h */,
				4BFD0B991FBA59CB009895D7 /* OFCharacterSet_invertedSet.m */,
				4BB99CE21FAF542000CC79A9 /* OFCharacterSet_range.h */,
				4BB99CE31FAF542000CC79A9 /* OFCharacterSet_range.m */,
				4BAF5F46123460C900F4E111 /* OFCollection.h */,
				4B6743F7163C395900EB1E59 /* OFCondition.h */,
				4B6743F8163C395900EB1E59 /* OFCondition.m */,
				4BE5F0D712DF4225005C7A0C /* OFConstantString.h */,
				4BE5F0D812DF4225005C7A0C /* OFConstantString.m */,
2784
2785
2786
2787
2788
2789
2790

2791
2792
2793
2794
2795
2796
2797
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806







+







				4B2C228D1DA292BE00735907 /* OFWriteFailedException.h in Headers */,
				4B2C22A91DA292BE00735907 /* config.h in Headers */,
				4B2C228E1DA292BE00735907 /* OFArray_adjacent.h in Headers */,
				4B2C228F1DA292BE00735907 /* OFArray_adjacentSubarray.h in Headers */,
				4B2C21D91DA292BE00735907 /* OFArray_subarray.h in Headers */,
				4B2C22901DA292BE00735907 /* OFAutoreleasePool+Private.h in Headers */,
				4BB99CDD1FAEC9DA00CC79A9 /* OFCharacterSet_bitset.h in Headers */,
				4BFD0B9B1FBA59CB009895D7 /* OFCharacterSet_invertedSet.h in Headers */,
				4BB99CE51FAF542000CC79A9 /* OFCharacterSet_range.h in Headers */,
				4B2C22911DA292BE00735907 /* OFCountedSet_hashtable.h in Headers */,
				4B1223171F23E6C100D9F8FF /* OFData+Private.h in Headers */,
				4B2C22921DA292BE00735907 /* OFDictionary_hashtable.h in Headers */,
				4B2C22931DA292BE00735907 /* OFINICategory+Private.h in Headers */,
				4B2C22941DA292BE00735907 /* OFKernelEventObserver+Private.h in Headers */,
				4B2C22951DA292BE00735907 /* OFKernelEventObserver_kqueue.h in Headers */,
3022
3023
3024
3025
3026
3027
3028

3029
3030
3031
3032
3033
3034
3035
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045







+







				4B55A116133AC24600B58A93 /* OFWriteFailedException.h in Headers */,
				4BDF37B51338055600F9A81A /* config.h in Headers */,
				4B2B3E7D140D430500EC2F7C /* OFArray_adjacent.h in Headers */,
				4B9BB7BD141CDE2D000AD1CC /* OFArray_adjacentSubarray.h in Headers */,
				4B9BB7BF141CDE2D000AD1CC /* OFArray_subarray.h in Headers */,
				4B1473CB17E6391900B46BB8 /* OFAutoreleasePool+Private.h in Headers */,
				4BB99CDC1FAEC9DA00CC79A9 /* OFCharacterSet_bitset.h in Headers */,
				4BFD0B9A1FBA59CB009895D7 /* OFCharacterSet_invertedSet.h in Headers */,
				4BB99CE41FAF542000CC79A9 /* OFCharacterSet_range.h in Headers */,
				4BA85BCA140ECCE800E91D51 /* OFCountedSet_hashtable.h in Headers */,
				4B1223141F23E6C000D9F8FF /* OFData+Private.h in Headers */,
				4B2B3E7F140D430500EC2F7C /* OFDictionary_hashtable.h in Headers */,
				4B06855518B2AD3800FC731A /* OFINICategory+Private.h in Headers */,
				4B0EA9231898690E00F573A4 /* OFKernelEventObserver+Private.h in Headers */,
				4B0EA91B1898690E00F573A4 /* OFKernelEventObserver_kqueue.h in Headers */,
3389
3390
3391
3392
3393
3394
3395

3396
3397
3398
3399
3400
3401
3402
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413







+







				4B2C21211DA292BE00735907 /* OFArray_adjacent.m in Sources */,
				4B2C21221DA292BE00735907 /* OFArray_adjacentSubarray.m in Sources */,
				4B2C21231DA292BE00735907 /* OFArray_subarray.m in Sources */,
				4B2C21241DA292BE00735907 /* OFAutoreleasePool.m in Sources */,
				4B2C21261DA292BE00735907 /* OFBlock.m in Sources */,
				4BB99CDB1FAEC9DA00CC79A9 /* OFCharacterSet.m in Sources */,
				4BB99CDF1FAEC9DA00CC79A9 /* OFCharacterSet_bitset.m in Sources */,
				4BFD0B9D1FBA59CB009895D7 /* OFCharacterSet_invertedSet.m in Sources */,
				4BB99CE71FAF542000CC79A9 /* OFCharacterSet_range.m in Sources */,
				4B2C21271DA292BE00735907 /* OFCondition.m in Sources */,
				4B2C21281DA292BE00735907 /* OFConstantString.m in Sources */,
				4B2C21291DA292BE00735907 /* OFCountedSet.m in Sources */,
				4B2C212A1DA292BE00735907 /* OFCountedSet_hashtable.m in Sources */,
				4B2C212B1DA292BE00735907 /* OFData.m in Sources */,
				4B2C212C1DA292BE00735907 /* OFData+CryptoHashing.m in Sources */,
3601
3602
3603
3604
3605
3606
3607

3608
3609
3610
3611
3612
3613
3614
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626







+







				4B2B3E7E140D430500EC2F7C /* OFArray_adjacent.m in Sources */,
				4B9BB7BE141CDE2D000AD1CC /* OFArray_adjacentSubarray.m in Sources */,
				4B9BB7C0141CDE2D000AD1CC /* OFArray_subarray.m in Sources */,
				4B3D238D1337FC0D00DD29B8 /* OFAutoreleasePool.m in Sources */,
				4B3D238E1337FC0D00DD29B8 /* OFBlock.m in Sources */,
				4BB99CDA1FAEC9DA00CC79A9 /* OFCharacterSet.m in Sources */,
				4BB99CDE1FAEC9DA00CC79A9 /* OFCharacterSet_bitset.m in Sources */,
				4BFD0B9C1FBA59CB009895D7 /* OFCharacterSet_invertedSet.m in Sources */,
				4BB99CE61FAF542000CC79A9 /* OFCharacterSet_range.m in Sources */,
				4B674401163C395900EB1E59 /* OFCondition.m in Sources */,
				4B3D238F1337FC0D00DD29B8 /* OFConstantString.m in Sources */,
				4B45355413DCFE1E0037AB4D /* OFCountedSet.m in Sources */,
				4BA85BCB140ECCE800E91D51 /* OFCountedSet_hashtable.m in Sources */,
				4B3D23901337FC0D00DD29B8 /* OFData.m in Sources */,
				4B3D23911337FC0D00DD29B8 /* OFData+CryptoHashing.m in Sources */,

Modified src/Makefile from [e79ddbdefe] to [8aff73e1a1].

157
158
159
160
161
162
163

164
165
166
167
168
169
170
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171







+







	    platform.h				\
	    ${USE_INCLUDES_ATOMIC}

SRCS += OFArray_adjacent.m		\
	OFArray_adjacentSubarray.m	\
	OFArray_subarray.m		\
	OFCharacterSet_bitset.m		\
	OFCharacterSet_invertedSet.m	\
	OFCharacterSet_range.m		\
	OFCountedSet_hashtable.m	\
	OFDictionary_hashtable.m	\
	OFMutableArray_adjacent.m	\
	OFMutableDictionary_hashtable.m	\
	OFMutableSet_hashtable.m	\
	OFMutableString_UTF8.m		\

Modified src/OFCharacterSet.h from [b4e9d14055] to [3a3c180f05].

21
22
23
24
25
26
27






28
29
30
31
32
33
34
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40







+
+
+
+
+
+








/*!
 * @class OFCharacterSet OFCharacterSet.h ObjFW/OFCharacterSet.h
 *
 * @brief A class cluster representing a character set.
 */
@interface OFCharacterSet: OFObject
/*!
 * The inverted set, containing only the characters that do not exist in the
 * receiver.
 */
@property (readonly, nonatomic) OFCharacterSet *invertedSet;

/*!
 * @brief Creates a new character set containing the characters of the
 *	  specified string.
 *
 * @param characters The characters for the character set
 * @return A new OFCharacterSet
 */

Modified src/OFCharacterSet.m from [21dcb32047] to [c44f9cacb6].

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







+







 * file.
 */

#include "config.h"

#import "OFCharacterSet.h"
#import "OFCharacterSet_bitset.h"
#import "OFCharacterSet_invertedSet.h"
#import "OFCharacterSet_range.h"

static struct {
	Class isa;
} placeholder;

@interface OFCharacterSet_placeholder: OFCharacterSet
118
119
120
121
122
123
124






125
119
120
121
122
123
124
125
126
127
128
129
130
131
132







+
+
+
+
+
+

	OF_INVALID_INIT_METHOD
}

- (bool)characterIsMember: (of_unichar_t)character
{
	OF_UNRECOGNIZED_SELECTOR
}

- (OFCharacterSet *)invertedSet
{
	return [[[OFCharacterSet_invertedSet alloc]
	    of_initWithCharacterSet: self] autorelease];
}
@end

Added src/OFCharacterSet_invertedSet.h version [57d2318733].
































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
 *   Jonathan Schleifer <js@heap.zone>
 *
 * 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 "OFCharacterSet.h"

OF_ASSUME_NONNULL_BEGIN

@interface OFCharacterSet_invertedSet: OFCharacterSet
{
	OFCharacterSet *_characterSet;
	bool (*_characterIsMember)(id, SEL, of_unichar_t);
}

- (instancetype)of_initWithCharacterSet: (OFCharacterSet *)characterSet
    OF_METHOD_FAMILY(init);
@end

OF_ASSUME_NONNULL_END

Added src/OFCharacterSet_invertedSet.m version [66795d1b29].






















































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, 2013, 2014, 2015, 2016, 2017
 *   Jonathan Schleifer <js@heap.zone>
 *
 * 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 "OFCharacterSet_invertedSet.h"
#import "OFString.h"

#import "OFOutOfRangeException.h"

@implementation OFCharacterSet_invertedSet
- (instancetype)of_initWithCharacterSet: (OFCharacterSet *)characterSet
{
	self = [super init];

	_characterSet = [characterSet retain];
	_characterIsMember = (bool (*)(id, SEL, of_unichar_t))
	    [_characterSet methodForSelector: @selector(characterIsMember:)];

	return self;
}

- (void)dealloc
{
	[_characterSet release];

	[super dealloc];
}

- (bool)characterIsMember: (of_unichar_t)character
{
	return !_characterIsMember(_characterSet, @selector(characterIsMember:),
	    character);
}

- (OFCharacterSet *)invertedSet
{
	return [[_characterSet retain] autorelease];
}
@end

Modified tests/OFCharacterSetTests.m from [d40eda3b19] to [ca87024db1].

35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
35
36
37
38
39
40
41

42
43
44
45
46
47
48
49







-
+







}
@end

@implementation TestsAppDelegate (OFCharacterSetTests)
- (void)characterSetTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFCharacterSet *cs;
	OFCharacterSet *cs, *ics;
	bool ok;

	module = @"OFCharacterSet";

	cs = [[[SimpleCharacterSet alloc] init] autorelease];

	ok = true;
85
86
87
88
89
90
91














92
93
94
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108







+
+
+
+
+
+
+
+
+
+
+
+
+
+



			if (![cs characterIsMember: c])
				ok = false;
		} else if ([cs characterIsMember: c])
			ok = false;
	}
	TEST(@"-[characterIsMember:]", ok);

	ok = true;
	ics = [cs invertedSet];
	for (of_unichar_t c = 0; c < 65536; c++) {
		if (c >= '0' && c <= '9') {
			if ([ics characterIsMember: c])
				ok = false;
		} else if (![ics characterIsMember: c])
			ok = false;
	}
	TEST(@"-[invertedSet]", ok);

	TEST(@"Inverting -[invertedSet] returns original set",
	    [ics invertedSet] == cs)

	[pool drain];
}
@end