Skip to content

Commit

Permalink
Various fixes, mostly for GCC, as reported by Fred Kiefer.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/quartzcore/trunk@35429 72102866-910b-0410-8b05-ffd578937521
  • Loading branch information
ivucica committed Aug 20, 2012
1 parent 1df39b0 commit 7810987
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 62 deletions.
2 changes: 2 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ syntax: glob
*/*.xcworkspace/*
Tests/CATransform3D/catransform3d*
Tests/CAMediaTimingFunction/camediatimingfunction*
Tests/*.app/*
_notes/*

28 changes: 28 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
2012-08-20 Ivan Vučica <ivan@vucica.net>

* Headers/QuartzCore/CALayer.h:
GCC doesn't like that we declare a property as NSMutableArray
in public header and then override that with a NSArray in
class extension.

Added missing method declaration.

* Source/CAImplicitAnimationObserver.m:
Making a call to -isEqual: instead of -isEqualTo:.
Fixed a possible problem if actionForKey: returns nil or NSNull.

* Source/CALayer+DynamicProperties.h:
* Source/CARenderer.m:
Added missing method declarations.

* Source/CALayer+DynamicProperties.m:
Style fixes.

* Source/CALayer.m:
* Source/GLHelpers/CAGLTexture.m:
Resolved warnings.

* Source/Shaders/simple.fsh:
Commented out textureSize() function which broke compiling on
some GPUs.

2012-08-20 Ivan Vučica <ivan@vucica.net>

* INSTALL:
Expand Down
6 changes: 6 additions & 0 deletions Headers/QuartzCore/CALayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ NSString *const kCATransition;
@property (copy) NSDictionary *actions;
/* TODO: Style property is unimplemented */
@property (copy) NSDictionary *style;
#if __clang__
@property (retain, readonly) NSArray *animationKeys;
#else
#warning GCC workaround: CALayer.animationKeys publicly defined as NSMutableArray although it should not be.
@property (retain, readonly) NSMutableArray *animationKeys;
#endif

- (id) init;
- (id) initWithLayer: (CALayer *)layer;
Expand Down Expand Up @@ -188,6 +193,7 @@ NSString *const kCATransition;
- (BOOL) needsDisplay;
- (void) setNeedsDisplay;
- (void) setNeedsDisplayInRect: (CGRect)r;
- (void) drawInContext: (CGContextRef)context;
- (BOOL) needsLayout;
- (void) setNeedsLayout;
- (void) layoutIfNeeded;
Expand Down
4 changes: 3 additions & 1 deletion Source/CAImplicitAnimationObserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ - (void) observeValueForKeyPath: (NSString *)keyPath
/* Implicit animation must not be launched if model tree value
is equal to the new value, even if the presentation tree value
is not equal. */
if ([to isEqualTo: from])
if ([to isEqual: from])
return;

NSObject<CAAction>* action = (id)[object actionForKey: keyPath];
if (!action || [action isKindOfClass: [NSNull class]])
return;
[[CATransaction topTransaction] registerAction: action
onObject: object
keyPath: keyPath];
Expand Down
4 changes: 4 additions & 0 deletions Source/CALayer+DynamicProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@

@interface CALayer (DynamicProperties)
+ (void)_dynamicallyCreateProperty:(objc_property_t)property;

