1
0
mirror of https://github.com/YPLiang19/Mango synced 2025-07-07 21:55:49 +00:00

Support to Fix Swift

This commit is contained in:
Pengliang Yong
2022-03-10 20:18:45 +08:00
parent d0ba77ffcb
commit 97f52b9c84
12 changed files with 150 additions and 51 deletions

View File

@ -8,9 +8,9 @@
/* Begin PBXBuildFile section */
592F650ADAB6D1FBD5649F95 /* Pods_MangoFix_MangoFixTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AECE17506FE1D0E845D7EADF /* Pods_MangoFix_MangoFixTests.framework */; };
747E6F3F96888F7AB3C8BADF /* Pods_MangoFix.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C56513D96A3178630BF8E67 /* Pods_MangoFix.framework */; };
89201FC327D9D87700A8AEA0 /* MFSwfitClassNameAlisTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 89201FC127D9D87700A8AEA0 /* MFSwfitClassNameAlisTable.h */; };
89201FC427D9D87700A8AEA0 /* MFSwfitClassNameAlisTable.m in Sources */ = {isa = PBXBuildFile; fileRef = 89201FC227D9D87700A8AEA0 /* MFSwfitClassNameAlisTable.m */; };
89201FC827DA234600A8AEA0 /* Pods_MangoFix.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C56513D96A3178630BF8E67 /* Pods_MangoFix.framework */; };
89253B3322B395A400AD9A33 /* MFTypedefTable.m in Sources */ = {isa = PBXBuildFile; fileRef = 89253B3122B395A300AD9A33 /* MFTypedefTable.m */; };
89253B3822B395C400AD9A33 /* MFTypedefTest.mg in Resources */ = {isa = PBXBuildFile; fileRef = 89253B3522B395C400AD9A33 /* MFTypedefTest.mg */; };
89253B3922B395C400AD9A33 /* MFTypedefTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 89253B3622B395C400AD9A33 /* MFTypedefTest.m */; };
@ -288,7 +288,7 @@
buildActionMask = 2147483647;
files = (
89967275224BFE6F00C7DACB /* libffi.a in Frameworks */,
747E6F3F96888F7AB3C8BADF /* Pods_MangoFix.framework in Frameworks */,
89201FC827DA234600A8AEA0 /* Pods_MangoFix.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -651,7 +651,7 @@
8996718B224BFD2A00C7DACB /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1320;
ORGANIZATIONNAME = yongpengliang;
TargetAttributes = {
89967193224BFD2A00C7DACB = {
@ -898,6 +898,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@ -924,7 +925,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
@ -960,6 +961,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@ -980,7 +982,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
@ -1008,7 +1010,7 @@
GCC_INPUT_FILETYPE = sourcecode.c.objc;
INFOPLIST_FILE = MangoFix/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -1045,7 +1047,7 @@
GCC_INPUT_FILETYPE = sourcecode.c.objc;
INFOPLIST_FILE = MangoFix/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "89967193224BFD2A00C7DACB"
BuildableName = "MangoFix.framework"
BlueprintName = "MangoFix"
ReferencedContainer = "container:MangoFix.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "89967193224BFD2A00C7DACB"
BuildableName = "MangoFix.framework"
BlueprintName = "MangoFix"
ReferencedContainer = "container:MangoFix.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -70,8 +68,6 @@
ReferencedContainer = "container:MangoFix.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"

View File

@ -232,8 +232,7 @@
}
}
- (void)assignToCValuePointer:(void *)cvaluePointer typeEncoding:(const char *)typeEncoding{
- (void)assignToCValuePointer:(void *)cvaluePointer typeEncoding:(const char *)typeEncoding {
typeEncoding = removeTypeEncodingPrefix((char *)typeEncoding);
#define mf_ASSIGN_2_C_VALUE_POINTER_CASE(_encode, _type, _sel)\
case _encode:{\
@ -260,7 +259,7 @@ break;\
mf_ASSIGN_2_C_VALUE_POINTER_CASE('^', void *, c2pointerValue)
mf_ASSIGN_2_C_VALUE_POINTER_CASE(':', SEL, selValue)
case '@':{
void **ptr =cvaluePointer;
void **ptr = cvaluePointer;
*ptr = (__bridge void *)[self c2objectValue];
break;
}

View File

@ -85,6 +85,8 @@ static MFValue *invoke_sueper_values(id instance, Class superClass, SEL sel, NSA
NSMethodSignature *sig = [instance methodSignatureForSelector:sel];
NSUInteger argCount = sig.numberOfArguments;
MFValue *v;
void **args = alloca(sizeof(void *) * argCount);
ffi_type **argTypes = alloca(sizeof(ffi_type *) * argCount);
@ -93,40 +95,44 @@ static MFValue *invoke_sueper_values(id instance, Class superClass, SEL sel, NSA
argTypes[1] = &ffi_type_pointer;
args[1] = &sel;
for (NSUInteger i = 2; i < argCount; i++) {
MFValue *argValue = argValues[i-2];
char *argTypeEncoding = (char *)[sig getArgumentTypeAtIndex:i];
argTypeEncoding = removeTypeEncodingPrefix(argTypeEncoding);
#define mf_SET_FFI_TYPE_AND_ARG_CASE(_code, _type, _ffi_type_value, _sel)\
#define mf_SET_FFI_TYPE_AND_ARG_CASE(_code, _ffi_type_value)\
case _code:{\
argTypes[i] = &_ffi_type_value;\
_type value = (_type)argValue._sel;\
args[i] = &value;\
void *ffiArgPtr = alloca(argTypes[i]->size);\
args[i] = ffiArgPtr;\
char c = _code;\
[argValue assignToCValuePointer:ffiArgPtr typeEncoding:&c];\
break;\
}
switch (*argTypeEncoding) {
mf_SET_FFI_TYPE_AND_ARG_CASE('c', char, ffi_type_schar, c2integerValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('i', int, ffi_type_sint, c2integerValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('s', short, ffi_type_sshort, c2integerValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('l', long, ffi_type_slong, c2integerValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('q', long long, ffi_type_sint64, c2integerValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('C', unsigned char, ffi_type_uchar, c2uintValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('I', unsigned int, ffi_type_uint, c2uintValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('S', unsigned short, ffi_type_ushort, c2uintValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('L', unsigned long, ffi_type_ulong, c2uintValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('Q', unsigned long long, ffi_type_uint64, c2uintValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('B', BOOL, ffi_type_sint8, c2uintValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('f', float, ffi_type_float, c2doubleValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('d', double, ffi_type_double, c2doubleValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('@', id, ffi_type_pointer, c2objectValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('#', Class, ffi_type_pointer, c2objectValue)
mf_SET_FFI_TYPE_AND_ARG_CASE(':', SEL, ffi_type_pointer, selValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('*', char *, ffi_type_pointer, c2pointerValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('^', id, ffi_type_pointer, c2pointerValue)
mf_SET_FFI_TYPE_AND_ARG_CASE('c', ffi_type_schar)
mf_SET_FFI_TYPE_AND_ARG_CASE('i', ffi_type_sint)
mf_SET_FFI_TYPE_AND_ARG_CASE('s', ffi_type_sshort)
mf_SET_FFI_TYPE_AND_ARG_CASE('l', ffi_type_slong)
mf_SET_FFI_TYPE_AND_ARG_CASE('q', ffi_type_sint64)
mf_SET_FFI_TYPE_AND_ARG_CASE('C', ffi_type_uchar)
mf_SET_FFI_TYPE_AND_ARG_CASE('I', ffi_type_uint)
mf_SET_FFI_TYPE_AND_ARG_CASE('S', ffi_type_ushort)
mf_SET_FFI_TYPE_AND_ARG_CASE('L', ffi_type_ulong)
mf_SET_FFI_TYPE_AND_ARG_CASE('Q', ffi_type_uint64)
mf_SET_FFI_TYPE_AND_ARG_CASE('B', ffi_type_sint8)
mf_SET_FFI_TYPE_AND_ARG_CASE('f', ffi_type_float)
mf_SET_FFI_TYPE_AND_ARG_CASE('d', ffi_type_double)
mf_SET_FFI_TYPE_AND_ARG_CASE('#', ffi_type_pointer)
mf_SET_FFI_TYPE_AND_ARG_CASE(':', ffi_type_pointer)
mf_SET_FFI_TYPE_AND_ARG_CASE('*', ffi_type_pointer)
mf_SET_FFI_TYPE_AND_ARG_CASE('^', ffi_type_pointer)
mf_SET_FFI_TYPE_AND_ARG_CASE('@', ffi_type_pointer)
case '{':{
argTypes[i] = mf_ffi_type_with_type_encoding(argTypeEncoding);
@ -1308,7 +1314,7 @@ static void eval_logic_and_expression(MFInterpreter *inter, MFScopeChain *scope,
if (!leftValue.isSubtantial) {
resultValue.uintValue = NO;
[inter.stack pop];
}else{
} else {
eval_expression(inter, scope, expr.right);
MFValue *rightValue = [inter.stack peekStack:0];
if (!rightValue.isSubtantial) {
@ -1316,7 +1322,8 @@ static void eval_logic_and_expression(MFInterpreter *inter, MFScopeChain *scope,
}else{
resultValue.uintValue = YES;
}
[inter.stack pop];
[inter.stack pop]; // pop left
[inter.stack pop]; // pop right
}
[inter.stack push:resultValue];
}
@ -1337,7 +1344,8 @@ static void eval_logic_or_expression(MFInterpreter *inter, MFScopeChain *scope,
}else{
resultValue.uintValue = NO;
}
[inter.stack pop];
[inter.stack pop]; // pop left
[inter.stack pop]; // pop right
}
[inter.stack push:resultValue];
}

View File

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
89201FC727DA04C500A8AEA0 /* SomClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 89201FC627DA04C500A8AEA0 /* SomClass.m */; };
8977D885224CC9070048A954 /* demo.mg in Resources */ = {isa = PBXBuildFile; fileRef = 89FC7DA9224C047700AFC0AC /* demo.mg */; };
899672BC224C02DC00C7DACB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 899672BB224C02DC00C7DACB /* Assets.xcassets */; };
899672BF224C02DC00C7DACB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 899672BD224C02DC00C7DACB /* LaunchScreen.storyboard */; };
@ -21,6 +22,8 @@
/* Begin PBXFileReference section */
0EDFFE948A3B02594E2D1D61 /* Pods-MangoFixDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MangoFixDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MangoFixDemo/Pods-MangoFixDemo.debug.xcconfig"; sourceTree = "<group>"; };
89201FC527DA04C500A8AEA0 /* SomClass.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SomClass.h; sourceTree = "<group>"; };
89201FC627DA04C500A8AEA0 /* SomClass.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SomClass.m; sourceTree = "<group>"; };
899672AF224C02DB00C7DACB /* MangoFixDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MangoFixDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
899672BB224C02DC00C7DACB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
899672BE224C02DC00C7DACB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
@ -99,6 +102,8 @@
89FC7DA1224C046800AFC0AC /* SuperMyController.m */,
89FC7DA0224C046700AFC0AC /* ViewController.h */,
89FC7DA3224C046800AFC0AC /* ViewController.m */,
89201FC527DA04C500A8AEA0 /* SomClass.h */,
89201FC627DA04C500A8AEA0 /* SomClass.m */,
89FC7DAE224C048600AFC0AC /* Main.storyboard */,
899672BB224C02DC00C7DACB /* Assets.xcassets */,
899672BD224C02DC00C7DACB /* LaunchScreen.storyboard */,
@ -208,6 +213,7 @@
files = (
899672C2224C02DC00C7DACB /* main.m in Sources */,
89FC7DAD224C047800AFC0AC /* AppDelegate.m in Sources */,
89201FC727DA04C500A8AEA0 /* SomClass.m in Sources */,
89FC7DA6224C046800AFC0AC /* CustomView.m in Sources */,
89FC7DA7224C046800AFC0AC /* SuperMyController.m in Sources */,
89FC7DA8224C046800AFC0AC /* ViewController.m in Sources */,

View File

@ -0,0 +1,25 @@
//
// SomClass.h
// MangoFixDemo
//
// Created by Pengliang Yong on 2022/3/10.
// Copyright © 2022 yongpengliang. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface SomClass1 : NSObject
-(instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration;
@end
@interface SomClass2 : SomClass1
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,34 @@
//
// SomClass.m
// MangoFixDemo
//
// Created by Pengliang Yong on 2022/3/10.
// Copyright © 2022 yongpengliang. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
#import "SomClass.h"
@implementation SomClass1
-(instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration {
NSLog(@"fraeX: %f, config:%@", frame.origin.x, configuration);
return self;
}
@end
@implementation SomClass2
-(instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration {
// go here crash
abort();
return self;
}
@end

View File

@ -9,6 +9,20 @@
#import "ViewController.h"
#import <WebKit/WebKit.h>
#import <objc/runtime.h>
#import "SomClass.h"
@interface MyObject : NSObject
@end
@implementation MyObject
- (void)dealloc {
NSLog(@"dealloc MyObject");
}
@end
typedef struct {
CGFloat x;
@ -40,6 +54,11 @@ void load_function(void *p){
self.title = @"Mango示例";
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier];
CGRect rect = CGRectMake(1, 2, 2, 4);
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
SomClass2 *some = [[SomClass2 alloc] initWithFrame:rect configuration:config];
NSLog(@"some: %@", some);
}
#pragma mark - UITableViewDelegate,UITableViewDataSource

View File

@ -294,3 +294,11 @@ class SubMyController:SuperMyController {
}
}
class SomClass2 : SomClass1 {
-(instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration {
self = super.initWithFrame:configuration:(frame,configuration);
return self;
}
}

View File

@ -51,7 +51,7 @@
- (void)setUp {
self.context = [[MFContext alloc] initWithRSAPrivateKey:nil];
self.context = [[MFContext alloc] initWithAES128Key:@"" iv:@""];
}

View File

@ -13,6 +13,8 @@ target 'MangoFix' do
target 'MangoFixTests' do
# Pods for testing
pod 'symdl'
end
end

View File

@ -11,6 +11,6 @@ SPEC REPOS:
SPEC CHECKSUMS:
symdl: 41f089ed2aab0790aa72ca7039e5160c71d7e3a5
PODFILE CHECKSUM: 3399a0f27725e777575ef07c352a35c39c37f949
PODFILE CHECKSUM: 3b359b48c2b8373c99b9e0136127bdb423e654b1
COCOAPODS: 1.11.2