Browse code

Try Travis integration on Github. Use smarter mulle-bootstrap to integrate google-toolbox automatically.

Nat! authored on 10/03/2016 14:09:03
Showing 10 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,2 @@
0
+http://google-toolbox-for-mac.googlecode.com/svn/trunk/;google-toolbox-for-mac
1
+
0 2
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+svn
... ...
@@ -13,3 +13,7 @@ github*.json
13 13
 google-toolbox-for-mac/
14 14
 *.xxx
15 15
 tests/compare-parse-speed-to-unarchive-speed.sh
16
+.bootstrap.auto/
17
+.bootstrap.local/
18
+dependencies/
19
+.repos/
16 20
new file mode 100644
... ...
@@ -0,0 +1,11 @@
0
+language: objective-c
1
+
2
+before_install:
3
+  - brew tap mulle-kybernetik/software
4
+  - brew install mulle-bootstrap
5
+
6
+before_script: mulle-bootstrap -y
7
+
8
+script: xcodebuild -target "OSX"
9
+
10
+after_success: (cd tests ; ./run-all-scion-tests.sh )
... ...
@@ -1,6 +1,7 @@
1 1
 Mac OS X
2 2
 ========
3 3
 
4
+	mulle-bootstrap
4 5
 	./install.sh OSX
5 6
 
6 7
 
... ...
@@ -13,6 +14,7 @@ It will also produce the **mulle-scion** executable. This will place the Framewo
13 13
 iOS
14 14
 =====
15 15
 
16
+	mulle-bootstrap
16 17
 	xcodebuild -target iOS
17 18
 
18 19
 to produce a static library libMulleScion.a with a set of include headers.
... ...
@@ -41,7 +43,7 @@ mulle-bootstrap
41 41
       
42 42
 to your
43 43
 
44
-      .bootstrap/gits
44
+      .bootstrap/repositories
45 45
 
46 46
 and say
47 47
 
... ...
@@ -7,17 +7,6 @@
7 7
 	objects = {
8 8
 
9 9
 /* Begin PBXAggregateTarget section */
10
-		415DA59D182BBC8200F654F7 /* grab google-toolbox-for-mac from code.google.com */ = {
11
-			isa = PBXAggregateTarget;
12
-			buildConfigurationList = 415DA59E182BBC8200F654F7 /* Build configuration list for PBXAggregateTarget "grab google-toolbox-for-mac from code.google.com" */;
13
-			buildPhases = (
14
-				415DA5A2182BBC9300F654F7 /* ShellScript */,
15
-			);
16
-			dependencies = (
17
-			);
18
-			name = "grab google-toolbox-for-mac from code.google.com";
19
-			productName = "grab google-toolbox-for-mac from code.google.com";
20
-		};
21 10
 		415DA5A5182BC9E300F654F7 /* All */ = {
22 11
 			isa = PBXAggregateTarget;
23 12
 			buildConfigurationList = 415DA5A6182BC9E300F654F7 /* Build configuration list for PBXAggregateTarget "All" */;
... ...
@@ -248,13 +237,6 @@
248 248
 			remoteGlobalIDString = 41FAED68182D275E002CD114;
249 249
 			remoteInfo = "MulleScionFoundation (OSX Library)";
250 250
 		};
251
-		411EEABC182D315200361ADF /* PBXContainerItemProxy */ = {
252
-			isa = PBXContainerItemProxy;
253
-			containerPortal = 41764B8416DA511200560FCF /* Project object */;
254
-			proxyType = 1;
255
-			remoteGlobalIDString = 415DA59D182BBC8200F654F7;
256
-			remoteInfo = "grab google-toolbox-for-mac from code.google.com";
257
-		};
258 251
 		4146F1F2182D31A80020594C /* PBXContainerItemProxy */ = {
259 252
 			isa = PBXContainerItemProxy;
260 253
 			containerPortal = 41764B8416DA511200560FCF /* Project object */;
... ...
@@ -416,13 +398,6 @@
416 416
 			remoteGlobalIDString = 41FAED68182D275E002CD114;
417 417
 			remoteInfo = "MulleScionFoundation (OSX Library)";
418 418
 		};
419
-		41FAEDDB182D283B002CD114 /* PBXContainerItemProxy */ = {
420
-			isa = PBXContainerItemProxy;
421
-			containerPortal = 41764B8416DA511200560FCF /* Project object */;
422
-			proxyType = 1;
423
-			remoteGlobalIDString = 415DA59D182BBC8200F654F7;
424
-			remoteInfo = "grab google-toolbox-for-mac from code.google.com";
425
-		};
426 419
 		41FAEE09182D28C4002CD114 /* PBXContainerItemProxy */ = {
427 420
 			isa = PBXContainerItemProxy;
428 421
 			containerPortal = 41764B8416DA511200560FCF /* Project object */;
... ...
@@ -1196,7 +1171,6 @@
1196 1196
 			buildRules = (
1197 1197
 			);
1198 1198
 			dependencies = (
1199
-				411EEABD182D315200361ADF /* PBXTargetDependency */,
1200 1199
 			);
1201 1200
 			name = "MulleScionFoundation (iOS Library)";
1202 1201
 			productName = "MulleScion (iOS Library)";
... ...
@@ -1358,7 +1332,6 @@
1358 1358
 			buildRules = (
1359 1359
 			);
1360 1360
 			dependencies = (
1361
-				41FAEDDC182D283B002CD114 /* PBXTargetDependency */,
1362 1361
 			);
1363 1362
 			name = "MulleScionFoundation (OSX Library)";
1364 1363
 			productName = "MulleScionFoundation (OSX Library)";
... ...
@@ -1402,7 +1375,6 @@
1402 1402
 				412E7FD0182D2F80008A7FCC /* MulleScionGraphviz (iOS Library) */,
1403 1403
 				41EC013A182D301A00A17DBD /* MulleScionParser (iOS Library) */,
1404 1404
 				411EEA8B182D30B600361ADF /* MulleScionPrinter (iOS Library) */,
1405
-				415DA59D182BBC8200F654F7 /* grab google-toolbox-for-mac from code.google.com */,
1406 1405
 			);
1407 1406
 		};
1408 1407
 /* End PBXProject section */
... ...
@@ -1466,20 +1438,6 @@
1466 1466
 			shellScript = "DIR=\"${OBJROOT}/UninstalledProducts\"\nLIB=\"${TARGET_BUILD_DIR}/${EXECUTABLE_PATH}\"\n\nCHILDREN=\"MulleScionFoundation MulleScionParser MulleScionPrinter\"\n\n# first remove it otherwise libtool can choke\n# rm \"${DIR}/${EXECUTABLE_PATH}\" 2> /dev/null\n\n# libtool call looks dangerous but worked for me\nfor CHILD in $CHILDREN\ndo\n    CHILDPATH=\"${DIR}/lib${CHILD}.a\"\n    if [ ! -f \"${CHILDPATH}\" ]\n    then\n       CHILDPATH=\"${TARGET_BUILD_DIR}/lib${CHILD}.a\"\n    fi\n\n    echo \"Adding lib${CHILD}.a to ${LIB}\"\n    libtool -s -o \"$LIB\" \"$LIB\" \"${CHILDPATH}\"\n    if [ $? -ne 0 ]\n    then\n       echo \"libtool failed\"\n       exit 1\n    fi\ndone\n";
1467 1467
 			showEnvVarsInLog = 0;
1468 1468
 		};
