Updating CPDictionary and CPString to both actually subclass.. not just create a new object without inherited properties.

This commit is contained in:
Derek Hammer
2010-09-06 13:46:27 -05:00
parent 8e5471d0fe
commit 4e1766485f
2 changed files with 15 additions and 3 deletions
+3 -2
View File
@@ -84,8 +84,9 @@
*/
+ (id)alloc
{
if ([self class] !== CPDictionary && [self class] !== CPMutableDictionary) return [super alloc];
return new CFMutableDictionary();
var result = new CFMutableDictionary();
if ([self class] !== CPDictionary && [self class] !== CPMutableDictionary) result.isa = [self class];
return result;
}
/*!
+12 -1
View File
@@ -135,7 +135,7 @@ var CPStringRegexSpecialCharacters = [
*/
- (id)initWithString:(CPString)aString
{
return String(aString);
return CreateSubclassableString(aString, [self class]);
}
/*!
@@ -796,6 +796,17 @@ var CPStringRegexSpecialCharacters = [
@end
var CreateSubclassableString = function(aString, aClass)
{
if (aClass === CPString) return String(aString);
var result = new String(aString);
result.isa = aClass;
return result;
};
var diacritics = [[192,198],[224,230],[231,231],[232,235],[236,239],[242,246],[249,252]]; // Basic Latin ; Latin-1 Supplement.
var normalized = [65,97,99,101,105,111,117];