mirror of
https://github.com/darlinghq/darling-stub-gen.git
synced 2024-11-23 04:19:46 +00:00
Keep track of whether C variables and functions are external
We're going to use this info to avoid generating stubs for local symbols. Also, get rid of duplicate `extern` keyword.
This commit is contained in:
parent
465e1546d2
commit
417644cae3
@ -24,8 +24,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface DLCFunction : NSObject
|
||||
|
||||
@property(readonly) NSString *functionName;
|
||||
@property(readonly) BOOL isExtern;
|
||||
|
||||
+(instancetype)parseMethod:(NSString *)method;
|
||||
+(instancetype)parseMethod:(NSString *)method isExtern:(BOOL)isExtern;
|
||||
-(NSString*)generateStubMethod;
|
||||
|
||||
@end
|
||||
|
@ -23,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DLCVariable : NSObject
|
||||
|
||||
@property(readonly) BOOL isExtern;
|
||||
|
||||
+(instancetype)parseVariable:(NSString *)method
|
||||
isConstant:(BOOL)isConstant
|
||||
isStatic:(BOOL)isStatic;
|
||||
|
@ -21,13 +21,14 @@
|
||||
|
||||
@implementation DLCFunction
|
||||
|
||||
+(instancetype)parseMethod:(NSString*)method {
|
||||
return [[DLCFunction alloc] initWithMethodName:method];
|
||||
+(instancetype)parseMethod:(NSString*)method isExtern:(BOOL)isExtern {
|
||||
return [[DLCFunction alloc] initWithMethodName:method isExtern:isExtern];
|
||||
}
|
||||
|
||||
-(instancetype)initWithMethodName:(NSString*)methodName {
|
||||
-(instancetype)initWithMethodName:(NSString*)methodName isExtern:(BOOL)isExtern {
|
||||
if ([methodName hasPrefix:@"_"]) { methodName = [methodName substringFromIndex:1]; }
|
||||
_functionName = methodName;
|
||||
_isExtern = isExtern;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,11 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [NSString stringWithFormat:@"extern %@", [self generateStubVariable]];
|
||||
return [self generateStubVariable];
|
||||
}
|
||||
|
||||
-(BOOL)isExtern {
|
||||
return !_static;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user