1469
-		415DA5A2182BBC9300F654F7 /* ShellScript */ = {
1470
-			isa = PBXShellScriptBuildPhase;
1471
-			buildActionMask = 2147483647;
1472
-			files = (
1473
-			);
1474
-			inputPaths = (
1475
-			);
1476
-			outputPaths = (
1477
-			);
1478
-			runOnlyForDeploymentPostprocessing = 0;
1479
-			shellPath = /bin/sh;
1480
-			shellScript = "if [ ! -d \"$PROJECT_DIR\"/google-toolbox-for-mac ]\nthen\n( cd \"$PROJECT_DIR\" ;\n  svn checkout http://google-toolbox-for-mac.googlecode.com/svn/trunk/ google-toolbox-for-mac\n)\n\nfi\n\n# could optionally also \"update\" tidy\n\n";
1481
-			showEnvVarsInLog = 0;
1482
-		};
1483 1469
 		41741ADD18303A560065E5FD /* Remove Library */ = {
1484 1470
 			isa = PBXShellScriptBuildPhase;
1485 1471
 			buildActionMask = 2147483647;
... ...
@@ -1654,11 +1612,6 @@
1654 1654
 			target = 41FAED68182D275E002CD114 /* MulleScionFoundation (OSX Library) */;
1655 1655
 			targetProxy = 410636961BBA8256008B84AC /* PBXContainerItemProxy */;
1656 1656
 		};
1657
-		411EEABD182D315200361ADF /* PBXTargetDependency */ = {
1658
-			isa = PBXTargetDependency;
1659
-			target = 415DA59D182BBC8200F654F7 /* grab google-toolbox-for-mac from code.google.com */;
1660
-			targetProxy = 411EEABC182D315200361ADF /* PBXContainerItemProxy */;
1661
-		};
1662 1657
 		4146F1F3182D31A80020594C /* PBXTargetDependency */ = {
1663 1658
 			isa = PBXTargetDependency;
1664 1659
 			target = 411EEAA6182D311F00361ADF /* MulleScionFoundation (iOS Library) */;
... ...
@@ -1774,11 +1727,6 @@
1774 1774
 			target = 41FAED68182D275E002CD114 /* MulleScionFoundation (OSX Library) */;
1775 1775
 			targetProxy = 41FAEDD9182D2834002CD114 /* PBXContainerItemProxy */;
1776 1776
 		};
1777
-		41FAEDDC182D283B002CD114 /* PBXTargetDependency */ = {
1778
-			isa = PBXTargetDependency;
1779
-			target = 415DA59D182BBC8200F654F7 /* grab google-toolbox-for-mac from code.google.com */;
1780
-			targetProxy = 41FAEDDB182D283B002CD114 /* PBXContainerItemProxy */;
1781
-		};
1782 1777
 		41FAEE0A182D28C4002CD114 /* PBXTargetDependency */ = {
1783 1778
 			isa = PBXTargetDependency;
1784 1779
 			target = 41FAED68182D275E002CD114 /* MulleScionFoundation (OSX Library) */;
... ...
@@ -1917,28 +1865,6 @@
1917 1917
 			};
1918 1918
 			name = Profile;
1919 1919
 		};
