PageRenderTime 69ms CodeModel.GetById 45ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/Frameworks/Debug/Foundation/objj.platform/Foundation.sj

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 7398 lines | 7348 code | 50 blank | 0 comment | 0 complexity | 7e7ccd4c4b044b8ba53940fea92d2cb5 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1@STATIC;1.0;p;13;CPArray+KVO.ji;9;CPArray.jc;15620;
   2{
   3var the_class = objj_getClass("CPObject")
   4if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPObject\""));
   5var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("mutableArrayValueForKey:"), function $CPObject__mutableArrayValueForKey_(self, _cmd, aKey)
   6{ with(self)
   7{
   8 return objj_msgSend(objj_msgSend(_CPKVCArray, "alloc"), "initWithKey:forProxyObject:", aKey, self);
   9}
  10}), new objj_method(sel_getUid("mutableArrayValueForKeyPath:"), function $CPObject__mutableArrayValueForKeyPath_(self, _cmd, aKeyPath)
  11{ with(self)
  12{
  13    var dotIndex = aKeyPath.indexOf(".");
  14    if (dotIndex < 0)
  15        return objj_msgSend(self, "mutableArrayValueForKey:", aKeyPath);
  16    var firstPart = aKeyPath.substring(0, dotIndex),
  17        lastPart = aKeyPath.substring(dotIndex+1);
  18    return objj_msgSend(objj_msgSend(self, "valueForKeyPath:", firstPart), "valueForKeyPath:", lastPart);
  19}
  20})]);
  21}
  22{var the_class = objj_allocateClassPair(CPArray, "_CPKVCArray"),
  23meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_proxyObject"), new objj_ivar("_key"), new objj_ivar("_insertSEL"), new objj_ivar("_insert"), new objj_ivar("_removeSEL"), new objj_ivar("_remove"), new objj_ivar("_replaceSEL"), new objj_ivar("_replace"), new objj_ivar("_insertManySEL"), new objj_ivar("_insertMany"), new objj_ivar("_removeManySEL"), new objj_ivar("_removeMany"), new objj_ivar("_replaceManySEL"), new objj_ivar("_replaceMany"), new objj_ivar("_objectAtIndexSEL"), new objj_ivar("_objectAtIndex"), new objj_ivar("_countSEL"), new objj_ivar("_count"), new objj_ivar("_accessSEL"), new objj_ivar("_access"), new objj_ivar("_setSEL"), new objj_ivar("_set")]);
  24objj_registerClassPair(the_class);
  25objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  26class_addMethods(the_class, [new objj_method(sel_getUid("initWithKey:forProxyObject:"), function $_CPKVCArray__initWithKey_forProxyObject_(self, _cmd, aKey, anObject)
  27{ with(self)
  28{
  29    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPArray") }, "init");
  30    _key = aKey;
  31    _proxyObject = anObject;
  32    var capitalizedKey = _key.charAt(0).toUpperCase() + _key.substring(1);
  33    _insertSEL = sel_getName("insertObject:in"+capitalizedKey+"AtIndex:");
  34    if (objj_msgSend(_proxyObject, "respondsToSelector:", _insertSEL))
  35        _insert = objj_msgSend(_proxyObject, "methodForSelector:", _insertSEL);
  36    _removeSEL = sel_getName("removeObjectFrom"+capitalizedKey+"AtIndex:");
  37    if (objj_msgSend(_proxyObject, "respondsToSelector:", _removeSEL))
  38        _remove = objj_msgSend(_proxyObject, "methodForSelector:", _removeSEL);
  39    _replaceSEL = sel_getName("replaceObjectFrom"+capitalizedKey+"AtIndex:withObject:");
  40    if (objj_msgSend(_proxyObject, "respondsToSelector:", _replaceSEL))
  41        _replace = objj_msgSend(_proxyObject, "methodForSelector:", _replaceSEL);
  42    _insertManySEL = sel_getName("insertObjects:in"+capitalizedKey+"AtIndexes:");
  43    if (objj_msgSend(_proxyObject, "respondsToSelector:", _insertManySEL))
  44        _insert = objj_msgSend(_proxyObject, "methodForSelector:", _insertManySEL);
  45    _removeManySEL = sel_getName("removeObjectsFrom"+capitalizedKey+"AtIndexes:");
  46    if (objj_msgSend(_proxyObject, "respondsToSelector:", _removeManySEL))
  47        _remove = objj_msgSend(_proxyObject, "methodForSelector:", _removeManySEL);
  48    _replaceManySEL = sel_getName("replaceObjectsFrom"+capitalizedKey+"AtIndexes:withObjects:");
  49    if (objj_msgSend(_proxyObject, "respondsToSelector:", _replaceManySEL))
  50        _replace = objj_msgSend(_proxyObject, "methodForSelector:", _replaceManySEL);
  51    _objectAtIndexSEL = sel_getName("objectIn"+capitalizedKey+"AtIndex:");
  52    if (objj_msgSend(_proxyObject, "respondsToSelector:", _objectAtIndexSEL))
  53        _objectAtIndex = objj_msgSend(_proxyObject, "methodForSelector:", _objectAtIndexSEL);
  54    _countSEL = sel_getName("countOf"+capitalizedKey);
  55    if (objj_msgSend(_proxyObject, "respondsToSelector:", _countSEL))
  56        _count = objj_msgSend(_proxyObject, "methodForSelector:", _countSEL);
  57    _accessSEL = sel_getName(_key);
  58    if (objj_msgSend(_proxyObject, "respondsToSelector:", _accessSEL))
  59        _access = objj_msgSend(_proxyObject, "methodForSelector:", _accessSEL);
  60    _setSEL = sel_getName("set"+capitalizedKey+":");
  61    if (objj_msgSend(_proxyObject, "respondsToSelector:", _setSEL))
  62        _set = objj_msgSend(_proxyObject, "methodForSelector:", _setSEL);
  63    return self;
  64}
  65}), new objj_method(sel_getUid("copy"), function $_CPKVCArray__copy(self, _cmd)
  66{ with(self)
  67{
  68    var theCopy = [],
  69        count = objj_msgSend(self, "count");
  70    for (var i=0; i<count; i++)
  71        objj_msgSend(theCopy, "addObject:", objj_msgSend(self, "objectAtIndex:", i));
  72    return theCopy;
  73}
  74}), new objj_method(sel_getUid("_representedObject"), function $_CPKVCArray___representedObject(self, _cmd)
  75{ with(self)
  76{
  77    if (_access)
  78        return _access(_proxyObject, _accessSEL);
  79    return objj_msgSend(_proxyObject, "valueForKey:", _key);
  80}
  81}), new objj_method(sel_getUid("_setRepresentedObject:"), function $_CPKVCArray___setRepresentedObject_(self, _cmd, anObject)
  82{ with(self)
  83{
  84    if (_set)
  85        return _set(_proxyObject, _setSEL, anObject);
  86    objj_msgSend(_proxyObject, "setValue:forKey:", anObject, _key);
  87}
  88}), new objj_method(sel_getUid("count"), function $_CPKVCArray__count(self, _cmd)
  89{ with(self)
  90{
  91    if (_count)
  92        return _count(_proxyObject, _countSEL);
  93    return objj_msgSend(objj_msgSend(self, "_representedObject"), "count");
  94}
  95}), new objj_method(sel_getUid("objectAtIndex:"), function $_CPKVCArray__objectAtIndex_(self, _cmd, anIndex)
  96{ with(self)
  97{
  98    if(_objectAtIndex)
  99        return _objectAtIndex(_proxyObject, _objectAtIndexSEL, anIndex);
 100    return objj_msgSend(objj_msgSend(self, "_representedObject"), "objectAtIndex:", anIndex);
 101}
 102}), new objj_method(sel_getUid("addObject:"), function $_CPKVCArray__addObject_(self, _cmd, anObject)
 103{ with(self)
 104{
 105    if (_insert)
 106        return _insert(_proxyObject, _insertSEL, anObject, objj_msgSend(self, "count"));
 107    var target = objj_msgSend(objj_msgSend(self, "_representedObject"), "copy");
 108    objj_msgSend(target, "addObject:", anObject);
 109    objj_msgSend(self, "_setRepresentedObject:", target);
 110}
 111}), new objj_method(sel_getUid("insertObject:atIndex:"), function $_CPKVCArray__insertObject_atIndex_(self, _cmd, anObject, anIndex)
 112{ with(self)
 113{
 114    if (_insert)
 115        return _insert(_proxyObject, _insertSEL, anObject, anIndex);
 116    var target = objj_msgSend(objj_msgSend(self, "_representedObject"), "copy");
 117    objj_msgSend(target, "insertObject:atIndex:", anObject, anIndex);
 118    objj_msgSend(self, "_setRepresentedObject:", target);
 119}
 120}), new objj_method(sel_getUid("removeLastObject"), function $_CPKVCArray__removeLastObject(self, _cmd)
 121{ with(self)
 122{
 123    if(_remove)
 124        return _remove(_proxyObject, _removeSEL, objj_msgSend(self, "count")-1);
 125    var target = objj_msgSend(objj_msgSend(self, "_representedObject"), "copy");
 126    objj_msgSend(target, "removeLastObject");
 127    objj_msgSend(self, "_setRepresentedObject:", target);
 128}
 129}), new objj_method(sel_getUid("removeObjectAtIndex:"), function $_CPKVCArray__removeObjectAtIndex_(self, _cmd, anIndex)
 130{ with(self)
 131{
 132    if(_remove)
 133        return _remove(_proxyObject, _removeSEL, anIndex);
 134    var target = objj_msgSend(objj_msgSend(self, "_representedObject"), "copy");
 135    objj_msgSend(target, "removeObjectAtIndex:", anIndex);
 136    objj_msgSend(self, "_setRepresentedObject:", target);
 137}
 138}), new objj_method(sel_getUid("replaceObjectAtIndex:withObject:"), function $_CPKVCArray__replaceObjectAtIndex_withObject_(self, _cmd, anIndex, anObject)
 139{ with(self)
 140{
 141    if(_replace)
 142        return _replace(_proxyObject, _replaceSEL, anIndex, anObject);
 143    var target = objj_msgSend(objj_msgSend(self, "_representedObject"), "copy");
 144    objj_msgSend(target, "replaceObjectAtIndex:withObject:", anIndex, anObject);
 145    objj_msgSend(self, "_setRepresentedObject:", target);
 146}
 147}), new objj_method(sel_getUid("objectsAtIndexes:"), function $_CPKVCArray__objectsAtIndexes_(self, _cmd, indexes)
 148{ with(self)
 149{
 150    var index = objj_msgSend(indexes, "firstIndex"),
 151        objects = [];
 152    while(index != CPNotFound)
 153    {
 154        objj_msgSend(objects, "addObject:", objj_msgSend(self, "objectAtIndex:", index));
 155        index = objj_msgSend(indexes, "indexGreaterThanIndex:", index);
 156    }
 157    return objects;
 158}
 159})]);
 160class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $_CPKVCArray__alloc(self, _cmd)
 161{ with(self)
 162{
 163    var a = [];
 164    a.isa = self;
 165    var ivars = class_copyIvarList(self),
 166        count = ivars.length;
 167    while (count--)
 168        a[ivar_getName(ivars[count])] = nil;
 169    return a;
 170}
 171})]);
 172}
 173{
 174var the_class = objj_getClass("CPArray")
 175if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPArray\""));
 176var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("valueForKey:"), function $CPArray__valueForKey_(self, _cmd, aKey)
 177{ with(self)
 178{
 179    if (aKey.indexOf("@") === 0)
 180    {
 181        if (aKey.indexOf(".") !== -1)
 182            objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "called valueForKey: on an array with a complex key ("+aKey+"). use valueForKeyPath:");
 183        if (aKey == "@count")
 184            return length;
 185        return nil;
 186    }
 187    else
 188    {
 189        var newArray = [],
 190            enumerator = objj_msgSend(self, "objectEnumerator"),
 191            object;
 192        while ((object = objj_msgSend(enumerator, "nextObject")) !== nil)
 193        {
 194            var value = objj_msgSend(object, "valueForKey:", aKey);
 195            if (value === nil || value === undefined)
 196                value = objj_msgSend(CPNull, "null");
 197            newArray.push(value);
 198        }
 199        return newArray;
 200    }
 201}
 202}), new objj_method(sel_getUid("valueForKeyPath:"), function $CPArray__valueForKeyPath_(self, _cmd, aKeyPath)
 203{ with(self)
 204{
 205    if (aKeyPath.indexOf("@") === 0)
 206    {
 207        var dotIndex = aKeyPath.indexOf("."),
 208            operator = aKeyPath.substring(1, dotIndex),
 209            parameter = aKeyPath.substring(dotIndex+1);
 210        if (kvoOperators[operator])
 211            return kvoOperators[operator](self, _cmd, parameter);
 212        return nil;
 213    }
 214    else
 215    {
 216        var newArray = [],
 217            enumerator = objj_msgSend(self, "objectEnumerator"),
 218            object;
 219        while ((object = objj_msgSend(enumerator, "nextObject")) !== nil)
 220        {
 221            var value = objj_msgSend(object, "valueForKeyPath:", aKeyPath);
 222            if (value === nil || value === undefined)
 223                value = objj_msgSend(CPNull, "null");
 224            newArray.push(value);
 225        }
 226        return newArray;
 227    }
 228}
 229}), new objj_method(sel_getUid("setValue:forKey:"), function $CPArray__setValue_forKey_(self, _cmd, aValue, aKey)
 230{ with(self)
 231{
 232    var enumerator = objj_msgSend(self, "objectEnumerator"),
 233        object;
 234    while (object = objj_msgSend(enumerator, "nextObject"))
 235        objj_msgSend(object, "setValue:forKey:", aValue, aKey);
 236}
 237}), new objj_method(sel_getUid("setValue:forKeyPath:"), function $CPArray__setValue_forKeyPath_(self, _cmd, aValue, aKeyPath)
 238{ with(self)
 239{
 240    var enumerator = objj_msgSend(self, "objectEnumerator"),
 241        object;
 242    while (object = objj_msgSend(enumerator, "nextObject"))
 243        objj_msgSend(object, "setValue:forKeyPath:", aValue, aKeyPath);
 244}
 245})]);
 246}
 247var kvoOperators = [];
 248kvoOperators["avg"] = avgOperator= function(self, _cmd, param)
 249{
 250    var objects = objj_msgSend(self, "valueForKeyPath:", param),
 251        length = objj_msgSend(objects, "count"),
 252        index = length;
 253        average = 0.0;
 254    if (!length)
 255        return 0;
 256    while(index--)
 257        average += objj_msgSend(objects[index], "doubleValue");
 258    return average / length;
 259}
 260kvoOperators["max"] = maxOperator= function(self, _cmd, param)
 261{
 262    var objects = objj_msgSend(self, "valueForKeyPath:", param),
 263        index = objj_msgSend(objects, "count") - 1,
 264        max = objj_msgSend(objects, "lastObject");
 265    while (index--)
 266    {
 267        var item = objects[index];
 268        if (objj_msgSend(max, "compare:", item) < 0)
 269            max = item;
 270    }
 271    return max;
 272}
 273kvoOperators["min"] = minOperator= function(self, _cmd, param)
 274{
 275    var objects = objj_msgSend(self, "valueForKeyPath:", param),
 276        index = objj_msgSend(objects, "count") - 1,
 277        min = objj_msgSend(objects, "lastObject");
 278    while (index--)
 279    {
 280        var item = objects[index];
 281        if (objj_msgSend(min, "compare:", item) > 0)
 282            min = item;
 283    }
 284    return min;
 285}
 286kvoOperators["count"] = countOperator= function(self, _cmd, param)
 287{
 288    return objj_msgSend(self, "count");
 289}
 290kvoOperators["sum"] = sumOperator= function(self, _cmd, param)
 291{
 292    var objects = objj_msgSend(self, "valueForKeyPath:", param),
 293        index = objj_msgSend(objects, "count"),
 294        sum = 0.0;
 295    while(index--)
 296        sum += objj_msgSend(objects[index], "doubleValue");
 297    return sum;
 298}
 299{
 300var the_class = objj_getClass("CPArray")
 301if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPArray\""));
 302var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("addObserver:toObjectsAtIndexes:forKeyPath:options:context:"), function $CPArray__addObserver_toObjectsAtIndexes_forKeyPath_options_context_(self, _cmd, anObserver, indexes, aKeyPath, options, context)
 303{ with(self)
 304{
 305    var index = objj_msgSend(indexes, "firstIndex");
 306    while (index >= 0)
 307    {
 308        objj_msgSend(self[index], "addObserver:forKeyPath:options:context:", anObserver, aKeyPath, options, context);
 309        index = objj_msgSend(indexes, "indexGreaterThanIndex:", index);
 310    }
 311}
 312}), new objj_method(sel_getUid("removeObserver:fromObjectsAtIndexes:forKeyPath:"), function $CPArray__removeObserver_fromObjectsAtIndexes_forKeyPath_(self, _cmd, anObserver, indexes, aKeyPath)
 313{ with(self)
 314{
 315    var index = objj_msgSend(indexes, "firstIndex");
 316    while (index >= 0)
 317    {
 318        objj_msgSend(self[index], "removeObserver:forKeyPath:", anObserver, aKeyPath);
 319        index = objj_msgSend(indexes, "indexGreaterThanIndex:", index);
 320    }
 321}
 322}), new objj_method(sel_getUid("addObserver:forKeyPath:options:context:"), function $CPArray__addObserver_forKeyPath_options_context_(self, _cmd, observer, aKeyPath, options, context)
 323{ with(self)
 324{
 325    if (objj_msgSend(isa, "instanceMethodForSelector:", _cmd) === objj_msgSend(CPArray, "instanceMethodForSelector:", _cmd))
 326        objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "Unsupported method on CPArray");
 327    else
 328        objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPArray").super_class }, "addObserver:forKeyPath:options:context:", observer, aKeyPath, options, context);
 329}
 330}), new objj_method(sel_getUid("removeObserver:forKeyPath:"), function $CPArray__removeObserver_forKeyPath_(self, _cmd, observer, aKeyPath)
 331{ with(self)
 332{
 333    if (objj_msgSend(isa, "instanceMethodForSelector:", _cmd) === objj_msgSend(CPArray, "instanceMethodForSelector:", _cmd))
 334        objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "Unsupported method on CPArray");
 335    else
 336        objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPArray").super_class }, "removeObserver:forKeyPath:", observer, aKeyPath);
 337}
 338})]);
 339}
 340
 341p;9;CPArray.ji;10;CPObject.ji;9;CPRange.ji;14;CPEnumerator.ji;18;CPSortDescriptor.ji;13;CPException.jc;25556;
 342{var the_class = objj_allocateClassPair(CPEnumerator, "_CPArrayEnumerator"),
 343meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_array"), new objj_ivar("_index")]);
 344objj_registerClassPair(the_class);
 345objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
 346class_addMethods(the_class, [new objj_method(sel_getUid("initWithArray:"), function $_CPArrayEnumerator__initWithArray_(self, _cmd, anArray)
 347{ with(self)
 348{
 349    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPEnumerator") }, "init");
 350    if (self)
 351    {
 352        _array = anArray;
 353        _index = -1;
 354    }
 355    return self;
 356}
 357}), new objj_method(sel_getUid("nextObject"), function $_CPArrayEnumerator__nextObject(self, _cmd)
 358{ with(self)
 359{
 360    if (++_index >= objj_msgSend(_array, "count"))
 361        return nil;
 362    return objj_msgSend(_array, "objectAtIndex:", _index);
 363}
 364})]);
 365}
 366{var the_class = objj_allocateClassPair(CPEnumerator, "_CPReverseArrayEnumerator"),
 367meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_array"), new objj_ivar("_index")]);
 368objj_registerClassPair(the_class);
 369objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
 370class_addMethods(the_class, [new objj_method(sel_getUid("initWithArray:"), function $_CPReverseArrayEnumerator__initWithArray_(self, _cmd, anArray)
 371{ with(self)
 372{
 373    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPEnumerator") }, "init");
 374    if (self)
 375    {
 376        _array = anArray;
 377        _index = objj_msgSend(_array, "count");
 378    }
 379    return self;
 380}
 381}), new objj_method(sel_getUid("nextObject"), function $_CPReverseArrayEnumerator__nextObject(self, _cmd)
 382{ with(self)
 383{
 384    if (--_index < 0)
 385        return nil;
 386    return objj_msgSend(_array, "objectAtIndex:", _index);
 387}
 388})]);
 389}
 390{var the_class = objj_allocateClassPair(CPObject, "CPArray"),
 391meta_class = the_class.isa;objj_registerClassPair(the_class);
 392objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
 393class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPArray__init(self, _cmd)
 394{ with(self)
 395{
 396    return self;
 397}
 398}), new objj_method(sel_getUid("initWithArray:"), function $CPArray__initWithArray_(self, _cmd, anArray)
 399{ with(self)
 400{
 401    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
 402    if (self)
 403        objj_msgSend(self, "setArray:", anArray);
 404    return self;
 405}
 406}), new objj_method(sel_getUid("initWithArray:copyItems:"), function $CPArray__initWithArray_copyItems_(self, _cmd, anArray, copyItems)
 407{ with(self)
 408{
 409    if (!copyItems)
 410        return objj_msgSend(self, "initWithArray:", anArray);
 411    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
 412    if (self)
 413    {
 414        var index = 0,
 415            count = objj_msgSend(anArray, "count");
 416        for(; index < count; ++i)
 417        {
 418            if (anArray[i].isa)
 419                self[i] = objj_msgSend(anArray, "copy");
 420            else
 421                self[i] = anArray;
 422        }
 423    }
 424    return self;
 425}
 426}), new objj_method(sel_getUid("initWithObjects:"), function $CPArray__initWithObjects_(self, _cmd, anArray)
 427{ with(self)
 428{
 429    var i = 2,
 430        argument;
 431    for(; i < arguments.length && (argument = arguments[i]) != nil; ++i)
 432        push(argument);
 433    return self;
 434}
 435}), new objj_method(sel_getUid("initWithObjects:count:"), function $CPArray__initWithObjects_count_(self, _cmd, objects, aCount)
 436{ with(self)
 437{
 438    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
 439    if (self)
 440    {
 441        var index = 0;
 442        for(; index < aCount; ++index)
 443            push(objects[index]);
 444    }
 445    return self;
 446}
 447}), new objj_method(sel_getUid("hash"), function $CPArray__hash(self, _cmd)
 448{ with(self)
 449{
 450    if (self.__address == nil)
 451        self.__address = _objj_generateObjectHash();
 452    return self.__address;
 453}
 454}), new objj_method(sel_getUid("containsObject:"), function $CPArray__containsObject_(self, _cmd, anObject)
 455{ with(self)
 456{
 457    return objj_msgSend(self, "indexOfObject:", anObject) != CPNotFound;
 458}
 459}), new objj_method(sel_getUid("count"), function $CPArray__count(self, _cmd)
 460{ with(self)
 461{
 462    return length;
 463}
 464}), new objj_method(sel_getUid("indexOfObject:"), function $CPArray__indexOfObject_(self, _cmd, anObject)
 465{ with(self)
 466{
 467    if (anObject === nil)
 468        return CPNotFound;
 469    var i = 0,
 470        count = length;
 471    if (anObject.isa)
 472    {
 473        for(; i < count; ++i)
 474            if(objj_msgSend(self[i], "isEqual:", anObject))
 475                return i;
 476    }
 477    else if (self.indexOf)
 478        return indexOf(anObject);
 479    else
 480        for(; i < count; ++i)
 481            if(self[i] == anObject)
 482                return i;
 483    return CPNotFound;
 484}
 485}), new objj_method(sel_getUid("indexOfObject:inRange:"), function $CPArray__indexOfObject_inRange_(self, _cmd, anObject, aRange)
 486{ with(self)
 487{
 488    if (anObject === nil)
 489        return CPNotFound;
 490    var i = aRange.location,
 491        count = MIN(CPMaxRange(aRange), length);
 492    if (anObject.isa)
 493    {
 494        for(; i < count; ++i)
 495            if(objj_msgSend(self[i], "isEqual:", anObject))
 496                return i;
 497    }
 498    else
 499        for(; i < count; ++i)
 500            if(self[i] == anObject)
 501                return i;
 502    return CPNotFound;
 503}
 504}), new objj_method(sel_getUid("indexOfObjectIdenticalTo:"), function $CPArray__indexOfObjectIdenticalTo_(self, _cmd, anObject)
 505{ with(self)
 506{
 507    if (anObject === nil)
 508        return CPNotFound;
 509    if (self.indexOf)
 510        return indexOf(anObject);
 511    else
 512    {
 513        var index = 0,
 514            count = length;
 515        for(; index < count; ++index)
 516            if(self[index] == anObject)
 517                return index;
 518    }
 519    return CPNotFound;
 520}
 521}), new objj_method(sel_getUid("indexOfObjectIdenticalTo:inRange:"), function $CPArray__indexOfObjectIdenticalTo_inRange_(self, _cmd, anObject, aRange)
 522{ with(self)
 523{
 524    if (anObject === nil)
 525        return CPNotFound;
 526    if (self.indexOf)
 527    {
 528        var index = indexOf(anObject, aRange.location);
 529        if (CPLocationInRange(index, aRange))
 530            return index;
 531    }
 532    else
 533    {
 534        var index = aRange.location,
 535            count = MIN(CPMaxRange(aRange), length);
 536        for(; index < count; ++index)
 537            if(self[index] == anObject)
 538                return index;
 539    }
 540    return CPNotFound;
 541}
 542}), new objj_method(sel_getUid("indexOfObject:sortedBySelector:"), function $CPArray__indexOfObject_sortedBySelector_(self, _cmd, anObject, aSelector)
 543{ with(self)
 544{
 545    return objj_msgSend(self, "indexOfObject:sortedByFunction:", anObject,  function(lhs, rhs) { objj_msgSend(lhs, aSelector, rhs); });
 546}
 547}), new objj_method(sel_getUid("indexOfObject:sortedByFunction:"), function $CPArray__indexOfObject_sortedByFunction_(self, _cmd, anObject, aFunction)
 548{ with(self)
 549{
 550    return objj_msgSend(self, "indexOfObject:sortedByFunction:context:", anObject, aFunction, nil);
 551}
 552}), new objj_method(sel_getUid("indexOfObject:sortedByFunction:context:"), function $CPArray__indexOfObject_sortedByFunction_context_(self, _cmd, anObject, aFunction, aContext)
 553{ with(self)
 554{
 555    if (!aFunction || anObject === undefined)
 556        return CPNotFound;
 557    var mid, c, first = 0, last = length - 1;
 558    while (first <= last)
 559    {
 560        mid = FLOOR((first + last) / 2);
 561          c = aFunction(anObject, self[mid], aContext);
 562        if (c > 0)
 563            first = mid + 1;
 564        else if (c < 0)
 565            last = mid - 1;
 566        else
 567        {
 568            while (mid < length - 1 && aFunction(anObject, self[mid+1], aContext) == CPOrderedSame)
 569                mid++;
 570            return mid;
 571        }
 572    }
 573    return CPNotFound;
 574}
 575}), new objj_method(sel_getUid("indexOfObject:sortedByDescriptors:"), function $CPArray__indexOfObject_sortedByDescriptors_(self, _cmd, anObject, descriptors)
 576{ with(self)
 577{
 578    objj_msgSend(self, "indexOfObject:sortedByFunction:", anObject, function(lhs, rhs)
 579    {
 580        var i = 0,
 581            count = objj_msgSend(descriptors, "count"),
 582            result = CPOrderedSame;
 583        while (i < count)
 584            if((result = objj_msgSend(descriptors[i++], "compareObject:withObject:", lhs, rhs)) != CPOrderedSame)
 585                return result;
 586        return result;
 587    });
 588}
 589}), new objj_method(sel_getUid("lastObject"), function $CPArray__lastObject(self, _cmd)
 590{ with(self)
 591{
 592    var count = objj_msgSend(self, "count");
 593    if (!count) return nil;
 594    return self[count - 1];
 595}
 596}), new objj_method(sel_getUid("objectAtIndex:"), function $CPArray__objectAtIndex_(self, _cmd, anIndex)
 597{ with(self)
 598{
 599    return self[anIndex];
 600}
 601}), new objj_method(sel_getUid("objectsAtIndexes:"), function $CPArray__objectsAtIndexes_(self, _cmd, indexes)
 602{ with(self)
 603{
 604    var index = objj_msgSend(indexes, "firstIndex"),
 605        objects = [];
 606    while(index != CPNotFound)
 607    {
 608        objj_msgSend(objects, "addObject:", self[index]);
 609        index = objj_msgSend(indexes, "indexGreaterThanIndex:", index);
 610    }
 611    return objects;
 612}
 613}), new objj_method(sel_getUid("objectEnumerator"), function $CPArray__objectEnumerator(self, _cmd)
 614{ with(self)
 615{
 616    return objj_msgSend(objj_msgSend(_CPArrayEnumerator, "alloc"), "initWithArray:", self);
 617}
 618}), new objj_method(sel_getUid("reverseObjectEnumerator"), function $CPArray__reverseObjectEnumerator(self, _cmd)
 619{ with(self)
 620{
 621    return objj_msgSend(objj_msgSend(_CPReverseArrayEnumerator, "alloc"), "initWithArray:", self);
 622}
 623}), new objj_method(sel_getUid("makeObjectsPerformSelector:"), function $CPArray__makeObjectsPerformSelector_(self, _cmd, aSelector)
 624{ with(self)
 625{
 626    if (!aSelector)
 627        objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "makeObjectsPerformSelector: 'aSelector' can't be nil");
 628    var index = 0,
 629        count = length;
 630    for(; index < count; ++index)
 631        objj_msgSend(self[index], aSelector);
 632}
 633}), new objj_method(sel_getUid("makeObjectsPerformSelector:withObject:"), function $CPArray__makeObjectsPerformSelector_withObject_(self, _cmd, aSelector, anObject)
 634{ with(self)
 635{
 636    if (!aSelector)
 637        objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "makeObjectsPerformSelector:withObject 'aSelector' can't be nil");
 638    var index = 0,
 639        count = length;
 640    for(; index < count; ++index)
 641        objj_msgSend(self[index], aSelector, anObject);
 642}
 643}), new objj_method(sel_getUid("firstObjectCommonWithArray:"), function $CPArray__firstObjectCommonWithArray_(self, _cmd, anArray)
 644{ with(self)
 645{
 646    if (!objj_msgSend(anArray, "count") || !objj_msgSend(self, "count"))
 647        return nil;
 648    var i = 0,
 649        count = objj_msgSend(self, "count");
 650    for(; i < count; ++i)
 651        if(objj_msgSend(anArray, "containsObject:", self[i]))
 652            return self[i];
 653    return nil;
 654}
 655}), new objj_method(sel_getUid("isEqualToArray:"), function $CPArray__isEqualToArray_(self, _cmd, anArray)
 656{ with(self)
 657{
 658    if (self === anArray)
 659        return YES;
 660    if(length != anArray.length)
 661        return NO;
 662    var index = 0,
 663        count = objj_msgSend(self, "count");
 664    for(; index < count; ++index)
 665    {
 666        var lhs = self[index],
 667            rhs = anArray[index];
 668        if (lhs !== rhs && (!lhs.isa || !rhs.isa || !objj_msgSend(lhs, "isEqual:", rhs)))
 669            return NO;
 670    }
 671    return YES;
 672}
 673}), new objj_method(sel_getUid("isEqual:"), function $CPArray__isEqual_(self, _cmd, anObject)
 674{ with(self)
 675{
 676    if (self === anObject)
 677        return YES;
 678    if(!objj_msgSend(anObject, "isKindOfClass:", objj_msgSend(CPArray, "class")))
 679        return NO;
 680    return objj_msgSend(self, "isEqualToArray:", anObject);
 681}
 682}), new objj_method(sel_getUid("arrayByAddingObject:"), function $CPArray__arrayByAddingObject_(self, _cmd, anObject)
 683{ with(self)
 684{
 685    if (anObject === nil || anObject === undefined)
 686        objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "arrayByAddingObject: object can't be nil");
 687    var array = objj_msgSend(self, "copy");
 688    array.push(anObject);
 689    return array;
 690}
 691}), new objj_method(sel_getUid("arrayByAddingObjectsFromArray:"), function $CPArray__arrayByAddingObjectsFromArray_(self, _cmd, anArray)
 692{ with(self)
 693{
 694    return slice(0).concat(anArray);
 695}
 696}), new objj_method(sel_getUid("subarrayWithRange:"), function $CPArray__subarrayWithRange_(self, _cmd, aRange)
 697{ with(self)
 698{
 699    if (aRange.location < 0 || CPMaxRange(aRange) > length)
 700        objj_msgSend(CPException, "raise:reason:", CPRangeException, "subarrayWithRange: aRange out of bounds");
 701    return slice(aRange.location, CPMaxRange(aRange));
 702}
 703}), new objj_method(sel_getUid("sortedArrayUsingDescriptors:"), function $CPArray__sortedArrayUsingDescriptors_(self, _cmd, descriptors)
 704{ with(self)
 705{
 706    var sorted = objj_msgSend(self, "copy");
 707    objj_msgSend(sorted, "sortUsingDescriptors:", descriptors);
 708    return sorted;
 709}
 710}), new objj_method(sel_getUid("sortedArrayUsingFunction:"), function $CPArray__sortedArrayUsingFunction_(self, _cmd, aFunction)
 711{ with(self)
 712{
 713    return objj_msgSend(self, "sortedArrayUsingFunction:context:", aFunction, nil);
 714}
 715}), new objj_method(sel_getUid("sortedArrayUsingFunction:context:"), function $CPArray__sortedArrayUsingFunction_context_(self, _cmd, aFunction, aContext)
 716{ with(self)
 717{
 718    var sorted = objj_msgSend(self, "copy");
 719    objj_msgSend(sorted, "sortUsingFunction:context:", aFunction, aContext);
 720    return sorted;
 721}
 722}), new objj_method(sel_getUid("sortedArrayUsingSelector:"), function $CPArray__sortedArrayUsingSelector_(self, _cmd, aSelector)
 723{ with(self)
 724{
 725    var sorted = objj_msgSend(self, "copy")
 726    objj_msgSend(sorted, "sortUsingSelector:", aSelector);
 727    return sorted;
 728}
 729}), new objj_method(sel_getUid("componentsJoinedByString:"), function $CPArray__componentsJoinedByString_(self, _cmd, aString)
 730{ with(self)
 731{
 732    return join(aString);
 733}
 734}), new objj_method(sel_getUid("description"), function $CPArray__description(self, _cmd)
 735{ with(self)
 736{
 737    var i = 0,
 738        count = objj_msgSend(self, "count"),
 739        description = '(';
 740    for(; i < count; ++i)
 741    {
 742        if (self[i].isa) description += objj_msgSend(self[i], "description");
 743        else description += self[i];
 744        if (i != count - 1) description += ", ";
 745    }
 746    return description + ')';
 747}
 748}), new objj_method(sel_getUid("pathsMatchingExtensions:"), function $CPArray__pathsMatchingExtensions_(self, _cmd, filterTypes)
 749{ with(self)
 750{
 751    var index = 0,
 752        count = objj_msgSend(self, "count"),
 753        array = [];
 754    for(; index < count; ++index)
 755        if (self[index].isa && objj_msgSend(self[index], "isKindOfClass:", objj_msgSend(CPString, "class")) && objj_msgSend(filterTypes, "containsObject:", objj_msgSend(self[index], "pathExtension")))
 756            array.push(self[index]);
 757    return array;
 758}
 759}), new objj_method(sel_getUid("setValue:forKey:"), function $CPArray__setValue_forKey_(self, _cmd, aValue, aKey)
 760{ with(self)
 761{
 762    var i = 0,
 763        count = objj_msgSend(self, "count");
 764    for(; i < count; ++i)
 765        objj_msgSend(self[i], "setValue:forKey:", aValue, aKey);
 766}
 767}), new objj_method(sel_getUid("valueForKey:"), function $CPArray__valueForKey_(self, _cmd, aKey)
 768{ with(self)
 769{
 770    var i = 0,
 771        count = objj_msgSend(self, "count"),
 772        array = [];
 773    for(; i < count; ++i)
 774        array.push(objj_msgSend(self[i], "valueForKey:", aKey));
 775    return array;
 776}
 777}), new objj_method(sel_getUid("copy"), function $CPArray__copy(self, _cmd)
 778{ with(self)
 779{
 780    return slice(0);
 781}
 782})]);
 783class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $CPArray__alloc(self, _cmd)
 784{ with(self)
 785{
 786    return [];
 787}
 788}), new objj_method(sel_getUid("array"), function $CPArray__array(self, _cmd)
 789{ with(self)
 790{
 791    return objj_msgSend(objj_msgSend(self, "alloc"), "init");
 792}
 793}), new objj_method(sel_getUid("arrayWithArray:"), function $CPArray__arrayWithArray_(self, _cmd, anArray)
 794{ with(self)
 795{
 796    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithArray:", anArray);
 797}
 798}), new objj_method(sel_getUid("arrayWithObject:"), function $CPArray__arrayWithObject_(self, _cmd, anObject)
 799{ with(self)
 800{
 801    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithObjects:", anObject);
 802}
 803}), new objj_method(sel_getUid("arrayWithObjects:"), function $CPArray__arrayWithObjects_(self, _cmd, anObject)
 804{ with(self)
 805{
 806    var i = 2,
 807        array = objj_msgSend(objj_msgSend(self, "alloc"), "init"),
 808        argument;
 809    for(; i < arguments.length && (argument = arguments[i]) != nil; ++i)
 810        array.push(argument);
 811    return array;
 812}
 813}), new objj_method(sel_getUid("arrayWithObjects:count:"), function $CPArray__arrayWithObjects_count_(self, _cmd, objects, aCount)
 814{ with(self)
 815{
 816    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithObjects:count:", objects, aCount);
 817}
 818})]);
 819}
 820{
 821var the_class = objj_getClass("CPArray")
 822if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPArray\""));
 823var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCapacity:"), function $CPArray__initWithCapacity_(self, _cmd, aCapacity)
 824{ with(self)
 825{
 826    return self;
 827}
 828}), new objj_method(sel_getUid("addObject:"), function $CPArray__addObject_(self, _cmd, anObject)
 829{ with(self)
 830{
 831    push(anObject);
 832}
 833}), new objj_method(sel_getUid("addObjectsFromArray:"), function $CPArray__addObjectsFromArray_(self, _cmd, anArray)
 834{ with(self)
 835{
 836    splice.apply(self, [length, 0].concat(anArray));
 837}
 838}), new objj_method(sel_getUid("insertObject:atIndex:"), function $CPArray__insertObject_atIndex_(self, _cmd, anObject, anIndex)
 839{ with(self)
 840{
 841    splice(anIndex, 0, anObject);
 842}
 843}), new objj_method(sel_getUid("insertObjects:atIndexes:"), function $CPArray__insertObjects_atIndexes_(self, _cmd, objects, indexes)
 844{ with(self)
 845{
 846    var indexesCount = objj_msgSend(indexes, "count"),
 847        objectsCount = objj_msgSend(objects, "count");
 848    if(indexesCount !== objectsCount)
 849        objj_msgSend(CPException, "raise:reason:", CPRangeException, "the counts of the passed-in array (" + objectsCount + ") and index set (" + indexesCount + ") must be identical.");
 850    var lastIndex = objj_msgSend(indexes, "lastIndex");
 851    if(lastIndex >= objj_msgSend(self, "count") + indexesCount)
 852        objj_msgSend(CPException, "raise:reason:", CPRangeException, "the last index (" + lastIndex + ") must be less than the sum of the original count (" + objj_msgSend(self, "count") + ") and the insertion count (" + indexesCount + ").");
 853    var index = 0,
 854        currentIndex = objj_msgSend(indexes, "firstIndex");
 855    for (; index < objectsCount; ++index, currentIndex = objj_msgSend(indexes, "indexGreaterThanIndex:", currentIndex))
 856        objj_msgSend(self, "insertObject:atIndex:", objects[index], currentIndex);
 857}
 858}), new objj_method(sel_getUid("replaceObjectAtIndex:withObject:"), function $CPArray__replaceObjectAtIndex_withObject_(self, _cmd, anIndex, anObject)
 859{ with(self)
 860{
 861    self[anIndex] = anObject;
 862}
 863}), new objj_method(sel_getUid("replaceObjectsAtIndexes:withObjects:"), function $CPArray__replaceObjectsAtIndexes_withObjects_(self, _cmd, anIndexSet, objects)
 864{ with(self)
 865{
 866    var i = 0,
 867        index = objj_msgSend(anIndexSet, "firstIndex");
 868    while(index != CPNotFound)
 869    {
 870        objj_msgSend(self, "replaceObjectAtIndex:withObject:", index, objects[i++]);
 871        index = objj_msgSend(anIndexSet, "indexGreaterThanIndex:", index);
 872    }
 873}
 874}), new objj_method(sel_getUid("replaceObjectsInRange:withObjectsFromArray:range:"), function $CPArray__replaceObjectsInRange_withObjectsFromArray_range_(self, _cmd, aRange, anArray, otherRange)
 875{ with(self)
 876{
 877    if (!otherRange.location && otherRange.length == objj_msgSend(anArray, "count"))
 878        objj_msgSend(self, "replaceObjectsInRange:withObjectsFromArray:", aRange, anArray);
 879    else
 880        splice.apply(self, [aRange.location, aRange.length].concat(objj_msgSend(anArray, "subarrayWithRange:", otherRange)));
 881}
 882}), new objj_method(sel_getUid("replaceObjectsInRange:withObjectsFromArray:"), function $CPArray__replaceObjectsInRange_withObjectsFromArray_(self, _cmd, aRange, anArray)
 883{ with(self)
 884{
 885    splice.apply(self, [aRange.location, aRange.length].concat(anArray));
 886}
 887}), new objj_method(sel_getUid("setArray:"), function $CPArray__setArray_(self, _cmd, anArray)
 888{ with(self)
 889{
 890    if(self == anArray) return;
 891    splice.apply(self, [0, length].concat(anArray));
 892}
 893}), new objj_method(sel_getUid("removeAllObjects"), function $CPArray__removeAllObjects(self, _cmd)
 894{ with(self)
 895{
 896    splice(0, length);
 897}
 898}), new objj_method(sel_getUid("removeLastObject"), function $CPArray__removeLastObject(self, _cmd)
 899{ with(self)
 900{
 901    pop();
 902}
 903}), new objj_method(sel_getUid("removeObject:"), function $CPArray__removeObject_(self, _cmd, anObject)
 904{ with(self)
 905{
 906    objj_msgSend(self, "removeObject:inRange:", anObject, CPMakeRange(0, length));
 907}
 908}), new objj_method(sel_getUid("removeObject:inRange:"), function $CPArray__removeObject_inRange_(self, _cmd, anObject, aRange)
 909{ with(self)
 910{
 911    var index;
 912    while ((index = objj_msgSend(self, "indexOfObject:inRange:", anObject, aRange)) != CPNotFound)
 913    {
 914        objj_msgSend(self, "removeObjectAtIndex:", index);
 915        aRange = CPIntersectionRange(CPMakeRange(index, length - index), aRange);
 916    }
 917}
 918}), new objj_method(sel_getUid("removeObjectAtIndex:"), function $CPArray__removeObjectAtIndex_(self, _cmd, anIndex)
 919{ with(self)
 920{
 921    splice(anIndex, 1);
 922}
 923}), new objj_method(sel_getUid("removeObjectsAtIndexes:"), function $CPArray__removeObjectsAtIndexes_(self, _cmd, anIndexSet)
 924{ with(self)
 925{
 926    var index = objj_msgSend(anIndexSet, "lastIndex");
 927    while (index != CPNotFound)
 928    {
 929        objj_msgSend(self, "removeObjectAtIndex:", index);
 930        index = objj_msgSend(anIndexSet, "indexLessThanIndex:", index);
 931    }
 932}
 933}), new objj_method(sel_getUid("removeObjectIdenticalTo:"), function $CPArray__removeObjectIdenticalTo_(self, _cmd, anObject)
 934{ with(self)
 935{
 936    objj_msgSend(self, "removeObjectIdenticalTo:inRange:", anObject, CPMakeRange(0, length));
 937}
 938}), new objj_method(sel_getUid("removeObjectIdenticalTo:inRange:"), function $CPArray__removeObjectIdenticalTo_inRange_(self, _cmd, anObject, aRange)
 939{ with(self)
 940{
 941    var index;
 942    while ((index = objj_msgSend(self, "indexOfObjectIdenticalTo:inRange:", anObject, aRange)) != CPNotFound)
 943    {
 944        objj_msgSend(self, "removeObjectAtIndex:", index);
 945        aRange = CPIntersectionRange(CPMakeRange(index, length - index), aRange);
 946    }
 947}
 948}), new objj_method(sel_getUid("removeObjectsInArray:"), function $CPArray__removeObjectsInArray_(self, _cmd, anArray)
 949{ with(self)
 950{
 951    var index = 0,
 952        count = objj_msgSend(anArray, "count");
 953    for (; index < count; ++index)
 954        objj_msgSend(self, "removeObject:", anArray[index]);
 955}
 956}), new objj_method(sel_getUid("removeObjectsInRange:"), function $CPArray__removeObjectsInRange_(self, _cmd, aRange)
 957{ with(self)
 958{
 959    splice(aRange.location, aRange.length);
 960}
 961}), new objj_method(sel_getUid("exchangeObjectAtIndex:withObjectAtIndex:"), function $CPArray__exchangeObjectAtIndex_withObjectAtIndex_(self, _cmd, anIndex, otherIndex)
 962{ with(self)
 963{
 964    var temporary = self[anIndex];
 965    self[anIndex] = self[otherIndex];
 966    self[otherIndex] = temporary;
 967}
 968}), new objj_method(sel_getUid("sortUsingDescriptors:"), function $CPArray__sortUsingDescriptors_(self, _cmd, descriptors)
 969{ with(self)
 970{
 971    sort(function(lhs, rhs)
 972    {
 973        var i = 0,
 974            count = objj_msgSend(descriptors, "count"),
 975            result = CPOrderedSame;
 976        while(i < count)
 977            if((result = objj_msgSend(descriptors[i++], "compareObject:withObject:", lhs, rhs)) != CPOrderedSame)
 978                return result;
 979        return result;
 980    });
 981}
 982}), new objj_method(sel_getUid("sortUsingFunction:context:"), function $CPArray__sortUsingFunction_context_(self, _cmd, aFunction, aContext)
 983{ with(self)
 984{
 985    sort(function(lhs, rhs) { return aFunction(lhs, rhs, aContext); });
 986}
 987}), new objj_method(sel_getUid("sortUsingSelector:"), function $CPArray__sortUsingSelector_(self, _cmd, aSelector)
 988{ with(self)
 989{
 990    sort(function(lhs, rhs) { return objj_msgSend(lhs, aSelector, rhs); });
 991}
 992})]);
 993class_addMethods(meta_class, [new objj_method(sel_getUid("arrayWithCapacity:"), function $CPArray__arrayWithCapacity_(self, _cmd, aCapacity)
 994{ with(self)
 995{
 996    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithCapacity:", aCapacity);
 997}
 998})]);
 999}
