public static int ClrFuncDict(IntPtr l)
 {
     if (l.istable(1))
     {
         IDictionary dict = null;
         using (var lr = new LuaStateRecover(l))
         {
             LuaOnStackTable tab   = new LuaOnStackTable(l, 1);
             var             ktype = l.GetLua(2).ConvertType(typeof(Type)) as Type;
             var             vtype = l.GetLua(3).ConvertType(typeof(Type)) as Type;
             if (ktype == null)
             {
                 ktype = typeof(object);
             }
             if (vtype == null)
             {
                 vtype = typeof(object);
             }
             dict = typeof(Dictionary <,>).MakeGenericType(ktype, vtype).GetConstructor(new Type[0]).Invoke(null) as IDictionary;
             l.PushLua(tab);
             l.pushnil();
             while (l.next(-2))
             {
                 object key = l.GetLua(-2);
                 object val = l.GetLua(-1);
                 dict.Add(key.UnwrapDynamic().ConvertType(ktype), val.UnwrapDynamic().ConvertType(vtype));
                 l.pop(1);
             }
             //l.pop(1);
         }
         l.PushLua(dict);
         return(1);
     }
     return(0);
 }
 public static int ClrFuncArray(IntPtr l)
 {
     if (l.istable(1))
     {
         Array arr = null;
         using (var lr = new LuaStateRecover(l))
         {
             LuaOnStackTable tab   = new LuaOnStackTable(l, 1);
             var             len   = ((LuaOnStackTable.LuaTableFieldsProvider)tab.FieldsProvider).ArrLength;
             var             otype = l.GetLua(2).ConvertType(typeof(Type));
             if (otype == null)
             {
                 otype = typeof(object);
             }
             arr = Array.CreateInstance((Type)otype, len);
             for (int i = 0; i < len; ++i)
             {
                 arr.SetValue(tab[i + 1].UnwrapDynamic().ConvertType((Type)otype), i);
             }
         }
         l.PushUserDataOfType(arr, arr.GetType());
         return(1);
     }
     else if (l.IsString(1))
     {
         var bytes = l.tolstring(1);
         l.PushUserDataOfType(bytes, typeof(byte[]));
         return(1);
     }
     else if (l.IsNumber(1))
     {
         int len = (int)l.tonumber(1);
         if (len < 0)
         {
             len = 0;
         }
         var otype = l.GetLua(2).ConvertType(typeof(Type));
         if (otype == null)
         {
             otype = typeof(object);
         }
         Array arr = Array.CreateInstance((Type)otype, len);
         l.PushUserDataOfType(arr, arr.GetType());
         return(1);
     }
     return(0);
 }