Added .gitignore version [e6b723e3e1].
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
*.a
*.bundle
*.dll
*.dylib
*.o
*.orig
*.so
*~
.deps
aclocal.m4
autom4te.cache
build
buildsys.mk
config.h
config.h.in
config.log
config.status
configure
DerivedData
docs
extra.mk
generators/gen_tables
generators/gen_tables.exe
generators/CaseFolding.txt
generators/UnicodeData.txt
Info.plist
ObjFW.xcodeproj/*.mode1v3
ObjFW.xcodeproj/*.pbxuser
ObjFW.xcodeproj/project.xcworkspace
ObjFW.xcodeproj/xcuserdata
src/objfw-defs.h
src/ObjFW
tests/tests
tests/tests.exe
tests/EBOOT.PBP
tests/PARAM.SFO
utils/objfw-config
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Deleted .hgignore version [41e0bfc125].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
syntax: glob
*.a
*.dll
*.dylib
*.impl
*.o
*.orig
*.so
*~
.deps
aclocal.m4
autom4te.cache
build
buildsys.mk
config.h
config.h.in
config.log
config.status
configure
DerivedData
docs
extra.mk
generators/gen_tables
generators/gen_tables.exe
generators/CaseFolding.txt
generators/UnicodeData.txt
objfw-config
ObjFW.xcodeproj/*.mode1v3
ObjFW.xcodeproj/*.pbxuser
ObjFW.xcodeproj/project.xcworkspace
ObjFW.xcodeproj/xcuserdata
src/objfw-defs.h
src/ObjFW
tests/tests
tests/tests.exe
tests/EBOOT.PBP
tests/PARAM.SFO
|
Modified ChangeLog
from [33d26b0e3e]
to [92fa197ba9].
︙ | | |
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
-
+
|
* The blocks runtime is now working correctly.
* Documentation fixes.
* -framework works with objfw-compile now.
+ Support for QNX.
* Various small fixes.
ObjFW 0.5.2 -> ObjFW 0.5.3, 01.07.2011
* Lots of bugfixes, see Mercurial log for details. (hg log -b 0.5)
* Lots of bugfixes, see Git log for details.
ObjFW 0.5.1 -> ObjFW 0.5.2, 25.04.2011
* Fix double-retain in OFList.
* Don't ignore the timeout in OFStreamObserver when using select().
* Do -[OFURL copy] in a try block to prevent a leak when an exception occurs.
* Fix too big buffer in -[OFMutableString _applyTable:withSize:].
* Call madvise() on the correct length variable so it covers the whole string.
|
︙ | | |
Deleted Info.plist version [f1d4c55aab].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>ObjFW</string>
<key>CFBundleName</key>
<string>ObjFW</string>
<key>CFBundleIdentifier</key>
<string>org.webkeks.objfw</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>OBJFW</string>
<key>CFBundleVersion</key>
<string>0.7-dev</string>
<key>CFBundleShortVersionString</key>
<string>0.7-dev</string>
</dict>
</plist>
|
Added Info.plist.in version [a131e6786c].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>ObjFW</string>
<key>CFBundleName</key>
<string>ObjFW</string>
<key>CFBundleIdentifier</key>
<string>org.webkeks.objfw</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>OBJFW</string>
<key>CFBundleVersion</key>
<string>@PACKAGE_VERSION@</string>
<key>CFBundleShortVersionString</key>
<string>@PACKAGE_VERSION@</string>
</dict>
</plist>
|
| | | | | | | | | | | | | | | | | | | | |
Modified Makefile
from [8a97a82e19]
to [2c18cb613e].
︙ | | |
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
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
|
config.log \
config.status \
extra.mk
include buildsys.mk
tarball:
V=$$(fgrep VERSION= utils/objfw-config.in | \
sed 's/VERSION="\(.*\)"/\1/'); \
V2=$$(fgrep AC_INIT configure.ac | \
sed 's/AC_INIT([^,]*,\([^,]*\),.*/\1/' | sed 's/ //'); \
V3=$$(fgrep -A1 CFBundleVersion Info.plist | tail -1 | \
sed 's/.*>\(.*\)<.*/\1/'); \
V4=$$(fgrep -A1 CFBundleShortVersion Info.plist | tail -1 | \
sed 's/.*>\(.*\)<.*/\1/'); \
if test x"$$V2" != x"$$V" \
-o x"$$V3" != x"$$V" \
-o x"$$V4" != x"$$V4"; then \
echo "Not all files have the same version number!"; \
echo "Files: util/objfw-config.in configure.ac Info.plist"; \
exit 1; \
fi; \
echo "Generating tarball for version $$V..."; \
rm -f objfw-$$V.tar.gz; \
rm -fr objfw-$$V; \
hg archive objfw-$$V; \
cp configure config.h.in objfw-$$V; \
cd objfw-$$V && rm -f .hg_archival.txt .hgignore .hgtags && cd ..; \
tar cf objfw-$$V.tar objfw-$$V; \
gzip -9 objfw-$$V.tar; \
rm -fr objfw-$$V
echo "Generating tarball for version ${PACKAGE_VERSION}..."
rm -fr tmp.tar objfw-${PACKAGE_VERSION} objfw-${PACKAGE_VERSION}.tar \
objfw-${PACKAGE_VERSION}.tar.gz
git archive HEAD --prefix objfw-${PACKAGE_VERSION}/ -o tmp.tar
tar xf tmp.tar
rm -f tmp.tar objfw-${PACKAGE_VERSION}/.gitignore
cp configure config.h.in objfw-${PACKAGE_VERSION}/
tar cf objfw-${PACKAGE_VERSION}.tar objfw-${PACKAGE_VERSION}
rm -fr objfw-${PACKAGE_VERSION}
gzip -9 objfw-${PACKAGE_VERSION}.tar
rm -f objfw-${PACKAGE_VERSION}.tar
|
Modified ObjFW.xcodeproj/project.pbxproj
from [b030246336]
to [3d876805a7].
︙ | | |
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
+
+
|
4B90B7A1133AD87D00BD33CB /* OFAddressTranslationFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B797133AD87D00BD33CB /* OFAddressTranslationFailedException.m */; };
4B90B7A2133AD87D00BD33CB /* OFBindFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B798133AD87D00BD33CB /* OFBindFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B90B7A3133AD87D00BD33CB /* OFBindFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B799133AD87D00BD33CB /* OFBindFailedException.m */; };
4B90B7A4133AD87D00BD33CB /* OFConnectionFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B79A133AD87D00BD33CB /* OFConnectionFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B90B7A5133AD87D00BD33CB /* OFConnectionFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B79B133AD87D00BD33CB /* OFConnectionFailedException.m */; };
4B90B7A6133AD87D00BD33CB /* OFListenFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B79C133AD87D00BD33CB /* OFListenFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B90B7A7133AD87D00BD33CB /* OFListenFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B79D133AD87D00BD33CB /* OFListenFailedException.m */; };
4B9361A81511000C00DCD16B /* OFThreadPool.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B9361A61511000C00DCD16B /* OFThreadPool.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B9361A91511000C00DCD16B /* OFThreadPool.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B9361A71511000C00DCD16B /* OFThreadPool.m */; };
4B989C2F13771A3700109A30 /* OFSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B989C2E13771A3700109A30 /* OFSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B9BB7BD141CDE2D000AD1CC /* OFArray_adjacentSubarray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B9BB7B9141CDE2D000AD1CC /* OFArray_adjacentSubarray.h */; };
4B9BB7BE141CDE2D000AD1CC /* OFArray_adjacentSubarray.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B9BB7BA141CDE2D000AD1CC /* OFArray_adjacentSubarray.m */; };
4B9BB7BF141CDE2D000AD1CC /* OFArray_subarray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B9BB7BB141CDE2D000AD1CC /* OFArray_subarray.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B9BB7C0141CDE2D000AD1CC /* OFArray_subarray.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B9BB7BC141CDE2D000AD1CC /* OFArray_subarray.m */; };
4BA02BA115041F5900002F84 /* OFJSONRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BA02B9F15041F5900002F84 /* OFJSONRepresentation.h */; settings = {ATTRIBUTES = (Public, ); }; };
4BA02BA215041F5900002F84 /* OFTLSSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BA02BA015041F5900002F84 /* OFTLSSocket.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
︙ | | |
615
616
617
618
619
620
621
622
623
624
625
626
627
628
|
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
|
+
+
|
4B90B797133AD87D00BD33CB /* OFAddressTranslationFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFAddressTranslationFailedException.m; path = src/exceptions/OFAddressTranslationFailedException.m; sourceTree = "<group>"; };
4B90B798133AD87D00BD33CB /* OFBindFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBindFailedException.h; path = src/exceptions/OFBindFailedException.h; sourceTree = "<group>"; };
4B90B799133AD87D00BD33CB /* OFBindFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBindFailedException.m; path = src/exceptions/OFBindFailedException.m; sourceTree = "<group>"; };
4B90B79A133AD87D00BD33CB /* OFConnectionFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConnectionFailedException.h; path = src/exceptions/OFConnectionFailedException.h; sourceTree = "<group>"; };
4B90B79B133AD87D00BD33CB /* OFConnectionFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConnectionFailedException.m; path = src/exceptions/OFConnectionFailedException.m; sourceTree = "<group>"; };
4B90B79C133AD87D00BD33CB /* OFListenFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFListenFailedException.h; path = src/exceptions/OFListenFailedException.h; sourceTree = "<group>"; };
4B90B79D133AD87D00BD33CB /* OFListenFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFListenFailedException.m; path = src/exceptions/OFListenFailedException.m; sourceTree = "<group>"; };
4B9361A61511000C00DCD16B /* OFThreadPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFThreadPool.h; path = src/OFThreadPool.h; sourceTree = "<group>"; };
4B9361A71511000C00DCD16B /* OFThreadPool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFThreadPool.m; path = src/OFThreadPool.m; sourceTree = "<group>"; };
4B981CDE116F71DD00294DB7 /* OFSeekableStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFSeekableStream.h; path = src/OFSeekableStream.h; sourceTree = "<group>"; };
4B981CDF116F71DD00294DB7 /* OFSeekableStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSeekableStream.m; path = src/OFSeekableStream.m; sourceTree = "<group>"; };
4B989C2E13771A3700109A30 /* OFSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFSerialization.h; path = src/OFSerialization.h; sourceTree = "<group>"; };
4B99250F12E0780000215DBE /* OFHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFHTTPRequest.h; path = src/OFHTTPRequest.h; sourceTree = "<group>"; };
4B99251012E0780000215DBE /* OFHTTPRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFHTTPRequest.m; path = src/OFHTTPRequest.m; sourceTree = "<group>"; };
4B9BB7B9141CDE2D000AD1CC /* OFArray_adjacentSubarray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFArray_adjacentSubarray.h; path = src/OFArray_adjacentSubarray.h; sourceTree = "<group>"; };
4B9BB7BA141CDE2D000AD1CC /* OFArray_adjacentSubarray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFArray_adjacentSubarray.m; path = src/OFArray_adjacentSubarray.m; sourceTree = "<group>"; };
|
︙ | | |
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
|
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
|
+
+
|
4B552551147AA5DB0003BF47 /* OFString_UTF8.m */,
4B6799811099E7C50041064A /* OFTCPSocket.h */,
4B6799821099E7C50041064A /* OFTCPSocket.m */,
4BD653C3143B8489006182F0 /* OFTCPSocket+SOCKS5.h */,
4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */,
4B6799831099E7C50041064A /* OFThread.h */,
4B6799841099E7C50041064A /* OFThread.m */,
4B9361A61511000C00DCD16B /* OFThreadPool.h */,
4B9361A71511000C00DCD16B /* OFThreadPool.m */,
4BA02BA015041F5900002F84 /* OFTLSSocket.h */,
4B4A61F212DF5EA20048F3F2 /* OFURL.h */,
4B4A61F312DF5EA20048F3F2 /* OFURL.m */,
4BF1BCCE11C9663F0025511F /* OFXMLAttribute.h */,
4BF1BCCF11C9663F0025511F /* OFXMLAttribute.m */,
4B49EA67143B3A090005BBC6 /* OFXMLCDATA.h */,
4B49EA68143B3A090005BBC6 /* OFXMLCDATA.m */,
|
︙ | | |
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
|
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
|
+
|
4B5CF8F914940BD2007AA324 /* OFString+JSONValue.h in Headers */,
4BB25E8A139C388A00F574EA /* OFString+Serialization.h in Headers */,
4B3D23DA1337FCB000DD29B8 /* OFString+URLEncoding.h in Headers */,
4B3D23DB1337FCB000DD29B8 /* OFString+XMLEscaping.h in Headers */,
4B3D23DC1337FCB000DD29B8 /* OFString+XMLUnescaping.h in Headers */,
4B3D23DD1337FCB000DD29B8 /* OFTCPSocket.h in Headers */,
4B3D23DE1337FCB000DD29B8 /* OFThread.h in Headers */,
4B9361A81511000C00DCD16B /* OFThreadPool.h in Headers */,
4BA02BA215041F5900002F84 /* OFTLSSocket.h in Headers */,
4B3D23DF1337FCB000DD29B8 /* OFURL.h in Headers */,
4B3D23E01337FCB000DD29B8 /* OFXMLAttribute.h in Headers */,
4B49EA6D143B3A090005BBC6 /* OFXMLCDATA.h in Headers */,
4B49EA6F143B3A090005BBC6 /* OFXMLCharacters.h in Headers */,
4B49EA71143B3A090005BBC6 /* OFXMLComment.h in Headers */,
4B3D23E11337FCB000DD29B8 /* OFXMLElement.h in Headers */,
|
︙ | | |
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
|
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
|
+
|
4B3D23A81337FC0D00DD29B8 /* OFString+URLEncoding.m in Sources */,
4B3D23A91337FC0D00DD29B8 /* OFString+XMLEscaping.m in Sources */,
4B3D23AA1337FC0D00DD29B8 /* OFString+XMLUnescaping.m in Sources */,
4B552555147AA5DB0003BF47 /* OFString_UTF8.m in Sources */,
4B3D23AB1337FC0D00DD29B8 /* OFTCPSocket.m in Sources */,
4BD653C6143B8489006182F0 /* OFTCPSocket+SOCKS5.m in Sources */,
4B3D23AC1337FC0D00DD29B8 /* OFThread.m in Sources */,
4B9361A91511000C00DCD16B /* OFThreadPool.m in Sources */,
4B3D23AD1337FC0D00DD29B8 /* OFURL.m in Sources */,
4B3D23AE1337FC0D00DD29B8 /* OFXMLAttribute.m in Sources */,
4B49EA6E143B3A090005BBC6 /* OFXMLCDATA.m in Sources */,
4B49EA70143B3A090005BBC6 /* OFXMLCharacters.m in Sources */,
4B49EA72143B3A090005BBC6 /* OFXMLComment.m in Sources */,
4B3D23AF1337FC0D00DD29B8 /* OFXMLElement.m in Sources */,
4BB25E8D139C388A00F574EA /* OFXMLElement+Serialization.m in Sources */,
|
︙ | | |
Deleted README version [02fd1965be].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
ObjFW is a portable, lightweight framework for the Objective C language.
It enables you to write an application in Objective C that will run on
any platform supported by ObjFW without having to worry about
differences between operating systems or various frameworks that you
would otherwise need if you want to be portable.
See https://webkeks.org/objfw for more information.
INSTALLATION
To install ObjFW, just run the following commands:
$ ./configure
$ make
$ make install
In case you checked out ObjFW from the Mercurial repository, you need
to run the following command first:
$ ./autogen.sh
BUILDING AS A MAC OS X FRAMEWORK
It is also possible to build ObjFW as a Mac OS X framework. To do so,
just execute xcodebuild -target ObjFW in the root directory of ObjFW or open
the .xcodeproj in Xcode and choose Build -> Build from the menu. Copy the
resulting ObjFW.framework to /Library/Frameworks and you are done.
USING THE MAC OS X FRAMEWORK IN XCODE
To use the Mac OS X framework in Xcode, you need to add the .framework
to your project and add the following flags to "Other C Flags":
-fconstant-string-class=OFConstantString -fno-constant-cfstrings
Additionally, since Xcode 4, you need to manually set the compiler to GCC
or LLVM-GCC due to bugs in Clang on OS X with using a different constant
string class.
Optionally, if you want to use blocks, you also need to add:
-fblocks
BUGS AND FEATURE REQUESTS
If you find any bugs or have feature requests, feel free to send a
mail to js-spam@webkeks.org (remove -spam from the address!).
|
Added README.md version [b5ec898978].
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
ObjFW is a portable, lightweight framework for the Objective C language.
It enables you to write an application in Objective C that will run on
any platform supported by ObjFW without having to worry about
differences between operating systems or various frameworks that you
would otherwise need if you want to be portable.
See https://webkeks.org/objfw for more information.
Installation
============
To install ObjFW, just run the following commands:
$ ./configure
$ make
$ make install
In case you checked out ObjFW from the Git repository, you need to run
the following command first:
$ ./autogen.sh
Building as a Mac OS X framework
================================
It is also possible to build ObjFW as a Mac OS X framework. To do so,
just execute xcodebuild -target ObjFW in the root directory of ObjFW
or open the .xcodeproj in Xcode and choose Build -> Build from the
menu. Copy the resulting ObjFW.framework to `/Library/Frameworks` and
you are done.
Using the Mac OS X framework in Xcode
=====================================
To use the Mac OS X framework in Xcode, you need to add the .framework
to your project and add the following flags to "Other C Flags":
-fconstant-string-class=OFConstantString -fno-constant-cfstrings
Optionally, if you want to use blocks, you also need to add:
-fblocks
Bugs and feature requests
=========================
If you find any bugs or have feature requests, feel free to send a
mail to js-spam@webkeks.org (remove -spam from the address!).
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Modified buildsys.mk.in
from [78e4b27e5f]
to [c1236492e2].
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
|
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
|
-
+
-
+
-
+
+
|
#
# Copyright (c) 2007, 2008, 2009, 2010, 2011
# Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012
# Jonathan Schleifer <js@webkeks.org>
#
# https://webkeks.org/hg/buildsys/
# https://webkeks.org/git/?p=buildsys.git
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice is present in all copies.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
PACKAGE = @PACKAGE@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
AS = @AS@
CC = @CC@
CXX = @CXX@
CPP = @CPP@
DC = @DC@
ERLC = @ERLC@
OBJC = @OBJC@
|
︙ | | |
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
-
+
-
+
-
+
|
JAVACFLAGS = @JAVACFLAGS@
JAR = @JAR@
WINDRES = @WINDRES@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
plugindir ?= ${libdir}/${PACKAGE}
plugindir ?= ${libdir}/${PACKAGE_NAME}
datarootdir = @datarootdir@
datadir = @datadir@
includedir = @includedir@
includesubdir ?= ${PACKAGE}
includesubdir ?= ${PACKAGE_NAME}
localedir = @localedir@
localename ?= ${PACKAGE}
localename ?= ${PACKAGE_NAME}
mandir = @mandir@
mansubdir ?= man1
OBJS1 = ${SRCS:.c=.o}
OBJS2 = ${OBJS1:.cc=.o}
OBJS3 = ${OBJS2:.cxx=.o}
OBJS4 = ${OBJS3:.d=.o}
|
︙ | | |
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
.c.c.dep .cc.cc.dep .cxx.cxx.dep .m.m.dep .mm.mm.dep .S.S.dep:
${CPP} ${CPPFLAGS} -M $< | \
sed 's/^\([^\.]*\)\.o:/\1.o \1.lib.o \1.plugin.o:/' >$@ || \
{ rm -f $@; false; }
pre-depend:
${PROG} ${PROG_NOINST}: ${EXT_DEPS} ${OBJS}
${PROG} ${PROG_NOINST}: ${EXT_DEPS} ${OBJS} ${OBJS_EXTRA}
${LINK_STATUS}
if ${LD} -o $@ ${OBJS} ${LDFLAGS} ${LIBS}; then \
if ${LD} -o $@ ${OBJS} ${OBJS_EXTRA} ${LDFLAGS} ${LIBS}; then \
${LINK_OK}; \
else \
${LINK_FAILED}; \
fi
${JARFILE}: ${EXT_DEPS} ${JAR_MANIFEST} ${OBJS}
${JARFILE}: ${EXT_DEPS} ${JAR_MANIFEST} ${OBJS} ${OBJS_EXTRA}
${LINK_STATUS}
if test x"${JAR_MANIFEST}" != x""; then \
if ${JAR} cfm ${JARFILE} ${JAR_MANIFEST} ${OBJS}; then \
if ${JAR} cfm ${JARFILE} ${JAR_MANIFEST} ${OBJS} ${OBJS_EXTRA}; then \
${LINK_OK}; \
else \
${LINK_FAILED}; \
fi \
else \
if ${JAR} cf ${JARFILE} ${OBJS}; then \
if ${JAR} cf ${JARFILE} ${OBJS} ${OBJS_EXTRA}; then \
${LINK_OK}; \
else \
${LINK_FAILED}; \
fi \
fi
${SHARED_LIB} ${SHARED_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS}
${SHARED_LIB} ${SHARED_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS} ${LIB_OBJS_EXTRA}
${LINK_STATUS}; \
objs=""; \
ars=""; \
for i in ${LIB_OBJS}; do \
for i in ${LIB_OBJS} ${LIB_OBJS_EXTRA}; do \
case $$i in \
*.a) \
ars="$$ars $$i" \
;; \
*.o) \
objs="$$objs $$i" \
;; \
|
︙ | | |
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
-
+
-
+
|
${LINK_FAILED}; \
fi; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
done
${STATIC_LIB} ${STATIC_LIB_NOINST}: ${EXT_DEPS} ${OBJS}
${STATIC_LIB} ${STATIC_LIB_NOINST}: ${EXT_DEPS} ${OBJS} ${OBJS_EXTRA}
${LINK_STATUS}
rm -f $@
objs=""; \
ars=""; \
for i in ${OBJS}; do \
for i in ${OBJS} ${OBJS_EXTRA}; do \
case $$i in \
*.a) \
ars="$$ars $$i" \
;; \
*.o) \
objs="$$objs $$i" \
;; \
|
︙ | | |
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
-
+
-
+
|
rm -f $@; \
fi; \
for i in $$ars; do \
dir=".$$(echo $$i | sed 's/\//_/g').objs"; \
rm -fr $$dir; \
done
${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS}
${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST}: ${EXT_DEPS} ${LIB_OBJS} ${LIB_OBJS_EXTRA}
${LINK_STATUS}
rm -f $@
objs=""; \
ars=""; \
for i in ${LIB_OBJS}; do \
for i in ${LIB_OBJS} ${LIB_OBJS_EXTRA}; do \
case $$i in \
*.a) \
ars="$$ars $$i" \
;; \
*.o) \
objs="$$objs $$i" \
;; \
|
︙ | | |
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
|
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
|
-
+
|
else \
${INSTALL_FAILED}; \
fi \
done
for i in ${DATA}; do \
${INSTALL_STATUS}; \
if ${MKDIR_P} $$(dirname ${DESTDIR}${datadir}/${PACKAGE}/$$i) && ${INSTALL} -m 644 $$i ${DESTDIR}${datadir}/${PACKAGE}/$$i; then \
if ${MKDIR_P} $$(dirname ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i) && ${INSTALL} -m 644 $$i ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i; then \
${INSTALL_OK}; \
else \
${INSTALL_FAILED}; \
fi \
done
for i in ${PROG}; do \
|
︙ | | |
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
|
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
|
-
-
+
+
-
+
-
+
|
${DELETE_FAILED}; \
fi \
fi \
done
-rmdir ${DESTDIR}${plugindir} >/dev/null 2>&1
for i in ${DATA}; do \
if test -f ${DESTDIR}${datadir}/${PACKAGE}/$$i; then \
if rm -f ${DESTDIR}${datadir}/${PACKAGE}/$$i; then \
if test -f ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i; then \
if rm -f ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi; \
rmdir "$$(dirname ${DESTDIR}${datadir}/${PACKAGE}/$$i)" >/dev/null 2>&1 || true; \
rmdir "$$(dirname ${DESTDIR}${datadir}/${PACKAGE_NAME}/$$i)" >/dev/null 2>&1 || true; \
done
-rmdir ${DESTDIR}${datadir}/${PACKAGE} >/dev/null 2>&1
-rmdir ${DESTDIR}${datadir}/${PACKAGE_NAME} >/dev/null 2>&1
for i in ${PROG}; do \
if test -f ${DESTDIR}${bindir}/$$i; then \
if rm -f ${DESTDIR}${bindir}/$$i; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
|
︙ | | |
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
|
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
|
-
+
|
clean:
for i in ${SUBDIRS}; do \
${DIR_ENTER}; \
${MAKE} ${MFLAGS} clean || exit $$?; \
${DIR_LEAVE}; \
done
for i in ${DEPS} ${OBJS} ${LIB_OBJS} ${PLUGIN_OBJS} ${PROG} ${PROG_NOINST} ${SHARED_LIB} ${SHARED_LIB_NOINST} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} ${PLUGIN} ${PLUGIN_NOINST} ${CLEAN_LIB} ${MO_FILES} ${CLEAN}; do \
for i in ${DEPS} ${OBJS} ${OBJS_EXTRA} ${LIB_OBJS} ${LIB_OBJS_EXTRA} ${PLUGIN_OBJS} ${PROG} ${PROG_NOINST} ${SHARED_LIB} ${SHARED_LIB_NOINST} ${STATIC_LIB} ${STATIC_LIB_NOINST} ${STATIC_PIC_LIB} ${STATIC_PIC_LIB_NOINST} ${PLUGIN} ${PLUGIN_NOINST} ${CLEAN_LIB} ${MO_FILES} ${CLEAN}; do \
if test -f $$i -o -d $$i; then \
if rm -fr $$i; then \
${DELETE_OK}; \
else \
${DELETE_FAILED}; \
fi \
fi \
|
︙ | | |
Modified configure.ac
from [965b9ca7ef]
to [66c5f3668b].
︙ | | |
646
647
648
649
650
651
652
653
654
655
|
646
647
648
649
650
651
652
653
654
655
|
-
+
|
dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP
dnl and add OBJCPPFLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself.
AC_SUBST(CPP)
AC_SUBST(CPPFLAGS)
AC_SUBST(PACKAGE, ObjFW)
AC_CONFIG_FILES([buildsys.mk extra.mk utils/objfw-config])
AC_CONFIG_FILES([buildsys.mk extra.mk utils/objfw-config Info.plist])
AC_CONFIG_HEADERS([config.h src/objfw-defs.h])
AC_OUTPUT
|
Modified generators/TableGenerator.m
from [0d391d18e7]
to [f8d68ed27e].
︙ | | |
58
59
60
61
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
58
59
60
61
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
|
OFFile *file = [OFFile fileWithPath: path
mode: @"rb"];
OFString *line;
pool2 = [[OFAutoreleasePool alloc] init];
while ((line = [file readLine])) {
OFArray *split;
OFString **splitCArray;
OFString **splitObjects;
of_unichar_t codep;
split = [line componentsSeparatedByString: @";"];
if ([split count] != 15) {
of_log(@"Invalid line: %@\n", line);
[OFApplication terminateWithStatus: 1];
}
splitCArray = [split cArray];
splitObjects = [split objects];
codep = (of_unichar_t)[splitCArray[0] hexadecimalValue];
codep = (of_unichar_t)[splitObjects[0] hexadecimalValue];
upperTable[codep] =
(of_unichar_t)[splitCArray[12] hexadecimalValue];
(of_unichar_t)[splitObjects[12] hexadecimalValue];
lowerTable[codep] =
(of_unichar_t)[splitCArray[13] hexadecimalValue];
(of_unichar_t)[splitObjects[13] hexadecimalValue];
[pool2 releaseObjects];
}
[pool release];
}
- (void)readCaseFoldingFileAtPath: (OFString*)path
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init], *pool2;
OFFile *file = [OFFile fileWithPath: path
mode: @"rb"];
OFString *line;
pool2 = [[OFAutoreleasePool alloc] init];
while ((line = [file readLine])) {
while ((line = [file readLine]) != nil) {
OFArray *split;
OFString **splitCArray;
OFString **splitObjects;
of_unichar_t codep;
if ([line characterAtIndex: 0] == '#')
if ([line length] == 0 || [line hasPrefix: @"#"])
continue;
split = [line componentsSeparatedByString: @"; "];
if ([split count] != 4) {
of_log(@"Invalid line: %s\n", line);
[OFApplication terminateWithStatus: 1];
}
splitCArray = [split cArray];
splitObjects = [split objects];
if (![splitCArray[1] isEqual: @"S"] &&
![splitCArray[1] isEqual: @"C"])
if (![splitObjects[1] isEqual: @"S"] &&
![splitObjects[1] isEqual: @"C"])
continue;
codep = (of_unichar_t)[splitCArray[0] hexadecimalValue];
codep = (of_unichar_t)[splitObjects[0] hexadecimalValue];
casefoldingTable[codep] =
(of_unichar_t)[splitCArray[2] hexadecimalValue];
(of_unichar_t)[splitObjects[2] hexadecimalValue];
[pool2 releaseObjects];
}
[pool release];
}
|
︙ | | |
Modified m4/buildsys.m4
from [06736558b1]
to [7661b473e8].
1
2
3
4
5
6
7
8
9
10
11
|
1
2
3
4
5
6
7
8
9
10
11
12
|
+
-
+
-
+
|
dnl
dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012
dnl Copyright (c) 2007 - 2009, Jonathan Schleifer <js@webkeks.org>
dnl Jonathan Schleifer <js@webkeks.org>
dnl
dnl https://webkeks.org/hg/buildsys/
dnl https://webkeks.org/git/?p=buildsys.git
dnl
dnl Permission to use, copy, modify, and/or distribute this software for any
dnl purpose with or without fee is hereby granted, provided that the above
dnl copyright notice and this permission notice is present in all copies.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
dnl AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
︙ | | |
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
-
-
+
+
|
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-dynamiclib -current_version ${LIB_MAJOR}.${LIB_MINOR} -compatibility_version ${LIB_MAJOR}'
LIB_PREFIX='lib'
LIB_SUFFIX='.dylib'
LDFLAGS_RPATH='-Wl,-rpath,${libdir}'
PLUGIN_CFLAGS='-fPIC -DPIC'
PLUGIN_LDFLAGS='-bundle -undefined dynamic_lookup'
PLUGIN_SUFFIX='.impl'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i'
PLUGIN_SUFFIX='.bundle'
INSTALL_LIB='&& ${INSTALL} -m 755 $$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && install_name_tool -id ${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib && ${LN_S} -f $${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib ${DESTDIR}${libdir}/$$i'
UNINSTALL_LIB='&& rm -f ${DESTDIR}${libdir}/$$i ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.dylib ${DESTDIR}${libdir}/$${i%.dylib}.${LIB_MAJOR}.${LIB_MINOR}.dylib'
CLEAN_LIB=''
;;
solaris*)
AC_MSG_RESULT(Solaris)
LIB_CFLAGS='-fPIC -DPIC'
LIB_LDFLAGS='-shared -Wl,-soname=${SHARED_LIB}.${LIB_MAJOR}.${LIB_MINOR}'
|
︙ | | |
Modified src/Makefile
from [a7ff014919]
to [09b46eda88].
︙ | | |
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
+
|
OFString+JSONValue.m \
OFString+Serialization.m \
OFString+URLEncoding.m \
OFString+XMLEscaping.m \
OFString+XMLUnescaping.m \
OFTCPSocket.m \
${OFTHREAD_M} \
OFThreadPool.m \
OFURL.m \
OFXMLAttribute.m \
OFXMLCDATA.m \
OFXMLCharacters.m \
OFXMLComment.m \
OFXMLElement.m \
OFXMLElement+Serialization.m \
|
︙ | | |
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
+
+
+
-
-
-
|
${ASPRINTF_M} \
${FOUNDATION_COMPAT_M} \
iso_8859_15.m \
windows_1252.m \
${OBJC_PROPERTIES_M} \
${OBJC_SYNC_M}
OBJS_EXTRA = ${EXCEPTIONS_EXCEPTIONS_A} ${RUNTIME_RUNTIME_A}
LIB_OBJS_EXTRA = ${EXCEPTIONS_EXCEPTIONS_LIB_A} ${RUNTIME_RUNTIME_LIB_A}
include ../buildsys.mk
CPPFLAGS += -I. -I.. -Iexceptions -Iruntime
LD = ${OBJC}
LDFLAGS += ${REEXPORT_LIBOBJC} ${MACH_ALIAS_LIST}
LIB_OBJS := ${LIB_OBJS} ${EXCEPTIONS_EXCEPTIONS_LIB_A} ${RUNTIME_RUNTIME_LIB_A}
OBJS += ${EXCEPTIONS_EXCEPTIONS_A} ${RUNTIME_RUNTIME_A}
|
Modified src/OFArray.h
from [f3beab2ab4]
to [1778f85d38].
︙ | | |
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
|
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
-
-
-
-
-
-
-
-
-
-
+
+
|
* \brief Creates a new OFArray with the objects from the specified array.
*
* \param array An array
* \return A new autoreleased OFArray
*/
+ arrayWithArray: (OFArray*)array;
/**
* \brief Creates a new OFArray with the objects from the specified C array.
*
* \param objects A C array of objects, terminated with nil
* \return A new autoreleased OFArray
*/
+ arrayWithCArray: (id*)objects;
/**
* \brief Creates a new OFArray with the objects from the specified C array of
* the specified length.
*
* \param objects A C array of objects
* \param length The length of the C array
* \return A new autoreleased OFArray
*/
+ arrayWithCArray: (id*)objects
length: (size_t)length;
+ arrayWithObjects: (id*)objects
count: (size_t)count;
/**
* \brief Initializes an OFArray with the specified object.
*
* \param object An object
* \return An initialized OFArray
*/
|
︙ | | |
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
|
* \brief Initializes an OFArray with the objects from the specified array.
*
* \param array An array
* \return An initialized OFArray
*/
- initWithArray: (OFArray*)array;
/**
* \brief Initializes an OFArray with the objects from the specified C array.
*
* \param objects A C array of objects, terminated with nil
* \return An initialized OFArray
*/
- initWithCArray: (id*)objects;
/**
* \brief Initializes an OFArray with the objects from the specified C array of
* the specified length.
*
* \param objects A C array of objects
* \param length The length of the C array
* \return An initialized OFArray
*/
- initWithCArray: (id*)objects
length: (size_t)length;
- initWithObjects: (id*)objects
count: (size_t)count;
/**
* \brief Returns a specified object of the array.
*
* The returned object is <i>not</i> retained and autoreleased for performance
* reasons!
*
* \param index The number of the object to return
* \return The specified object of the OFArray
*/
- (id)objectAtIndex: (size_t)index;
- (id)objectAtIndexedSubscript: (size_t)index;
/**
* \brief Copies the objects at the specified range to the specified buffer.
*
* \param buffer The buffer to copy the objects to
* \param range The range to copy
*/
- (void)getObjects: (id*)buffer
inRange: (of_range_t)range;
/**
* \brief Returns the objects of the array as a C array.
*
* \return The objects of the array as a C array
*/
- (id*)cArray;
- (id*)objects;
/**
* \brief Returns the index of the first object that is equivalent to the
* specified object or OF_INVALID_INDEX if it was not found.
*
* \param object The object whose index is returned
* \return The index of the first object equivalent to the specified object
|
︙ | | |
343
344
345
346
347
348
349
|
328
329
330
331
332
333
334
335
336
337
338
339
|
+
+
+
+
+
|
}
- initWithArray: (OFArray*)data
mutationsPtr: (unsigned long*)mutationsPtr;
@end
#import "OFMutableArray.h"
#ifndef NSINTEGER_DEFINED
/* Required for array literals to work */
@compatibility_alias NSArray OFArray;
#endif
|
Modified src/OFArray.m
from [6919605399]
to [652b854188].
︙ | | |
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
-
+
-
-
-
-
-
-
+
-
-
+
+
|
}
- initWithArray: (OFArray*)array
{
return (id)[[OFArray_adjacent alloc] initWithArray: array];
}
- initWithCArray: (id*)objects
- initWithObjects: (id*)objects
{
return (id)[[OFArray_adjacent alloc] initWithCArray: objects];
}
- initWithCArray: (id*)objects
length: (size_t)length
count: (size_t)count
{
return (id)[[OFArray_adjacent alloc] initWithCArray: objects
length: length];
return (id)[[OFArray_adjacent alloc] initWithObjects: objects
count: count];
}
- initWithSerialization: (OFXMLElement*)element
{
return (id)[[OFArray_adjacent alloc] initWithSerialization: element];
}
|
︙ | | |
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
-
+
-
-
-
-
-
-
+
-
-
+
+
|
}
+ arrayWithArray: (OFArray*)array
{
return [[[self alloc] initWithArray: array] autorelease];
}
+ arrayWithCArray: (id*)objects
+ arrayWithObjects: (id*)objects
{
return [[[self alloc] initWithCArray: objects] autorelease];
}
+ arrayWithCArray: (id*)objects
length: (size_t)length
count: (size_t)count
{
return [[[self alloc] initWithCArray: objects
length: length] autorelease];
return [[[self alloc] initWithObjects: objects
count: count] autorelease];
}
- init
{
if (isa == [OFArray class]) {
Class c = isa;
[self release];
|
︙ | | |
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
-
+
-
-
-
-
-
-
-
-
-
+
|
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithCArray: (id*)objects
- initWithObjects: (id*)objects
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithCArray: (id*)objects
length: (size_t)length
count: (size_t)count
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
|
︙ | | |
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
-
+
|
{
size_t i;
for (i = 0; i < range.length; i++)
buffer[i] = [self objectAtIndex: range.start + i];
}
- (id*)cArray
- (id*)objects
{
OFObject *container;
size_t count;
id *buffer;
container = [[[OFObject alloc] init] autorelease];
count = [self count];
|
︙ | | |
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
+
+
+
+
+
|
}
- (id)objectAtIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (id)objectAtIndexedSubscript: (size_t)index
{
return [self objectAtIndex: index];
}
- (size_t)indexOfObject: (id)object
{
size_t i, count = [self count];
for (i = 0; i < count; i++)
if ([[self objectAtIndex: i] isEqual: object])
|
︙ | | |
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
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
|
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
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
|
-
-
+
+
-
+
-
+
-
+
-
+
|
buffer = [self allocMemoryForNItems: range.length
ofSize: sizeof(*buffer)];
@try {
[self getObjects: buffer
inRange: range];
ret = [OFArray arrayWithCArray: buffer
length: range.length];
ret = [OFArray arrayWithObjects: buffer
count: range.length];
} @finally {
[self freeMemory: buffer];
}
return ret;
}
- (OFString*)componentsJoinedByString: (OFString*)separator
{
return [self componentsJoinedByString: separator
usingSelector: @selector(description)];
}
- (OFString*)componentsJoinedByString: (OFString*)separator
usingSelector: (SEL)selector
{
OFAutoreleasePool *pool, *pool2;
OFMutableString *ret;
id *cArray;
id *objects;
size_t i, count = [self count];
IMP append;
if (count == 0)
return @"";
if (count == 1)
return [[self firstObject] performSelector: selector];
ret = [OFMutableString string];
append = [ret methodForSelector: @selector(appendString:)];
pool = [[OFAutoreleasePool alloc] init];
cArray = [self cArray];
objects = [self objects];
pool2 = [[OFAutoreleasePool alloc] init];
for (i = 0; i < count - 1; i++) {
append(ret, @selector(appendString:),
[cArray[i] performSelector: selector]);
[objects[i] performSelector: selector]);
append(ret, @selector(appendString:), separator);
[pool2 releaseObjects];
}
append(ret, @selector(appendString:),
[cArray[i] performSelector: selector]);
[objects[i] performSelector: selector]);
[ret makeImmutable];
[pool release];
return ret;
}
|
︙ | | |
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
|
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
|
-
+
-
+
|
return NO;
return YES;
}
- (uint32_t)hash
{
id *cArray = [self cArray];
id *objects = [self objects];
size_t i, count = [self count];
uint32_t hash;
OF_HASH_INIT(hash);
for (i = 0; i < count; i++) {
uint32_t h = [cArray[i] hash];
uint32_t h = [objects[i] hash];
OF_HASH_ADD(hash, h >> 24);
OF_HASH_ADD(hash, (h >> 16) & 0xFF);
OF_HASH_ADD(hash, (h >> 8) & 0xFF);
OF_HASH_ADD(hash, h & 0xFF);
}
|
︙ | | |
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
|
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
|
-
+
-
+
|
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFAutoreleasePool *pool2;
OFXMLElement *element;
id <OFSerialization> *cArray = [self cArray];
id <OFSerialization> *objects = [self objects];
size_t i, count = [self count];
if ([self isKindOfClass: [OFMutableArray class]])
element = [OFXMLElement elementWithName: @"OFMutableArray"
namespace: OF_SERIALIZATION_NS];
else
element = [OFXMLElement elementWithName: @"OFArray"
namespace: OF_SERIALIZATION_NS];
pool2 = [[OFAutoreleasePool alloc] init];
for (i = 0; i < count; i++) {
[element addChild: [cArray[i] XMLElementBySerializing]];
[element addChild: [objects[i] XMLElementBySerializing]];
[pool2 releaseObjects];
}
[element retain];
[pool release];
[element autorelease];
|
︙ | | |
531
532
533
534
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
|
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
|
-
+
-
-
+
+
-
+
-
-
+
+
|
[JSON makeImmutable];
return JSON;
}
- (void)makeObjectsPerformSelector: (SEL)selector
{
id *cArray = [self cArray];
id *objects = [self objects];
size_t i, count = [self count];
for (i = 0; i < count; i++)
((void(*)(id, SEL))[cArray[i]
methodForSelector: selector])(cArray[i], selector);
((void(*)(id, SEL))[objects[i]
methodForSelector: selector])(objects[i], selector);
}
- (void)makeObjectsPerformSelector: (SEL)selector
withObject: (id)object
{
id *cArray = [self cArray];
id *objects = [self objects];
size_t i, count = [self count];
for (i = 0; i < count; i++)
((void(*)(id, SEL, id))[cArray[i]
methodForSelector: selector])(cArray[i], selector, object);
((void(*)(id, SEL, id))[objects[i]
methodForSelector: selector])(objects[i], selector, object);
}
- (OFArray*)sortedArray
{
OFMutableArray *new = [[self mutableCopy] autorelease];
[new sort];
|
︙ | | |
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
|
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
|
-
+
|
if (count > INT_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
if (state->state >= count)
return 0;
state->state = count;
state->itemsPtr = [self cArray];
state->itemsPtr = [self objects];
state->mutationsPtr = (unsigned long*)self;
return (int)count;
}
- (OFEnumerator*)objectEnumerator
{
|
︙ | | |
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
|
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
-
-
+
+
|
@try {
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
BOOL *stop) {
tmp[index] = block(object, index);
}];
ret = [OFArray arrayWithCArray: tmp
length: count];
ret = [OFArray arrayWithObjects: tmp
count: count];
} @finally {
[self freeMemory: tmp];
}
return ret;
}
|
︙ | | |
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
|
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
|
-
-
+
+
|
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
BOOL *stop) {
if (block(object, index))
tmp[i++] = object;
}];
ret = [OFArray arrayWithCArray: tmp
length: i];
ret = [OFArray arrayWithObjects: tmp
count: i];
} @finally {
[self freeMemory: tmp];
}
return ret;
}
|
︙ | | |
Modified src/OFArray_adjacent.m
from [49ed7295ca]
to [0afb4e2882].
︙ | | |
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
|
}
return self;
}
- initWithArray: (OFArray*)array_
{
id *cArray;
id *objects;
size_t i, count;
self = [self init];
@try {
cArray = [array_ cArray];
objects = [array_ objects];
count = [array_ count];
} @catch (id e) {
[self release];
@throw e;
}
@try {
for (i = 0; i < count; i++)
[cArray[i] retain];
[objects[i] retain];
[array addNItems: count
fromCArray: cArray];
fromCArray: objects];
} @catch (id e) {
for (i = 0; i < count; i++)
[cArray[i] release];
[objects[i] release];
/* Prevent double-release of objects */
[array release];
array = nil;
[self release];
@throw e;
}
return self;
}
- initWithCArray: (id*)objects
- initWithObjects: (id*)objects
{
self = [self init];
@try {
id *object;
size_t count = 0;
for (object = objects; *object != nil; object++) {
[*object retain];
count++;
}
[array addNItems: count
fromCArray: objects];
} @catch (id e) {
id *object;
for (object = objects; *object != nil; object++)
[*object release];
[self release];
@throw e;
}
return self;
}
- initWithCArray: (id*)objects
length: (size_t)length
count: (size_t)count
{
self = [self init];
@try {
size_t i;
for (i = 0; i < length; i++)
for (i = 0; i < count; i++)
[objects[i] retain];
[array addNItems: length
[array addNItems: count
fromCArray: objects];
} @catch (id e) {
size_t i;
for (i = 0; i < length; i++)
for (i = 0; i < count; i++)
[objects[i] release];
[self release];
@throw e;
}
return self;
|
︙ | | |
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
-
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
}
- (size_t)count
{
return [array count];
}
- (id*)cArray
- (id*)objects
{
return [array cArray];
}
- (id)objectAtIndex: (size_t)index
{
return *((id*)[array itemAtIndex: index]);
}
- (id)objectAtIndexedSubscript: (size_t)index
{
return *((id*)[array itemAtIndex: index]);
}
- (void)getObjects: (id*)buffer
inRange: (of_range_t)range
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
if (range.start + range.length > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
for (i = 0; i < range.length; i++)
buffer[i] = cArray[range.start + i];
buffer[i] = objects[range.start + i];
}
- (size_t)indexOfObject: (id)object
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++)
if ([cArray[i] isEqual: object])
if ([objects[i] isEqual: object])
return i;
return OF_INVALID_INDEX;
}
- (size_t)indexOfObjectIdenticalTo: (id)object
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++)
if (cArray[i] == object)
if (objects[i] == object)
return i;
return OF_INVALID_INDEX;
}
- (OFArray*)objectsInRange: (of_range_t)range
{
size_t count;
if (![self isKindOfClass: [OFMutableArray class]])
return [OFArray_adjacentSubarray arrayWithArray: self
range: range];
count = [array count];
if (range.start + range.length > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
return [OFArray arrayWithCArray: (id*)[array cArray] + range.start
length: range.length];
return [OFArray arrayWithObjects: (id*)[array cArray] + range.start
count: range.length];
}
- (BOOL)isEqual: (id)object
{
OFArray *otherArray;
id *cArray, *otherCArray;
id *objects, *otherObjects;
size_t i, count;
if ([object class] != [OFArray_adjacent class] &&
[object class] != [OFMutableArray_adjacent class] &&
[object class] != [OFArray_adjacentSubarray class])
return [super isEqual: object];
otherArray = object;
count = [array count];
if (count != [otherArray count])
return NO;
cArray = [array cArray];
otherCArray = [otherArray cArray];
objects = [array cArray];
otherObjects = [otherArray objects];
for (i = 0; i < count; i++)
if (![cArray[i] isEqual: otherCArray[i]])
if (![objects[i] isEqual: otherObjects[i]])
return NO;
return YES;
}
- (uint32_t)hash
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
uint32_t hash;
OF_HASH_INIT(hash);
for (i = 0; i < count; i++) {
uint32_t h = [cArray[i] hash];
uint32_t h = [objects[i] hash];
OF_HASH_ADD(hash, h >> 24);
OF_HASH_ADD(hash, (h >> 16) & 0xFF);
OF_HASH_ADD(hash, (h >> 8) & 0xFF);
OF_HASH_ADD(hash, h & 0xFF);
}
OF_HASH_FINALIZE(hash);
return hash;
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
BOOL stop = NO;
for (i = 0; i < count && !stop; i++)
block(cArray[i], i, &stop);
block(objects[i], i, &stop);
}
#endif
- (void)dealloc
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++)
[cArray[i] release];
[objects[i] release];
[array release];
[super dealloc];
}
@end
|
Modified src/OFArray_adjacentSubarray.m
from [93b321ec4d]
to [eb001a037a].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
|
#include "config.h"
#import "OFArray_adjacentSubarray.h"
#import "OFArray_adjacent.h"
#import "OFMutableArray_adjacent.h"
@implementation OFArray_adjacentSubarray
- (id*)cArray
- (id*)objects
{
return [array cArray] + range.start;
return [array objects] + range.start;
}
- (BOOL)isEqual: (id)object
{
OFArray *otherArray;
id *cArray, *otherCArray;
id *objects, *otherObjects;
size_t i;
if ([object class] != [OFArray_adjacent class] &&
[object class] != [OFMutableArray_adjacent class] &&
[object class] != [OFArray_adjacentSubarray class])
return [super isEqual: object];
otherArray = object;
if (range.length != [otherArray count])
return NO;
cArray = [self cArray];
otherCArray = [otherArray cArray];
objects = [self objects];
otherObjects = [otherArray objects];
for (i = 0; i < range.length; i++)
if (![cArray[i] isEqual: otherCArray[i]])
if (![objects[i] isEqual: otherObjects[i]])
return NO;
return YES;
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
id *cArray = [self cArray];
id *objects = [self objects];
size_t i;
BOOL stop = NO;
for (i = 0; i < range.length && !stop; i++)
block(cArray[i], i, &stop);
block(objects[i], i, &stop);
}
#endif
@end
|
Modified src/OFBlock.m
from [5f9f9c11d5]
to [100cdf479d].
︙ | | |
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
-
-
-
-
-
-
|
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- init
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)addMemoryToPool: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
|
︙ | | |
Modified src/OFConstantString.m
from [1513456645]
to [e6c815e41d].
︙ | | |
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
-
-
-
-
-
|
@implementation OFString_const
+ alloc
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- (void)addMemoryToPool: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
|
︙ | | |
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
-
-
-
-
-
-
|
+ alloc
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
- (void)addMemoryToPool: (void*)ptr
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void*)allocMemoryForNItems: (size_t)nitems
|
︙ | | |
Modified src/OFCountedSet_hashtable.m
from [d9c4c3dca1]
to [fed71ad63c].
︙ | | |
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
-
+
-
+
|
}
- initWithArray: (OFArray*)array
{
self = [self init];
@try {
id *cArray = [array cArray];
id *objects = [array objects];
size_t i, count = [array count];
for (i = 0; i < count; i++)
[self addObject: cArray[i]];
[self addObject: objects[i]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
︙ | | |
Modified src/OFDataArray.m
from [80fa284829]
to [f620eb9fde].
︙ | | |
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
|
-
+
-
|
@throw [OFOutOfRangeException exceptionWithClass: isa];
lastPageByte = of_pagesize - 1;
newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
toNItems: newSize
toSize: newSize];
ofSize: itemSize];
memmove(data + (index + nItems) * itemSize, data + index * itemSize,
(count - index) * itemSize);
memcpy(data + index * itemSize, cArray, nItems * itemSize);
count += nItems;
size = newSize;
|
︙ | | |
Modified src/OFDictionary.h
from [d9d9397b7f]
to [03d734b6a0].
︙ | | |
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
|
* \param keys An array of keys
* \param objects An array of objects
* \return A new autoreleased OFDictionary
*/
+ dictionaryWithObjects: (OFArray*)objects
forKeys: (OFArray*)keys;
/**
* \brief Creates a new OFDictionary with the specified keys and objects.
*
* \param keys An array of keys
* \param objects An array of objects
* \param count The number of objects in the arrays
* \return A new autoreleased OFDictionary
*/
+ dictionaryWithObjects: (id*)objects
forKeys: (id*)keys
count: (size_t)count;
/**
* \brief Creates a new OFDictionary with the specified keys objects.
*
* \param firstKey The first key
* \return A new autoreleased OFDictionary
*/
+ dictionaryWithKeysAndObjects: (id)firstKey, ...;
|
︙ | | |
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
+
+
+
+
+
+
+
+
+
+
+
+
+
|
*/
- initWithObjects: (OFArray*)objects
forKeys: (OFArray*)keys;
/**
* \brief Initializes an already allocated OFDictionary with the specified keys
* and objects.
*
* \param keys An array of keys
* \param objects An array of objects
* \param count The number of objects in the arrays
* \return A new initialized OFDictionary
*/
- initWithObjects: (id*)objects
forKeys: (id*)keys
count: (size_t)count;
/**
* \brief Initializes an already allocated OFDictionary with the specified keys
* and objects.
*
* \param firstKey The first key
* \return A new initialized OFDictionary
*/
- initWithKeysAndObjects: (id)firstKey, ...;
/**
|
︙ | | |
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
+
|
* The returned object is <i>not</i> retained and autoreleased for performance
* reasons!
*
* \param key The key whose object should be returned
* \return The object for the given key or nil if the key was not found
*/
- (id)objectForKey: (id)key;
- (id)objectForKeyedSubscript: (id)key;
/**
* \brief Checks whether the dictionary contains an object with the specified
* address.
*
* \param object The object which is checked for being in the dictionary
* \return A boolean whether the dictionary contains an object with the
|
︙ | | |
224
225
226
227
228
229
230
|
250
251
252
253
254
255
256
257
258
259
260
261
|
+
+
+
+
+
|
#if defined(OF_SET_M) || defined(OF_COUNTED_SET_M)
- _initWithDictionary: (OFDictionary*)dictionary
copyKeys: (BOOL)copyKeys;
#endif
@end
#import "OFMutableDictionary.h"
#ifndef NSINTEGER_DEFINED
/* Required for dictionary literals to work */
@compatibility_alias NSDictionary OFDictionary;
#endif
|
Modified src/OFDictionary.m
from [940c27c632]
to [e60712dc03].
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
+
+
+
+
+
+
+
+
+
|
- initWithObjects: (OFArray*)objects
forKeys: (OFArray*)keys
{
return (id)[[OFDictionary_hashtable alloc] initWithObjects: objects
forKeys: keys];
}
- initWithObjects: (id*)objects
forKeys: (id*)keys
count: (size_t)count
{
return (id)[[OFDictionary_hashtable alloc] initWithObjects: objects
forKeys: keys
count: count];
}
- initWithKeysAndObjects: (id <OFCopying>)firstKey, ...
{
id ret;
va_list arguments;
va_start(arguments, firstKey);
|
︙ | | |
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
+
+
+
+
+
+
+
+
+
|
+ dictionaryWithObjects: (OFArray*)objects
forKeys: (OFArray*)keys
{
return [[[self alloc] initWithObjects: objects
forKeys: keys] autorelease];
}
+ dictionaryWithObjects: (id*)objects
forKeys: (id*)keys
count: (size_t)count
{
return [[[self alloc] initWithObjects: objects
forKeys: keys
count: count] autorelease];
}
+ dictionaryWithKeysAndObjects: (id)firstKey, ...
{
id ret;
va_list arguments;
va_start(arguments, firstKey);
|
︙ | | |
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
+
+
+
+
+
+
+
+
+
+
|
forKeys: (OFArray*)keys
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithObjects: (id*)objects
forKeys: (id*)keys
count: (size_t)count
{
Class c = isa;
[self release];
@throw [OFNotImplementedException exceptionWithClass: c
selector: _cmd];
}
- initWithKeysAndObjects: (id)firstKey, ...
{
id ret;
va_list arguments;
va_start(arguments, firstKey);
|
︙ | | |
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
+
+
+
+
+
-
+
+
+
+
+
+
+
-
+
-
+
|
}
- (id)objectForKey: (id)key
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (id)objectForKeyedSubscript: (id)key
{
return [self objectForKey: key];
}
- (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- copy
{
return [self retain];
}
- mutableCopy
{
return [[OFMutableDictionary alloc] initWithDictionary: self];
}
- (BOOL)isEqual: (id)dictionary
- (BOOL)isEqual: (id)object
{
OFDictionary *otherDictionary;
OFAutoreleasePool *pool;
OFEnumerator *enumerator;
id key;
if (![object isKindOfClass: [OFDictionary class]])
return NO;
otherDictionary = object;
if ([dictionary count] != [self count])
if ([otherDictionary count] != [self count])
return NO;
pool = [[OFAutoreleasePool alloc] init];
enumerator = [self keyEnumerator];
while ((key = [enumerator nextObject]) != nil) {
id object = [dictionary objectForKey: key];
id object = [otherDictionary objectForKey: key];
if (object == nil ||
![object isEqual: [self objectForKey: key]]) {
[pool release];
return NO;
}
}
|
︙ | | |
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
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
|
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
|
return NO;
}
- (OFArray*)allKeys
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
id *cArray = [self allocMemoryForNItems: [self count]
ofSize: sizeof(id)];
id *keys = [self allocMemoryForNItems: [self count]
ofSize: sizeof(id)];
OFArray *ret;
OFEnumerator *enumerator;
id key;
size_t i = 0;
pool = [[OFAutoreleasePool alloc] init];
enumerator = [self keyEnumerator];
while ((key = [enumerator nextObject]) != nil)
cArray[i++] = key;
keys[i++] = key;
assert(i == [self count]);
[pool release];
@try {
ret = [OFArray arrayWithCArray: cArray
length: [self count]];
ret = [OFArray arrayWithObjects: keys
count: [self count]];
} @finally {
[self freeMemory: cArray];
[self freeMemory: keys];
}
return ret;
}
- (OFArray*)allObjects
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
id *cArray = [self allocMemoryForNItems: [self count]
ofSize: sizeof(id)];
id *objects = [self allocMemoryForNItems: [self count]
ofSize: sizeof(id)];
OFArray *ret;
OFEnumerator *enumerator;
id object;
size_t i = 0;
pool = [[OFAutoreleasePool alloc] init];
enumerator = [self objectEnumerator];
while ((object = [enumerator nextObject]) != nil)
cArray[i++] = object;
objects[i++] = object;
assert(i == [self count]);
[pool release];
@try {
ret = [OFArray arrayWithCArray: cArray
length: [self count]];
ret = [OFArray arrayWithObjects: objects
count: [self count]];
} @finally {
[self freeMemory: cArray];
[self freeMemory: objects];
}
return ret;
}
- (OFEnumerator*)objectEnumerator
{
|
︙ | | |
Modified src/OFDictionary_hashtable.m
from [a4ce122b88]
to [fd15d2ff3e].
︙ | | |
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
|
return self;
}
- initWithObjects: (OFArray*)objects
forKeys: (OFArray*)keys
{
id ret;
@try {
if ([objects count] != [keys count])
@throw [OFInvalidArgumentException
exceptionWithClass: isa];
ret = [self initWithObjects: [objects objects]
forKeys: [keys objects]
count: [objects count]];
} @catch (id e) {
[self release];
@throw e;
}
return ret;
}
- initWithObjects: (id*)objects
forKeys: (id*)keys
count: (size_t)count_
{
self = [super init];
@try {
id *objectsCArray, *keysCArray;
uint32_t i, j, newSize;
keysCArray = [keys cArray];
objectsCArray = [objects cArray];
count = [keys count];
count = count_;
if (count > UINT32_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
for (newSize = 1; newSize < count; newSize <<= 1);
if (count * 4 / newSize >= 3)
newSize <<= 1;
|
︙ | | |
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
-
+
-
+
-
+
-
-
+
|
data[j] = NULL;
size = newSize;
for (i = 0; i < count; i++) {
uint32_t hash, last;
hash = [keysCArray[i] hash];
hash = [keys[i] hash];
last = size;
for (j = hash & (size - 1); j < last && data[j] != NULL;
j++)
if ([data[j]->key isEqual: keysCArray[i]])
if ([data[j]->key isEqual: keys[i]])
break;
/* In case the last bucket is already used */
if (j >= last) {
last = hash & (size - 1);
for (j = 0; j < last && data[j] != NULL; j++)
if ([data[j]->key
if ([data[j]->key isEqual: keys[i]])
isEqual: keysCArray[i]])
break;
}
/* Key not in dictionary */
if (j >= last || data[j] == NULL ||
![data[j]->key isEqual: keysCArray[i]]) {
![data[j]->key isEqual: keys[i]]) {
struct of_dictionary_hashtable_bucket *bucket;
id key;
last = size;
j = hash & (size - 1);
for (; j < last && data[j] != NULL; j++);
|
︙ | | |
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
-
+
-
+
-
+
-
+
|
if (j >= last)
@throw [OFOutOfRangeException
exceptionWithClass: isa];
bucket =
[self allocMemoryWithSize: sizeof(*bucket)];
key = [keysCArray[i] copy];
key = [keys[i] copy];
bucket->key = key;
bucket->object = [objectsCArray[i] retain];
bucket->object = [objects[i] retain];
bucket->hash = hash;
data[j] = bucket;
continue;
}
/*
* The key is already in the dictionary. However, we
* just replace it so that the programmer gets the same
* behavior as if he'd call setObject:forKey: for each
* key/object pair.
*/
[objectsCArray[i] retain];
[objects[i] retain];
[data[j]->object release];
data[j]->object = objectsCArray[i];
data[j]->object = objects[i];
}
} @catch (id e) {
[self release];
@throw e;
}
return self;
|
︙ | | |
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
|
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
|
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
|
return NO;
}
- (OFArray*)allKeys
{
OFArray *ret;
id *cArray = [self allocMemoryForNItems: count
ofSize: sizeof(id)];
id *keys = [self allocMemoryForNItems: count
ofSize: sizeof(id)];
size_t i, j;
for (i = j = 0; i < size; i++)
if (data[i] != NULL && data[i] != DELETED)
cArray[j++] = data[i]->key;
keys[j++] = data[i]->key;
assert(j == count);
@try {
ret = [OFArray arrayWithCArray: cArray
length: count];
ret = [OFArray arrayWithObjects: keys
count: count];
} @finally {
[self freeMemory: cArray];
[self freeMemory: keys];
}
return ret;
}
- (OFArray*)allObjects
{
OFArray *ret;
id *cArray = [self allocMemoryForNItems: count
ofSize: sizeof(id)];
id *objects = [self allocMemoryForNItems: count
ofSize: sizeof(id)];
size_t i, j;
for (i = j = 0; i < size; i++)
if (data[i] != NULL && data[i] != DELETED)
cArray[j++] = data[i]->object;
objects[j++] = data[i]->object;
assert(j == count);
@try {
ret = [OFArray arrayWithCArray: cArray
length: count];
ret = [OFArray arrayWithObjects: objects
count: count];
} @finally {
[self freeMemory: cArray];
[self freeMemory: objects];
}
return ret;
}
- (OFEnumerator*)keyEnumerator
{
|
︙ | | |
Modified src/OFFile.h
from [c75eb39d48]
to [a381f6647c].
︙ | | |
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
116
117
118
119
|
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/**
* \brief Creates a directory at the specified path.
*
* \param path The path of the directory
*/
+ (void)createDirectoryAtPath: (OFString*)path;
/**
* \brief Creates a directory at the specified path.
*
* \param path The path of the directory
* \param createParents Whether to create the parents of the directory
*/
+ (void)createDirectoryAtPath: (OFString*)path
createParents: (BOOL)createParents;
/**
* \brief Returns an array with the files in the specified directory.
*
* \param path The path of the directory
* \return An array of OFStrings with the files at the specified path
*/
+ (OFArray*)filesInDirectoryAtPath: (OFString*)path;
/**
* \brief Changes the current working directory.
*
* \param path The new directory to change to
*/
+ (void)changeToDirectory: (OFString*)path;
/**
* \brief Returns the size of the specified file.
*
* \return The size of the specified file
*/
+ (off_t)sizeOfFile: (OFString*)path;
/**
* \brief Returns the date of the last modification of the file.
*
* \return The date of the last modification of the file
*/
+ (OFDate*)modificationDateOfFile: (OFString*)path;
|
︙ | | |
Modified src/OFFile.m
from [73d7458af5]
to [83d1b0c935].
︙ | | |
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
#else
if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#endif
@throw [OFCreateDirectoryFailedException
exceptionWithClass: self
path: path];
}
+ (void)createDirectoryAtPath: (OFString*)path
createParents: (BOOL)createParents
{
OFAutoreleasePool *pool, *pool2;
OFArray *pathComponents;
OFString *currentPath = nil, *component;
OFEnumerator *enumerator;
if (!createParents) {
[OFFile createDirectoryAtPath: path];
return;
}
pool = [[OFAutoreleasePool alloc] init];
pathComponents = [path pathComponents];
enumerator = [pathComponents objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((component = [enumerator nextObject]) != nil) {
if (currentPath != nil)
currentPath = [OFString
stringWithPath: currentPath, component, nil];
else
currentPath = component;
if (![currentPath isEqual: @""] &&
![OFFile directoryExistsAtPath: currentPath])
[OFFile createDirectoryAtPath: currentPath];
[currentPath retain];
[pool2 releaseObjects];
[currentPath autorelease];
}
[pool release];
}
+ (OFArray*)filesInDirectoryAtPath: (OFString*)path
{
OFAutoreleasePool *pool;
OFMutableArray *files = [OFMutableArray array];
#ifndef _WIN32
|
︙ | | |
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
@throw [OFChangeFileModeFailedException
exceptionWithClass: self
path: path
mode: mode];
# endif
}
#endif
+ (off_t)sizeOfFile: (OFString*)path
{
struct stat s;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
/* FIXME: Maybe use another exception? */
@throw [OFOpenFileFailedException exceptionWithClass: self
path: path
mode: @"r"];
return s.st_size;
}
+ (OFDate*)modificationDateOfFile: (OFString*)path
{
struct stat s;
if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
&s) == -1)
|
︙ | | |
Modified src/OFHTTPRequest.m
from [4bbd6ecaac]
to [4b826a148e].
︙ | | |
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
|
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
|
+
+
-
+
|
#import "OFURL.h"
#import "OFTCPSocket.h"
#import "OFDictionary.h"
#import "OFDataArray.h"
#import "OFAutoreleasePool.h"
#import "OFHTTPRequestFailedException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFInvalidServerReplyException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#import "OFUnsupportedProtocolException.h"
#import "macros.h"
Class of_http_request_tls_socket_class = Nil;
static OF_INLINE void
normalize_key(OFString *key)
normalizeKey(OFString *key)
{
uint8_t *str = (uint8_t*)[key UTF8String];
BOOL firstLetter = YES;
while (*str != '\0') {
if (!isalnum(*str)) {
firstLetter = YES;
|
︙ | | |
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
-
-
-
+
+
+
+
-
|
}
- init
{
self = [super init];
requestType = OF_HTTP_REQUEST_TYPE_GET;
headers = [[OFDictionary alloc]
initWithObject: @"Something using ObjFW "
@"<https://webkeks.org/objfw/>"
headers = [[OFDictionary alloc] initWithKeysAndObjects:
@"Connection", @"close",
@"User-Agent", @"Something using ObjFW "
@"<https://webkeks.org/objfw/>", nil];
forKey: @"User-Agent"];
storesData = YES;
return self;
}
- initWithURL: (OFURL*)URL_
{
|
︙ | | |
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
-
+
-
+
-
+
|
[headers release];
[super dealloc];
}
- (void)setURL: (OFURL*)URL_
{
OF_SETTER(URL, URL_, YES, YES)
OF_SETTER(URL, URL_, YES, 1)
}
- (OFURL*)URL
{
OF_GETTER(URL, YES)
}
- (void)setRequestType: (of_http_request_type_t)requestType_
{
requestType = requestType_;
}
- (of_http_request_type_t)requestType
{
return requestType;
}
- (void)setQueryString: (OFString*)queryString_
{
OF_SETTER(queryString, queryString_, YES, YES)
OF_SETTER(queryString, queryString_, YES, 1)
}
- (OFString*)queryString
{
OF_GETTER(queryString, YES)
}
- (void)setHeaders: (OFDictionary*)headers_
{
OF_SETTER(headers, headers_, YES, YES)
OF_SETTER(headers, headers_, YES, 1)
}
- (OFDictionary*)headers
{
OF_GETTER(headers, YES)
}
|
︙ | | |
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
+
+
|
OFString *line, *path;
OFMutableDictionary *serverHeaders;
OFDataArray *data;
OFEnumerator *keyEnumerator, *objectEnumerator;
OFString *key, *object, *contentLengthHeader;
int status;
const char *type = NULL;
size_t contentLength = 0;
BOOL chunked;
char *buffer;
size_t bytesReceived;
if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"])
@throw [OFUnsupportedProtocolException exceptionWithClass: isa
URL: URL];
|
︙ | | |
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
-
+
-
+
|
if (requestType == OF_HTTP_REQUEST_TYPE_POST)
type = "POST";
if ([(path = [URL path]) isEqual: @""])
path = @"/";
if ([URL query] != nil)
[sock writeFormat: @"%s %@?%@ HTTP/1.0\r\n",
[sock writeFormat: @"%s %@?%@ HTTP/1.1\r\n",
type, path, [URL query]];
else
[sock writeFormat: @"%s %@ HTTP/1.0\r\n", type, path];
[sock writeFormat: @"%s %@ HTTP/1.1\r\n", type, path];
if ([URL port] == 80)
[sock writeFormat: @"Host: %@\r\n", [URL host]];
else
[sock writeFormat: @"Host: %@:%d\r\n", [URL host],
[URL port]];
|
︙ | | |
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
-
-
-
+
-
-
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
|
/* Work around a bug in lighttpd, see above */
[sock flushWriteBuffer];
[sock setBuffersWrites: NO];
if (requestType == OF_HTTP_REQUEST_TYPE_POST)
[sock writeString: queryString];
/*
* We also need to check for HTTP/1.1 since Apache always declares the
* reply to be HTTP/1.1.
@try {
*/
line = [sock readLine];
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException exceptionWithClass: isa];
}
if (![line hasPrefix: @"HTTP/1.0 "] && ![line hasPrefix: @"HTTP/1.1 "])
@throw [OFInvalidServerReplyException exceptionWithClass: isa];
status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];
serverHeaders = [OFMutableDictionary dictionary];
while ((line = [sock readLine]) != nil) {
for (;;) {
OFString *key, *value;
const char *line_c = [line UTF8String], *tmp;
const char *line_c, *tmp;
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
}
if (line == nil)
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
if ([line isEqual: @""])
break;
line_c = [line UTF8String];
if ((tmp = strchr(line_c, ':')) == NULL)
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
key = [OFString stringWithUTF8String: line_c
length: tmp - line_c];
normalize_key(key);
normalizeKey(key);
do {
tmp++;
} while (*tmp == ' ');
value = [OFString stringWithUTF8String: tmp];
if ((redirects > 0 && (status == 301 || status == 302 ||
status == 303 || status == 307) &&
status == 303) && [key isEqual: @"Location"]) &&
[key isEqual: @"Location"]) &&
(redirectsFromHTTPSToHTTPAllowed ||
[scheme isEqual: @"http"] ||
![value hasPrefix: @"http://"])) {
OFURL *new;
BOOL follow;
new = [OFURL URLWithString: value
|
︙ | | |
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
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
|
367
368
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
|
}
[delegate request: self
didReceiveHeaders: serverHeaders
withStatusCode: status];
data = (storesData ? [OFDataArray dataArray] : nil);
chunked = [[serverHeaders objectForKey: @"Transfer-Encoding"]
isEqual: @"chunked"];
contentLengthHeader = [serverHeaders objectForKey: @"Content-Length"];
if (contentLengthHeader != nil) {
contentLength = (size_t)[contentLengthHeader decimalValue];
if (contentLength > SIZE_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
}
buffer = [self allocMemoryWithSize: of_pagesize];
bytesReceived = 0;
@try {
OFAutoreleasePool *pool2 = [[OFAutoreleasePool alloc] init];
if (chunked) {
for (;;) {
size_t pos, toRead;
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
}
pos = [line
indexOfFirstOccurrenceOfString: @";"];
if (pos != OF_INVALID_INDEX)
line = [line substringWithRange:
of_range(0, pos)];
@try {
toRead =
(size_t)[line hexadecimalValue];
} @catch (OFInvalidFormatException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
}
if (toRead == 0 ||
(contentLengthHeader != nil &&
contentLength >= bytesReceived))
break;
while (toRead > 0) {
size_t length = (toRead < of_pagesize
? toRead : of_pagesize);
length = [sock readNBytes: length
intoBuffer: buffer];
[delegate request: self
didReceiveData: buffer
withLength: length];
[pool2 releaseObjects];
bytesReceived += length;
[data addNItems: length
fromCArray: buffer];
toRead -= length;
}
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
}
if (![line isEqual: @""])
@throw [OFInvalidServerReplyException
exceptionWithClass: isa];
[pool2 releaseObjects];
}
} else {
size_t len;
size_t length;
while ((len = [sock readNBytes: of_pagesize
intoBuffer: buffer]) > 0) {
[delegate request: self
didReceiveData: buffer
withLength: len];
while ((length = [sock readNBytes: of_pagesize
intoBuffer: buffer]) > 0) {
[delegate request: self
didReceiveData: buffer
withLength: length];
[pool2 releaseObjects];
bytesReceived += len;
[data addNItems: len
fromCArray: buffer];
}
bytesReceived += length;
[data addNItems: length
fromCArray: buffer];
if (contentLengthHeader != nil &&
bytesReceived >= contentLength)
break;
}
}
[pool2 release];
} @finally {
[self freeMemory: buffer];
}
if ((contentLengthHeader =
[serverHeaders objectForKey: @"Content-Length"]) != nil) {
intmax_t cl = [contentLengthHeader decimalValue];
[sock close];
if (cl > SIZE_MAX)
@throw [OFOutOfRangeException exceptionWithClass: isa];
/*
* We only want to throw on these status codes as we will throw
* an OFHTTPRequestFailedException for all other status codes
/*
* We only want to throw on these status codes as we will throw an
* OFHTTPRequestFailedException for all other status codes later.
* later.
*/
if (cl != bytesReceived && (status == 200 || status == 301 ||
status == 302 || status == 303))
@throw [OFTruncatedDataException
*/
if (contentLengthHeader != nil && contentLength != bytesReceived &&
(status == 200 || status == 301 || status == 302 || status == 303 ||
status == 307))
@throw [OFTruncatedDataException exceptionWithClass: isa];
exceptionWithClass: isa];
}
[serverHeaders makeImmutable];
result = [[OFHTTPRequestResult alloc] initWithStatusCode: status
headers: serverHeaders
data: data];
if (status != 200 && status != 301 && status != 302 && status != 303)
switch (status) {
case 200:
case 301:
case 302:
case 303:
case 307:
break;
default:
[result release];
@throw [OFHTTPRequestFailedException
exceptionWithClass: isa
HTTPRequest: self
result: result];
}
[pool release];
return [result autorelease];
}
@end
@implementation OFHTTPRequestResult
- initWithStatusCode: (short)status
|
︙ | | |
Modified src/OFMutableArray.h
from [7347712143]
to [7429d32994].
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
+
+
|
* \brief Replaces the object at the specified index with the specified object.
*
* \param index The index of the object to replace
* \param object The replacement object
*/
- (void)replaceObjectAtIndex: (size_t)index
withObject: (id)object;
- (void)setObject: (id)object
atIndexedSubscript: (size_t)index;
/**
* \brief Replaces the first object that has the same address as the specified
* object with the other specified object.
*
* \param oldObject The object to replace
* \param newObject The replacement object
|
︙ | | |
Modified src/OFMutableArray.m
from [46ae62e754]
to [ef22d34f56].
︙ | | |
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
-
+
-
-
-
-
-
-
+
-
-
+
+
|
}
- initWithArray: (OFArray*)array
{
return (id)[[OFMutableArray_adjacent alloc] initWithArray: array];
}
- initWithCArray: (id*)objects
- initWithObjects: (id*)objects
{
return (id)[[OFMutableArray_adjacent alloc] initWithCArray: objects];
}
- initWithCArray: (id*)objects
length: (size_t)length
count: (size_t)count
{
return (id)[[OFMutableArray_adjacent alloc] initWithCArray: objects
length: length];
return (id)[[OFMutableArray_adjacent alloc] initWithObjects: objects
count: count];
}
- initWithSerialization: (OFXMLElement*)element
{
return (id)[[OFMutableArray_adjacent alloc]
initWithSerialization: element];
}
|
︙ | | |
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
+
+
+
+
+
+
+
|
- (void)replaceObjectAtIndex: (size_t)index
withObject: (id)object
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)setObject: (id)object
atIndexedSubscript: (size_t)index
{
[self replaceObjectAtIndex: index
withObject: object];
}
- (void)replaceObject: (id)oldObject
withObject: (id)newObject
{
size_t i, count = [self count];
for (i = 0; i < count; i++) {
|
︙ | | |
Modified src/OFMutableArray_adjacent.m
from [e02a8ee9e6]
to [a923c5af53].
︙ | | |
51
52
53
54
55
56
57
58
59
60
61
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
51
52
53
54
55
56
57
58
59
60
61
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
|
mutations++;
}
- (void)replaceObject: (id)oldObject
withObject: (id)newObject
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++) {
if ([cArray[i] isEqual: oldObject]) {
if ([objects[i] isEqual: oldObject]) {
[newObject retain];
[cArray[i] release];
cArray[i] = newObject;
[objects[i] release];
objects[i] = newObject;
return;
}
}
}
- (void)replaceObjectAtIndex: (size_t)index
withObject: (id)object
{
id *cArray = [array cArray];
id *objects = [array cArray];
id oldObject;
if (index >= [array count])
@throw [OFOutOfRangeException exceptionWithClass: isa];
oldObject = cArray[index];
cArray[index] = [object retain];
oldObject = objects[index];
objects[index] = [object retain];
[oldObject release];
}
- (void)replaceObjectIdenticalTo: (id)oldObject
withObject: (id)newObject
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++) {
if (cArray[i] == oldObject) {
if (objects[i] == oldObject) {
[newObject retain];
[cArray[i] release];
cArray[i] = newObject;
[objects[i] release];
objects[i] = newObject;
return;
}
}
}
- (void)removeObject: (id)object
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++) {
if ([cArray[i] isEqual: object]) {
object = cArray[i];
if ([objects[i] isEqual: object]) {
object = objects[i];
[array removeItemAtIndex: i];
mutations++;
[object release];
return;
}
}
}
- (void)removeObjectIdenticalTo: (id)object
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++) {
if (cArray[i] == object) {
if (objects[i] == object) {
[array removeItemAtIndex: i];
mutations++;
[object release];
return;
}
|
︙ | | |
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
-
+
-
+
-
+
-
+
-
+
-
+
|
[object release];
mutations++;
}
- (void)removeNObjects: (size_t)nObjects
{
id *cArray = [array cArray], *copy;
id *objects = [array cArray], *copy;
size_t i, count = [array count];
if (nObjects > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
copy = [self allocMemoryForNItems: nObjects
ofSize: sizeof(id)];
memcpy(copy, cArray + (count - nObjects), nObjects * sizeof(id));
memcpy(copy, objects + (count - nObjects), nObjects * sizeof(id));
@try {
[array removeNItems: nObjects];
mutations++;
for (i = 0; i < nObjects; i++)
[copy[i] release];
} @finally {
[self freeMemory: copy];
}
}
- (void)removeAllObjects
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++)
[cArray[i] release];
[objects[i] release];
[array removeAllItems];
}
- (void)removeObjectsInRange: (of_range_t)range
{
id *cArray = [array cArray], *copy;
id *objects = [array cArray], *copy;
size_t i, count = [array count];
if (range.length > count - range.start)
@throw [OFOutOfRangeException exceptionWithClass: isa];
copy = [self allocMemoryForNItems: range.length
ofSize: sizeof(id)];
memcpy(copy, cArray + range.start, range.length * sizeof(id));
memcpy(copy, objects + range.start, range.length * sizeof(id));
@try {
[array removeNItems: range.length
atIndex: range.start];
mutations++;
for (i = 0; i < range.length; i++)
|
︙ | | |
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
-
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
|
mutations++;
}
- (void)swapObjectAtIndex: (size_t)index1
withObjectAtIndex: (size_t)index2
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t count = [array count];
id tmp;
if (index1 >= count || index2 >= count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
tmp = cArray[index1];
cArray[index1] = cArray[index2];
cArray[index2] = tmp;
tmp = objects[index1];
objects[index1] = objects[index2];
objects[index2] = tmp;
}
- (void)reverse
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, j, count = [array count];
if (count == 0 || count == 1)
return;
for (i = 0, j = count - 1; i < j; i++, j--) {
id tmp = cArray[i];
cArray[i] = cArray[j];
cArray[j] = tmp;
id tmp = objects[i];
objects[i] = objects[j];
objects[j] = tmp;
}
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
objects: (id*)objects
count: (int)count
{
|
︙ | | |
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
-
+
-
+
-
+
-
+
-
-
+
+
|
initWithArray: self
mutationsPtr: &mutations] autorelease];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
BOOL stop = NO;
unsigned long mutations2 = mutations;
for (i = 0; i < count && !stop; i++) {
if (mutations != mutations2)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: self];
block(cArray[i], i, &stop);
block(objects[i], i, &stop);
}
}
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
id *cArray = [array cArray];
id *objects = [array cArray];
size_t i, count = [array count];
BOOL stop = NO;
unsigned long mutations2 = mutations;
for (i = 0; i < count && !stop; i++) {
id newObject;
if (mutations != mutations2)
@throw [OFEnumerationMutationException
exceptionWithClass: isa
object: self];
newObject = block(cArray[i], i, &stop);
newObject = block(objects[i], i, &stop);
if (newObject == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
[newObject retain];
[cArray[i] release];
cArray[i] = newObject;
[objects[i] release];
objects[i] = newObject;
}
}
#endif
- (void)makeImmutable
{
isa = [OFArray_adjacent class];
}
@end
|
Modified src/OFMutableDictionary.h
from [513d866e37]
to [e2f5552214].
︙ | | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
+
+
|
* A key can be any object that conforms to the OFCopying protocol.
*
* \param key The key to set
* \param object The object to set the key to
*/
- (void)setObject: (id)object
forKey: (id)key;
- (void)setObject: (id)object
forKeyedSubscript: (id)key;
/**
* \brief Removes the object for the specified key from the dictionary.
*
* \param key The key whose object should be removed
*/
- (void)removeObjectForKey: (id)key;
|
︙ | | |
Modified src/OFMutableDictionary.m
from [f8225615a5]
to [9331cf055e].
︙ | | |
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
+
+
+
+
+
+
+
+
+
+
|
- initWithObjects: (OFArray*)objects
forKeys: (OFArray*)keys
{
return (id)[[OFMutableDictionary_hashtable alloc]
initWithObjects: objects
forKeys: keys];
}
- initWithObjects: (id*)objects
forKeys: (id*)keys
count: (size_t)count
{
return (id)[[OFMutableDictionary_hashtable alloc]
initWithObjects: objects
forKeys: keys
count: count];
}
- initWithKeysAndObjects: (id)firstKey, ...
{
id ret;
va_list arguments;
va_start(arguments, firstKey);
|
︙ | | |
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
+
+
+
+
+
+
+
|
- (void)setObject: (id)object
forKey: (id)key
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)setObject: (id)object
forKeyedSubscript: (id)key
{
[self setObject: object
forKey: key];
}
- (void)removeObjectForKey: (id)key
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
|
︙ | | |
Modified src/OFMutableString_UTF8.h
from [593b73ce69]
to [ddae683c1b].
︙ | | |
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
+
+
|
* 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 "OFMutableString.h"
#import "OFString_UTF8.h"
@interface OFMutableString_UTF8: OFMutableString
{
@public
struct of_string_utf8_ivars *restrict s;
struct of_string_utf8_ivars s_store;
}
@end
|
Modified src/OFObject.h
from [38b992ba28]
to [c823dc085d].
︙ | | |
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
|
472
473
474
475
476
477
478
479
480
481
482
483
484
485
|
-
-
-
-
-
-
-
-
-
-
|
*
* This is mostly for debugging purposes.
*
* \return A description for the object
*/
- (OFString*)description;
/**
* \brief Adds a pointer to the object's memory pool.
*
* This is useful to add memory allocated by functions such as asprintf to the
* pool so it gets free'd automatically when the object is deallocated.
*
* \param pointer A pointer to add to the memory pool
*/
- (void)addMemoryToPool: (void*)pointer;
/**
* \brief Allocates memory and stores it in the object's memory pool.
*
* It will be free'd automatically when the object is deallocated.
*
* \param size The size of the memory to allocate
* \return A pointer to the allocated memory
|
︙ | | |
604
605
606
607
608
609
610
611
612
613
614
615
616
|
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
-
+
-
-
+
+
+
|
@end
#import "OFObject+Serialization.h"
#ifdef __cplusplus
extern "C" {
#endif
extern id objc_getProperty(id, SEL, ptrdiff_t, BOOL);
extern size_t of_pagesize;
extern void objc_setProperty(id, SEL, ptrdiff_t, id, BOOL, BOOL);
extern size_t of_pagesize;
extern size_t of_num_cpus;
extern id of_alloc_object(Class class_, size_t extraSize, size_t extraAlignment,
void **extra);
#ifdef __cplusplus
}
#endif
|
Modified src/OFObject.m
from [6045fcc9af]
to [97e6d3c1aa].
︙ | | |
55
56
57
58
59
60
61
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
|
55
56
57
58
59
60
61
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
|
-
-
+
+
-
-
-
+
+
-
-
+
+
+
+
+
+
+
|
#if defined(OF_ATOMIC_OPS)
# import "atomic.h"
#elif defined(OF_THREADS)
# import "threading.h"
#endif
struct pre_ivar {
int32_t retainCount;
void **memoryChunks;
int32_t retainCount;
struct pre_mem *firstMem, *lastMem;
unsigned int memoryChunksSize;
#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS)
of_spinlock_t retainCountSpinlock;
#endif
};
/* Hopefully no arch needs more than 16 bytes padding */
#ifndef __BIGGEST_ALIGNMENT__
struct pre_mem {
struct pre_mem *prev, *next;
# define __BIGGEST_ALIGNMENT__ 16
#endif
id owner;
};
#define PRE_IVAR_ALIGN ((sizeof(struct pre_ivar) + \
(__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1))
#define PRE_IVAR ((struct pre_ivar*)(void*)((char*)self - PRE_IVAR_ALIGN))
#define PRE_MEM_ALIGN ((sizeof(struct pre_mem) + \
(__BIGGEST_ALIGNMENT__ - 1)) & ~(__BIGGEST_ALIGNMENT__ - 1))
#define PRE_MEM(mem) ((struct pre_mem*)(void*)((char*)mem - PRE_MEM_ALIGN))
static struct {
Class isa;
} alloc_failed_exception;
static Class autoreleasePool = Nil;
static SEL cxx_construct = NULL;
static SEL cxx_destruct = NULL;
size_t of_pagesize;
size_t of_num_cpus;
#ifdef NEED_OBJC_SYNC_INIT
extern BOOL objc_sync_init();
#endif
#ifdef NEED_OBJC_PROPERTIES_INIT
extern BOOL objc_properties_init();
|
︙ | | |
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
#ifndef HAVE_OBJC_ENUMERATIONMUTATION
void
objc_enumerationMutation(id object)
{
enumeration_mutation_handler(object);
}
#endif
id
of_alloc_object(Class class, size_t extraSize, size_t extraAlignment,
void **extra)
{
OFObject *instance;
size_t instanceSize;
instanceSize = class_getInstanceSize(class);
if (OF_UNLIKELY(extraAlignment > 0))
extraAlignment = ((instanceSize + extraAlignment - 1) &
~(extraAlignment - 1)) - extraAlignment;
instance = malloc(PRE_IVAR_ALIGN + instanceSize +
extraAlignment + extraSize);
if (OF_UNLIKELY(instance == nil)) {
alloc_failed_exception.isa = [OFAllocFailedException class];
@throw (OFAllocFailedException*)&alloc_failed_exception;
}
((struct pre_ivar*)instance)->retainCount = 1;
((struct pre_ivar*)instance)->firstMem = NULL;
((struct pre_ivar*)instance)->lastMem = NULL;
#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS)
if (OF_UNLIKELY(!of_spinlock_new(
&((struct pre_ivar*)instance)->retainCountSpinlock))) {
free(instance);
@throw [OFInitializationFailedException
exceptionWithClass: class];
}
#endif
instance = (OFObject*)((char*)instance + PRE_IVAR_ALIGN);
instance->isa = class;
memset((char*)instance + sizeof(instance->isa), 0,
instanceSize - sizeof(instance->isa));
if (OF_UNLIKELY(extra != NULL))
*extra = (char*)instance + instanceSize + extraAlignment;
return instance;
}
const char*
_NSPrintForDebugger(id object)
{
return [[object description]
cStringWithEncoding: OF_STRING_ENCODING_NATIVE];
}
|
︙ | | |
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
+
+
+
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
abort();
}
#if defined(_WIN32)
SYSTEM_INFO si;
GetSystemInfo(&si);
of_pagesize = si.dwPageSize;
of_num_cpus = si.dwNumberOfProcessors;
#elif defined(_PSP)
of_pagesize = 4096;
of_num_cpus = 1;
#else
if ((of_pagesize = sysconf(_SC_PAGESIZE)) < 1)
of_pagesize = 4096;
if ((of_num_cpus = sysconf(_SC_NPROCESSORS_CONF)) < 1)
of_num_cpus = 1;
#endif
}
+ (void)initialize
{
}
+ alloc
{
OFObject *instance;
size_t instanceSize = class_getInstanceSize(self);
return of_alloc_object(self, 0, 0, NULL);
if ((instance = calloc(instanceSize + PRE_IVAR_ALIGN, 1)) == NULL) {
alloc_failed_exception.isa = [OFAllocFailedException class];
@throw (OFAllocFailedException*)&alloc_failed_exception;
}
((struct pre_ivar*)instance)->memoryChunks = NULL;
((struct pre_ivar*)instance)->memoryChunksSize = 0;
((struct pre_ivar*)instance)->retainCount = 1;
#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS)
if (!of_spinlock_new(
&((struct pre_ivar*)instance)->retainCountSpinlock)) {
free(instance);
@throw [OFInitializationFailedException
exceptionWithClass: self];
}
#endif
instance = (OFObject*)((char*)instance + PRE_IVAR_ALIGN);
instance->isa = self;
return instance;
}
+ new
{
return [[self alloc] init];
}
|
︙ | | |
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
590
591
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
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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
|
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
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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
+
-
-
+
+
+
-
-
+
+
-
-
-
-
-
+
+
+
-
+
-
-
-
+
-
+
+
+
-
+
+
+
-
-
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
|
- (OFString*)description
{
/* Classes containing data should reimplement this! */
return [OFString stringWithFormat: @"<%@: %p>", [self className], self];
}
- (void)addMemoryToPool: (void*)pointer
{
void **memoryChunks;
unsigned int memoryChunksSize;
memoryChunksSize = PRE_IVAR->memoryChunksSize + 1;
if (UINT_MAX - PRE_IVAR->memoryChunksSize < 1 ||
memoryChunksSize > UINT_MAX / sizeof(void*))
@throw [OFOutOfRangeException exceptionWithClass: isa];
if ((memoryChunks = realloc(PRE_IVAR->memoryChunks,
memoryChunksSize * sizeof(void*))) == NULL)
@throw [OFOutOfMemoryException
exceptionWithClass: isa
requestedSize: memoryChunksSize];
PRE_IVAR->memoryChunks = memoryChunks;
PRE_IVAR->memoryChunks[PRE_IVAR->memoryChunksSize] = pointer;
PRE_IVAR->memoryChunksSize = memoryChunksSize;
}
- (void*)allocMemoryWithSize: (size_t)size
{
void *pointer, **memoryChunks;
void *pointer;
unsigned int memoryChunksSize;
struct pre_mem *preMem;
if (size == 0)
return NULL;
memoryChunksSize = PRE_IVAR->memoryChunksSize + 1;
if (UINT_MAX - PRE_IVAR->memoryChunksSize == 0 ||
if (size > SIZE_MAX - PRE_IVAR_ALIGN)
memoryChunksSize > UINT_MAX / sizeof(void*))
@throw [OFOutOfRangeException exceptionWithClass: isa];
if ((pointer = malloc(size)) == NULL)
if ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL)
@throw [OFOutOfMemoryException exceptionWithClass: isa
requestedSize: size];
preMem = pointer;
preMem->owner = self;
if ((memoryChunks = realloc(PRE_IVAR->memoryChunks,
memoryChunksSize * sizeof(void*))) == NULL) {
preMem->prev = PRE_IVAR->lastMem;
preMem->next = NULL;
free(pointer);
@throw [OFOutOfMemoryException
exceptionWithClass: isa
requestedSize: memoryChunksSize];
}
if (PRE_IVAR->lastMem != NULL)
PRE_IVAR->lastMem->next = preMem;
PRE_IVAR->memoryChunks = memoryChunks;
PRE_IVAR->lastMem = preMem;
PRE_IVAR->memoryChunks[PRE_IVAR->memoryChunksSize] = pointer;
PRE_IVAR->memoryChunksSize = memoryChunksSize;
return pointer;
return (char*)pointer + PRE_MEM_ALIGN;
}
- (void*)allocMemoryForNItems: (size_t)nItems
ofSize: (size_t)size
{
if (nItems == 0 || size == 0)
return NULL;
if (nItems > SIZE_MAX / size)
@throw [OFOutOfRangeException exceptionWithClass: isa];
return [self allocMemoryWithSize: nItems * size];
}
- (void*)resizeMemory: (void*)pointer
toSize: (size_t)size
{
void **iter;
void *new;
struct pre_mem *preMem;
if (pointer == NULL)
return [self allocMemoryWithSize: size];
if (size == 0) {
[self freeMemory: pointer];
return NULL;
}
if (PRE_MEM(pointer)->owner != self)
iter = PRE_IVAR->memoryChunks + PRE_IVAR->memoryChunksSize;
@throw [OFMemoryNotPartOfObjectException
exceptionWithClass: isa
pointer: pointer];
while (iter-- > PRE_IVAR->memoryChunks) {
if (OF_UNLIKELY(*iter == pointer)) {
if (OF_UNLIKELY((pointer = realloc(pointer,
size)) == NULL))
@throw [OFOutOfMemoryException
if ((new = realloc(PRE_MEM(pointer), PRE_MEM_ALIGN + size)) == NULL)
@throw [OFOutOfMemoryException exceptionWithClass: isa
exceptionWithClass: isa
requestedSize: size];
requestedSize: size];
preMem = new;
*iter = pointer;
return pointer;
}
if (preMem != PRE_MEM(pointer)) {
if (preMem->prev != NULL)
preMem->prev->next = preMem;
if (preMem->next != NULL)
preMem->next->prev = preMem;
if (PRE_IVAR->firstMem == PRE_MEM(pointer))
PRE_IVAR->firstMem = preMem;
if (PRE_IVAR->lastMem == PRE_MEM(pointer))
PRE_IVAR->lastMem = preMem;
}
@throw [OFMemoryNotPartOfObjectException exceptionWithClass: isa
pointer: pointer];
return (char*)new + PRE_MEM_ALIGN;
}
- (void*)resizeMemory: (void*)pointer
toNItems: (size_t)nItems
ofSize: (size_t)size
{
if (pointer == NULL)
|
︙ | | |
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
|
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
|
-
-
-
-
-
-
+
+
-
-
-
-
+
+
-
-
-
-
-
+
-
-
+
-
-
+
-
-
-
+
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
-
-
+
-
-
+
-
-
-
-
+
|
return [self resizeMemory: pointer
toSize: nItems * size];
}
- (void)freeMemory: (void*)pointer
{
void **iter, *last, **memoryChunks;
unsigned int i, memoryChunksSize;
if (pointer == NULL)
return;
iter = PRE_IVAR->memoryChunks + PRE_IVAR->memoryChunksSize;
i = PRE_IVAR->memoryChunksSize;
if (PRE_MEM(pointer)->owner != self)
@throw [OFMemoryNotPartOfObjectException
while (iter-- > PRE_IVAR->memoryChunks) {
i--;
if (OF_UNLIKELY(*iter == pointer)) {
exceptionWithClass: isa
pointer: pointer];
memoryChunksSize = PRE_IVAR->memoryChunksSize - 1;
last = PRE_IVAR->memoryChunks[memoryChunksSize];
assert(PRE_IVAR->memoryChunksSize != 0 &&
memoryChunksSize <= UINT_MAX / sizeof(void*));
if (PRE_MEM(pointer)->prev != NULL)
if (OF_UNLIKELY(memoryChunksSize == 0)) {
free(pointer);
PRE_MEM(pointer)->prev->next = PRE_MEM(pointer)->next;
free(PRE_IVAR->memoryChunks);
if (PRE_MEM(pointer)->next != NULL)
PRE_IVAR->memoryChunks = NULL;
PRE_IVAR->memoryChunksSize = 0;
PRE_MEM(pointer)->next->prev = PRE_MEM(pointer)->prev;
return;
}
free(pointer);
PRE_IVAR->memoryChunks[i] = last;
PRE_IVAR->memoryChunksSize = memoryChunksSize;
if (PRE_IVAR->firstMem == PRE_MEM(pointer))
PRE_IVAR->firstMem = PRE_MEM(pointer)->next;
if (PRE_IVAR->lastMem == PRE_MEM(pointer))
PRE_IVAR->lastMem = PRE_MEM(pointer)->prev;
if (OF_UNLIKELY((memoryChunks = realloc(
PRE_IVAR->memoryChunks, memoryChunksSize *
sizeof(void*))) == NULL))
return;
/* To detect double-free */
PRE_IVAR->memoryChunks = memoryChunks;
PRE_MEM(pointer)->owner = nil;
return;
}
}
@throw [OFMemoryNotPartOfObjectException exceptionWithClass: isa
pointer: pointer];
free(PRE_MEM(pointer));
}
- retain
{
#if defined(OF_ATOMIC_OPS)
of_atomic_inc_32(&PRE_IVAR->retainCount);
#elif defined(OF_THREADS)
|
︙ | | |
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
|
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
|
-
+
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
|
return NO;
}
- (void)dealloc
{
Class class;
void (*last)(id, SEL) = NULL;
void **iter;
struct pre_mem *iter;
for (class = isa; class != Nil; class = class_getSuperclass(class)) {
void (*destruct)(id, SEL);
if ([class instancesRespondToSelector: cxx_destruct]) {
if ((destruct = (void(*)(id, SEL))[class
instanceMethodForSelector: cxx_destruct]) != last)
destruct(self, cxx_destruct);
last = destruct;
} else
break;
}
iter = PRE_IVAR->memoryChunks + PRE_IVAR->memoryChunksSize;
while (iter-- > PRE_IVAR->memoryChunks)
free(*iter);
iter = PRE_IVAR->firstMem;
while (iter != NULL) {
struct pre_mem *next = iter->next;
/*
* We can use owner as a sentinel to prevent exploitation in
* case there is a buffer underflow somewhere.
*/
if (iter->owner != self)
abort();
if (PRE_IVAR->memoryChunks != NULL)
free(PRE_IVAR->memoryChunks);
free(iter);
iter = next;
}
free((char*)self - PRE_IVAR_ALIGN);
}
/* Required to use properties with the Apple runtime */
- copyWithZone: (void*)zone
{
|
︙ | | |
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
|
842
843
844
845
846
847
848
849
850
851
852
853
854
855
|
-
-
-
-
-
-
|
return [(id)self mutableCopy];
}
/*
* Those are needed as the root class is the superclass of the root class's
* metaclass and thus instance methods can be sent to class objects as well.
*/
+ (void)addMemoryToPool: (void*)pointer
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
+ (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
+ (void*)allocMemoryForNItems: (size_t)nItems
|
︙ | | |
Modified src/OFProcess.m
from [39656659f7]
to [53a70ada66].
︙ | | |
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
|
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
|
-
+
-
+
|
#ifndef _WIN32
if (pipe(readPipe) != 0 || pipe(writePipe) != 0)
@throw [OFInitializationFailedException
exceptionWithClass: isa];
switch ((pid = fork())) {
case 0:;
OFString **cArray = [arguments cArray];
OFString **objects = [arguments objects];
size_t i, count = [arguments count];
char **argv;
argv = [self allocMemoryForNItems: count + 2
ofSize: sizeof(char*)];
argv[0] = (char*)[programName cStringWithEncoding:
OF_STRING_ENCODING_NATIVE];
for (i = 0; i < count; i++)
argv[i + 1] = (char*)[cArray[i]
argv[i + 1] = (char*)[objects[i]
cStringWithEncoding:
OF_STRING_ENCODING_NATIVE];
argv[i + 1] = NULL;
close(readPipe[0]);
close(writePipe[1]);
|
︙ | | |
Modified src/OFSet_hashtable.m
from [44df8e110b]
to [2beeed38e8].
︙ | | |
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
-
+
-
+
|
- initWithArray: (OFArray*)array
{
self = [self init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFNumber *one = [OFNumber numberWithSize: 1];
id *cArray = [array cArray];
id *objects = [array objects];
size_t i, count = [array count];
for (i = 0; i < count; i++)
[dictionary _setObject: one
forKey: cArray[i]
forKey: objects[i]
copyKey: NO];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
Modified src/OFStreamObserver.m
from [ff67a9acd7]
to [89d321be6d].
︙ | | |
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
-
+
-
+
|
selector: _cmd];
}
- (void)_processQueue
{
[mutex lock];
@try {
OFStream **queueCArray = [queue cArray];
OFStream **queueObjects = [queue objects];
int *queueInfoCArray = [queueInfo cArray];
int *queueFDsCArray = [queueFDs cArray];
size_t i, count = [queue count];
for (i = 0; i < count; i++) {
OFStream *stream = queueCArray[i];
OFStream *stream = queueObjects[i];
int action = queueInfoCArray[i];
int fd = queueFDsCArray[i];
if ((action & QUEUE_ACTION) == QUEUE_ADD) {
if (fd > maxFD) {
maxFD = fd;
FDToStream = [self
|
︙ | | |
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
-
+
-
-
-
+
+
+
|
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (BOOL)_processCache
{
OFAutoreleasePool *pool;
OFStream **cArray = [readStreams cArray];
OFStream **objects = [readStreams objects];
size_t i, count = [readStreams count];
BOOL foundInCache = NO;
pool = [[OFAutoreleasePool alloc] init];
for (i = 0; i < count; i++) {
if ([cArray[i] pendingBytes] > 0 &&
![cArray[i] _isWaitingForDelimiter]) {
[delegate streamIsReadyForReading: cArray[i]];
if ([objects[i] pendingBytes] > 0 &&
![objects[i] _isWaitingForDelimiter]) {
[delegate streamIsReadyForReading: objects[i]];
foundInCache = YES;
[pool releaseObjects];
}
}
[pool release];
|
︙ | | |
Modified src/OFStreamObserver_select.m
from [a5aa0c34fc]
to [17f835ff3b].
︙ | | |
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
-
+
|
if (!FD_ISSET(fd, &readFDs))
FD_CLR(fd, &exceptFDs);
}
- (BOOL)observeWithTimeout: (int)timeout
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFStream **cArray;
OFStream **objects;
fd_set readFDs_;
fd_set writeFDs_;
fd_set exceptFDs_;
struct timeval time;
size_t i, count;
[self _processQueue];
|
︙ | | |
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#ifndef _WIN32
assert(read(cancelFD[0], &buffer, 1) > 0);
#else
assert(recvfrom(cancelFD[0], &buffer, 1, 0, NULL, NULL) > 0);
#endif
}
cArray = [readStreams cArray];
objects = [readStreams objects];
count = [readStreams count];
for (i = 0; i < count; i++) {
int fileDescriptor = [cArray[i] fileDescriptor];
int fileDescriptor = [objects[i] fileDescriptor];
if (FD_ISSET(fileDescriptor, &readFDs_)) {
[delegate streamIsReadyForReading: cArray[i]];
[delegate streamIsReadyForReading: objects[i]];
[pool releaseObjects];
}
if (FD_ISSET(fileDescriptor, &exceptFDs_)) {
[delegate streamDidReceiveException: cArray[i]];
[delegate streamDidReceiveException: objects[i]];
[pool releaseObjects];
/*
* Prevent calling it twice in case the FD is in both
* sets.
*/
FD_CLR(fileDescriptor, &exceptFDs_);
}
}
cArray = [writeStreams cArray];
objects = [writeStreams objects];
count = [writeStreams count];
for (i = 0; i < count; i++) {
int fileDescriptor = [cArray[i] fileDescriptor];
int fileDescriptor = [objects[i] fileDescriptor];
if (FD_ISSET(fileDescriptor, &writeFDs_)) {
[delegate streamIsReadyForWriting: cArray[i]];
[delegate streamIsReadyForWriting: objects[i]];
[pool releaseObjects];
}
if (FD_ISSET(fileDescriptor, &exceptFDs_)) {
[delegate streamDidReceiveException: cArray[i]];
[delegate streamDidReceiveException: objects[i]];
[pool releaseObjects];
}
}
[pool release];
return YES;
}
@end
|
Modified src/OFString.m
from [f2bf50723c]
to [bcea8a4ed5].
︙ | | |
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
- init
{
return (id)[[OFString_UTF8 alloc] init];
}
- initWithUTF8String: (const char*)UTF8String
{
id string;
size_t length;
void *storage;
length = strlen(UTF8String);
string = of_alloc_object([OFString_UTF8 class],
length + 1, 1, &storage);
return (id)[[OFString_UTF8 alloc] initWithUTF8String: UTF8String];
return (id)[string _initWithUTF8String: UTF8String
length: length
storage: storage];
}
- initWithUTF8String: (const char*)UTF8String
length: (size_t)UTF8StringLength
{
id string;
void *storage;
string = of_alloc_object([OFString_UTF8 class],
UTF8StringLength + 1, 1, &storage);
return (id)[[OFString_UTF8 alloc] initWithUTF8String: UTF8String
length: UTF8StringLength];
return (id)[string _initWithUTF8String: UTF8String
length: UTF8StringLength
storage: storage];
}
- initWithCString: (const char*)cString
encoding: (of_string_encoding_t)encoding
{
if (encoding == OF_STRING_ENCODING_UTF_8) {
id string;
size_t length;
void *storage;
length = strlen(cString);
string = of_alloc_object([OFString_UTF8 class],
length + 1, 1, &storage);
return (id)[string _initWithUTF8String: cString
length: length
storage: storage];
}
return (id)[[OFString_UTF8 alloc] initWithCString: cString
encoding: encoding];
}
- initWithCString: (const char*)cString
encoding: (of_string_encoding_t)encoding
length: (size_t)cStringLength
{
if (encoding == OF_STRING_ENCODING_UTF_8) {
id string;
void *storage;
string = of_alloc_object([OFString_UTF8 class],
cStringLength + 1, 1, &storage);
return (id)[string _initWithUTF8String: cString
length: cStringLength
storage: storage];
}
return (id)[[OFString_UTF8 alloc] initWithCString: cString
encoding: encoding
length: cStringLength];
}
- initWithString: (OFString*)string
{
|
︙ | | |
Modified src/OFString_UTF8.h
from [958573e473]
to [f6988d5f2e].
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
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
|
+
+
+
+
+
+
+
+
+
+
+
+
|
*/
#import "OFString.h"
@interface OFString_UTF8: OFString
{
@public
/*
* A pointer to the actual data.
*
* Since constant strings don't have s_store, they have to malloc it on
* the first access. Strings created at runtime just set the pointer to
* &s_store.
*/
struct of_string_utf8_ivars {
char *cString;
size_t cStringLength;
BOOL UTF8;
size_t length;
BOOL hashed;
uint32_t hash;
} *restrict s;
struct of_string_utf8_ivars s_store;
}
- _initWithUTF8String: (const char*)UTF8String
length: (size_t)UTF8StringLength
storage: (char*)storage;
@end
|
Modified src/OFString_UTF8.m
from [df8f106867]
to [03beefc292].
︙ | | |
60
61
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
103
104
|
60
61
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
|
@implementation OFString_UTF8
- init
{
self = [super init];
@try {
s = [self allocMemoryWithSize: sizeof(*s)];
s = &s_store;
memset(s, 0, sizeof(*s));
s->cString = [self allocMemoryWithSize: 1];
s->cString[0] = '\0';
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- _initWithUTF8String: (const char*)UTF8String
length: (size_t)UTF8StringLength
storage: (char*)storage
{
self = [super init];
@try {
if (UTF8StringLength >= 3 &&
!memcmp(UTF8String, "\xEF\xBB\xBF", 3)) {
UTF8String += 3;
UTF8StringLength -= 3;
}
s = &s_store;
s->cString = storage;
s->cStringLength = UTF8StringLength;
switch (of_string_check_utf8(UTF8String, UTF8StringLength,
&s->length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
memcpy(s->cString, UTF8String, UTF8StringLength);
s->cString[UTF8StringLength] = 0;
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithCString: (const char*)cString
encoding: (of_string_encoding_t)encoding
length: (size_t)cStringLength
{
self = [super init];
@try {
size_t i, j;
const uint16_t *table;
if (encoding == OF_STRING_ENCODING_UTF_8 &&
cStringLength >= 3 && !memcmp(cString, "\xEF\xBB\xBF", 3)) {
cString += 3;
cStringLength -= 3;
}
s = [self allocMemoryWithSize: sizeof(*s)];
s = &s_store;
memset(s, 0, sizeof(*s));
s->cString = [self allocMemoryWithSize: cStringLength + 1];
s->cStringLength = cStringLength;
if (encoding == OF_STRING_ENCODING_UTF_8 ||
encoding == OF_STRING_ENCODING_ASCII) {
switch (of_string_check_utf8(cString, cStringLength,
|
︙ | | |
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
-
+
-
|
}
- initWithString: (OFString*)string
{
self = [super init];
@try {
s = [self allocMemoryWithSize: sizeof(*s)];
s = &s_store;
memset(s, 0, sizeof(*s));
s->cStringLength = [string UTF8StringLength];
if ([string isKindOfClass: [OFString_UTF8 class]] ||
[string isKindOfClass: [OFMutableString_UTF8 class]])
s->UTF8 = ((OFString_UTF8*)string)->s->UTF8;
else
|
︙ | | |
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
-
+
-
|
} else if (length > 0 && *string == 0xFFFE0000) {
swap = YES;
string++;
length--;
} else if (byteOrder != OF_ENDIANESS_NATIVE)
swap = YES;
s = [self allocMemoryWithSize: sizeof(*s)];
s = &s_store;
memset(s, 0, sizeof(*s));
s->cStringLength = length;
s->cString = [self allocMemoryWithSize: (length * 4) + 1];
s->length = length;
for (i = 0; i < length; i++) {
char buffer[4];
|
︙ | | |
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
-
+
-
|
} else if (length > 0 && *string == 0xFFFE) {
swap = YES;
string++;
length--;
} else if (byteOrder != OF_ENDIANESS_NATIVE)
swap = YES;
s = [self allocMemoryWithSize: sizeof(*s)];
s = &s_store;
memset(s, 0, sizeof(*s));
s->cStringLength = length;
s->cString = [self allocMemoryWithSize: (length * 4) + 1];
s->length = length;
for (i = 0; i < length; i++) {
char buffer[4];
|
︙ | | |
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
|
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
|
+
-
+
-
-
-
+
+
-
-
+
+
-
-
-
+
+
+
+
+
-
-
+
-
|
- initWithFormat: (OFConstantString*)format
arguments: (va_list)arguments
{
self = [super init];
@try {
char *tmp;
int cStringLength;
if (format == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
s = [self allocMemoryWithSize: sizeof(*s)];
s = &s_store;
memset(s, 0, sizeof(*s));
if ((cStringLength = of_vasprintf(&s->cString,
[format UTF8String], arguments)) == -1)
if ((cStringLength = of_vasprintf(&tmp, [format UTF8String],
arguments)) == -1)
@throw [OFInvalidFormatException
exceptionWithClass: isa];
s->cStringLength = cStringLength;
@try {
switch (of_string_check_utf8(s->cString,
cStringLength, &s->length)) {
switch (of_string_check_utf8(tmp, cStringLength,
&s->length)) {
case 1:
s->UTF8 = YES;
break;
case -1:
@throw [OFInvalidEncodingException
exceptionWithClass: isa];
}
[self addMemoryToPool: s->cString];
} @catch (id e) {
free(s->cString);
s->cString = [self
allocMemoryWithSize: cStringLength + 1];
memcpy(s->cString, tmp, cStringLength + 1);
} @finally {
free(tmp);
@throw e;
}
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- initWithPath: (OFString*)firstComponent
arguments: (va_list)arguments
{
self = [super init];
@try {
OFString *component;
size_t i, cStringLength;
va_list argumentsCopy;
s = [self allocMemoryWithSize: sizeof(*s)];
s = &s_store;
memset(s, 0, sizeof(*s));
s->cStringLength = [firstComponent UTF8StringLength];
if ([firstComponent isKindOfClass: [OFString_UTF8 class]] ||
[firstComponent isKindOfClass:
[OFMutableString_UTF8 class]])
s->UTF8 = ((OFString_UTF8*)firstComponent)->s->UTF8;
|
︙ | | |
Modified src/OFTCPSocket.m
from [34d16710ab]
to [43ccdbbf0d].
︙ | | |
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
-
+
|
[SOCKS5Host release];
[super dealloc];
}
- (void)setSOCKS5Host: (OFString*)host
{
OF_SETTER(SOCKS5Host, host, YES, YES)
OF_SETTER(SOCKS5Host, host, YES, 1)
}
- (OFString*)SOCKS5Host
{
OF_GETTER(SOCKS5Host, YES)
}
|
︙ | | |
Added src/OFThreadPool.h version [2701771c31].