1000{
1001var the_class = objj_getClass("CPArray")
1002if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPArray\""));
1003var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPArray__initWithCoder_(self, _cmd, aCoder)
1004{ with(self)
1005{
1006    return objj_msgSend(aCoder, "decodeObjectForKey:", "CP.objects");
1007}
1008}), new objj_method(sel_getUid("encodeWithCoder:"), function $CPArray__encodeWithCoder_(self, _cmd, aCoder)
1009{ with(self)
1010{
1011    objj_msgSend(aCoder, "_encodeArrayOfObjects:forKey:", self, "CP.objects");
1012}
1013})]);
1014}
1015{var the_class = objj_allocateClassPair(CPArray, "CPMutableArray"),
1016meta_class = the_class.isa;objj_registerClassPair(the_class);
1017objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
1018}
1019Array.prototype.isa = CPArray;
1020objj_msgSend(CPArray, "initialize");
1021
1022p;20;CPAttributedString.ji;10;CPObject.ji;10;CPString.ji;14;CPDictionary.ji;9;CPRange.jc;19869;
1023{var the_class = objj_allocateClassPair(CPObject, "CPAttributedString"),
1024meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_string"), new objj_ivar("_rangeEntries")]);
1025objj_registerClassPair(the_class);
1026objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
1027class_addMethods(the_class, [new objj_method(sel_getUid("initWithString:"), function $CPAttributedString__initWithString_(self, _cmd, aString)
1028{ with(self)
1029{
1030    return objj_msgSend(self, "initWithString:attributes:", aString, nil);
1031}
1032}), new objj_method(sel_getUid("initWithAttributedString:"), function $CPAttributedString__initWithAttributedString_(self, _cmd, aString)
1033{ with(self)
1034{
1035    var string = objj_msgSend(self, "initWithString:attributes:", "", nil);
1036    objj_msgSend(string, "setAttributedString:", aString);
1037    return string;
1038}
1039}), new objj_method(sel_getUid("initWithString:attributes:"), function $CPAttributedString__initWithString_attributes_(self, _cmd, aString, attributes)
1040{ with(self)
1041{
1042    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
1043    if (!attributes)
1044        attributes = objj_msgSend(CPDictionary, "dictionary");
1045    _string = ""+aString;
1046    _rangeEntries = [makeRangeEntry(CPMakeRange(0, _string.length), attributes)];
1047    return self;
1048}
1049}), new objj_method(sel_getUid("string"), function $CPAttributedString__string(self, _cmd)
1050{ with(self)
1051{
1052    return _string;
1053}
1054}), new objj_method(sel_getUid("mutableString"), function $CPAttributedString__mutableString(self, _cmd)
1055{ with(self)
1056{
1057    return objj_msgSend(self, "string");
1058}
1059}), new objj_method(sel_getUid("length"), function $CPAttributedString__length(self, _cmd)
1060{ with(self)
1061{
1062    return _string.length;
1063}
1064}), new objj_method(sel_getUid("_indexOfEntryWithIndex:"), function $CPAttributedString___indexOfEntryWithIndex_(self, _cmd, anIndex)
1065{ with(self)
1066{
1067    if (anIndex < 0 || anIndex > _string.length || anIndex === undefined)
1068        return CPNotFound;
1069    var sortFunction = function(index, entry)
1070    {
1071        if (CPLocationInRange(index, entry.range))
1072            return CPOrderedSame;
1073        else if (CPMaxRange(entry.range) <= index)
1074            return CPOrderedDescending;
1075        else
1076            return CPOrderedAscending;
1077    }
1078    return objj_msgSend(_rangeEntries, "indexOfObject:sortedByFunction:", anIndex, sortFunction);
1079}
1080}), new objj_method(sel_getUid("attributesAtIndex:effectiveRange:"), function $CPAttributedString__attributesAtIndex_effectiveRange_(self, _cmd, anIndex, aRange)
1081{ with(self)
1082{
1083    var entryIndex = objj_msgSend(self, "_indexOfEntryWithIndex:", anIndex);
1084    if (entryIndex == CPNotFound)
1085        return nil;
1086    var matchingRange = _rangeEntries[entryIndex];
1087    if (aRange)
1088    {
1089        aRange.location = matchingRange.range.location;
1090        aRange.length = matchingRange.range.length;
1091    }
1092    return matchingRange.attributes;
1093}
1094}), new objj_method(sel_getUid("attributesAtIndex:longestEffectiveRange:inRange:"), function $CPAttributedString__attributesAtIndex_longestEffectiveRange_inRange_(self, _cmd, anIndex, aRange, rangeLimit)
1095{ with(self)
1096{
1097    var startingEntryIndex = objj_msgSend(self, "_indexOfEntryWithIndex:", anIndex);
1098    if (startingEntryIndex == CPNotFound)
1099        return nil;
1100    if (!aRange)
1101        return _rangeEntries[startingEntryIndex].attributes;
1102    if (CPRangeInRange(_rangeEntries[startingEntryIndex].range, rangeLimit))
1103    {
1104        aRange.location = rangeLimit.location;
1105        aRange.length = rangeLimit.length;
1106        return _rangeEntries[startingEntryIndex].attributes;
1107    }
1108    var nextRangeIndex = startingEntryIndex - 1,
1109        currentEntry = _rangeEntries[startingEntryIndex],
1110        comparisonDict = currentEntry.attributes;
1111    while (nextRangeIndex >= 0)
1112    {
1113        var nextEntry = _rangeEntries[nextRangeIndex];
1114        if (CPMaxRange(nextEntry.range) > rangeLimit.location && objj_msgSend(nextEntry.attributes, "isEqualToDictionary:", comparisonDict))
1115        {
1116            currentEntry = nextEntry;
1117            nextRangeIndex--;
1118        }
1119        else
1120            break;
1121    }
1122    aRange.location = MAX(currentEntry.range.location, rangeLimit.location);
1123    currentEntry = _rangeEntries[startingEntryIndex];
1124    nextRangeIndex = startingEntryIndex + 1;
1125    while (nextRangeIndex < _rangeEntries.length)
1126    {
1127        var nextEntry = _rangeEntries[nextRangeIndex];
1128        if (nextEntry.range.location < CPMaxRange(rangeLimit) && objj_msgSend(nextEntry.attributes, "isEqualToDictionary:", comparisonDict))
1129        {
1130            currentEntry = nextEntry;
1131            nextRangeIndex++;
1132        }
1133        else
1134            break;
1135    }
1136    aRange.length = MIN(CPMaxRange(currentEntry.range), CPMaxRange(rangeLimit)) - aRange.location;
1137    return comparisonDict;
1138}
1139}), new objj_method(sel_getUid("attribute:atIndex:effectiveRange:"), function $CPAttributedString__attribute_atIndex_effectiveRange_(self, _cmd, attribute, index, aRange)
1140{ with(self)
1141{
1142    if (!attribute)
1143    {
1144        if (aRange)
1145        {
1146            aRange.location = 0;
1147            aRange.length = _string.length;
1148        }
1149        return nil;
1150    }
1151    return objj_msgSend(objj_msgSend(self, "attributesAtIndex:effectiveRange:", index, aRange), "valueForKey:", attribute);
1152}
1153}), new objj_method(sel_getUid("attribute:atIndex:longestEffectiveRange:inRange:"), function $CPAttributedString__attribute_atIndex_longestEffectiveRange_inRange_(self, _cmd, attribute, anIndex, aRange, rangeLimit)
1154{ with(self)
1155{
1156    var startingEntryIndex = objj_msgSend(self, "_indexOfEntryWithIndex:", anIndex);
1157    if (startingEntryIndex == CPNotFound || !attribute)
1158        return nil;
1159    if (!aRange)
1160        return objj_msgSend(_rangeEntries[startingEntryIndex].attributes, "objectForKey:", attribute);
1161    if (CPRangeInRange(_rangeEntries[startingEntryIndex].range, rangeLimit))
1162    {
1163        aRange.location = rangeLimit.location;
1164        aRange.length = rangeLimit.length;
1165        return objj_msgSend(_rangeEntries[startingEntryIndex].attributes, "objectForKey:", attribute);
1166    }
1167    var nextRangeIndex = startingEntryIndex - 1,
1168        currentEntry = _rangeEntries[startingEntryIndex],
1169        comparisonAttribute = objj_msgSend(currentEntry.attributes, "objectForKey:", attribute);
1170    while (nextRangeIndex >= 0)
1171    {
1172        var nextEntry = _rangeEntries[nextRangeIndex];
1173        if (CPMaxRange(nextEntry.range) > rangeLimit.location && isEqual(comparisonAttribute, objj_msgSend(nextEntry.attributes, "objectForKey:", attribute)))
1174        {
1175            currentEntry = nextEntry;
1176            nextRangeIndex--;
1177        }
1178        else
1179            break;
1180    }
1181    aRange.location = MAX(currentEntry.range.location, rangeLimit.location);
1182    currentEntry = _rangeEntries[startingEntryIndex];
1183    nextRangeIndex = startingEntryIndex + 1;
1184    while (nextRangeIndex < _rangeEntries.length)
1185    {
1186        var nextEntry = _rangeEntries[nextRangeIndex];
1187        if (nextEntry.range.location < CPMaxRange(rangeLimit) && isEqual(comparisonAttribute, objj_msgSend(nextEntry.attributes, "objectForKey:", attribute)))
1188        {
1189            currentEntry = nextEntry;
1190            nextRangeIndex++;
1191        }
1192        else
1193            break;
1194    }
1195    aRange.length = MIN(CPMaxRange(currentEntry.range), CPMaxRange(rangeLimit)) - aRange.location;
1196    return comparisonAttribute;
1197}
1198}), new objj_method(sel_getUid("isEqualToAttributedString:"), function $CPAttributedString__isEqualToAttributedString_(self, _cmd, aString)
1199{ with(self)
1200{
1201 if(!aString)
1202  return NO;
1203 if(_string != objj_msgSend(aString, "string"))
1204  return NO;
1205    var myRange = CPMakeRange(),
1206        comparisonRange = CPMakeRange(),
1207        myAttributes = objj_msgSend(self, "attributesAtIndex:effectiveRange:", 0, myRange),
1208        comparisonAttributes = objj_msgSend(aString, "attributesAtIndex:effectiveRange:", 0, comparisonRange),
1209        length = _string.length;
1210    while (CPMaxRange(CPUnionRange(myRange, comparisonRange)) < length)
1211    {
1212        if (CPIntersectionRange(myRange, comparisonRange).length > 0 && !objj_msgSend(myAttributes, "isEqualToDictionary:", comparisonAttributes))
1213            return NO;
1214        if (CPMaxRange(myRange) < CPMaxRange(comparisonRange))
1215            myAttributes = objj_msgSend(self, "attributesAtIndex:effectiveRange:", CPMaxRange(myRange), myRange);
1216        else
1217            comparisonAttributes = objj_msgSend(aString, "attributesAtIndex:effectiveRange:", CPMaxRange(comparisonRange), comparisonRange);
1218    }
1219    return YES;
1220}
1221}), new objj_method(sel_getUid("isEqual:"), fun…

Large files files are truncated, but you can click here to view the full file