NAMESPACE_LUA_BEGIN /* limit for table tag-method chains (to avoid loops) */ #define MAXTAGLOOP 100 #if LUA_REFCOUNT const TValue *luaV_tonumber (lua_State *L, const TValue *obj, TValue *n) { #else const TValue *luaV_tonumber (const TValue *obj, TValue *n) { #endif /* LUA_REFCOUNT */ lua_Number num; if (ttisnumber(obj)) return obj; if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { setnvalue(n, num); return n; } #if LUA_WIDESTRING else if (ttiswstring(obj) && luaO_wstr2d(wsvalue(obj), &num)) { setnvalue(n, num); return n; } #endif /* LUA_WIDESTRING */ else return NULL; }
const TValue *luaV_tonumber (const TValue *obj, TValue *n) { lua_Number num; if (ttisnumber(obj)) return obj; if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { setnvalue(n, num); return n; } else if (ttiswstring(obj) && luaO_wstr2d(wsvalue(obj), &num)) { setnvalue(n, num); return n; } else return NULL; }
NAMESPACE_LUA_BEGIN /* limit for table tag-method chains (to avoid loops) */ #define MAXTAGLOOP 100 const TValue *luaV_tonumber(const TValue *obj, TValue *n) { lua_Number num = 0.0f; if (ttisnumber(obj)) return obj; if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { setnvalue(n, num); return n; } else if (ttiswstring(obj) && luaO_wstr2d(wsvalue(obj), &num)) { setnvalue(n, num); return n; } else return NULL; }