Fill in the jsval_to_ccdictionary pit of Cocos2dx

Source: Internet
Author: User

The nactive function jsval_to_ccdictionary is converted in the cocos2dx dictionary. Only three types of jsval_to_ccdictionary are determined. If they are empty, the system crashes.

Find the bottom of the function.

Else if (JSVAL_IS_STRING (value )){

JSStringWrapper valueWapper (JSVAL_TO_STRING (value), cx );

Dict-> setObject (String: create (valueWapper. get (), keyWrapper. get ());

// CCLOG ("iterate object: key = % s, value = % s", keyWrapper. get (). c_str (), valueWapper. get (). c_str ());

}

Elseif (JSVAL_IS_NUMBER (value )){

Double number = 0.0;

JSBool OK = JS_ValueToNumber (cx, value, & number );

If (OK ){

Dict-> setObject (Double: create (number), keyWrapper. get ());

// CCLOG ("iterate object: key = % s, value = % lf", keyWrapper. get (). c_str (), number );

}

}

Elseif (JSVAL_IS_BOOLEAN (value )){

JSBool boolVal = JS_FALSE;

JSBool OK = JS_ValueToBoolean (cx, value, & boolVal );

If (OK ){

Dict-> setObject (Bool: create (boolVal), keyWrapper. get ());

// + CCLOG ("iterate object: key = % s, value = % d", keyWrapper. get (). c_str (), boolVal );

}

}Else if (value. isNullOrUndefined ())

{

// CCASSERT (false, "not isNull supported type"); // The value. isNullOrUndefined must be determined; otherwise, the system will crash if the inserted value is null.

Dict-> setObject (String: create (""), keyWrapper. get ());

}

Else {

CCASSERT (false, "not supported type ");

}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.