public void PrintLastException(INTPTR ctx) { return; INTPTR p = M.ReadIntPtr(lastException); if (p != INTPTR.Zero) { JSDLL.JSType t = JSDLL.JSType.kJSTypeUndefined; t = JSDLL.JSValueGetType(ctx, p); if (t != JSDLL.JSType.kJSTypeUndefined) { print(t.ToString()); if (t != JSDLL.JSType.kJSTypeNull) { var eStr = JSDLL.JSValueToStringCopy(ctx, p, lastException); var eStrPtr = JSDLL.JSStringGetCharactersPtr(eStr); var eStrLen = JSDLL.JSStringGetLength(eStr); var eString = M.PtrToStringAuto(eStrPtr, eStrLen); print(eString); } } } M.WriteIntPtr(lastException, INTPTR.Zero); }
public static bool CheckType(IntPtr L, Type type, int pos) { //默认都可以转 object if (type == typeof(object)) { return(true); } Type t = GetNullableType(type); JSDLL.JSType jsType = JSDLL.JSType.kJSTypeUndefined; //JSDLL.JSValueGetType(L, ) /* * switch (jsType) * { * case JSDLL.JSType.kJSTypeNumber: * return true; * case JSDLL.JSType.kJSTypeString: * return t == typeof(string) || t == typeof(byte[]) || t == typeof(char[]) || t == typeof(LuaByteBuffer); * case JSDLL.JSType.kJSTypeObject: //LuaTypes.LUA_TUSERDATA: * return IsMatchUserData(L, t, pos); * case JSDLL.JSType.kJSTypeBoolean: // LuaTypes.LUA_TBOOLEAN: * return t == typeof(bool); * case JSDLL.JSType.kJSTypeObject:// LuaTypes.LUA_TFUNCTION: * //return t == typeof(LuaFunction); * case LuaTypes.LUA_TTABLE: * return IsUserTable(t, L, pos); * case LuaTypes.LUA_TLIGHTUSERDATA: * return t == typeof(IntPtr) || t == typeof(UIntPtr); * case LuaTypes.LUA_TNIL: * return IsNilType(type); * default: * break; * } */ return(true); //throw new LuaException("undefined type to check" + LuaDLL.luaL_typename(L, pos)); }