1920
-		415DA59F182BBC8200F654F7 /* Debug */ = {
1921
-			isa = XCBuildConfiguration;
1922
-			buildSettings = {
1923
-				PRODUCT_NAME = "$(TARGET_NAME)";
1924
-			};
1925
-			name = Debug;
1926
-		};
1927
-		415DA5A0182BBC8200F654F7 /* Release */ = {
1928
-			isa = XCBuildConfiguration;
1929
-			buildSettings = {
1930
-				PRODUCT_NAME = "$(TARGET_NAME)";
1931
-				XXX_FLAGS = "-ObjC -xxx";
1932
-			};
1933
-			name = Release;
1934
-		};
1935
-		415DA5A1182BBC8200F654F7 /* Profile */ = {
1936
-			isa = XCBuildConfiguration;
1937
-			buildSettings = {
1938
-				PRODUCT_NAME = "$(TARGET_NAME)";
1939
-			};
1940
-			name = Profile;
1941
-		};
1942 1920
 		415DA5A7182BC9E300F654F7 /* Debug */ = {
1943 1921
 			isa = XCBuildConfiguration;
1944 1922
 			buildSettings = {
... ...
@@ -2411,16 +2337,6 @@
2411 2411
 			defaultConfigurationIsVisible = 0;
2412 2412
 			defaultConfigurationName = Release;
2413 2413
 		};
2414
-		415DA59E182BBC8200F654F7 /* Build configuration list for PBXAggregateTarget "grab google-toolbox-for-mac from code.google.com" */ = {
2415
-			isa = XCConfigurationList;
2416
-			buildConfigurations = (
2417
-				415DA59F182BBC8200F654F7 /* Debug */,
2418
-				415DA5A0182BBC8200F654F7 /* Release */,
2419
-				415DA5A1182BBC8200F654F7 /* Profile */,
2420
-			);
2421
-			defaultConfigurationIsVisible = 0;
2422
-			defaultConfigurationName = Release;
2423
-		};
2424 2414
 		415DA5A6182BC9E300F654F7 /* Build configuration list for PBXAggregateTarget "All" */ = {
2425 2415
 			isa = XCConfigurationList;
2426 2416
 			buildConfigurations = (
... ...
@@ -1,5 +1,5 @@
1 1
 #! /bin/sh
2
-# 
2
+#
3 3
 # Generate a formula for mulle-scion stand alone
4 4
 #
5 5
 PROJECT=MulleScion
... ...
@@ -20,7 +20,7 @@ TMPARCHIVE="/tmp/${PROJECT}-${VERSION}-archive"
20 20
 if [ ! -f  "${TMPARCHIVE}" ]
21 21
 then
22 22
    curl -s -L -o "${TMPARCHIVE}" "${ARCHIVEURL}"
23
-   if [ $? -ne 0 -o ! -f "${TMPARCHIVE}" ] 
23
+   if [ $? -ne 0 -o ! -f "${TMPARCHIVE}" ]
24 24
    then
25 25
       echo "Download failed" >&2
26 26
       exit 1
... ...
@@ -30,7 +30,7 @@ else
30 30
 fi
31 31
 
32 32
 #
33
-# anything less than 17 KB is wrong 
33
+# anything less than 17 KB is wrong
34 34
 #
35 35
 size=`du -k "${TMPARCHIVE}" | awk '{ print $ 1}'`
36 36
 if [ $size -lt 17 ]
... ...
@@ -43,20 +43,22 @@ fi
43 43
 
44 44
 HASH=`shasum -p -a 256 "${TMPARCHIVE}" | awk '{ print $1 }'`
45 45
 
46
-cat <<EOF  
46
+cat <<EOF
47 47
 class ${PROJECT} < Formula
48 48
   homepage "${HOMEPAGE}"
49
-  desc "${DESC)"
49
+  desc "${DESC}"
50 50
   url "${ARCHIVEURL}"
51 51
   version "${VERSION}"
52 52
   sha256 "${HASH}"
53 53
 
54
+  depends_on "mulle-bootstrap"
54 55
   depends_on :xcode => :build
55 56
   depends_on :macos => :snow_leopard
56 57
 
57 58
 #  depends_on "zlib"
58 59
   def install
59
-     xcodebuild, "-target", "${TARGET}", "DEPLOYMENT_LOCATION=YES", "SYMROOT=build", "DSTROOT=/", "INSTALL_PATH=#{bin}"
60
+     system "mulle-bootstrap"
61
+     xcodebuild, "install", "-target", "${TARGET}", "DSTROOT=/", "INSTALL_PATH=#{bin}"
60 62
   end
61 63
 
62 64
   test do
63 65
deleted file mode 100644
... ...
@@ -1,66 +0,0 @@
1
-//
2
-//  GTMNSString+HTML.h
3
-//  Dealing with NSStrings that contain HTML
4
-//
5
-//  Copyright 2006-2008 Google Inc.
6
-//
7
-//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
-//  use this file except in compliance with the License.  You may obtain a copy
9
-//  of the License at
10
-// 
11
-//  http://www.apache.org/licenses/LICENSE-2.0
12
-// 
13
-//  Unless required by applicable law or agreed to in writing, software
14
-//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
-//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
16
-//  License for the specific language governing permissions and limitations under
17
-//  the License.
18
-//
19
-
20
-#import <Foundation/Foundation.h>
21
-
22
-/// Utilities for NSStrings containing HTML
23
-@interface NSString (GTMNSStringHTMLAdditions)
24
-
25
-/// Get a string where internal characters that need escaping for HTML are escaped 
26
-//
27
-///  For example, '&' become '&amp;'. This will only cover characters from table
28
-///  A.2.2 of http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters
29
-///  which is what you want for a unicode encoded webpage. If you have a ascii
30
-///  or non-encoded webpage, please use stringByEscapingAsciiHTML which will
31
-///  encode all characters.
32
-///
33
-/// For obvious reasons this call is only safe once.
34
-//
35
-//  Returns:
36
-//    Autoreleased NSString
37
-//
38
-- (NSString *)gtm_stringByEscapingForHTML;
39
-
40
-/// Get a string where internal characters that need escaping for HTML are escaped 
41
-//
42
-///  For example, '&' become '&amp;'
43
-///  All non-mapped characters (unicode that don't have a &keyword; mapping)
44
-///  will be converted to the appropriate &#xxx; value. If your webpage is
45
-///  unicode encoded (UTF16 or UTF8) use stringByEscapingHTML instead as it is
46
-///  faster, and produces less bloated and more readable HTML (as long as you
47
-///  are using a unicode compliant HTML reader).
48
-///
49
-/// For obvious reasons this call is only safe once.
50
-//
51
-//  Returns:
52
-//    Autoreleased NSString
53
-//
54
-- (NSString *)gtm_stringByEscapingForAsciiHTML;
55
-
56
-/// Get a string where internal characters that are escaped for HTML are unescaped 
57
-//
58
-///  For example, '&amp;' becomes '&'
59
-///  Handles &#32; and &#x32; cases as well
60
-///
61
-//  Returns:
62
-//    Autoreleased NSString
63
-//
64
-- (NSString *)gtm_stringByUnescapingFromHTML;
65
-
66
-@end
67 1
deleted file mode 100644
... ...
@@ -1,522 +0,0 @@
1
-//
2
-//  GTMNSString+HTML.m
3
-//  Dealing with NSStrings that contain HTML
4
-//
5
-//  Copyright 2006-2008 Google Inc.
6
-//
7
-//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
8
-//  use this file except in compliance with the License.  You may obtain a copy
9
-//  of the License at
10
-// 
11
-//  http://www.apache.org/licenses/LICENSE-2.0
12
-// 
13
-//  Unless required by applicable law or agreed to in writing, software
14
-//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
-//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
16
-//  License for the specific language governing permissions and limitations under
17
-//  the License.
18
-//
19
-
20
-#import "GTMDefines.h"
21
-#import "GTMNSString+HTML.h"
22
-
23
-typedef struct {
24
-  NSString *escapeSequence;
25
-  unichar uchar;
26
-} HTMLEscapeMap;
27
-
28
-// Taken from http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters
29
-// Ordered by uchar lowest to highest for bsearching
30
-static HTMLEscapeMap gAsciiHTMLEscapeMap[] = {
31
-  // A.2.2. Special characters
32
-  { @"&quot;", 34 },
33
-  { @"&amp;", 38 },
34
-  { @"&apos;", 39 },
35
-  { @"&lt;", 60 },
36
-  { @"&gt;", 62 },
37
-  
38
-    // A.2.1. Latin-1 characters
39
-  { @"&nbsp;", 160 }, 
40
-  { @"&iexcl;", 161 }, 
41
-  { @"&cent;", 162 }, 
42
-  { @"&pound;", 163 }, 
43
-  { @"&curren;", 164 }, 
44
-  { @"&yen;", 165 }, 
45
-  { @"&brvbar;", 166 }, 
46
-  { @"&sect;", 167 }, 
47
-  { @"&uml;", 168 }, 
48
-  { @"&copy;", 169 }, 
49
-  { @"&ordf;", 170 }, 
50
-  { @"&laquo;", 171 }, 
51
-  { @"&not;", 172 }, 
52
-  { @"&shy;", 173 }, 
53
-  { @"&reg;", 174 }, 
54
-  { @"&macr;", 175 }, 
55
-  { @"&deg;", 176 }, 
56
-  { @"&plusmn;", 177 }, 
57
-  { @"&sup2;", 178 }, 
58
-  { @"&sup3;", 179 }, 
59
-  { @"&acute;", 180 }, 
60
-  { @"&micro;", 181 }, 
61
-  { @"&para;", 182 }, 
62
-  { @"&middot;", 183 }, 
63
-  { @"&cedil;", 184 }, 
64
-  { @"&sup1;", 185 }, 
65
-  { @"&ordm;", 186 }, 
66
-  { @"&raquo;", 187 }, 
67
-  { @"&frac14;", 188 }, 
68
-  { @"&frac12;", 189 }, 
69
-  { @"&frac34;", 190 }, 
70
-  { @"&iquest;", 191 }, 
71
-  { @"&Agrave;", 192 }, 
72
-  { @"&Aacute;", 193 }, 
73
-  { @"&Acirc;", 194 }, 
74
-  { @"&Atilde;", 195 }, 
75
-  { @"&Auml;", 196 }, 
76
-  { @"&Aring;", 197 }, 
77
-  { @"&AElig;", 198 }, 
78
-  { @"&Ccedil;", 199 }, 
79
-  { @"&Egrave;", 200 }, 
80
-  { @"&Eacute;", 201 }, 
81
-  { @"&Ecirc;", 202 }, 
82
-  { @"&Euml;", 203 }, 
83
-  { @"&Igrave;", 204 }, 
84
-  { @"&Iacute;", 205 }, 
85
-  { @"&Icirc;", 206 }, 
86
-  { @"&Iuml;", 207 }, 
87
-  { @"&ETH;", 208 }, 
88
-  { @"&Ntilde;", 209 }, 
89
-  { @"&Ograve;", 210 }, 
90
-  { @"&Oacute;", 211 }, 
91
-  { @"&Ocirc;", 212 }, 
92
-  { @"&Otilde;", 213 }, 
93
-  { @"&Ouml;", 214 }, 
94
-  { @"&times;", 215 }, 
95
-  { @"&Oslash;", 216 }, 
96
-  { @"&Ugrave;", 217 }, 
97
-  { @"&Uacute;", 218 }, 
98
-  { @"&Ucirc;", 219 }, 
99
-  { @"&Uuml;", 220 }, 
100
-  { @"&Yacute;", 221 }, 
101
-  { @"&THORN;", 222 }, 
102
-  { @"&szlig;", 223 }, 
103
-  { @"&agrave;", 224 }, 
104
-  { @"&aacute;", 225 }, 
105
-  { @"&acirc;", 226 }, 
106
-  { @"&atilde;", 227 }, 
107
-  { @"&auml;", 228 }, 
108
-  { @"&aring;", 229 }, 
109
-  { @"&aelig;", 230 }, 
110
-  { @"&ccedil;", 231 }, 
111
-  { @"&egrave;", 232 }, 
112
-  { @"&eacute;", 233 }, 
113
-  { @"&ecirc;", 234 }, 
114
-  { @"&euml;", 235 }, 
115
-  { @"&igrave;", 236 }, 
116
-  { @"&iacute;", 237 }, 
117
-  { @"&icirc;", 238 }, 
118
-  { @"&iuml;", 239 }, 
119
-  { @"&eth;", 240 }, 
120
-  { @"&ntilde;", 241 }, 
121
-  { @"&ograve;", 242 }, 
122
-  { @"&oacute;", 243 }, 
123
-  { @"&ocirc;", 244 }, 
124
-  { @"&otilde;", 245 }, 
125
-  { @"&ouml;", 246 }, 
126
-  { @"&divide;", 247 }, 
127
-  { @"&oslash;", 248 }, 
128
-  { @"&ugrave;", 249 }, 
129
-  { @"&uacute;", 250 }, 
130
-  { @"&ucirc;", 251 }, 
131
-  { @"&uuml;", 252 }, 
132
-  { @"&yacute;", 253 }, 
133
-  { @"&thorn;", 254 }, 
134
-  { @"&yuml;", 255 },
135
-  
136
-  // A.2.2. Special characters cont'd
137
-  { @"&OElig;", 338 },
138
-  { @"&oelig;", 339 },
139
-  { @"&Scaron;", 352 },
140
-  { @"&scaron;", 353 },
141
-  { @"&Yuml;", 376 },
142
-
143
-  // A.2.3. Symbols
144
-  { @"&fnof;", 402 }, 
145
-
146
-  // A.2.2. Special characters cont'd
147
-  { @"&circ;", 710 },
148
-  { @"&tilde;", 732 },
149
-  
150
-  // A.2.3. Symbols cont'd
151
-  { @"&Alpha;", 913 }, 
152
-  { @"&Beta;", 914 }, 
153
-  { @"&Gamma;", 915 }, 
154
-  { @"&Delta;", 916 }, 
155
-  { @"&Epsilon;", 917 }, 
156
-  { @"&Zeta;", 918 }, 
157
-  { @"&Eta;", 919 }, 
158
-  { @"&Theta;", 920 }, 
159
-  { @"&Iota;", 921 }, 
160
-  { @"&Kappa;", 922 }, 
161
-  { @"&Lambda;", 923 }, 
162
-  { @"&Mu;", 924 }, 
163
-  { @"&Nu;", 925 }, 
164
-  { @"&Xi;", 926 }, 
165
-  { @"&Omicron;", 927 }, 
166
-  { @"&Pi;", 928 }, 
167
-  { @"&Rho;", 929 }, 
168
-  { @"&Sigma;", 931 }, 
169
-  { @"&Tau;", 932 }, 
170
-  { @"&Upsilon;", 933 }, 
171
-  { @"&Phi;", 934 }, 
172
-  { @"&Chi;", 935 }, 
173
-  { @"&Psi;", 936 }, 
174
-  { @"&Omega;", 937 }, 
175
-  { @"&alpha;", 945 }, 
176
-  { @"&beta;", 946 }, 
177
-  { @"&gamma;", 947 }, 
178
-  { @"&delta;", 948 }, 
179
-  { @"&epsilon;", 949 }, 
180
-  { @"&zeta;", 950 }, 
181
-  { @"&eta;", 951 }, 
182
-  { @"&theta;", 952 }, 
183
-  { @"&iota;", 953 }, 
184
-  { @"&kappa;", 954 }, 
185
-  { @"&lambda;", 955 }, 
186
-  { @"&mu;", 956 }, 
187
-  { @"&nu;", 957 }, 
188
-  { @"&xi;", 958 }, 
189
-  { @"&omicron;", 959 }, 
190
-  { @"&pi;", 960 }, 
191
-  { @"&rho;", 961 }, 
192
-  { @"&sigmaf;", 962 }, 
193
-  { @"&sigma;", 963 }, 
194
-  { @"&tau;", 964 }, 
195
-  { @"&upsilon;", 965 }, 
196
-  { @"&phi;", 966 }, 
197
-  { @"&chi;", 967 }, 
198
-  { @"&psi;", 968 }, 
199
-  { @"&omega;", 969 }, 
200
-  { @"&thetasym;", 977 }, 
201
-  { @"&upsih;", 978 }, 
202
-  { @"&piv;", 982 }, 
203
- 
204
-  // A.2.2. Special characters cont'd
205
-  { @"&ensp;", 8194 },
206
-  { @"&emsp;", 8195 },
207
-  { @"&thinsp;", 8201 },
208
-  { @"&zwnj;", 8204 },
209
-  { @"&zwj;", 8205 },
210
-  { @"&lrm;", 8206 },
211
-  { @"&rlm;", 8207 },
212
-  { @"&ndash;", 8211 },
213
-  { @"&mdash;", 8212 },
214
-  { @"&lsquo;", 8216 },
215
-  { @"&rsquo;", 8217 },
216
-  { @"&sbquo;", 8218 },
217
-  { @"&ldquo;", 8220 },
218
-  { @"&rdquo;", 8221 },
219
-  { @"&bdquo;", 8222 },
220
-  { @"&dagger;", 8224 },
221
-  { @"&Dagger;", 8225 },
222
-    // A.2.3. Symbols cont'd  
223
-  { @"&bull;", 8226 }, 
224
-  { @"&hellip;", 8230 }, 
225
- 
226
-  // A.2.2. Special characters cont'd
227
-  { @"&permil;", 8240 },
228
-  
229
-  // A.2.3. Symbols cont'd  
230
-  { @"&prime;", 8242 }, 
231
-  { @"&Prime;", 8243 }, 
232
-
233
-  // A.2.2. Special characters cont'd
234
-  { @"&lsaquo;", 8249 },
235
-  { @"&rsaquo;", 8250 },
236
-
237
-  // A.2.3. Symbols cont'd  
238
-  { @"&oline;", 8254 }, 
239
-  { @"&frasl;", 8260 }, 
240
-  
241
-  // A.2.2. Special characters cont'd
242
-  { @"&euro;", 8364 },
243
-
244
-  // A.2.3. Symbols cont'd  
245
-  { @"&image;", 8465 },
246
-  { @"&weierp;", 8472 }, 
247
-  { @"&real;", 8476 }, 
248
-  { @"&trade;", 8482 }, 
249
-  { @"&alefsym;", 8501 }, 
250
-  { @"&larr;", 8592 }, 
251
-  { @"&uarr;", 8593 }, 
252
-  { @"&rarr;", 8594 }, 
253
-  { @"&darr;", 8595 }, 
254
-  { @"&harr;", 8596 }, 
255
-  { @"&crarr;", 8629 }, 
256
-  { @"&lArr;", 8656 }, 
257
-  { @"&uArr;", 8657 }, 
258
-  { @"&rArr;", 8658 }, 
259
-  { @"&dArr;", 8659 }, 
260
-  { @"&hArr;", 8660 }, 
261
-  { @"&forall;", 8704 }, 
262
-  { @"&part;", 8706 }, 
263
-  { @"&exist;", 8707 }, 
264
-  { @"&empty;", 8709 }, 
265
-  { @"&nabla;", 8711 }, 
266
-  { @"&isin;", 8712 }, 
267
-  { @"&notin;", 8713 }, 
268
-  { @"&ni;", 8715 }, 
269
-  { @"&prod;", 8719 }, 
270
-  { @"&sum;", 8721 }, 
271
-  { @"&minus;", 8722 }, 
272
-  { @"&lowast;", 8727 }, 
273
-  { @"&radic;", 8730 }, 
274
-  { @"&prop;", 8733 }, 
275
-  { @"&infin;", 8734 }, 
276
-  { @"&ang;", 8736 }, 
277
-  { @"&and;", 8743 }, 
278
-  { @"&or;", 8744 }, 
279
-  { @"&cap;", 8745 }, 
280
-  { @"&cup;", 8746 }, 
281
-  { @"&int;", 8747 }, 
282
-  { @"&there4;", 8756 }, 
283
-  { @"&sim;", 8764 }, 
284
-  { @"&cong;", 8773 }, 
285
-  { @"&asymp;", 8776 }, 
286
-  { @"&ne;", 8800 }, 
287
-  { @"&equiv;", 8801 }, 
288
-  { @"&le;", 8804 }, 
289
-  { @"&ge;", 8805 }, 
290
-  { @"&sub;", 8834 }, 
291
-  { @"&sup;", 8835 }, 
292
-  { @"&nsub;", 8836 }, 
293
-  { @"&sube;", 8838 }, 
294
-  { @"&supe;", 8839 }, 
295
-  { @"&oplus;", 8853 }, 
296
-  { @"&otimes;", 8855 }, 
297
-  { @"&perp;", 8869 }, 
298
-  { @"&sdot;", 8901 }, 
299
-  { @"&lceil;", 8968 }, 
300
-  { @"&rceil;", 8969 }, 
301
-  { @"&lfloor;", 8970 }, 
302
-  { @"&rfloor;", 8971 }, 
303
-  { @"&lang;", 9001 }, 
304
-  { @"&rang;", 9002 }, 
305
-  { @"&loz;", 9674 }, 
306
-  { @"&spades;", 9824 }, 
307
-  { @"&clubs;", 9827 }, 
308
-  { @"&hearts;", 9829 }, 
309
-  { @"&diams;", 9830 }
310
-};
311
-
312
-// Taken from http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters
313
-// This is table A.2.2 Special Characters
314
-static HTMLEscapeMap gUnicodeHTMLEscapeMap[] = {
315
-  // C0 Controls and Basic Latin
316
-  { @"&quot;", 34 },
317
-  { @"&amp;", 38 },
318
-  { @"&apos;", 39 },
319
-  { @"&lt;", 60 },
320
-  { @"&gt;", 62 },
321
-
322
-  // Latin Extended-A
323
-  { @"&OElig;", 338 },
324
-  { @"&oelig;", 339 },
325
-  { @"&Scaron;", 352 },
326
-  { @"&scaron;", 353 },
327
-  { @"&Yuml;", 376 },
328
-  
329
-  // Spacing Modifier Letters
330
-  { @"&circ;", 710 },
331
-  { @"&tilde;", 732 },
332
-    
333
-  // General Punctuation
334
-  { @"&ensp;", 8194 },
335
-  { @"&emsp;", 8195 },
336
-  { @"&thinsp;", 8201 },
337
-  { @"&zwnj;", 8204 },
338
-  { @"&zwj;", 8205 },
339
-  { @"&lrm;", 8206 },
340
-  { @"&rlm;", 8207 },
341
-  { @"&ndash;", 8211 },
342
-  { @"&mdash;", 8212 },
343
-  { @"&lsquo;", 8216 },
344
-  { @"&rsquo;", 8217 },
345
-  { @"&sbquo;", 8218 },
346
-  { @"&ldquo;", 8220 },
347
-  { @"&rdquo;", 8221 },
348
-  { @"&bdquo;", 8222 },
349
-  { @"&dagger;", 8224 },
350
-  { @"&Dagger;", 8225 },
351
-  { @"&permil;", 8240 },
352
-  { @"&lsaquo;", 8249 },
353
-  { @"&rsaquo;", 8250 },
354
-  { @"&euro;", 8364 },
355
-};
356
-
357
-
358
-// Utility function for Bsearching table above
359
-static int EscapeMapCompare(const void *ucharVoid, const void *mapVoid) {
360
-  const unichar *uchar = (const unichar*)ucharVoid;
361
-  const HTMLEscapeMap *map = (const HTMLEscapeMap*)mapVoid;
362
-  int val;
363
-  if (*uchar > map->uchar) {
364
-    val = 1;
365
-  } else if (*uchar < map->uchar) {
366
-    val = -1;
367
-  } else {
368
-    val = 0;
369
-  }
370
-  return val;
371
-}
372
-
373
-@implementation NSString (GTMNSStringHTMLAdditions)
374
-
375
-- (NSString *)gtm_stringByEscapingHTMLUsingTable:(HTMLEscapeMap*)table 
376
-                                          ofSize:(NSUInteger)size 
377
-                                 escapingUnicode:(BOOL)escapeUnicode {  
378
-  NSUInteger length = [self length];
379
-  if (!length) {
380
-    return self;
381
-  }
382
-  
383
-  NSMutableString *finalString = [NSMutableString string];
384
-  NSMutableData *data2 = [NSMutableData dataWithCapacity:sizeof(unichar) * length];
385
-
386
-  // this block is common between GTMNSString+HTML and GTMNSString+XML but
387
-  // it's so short that it isn't really worth trying to share.
388
-  const unichar *buffer = CFStringGetCharactersPtr((CFStringRef)self);
389
-  if (!buffer) {
390
-    // We want this buffer to be autoreleased.
391
-    NSMutableData *data = [NSMutableData dataWithLength:length * sizeof(UniChar)];
392
-    if (!data) {
393
-      // COV_NF_START  - Memory fail case
394
-      _GTMDevLog(@"couldn't alloc buffer");
395
-      return nil;
396
-      // COV_NF_END
397
-    }
398
-    [self getCharacters:[data mutableBytes]];
399
-    buffer = [data bytes];
400
-  }
401
-
402
-  if (!buffer || !data2) {
403
-    // COV_NF_START
404
-    _GTMDevLog(@"Unable to allocate buffer or data2");
405
-    return nil;
406
-    // COV_NF_END
407
-  }
408
-  
409
-  unichar *buffer2 = (unichar *)[data2 mutableBytes];
410
-  
411
-  NSUInteger buffer2Length = 0;
412
-  
413
-  for (NSUInteger i = 0; i < length; ++i) {
414
-    HTMLEscapeMap *val = bsearch(&buffer[i], table, 
415
-                                 size / sizeof(HTMLEscapeMap), 
416
-                                 sizeof(HTMLEscapeMap), EscapeMapCompare);
417
-    if (val || (escapeUnicode && buffer[i] > 127)) {
418
-      if (buffer2Length) {
419
-        CFStringAppendCharacters((CFMutableStringRef)finalString, 
420
-                                 buffer2, 
421
-                                 buffer2Length);
422
-        buffer2Length = 0;
423
-      }
424
-      if (val) {
425
-        [finalString appendString:val->escapeSequence];
426
-      }
427
-      else {
428
-        _GTMDevAssert(escapeUnicode && buffer[i] > 127, @"Illegal Character");
429
-        [finalString appendFormat:@"&#%d;", buffer[i]];
430
-      }
431
-    } else {
432
-      buffer2[buffer2Length] = buffer[i];
433
-      buffer2Length += 1;
434
-    }
435
-  }
436
-  if (buffer2Length) {
437
-    CFStringAppendCharacters((CFMutableStringRef)finalString, 
438
-                             buffer2, 
439
-                             buffer2Length);
440
-  }
441
-  return finalString;
442
-}
443
-
444
-- (NSString *)gtm_stringByEscapingForHTML {
445
-  return [self gtm_stringByEscapingHTMLUsingTable:gUnicodeHTMLEscapeMap 
446
-                                           ofSize:sizeof(gUnicodeHTMLEscapeMap) 
447
-                                  escapingUnicode:NO];
448
-} // gtm_stringByEscapingHTML
449
-
450
-- (NSString *)gtm_stringByEscapingForAsciiHTML {
451
-  return [self gtm_stringByEscapingHTMLUsingTable:gAsciiHTMLEscapeMap 
452
-                                           ofSize:sizeof(gAsciiHTMLEscapeMap) 
453
-                                  escapingUnicode:YES];
454
-} // gtm_stringByEscapingAsciiHTML
455
-
456
-- (NSString *)gtm_stringByUnescapingFromHTML {
457
-  NSRange range = NSMakeRange(0, [self length]);
458
-  NSRange subrange = [self rangeOfString:@"&" options:NSBackwardsSearch range:range];
459
-  
460
-  // if no ampersands, we've got a quick way out
461
-  if (subrange.length == 0) return self;
462
-  NSMutableString *finalString = [NSMutableString stringWithString:self];
463
-  do {
464
-    NSRange semiColonRange = NSMakeRange(subrange.location, NSMaxRange(range) - subrange.location);
465
-    semiColonRange = [self rangeOfString:@";" options:0 range:semiColonRange];
466
-    range = NSMakeRange(0, subrange.location);
467
-    // if we don't find a semicolon in the range, we don't have a sequence
468
-    if (semiColonRange.location == NSNotFound) {
469
-      continue;
470
-    }
471
-    NSRange escapeRange = NSMakeRange(subrange.location, semiColonRange.location - subrange.location + 1);
472
-    NSString *escapeString = [self substringWithRange:escapeRange];
473
-    NSUInteger length = [escapeString length];
474
-    // a squence must be longer than 3 (&lt;) and less than 11 (&thetasym;)
475
-    if (length > 3 && length < 11) {
476
-      if ([escapeString characterAtIndex:1] == '#') {
477
-        unichar char2 = [escapeString characterAtIndex:2];
478
-        if (char2 == 'x' || char2 == 'X') {
479
-          // Hex escape squences &#xa3;
480
-          NSString *hexSequence = [escapeString substringWithRange:NSMakeRange(3, length - 4)];
481
-          NSScanner *scanner = [NSScanner scannerWithString:hexSequence];
482
-          unsigned value;
483
-          if ([scanner scanHexInt:&value] && 
484
-              value < USHRT_MAX &&
485
-              value > 0 
486
-              && [scanner scanLocation] == length - 4) {
487
-            unichar uchar = (unichar)value;
488
-            NSString *charString = [NSString stringWithCharacters:&uchar length:1];
489
-            [finalString replaceCharactersInRange:escapeRange withString:charString];
490
-          }
491
-
492
-        } else {
493
-          // Decimal Sequences &#123;
494
-          NSString *numberSequence = [escapeString substringWithRange:NSMakeRange(2, length - 3)];
495
-          NSScanner *scanner = [NSScanner scannerWithString:numberSequence];
496
-          int value;
497
-          if ([scanner scanInt:&value] && 
498
-              value < USHRT_MAX &&
499
-              value > 0 
500
-              && [scanner scanLocation] == length - 3) {
501
-            unichar uchar = (unichar)value;
502
-            NSString *charString = [NSString stringWithCharacters:&uchar length:1];
503
-            [finalString replaceCharactersInRange:escapeRange withString:charString];
504
-          }
505
-        }
506
-      } else {
507
-        // "standard" sequences
508
-        for (unsigned i = 0; i < sizeof(gAsciiHTMLEscapeMap) / sizeof(HTMLEscapeMap); ++i) {
509
-          if ([escapeString isEqualToString:gAsciiHTMLEscapeMap[i].escapeSequence]) {
510
-            [finalString replaceCharactersInRange:escapeRange withString:[NSString stringWithCharacters:&gAsciiHTMLEscapeMap[i].uchar length:1]];
511
-            break;
512
-          }
513
-        }
514
-      }
515
-    }
516
-  } while ((subrange = [self rangeOfString:@"&" options:NSBackwardsSearch range:range]).length != 0);
517
-  return finalString;
518
-} // gtm_stringByUnescapingHTML
519
-
520
-
521
-
522
-@end
523 1
deleted file mode 100644
... ...
@@ -1,441 +0,0 @@
1
-//
2
-// GTMDefines.h
3
-//
4
-//  Copyright 2008 Google Inc.
5
-//
6
-//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
7
-//  use this file except in compliance with the License.  You may obtain a copy
8
-//  of the License at
9
-//
10
-//  http://www.apache.org/licenses/LICENSE-2.0
11
-//
12
-//  Unless required by applicable law or agreed to in writing, software
13
-//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
-//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15
-//  License for the specific language governing permissions and limitations under
16
-//  the License.
17
-//
18
-
19
-// ============================================================================
20
-
21
-#include <AvailabilityMacros.h>
22
-#include <TargetConditionals.h>
23
-
24
-#ifdef __OBJC__
25
-#include <Foundation/NSObjCRuntime.h>
26
-#endif  // __OBJC__
27
-
28
-#if TARGET_OS_IPHONE
29
-#include <Availability.h>
30
-#endif  // TARGET_OS_IPHONE
31
-
32
-// Not all MAC_OS_X_VERSION_10_X macros defined in past SDKs
33
-#ifndef MAC_OS_X_VERSION_10_5
34
-  #define MAC_OS_X_VERSION_10_5 1050
35
-#endif
36
-#ifndef MAC_OS_X_VERSION_10_6
37
-  #define MAC_OS_X_VERSION_10_6 1060
38
-#endif
39
-#ifndef MAC_OS_X_VERSION_10_7
40
-  #define MAC_OS_X_VERSION_10_7 1070
41
-#endif
42
-
43
-// Not all __IPHONE_X macros defined in past SDKs
44
-#ifndef __IPHONE_3_0
45
-  #define __IPHONE_3_0 30000
46
-#endif
47
-#ifndef __IPHONE_3_1
48
-  #define __IPHONE_3_1 30100
49
-#endif
50
-#ifndef __IPHONE_3_2
51
-  #define __IPHONE_3_2 30200
52
-#endif
53
-#ifndef __IPHONE_4_0
54
-  #define __IPHONE_4_0 40000
55
-#endif
56
-#ifndef __IPHONE_4_3
57
-  #define __IPHONE_4_3 40300
58
-#endif
59
-#ifndef __IPHONE_5_0
60
-  #define __IPHONE_5_0 50000
61
-#endif
62
-
63
-// ----------------------------------------------------------------------------
64
-// CPP symbols that can be overridden in a prefix to control how the toolbox
65
-// is compiled.
66
-// ----------------------------------------------------------------------------
67
-
68
-
69
-// By setting the GTM_CONTAINERS_VALIDATION_FAILED_LOG and
70
-// GTM_CONTAINERS_VALIDATION_FAILED_ASSERT macros you can control what happens
71
-// when a validation fails. If you implement your own validators, you may want
72
-// to control their internals using the same macros for consistency.
73
-#ifndef GTM_CONTAINERS_VALIDATION_FAILED_ASSERT
74
-  #define GTM_CONTAINERS_VALIDATION_FAILED_ASSERT 0
75
-#endif
76
-
77
-// Give ourselves a consistent way to do inlines.  Apple's macros even use
78
-// a few different actual definitions, so we're based off of the foundation
79
-// one.
80
-#if !defined(GTM_INLINE)
81
-  #if (defined (__GNUC__) && (__GNUC__ == 4)) || defined (__clang__)
82
-    #define GTM_INLINE static __inline__ __attribute__((always_inline))
83
-  #else
84
-    #define GTM_INLINE static __inline__
85
-  #endif
86
-#endif
87
-
88
-// Give ourselves a consistent way of doing externs that links up nicely
89
-// when mixing objc and objc++
90
-#if !defined (GTM_EXTERN)
91
-  #if defined __cplusplus
92
-    #define GTM_EXTERN extern "C"
93
-    #define GTM_EXTERN_C_BEGIN extern "C" {
94
-    #define GTM_EXTERN_C_END }
95
-  #else
96
-    #define GTM_EXTERN extern
97
-    #define GTM_EXTERN_C_BEGIN
98
-    #define GTM_EXTERN_C_END
99
-  #endif
100
-#endif
101
-
102
-// Give ourselves a consistent way of exporting things if we have visibility
103
-// set to hidden.
104
-#if !defined (GTM_EXPORT)
105
-  #define GTM_EXPORT __attribute__((visibility("default")))
106
-#endif
107
-
108
-// Give ourselves a consistent way of declaring something as unused. This
109
-// doesn't use __unused because that is only supported in gcc 4.2 and greater.
110
-#if !defined (GTM_UNUSED)
111
-#define GTM_UNUSED(x) ((void)(x))
112
-#endif
113
-
114
-// _GTMDevLog & _GTMDevAssert
115
-//
116
-// _GTMDevLog & _GTMDevAssert are meant to be a very lightweight shell for
117
-// developer level errors.  This implementation simply macros to NSLog/NSAssert.
118
-// It is not intended to be a general logging/reporting system.
119
-//
120
-// Please see http://code.google.com/p/google-toolbox-for-mac/wiki/DevLogNAssert
121
-// for a little more background on the usage of these macros.
122
-//
123
-//    _GTMDevLog           log some error/problem in debug builds
124
-//    _GTMDevAssert        assert if conditon isn't met w/in a method/function
125
-//                           in all builds.
126
-//
127
-// To replace this system, just provide different macro definitions in your
128
-// prefix header.  Remember, any implementation you provide *must* be thread
129
-// safe since this could be called by anything in what ever situtation it has
130
-// been placed in.
131
-//
132
-
133
-// We only define the simple macros if nothing else has defined this.
134
-#ifndef _GTMDevLog
135
-
136
-#ifdef DEBUG
137
-  #define _GTMDevLog(...) NSLog(__VA_ARGS__)
138
-#else
139
-  #define _GTMDevLog(...) do { } while (0)
140
-#endif
141
-
142
-#endif // _GTMDevLog
143
-
144
-#ifndef _GTMDevAssert
145
-// we directly invoke the NSAssert handler so we can pass on the varargs
146
-// (NSAssert doesn't have a macro we can use that takes varargs)
147
-#if !defined(NS_BLOCK_ASSERTIONS)
148
-  #define _GTMDevAssert(condition, ...)                                       \
149
-    do {                                                                      \
150
-      if (!(condition)) {                                                     \
151
-        [[NSAssertionHandler currentHandler]                                  \
152
-            handleFailureInFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
153
-                               file:[NSString stringWithUTF8String:__FILE__]  \
154
-                         lineNumber:__LINE__                                  \
155
-                        description:__VA_ARGS__];                             \
156
-      }                                                                       \
157
-    } while(0)
158
-#else // !defined(NS_BLOCK_ASSERTIONS)
159
-  #define _GTMDevAssert(condition, ...) do { } while (0)
160
-#endif // !defined(NS_BLOCK_ASSERTIONS)
161
-
162
-#endif // _GTMDevAssert
163
-
164
-// _GTMCompileAssert
165
-// _GTMCompileAssert is an assert that is meant to fire at compile time if you
166
-// want to check things at compile instead of runtime. For example if you
167
-// want to check that a wchar is 4 bytes instead of 2 you would use
168
-// _GTMCompileAssert(sizeof(wchar_t) == 4, wchar_t_is_4_bytes_on_OS_X)
169
-// Note that the second "arg" is not in quotes, and must be a valid processor
170
-// symbol in it's own right (no spaces, punctuation etc).
171
-
172
-// Wrapping this in an #ifndef allows external groups to define their own
173
-// compile time assert scheme.
174
-#ifndef _GTMCompileAssert
175
-  // We got this technique from here:
176
-  // http://unixjunkie.blogspot.com/2007/10/better-compile-time-asserts_29.html
177
-
178
-  #define _GTMCompileAssertSymbolInner(line, msg) _GTMCOMPILEASSERT ## line ## __ ## msg
179
-  #define _GTMCompileAssertSymbol(line, msg) _GTMCompileAssertSymbolInner(line, msg)
180
-  #define _GTMCompileAssert(test, msg) \
181
-    typedef char _GTMCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
182
-#endif // _GTMCompileAssert
183
-
184
-// ----------------------------------------------------------------------------
185
-// CPP symbols defined based on the project settings so the GTM code has
186
-// simple things to test against w/o scattering the knowledge of project
187
-// setting through all the code.
188
-// ----------------------------------------------------------------------------
189
-
190
-// Provide a single constant CPP symbol that all of GTM uses for ifdefing
191
-// iPhone code.
192
-#if TARGET_OS_IPHONE // iPhone SDK
193
-  // For iPhone specific stuff
194
-  #define GTM_IPHONE_SDK 1
195
-  #if TARGET_IPHONE_SIMULATOR
196
-    #define GTM_IPHONE_SIMULATOR 1
197
-  #else
198
-    #define GTM_IPHONE_DEVICE 1
199
-  #endif  // TARGET_IPHONE_SIMULATOR
200
-  // By default, GTM has provided it's own unittesting support, define this
201
-  // to use the support provided by Xcode, especially for the Xcode4 support
202
-  // for unittesting.
203
-  #ifndef GTM_IPHONE_USE_SENTEST
204
-    #define GTM_IPHONE_USE_SENTEST 0
205
-  #endif
206
-#else
207
-  // For MacOS specific stuff
208
-  #define GTM_MACOS_SDK 1
209
-#endif
210
-
211
-// Some of our own availability macros
212
-#if GTM_MACOS_SDK
213
-#define GTM_AVAILABLE_ONLY_ON_IPHONE UNAVAILABLE_ATTRIBUTE
214
-#define GTM_AVAILABLE_ONLY_ON_MACOS
215
-#else
216
-#define GTM_AVAILABLE_ONLY_ON_IPHONE
217
-#define GTM_AVAILABLE_ONLY_ON_MACOS UNAVAILABLE_ATTRIBUTE
218
-#endif
219
-
220
-// GC was dropped by Apple, define the old constant incase anyone still keys
221
-// off of it.
222
-#ifndef GTM_SUPPORT_GC
223
-  #define GTM_SUPPORT_GC 0
224
-#endif
225
-
226
-// To simplify support for 64bit (and Leopard in general), we provide the type
227
-// defines for non Leopard SDKs
228
-#if !(MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
229
- // NSInteger/NSUInteger and Max/Mins
230
-  #ifndef NSINTEGER_DEFINED
231
-    #if __LP64__ || NS_BUILD_32_LIKE_64
232
-      typedef long NSInteger;
233
-      typedef unsigned long NSUInteger;
234
-    #else
235
-      typedef int NSInteger;
236
-      typedef unsigned int NSUInteger;
237
-    #endif
238
-    #define NSIntegerMax    LONG_MAX
239
-    #define NSIntegerMin    LONG_MIN
240
-    #define NSUIntegerMax   ULONG_MAX
241
-    #define NSINTEGER_DEFINED 1
242
-  #endif  // NSINTEGER_DEFINED
243
-  // CGFloat
244
-  #ifndef CGFLOAT_DEFINED
245
-    #if defined(__LP64__) && __LP64__
246
-      // This really is an untested path (64bit on Tiger?)
247
-      typedef double CGFloat;
248
-      #define CGFLOAT_MIN DBL_MIN
249
-      #define CGFLOAT_MAX DBL_MAX
250
-      #define CGFLOAT_IS_DOUBLE 1
251
-    #else /* !defined(__LP64__) || !__LP64__ */
252
-      typedef float CGFloat;
253
-      #define CGFLOAT_MIN FLT_MIN
254
-      #define CGFLOAT_MAX FLT_MAX
255
-      #define CGFLOAT_IS_DOUBLE 0
256
-    #endif /* !defined(__LP64__) || !__LP64__ */
257
-    #define CGFLOAT_DEFINED 1
258
-  #endif // CGFLOAT_DEFINED
259
-#endif  // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
260
-
261
-// Some support for advanced clang static analysis functionality
262
-// See http://clang-analyzer.llvm.org/annotations.html
263
-#ifndef __has_feature      // Optional.
264
-  #define __has_feature(x) 0 // Compatibility with non-clang compilers.
265
-#endif
266
-
267
-#ifndef NS_RETURNS_RETAINED
268
-  #if __has_feature(attribute_ns_returns_retained)
269
-    #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
270
-  #else
271
-    #define NS_RETURNS_RETAINED
272
-  #endif
273
-#endif
274
-
275
-#ifndef NS_RETURNS_NOT_RETAINED
276
-  #if __has_feature(attribute_ns_returns_not_retained)
277
-    #define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
278
-  #else
279
-    #define NS_RETURNS_NOT_RETAINED
280
-  #endif
281
-#endif
282
-
283
-#ifndef CF_RETURNS_RETAINED
284
-  #if __has_feature(attribute_cf_returns_retained)
285
-    #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
286
-  #else
287
-    #define CF_RETURNS_RETAINED
288
-  #endif
289
-#endif
290
-
291
-#ifndef CF_RETURNS_NOT_RETAINED
292
-  #if __has_feature(attribute_cf_returns_not_retained)
293
-    #define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
294
-  #else
295
-    #define CF_RETURNS_NOT_RETAINED
296
-  #endif
297
-#endif
298
-
299
-#ifndef NS_CONSUMED
300
-  #if __has_feature(attribute_ns_consumed)
301
-    #define NS_CONSUMED __attribute__((ns_consumed))
302
-  #else
303
-    #define NS_CONSUMED
304
-  #endif
305
-#endif
306
-
307
-#ifndef CF_CONSUMED
308
-  #if __has_feature(attribute_cf_consumed)
309
-    #define CF_CONSUMED __attribute__((cf_consumed))
310
-  #else
311
-    #define CF_CONSUMED
312
-  #endif
313
-#endif
314
-
315
-#ifndef NS_CONSUMES_SELF
316
-  #if __has_feature(attribute_ns_consumes_self)
317
-    #define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
318
-  #else
319
-    #define NS_CONSUMES_SELF
320
-  #endif
321
-#endif
322
-
323
-// Defined on 10.6 and above.
324
-#ifndef NS_FORMAT_ARGUMENT
325
-  #define NS_FORMAT_ARGUMENT(A)
326
-#endif
327
-
328
-// Defined on 10.6 and above.
329
-#ifndef NS_FORMAT_FUNCTION
330
-  #define NS_FORMAT_FUNCTION(F,A)
331
-#endif
332
-
333
-// Defined on 10.6 and above.
334
-#ifndef CF_FORMAT_ARGUMENT
335
-  #define CF_FORMAT_ARGUMENT(A)
336
-#endif
337
-
338
-// Defined on 10.6 and above.
339
-#ifndef CF_FORMAT_FUNCTION
340
-  #define CF_FORMAT_FUNCTION(F,A)
341
-#endif
342
-
343
-#ifndef GTM_NONNULL
344
-  #if defined(__has_attribute)
345
-    #if __has_attribute(nonnull)
346
-      #define GTM_NONNULL(x) __attribute__((nonnull x))
347
-    #else
348
-      #define GTM_NONNULL(x)
349
-    #endif
350
-  #else
351
-    #define GTM_NONNULL(x)
352
-  #endif
353
-#endif
354
-
355
-// Invalidates the initializer from which it's called.
356
-#ifndef GTMInvalidateInitializer
357
-  #if __has_feature(objc_arc)
358
-    #define GTMInvalidateInitializer() \
359
-      do { \
360
-        [self class]; /* Avoid warning of dead store to |self|. */ \
361
-        _GTMDevAssert(NO, @"Invalid initializer."); \
362
-        return nil; \
363
-      } while (0)
364
-  #else
365
-    #define GTMInvalidateInitializer() \
366
-      do { \
367
-        [self release]; \
368
-        _GTMDevAssert(NO, @"Invalid initializer."); \
369
-        return nil; \
370
-      } while (0)
371
-  #endif
372
-#endif
373
-
374
-#ifdef __OBJC__
375
-
376
-// Declared here so that it can easily be used for logging tracking if
377
-// necessary. See GTMUnitTestDevLog.h for details.
378
-@class NSString;
379
-GTM_EXTERN void _GTMUnitTestDevLog(NSString *format, ...) NS_FORMAT_FUNCTION(1, 2);
380
-
381
-// Macro to allow you to create NSStrings out of other macros.
382
-// #define FOO foo
383
-// NSString *fooString = GTM_NSSTRINGIFY(FOO);
384
-#if !defined (GTM_NSSTRINGIFY)
385
-  #define GTM_NSSTRINGIFY_INNER(x) @#x
386
-  #define GTM_NSSTRINGIFY(x) GTM_NSSTRINGIFY_INNER(x)
387
-#endif
388
-
389
-// Macro to allow fast enumeration when building for 10.5 or later, and
390
-// reliance on NSEnumerator for 10.4.  Remember, NSDictionary w/ FastEnumeration
391
-// does keys, so pick the right thing, nothing is done on the FastEnumeration
392
-// side to be sure you're getting what you wanted.
393
-#ifndef GTM_FOREACH_OBJECT
394
-  #if TARGET_OS_IPHONE || !(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
395
-    #define GTM_FOREACH_ENUMEREE(element, enumeration) \
396
-      for (element in enumeration)
397
-    #define GTM_FOREACH_OBJECT(element, collection) \
398
-      for (element in collection)
399
-    #define GTM_FOREACH_KEY(element, collection) \
400
-      for (element in collection)
401
-  #else
402
-    #define GTM_FOREACH_ENUMEREE(element, enumeration) \
403
-      for (NSEnumerator *_ ## element ## _enum = enumeration; \
404
-           (element = [_ ## element ## _enum nextObject]) != nil; )
405
-    #define GTM_FOREACH_OBJECT(element, collection) \
406
-      GTM_FOREACH_ENUMEREE(element, [collection objectEnumerator])
407
-    #define GTM_FOREACH_KEY(element, collection) \
408
-      GTM_FOREACH_ENUMEREE(element, [collection keyEnumerator])
409
-  #endif
410
-#endif
411
-
412
-// ============================================================================
413
-
414
-// To simplify support for both Leopard and Snow Leopard we declare
415
-// the Snow Leopard protocols that we need here.
416
-#if !defined(GTM_10_6_PROTOCOLS_DEFINED) && !(MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
417
-#define GTM_10_6_PROTOCOLS_DEFINED 1
418
-@protocol NSConnectionDelegate
419
-@end
420
-@protocol NSAnimationDelegate
421
-@end
422
-@protocol NSImageDelegate
423
-@end
424
-@protocol NSTabViewDelegate
425
-@end
426
-#endif  // !defined(GTM_10_6_PROTOCOLS_DEFINED) && !(MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
427
-
428
-// GTM_SEL_STRING is for specifying selector (usually property) names to KVC
429
-// or KVO methods.
430
-// In debug it will generate warnings for undeclared selectors if
431
-// -Wunknown-selector is turned on.
432
-// In release it will have no runtime overhead.
433
-#ifndef GTM_SEL_STRING
434
-  #ifdef DEBUG
435
-    #define GTM_SEL_STRING(selName) NSStringFromSelector(@selector(selName))
436
-  #else
437
-    #define GTM_SEL_STRING(selName) @#selName
438
-  #endif  // DEBUG
439
-#endif  // GTM_SEL_STRING
440
-
441
-#endif  // __OBJC__