Re: [Hessianobjc-user] Bug decoding references to mapped class instances
Status: Alpha
Brought to you by:
cocoa_dood
|
From: Tore H. <ha...@pv...> - 2007-12-16 22:32:00
|
Hello.
This patch make it impossible to decode self-refering object graphs as
you sometimes need an updated refArray before the complete Map is
decoded.
I think this should be handled as a special case in decodeRef instead.
Regards,
- Tore.
On Dec 15, 2007, at 02:22, Tom Davies wrote:
> When a map is decoded, the NSDictionary is stored in the refArray,
> even if the dictionary is subsequently mapped to a class. This means
> that references get the dictionary, not the class:
>
> Here's a simple fix which defers storing the reference until the end:
>
> - (id) decodeMap {
> id dict = [NSMutableDictionary dictionary];
> - //add the pointer to the ref array and not the actually value.
> - [refArray addObject:[NSValue valueWithPointer:dict]];
> Class mappedClass = nil;
> uint8_t objectTag = 'e';
> if([dataInputStream hasBytesAvailable]) {
> @@ -264,9 +297,11 @@
> if(mappedClass) {
> //a mapped class, user map decoder to init object
> BBSHessianMapDecoder * mapDecoder =
> [[[BBSHessianMapDecoder alloc] initForReadingWithDictionary:dict]
> autorelease];
> - id obj = [[[mappedClass alloc] initWithCoder:mapDecoder]
> autorelease];
> + id obj = [[[mappedClass alloc] initWithCoder:mapDecoder]
> autorelease];
> + [refArray addObject:[NSValue valueWithPointer:obj]];
> return obj;
> }
> + [refArray addObject:[NSValue valueWithPointer:dict]];
> return dict;
> }
> else {
>
>
>
> -------------------------------------------------------------------------
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services
> for just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Hessianobjc-user mailing list
> Hes...@li...
> https://lists.sourceforge.net/lists/listinfo/hessianobjc-user
>
|