static int Add(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type   argType = null;
         object obj     = ToLua.CheckGenericObject(L, 1, typeof(List <>), out argType);
         object arg0    = ToLua.CheckVarObject(L, 2, argType);
         LuaMethodCache.CallSingleMethod("Add", obj, arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int get_Capacity(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            int ret = (int)LuaMethodCache.CallSingleMethod("get_Capacity", o);
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Capacity on a nil value"));
        }
    }
 static int RemoveRange(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         object obj  = ToLua.CheckGenericObject(L, 1, TypeOfList);
         int    arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         int    arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         LuaMethodCache.CallSingleMethod("RemoveRange", obj, arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int AddRange(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type   argType = null;
         object obj     = ToLua.CheckGenericObject(L, 1, TypeOfList, out argType);
         object arg0    = ToLua.CheckObject(L, 2, typeof(IEnumerable <>).MakeGenericType(argType));
         LuaMethodCache.CallSingleMethod("AddRange", obj, arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int ForEach(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type     argType = null;
         object   obj     = ToLua.CheckGenericObject(L, 1, TypeOfList, out argType);
         Delegate arg0    = ToLua.CheckDelegate(typeof(System.Action <>).MakeGenericType(argType), L, 2);
         LuaMethodCache.CallSingleMethod("ForEach", obj, arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #6
0
 static int GetObjectData(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         object            obj  = ToLua.CheckGenericObject(L, 1, typeof(Dictionary <,>));
         SerializationInfo arg0 = (SerializationInfo)ToLua.CheckObject(L, 2, typeof(SerializationInfo));
         StreamingContext  arg1 = (StreamingContext)ToLua.CheckObject(L, 3, typeof(StreamingContext));
         LuaMethodCache.CallSingleMethod("GetObjectData", obj, arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int get_Value(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            object ret = LuaMethodCache.CallSingleMethod("get_Value", o);
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Value on a nil value"));
        }
    }
    static int set_Capacity(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
            LuaMethodCache.CallSingleMethod("set_Capacity", o, arg0);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Capacity on a nil value" : e.Message));
        }
    }
 static int AsReadOnly(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         Type   argType = null;
         object obj     = ToLua.CheckGenericObject(L, 1, typeof(List <>), out argType);
         object o       = LuaMethodCache.CallSingleMethod("AsReadOnly", obj);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int get_Item(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         object obj  = ToLua.CheckGenericObject(L, 1, typeof(List <>));
         int    arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         object o    = LuaMethodCache.CallSingleMethod("get_Item", obj, arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int get_Keys(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            object ret = LuaMethodCache.CallSingleMethod("get_Keys", o);
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Keys on a nil value" : e.Message));
        }
    }
    private static int Clear(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 1);
            object obj = ToLua.CheckGenericObject(L, 1, typeof(Dictionary <, >));
            LuaMethodCache.CallSingleMethod("Clear", obj, new object[0]);
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
 static int RemoveAll(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type     argType = null;
         object   obj     = ToLua.CheckGenericObject(L, 1, TypeOfList, out argType);
         Delegate arg0    = ToLua.CheckDelegate(TypeOfPredicate.MakeGenericType(argType), L, 2);
         int      o       = (int)LuaMethodCache.CallSingleMethod("RemoveAll", obj, arg0);
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int FindAll(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type     argType = null;
         object   obj     = ToLua.CheckGenericObject(L, 1, TypeOfList, out argType);
         Delegate arg0    = ToLua.CheckDelegate(TypeOfPredicate.MakeGenericType(argType), L, 2);
         object   o       = LuaMethodCache.CallMethod("FindAll", obj, arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int Exists(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type     argType = null;
         object   obj     = ToLua.CheckGenericObject(L, 1, TypeOfList, out argType);
         Delegate arg0    = ToLua.CheckDelegate(TypeOfPredicate.MakeGenericType(argType), L, 2);
         bool     o       = (bool)LuaMethodCache.CallMethod("Exists", obj, arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int Remove(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type   kt;
         object obj  = ToLua.CheckGenericObject(L, 1, TypeOfDictionary, out kt);
         object arg0 = ToLua.CheckVarObject(L, 2, kt);
         bool   o    = (bool)LuaMethodCache.CallSingleMethod("Remove", obj, arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int set_Item(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         Type   argType = null;
         object obj     = ToLua.CheckGenericObject(L, 1, typeof(List <>), out argType);
         int    arg0    = (int)LuaDLL.luaL_checknumber(L, 2);
         object arg1    = ToLua.CheckObject(L, 3, argType);
         LuaMethodCache.CallSingleMethod("set_Item", obj, arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int TrueForAll(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type     argType = null;
         object   obj     = ToLua.CheckGenericObject(L, 1, typeof(List <>), out argType);
         Delegate arg0    = ToLua.CheckDelegate(typeof(System.Predicate <>).MakeGenericType(argType), L, 2);
         bool     o       = (bool)LuaMethodCache.CallSingleMethod("TrueForAll", obj, arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int InsertRange(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         Type        argType = null;
         object      obj     = ToLua.CheckGenericObject(L, 1, typeof(List <>), out argType);
         int         arg0    = (int)LuaDLL.luaL_checknumber(L, 2);
         IEnumerable arg1    = (IEnumerable)ToLua.CheckObject(L, 3, typeof(IEnumerable <>).MakeGenericType(argType));
         LuaMethodCache.CallSingleMethod("InsertRange", obj, arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int Remove(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type   argType = null;
         object obj     = ToLua.CheckGenericObject(L, 1, typeof(List <>), out argType);
         object arg0    = ToLua.CheckVarObject(L, 2, argType);
         bool   o       = (bool)LuaMethodCache.CallSingleMethod("Remove", obj, arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int CopyTo(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         Type   kt, kv;
         object obj  = ToLua.CheckGenericObject(L, 1, typeof(Dictionary <,> .ValueCollection), out kt, out kv);
         object arg0 = ToLua.CheckObject(L, 2, kv.MakeArrayType());
         int    arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         LuaMethodCache.CallSingleMethod("CopyTo", obj, arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int FindLast(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type     argType = null;
         object   obj     = ToLua.CheckGenericObject(L, 1, typeof(List <>), out argType);
         Delegate arg0    = ToLua.CheckDelegate(typeof(System.Predicate <>).MakeGenericType(argType), L, 2);
         object   o       = LuaMethodCache.CallSingleMethod("FindLast", obj, arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int CopyTo(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         Type   argType = null;
         object obj     = ToLua.CheckGenericObject(L, 1, typeof(ReadOnlyCollection <>), out argType);
         object arg0    = ToLua.CheckObject(L, 2, argType.MakeArrayType());
         int    arg1    = (int)LuaDLL.luaL_checknumber(L, 3);
         LuaMethodCache.CallSingleMethod("CopyTo", obj, arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int IndexOf(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type   argType = null;
         object obj     = ToLua.CheckGenericObject(L, 1, typeof(ReadOnlyCollection <>), out argType);
         object arg0    = ToLua.CheckVarObject(L, 2, argType);
         int    o       = (int)LuaMethodCache.CallSingleMethod("IndexOf", obj, arg0);
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int get_Item(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type   kt   = null;
         object obj  = ToLua.CheckGenericObject(L, 1, typeof(Dictionary <,>), out kt);
         object arg0 = ToLua.CheckVarObject(L, 2, kt);
         object o    = LuaMethodCache.CallSingleMethod("get_Item", obj, arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int _set_this(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         Type   kt, vt;
         object obj  = ToLua.CheckGenericObject(L, 1, typeof(Dictionary <,>), out kt, out vt);
         object arg0 = ToLua.CheckVarObject(L, 2, kt);
         object arg1 = ToLua.CheckVarObject(L, 2, vt);
         LuaMethodCache.CallSingleMethod("set_Item", obj, arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int ContainsValue(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Type   kt, vt;
         object obj  = ToLua.CheckGenericObject(L, 1, typeof(Dictionary <,>), out kt, out vt);
         object arg0 = ToLua.CheckVarObject(L, 2, vt);
         bool   o    = (bool)LuaMethodCache.CallSingleMethod("ContainsValue", obj, arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    private static int get_Value(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            object obj2 = LuaMethodCache.CallSingleMethod("get_Value", obj, new object[0]);
            ToLua.Push(L, obj2);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index Value on a nil value");
        }
        return(result);
    }
    private static int GetEnumerator(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 1);
            object      obj  = ToLua.CheckGenericObject(L, 1, typeof(ReadOnlyCollection <>));
            IEnumerator iter = (IEnumerator)LuaMethodCache.CallSingleMethod("GetEnumerator", obj, new object[0]);
            ToLua.Push(L, iter);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
    private static int get_Count(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            int n = (int)LuaMethodCache.CallSingleMethod("get_Count", obj, new object[0]);
            LuaDLL.lua_pushinteger(L, n);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index Count on a nil value");
        }
        return(result);
    }