mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 08:00:47 +00:00
* Source/GSXibLoader.m: Add support for the "array" and
"dictionary" elements found in newer XIB files (Version >= 8). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33022 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
18a1c91c6c
commit
dfa18a81da
2 changed files with 120 additions and 83 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2011-05-11 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/GSXibLoader.m: Add support for the "array" and
|
||||||
|
"dictionary" elements found in newer XIB files (Version >= 8).
|
||||||
|
|
||||||
2011-05-11 Eric Wasylishen <ewasylishen@gmail.com>
|
2011-05-11 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Source/Functions.m: For functions which set the fill or stroke
|
* Source/Functions.m: For functions which set the fill or stroke
|
||||||
|
|
|
@ -794,6 +794,94 @@ didStartElement: (NSString *)elementName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) decodeObjectForXib: (GSXibElement*)element
|
||||||
|
forClassName: (NSString *)classname
|
||||||
|
withKey: (NSString *)key
|
||||||
|
{
|
||||||
|
GSXibElement *last;
|
||||||
|
Class c = [self classForClassName: classname];
|
||||||
|
id o, r;
|
||||||
|
id delegate = [self delegate];
|
||||||
|
|
||||||
|
if (c == nil)
|
||||||
|
{
|
||||||
|
c = [[self class] classForClassName: classname];
|
||||||
|
if (c == nil)
|
||||||
|
{
|
||||||
|
c = NSClassFromString(classname);
|
||||||
|
if (c == nil)
|
||||||
|
{
|
||||||
|
c = [delegate unarchiver: self
|
||||||
|
cannotDecodeObjectOfClassName: classname
|
||||||
|
originalClasses: nil];
|
||||||
|
if (c == nil)
|
||||||
|
{
|
||||||
|
[NSException raise: NSInvalidUnarchiveOperationException
|
||||||
|
format: @"[%@ -%@]: no class for name '%@'",
|
||||||
|
NSStringFromClass([self class]),
|
||||||
|
NSStringFromSelector(_cmd),
|
||||||
|
classname];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// push
|
||||||
|
last = currentElement;
|
||||||
|
currentElement = element;
|
||||||
|
|
||||||
|
// Create instance.
|
||||||
|
o = [c allocWithZone: [self zone]];
|
||||||
|
// Make sure the object stays around, even when replaced.
|
||||||
|
RETAIN(o);
|
||||||
|
if (key != nil)
|
||||||
|
[decoded setObject: o forKey: key];
|
||||||
|
r = [o initWithCoder: self];
|
||||||
|
if (r != o)
|
||||||
|
{
|
||||||
|
[delegate unarchiver: self
|
||||||
|
willReplaceObject: o
|
||||||
|
withObject: r];
|
||||||
|
ASSIGN(o, r);
|
||||||
|
if (key != nil)
|
||||||
|
[decoded setObject: o forKey: key];
|
||||||
|
}
|
||||||
|
r = [o awakeAfterUsingCoder: self];
|
||||||
|
if (r != o)
|
||||||
|
{
|
||||||
|
[delegate unarchiver: self
|
||||||
|
willReplaceObject: o
|
||||||
|
withObject: r];
|
||||||
|
ASSIGN(o, r);
|
||||||
|
if (key != nil)
|
||||||
|
[decoded setObject: o forKey: key];
|
||||||
|
}
|
||||||
|
if (delegate != nil)
|
||||||
|
{
|
||||||
|
r = [delegate unarchiver: self didDecodeObject: o];
|
||||||
|
if (r != o)
|
||||||
|
{
|
||||||
|
[delegate unarchiver: self
|
||||||
|
willReplaceObject: o
|
||||||
|
withObject: r];
|
||||||
|
ASSIGN(o, r);
|
||||||
|
if (key != nil)
|
||||||
|
[decoded setObject: o forKey: key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Balance the retain above
|
||||||
|
RELEASE(o);
|
||||||
|
|
||||||
|
// pop
|
||||||
|
currentElement = last;
|
||||||
|
|
||||||
|
if (key != nil)
|
||||||
|
{
|
||||||
|
NSDebugLLog(@"XIB", @"decoded object %@ for key %@", o, key);
|
||||||
|
}
|
||||||
|
return AUTORELEASE(o);
|
||||||
|
}
|
||||||
|
|
||||||
- (id) objectForXib: (GSXibElement*)element
|
- (id) objectForXib: (GSXibElement*)element
|
||||||
{
|
{
|
||||||
NSString *elementName;
|
NSString *elementName;
|
||||||
|
@ -807,90 +895,10 @@ didStartElement: (NSString *)elementName
|
||||||
elementName = [element type];
|
elementName = [element type];
|
||||||
if ([@"object" isEqualToString: elementName])
|
if ([@"object" isEqualToString: elementName])
|
||||||
{
|
{
|
||||||
GSXibElement *last;
|
|
||||||
NSString *classname = [element attributeForKey: @"class"];
|
NSString *classname = [element attributeForKey: @"class"];
|
||||||
Class c = [self classForClassName: classname];
|
return [self decodeObjectForXib: element
|
||||||
id o, r;
|
forClassName: classname
|
||||||
id delegate = [self delegate];
|
withKey: key];
|
||||||
|
|
||||||
if (c == nil)
|
|
||||||
{
|
|
||||||
c = [[self class] classForClassName: classname];
|
|
||||||
if (c == nil)
|
|
||||||
{
|
|
||||||
c = NSClassFromString(classname);
|
|
||||||
if (c == nil)
|
|
||||||
{
|
|
||||||
c = [delegate unarchiver: self
|
|
||||||
cannotDecodeObjectOfClassName: classname
|
|
||||||
originalClasses: nil];
|
|
||||||
if (c == nil)
|
|
||||||
{
|
|
||||||
[NSException raise:
|
|
||||||
NSInvalidUnarchiveOperationException
|
|
||||||
format: @"[%@ +%@]: no class for name '%@'",
|
|
||||||
NSStringFromClass([self class]),
|
|
||||||
NSStringFromSelector(_cmd),
|
|
||||||
classname];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// push
|
|
||||||
last = currentElement;
|
|
||||||
currentElement = element;
|
|
||||||
|
|
||||||
// Create instance.
|
|
||||||
o = [c allocWithZone: [self zone]];
|
|
||||||
// Make sure the object stays around, even when replaced.
|
|
||||||
RETAIN(o);
|
|
||||||
if (key != nil)
|
|
||||||
[decoded setObject: o forKey: key];
|
|
||||||
r = [o initWithCoder: self];
|
|
||||||
if (r != o)
|
|
||||||
{
|
|
||||||
[delegate unarchiver: self
|
|
||||||
willReplaceObject: o
|
|
||||||
withObject: r];
|
|
||||||
ASSIGN(o, r);
|
|
||||||
if (key != nil)
|
|
||||||
[decoded setObject: o forKey: key];
|
|
||||||
}
|
|
||||||
r = [o awakeAfterUsingCoder: self];
|
|
||||||
if (r != o)
|
|
||||||
{
|
|
||||||
[delegate unarchiver: self
|
|
||||||
willReplaceObject: o
|
|
||||||
withObject: r];
|
|
||||||
ASSIGN(o, r);
|
|
||||||
if (key != nil)
|
|
||||||
[decoded setObject: o forKey: key];
|
|
||||||
}
|
|
||||||
if (delegate != nil)
|
|
||||||
{
|
|
||||||
r = [delegate unarchiver: self didDecodeObject: o];
|
|
||||||
if (r != o)
|
|
||||||
{
|
|
||||||
[delegate unarchiver: self
|
|
||||||
willReplaceObject: o
|
|
||||||
withObject: r];
|
|
||||||
ASSIGN(o, r);
|
|
||||||
if (key != nil)
|
|
||||||
[decoded setObject: o forKey: key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Balance the retain above
|
|
||||||
RELEASE(o);
|
|
||||||
|
|
||||||
// pop
|
|
||||||
currentElement = last;
|
|
||||||
|
|
||||||
if (key != nil)
|
|
||||||
{
|
|
||||||
NSDebugLLog(@"XIB", @"decoded object %@ for key %@", o, key);
|
|
||||||
}
|
|
||||||
return AUTORELEASE(o);
|
|
||||||
}
|
}
|
||||||
else if ([@"string" isEqualToString: elementName])
|
else if ([@"string" isEqualToString: elementName])
|
||||||
{
|
{
|
||||||
|
@ -998,6 +1006,30 @@ didStartElement: (NSString *)elementName
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
else if ([@"array" isEqualToString: elementName])
|
||||||
|
{
|
||||||
|
NSString *classname = [element attributeForKey: @"class"];
|
||||||
|
|
||||||
|
if (classname == nil)
|
||||||
|
{
|
||||||
|
classname = @"NSArray";
|
||||||
|
}
|
||||||
|
return [self decodeObjectForXib: element
|
||||||
|
forClassName: classname
|
||||||
|
withKey: key];
|
||||||
|
}
|
||||||
|
else if ([@"dictionary" isEqualToString: elementName])
|
||||||
|
{
|
||||||
|
NSString *classname = [element attributeForKey: @"class"];
|
||||||
|
|
||||||
|
if (classname == nil)
|
||||||
|
{
|
||||||
|
classname = @"NSDictionary";
|
||||||
|
}
|
||||||
|
return [self decodeObjectForXib: element
|
||||||
|
forClassName: classname
|
||||||
|
withKey: key];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"Unknown element type %@", elementName);
|
NSLog(@"Unknown element type %@", elementName);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue