362 lines
12 KiB
C#
362 lines
12 KiB
C#
#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 BFSocketChannelNetPackWrap
|
|
{
|
|
public static void __Register(RealStatePtr L)
|
|
{
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
System.Type type = typeof(BF.SocketChannel.NetPack);
|
|
Utils.BeginObjectRegister(type, L, translator, 0, 2, 5, 5);
|
|
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Init", _m_Init);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Reset", _m_Reset);
|
|
|
|
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "group", _g_get_group);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "cmd", _g_get_cmd);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "seq", _g_get_seq);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "data", _g_get_data);
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "packDataLength", _g_get_packDataLength);
|
|
|
|
Utils.RegisterFunc(L, Utils.SETTER_IDX, "group", _s_set_group);
|
|
Utils.RegisterFunc(L, Utils.SETTER_IDX, "cmd", _s_set_cmd);
|
|
Utils.RegisterFunc(L, Utils.SETTER_IDX, "seq", _s_set_seq);
|
|
Utils.RegisterFunc(L, Utils.SETTER_IDX, "data", _s_set_data);
|
|
Utils.RegisterFunc(L, Utils.SETTER_IDX, "packDataLength", _s_set_packDataLength);
|
|
|
|
|
|
Utils.EndObjectRegister(type, L, translator, null, null,
|
|
null, null, null);
|
|
|
|
Utils.BeginClassRegister(type, L, __CreateInstance, 3, 0, 0);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "CreateNetPack", _m_CreateNetPack_xlua_st_);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "RecycleNetPack", _m_RecycleNetPack_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) == 5 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 4) && (LuaAPI.lua_isnil(L, 5) || LuaAPI.lua_type(L, 5) == LuaTypes.LUA_TSTRING))
|
|
{
|
|
int _s = LuaAPI.xlua_tointeger(L, 2);
|
|
uint _g = LuaAPI.xlua_touint(L, 3);
|
|
byte _c = (byte)LuaAPI.xlua_tointeger(L, 4);
|
|
byte[] _d = LuaAPI.lua_tobytes(L, 5);
|
|
|
|
var gen_ret = new BF.SocketChannel.NetPack(_s, _g, _c, _d);
|
|
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.SocketChannel.NetPack constructor!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_Init(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
int _s = LuaAPI.xlua_tointeger(L, 2);
|
|
uint _g = LuaAPI.xlua_touint(L, 3);
|
|
byte _c = (byte)LuaAPI.xlua_tointeger(L, 4);
|
|
byte[] _d = LuaAPI.lua_tobytes(L, 5);
|
|
|
|
gen_to_be_invoked.Init( _s, _g, _c, _d );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_Reset(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
|
|
gen_to_be_invoked.Reset( );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_CreateNetPack_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
|
|
|
|
{
|
|
int _seq = LuaAPI.xlua_tointeger(L, 1);
|
|
uint _group = LuaAPI.xlua_touint(L, 2);
|
|
byte _cmd = (byte)LuaAPI.xlua_tointeger(L, 3);
|
|
byte[] _data = LuaAPI.lua_tobytes(L, 4);
|
|
|
|
var gen_ret = BF.SocketChannel.NetPack.CreateNetPack( _seq, _group, _cmd, _data );
|
|
translator.Push(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_RecycleNetPack_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
|
|
|
|
{
|
|
BF.SocketChannel.NetPack _pack = (BF.SocketChannel.NetPack)translator.GetObject(L, 1, typeof(BF.SocketChannel.NetPack));
|
|
|
|
BF.SocketChannel.NetPack.RecycleNetPack( _pack );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_group(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.xlua_pushuint(L, gen_to_be_invoked.group);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_cmd(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.cmd);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_seq(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.seq);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_data(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.lua_pushstring(L, gen_to_be_invoked.data);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_packDataLength(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.packDataLength);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _s_set_group(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
gen_to_be_invoked.group = LuaAPI.xlua_touint(L, 2);
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _s_set_cmd(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
gen_to_be_invoked.cmd = (byte)LuaAPI.xlua_tointeger(L, 2);
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _s_set_seq(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
gen_to_be_invoked.seq = LuaAPI.xlua_tointeger(L, 2);
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _s_set_data(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
gen_to_be_invoked.data = LuaAPI.lua_tobytes(L, 2);
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _s_set_packDataLength(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
BF.SocketChannel.NetPack gen_to_be_invoked = (BF.SocketChannel.NetPack)translator.FastGetCSObj(L, 1);
|
|
gen_to_be_invoked.packDataLength = LuaAPI.xlua_tointeger(L, 2);
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|