motion-memorymanagement 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE +42 -0
- data/MMRuntime/MMRuntime.xcodeproj/project.pbxproj +271 -0
- data/MMRuntime/MMRuntime/MANotificationCenterAdditions.h +18 -0
- data/MMRuntime/MMRuntime/MANotificationCenterAdditions.m +36 -0
- data/MMRuntime/MMRuntime/MAWeakArray.h +16 -0
- data/MMRuntime/MMRuntime/MAWeakArray.m +121 -0
- data/MMRuntime/MMRuntime/MAWeakDictionary.h +16 -0
- data/MMRuntime/MMRuntime/MAWeakDictionary.m +66 -0
- data/MMRuntime/MMRuntime/MAZeroingWeakProxy.h +31 -0
- data/MMRuntime/MMRuntime/MAZeroingWeakProxy.m +99 -0
- data/MMRuntime/MMRuntime/MAZeroingWeakRef.h +73 -0
- data/MMRuntime/MMRuntime/MAZeroingWeakRef.m +852 -0
- data/MMRuntime/MMRuntime/MAZeroingWeakRefNativeZWRNotAllowedTable.h +180 -0
- data/MMRuntime/MMRuntime/MMRuntime-Prefix.pch +7 -0
- data/MMRuntime/MMRuntime/MMRuntime.h +3 -0
- data/MMRuntime/MMRuntime/MMRuntime.m +11 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/demoapp/.gitignore +13 -0
- data/demoapp/Rakefile +12 -0
- data/demoapp/app/app_delegate.rb +5 -0
- data/demoapp/spec/main_spec.rb +39 -0
- data/lib/motion-memorymanagement.rb +23 -0
- data/lib/motion-memorymanagement/runtime_helpers.rb +5 -0
- data/lib/motion-memorymanagement/version.rb +5 -0
- data/motion-memorymanagement.gemspec +17 -0
- metadata +90 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Copyright (c) 2013 Vladimir Pouzanov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
|
25
|
+
This gem includes sources from MAZeroingWeakRef which is distributed under a following license:
|
26
|
+
|
27
|
+
|
28
|
+
MAZeroingWeakRef and all code associated with it is distributed under a BSD license, as listed below.
|
29
|
+
|
30
|
+
|
31
|
+
Copyright (c) 2010, Michael Ash
|
32
|
+
All rights reserved.
|
33
|
+
|
34
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
35
|
+
|
36
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
37
|
+
|
38
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
39
|
+
|
40
|
+
Neither the name of Michael Ash nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
41
|
+
|
42
|
+
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 HOLDER 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.
|
@@ -0,0 +1,271 @@
|
|
1
|
+
// !$*UTF8*$!
|
2
|
+
{
|
3
|
+
archiveVersion = 1;
|
4
|
+
classes = {
|
5
|
+
};
|
6
|
+
objectVersion = 46;
|
7
|
+
objects = {
|
8
|
+
|
9
|
+
/* Begin PBXBuildFile section */
|
10
|
+
A53B9DF416B0394A003532F5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A53B9DF316B0394A003532F5 /* Foundation.framework */; };
|
11
|
+
A53B9E0716B039F3003532F5 /* MANotificationCenterAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = A53B9E0116B039F3003532F5 /* MANotificationCenterAdditions.m */; };
|
12
|
+
A53B9E0816B039F3003532F5 /* MAWeakArray.m in Sources */ = {isa = PBXBuildFile; fileRef = A53B9E0216B039F3003532F5 /* MAWeakArray.m */; };
|
13
|
+
A53B9E0916B039F3003532F5 /* MAWeakDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = A53B9E0316B039F3003532F5 /* MAWeakDictionary.m */; };
|
14
|
+
A53B9E0A16B039F3003532F5 /* MAZeroingWeakProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A53B9E0416B039F3003532F5 /* MAZeroingWeakProxy.m */; };
|
15
|
+
A53B9E0B16B039F3003532F5 /* MAZeroingWeakRef.m in Sources */ = {isa = PBXBuildFile; fileRef = A53B9E0516B039F3003532F5 /* MAZeroingWeakRef.m */; };
|
16
|
+
A53B9E1316B03AC7003532F5 /* MMRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = A53B9E1216B03AC7003532F5 /* MMRuntime.m */; };
|
17
|
+
/* End PBXBuildFile section */
|
18
|
+
|
19
|
+
/* Begin PBXCopyFilesBuildPhase section */
|
20
|
+
A53B9DEE16B0394A003532F5 /* CopyFiles */ = {
|
21
|
+
isa = PBXCopyFilesBuildPhase;
|
22
|
+
buildActionMask = 2147483647;
|
23
|
+
dstPath = "include/${PRODUCT_NAME}";
|
24
|
+
dstSubfolderSpec = 16;
|
25
|
+
files = (
|
26
|
+
);
|
27
|
+
runOnlyForDeploymentPostprocessing = 0;
|
28
|
+
};
|
29
|
+
/* End PBXCopyFilesBuildPhase section */
|
30
|
+
|
31
|
+
/* Begin PBXFileReference section */
|
32
|
+
A53B9DF016B0394A003532F5 /* libMMRuntime.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMMRuntime.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
33
|
+
A53B9DF316B0394A003532F5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
34
|
+
A53B9DF716B0394A003532F5 /* MMRuntime-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MMRuntime-Prefix.pch"; sourceTree = "<group>"; };
|
35
|
+
A53B9E0116B039F3003532F5 /* MANotificationCenterAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MANotificationCenterAdditions.m; sourceTree = "<group>"; };
|
36
|
+
A53B9E0216B039F3003532F5 /* MAWeakArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MAWeakArray.m; sourceTree = "<group>"; };
|
37
|
+
A53B9E0316B039F3003532F5 /* MAWeakDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MAWeakDictionary.m; sourceTree = "<group>"; };
|
38
|
+
A53B9E0416B039F3003532F5 /* MAZeroingWeakProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MAZeroingWeakProxy.m; sourceTree = "<group>"; };
|
39
|
+
A53B9E0516B039F3003532F5 /* MAZeroingWeakRef.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MAZeroingWeakRef.m; sourceTree = "<group>"; };
|
40
|
+
A53B9E0616B039F3003532F5 /* MAZeroingWeakRefNativeZWRNotAllowedTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAZeroingWeakRefNativeZWRNotAllowedTable.h; sourceTree = "<group>"; };
|
41
|
+
A53B9E1216B03AC7003532F5 /* MMRuntime.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMRuntime.m; sourceTree = "<group>"; };
|
42
|
+
A53B9E1516B04002003532F5 /* MANotificationCenterAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MANotificationCenterAdditions.h; sourceTree = "<group>"; };
|
43
|
+
A53B9E1616B04002003532F5 /* MAWeakArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAWeakArray.h; sourceTree = "<group>"; };
|
44
|
+
A53B9E1716B04002003532F5 /* MAWeakDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAWeakDictionary.h; sourceTree = "<group>"; };
|
45
|
+
A53B9E1816B04002003532F5 /* MAZeroingWeakProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAZeroingWeakProxy.h; sourceTree = "<group>"; };
|
46
|
+
A53B9E1916B04002003532F5 /* MAZeroingWeakRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAZeroingWeakRef.h; sourceTree = "<group>"; };
|
47
|
+
A53B9E1A16B04002003532F5 /* MMRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMRuntime.h; sourceTree = "<group>"; };
|
48
|
+
/* End PBXFileReference section */
|
49
|
+
|
50
|
+
/* Begin PBXFrameworksBuildPhase section */
|
51
|
+
A53B9DED16B0394A003532F5 /* Frameworks */ = {
|
52
|
+
isa = PBXFrameworksBuildPhase;
|
53
|
+
buildActionMask = 2147483647;
|
54
|
+
files = (
|
55
|
+
A53B9DF416B0394A003532F5 /* Foundation.framework in Frameworks */,
|
56
|
+
);
|
57
|
+
runOnlyForDeploymentPostprocessing = 0;
|
58
|
+
};
|
59
|
+
/* End PBXFrameworksBuildPhase section */
|
60
|
+
|
61
|
+
/* Begin PBXGroup section */
|
62
|
+
A53B9DE516B0394A003532F5 = {
|
63
|
+
isa = PBXGroup;
|
64
|
+
children = (
|
65
|
+
A53B9DF516B0394A003532F5 /* MMRuntime */,
|
66
|
+
A53B9DF216B0394A003532F5 /* Frameworks */,
|
67
|
+
A53B9DF116B0394A003532F5 /* Products */,
|
68
|
+
);
|
69
|
+
sourceTree = "<group>";
|
70
|
+
};
|
71
|
+
A53B9DF116B0394A003532F5 /* Products */ = {
|
72
|
+
isa = PBXGroup;
|
73
|
+
children = (
|
74
|
+
A53B9DF016B0394A003532F5 /* libMMRuntime.a */,
|
75
|
+
);
|
76
|
+
name = Products;
|
77
|
+
sourceTree = "<group>";
|
78
|
+
};
|
79
|
+
A53B9DF216B0394A003532F5 /* Frameworks */ = {
|
80
|
+
isa = PBXGroup;
|
81
|
+
children = (
|
82
|
+
A53B9DF316B0394A003532F5 /* Foundation.framework */,
|
83
|
+
);
|
84
|
+
name = Frameworks;
|
85
|
+
sourceTree = "<group>";
|
86
|
+
};
|
87
|
+
A53B9DF516B0394A003532F5 /* MMRuntime */ = {
|
88
|
+
isa = PBXGroup;
|
89
|
+
children = (
|
90
|
+
A53B9E1516B04002003532F5 /* MANotificationCenterAdditions.h */,
|
91
|
+
A53B9E1616B04002003532F5 /* MAWeakArray.h */,
|
92
|
+
A53B9E1716B04002003532F5 /* MAWeakDictionary.h */,
|
93
|
+
A53B9E1816B04002003532F5 /* MAZeroingWeakProxy.h */,
|
94
|
+
A53B9E1916B04002003532F5 /* MAZeroingWeakRef.h */,
|
95
|
+
A53B9E1A16B04002003532F5 /* MMRuntime.h */,
|
96
|
+
A53B9E0116B039F3003532F5 /* MANotificationCenterAdditions.m */,
|
97
|
+
A53B9E0216B039F3003532F5 /* MAWeakArray.m */,
|
98
|
+
A53B9E0316B039F3003532F5 /* MAWeakDictionary.m */,
|
99
|
+
A53B9E0416B039F3003532F5 /* MAZeroingWeakProxy.m */,
|
100
|
+
A53B9E0516B039F3003532F5 /* MAZeroingWeakRef.m */,
|
101
|
+
A53B9E0616B039F3003532F5 /* MAZeroingWeakRefNativeZWRNotAllowedTable.h */,
|
102
|
+
A53B9E1216B03AC7003532F5 /* MMRuntime.m */,
|
103
|
+
A53B9DF616B0394A003532F5 /* Supporting Files */,
|
104
|
+
);
|
105
|
+
path = MMRuntime;
|
106
|
+
sourceTree = "<group>";
|
107
|
+
};
|
108
|
+
A53B9DF616B0394A003532F5 /* Supporting Files */ = {
|
109
|
+
isa = PBXGroup;
|
110
|
+
children = (
|
111
|
+
A53B9DF716B0394A003532F5 /* MMRuntime-Prefix.pch */,
|
112
|
+
);
|
113
|
+
name = "Supporting Files";
|
114
|
+
sourceTree = "<group>";
|
115
|
+
};
|
116
|
+
/* End PBXGroup section */
|
117
|
+
|
118
|
+
/* Begin PBXNativeTarget section */
|
119
|
+
A53B9DEF16B0394A003532F5 /* MMRuntime */ = {
|
120
|
+
isa = PBXNativeTarget;
|
121
|
+
buildConfigurationList = A53B9DFE16B0394A003532F5 /* Build configuration list for PBXNativeTarget "MMRuntime" */;
|
122
|
+
buildPhases = (
|
123
|
+
A53B9DEC16B0394A003532F5 /* Sources */,
|
124
|
+
A53B9DED16B0394A003532F5 /* Frameworks */,
|
125
|
+
A53B9DEE16B0394A003532F5 /* CopyFiles */,
|
126
|
+
);
|
127
|
+
buildRules = (
|
128
|
+
);
|
129
|
+
dependencies = (
|
130
|
+
);
|
131
|
+
name = MMRuntime;
|
132
|
+
productName = MMRuntime;
|
133
|
+
productReference = A53B9DF016B0394A003532F5 /* libMMRuntime.a */;
|
134
|
+
productType = "com.apple.product-type.library.static";
|
135
|
+
};
|
136
|
+
/* End PBXNativeTarget section */
|
137
|
+
|
138
|
+
/* Begin PBXProject section */
|
139
|
+
A53B9DE716B0394A003532F5 /* Project object */ = {
|
140
|
+
isa = PBXProject;
|
141
|
+
attributes = {
|
142
|
+
LastUpgradeCheck = 0450;
|
143
|
+
ORGANIZATIONNAME = "Vladimir Pouzanov";
|
144
|
+
};
|
145
|
+
buildConfigurationList = A53B9DEA16B0394A003532F5 /* Build configuration list for PBXProject "MMRuntime" */;
|
146
|
+
compatibilityVersion = "Xcode 3.2";
|
147
|
+
developmentRegion = English;
|
148
|
+
hasScannedForEncodings = 0;
|
149
|
+
knownRegions = (
|
150
|
+
en,
|
151
|
+
);
|
152
|
+
mainGroup = A53B9DE516B0394A003532F5;
|
153
|
+
productRefGroup = A53B9DF116B0394A003532F5 /* Products */;
|
154
|
+
projectDirPath = "";
|
155
|
+
projectRoot = "";
|
156
|
+
targets = (
|
157
|
+
A53B9DEF16B0394A003532F5 /* MMRuntime */,
|
158
|
+
);
|
159
|
+
};
|
160
|
+
/* End PBXProject section */
|
161
|
+
|
162
|
+
/* Begin PBXSourcesBuildPhase section */
|
163
|
+
A53B9DEC16B0394A003532F5 /* Sources */ = {
|
164
|
+
isa = PBXSourcesBuildPhase;
|
165
|
+
buildActionMask = 2147483647;
|
166
|
+
files = (
|
167
|
+
A53B9E0716B039F3003532F5 /* MANotificationCenterAdditions.m in Sources */,
|
168
|
+
A53B9E0816B039F3003532F5 /* MAWeakArray.m in Sources */,
|
169
|
+
A53B9E0916B039F3003532F5 /* MAWeakDictionary.m in Sources */,
|
170
|
+
A53B9E0A16B039F3003532F5 /* MAZeroingWeakProxy.m in Sources */,
|
171
|
+
A53B9E0B16B039F3003532F5 /* MAZeroingWeakRef.m in Sources */,
|
172
|
+
A53B9E1316B03AC7003532F5 /* MMRuntime.m in Sources */,
|
173
|
+
);
|
174
|
+
runOnlyForDeploymentPostprocessing = 0;
|
175
|
+
};
|
176
|
+
/* End PBXSourcesBuildPhase section */
|
177
|
+
|
178
|
+
/* Begin XCBuildConfiguration section */
|
179
|
+
A53B9DFC16B0394A003532F5 /* Debug */ = {
|
180
|
+
isa = XCBuildConfiguration;
|
181
|
+
buildSettings = {
|
182
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
183
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
184
|
+
CLANG_CXX_LIBRARY = "libc++";
|
185
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
186
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
187
|
+
COPY_PHASE_STRIP = NO;
|
188
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
189
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
190
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
191
|
+
GCC_PREPROCESSOR_DEFINITIONS = (
|
192
|
+
"DEBUG=1",
|
193
|
+
"$(inherited)",
|
194
|
+
);
|
195
|
+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
196
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
197
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
198
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
199
|
+
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
|
200
|
+
ONLY_ACTIVE_ARCH = YES;
|
201
|
+
SDKROOT = iphoneos;
|
202
|
+
};
|
203
|
+
name = Debug;
|
204
|
+
};
|
205
|
+
A53B9DFD16B0394A003532F5 /* Release */ = {
|
206
|
+
isa = XCBuildConfiguration;
|
207
|
+
buildSettings = {
|
208
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
209
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
210
|
+
CLANG_CXX_LIBRARY = "libc++";
|
211
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
212
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
213
|
+
COPY_PHASE_STRIP = YES;
|
214
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
215
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
216
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
217
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
218
|
+
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
|
219
|
+
SDKROOT = iphoneos;
|
220
|
+
VALIDATE_PRODUCT = YES;
|
221
|
+
};
|
222
|
+
name = Release;
|
223
|
+
};
|
224
|
+
A53B9DFF16B0394A003532F5 /* Debug */ = {
|
225
|
+
isa = XCBuildConfiguration;
|
226
|
+
buildSettings = {
|
227
|
+
DSTROOT = /tmp/MMRuntime.dst;
|
228
|
+
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
229
|
+
GCC_PREFIX_HEADER = "MMRuntime/MMRuntime-Prefix.pch";
|
230
|
+
OTHER_LDFLAGS = "-ObjC";
|
231
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
232
|
+
SKIP_INSTALL = YES;
|
233
|
+
};
|
234
|
+
name = Debug;
|
235
|
+
};
|
236
|
+
A53B9E0016B0394A003532F5 /* Release */ = {
|
237
|
+
isa = XCBuildConfiguration;
|
238
|
+
buildSettings = {
|
239
|
+
DSTROOT = /tmp/MMRuntime.dst;
|
240
|
+
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
241
|
+
GCC_PREFIX_HEADER = "MMRuntime/MMRuntime-Prefix.pch";
|
242
|
+
OTHER_LDFLAGS = "-ObjC";
|
243
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
244
|
+
SKIP_INSTALL = YES;
|
245
|
+
};
|
246
|
+
name = Release;
|
247
|
+
};
|
248
|
+
/* End XCBuildConfiguration section */
|
249
|
+
|
250
|
+
/* Begin XCConfigurationList section */
|
251
|
+
A53B9DEA16B0394A003532F5 /* Build configuration list for PBXProject "MMRuntime" */ = {
|
252
|
+
isa = XCConfigurationList;
|
253
|
+
buildConfigurations = (
|
254
|
+
A53B9DFC16B0394A003532F5 /* Debug */,
|
255
|
+
A53B9DFD16B0394A003532F5 /* Release */,
|
256
|
+
);
|
257
|
+
defaultConfigurationIsVisible = 0;
|
258
|
+
defaultConfigurationName = Release;
|
259
|
+
};
|
260
|
+
A53B9DFE16B0394A003532F5 /* Build configuration list for PBXNativeTarget "MMRuntime" */ = {
|
261
|
+
isa = XCConfigurationList;
|
262
|
+
buildConfigurations = (
|
263
|
+
A53B9DFF16B0394A003532F5 /* Debug */,
|
264
|
+
A53B9E0016B0394A003532F5 /* Release */,
|
265
|
+
);
|
266
|
+
defaultConfigurationIsVisible = 0;
|
267
|
+
};
|
268
|
+
/* End XCConfigurationList section */
|
269
|
+
};
|
270
|
+
rootObject = A53B9DE716B0394A003532F5 /* Project object */;
|
271
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
//
|
2
|
+
// MANotificationCenterAdditions.h
|
3
|
+
// ZeroingWeakRef
|
4
|
+
//
|
5
|
+
// Created by Michael Ash on 7/12/10.
|
6
|
+
//
|
7
|
+
|
8
|
+
#import <Foundation/Foundation.h>
|
9
|
+
|
10
|
+
|
11
|
+
@interface NSNotificationCenter (MAZeroingWeakRefAdditions)
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Returns an opaque observation handle that can be removed with NSNotificationCenter's 'removeObserver:'.
|
15
|
+
*/
|
16
|
+
- (id)addWeakObserver: (id)observer selector: (SEL)selector name: (NSString *)name object: (id)object;
|
17
|
+
|
18
|
+
@end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
//
|
2
|
+
// MANotificationCenterAdditions.m
|
3
|
+
// ZeroingWeakRef
|
4
|
+
//
|
5
|
+
// Created by Michael Ash on 7/12/10.
|
6
|
+
//
|
7
|
+
|
8
|
+
#import "MANotificationCenterAdditions.h"
|
9
|
+
|
10
|
+
#import "MAZeroingWeakRef.h"
|
11
|
+
|
12
|
+
|
13
|
+
@implementation NSNotificationCenter (MAZeroingWeakRefAdditions)
|
14
|
+
|
15
|
+
- (id)addWeakObserver: (id)observer selector: (SEL)selector name: (NSString *)name object: (id)object
|
16
|
+
{
|
17
|
+
MAZeroingWeakRef *ref = [[MAZeroingWeakRef alloc] initWithTarget: observer];
|
18
|
+
|
19
|
+
id noteObj = [self addObserverForName: name object:object queue: nil usingBlock: ^(NSNotification *note) {
|
20
|
+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
21
|
+
|
22
|
+
id observer = [ref target];
|
23
|
+
[observer performSelector: selector withObject: note];
|
24
|
+
|
25
|
+
[pool release];
|
26
|
+
}];
|
27
|
+
|
28
|
+
[ref setCleanupBlock: ^(id target) {
|
29
|
+
[self removeObserver: noteObj];
|
30
|
+
[ref autorelease];
|
31
|
+
}];
|
32
|
+
|
33
|
+
return noteObj;
|
34
|
+
}
|
35
|
+
|
36
|
+
@end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
//
|
2
|
+
// MAWeakArray.m
|
3
|
+
// ZeroingWeakRef
|
4
|
+
//
|
5
|
+
// Created by Mike Ash on 7/13/10.
|
6
|
+
//
|
7
|
+
|
8
|
+
#import "MAWeakArray.h"
|
9
|
+
|
10
|
+
#import "MAZeroingWeakRef.h"
|
11
|
+
|
12
|
+
|
13
|
+
@implementation MAWeakArray
|
14
|
+
|
15
|
+
- (id)init
|
16
|
+
{
|
17
|
+
return [self initWithCapacity:0];
|
18
|
+
}
|
19
|
+
|
20
|
+
- (id)initWithCapacity:(NSUInteger)numItems
|
21
|
+
{
|
22
|
+
if((self = [super init]))
|
23
|
+
{
|
24
|
+
_weakRefs = [[NSMutableArray alloc] initWithCapacity:numItems];
|
25
|
+
}
|
26
|
+
return self;
|
27
|
+
}
|
28
|
+
|
29
|
+
- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt
|
30
|
+
{
|
31
|
+
self = [self initWithCapacity:cnt];
|
32
|
+
|
33
|
+
for(NSInteger i = 0; i < cnt; i++)
|
34
|
+
if(objects[i] != nil)
|
35
|
+
[self addObject:objects[i]];
|
36
|
+
|
37
|
+
return self;
|
38
|
+
}
|
39
|
+
|
40
|
+
- (void)dealloc
|
41
|
+
{
|
42
|
+
[_weakRefs release];
|
43
|
+
[super dealloc];
|
44
|
+
}
|
45
|
+
|
46
|
+
- (NSUInteger)count
|
47
|
+
{
|
48
|
+
return [_weakRefs count];
|
49
|
+
}
|
50
|
+
|
51
|
+
- (id)objectAtIndex: (NSUInteger)index
|
52
|
+
{
|
53
|
+
return [[_weakRefs objectAtIndex: index] target];
|
54
|
+
}
|
55
|
+
|
56
|
+
- (void)addObject: (id)anObject
|
57
|
+
{
|
58
|
+
[_weakRefs addObject: [MAZeroingWeakRef refWithTarget: anObject]];
|
59
|
+
}
|
60
|
+
|
61
|
+
- (void)insertObject: (id)anObject atIndex: (NSUInteger)index
|
62
|
+
{
|
63
|
+
[_weakRefs insertObject: [MAZeroingWeakRef refWithTarget: anObject]
|
64
|
+
atIndex: index];
|
65
|
+
}
|
66
|
+
|
67
|
+
- (void)removeLastObject
|
68
|
+
{
|
69
|
+
[_weakRefs removeLastObject];
|
70
|
+
}
|
71
|
+
|
72
|
+
- (void)removeObjectAtIndex: (NSUInteger)index
|
73
|
+
{
|
74
|
+
[_weakRefs removeObjectAtIndex: index];
|
75
|
+
}
|
76
|
+
|
77
|
+
- (void)replaceObjectAtIndex: (NSUInteger)index withObject: (id)anObject
|
78
|
+
{
|
79
|
+
[_weakRefs replaceObjectAtIndex: index
|
80
|
+
withObject: [MAZeroingWeakRef refWithTarget: anObject]];
|
81
|
+
}
|
82
|
+
|
83
|
+
- (id)copyWithZone:(NSZone *)zone
|
84
|
+
{
|
85
|
+
id *objects = calloc([self count], sizeof(id));
|
86
|
+
NSInteger count = 0;
|
87
|
+
|
88
|
+
for(id obj in self)
|
89
|
+
if(obj != nil)
|
90
|
+
{
|
91
|
+
objects[count] = obj;
|
92
|
+
count++;
|
93
|
+
}
|
94
|
+
|
95
|
+
NSArray *ret = [[NSArray alloc] initWithObjects:objects count:count];
|
96
|
+
|
97
|
+
free(objects);
|
98
|
+
|
99
|
+
return ret;
|
100
|
+
}
|
101
|
+
|
102
|
+
- (id)mutableCopyWithZone:(NSZone *)zone
|
103
|
+
{
|
104
|
+
id *objects = calloc([self count], sizeof(id));
|
105
|
+
NSInteger count = 0;
|
106
|
+
|
107
|
+
for(id obj in self)
|
108
|
+
if(obj != nil)
|
109
|
+
{
|
110
|
+
objects[count] = obj;
|
111
|
+
count++;
|
112
|
+
}
|
113
|
+
|
114
|
+
NSArray *ret = [[NSMutableArray alloc] initWithObjects:objects count:count];
|
115
|
+
|
116
|
+
free(objects);
|
117
|
+
|
118
|
+
return ret;
|
119
|
+
}
|
120
|
+
|
121
|
+
@end
|