static bool IsUserData(IntPtr L, int pos) { object obj = null; int udata = LuaDLL.tolua_rawnetobj(L, pos); if (udata != -1) { ObjectTranslator translator = ObjectTranslator.Get(L); obj = translator.GetObject(udata); if (obj != null) { return(obj is T); } else { return(!IsValueType); } } return(false); }
static public bool CheckDelegateType(Type type, IntPtr L, int pos) { LuaTypes luaType = LuaDLL.lua_type(L, pos); switch (luaType) { case LuaTypes.LUA_TNIL: return(true); case LuaTypes.LUA_TUSERDATA: int udata = LuaDLL.tolua_rawnetobj(L, pos); if (udata != -1) { ObjectTranslator translator = ObjectTranslator.Get(L); object obj = translator.GetObject(udata); return(obj == null ? true : type == obj.GetType()); } return(false); default: return(false); } }
static bool IsMatchUserData(IntPtr L, Type t, int pos) { if (t == typeof(long)) { return(LuaDLL.tolua_getvaluetype(L, pos) == LuaValueType.Int64); } else if (t == typeof(ulong)) { return(LuaDLL.tolua_getvaluetype(L, pos) == LuaValueType.UInt64); } object obj = null; int udata = LuaDLL.tolua_rawnetobj(L, pos); if (udata != -1) { ObjectTranslator translator = ObjectTranslator.Get(L); obj = translator.GetObject(udata); if (obj != null) { Type objType = obj.GetType(); if (t == objType || t.IsAssignableFrom(objType)) { return(true); } } else { return(!t.IsValueType); } } return(false); }