mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 20:26:42 +00:00
* Source/NSAffineTransform.m (-initWithCoder:, -encodeWithCoder:):
Add key coding and decoding for NSAffineTransform. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34800 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
82e85dab93
commit
474cfb91ed
2 changed files with 103 additions and 15 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2012-02-20 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSAffineTransform.m (-initWithCoder:, -encodeWithCoder:):
|
||||||
|
Add key coding and decoding for NSAffineTransform.
|
||||||
|
|
||||||
2012-02-19 22:37-EST Gregory John Casamento <greg.casamento@gmail.com>
|
2012-02-19 22:37-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||||
Doug Simons <doug.simons@testplant.com>
|
Doug Simons <doug.simons@testplant.com>
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#define EXPOSE_NSAffineTransform_IVARS 1
|
#define EXPOSE_NSAffineTransform_IVARS 1
|
||||||
|
|
||||||
#import "Foundation/NSArray.h"
|
#import "Foundation/NSArray.h"
|
||||||
|
#import "Foundation/NSData.h"
|
||||||
#import "Foundation/NSException.h"
|
#import "Foundation/NSException.h"
|
||||||
#import "Foundation/NSAffineTransform.h"
|
#import "Foundation/NSAffineTransform.h"
|
||||||
#import "Foundation/NSCoder.h"
|
#import "Foundation/NSCoder.h"
|
||||||
|
@ -594,18 +595,83 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
|
|
||||||
if ([aCoder allowsKeyedCoding])
|
if ([aCoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
// FIXME
|
if ([aCoder containsValueForKey: @"NSTransformStruct"])
|
||||||
return [self notImplemented: _cmd];
|
{
|
||||||
/*
|
NSUInteger length;
|
||||||
NSData *data = [aCoder decodeObjectForKey: @"NSTransformStruct"];
|
const uint8_t *data;
|
||||||
|
NSData *d;
|
||||||
unsigned int cursor = 0;
|
unsigned int cursor = 0;
|
||||||
// We get lengths of 12 and 18
|
|
||||||
NSLog(@"length %d data %@", [data length], data);
|
data = [aCoder decodeBytesForKey: @"NSTransformStruct"
|
||||||
[data deserializeDataAt: (CGFloat*)&replace
|
returnedLength: &length];
|
||||||
|
d = [NSData dataWithBytes: data length: length];
|
||||||
|
|
||||||
|
if (length == 9)
|
||||||
|
{
|
||||||
|
float f, g;
|
||||||
|
replace = identityTransform;
|
||||||
|
|
||||||
|
cursor = 1;
|
||||||
|
[d deserializeDataAt: &f
|
||||||
|
ofObjCType: "f"
|
||||||
|
atCursor: &cursor
|
||||||
|
context: nil];
|
||||||
|
[d deserializeDataAt: &g
|
||||||
|
ofObjCType: "f"
|
||||||
|
atCursor: &cursor
|
||||||
|
context: nil];
|
||||||
|
if (data[0] == 1)
|
||||||
|
{
|
||||||
|
replace.tX = f;
|
||||||
|
replace.tY = g;
|
||||||
|
}
|
||||||
|
else if (data[0] == 2)
|
||||||
|
{
|
||||||
|
replace.m11 = f;
|
||||||
|
replace.m22 = g;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
NSLog(@"Got type %d for affine transform", data[0]);
|
||||||
|
return [self notImplemented: _cmd];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (16 == length)
|
||||||
|
{
|
||||||
|
float s[4];
|
||||||
|
|
||||||
|
[d deserializeDataAt: s
|
||||||
|
ofObjCType: "[4f]"
|
||||||
|
atCursor: &cursor
|
||||||
|
context: nil];
|
||||||
|
replace.m11 = s[0];
|
||||||
|
replace.m22 = s[1];
|
||||||
|
replace.tX = s[2];
|
||||||
|
replace.tY = s[3];
|
||||||
|
}
|
||||||
|
else if (24 == length)
|
||||||
|
{
|
||||||
|
float s[6];
|
||||||
|
|
||||||
|
[d deserializeDataAt: s
|
||||||
ofObjCType: "[6f]"
|
ofObjCType: "[6f]"
|
||||||
atCursor: &cursor
|
atCursor: &cursor
|
||||||
context: nil];
|
context: nil];
|
||||||
*/
|
replace.m11 = s[0];
|
||||||
|
replace.m12 = s[1];
|
||||||
|
replace.m21 = s[2];
|
||||||
|
replace.m22 = s[3];
|
||||||
|
replace.tX = s[4];
|
||||||
|
replace.tY = s[5];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
NSLog(@"Got data %@ len %d for affine transform", d, length);
|
||||||
|
return [self notImplemented: _cmd];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -624,7 +690,24 @@ static NSAffineTransformStruct identityTransform = {
|
||||||
replace = [self transformStruct];
|
replace = [self transformStruct];
|
||||||
if ([aCoder allowsKeyedCoding])
|
if ([aCoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
// FIXME
|
if (!_isIdentity)
|
||||||
|
{
|
||||||
|
float s[6];
|
||||||
|
NSMutableData *d = [NSMutableData data];
|
||||||
|
|
||||||
|
s[0] = replace.m11;
|
||||||
|
s[1] = replace.m12;
|
||||||
|
s[2] = replace.m21;
|
||||||
|
s[3] = replace.m22;
|
||||||
|
s[4] = replace.tX;
|
||||||
|
s[5] = replace.tY;
|
||||||
|
[d serializeDataAt: s
|
||||||
|
ofObjCType: "[6f]"
|
||||||
|
context: nil];
|
||||||
|
[aCoder encodeBytes: [d bytes]
|
||||||
|
length: [d length]
|
||||||
|
forKey: @"NSTransformStruct"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue