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:
Ariel Abreu 2023-08-22 00:37:28 -04:00
parent 465e1546d2
commit 417644cae3
No known key found for this signature in database
GPG Key ID: 8031B538781E183F
4 changed files with 13 additions and 5 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -66,7 +66,11 @@
return nil;
}
return [NSString stringWithFormat:@"extern %@", [self generateStubVariable]];
return [self generateStubVariable];
}
-(BOOL)isExtern {
return !_static;
}
@end