PageRenderTime 43ms CodeModel.GetById 37ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Frameworks/Debug/Foundation/objj.platform/CPSet.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 302 lines | 301 code | 1 blank | 0 comment | 0 complexity | 3f25effceb6a9ee08445a6fd13a9bd13 MD5 | raw file
  1i;10;CPObject.ji;9;CPArray.ji;10;CPNumber.ji;14;CPEnumerator.jc;10411;
  2{var the_class = objj_allocateClassPair(CPObject, "CPSet"),
  3meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_contents"), new objj_ivar("_count")]);
  4objj_registerClassPair(the_class);
  5objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPSet__init(self, _cmd)
  7{ with(self)
  8{
  9    if (self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init"))
 10    {
 11        _count = 0;
 12        _contents = {};
 13    }
 14    return self;
 15}
 16}), new objj_method(sel_getUid("initWithArray:"), function $CPSet__initWithArray_(self, _cmd, anArray)
 17{ with(self)
 18{
 19    if (self = objj_msgSend(self, "init"))
 20    {
 21        var count = anArray.length;
 22        while (count--)
 23            objj_msgSend(self, "addObject:", anArray[count]);
 24    }
 25    return self;
 26}
 27}), new objj_method(sel_getUid("initWithObjects:count:"), function $CPSet__initWithObjects_count_(self, _cmd, objects, count)
 28{ with(self)
 29{
 30    return objj_msgSend(self, "initWithArray:", objects.splice(0, count));
 31}
 32}), new objj_method(sel_getUid("initWithObjects:"), function $CPSet__initWithObjects_(self, _cmd, anObject)
 33{ with(self)
 34{
 35    if (self = objj_msgSend(self, "init"))
 36    {
 37  var argLength = arguments.length,
 38   i = 2;
 39        for(; i < argLength && (argument = arguments[i]) != nil; ++i)
 40            objj_msgSend(self, "addObject:", argument);
 41    }
 42    return self;
 43}
 44}), new objj_method(sel_getUid("initWithSet:"), function $CPSet__initWithSet_(self, _cmd, aSet)
 45{ with(self)
 46{
 47    return objj_msgSend(self, "initWithSet:copyItems:", aSet, NO);
 48}
 49}), new objj_method(sel_getUid("initWithSet:copyItems:"), function $CPSet__initWithSet_copyItems_(self, _cmd, aSet, shouldCopyItems)
 50{ with(self)
 51{
 52    self = objj_msgSend(self, "init");
 53    if (!aSet)
 54        return self;
 55    var contents = aSet._contents;
 56    for (var property in contents)
 57    {
 58        if (contents.hasOwnProperty(property))
 59        {
 60            if (shouldCopyItems)
 61                objj_msgSend(self, "addObject:", objj_msgSend(contents[property], "copy"));
 62            else
 63                objj_msgSend(self, "addObject:", contents[property]);
 64        }
 65    }
 66    return self;
 67}
 68}), new objj_method(sel_getUid("allObjects"), function $CPSet__allObjects(self, _cmd)
 69{ with(self)
 70{
 71    var array = [];
 72    for (var property in _contents)
 73    {
 74        if (_contents.hasOwnProperty(property))
 75            array.push(_contents[property]);
 76    }
 77    return array;
 78}
 79}), new objj_method(sel_getUid("anyObject"), function $CPSet__anyObject(self, _cmd)
 80{ with(self)
 81{
 82    for (var property in _contents)
 83    {
 84        if (_contents.hasOwnProperty(property))
 85            return _contents[property];
 86    }
 87    return nil;
 88}
 89}), new objj_method(sel_getUid("containsObject:"), function $CPSet__containsObject_(self, _cmd, anObject)
 90{ with(self)
 91{
 92    if (_contents[objj_msgSend(anObject, "hash")] && objj_msgSend(_contents[objj_msgSend(anObject, "hash")], "isEqual:", anObject))
 93        return YES;
 94    return NO;
 95}
 96}), new objj_method(sel_getUid("count"), function $CPSet__count(self, _cmd)
 97{ with(self)
 98{
 99    return _count;
100}
101}), new objj_method(sel_getUid("intersectsSet:"), function $CPSet__intersectsSet_(self, _cmd, set)
102{ with(self)
103{
104    var items = objj_msgSend(set, "allObjects");
105    for (var i = items.length; i > 0; i--)
106    {
107        if (objj_msgSend(self, "containsObject:", items[i]))
108            return YES;
109    }
110    return NO;
111}
112}), new objj_method(sel_getUid("isEqualToSet:"), function $CPSet__isEqualToSet_(self, _cmd, set)
113{ with(self)
114{
115    return self === set || (objj_msgSend(self, "count") === objj_msgSend(set, "count") && objj_msgSend(set, "isSubsetOfSet:", self));
116}
117}), new objj_method(sel_getUid("isSubsetOfSet:"), function $CPSet__isSubsetOfSet_(self, _cmd, set)
118{ with(self)
119{
120    var items = objj_msgSend(self, "allObjects");
121    for (var i = 0; i < items.length; i++)
122    {
123        if (!objj_msgSend(set, "containsObject:", items[i]))
124            return NO;
125    }
126    return YES;
127}
128}), new objj_method(sel_getUid("makeObjectsPerformSelector:"), function $CPSet__makeObjectsPerformSelector_(self, _cmd, aSelector)
129{ with(self)
130{
131    objj_msgSend(self, "makeObjectsPerformSelector:withObject:", aSelector, nil);
132}
133}), new objj_method(sel_getUid("makeObjectsPerformSelector:withObject:"), function $CPSet__makeObjectsPerformSelector_withObject_(self, _cmd, aSelector, argument)
134{ with(self)
135{
136    var items = objj_msgSend(self, "allObjects");
137    for (var i = 0; i < items.length; i++)
138    {
139        objj_msgSend(items[i], "performSelector:withObject:", aSelector, argument);
140    }
141}
142}), new objj_method(sel_getUid("member:"), function $CPSet__member_(self, _cmd, object)
143{ with(self)
144{
145    if (objj_msgSend(self, "containsObject:", object))
146        return object;
147    return nil;
148}
149}), new objj_method(sel_getUid("objectEnumerator"), function $CPSet__objectEnumerator(self, _cmd)
150{ with(self)
151{
152    return objj_msgSend(objj_msgSend(self, "allObjects"), "objectEnumerator");
153}
154}), new objj_method(sel_getUid("initWithCapacity:"), function $CPSet__initWithCapacity_(self, _cmd, numItems)
155{ with(self)
156{
157    self = objj_msgSend(self, "init");
158    return self;
159}
160}), new objj_method(sel_getUid("setSet:"), function $CPSet__setSet_(self, _cmd, set)
161{ with(self)
162{
163    objj_msgSend(self, "removeAllObjects");
164    objj_msgSend(self, "addObjectsFromArray:", objj_msgSend(set, "allObjects"));
165}
166}), new objj_method(sel_getUid("addObject:"), function $CPSet__addObject_(self, _cmd, anObject)
167{ with(self)
168{
169    _contents[objj_msgSend(anObject, "hash")] = anObject;
170    _count++;
171}
172}), new objj_method(sel_getUid("addObjectsFromArray:"), function $CPSet__addObjectsFromArray_(self, _cmd, array)
173{ with(self)
174{
175    for (var i = 0, count = array.length; i < count; i++)
176    {
177        objj_msgSend(self, "addObject:", array[i]);
178    }
179}
180}), new objj_method(sel_getUid("removeObject:"), function $CPSet__removeObject_(self, _cmd, anObject)
181{ with(self)
182{
183    if (objj_msgSend(self, "containsObject:", anObject))
184    {
185        delete _contents[objj_msgSend(anObject, "hash")];
186        _count--;
187    }
188}
189}), new objj_method(sel_getUid("removeAllObjects"), function $CPSet__removeAllObjects(self, _cmd)
190{ with(self)
191{
192    _contents = {};
193    _count = 0;
194}
195}), new objj_method(sel_getUid("intersectSet:"), function $CPSet__intersectSet_(self, _cmd, set)
196{ with(self)
197{
198    var items = objj_msgSend(self, "allObjects");
199    for (var i = 0, count = items.length; i < count; i++)
200    {
201        if (!objj_msgSend(set, "containsObject:", items[i]))
202            objj_msgSend(self, "removeObject:", items[i]);
203    }
204}
205}), new objj_method(sel_getUid("minusSet:"), function $CPSet__minusSet_(self, _cmd, set)
206{ with(self)
207{
208    var items = objj_msgSend(set, "allObjects");
209    for (var i = 0; i < items.length; i++)
210    {
211        if (objj_msgSend(self, "containsObject:", items[i]))
212            objj_msgSend(self, "removeObject:", items[i]);
213    }
214}
215}), new objj_method(sel_getUid("unionSet:"), function $CPSet__unionSet_(self, _cmd, set)
216{ with(self)
217{
218    var items = objj_msgSend(set, "allObjects");
219    for (var i = 0, count = items.length; i < count; i++)
220    {
221        objj_msgSend(self, "addObject:", items[i]);
222    }
223}
224})]);
225class_addMethods(meta_class, [new objj_method(sel_getUid("set"), function $CPSet__set(self, _cmd)
226{ with(self)
227{
228    return objj_msgSend(objj_msgSend(self, "alloc"), "init");
229}
230}), new objj_method(sel_getUid("setWithArray:"), function $CPSet__setWithArray_(self, _cmd, array)
231{ with(self)
232{
233    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithArray:", array);
234}
235}), new objj_method(sel_getUid("setWithObject:"), function $CPSet__setWithObject_(self, _cmd, anObject)
236{ with(self)
237{
238    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithArray:", [anObject]);
239}
240}), new objj_method(sel_getUid("setWithObjects:count:"), function $CPSet__setWithObjects_count_(self, _cmd, objects, count)
241{ with(self)
242{
243    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithObjects:count:", objects, count);
244}
245}), new objj_method(sel_getUid("setWithObjects:"), function $CPSet__setWithObjects_(self, _cmd, anObject)
246{ with(self)
247{
248    var set = objj_msgSend(objj_msgSend(self, "alloc"), "init"),
249        argLength = arguments.length,
250        i = 2;
251    for(; i < argLength && ((argument = arguments[i]) !== nil); ++i)
252        objj_msgSend(set, "addObject:", argument);
253    return set;
254}
255}), new objj_method(sel_getUid("setWithSet:"), function $CPSet__setWithSet_(self, _cmd, set)
256{ with(self)
257{
258    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithSet:", set);
259}
260}), new objj_method(sel_getUid("setWithCapacity:"), function $CPSet__setWithCapacity_(self, _cmd, numItems)
261{ with(self)
262{
263    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithCapacity:", numItems);
264}
265})]);
266}
267{
268var the_class = objj_getClass("CPSet")
269if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPSet\""));
270var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("copy"), function $CPSet__copy(self, _cmd)
271{ with(self)
272{
273    return objj_msgSend(objj_msgSend(CPSet, "alloc"), "initWithSet:", self);
274}
275}), new objj_method(sel_getUid("mutableCopy"), function $CPSet__mutableCopy(self, _cmd)
276{ with(self)
277{
278    return objj_msgSend(self, "copy");
279}
280})]);
281}
282var CPSetObjectsKey = "CPSetObjectsKey";
283{
284var the_class = objj_getClass("CPSet")
285if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPSet\""));
286var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPSet__initWithCoder_(self, _cmd, aCoder)
287{ with(self)
288{
289    return objj_msgSend(self, "initWithArray:", objj_msgSend(aCoder, "decodeObjectForKey:", CPSetObjectsKey));
290}
291}), new objj_method(sel_getUid("encodeWithCoder:"), function $CPSet__encodeWithCoder_(self, _cmd, aCoder)
292{ with(self)
293{
294    objj_msgSend(aCoder, "encodeObject:forKey:", objj_msgSend(self, "allObjects"), CPSetObjectsKey);
295}
296})]);
297}
298{var the_class = objj_allocateClassPair(CPSet, "CPMutableSet"),
299meta_class = the_class.isa;objj_registerClassPair(the_class);
300objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
301}
302