Skip to content

Commit

Permalink
[Upstream] Class descriptions are debug-only
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi committed Mar 5, 2023
1 parent 947751f commit 54d54dc
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Libraries/Text/RawText/RCTRawTextShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ - (void)dirtyLayout
[self.superview dirtyLayout];
}

#if RCT_DEBUG
- (NSString *)description
{
NSString *superDescription = super.description;
return [[superDescription substringToIndex:superDescription.length - 1]
stringByAppendingFormat:@"; text: %@>", self.text];
}
#endif

@end
2 changes: 2 additions & 0 deletions Libraries/Text/Text/RCTTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ - (instancetype)initWithFrame:(CGRect)frame
return self;
}

#if RCT_DEBUG
- (NSString *)description
{
NSString *superDescription = super.description;
NSRange replacementRange = [superDescription rangeOfString:@">"];
NSString *replacement = [NSString stringWithFormat:@"; reactTag: %@; text: %@>", self.reactTag, _textStorage.string];
return [superDescription stringByReplacingCharactersInRange:replacementRange withString:replacement];
}
#endif

- (void)setSelectable:(BOOL)selectable
{
Expand Down
2 changes: 2 additions & 0 deletions React/Base/RCTImageSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ - (BOOL)isEqual:(RCTImageSource *)object
(CGSizeEqualToSize(_size, object.size) || CGSizeEqualToSize(object.size, CGSizeZero));
}

#if RCT_DEBUG
- (NSString *)description
{
return [NSString stringWithFormat:@"<RCTImageSource: %p URL=%@, size=%@, scale=%0.f>",
Expand All @@ -50,6 +51,7 @@ - (NSString *)description
NSStringFromCGSize(_size),
_scale];
}
#endif

@end

Expand Down
2 changes: 2 additions & 0 deletions React/Base/RCTJSStackFrame.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ + (instancetype)stackFrameWithDictionary:(NSDictionary *)dict
return stack;
}

#if RCT_DEBUG
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p method name: %@; file name: %@; line: %ld; column: %ld>",
Expand All @@ -146,5 +147,6 @@ - (NSString *)description
(long)self.lineNumber,
(long)self.column];
}
#endif

@end
2 changes: 2 additions & 0 deletions React/Base/RCTJavaScriptLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ @implementation RCTSource

@implementation RCTLoadingProgress

#if RCT_DEBUG
- (NSString *)description
{
NSMutableString *desc = [NSMutableString new];
Expand All @@ -71,6 +72,7 @@ - (NSString *)description
[desc appendString:@"\u2026"];
return desc;
}
#endif

@end

Expand Down
2 changes: 2 additions & 0 deletions React/Base/RCTKeyCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ - (BOOL)matchesInput:(NSString *)input flags:(UIKeyModifierFlags)flags
return [_key isEqual:input] && (_flags == flags || flags == 0);
}

#if RCT_DEBUG
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@:%p input=\"%@\" flags=%lld hasBlock=%@>",
Expand All @@ -83,6 +84,7 @@ - (NSString *)description
(long long)_flags,
_block ? @"YES" : @"NO"];
}
#endif

@end

Expand Down
2 changes: 2 additions & 0 deletions React/Base/RCTModuleData.mm
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,11 @@ - (void)invalidate
_methodQueue = nil;
}

#if RCT_DEBUG
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; name=\"%@\">", [self class], self, self.name];
}
#endif

@end
2 changes: 2 additions & 0 deletions React/Base/RCTModuleMethod.mm
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ - (NSString *)methodName
return [NSString stringWithFormat:@"-[%@ %s]", _moduleClass, sel_getName(_selector)];
}

#if RCT_DEBUG
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; exports %@ as %s(); type: %s>",
Expand All @@ -611,5 +612,6 @@ - (NSString *)description
self.JSMethodName,
RCTFunctionDescriptorFromType(self.functionType)];
}
#endif

@end
2 changes: 2 additions & 0 deletions React/Base/RCTTouchEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ - (uint16_t)coalescingKey
return _coalescingKey;
}

