AppKit: Remove remaining #if DEBUG conditionals

Eliminate conditional compilation for debug builds across AppKit.

* CPAnimationContext: Remove debug logging traces.
* _CPCibCustomObject, _CPCibCustomView, _CPCibWindowTemplate: Convert unknown-class log messages to unconditional warnings.
* CPView: Convert duplicate-subview assertion to an unconditional check.
* _CPObject+Theme: Convert array-as-state assertions to unconditional checks and remove obsolete performance TODOs.

AppKit is now free of C-style preprocessor directives.
This commit is contained in:
David Richardson committed 2026-10-09 16:47:46 -06:00
1 parent bf19b09ad0
commit 15268c45c4
6 files changed
-60

No files matched your search

-2
View File
@@ -589,10 +589,8 @@ var CPViewHighDPIDrawingEnabled = YES;
{
if (aSubview === self)
[CPException raise:CPInvalidArgumentException reason:"can't add a view as a subview of itself"];
#if DEBUG
if (!aSubview._superview && _subviews.indexOf(aSubview) !== CPNotFound)
[CPException raise:CPInvalidArgumentException reason:"can't insert a subview in duplicate (probably partially decoded)"];
#endif
// Notify the subview that it will be moving.
[aSubview viewWillMoveToSuperview:self];
-2
View File
@@ -81,9 +81,7 @@ var _CPCibCustomObjectClassName = @"_CPCibCustomObjectClassName";
if (!theClass)
{
#if DEBUG
CPLog("Unknown class \"" + _className + "\" in cib file");
#endif
theClass = [CPObject class];
}
-2
View File
@@ -82,9 +82,7 @@ var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
// FIXME: Should we instead throw an exception?
if (!theClass)
{
#if DEBUG
CPLog("Unknown class \"" + _className + "\" in cib file, using CPView instead.");
#endif
theClass = [CPView class];
}
-2
View File
@@ -91,9 +91,7 @@
if (!windowClass)
{
#if DEBUG
CPLog.warn("Unknown class \"%@\" in cib file, using CPWindow instead.", [self windowClass]);
#endif
windowClass = [CPWindow class];
}
-34
View File
@@ -70,9 +70,6 @@ var _CPAnimationContextStack = nil,
{
if (!_animationFlushingObserver)
{
#if (DEBUG)
CPLog.debug("create new observer");
#endif
_animationFlushingObserver = CFRunLoopObserverCreate(2, true, 0, _animationFlushingObserverCallback, 0);
CFRunLoopAddObserver([CPRunLoop mainRunLoop], _animationFlushingObserver);
}
@@ -101,9 +98,6 @@ var _CPAnimationContextStack = nil,
[context _flushAnimations];
[_CPAnimationContextStack removeLastObject];
#if (DEBUG)
CPLog.debug(_cmd + "context stack =" + _CPAnimationContextStack);
#endif
return YES;
}
@@ -234,9 +228,6 @@ var _CPAnimationContextStack = nil,
{
if (_completionHandlerAgent)
{
#if (DEBUG)
CPLog.debug("No animations are scheduled. Firing completion handler");
#endif
_completionHandlerAgent.fire();
}
}
@@ -266,9 +257,6 @@ var _CPAnimationContextStack = nil,
{
if (n == 0)
{
#if (DEBUG)
CPLog.debug("Animations are not needed. Firing completion handler");
#endif
_completionHandlerAgent.fire();
}
else
@@ -278,18 +266,12 @@ var _CPAnimationContextStack = nil,
// start timers
while(k--)
{
#if (DEBUG)
CPLog.debug("START TIMER " + timers[k].description());
#endif
timers[k].start();
}
// start css animations
while(n--)
{
#if (DEBUG)
CPLog.debug("START ANIMATION " + cssAnimations[n].description());
#endif
cssAnimations[n].start();
}
}
@@ -350,9 +332,6 @@ var _CPAnimationContextStack = nil,
action.completion = function()
{
[aSubview setFrame:targetFrame];
#if (DEBUG)
CPLog.debug(aSubview + " setFrame: " + CPStringFromRect(targetFrame));
#endif
if (idx == count - 1)
[animatorClass stopUpdaterWithIdentifier:[anAction.root UID]];
};
@@ -401,9 +380,6 @@ var _CPAnimationContextStack = nil,
if (aCompletionHandler)
{
_completionHandlerAgent = new CompletionHandlerAgent(aCompletionHandler);
#if (DEBUG)
CPLog.debug("created a new completion Agent with id " + _completionHandlerAgent.id);
#endif
}
else
{
@@ -563,9 +539,6 @@ CompletionHandlerAgent.prototype.invalidate = function()
var _animationFlushingObserverCallback = function()
{
#if (DEBUG)
CPLog.debug("_animationFlushingObserverCallback");
#endif
if ([_CPAnimationContextStack count] == 1)
{
var context = [_CPAnimationContextStack lastObject];
@@ -573,15 +546,8 @@ var _animationFlushingObserverCallback = function()
[_CPAnimationContextStack removeLastObject];
}
#if (DEBUG)
CPLog.debug("_animationFlushingObserver "+_animationFlushingObserver+" stack:" + [_CPAnimationContextStack count]);
#endif
if (_animationFlushingObserver && ![_CPAnimationContextStack count])
{
#if (DEBUG)
CPLog.debug("removeObserver");
#endif
CFRunLoopObserverInvalidate([CPRunLoop mainRunLoop], _animationFlushingObserver);
_animationFlushingObserver = nil;
}
-18
View File
@@ -76,12 +76,8 @@ var CPViewThemeClassKey = @"CPViewThemeClassKey",
- (BOOL)hasThemeState:(ThemeState)aState
{
#if DEBUG
// TODO: To allow aState to be an array is now deprecated. An exception is thrown only in Debug version as
// the preformance cost for this check is to high. We should remove this check in a future release.
if (aState && aState.isa && [aState isKindOfClass:CPArray])
[CPException raise:CPInvalidArgumentException reason:@"aState can't be an array. Please use 'hasThemeStates: instead: " + aState];
#endif
return _themeState.hasThemeState(aState);
}
@@ -99,12 +95,8 @@ var CPViewThemeClassKey = @"CPViewThemeClassKey",
- (BOOL)setThemeState:(ThemeState)aState
{
#if DEBUG
// TODO: To allow aState to be an array is now deprecated. An exception is thrown only in Debug version as
// the preformance cost for this check is to high. We should remove this check in a future release.
if (aState && aState.isa && [aState isKindOfClass:CPArray])
[CPException raise:CPInvalidArgumentException reason:@"aState can't be an array. Please use 'setThemeStates: instead: " + aState];
#endif
if (_themeState.hasThemeState(aState))
return NO;
@@ -116,12 +108,8 @@ var CPViewThemeClassKey = @"CPViewThemeClassKey",
- (BOOL)unsetThemeState:(ThemeState)aState
{
#if DEBUG
// TODO: To allow aState to be an array is now deprecated. An exception is thrown only in Debug version as
// the preformance cost for this check is to high. We should remove this check in a future release.
if (aState && aState.isa && [aState isKindOfClass:CPArray])
[CPException raise:CPInvalidArgumentException reason:@"aState can't be an array. Please use 'unsetThemeStates: instead: " + aState];
#endif
var oldThemeState = _themeState;
@@ -318,12 +306,8 @@ var NULL_THEME = {};
- (void)setValue:(id)aValue forThemeAttribute:(CPString)aName inState:(ThemeState)aState
{
#if DEBUG
// TODO: To allow aState to be an array is now deprecated. An exception is thrown only in Debug version as
// the preformance cost for this check is to high. We should remove this check in a future release.
if (aState.isa && [aState isKindOfClass:CPArray])
[CPException raise:CPInvalidArgumentException reason:self + @": aState can't be an array. Please use 'setValue:forThemeAttribute:inStates:' instead: " + aState];
#endif
var themeAttr = _themeAttributes && _themeAttributes[aName];
@@ -361,10 +345,8 @@ var NULL_THEME = {};
- (id)valueForThemeAttribute:(CPString)aName inState:(ThemeState)aState
{
#if DEBUG
if (aState.isa && [aState isKindOfClass:CPArray])
[CPException raise:CPInvalidArgumentException reason:@"aState can't be an array. Please use 'valueForThemeAttribute:inStates:' instead: " + aState];
#endif
var themeAttr = _themeAttributes && _themeAttributes[aName];