1.1 --- a/MYASN1Object.m Wed Jun 03 17:20:53 2009 -0700
1.2 +++ b/MYASN1Object.m Thu Jun 04 18:36:30 2009 -0700
1.3 @@ -61,6 +61,15 @@
1.4 return $sprintf(@"%@[%hhu/%u/%u, %u bytes]", self.class, _tagClass,(unsigned)_constructed,_tag, _value.length);
1.5 }
1.6
1.7 +- (BOOL) isEqual: (id)object {
1.8 + return [object isKindOfClass: [MYASN1Object class]]
1.9 + && _tag==[object tag]
1.10 + && _tagClass==[object tagClass]
1.11 + && _constructed==[object constructed]
1.12 + && $equal(_value,[object value])
1.13 + && $equal(_components,[object components]);
1.14 +}
1.15 +
1.16 static void dump(id object, NSMutableString *output, NSString *indent) {
1.17 if ([object isKindOfClass: [MYASN1Object class]]) {
1.18 MYASN1Object *asn1Obj = object;
1.19 @@ -108,8 +117,7 @@
1.20 @implementation MYBitString
1.21
1.22
1.23 -- (id)initWithBits: (NSData*)bits count: (unsigned)bitCount;
1.24 -{
1.25 +- (id)initWithBits: (NSData*)bits count: (unsigned)bitCount {
1.26 Assert(bits);
1.27 Assert(bitCount <= 8*bits.length);
1.28 self = [super init];
1.29 @@ -120,6 +128,10 @@
1.30 return self;
1.31 }
1.32
1.33 ++ (MYBitString*) bitStringWithData: (NSData*)bits {
1.34 + return [[[self alloc] initWithBits: bits count: 8*bits.length] autorelease];
1.35 +}
1.36 +
1.37 - (void) dealloc
1.38 {
1.39 [_bits release];
1.40 @@ -132,4 +144,14 @@
1.41 return $sprintf(@"%@%@", [self class], _bits);
1.42 }
1.43
1.44 +- (unsigned) hash {
1.45 + return _bits.hash ^ _bitCount;
1.46 +}
1.47 +
1.48 +- (BOOL) isEqual: (id)object {
1.49 + return [object isKindOfClass: [MYBitString class]]
1.50 + && _bitCount==[object bitCount]
1.51 + && [_bits isEqual: [object bits]];
1.52 +}
1.53 +
1.54 @end