Exemplo n.º 1
0
        private static int Add(IntPtr L)
        {
            //考虑到unsafe代码里传递对象指针生命周期管理非常麻烦,这里配合s_currentIndex,allLuaMyClassObj
            //牺牲了一点性能实现了一个简单的方案.
            //每个封装函数的开始就是得到对象的C# object instance
            IntPtr  ppMyClass    = XLLRTWarper.luaL_checkudata(L, 1, "HelloBolt.MyClass");
            IntPtr  myclassIndex = new IntPtr(Marshal.ReadInt32(ppMyClass));
            MyClass theObj       = allLuaMyClassObj[myclassIndex.ToInt32()];

            int lhs    = XLLRTWarper.lua_tointeger(L, 2);
            int rhs    = XLLRTWarper.lua_tointeger(L, 3);
            int result = theObj.Add(lhs, rhs);

            XLLRTWarper.lua_pushinteger(L, result);
            return(1);
        }
Exemplo n.º 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //这个Class是等会要注册到Lua环境里的,这里演示了一下这个对象的主要接口的功能
            MyClass theClass = new MyClass();
            AddOb theOb = new AddOb();
            theClass.OnAddFinish += theOb.OnAddFinish;
            theClass.Add(100, 200);

            BoltWarper.Instance().InitBolt("");

            LuaMyClass.RegisterClass();
            string searPath = System.Windows.Forms.Application.StartupPath + "\\..\\samples\\HelloBolt\\XAR\\";
            BoltWarper.Instance().AddXARSearchPath(searPath);
            BoltWarper.Instance().LoadXAR("HelloBolt7");

            Application.Run();
        }
Exemplo n.º 3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //这个Class是等会要注册到Lua环境里的,这里演示了一下这个对象的主要接口的功能
            MyClass theClass = new MyClass();
            AddOb   theOb    = new AddOb();

            theClass.OnAddFinish += theOb.OnAddFinish;
            theClass.Add(100, 200);

            BoltWarper.Instance().InitBolt("");

            LuaMyClass.RegisterClass();
            string searPath = System.Windows.Forms.Application.StartupPath + "\\..\\samples\\HelloBolt\\XAR\\";

            BoltWarper.Instance().AddXARSearchPath(searPath);
            BoltWarper.Instance().LoadXAR("HelloBolt7");



            Application.Run();
        }