Adds conversions for ssize_t.

This commit is contained in:
James Chen 2013-12-16 12:02:58 +08:00
parent 53092b359b
commit adb45d3c68
4 changed files with 18 additions and 0 deletions

View File

@ -1105,6 +1105,11 @@ JSBool jsval_to_ccvaluevector(JSContext* cx, jsval v, cocos2d::ValueVector* ret)
return JS_TRUE;
}
JSBool jsval_to_ssize( JSContext *cx, jsval vp, ssize_t* ret)
{
return jsval_to_long(cx, vp, static_cast<long*>(ret));
}
// native --> jsval
jsval ccarray_to_jsval(JSContext* cx, Array *arr)
@ -2021,3 +2026,8 @@ jsval ccvaluevector_to_jsval(JSContext* cx, const cocos2d::ValueVector& v)
}
return OBJECT_TO_JSVAL(jsretArr);
}
jsval ssize_to_jsval(JSContext *cx, ssize_t v)
{
return long_to_jsval(cx, v);
}

View File

@ -113,6 +113,7 @@ JSBool jsval_to_ccvalue(JSContext* cx, jsval v, cocos2d::Value* ret);
JSBool jsval_to_ccvaluemap(JSContext* cx, jsval v, cocos2d::ValueMap* ret);
JSBool jsval_to_ccintvaluemap(JSContext* cx, jsval v, cocos2d::IntValueMap* ret);
JSBool jsval_to_ccvaluevector(JSContext* cx, jsval v, cocos2d::ValueVector* ret);
JSBool jsval_to_ssize( JSContext *cx, jsval vp, ssize_t* ret);
// from native
jsval int32_to_jsval( JSContext *cx, int32_t l);
@ -172,6 +173,7 @@ jsval ccvalue_to_jsval(JSContext* cx, const cocos2d::Value& v);
jsval ccvaluemap_to_jsval(JSContext* cx, const cocos2d::ValueMap& v);
jsval ccintvaluemap_to_jsval(JSContext* cx, const cocos2d::IntValueMap& v);
jsval ccvaluevector_to_jsval(JSContext* cx, const cocos2d::ValueVector& v);
jsval ssize_to_jsval(JSContext *cx, ssize_t v);
#endif /* __JS_MANUAL_CONVERSIONS_H__ */

View File

@ -283,6 +283,11 @@ bool luaval_to_point(lua_State* L,int lo,Point* outValue)
return ok;
}
bool luaval_to_ssize(lua_State* L,int lo, long* outValue)
{
return luaval_to_long(L, lo, outValue);
}
bool luaval_to_long(lua_State* L,int lo, long* outValue)
{
if (NULL == L || NULL == outValue)

View File

@ -32,6 +32,7 @@ extern bool luaval_to_number(lua_State* L,int lo,double* outValue);
extern bool luaval_to_long_long(lua_State* L,int lo,long long* outValue);
extern bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue);
extern bool luaval_to_long(lua_State* L,int lo, long* outValue);
extern bool luaval_to_ssize(lua_State* L,int lo, long* outValue);
extern bool luaval_to_point(lua_State* L,int lo,Point* outValue);
extern bool luaval_to_size(lua_State* L,int lo,Size* outValue);