Exemplo n.º 1
0
 public void DetachProfiler()
 {
     if (profiler != null)
     {
         profiler.Call("stop", profiler);
         profiler.Dispose();
         LuaProfiler.Clear();
     }
 }
Exemplo n.º 2
0
 static int EndSample(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 0);
         LuaProfiler.EndSample();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 3
0
 static int BeginSample(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
         LuaProfiler.BeginSample(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 4
0
 static int GetID(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string arg0 = ToLua.CheckString(L, 1);
         int    o    = LuaProfiler.GetID(arg0);
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 5
0
    static int EndSample(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("LuaProfiler.EndSample");
#endif
        try
        {
            ToLua.CheckArgsCount(L, 0);
            LuaProfiler.EndSample();
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 6
0
    static int BeginSample(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("LuaProfiler.BeginSample");
#endif
        try
        {
            ToLua.CheckArgsCount(L, 1);
            int arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
            LuaProfiler.BeginSample(arg0);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 7
0
    static int GetID(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("LuaProfiler.GetID");
#endif
        try
        {
            ToLua.CheckArgsCount(L, 1);
            string arg0 = ToLua.CheckString(L, 1);
            int    o    = LuaProfiler.GetID(arg0);
            LuaDLL.lua_pushinteger(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        HookSetup.HookLuaFuns();

        LuaEnv luaenv = new LuaEnv();

        LuaProfiler.SetMainLuaEnv(luaenv);

        luaenv.AddBuildin("rapidjson", XLua.LuaDLL.Lua.LoadRapidJson);
        luaenv.AddBuildin("lpeg", XLua.LuaDLL.Lua.LoadLpeg);
        luaenv.AddBuildin("pb", XLua.LuaDLL.Lua.LoadLuaProfobuf);
        luaenv.DoString(@"
        ------------------------------------
        local rapidjson = require 'rapidjson' 
        local t = rapidjson.decode('{""a"":123}')
        print(t.a)
        t.a = 456
        local s = rapidjson.encode(t)
        print('json', s)
        ------------------------------------
        local lpeg = require 'lpeg'
        print(lpeg.match(lpeg.R '09','123'))
        ------------------------------------
        local pb = require 'pb'
        local protoc = require 'protoc'

        assert(protoc:load [[
        message Phone {
            optional string name        = 1;
            optional int64  phonenumber = 2;
        }
        message Person {
            optional string name     = 1;
            optional int32  age      = 2;
            optional string address  = 3;
            repeated Phone  contacts = 4;
        } ]])

        local data = {
        name = 'ilse',
        age  = 18,
            contacts = {
                { name = 'alice', phonenumber = 12312341234 },
                { name = 'bob',   phonenumber = 45645674567 }
            }
        }

        local bytes = assert(pb.encode('Person', data))
        print(pb.tohex(bytes))

        local data2 = assert(pb.decode('Person', bytes))
        print(data2.name)
        print(data2.age)
        print(data2.address)
        print(data2.contacts[1].name)
        print(data2.contacts[1].phonenumber)
        print(data2.contacts[2].name)
        print(data2.contacts[2].phonenumber)
        "
                        );
        //luaenv.Dispose();
    }