+ (NSDictionary *) _dynamicPropertyProcessAttributes: (objc_property_t)property;
+ (IMP) _getterForKey: (NSString *)key type: (NSString *)type;
+ (IMP) _setterForKey: (NSString *)key type: (NSString *)type;
@end
114 changes: 56 additions & 58 deletions Source/CALayer+DynamicProperties.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,72 +36,70 @@ @implementation CALayer (DynamicProperties)
+ (void) _dynamicallyCreateProperty: (objc_property_t)property
{

NSString* name = [NSString stringWithCString:property_getName(property)
encoding:NSASCIIStringEncoding];

NSDictionary* attributes = [self _dynamicPropertyProcessAttributes: property];

// create the method names
NSString* getterName = [attributes valueForKey:@"getter"];

if (getterName == nil)
{
getterName = name;
}

NSString* setterName = [attributes valueForKey:@"setter"];

if (setterName == nil)
{
setterName = [NSString stringWithFormat:@"set%@%@:",
[[name substringToIndex: 1] uppercaseString],
[name substringFromIndex: 1]];
}


// Set the types
NSString* type = [attributes valueForKey:@"type"];
NSString* getterTypes = [NSString stringWithFormat:@"%@@:", type];
NSString* setterTypes = [NSString stringWithFormat:@"v@:%@", type];

NSString* key = [NSString stringWithFormat:@"dynamicproperty_%@_%@",
NSStringFromClass([self class]),
name];

IMP getter = [self _getterForKey: key type: type];
IMP setter = [self _setterForKey: key type: type];

// Add getter
BOOL success;
success = class_addMethod([self class],
NSSelectorFromString(getterName),
getter,
[getterTypes cStringUsingEncoding:NSASCIIStringEncoding]);
NSString* name = [NSString stringWithCString: property_getName(property)
encoding: NSASCIIStringEncoding];

NSDictionary* attributes = [self _dynamicPropertyProcessAttributes: property];

// create the method names
NSString* getterName = [attributes valueForKey: @"getter"];
if (getterName == nil)
{
getterName = name;
}

NSString* setterName = [attributes valueForKey: @"setter"];

if (setterName == nil)
{
setterName = [NSString stringWithFormat: @"set%@%@:",
[[name substringToIndex: 1] uppercaseString],
[name substringFromIndex: 1]];
}

if (!success)
{
[NSException raise:NSGenericException
format:@"Could not add method %@", getterName];

}

// Add setter
success = class_addMethod([self class],
NSSelectorFromString(setterName),
setter,
[setterTypes cStringUsingEncoding:NSASCIIStringEncoding]);
// Set the types
NSString* type = [attributes valueForKey: @"type"];
NSString* getterTypes = [NSString stringWithFormat: @"%@@:", type];
NSString* setterTypes = [NSString stringWithFormat: @"v@:%@", type];

if (!success)
{
[NSException raise:NSGenericException
format:@"Could not add method %@", setterName];
NSString* key = [NSString stringWithFormat: @"dynamicproperty_%@_%@",
NSStringFromClass([self class]),
name];

}
IMP getter = [self _getterForKey: key type: type];
IMP setter = [self _setterForKey: key type: type];

// Add getter
BOOL success;
success = class_addMethod([self class],
NSSelectorFromString(getterName),
getter,
[getterTypes cStringUsingEncoding: NSASCIIStringEncoding]);

if (!success)
{
[NSException raise: NSGenericException
format: @"Could not add method %@", getterName];
}

// Add setter
success = class_addMethod([self class],
NSSelectorFromString(setterName),
setter,
[setterTypes cStringUsingEncoding: NSASCIIStringEncoding]);

if (!success)
{
[NSException raise: NSGenericException
format: @"Could not add method %@", setterName];
}

}


+ (NSDictionary *) _dynamicPropertyProcessAttributes: (objc_property_t)property {
+ (NSDictionary *) _dynamicPropertyProcessAttributes: (objc_property_t)property
{

NSString * attributes = [NSString stringWithCString: property_getAttributes(property)
encoding: NSASCIIStringEncoding];
Expand Down
2 changes: 1 addition & 1 deletion Source/CALayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ - (NSString *)description

/* *** properties *** */
#if GNUSTEP
#warning KVO under GNUstep doesn't work without custom setters for any struct type!
#warning KVO under GNUstep does not work without custom setters for any struct type!
/* For more info, refer to NSKeyValueObserving.m. */
/* Once we implement @dynamic generation, this won't be important, but
it's still a GNUstep bug. */
Expand Down
6 changes: 6 additions & 0 deletions Source/CARenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ - (void) _determineAndScheduleRasterizationForLayer: (CALayer *) layer;
- (void) _scheduleRasterization: (CALayer *) layer;
- (void) _rasterize: (NSDictionary *) rasterizationSpec;
- (void) _rasterizeAll;
- (void) _updateLayer: (CALayer *)layer
atTime: (CFTimeInterval)theTime;
- (void) _renderLayer: (CALayer *)layer
withTransform: (CATransform3D)transform;
- (id) initWithNSOpenGLContext: (NSOpenGLContext*)ctx
options: options;
@end

@implementation CARenderer
Expand Down
2 changes: 1 addition & 1 deletion Source/GLHelpers/CAGLTexture.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ - (void)loadImage: (CGImageRef) image
#if !GNUSTEP
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); //CGImageGetColorSpace(image); // if we get indexed-colorspace image, creation of bitmap context will fail. also, we load image into OpenGL as RGB. so, force RGB
#else
#warning Opal doesn't like CGColorSpaceCreateDeviceRGB() passed as colorpsace for bitmap context
#warning Opal does not like CGColorSpaceCreateDeviceRGB() passed as colorpsace for bitmap context
CGColorSpaceRef space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);// 2
#endif

Expand Down
3 changes: 2 additions & 1 deletion Source/Shaders/simple.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ varying mediump vec2 fragmentTextureCoordinates;
varying vec2 fragmentTextureCoordinates;
#endif


/*
vec2 textureSize(sampler2DRect sampler, int lod)
{
// function unavailable before GLSL 1.30!
Expand All @@ -41,6 +41,7 @@ vec2 textureSize(sampler2DRect sampler, int lod)
return vec2(512.0, 512.0);
}
*/

void main()
{
Expand Down

0 comments on commit 7810987

Please sign in to comment.