Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix instance self.super() 's call loop issue #173 #236

Merged
merged 2 commits into from
Feb 2, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
change the convertJPDeclaration function
  • Loading branch information
Awhisper committed Feb 2, 2016
commit c357595926effb790f2437662381af03714a5c31
31 changes: 17 additions & 14 deletions JSPatch/JPEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,12 @@ static void addMethodToProtocol(Protocol* protocol, NSString *selectorName, NSSt

static NSDictionary *defineClass(NSString *classDeclaration, JSValue *instanceMethods, JSValue *classMethods)
{
NSString *className;
NSString *superClassName;
NSString *protocolNames;

convertJPDeclarationString(classDeclaration, &className, &superClassName, &protocolNames);
NSDictionary *declarationDic = convertJPDeclarationString(classDeclaration);

NSString *className = [declarationDic objectForKey:@"className"];
NSString *superClassName = [declarationDic objectForKey:@"superClassName"];
NSString *protocolNames = [declarationDic objectForKey:@"protocolNames"];

NSArray *protocols = [protocolNames componentsSeparatedByString:@","];

Expand Down Expand Up @@ -856,8 +857,9 @@ static id callSelector(NSString *className, NSString *selectorName, JSValue *arg

Class superCls;
if (clsDeclaration && clsDeclaration.length > 0) {
NSString *defineClsName;
convertJPDeclarationString(clsDeclaration, &defineClsName, nil, nil);
NSDictionary * declarationDic =convertJPDeclarationString(clsDeclaration);
NSString *defineClsName = [declarationDic objectForKey:@"className"];

Class defineClass = NSClassFromString(defineClsName);
superCls = defineClass?[defineClass superclass]:[cls superclass];
}else
Expand Down Expand Up @@ -1337,7 +1339,7 @@ static BOOL blockTypeIsObject(NSString *typeString)
return [selectorName stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
}

static void convertJPDeclarationString(NSString *declaration, NSString **retClsName, NSString **retSuperClsName, NSString **retProtocolsNames){
static NSDictionary *convertJPDeclarationString(NSString *declaration){

NSScanner *scanner = [NSScanner scannerWithString:declaration];

Expand All @@ -1358,16 +1360,17 @@ static void convertJPDeclarationString(NSString *declaration, NSString **retClsN
className = trim(className);
superClassName = trim(superClassName);

if (retClsName) {
*retClsName = className;
NSMutableDictionary *retDic = [[NSMutableDictionary alloc]init];
if (className) {
[retDic setObject:className forKey:@"className"];
}
if (retSuperClsName) {
*retSuperClsName = superClassName;
if (superClassName) {
[retDic setObject:superClassName forKey:@"superClassName"];
}
if (retProtocolsNames) {
*retProtocolsNames = protocolNames;
if (protocolNames) {
[retDic setObject:protocolNames forKey:@"protocolNames"];
}
return;
return retDic;
}


Expand Down