mirror of https://github.com/axmolengine/axmol.git
Merge pull request #15807 from mogemimi/add-switch-default-case
Add missing default cases within switch block for JS and Lua JavaBridge
This commit is contained in:
commit
109f572bf6
|
@ -83,6 +83,7 @@ bool JavascriptJavaBridge::CallInfo::execute(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TypeString:
|
case TypeString:
|
||||||
|
{
|
||||||
m_retjstring = (jstring)m_env->CallStaticObjectMethod(m_classID, m_methodID);
|
m_retjstring = (jstring)m_env->CallStaticObjectMethod(m_classID, m_methodID);
|
||||||
std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(m_env, m_retjstring);
|
std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(m_env, m_retjstring);
|
||||||
|
|
||||||
|
@ -90,6 +91,12 @@ bool JavascriptJavaBridge::CallInfo::execute(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
m_error = JSJ_ERR_TYPE_NOT_SUPPORT;
|
||||||
|
LOGD("Return type '%d' is not supported", static_cast<int>(m_returnType));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_env->ExceptionCheck() == JNI_TRUE)
|
if (m_env->ExceptionCheck() == JNI_TRUE)
|
||||||
{
|
{
|
||||||
m_env->ExceptionDescribe();
|
m_env->ExceptionDescribe();
|
||||||
|
@ -123,12 +130,19 @@ bool JavascriptJavaBridge::CallInfo::executeWithArgs(jvalue *args)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TypeString:
|
case TypeString:
|
||||||
|
{
|
||||||
m_retjstring = (jstring)m_env->CallStaticObjectMethodA(m_classID, m_methodID, args);
|
m_retjstring = (jstring)m_env->CallStaticObjectMethodA(m_classID, m_methodID, args);
|
||||||
std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(m_env, m_retjstring);
|
std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(m_env, m_retjstring);
|
||||||
m_ret.stringValue = new string(strValue);
|
m_ret.stringValue = new string(strValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
m_error = JSJ_ERR_TYPE_NOT_SUPPORT;
|
||||||
|
LOGD("Return type '%d' is not supported", static_cast<int>(m_returnType));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_env->ExceptionCheck() == JNI_TRUE)
|
if (m_env->ExceptionCheck() == JNI_TRUE)
|
||||||
{
|
{
|
||||||
m_env->ExceptionDescribe();
|
m_env->ExceptionDescribe();
|
||||||
|
@ -279,6 +293,8 @@ JS::Value JavascriptJavaBridge::convertReturnValue(JSContext *cx, ReturnValue re
|
||||||
return BOOLEAN_TO_JSVAL(retValue.boolValue);
|
return BOOLEAN_TO_JSVAL(retValue.boolValue);
|
||||||
case TypeString:
|
case TypeString:
|
||||||
return c_string_to_jsval(cx, retValue.stringValue->c_str(),retValue.stringValue->size());
|
return c_string_to_jsval(cx, retValue.stringValue->c_str(),retValue.stringValue->size());
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -40,12 +40,19 @@ bool LuaJavaBridge::CallInfo::execute(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TypeString:
|
case TypeString:
|
||||||
|
{
|
||||||
m_retjs = (jstring)m_env->CallStaticObjectMethod(m_classID, m_methodID);
|
m_retjs = (jstring)m_env->CallStaticObjectMethod(m_classID, m_methodID);
|
||||||
std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(m_env, m_retjs);
|
std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(m_env, m_retjs);
|
||||||
m_ret.stringValue = new string(strValue);
|
m_ret.stringValue = new string(strValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
m_error = LUAJ_ERR_TYPE_NOT_SUPPORT;
|
||||||
|
LOGD("Return type '%d' is not supported", static_cast<int>(m_returnType));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_env->ExceptionCheck() == JNI_TRUE)
|
if (m_env->ExceptionCheck() == JNI_TRUE)
|
||||||
{
|
{
|
||||||
m_env->ExceptionDescribe();
|
m_env->ExceptionDescribe();
|
||||||
|
@ -79,12 +86,19 @@ bool LuaJavaBridge::CallInfo::executeWithArgs(jvalue *args)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TypeString:
|
case TypeString:
|
||||||
|
{
|
||||||
m_retjs = (jstring)m_env->CallStaticObjectMethodA(m_classID, m_methodID, args);
|
m_retjs = (jstring)m_env->CallStaticObjectMethodA(m_classID, m_methodID, args);
|
||||||
std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(m_env, m_retjs);
|
std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(m_env, m_retjs);
|
||||||
m_ret.stringValue = new string(strValue);
|
m_ret.stringValue = new string(strValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
m_error = LUAJ_ERR_TYPE_NOT_SUPPORT;
|
||||||
|
LOGD("Return type '%d' is not supported", static_cast<int>(m_returnType));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_env->ExceptionCheck() == JNI_TRUE)
|
if (m_env->ExceptionCheck() == JNI_TRUE)
|
||||||
{
|
{
|
||||||
m_env->ExceptionDescribe();
|
m_env->ExceptionDescribe();
|
||||||
|
@ -118,6 +132,8 @@ int LuaJavaBridge::CallInfo::pushReturnValue(lua_State *L)
|
||||||
case TypeString:
|
case TypeString:
|
||||||
lua_pushstring(L, m_ret.stringValue->c_str());
|
lua_pushstring(L, m_ret.stringValue->c_str());
|
||||||
return 1;
|
return 1;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue