This commit is contained in:
2025-10-28 10:18:10 +08:00
parent efb04d134e
commit 1deca2ae5b
166 changed files with 17288 additions and 1427 deletions

View File

@@ -0,0 +1,62 @@
#ifdef SHOULD_COMPILE_LOOKIN_SERVER
//
// LKS_ObjectRegistry.m
// LookinServer
//
// Created by Li Kai on 2019/4/21.
// https://lookin.work
//
#import "LKS_ObjectRegistry.h"
#import <objc/runtime.h>
@interface LKS_ObjectRegistry ()
@property(nonatomic, strong) NSPointerArray *data;
@end
@implementation LKS_ObjectRegistry
+ (instancetype)sharedInstance {
static dispatch_once_t onceToken;
static LKS_ObjectRegistry *instance = nil;
dispatch_once(&onceToken,^{
instance = [[super allocWithZone:NULL] init];
});
return instance;
}
+ (id)allocWithZone:(struct _NSZone *)zone{
return [self sharedInstance];
}
- (instancetype)init {
if (self = [super init]) {
self.data = [NSPointerArray weakObjectsPointerArray];
// index 0 Null
self.data.count = 1;
}
return self;
}
- (unsigned long)addObject:(NSObject *)object {
if (!object) {
return 0;
}
[self.data addPointer:(void *)object];
return self.data.count - 1;
}
- (NSObject *)objectWithOid:(unsigned long)oid {
if (self.data.count <= oid) {
return nil;
}
id object = [self.data pointerAtIndex:oid];
return object;
}
@end
#endif /* SHOULD_COMPILE_LOOKIN_SERVER */