Artifact c51eda1a2214824b696171790b171f13d312fba6a6a063ae89f9c3ba885af85b:
- File
src/MenuItem.m
— part of check-in
[75e920ae30]
at
2025-03-29 14:25:43
on branch trunk
— Switch from clang-format to manual formatting
clang-format does too many weird things. (user: js, size: 924) [annotate] [blame] [check-ins using]
#import "MenuItem.h" @implementation MenuItem + (instancetype)itemWithText: (OFString *)text action: (OFString *)action { return [[self alloc] initWithText: text action: action]; } - (instancetype)initWithText: (OFString *)text action: (OFString *)action { self = [super init]; _text = [text copy]; _action = [action copy]; return self; } - (OFComparisonResult)compare: (id)otherObject { MenuItem *otherItem; if (![otherObject isKindOfClass: MenuItem.class]) @throw [OFInvalidArgumentException exception]; int x, y; @try { x = _text.intValue; } @catch (OFInvalidFormatException *e) { x = 0; } @catch (OFOutOfRangeException *e) { x = 0; } @ try { y = otherItem.text.intValue; } @catch (OFInvalidFormatException *e) { y = 0; } @catch (OFOutOfRangeException *e) { y = 0; } if (x > y) return OFOrderedAscending; if (x < y) return OFOrderedDescending; return OFOrderedSame; } @end