#if USE_UNI_LUA using LuaAPI = UniLua.Lua; using RealStatePtr = UniLua.ILuaState; using LuaCSFunction = UniLua.CSharpFunctionDelegate; #else using LuaAPI = XLua.LuaDLL.Lua; using RealStatePtr = System.IntPtr; using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; #endif using XLua; using System.Collections.Generic; namespace XLua.CSObjectWrap { using Utils = XLua.Utils; public class BFSocketChannelHelperWrap { public static void __Register(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); System.Type type = typeof(BF.SocketChannelHelper); Utils.BeginObjectRegister(type, L, translator, 0, 5, 2, 0); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetRc4Encrypt", _m_SetRc4Encrypt); Utils.RegisterFunc(L, Utils.METHOD_IDX, "Shutdown", _m_Shutdown); Utils.RegisterFunc(L, Utils.METHOD_IDX, "UnPack", _m_UnPack); Utils.RegisterFunc(L, Utils.METHOD_IDX, "Serialize", _m_Serialize); Utils.RegisterFunc(L, Utils.METHOD_IDX, "DeserializeHeader", _m_DeserializeHeader); Utils.RegisterFunc(L, Utils.GETTER_IDX, "HeaderLength", _g_get_HeaderLength); Utils.RegisterFunc(L, Utils.GETTER_IDX, "InfoLength", _g_get_InfoLength); Utils.EndObjectRegister(type, L, translator, null, null, null, null, null); Utils.BeginClassRegister(type, L, __CreateInstance, 2, 0, 0); Utils.RegisterFunc(L, Utils.CLS_IDX, "DeCompressBuffer", _m_DeCompressBuffer_xlua_st_); Utils.EndClassRegister(type, L, translator); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if(LuaAPI.lua_gettop(L) == 2 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2)) { bool _isLittleEndian = LuaAPI.lua_toboolean(L, 2); var gen_ret = new BF.SocketChannelHelper(_isLittleEndian); translator.Push(L, gen_ret); return 1; } } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to BF.SocketChannelHelper constructor!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int _m_SetRc4Encrypt(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); BF.SocketChannelHelper gen_to_be_invoked = (BF.SocketChannelHelper)translator.FastGetCSObj(L, 1); { BF.Rc4Encrypt _Rc4Encrypt = (BF.Rc4Encrypt)translator.GetObject(L, 2, typeof(BF.Rc4Encrypt)); gen_to_be_invoked.SetRc4Encrypt( _Rc4Encrypt ); return 0; } } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int _m_Shutdown(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); BF.SocketChannelHelper gen_to_be_invoked = (BF.SocketChannelHelper)translator.FastGetCSObj(L, 1); { gen_to_be_invoked.Shutdown( ); return 0; } } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int _m_UnPack(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); BF.SocketChannelHelper gen_to_be_invoked = (BF.SocketChannelHelper)translator.FastGetCSObj(L, 1); { byte[] _body = LuaAPI.lua_tobytes(L, 2); uint _group; int _cmd; var gen_ret = gen_to_be_invoked.UnPack( ref _body, out _group, out _cmd ); LuaAPI.lua_pushboolean(L, gen_ret); LuaAPI.lua_pushstring(L, _body); LuaAPI.xlua_pushuint(L, _group); LuaAPI.xlua_pushinteger(L, _cmd); return 4; } } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int _m_DeCompressBuffer_xlua_st_(RealStatePtr L) { try { { byte[] _byteArray = LuaAPI.lua_tobytes(L, 1); var gen_ret = BF.SocketChannelHelper.DeCompressBuffer( _byteArray ); LuaAPI.lua_pushstring(L, gen_ret); return 1; } } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int _m_Serialize(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); BF.SocketChannelHelper gen_to_be_invoked = (BF.SocketChannelHelper)translator.FastGetCSObj(L, 1); { BF.SocketChannel.NetPack _pack = (BF.SocketChannel.NetPack)translator.GetObject(L, 2, typeof(BF.SocketChannel.NetPack)); System.IO.MemoryStream _destination = (System.IO.MemoryStream)translator.GetObject(L, 3, typeof(System.IO.MemoryStream)); var gen_ret = gen_to_be_invoked.Serialize( _pack, _destination ); LuaAPI.lua_pushboolean(L, gen_ret); return 1; } } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int _m_DeserializeHeader(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); BF.SocketChannelHelper gen_to_be_invoked = (BF.SocketChannelHelper)translator.FastGetCSObj(L, 1); { BF.ICircularBuffer _receiveBuffer = (BF.ICircularBuffer)translator.GetObject(L, 2, typeof(BF.ICircularBuffer)); var gen_ret = gen_to_be_invoked.DeserializeHeader( _receiveBuffer ); LuaAPI.xlua_pushinteger(L, gen_ret); return 1; } } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int _g_get_HeaderLength(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); BF.SocketChannelHelper gen_to_be_invoked = (BF.SocketChannelHelper)translator.FastGetCSObj(L, 1); LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.HeaderLength); } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int _g_get_InfoLength(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); BF.SocketChannelHelper gen_to_be_invoked = (BF.SocketChannelHelper)translator.FastGetCSObj(L, 1); LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.InfoLength); } catch(System.Exception gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + gen_e); } return 1; } } }