mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00

git-subtree-dir: submodules/MtProtoKit git-subtree-mainline: 3b155750f5a4894ff3dedf1860a37e94e0ea9571 git-subtree-split: 14ab734b977fd4f1686a2a13415f6a4c9b9fdd6d
52 lines
984 B
Objective-C
52 lines
984 B
Objective-C
|
|
|
|
#ifndef MtProtoKit_MTInternalId_h
|
|
#define MtProtoKit_MTInternalId_h
|
|
|
|
#import <libkern/OSAtomic.h>
|
|
|
|
#define MTInternalId(name) MT##name##InternalId
|
|
|
|
#define MTInternalIdClass(name) \
|
|
@interface MT##name##InternalId : NSObject <NSCopying> \
|
|
{ \
|
|
NSUInteger _value; \
|
|
} \
|
|
\
|
|
@end \
|
|
\
|
|
@implementation MT##name##InternalId \
|
|
\
|
|
- (instancetype)init \
|
|
{ \
|
|
self = [super init]; \
|
|
if (self != nil) \
|
|
{ \
|
|
static int32_t nextValue = 1; \
|
|
_value = OSAtomicIncrement32(&nextValue); \
|
|
} \
|
|
return self; \
|
|
} \
|
|
\
|
|
- (BOOL)isEqual:(id)object \
|
|
{ \
|
|
return [object isKindOfClass:[MT##name##InternalId class]] && ((MT##name##InternalId *)object)->_value == _value; \
|
|
} \
|
|
\
|
|
- (NSUInteger)hash \
|
|
{ \
|
|
return _value; \
|
|
} \
|
|
\
|
|
- (instancetype)copyWithZone:(NSZone *)__unused zone \
|
|
{ \
|
|
MT##name##InternalId *another = [[MT##name##InternalId alloc] init]; \
|
|
if (another != nil) \
|
|
another->_value = _value; \
|
|
return another; \
|
|
} \
|
|
\
|
|
@end
|
|
|
|
#endif
|