Fixed iOS/JS-Bind callStaticMethod() with bool arg #12598

Merged
merged 1 commit into from Jul 1, 2015

Projects

None yet

3 participants

@shinhirota
Contributor

Problem

Boolean arguments from JavaScript via jsb.reflection.callStaticMethod() cannot be received by C++ static methods like:

+ (void) setAdVisible:(BOOL) isVisible {
   if (isVisible) { // <== This "isVisible" is always NO due to the problem.
    // do something
   } 
}

Here is the workaround we are using currently.

// Workaround
+ (void) setAdVisible:(NSNumber*) isVisible {
   if ([isVisible booleanValue) { //<== Use NSNumber for boolean arguments.
    // do something
   } 
}

After this commit "Fixed iOS/JS-Bind callStaticMethod() with bool arg.", you can call the function of the upper example.

@shinhirota shinhirota referenced this pull request in cocos2d/cocos2d-js Jun 30, 2015
Closed

Fixed iOS/JS-Bind callStaticMethod() with bool arg. #1772

@pandamicro pandamicro added bug js labels Jun 30, 2015
@pandamicro pandamicro modified the milestone: v3.7, v3.8 Jun 30, 2015
@pandamicro
Member

@jianglong0156 please review this PR

@jianglong0156
Contributor

the pr is right, can be merge.@pandamicro @shinhirota

@jianglong0156
Contributor

i will add the testcase in the js-test. thank you for contribution.

@shinhirota
Contributor

Great. Thank you for your support!

@pandamicro pandamicro merged commit 4d95c87 into cocos2d:v3 Jul 1, 2015

1 check passed

Jenkins CI Build successfully!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment