37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
int _OFXMLElement_Serialization_reference;
@implementation OFXMLElement (Serialization)
- (id)objectByDeserializing
{
OFAutoreleasePool *pool;
OFString *className;
Class class;
id <OFSerialization> object;
pool = [[OFAutoreleasePool alloc] init];
className = [[self attributeForName: @"class"] stringValue];
if (className == nil)
@throw [OFNotImplementedException
newWithClass: nil
selector: @selector(initWithSerialization:)];
class = objc_lookUpClass([className cString]);
if (class == Nil)
@throw [OFNotImplementedException newWithClass: Nil];
if (![class conformsToProtocol: @protocol(OFSerialization)])
@throw [OFNotImplementedException
newWithClass: class
selector: @selector(initWithSerialization:)];
object = [[class alloc] initWithSerialization: self];
@try {
[pool release];
} @catch (id e) {
[object release];
@throw e;
}
return [object autorelease];
}
@end
|
<
<
<
<
<
<
|
<
|
|
<
|
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
int _OFXMLElement_Serialization_reference;
@implementation OFXMLElement (Serialization)
- (id)objectByDeserializing
{
OFAutoreleasePool *pool;
Class class;
id <OFSerialization> object;
pool = [[OFAutoreleasePool alloc] init];
if ((class = objc_lookUpClass([name cString])) == Nil)
@throw [OFNotImplementedException newWithClass: Nil];
if (![class conformsToProtocol: @protocol(OFSerialization)])
@throw [OFNotImplementedException
newWithClass: class
selector: @selector(initWithSerialization:)];
object = [[class alloc] initWithSerialization: self];
@try {
[pool release];
} @finally {
[object autorelease];
}
return object;
}
@end
|