#if RCT_DEBUG
- (NSString *)description
{
return [NSString
stringWithFormat:@"<%@: %p; name = %@; coalescing key = %hu>", [self class], self, _eventName, _coalescingKey];
}
#endif

@end
2 changes: 2 additions & 0 deletions React/CxxModule/RCTCxxMethod.mm
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ - (id)invokeWithBridge:(RCTBridge *)bridge module:(id)module arguments:(NSArray
}
}

#if RCT_DEBUG
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; name = %s>", [self class], self, self.JSMethodName];
}
#endif

@end
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ - (instancetype)initWithFrame:(CGRect)frame
return self;
}

#if RCT_DEBUG
- (NSString *)description
{
NSString *superDescription = [super description];
Expand All @@ -55,6 +56,7 @@ - (NSString *)description

return [NSString stringWithFormat:@"%@; attributedText = %@>", superDescription, self.attributedText];
}
#endif

- (NSAttributedString *_Nullable)attributedText
{
Expand Down
2 changes: 2 additions & 0 deletions React/Modules/RCTLayoutAnimation.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ - (BOOL)isEqual:(RCTLayoutAnimation *)animation
_animationType == animation.animationType;
}

#if RCT_DEBUG
- (NSString *)description
{
return [NSString
Expand All @@ -148,5 +149,6 @@ - (NSString *)description
_initialVelocity,
(long)_animationType];
}
#endif

@end
2 changes: 2 additions & 0 deletions React/Modules/RCTLayoutAnimationGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ - (BOOL)isEqual:(RCTLayoutAnimationGroup *)layoutAnimation
[_deletingLayoutAnimation isEqual:deletingLayoutAnimation]);
}

#if RCT_DEBUG
- (NSString *)description
{
return
Expand All @@ -75,5 +76,6 @@ - (NSString *)description
[_updatingLayoutAnimation description],
[_deletingLayoutAnimation description]];
}
#endif

@end
2 changes: 2 additions & 0 deletions React/Views/RCTShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ - (NSNumber *)reactTagAtPoint:(CGPoint)point
return self.reactTag;
}

#if RCT_DEBUG
- (NSString *)description
{
NSString *description = super.description;
Expand All @@ -393,6 +394,7 @@ - (NSString *)description
NSStringFromCGRect(self.layoutMetrics.frame)];
return description;
}
#endif

- (void)addRecursiveDescriptionToString:(NSMutableString *)string atLevel:(NSUInteger)level
{
Expand Down
2 changes: 2 additions & 0 deletions React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,15 @@ - (void)accessibilityDecrement
[self performAccessibilityAction:@"decrement"];
}

#if RCT_DEBUG
- (NSString *)description
{
NSString *superDescription = super.description;
NSRange semicolonRange = [superDescription rangeOfString:@";"];
NSString *replacement = [NSString stringWithFormat:@"; reactTag: %@;", self.reactTag];
return [superDescription stringByReplacingCharactersInRange:semicolonRange withString:replacement];
}
#endif

#pragma mark - Statics for dealing with layoutGuides

Expand Down
2 changes: 2 additions & 0 deletions React/Views/SafeAreaView/RCTSafeAreaView.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)

#if RCT_DEBUG
- (NSString *)description
{
NSString *superDescription = [super description];
Expand All @@ -43,6 +44,7 @@ - (NSString *)description
NSStringFromUIEdgeInsets(self.safeAreaInsets),
NSStringFromUIEdgeInsets(_currentSafeAreaInsets)];
}
#endif

static BOOL UIEdgeInsetsEqualToEdgeInsetsWithThreshold(UIEdgeInsets insets1, UIEdgeInsets insets2, CGFloat threshold)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ - (instancetype)initWithTestName:(NSString *)testName

#pragma mark - Properties

#if RCT_DEBUG
- (NSString *)description
{
return [NSString stringWithFormat:@"%@ %@", [super description], _referenceImagesDirectory];
}
#endif

#pragma mark - Public API

Expand Down

0 comments on commit 54d54dc

Please sign in to comment.