初始化提交

This commit is contained in:
2026-02-03 16:52:44 +08:00
commit d2f9806384
512 changed files with 65167 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "FBXCDeviceEvent.h"
#import "FBErrorBuilder.h"
id<FBXCDeviceEvent> FBCreateXCDeviceEvent(unsigned int page,
unsigned int usage,
double duration,
NSError **error)
{
Class xcDeviceEventClass = NSClassFromString(@"XCDeviceEvent");
if (nil == xcDeviceEventClass) {
[[[FBErrorBuilder builder]
withDescription:@"Cannot find XCDeviceEvent class"]
buildError:error];
return nil;
}
SEL deviceEventFactorySelector = NSSelectorFromString(@"deviceEventWithPage:usage:duration:");
if (![xcDeviceEventClass respondsToSelector:deviceEventFactorySelector]) {
[[[FBErrorBuilder builder]
withDescription:@"'deviceEventWithPage:usage:duration:' factory method is not found on XCDeviceEvent class"]
buildError:error];
return nil;
}
NSMethodSignature *deviceEventFactorySignature = [xcDeviceEventClass methodSignatureForSelector:deviceEventFactorySelector];
NSInvocation *deviceEventFactoryInvocation = [NSInvocation invocationWithMethodSignature:deviceEventFactorySignature];
[deviceEventFactoryInvocation setSelector:deviceEventFactorySelector];
[deviceEventFactoryInvocation setArgument:&page atIndex:2];
[deviceEventFactoryInvocation setArgument:&usage atIndex:3];
[deviceEventFactoryInvocation setArgument:&duration atIndex:4];
[deviceEventFactoryInvocation invokeWithTarget:xcDeviceEventClass];
id<FBXCDeviceEvent> __unsafe_unretained instance;
[deviceEventFactoryInvocation getReturnValue:&instance];
return instance;
}