/Frameworks/Debug/Foundation/objj.platform/CPDictionary.j
http://github.com/jfahrenkrug/MapKit-HelloWorld · Unknown · 260 lines · 259 code · 1 blank · 0 comment · 0 complexity · dab3270a0812acd679984fe47ab29fc9 MD5 · raw file
- i;10;CPObject.ji;14;CPEnumerator.ji;13;CPException.jc;10057;
- {var the_class = objj_allocateClassPair(CPEnumerator, "_CPDictionaryValueEnumerator"),
- meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_keyEnumerator"), new objj_ivar("_dictionary")]);
- objj_registerClassPair(the_class);
- objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
- class_addMethods(the_class, [new objj_method(sel_getUid("initWithDictionary:"), function $_CPDictionaryValueEnumerator__initWithDictionary_(self, _cmd, aDictionary)
- { with(self)
- {
- self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPEnumerator") }, "init");
- if (self)
- {
- _keyEnumerator = objj_msgSend(aDictionary, "keyEnumerator");
- _dictionary = aDictionary;
- }
- return self;
- }
- }), new objj_method(sel_getUid("nextObject"), function $_CPDictionaryValueEnumerator__nextObject(self, _cmd)
- { with(self)
- {
- var key = objj_msgSend(_keyEnumerator, "nextObject");
- if (!key)
- return nil;
- return objj_msgSend(_dictionary, "objectForKey:", key);
- }
- })]);
- }
- {var the_class = objj_allocateClassPair(CPObject, "CPDictionary"),
- meta_class = the_class.isa;objj_registerClassPair(the_class);
- objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
- class_addMethods(the_class, [new objj_method(sel_getUid("initWithDictionary:"), function $CPDictionary__initWithDictionary_(self, _cmd, aDictionary)
- { with(self)
- {
- var key = "",
- dictionary = objj_msgSend(objj_msgSend(CPDictionary, "alloc"), "init");
- for (key in aDictionary._buckets)
- objj_msgSend(dictionary, "setObject:forKey:", objj_msgSend(aDictionary, "objectForKey:", key), key);
- return dictionary;
- }
- }), new objj_method(sel_getUid("initWithObjects:forKeys:"), function $CPDictionary__initWithObjects_forKeys_(self, _cmd, objects, keyArray)
- { with(self)
- {
- self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
- if (objj_msgSend(objects, "count") != objj_msgSend(keyArray, "count"))
- objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "Counts are different.("+objj_msgSend(objects, "count")+"!="+objj_msgSend(keyArray, "count")+")");
- if (self)
- {
- var i = objj_msgSend(keyArray, "count");
- while (i--)
- objj_msgSend(self, "setObject:forKey:", objects[i], keyArray[i]);
- }
- return self;
- }
- }), new objj_method(sel_getUid("initWithObjectsAndKeys:"), function $CPDictionary__initWithObjectsAndKeys_(self, _cmd, firstObject)
- { with(self)
- {
- var argCount = arguments.length;
- if (argCount % 2 !== 0)
- objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "Key-value count is mismatched. (" + argCount + " arguments passed)");
- self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
- if (self)
- {
- var index = 2;
- for(; index < argCount; index += 2)
- {
- var value = arguments[index];
- if (value === nil)
- break;
- objj_msgSend(self, "setObject:forKey:", value, arguments[index + 1]);
- }
- }
- return self;
- }
- }), new objj_method(sel_getUid("copy"), function $CPDictionary__copy(self, _cmd)
- { with(self)
- {
- return objj_msgSend(CPDictionary, "dictionaryWithDictionary:", self);
- }
- }), new objj_method(sel_getUid("count"), function $CPDictionary__count(self, _cmd)
- { with(self)
- {
- return count;
- }
- }), new objj_method(sel_getUid("allKeys"), function $CPDictionary__allKeys(self, _cmd)
- { with(self)
- {
- return _keys;
- }
- }), new objj_method(sel_getUid("allValues"), function $CPDictionary__allValues(self, _cmd)
- { with(self)
- {
- var index = _keys.length,
- values = [];
- while (index--)
- values.push(dictionary_getValue(self, [_keys[index]]));
- return values;
- }
- }), new objj_method(sel_getUid("keyEnumerator"), function $CPDictionary__keyEnumerator(self, _cmd)
- { with(self)
- {
- return objj_msgSend(_keys, "objectEnumerator");
- }
- }), new objj_method(sel_getUid("objectEnumerator"), function $CPDictionary__objectEnumerator(self, _cmd)
- { with(self)
- {
- return objj_msgSend(objj_msgSend(_CPDictionaryValueEnumerator, "alloc"), "initWithDictionary:", self);
- }
- }), new objj_method(sel_getUid("isEqualToDictionary:"), function $CPDictionary__isEqualToDictionary_(self, _cmd, aDictionary)
- { with(self)
- {
- if (count !== objj_msgSend(aDictionary, "count"))
- return NO;
- var index = count;
- while (index--)
- {
- var currentKey = _keys[index],
- lhsObject = _buckets[currentKey],
- rhsObject = aDictionary._buckets[currentKey];
- if (lhsObject === rhsObject)
- continue;
- if (lhsObject.isa && rhsObject.isa && objj_msgSend(lhsObject, "respondsToSelector:", sel_getUid("isEqual:")) && objj_msgSend(lhsObject, "isEqual:", rhsObject))
- continue;
- return NO;
- }
- return YES;
- }
- }), new objj_method(sel_getUid("objectForKey:"), function $CPDictionary__objectForKey_(self, _cmd, aKey)
- { with(self)
- {
- var object = _buckets[aKey];
- return (object === undefined) ? nil : object;
- }
- }), new objj_method(sel_getUid("removeAllObjects"), function $CPDictionary__removeAllObjects(self, _cmd)
- { with(self)
- {
- _keys = [];
- count = 0;
- _buckets = {};
- }
- }), new objj_method(sel_getUid("removeObjectForKey:"), function $CPDictionary__removeObjectForKey_(self, _cmd, aKey)
- { with(self)
- {
- dictionary_removeValue(self, aKey);
- }
- }), new objj_method(sel_getUid("removeObjectsForKeys:"), function $CPDictionary__removeObjectsForKeys_(self, _cmd, allKeys)
- { with(self)
- {
- var index = allKeys.length;
- while (index--)
- dictionary_removeValue(self, allKeys[index]);
- }
- }), new objj_method(sel_getUid("setObject:forKey:"), function $CPDictionary__setObject_forKey_(self, _cmd, anObject, aKey)
- { with(self)
- {
- dictionary_setValue(self, aKey, anObject);
- }
- }), new objj_method(sel_getUid("addEntriesFromDictionary:"), function $CPDictionary__addEntriesFromDictionary_(self, _cmd, aDictionary)
- { with(self)
- {
- if (!aDictionary)
- return;
- var keys = objj_msgSend(aDictionary, "allKeys"),
- index = objj_msgSend(keys, "count");
- while (index--)
- {
- var key = keys[index];
- objj_msgSend(self, "setObject:forKey:", objj_msgSend(aDictionary, "objectForKey:", key), key);
- }
- }
- }), new objj_method(sel_getUid("description"), function $CPDictionary__description(self, _cmd)
- { with(self)
- {
- var description = "CPDictionary {\n";
- var i = _keys.length;
- while (i--)
- {
- description += _keys[i] + ":";
- var object = _buckets[_keys[i]];
- if (object && object.isa)
- description += objj_msgSend(object, "description");
- else
- description += object;
- description += "\n";
- }
- description += "}";
- return description;
- }
- })]);
- class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $CPDictionary__alloc(self, _cmd)
- { with(self)
- {
- return new objj_dictionary();
- }
- }), new objj_method(sel_getUid("dictionary"), function $CPDictionary__dictionary(self, _cmd)
- { with(self)
- {
- return objj_msgSend(objj_msgSend(self, "alloc"), "init");
- }
- }), new objj_method(sel_getUid("dictionaryWithDictionary:"), function $CPDictionary__dictionaryWithDictionary_(self, _cmd, aDictionary)
- { with(self)
- {
- return objj_msgSend(objj_msgSend(self, "alloc"), "initWithDictionary:", aDictionary);
- }
- }), new objj_method(sel_getUid("dictionaryWithObject:forKey:"), function $CPDictionary__dictionaryWithObject_forKey_(self, _cmd, anObject, aKey)
- { with(self)
- {
- return objj_msgSend(objj_msgSend(self, "alloc"), "initWithObjects:forKeys:", [anObject], [aKey]);
- }
- }), new objj_method(sel_getUid("dictionaryWithObjects:forKeys:"), function $CPDictionary__dictionaryWithObjects_forKeys_(self, _cmd, objects, keys)
- { with(self)
- {
- return objj_msgSend(objj_msgSend(self, "alloc"), "initWithObjects:forKeys:", objects, keys);
- }
- }), new objj_method(sel_getUid("dictionaryWithJSObject:"), function $CPDictionary__dictionaryWithJSObject_(self, _cmd, object)
- { with(self)
- {
- return objj_msgSend(self, "dictionaryWithJSObject:recursively:", object, NO);
- }
- }), new objj_method(sel_getUid("dictionaryWithJSObject:recursively:"), function $CPDictionary__dictionaryWithJSObject_recursively_(self, _cmd, object, recursively)
- { with(self)
- {
- var dictionary = objj_msgSend(objj_msgSend(self, "alloc"), "init");
- for (var key in object)
- {
- var value = object[key];
- if (recursively && value.constructor === Object)
- value = objj_msgSend(CPDictionary, "dictionaryWithJSObject:recursively:", value, YES);
- objj_msgSend(dictionary, "setObject:forKey:", value, key);
- }
- return dictionary;
- }
- }), new objj_method(sel_getUid("dictionaryWithObjectsAndKeys:"), function $CPDictionary__dictionaryWithObjectsAndKeys_(self, _cmd, firstObject)
- { with(self)
- {
- arguments[0] = objj_msgSend(self, "alloc");
- arguments[1] = sel_getUid("initWithObjectsAndKeys:");
- return objj_msgSend.apply(this, arguments);
- }
- })]);
- }
- {
- var the_class = objj_getClass("CPDictionary")
- if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPDictionary\""));
- var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPDictionary__initWithCoder_(self, _cmd, aCoder)
- { with(self)
- {
- return objj_msgSend(aCoder, "_decodeDictionaryOfObjectsForKey:", "CP.objects");
- }
- }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPDictionary__encodeWithCoder_(self, _cmd, aCoder)
- { with(self)
- {
- objj_msgSend(aCoder, "_encodeDictionaryOfObjects:forKey:", self, "CP.objects");
- }
- })]);
- }
- {var the_class = objj_allocateClassPair(CPDictionary, "CPMutableDictionary"),
- meta_class = the_class.isa;objj_registerClassPair(the_class);
- objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
- }
- objj_dictionary.prototype.isa = CPDictionary;