Esempio n. 1
0
        public void Register(string FuncName, LuaCall func)
        {
            LuaCall z = delegate(IntPtr x)
            {
                int    r;
                IntPtr oldOverride = lua_StateOverride;
                lua_StateOverride = x;
                r = func(x);
                lua_StateOverride = oldOverride;
                return(r);
            };

            luafunctions.Add(z); //prevent it from getting garbage collected
            LuaRegister(State, FuncName, z);
        }
Esempio n. 2
0
        private TreeListViewItem FunctionCallToTreeListViewItem(LuaCall call)
        {
            // Create main item with name
            TreeListViewItem tlvi = new TreeListViewItem(string.Empty);

            tlvi.Tag       = call;
            tlvi.ForeColor = call.FunctionSource != "Lua" ? Color.LightGray : Color.Black;

            // Create subitem with name
            TreeListViewSubItem tlvsi = new TreeListViewSubItem(0);

            if (call.IsLineCall)
            {
                ILuaEditDocument doc = DocumentsManager.Instance.OpenDocument(call.FileName, false);

                if (doc is LuaScriptDocument)
                {
                    LuaScriptDocument luaDoc = doc as LuaScriptDocument;

                    if (call.FunctionLineCall < luaDoc.Document.Lines.Length)
                    {
                        tlvsi.Object = string.Format("{0}  Line {1}", luaDoc.Document.Lines[call.FunctionLineCall - 1].TrimStart(new char[] { ' ', '\t' }), call.FunctionLineCall);
                    }
                }
            }
            else
            {
                if (call.FunctionName == "[EntryPoint]")
                {
                    tlvsi.Object = call.FunctionName;
                }
                else
                {
                    tlvsi.Object = string.Format("{0}({1})  Line {2}", call.FunctionName, call.ParamString, call.FunctionLineCall);
                }
            }

            tlvi.SubItems.Add(tlvsi);

            // Create subitem with language
            tlvi.SubItems.Add(new TreeListViewSubItem(1, call.FunctionSource));

            // Create subitem with filename
            tlvi.SubItems.Add(new TreeListViewSubItem(2, call.FileName));

            return(tlvi);
        }
Esempio n. 3
0
        private void ResetCallStackImages()
        {
            for (int x = 0; x < tlvwCallStack.Items.Count; ++x)
            {
                TreeListViewItem tlvi = tlvwCallStack.Items[x];
                LuaCall          call = (LuaCall)tlvi.Tag;

                if (!call.Equals(null))
                {
                    if (x == 0)
                    {
                        Breakpoint bp = BreakpointManager.Instance.GetBreakpointAtLine(call.FileName, call.FunctionLineCall);

                        if (bp != null)
                        {
                            tlvi.ImageIndex         = bp.Enabled ? 1 : 2;
                            tlvi.SelectedImageIndex = bp.Enabled ? 1 : 2;
                        }
                        else
                        {
                            tlvi.ImageIndex         = 0;
                            tlvi.SelectedImageIndex = 0;
                        }
                    }
                    else if (x == _currentStackLevel)
                    {
                        tlvi.ImageIndex         = 3;
                        tlvi.SelectedImageIndex = 3;
                    }
                    else
                    {
                        tlvi.ImageIndex         = -1;
                        tlvi.SelectedImageIndex = -1;
                    }
                }
            }
        }
Esempio n. 4
0
 public int PushFunction(LuaCall func)
 {
     return(PushClosure(func, 0));
 }
Esempio n. 5
0
 public int PushClosure(LuaCall func, int n)
 {
     return(lua_pushcclosure(State, func, n));
 }
Esempio n. 6
0
        private void UpdateThreads()
        {
            tlvwThreads.BeginUpdate();

            try
            {
                ClearThreads();

                if (ClientDebugManager.Instance.LuaThreads != null)
                {
                    foreach (LuaThread luaThread in ClientDebugManager.Instance.LuaThreads)
                    {
                        LuaCall          call = luaThread.CallStackTopCall;
                        TreeListViewItem tlvi = new TreeListViewItem();
                        tlvi.Tag = luaThread;
                        tlvi.SubItems.Add(new TreeListViewSubItem(0));

                        TreeListViewSubItem tlvsiID = new TreeListViewSubItem(1, luaThread.ThreadID);
                        tlvi.SubItems.Add(tlvsiID);

                        if (call != null)
                        {
                            if (call.IsLineCall)
                            {
                                ILuaEditDocument  doc    = DocumentsManager.Instance.OpenDocument(call.FileName, false);
                                LuaScriptDocument luaDoc = doc as LuaScriptDocument;

                                if (luaDoc != null)
                                {
                                    string location = string.Format("{0}   (Lua)   Line {1}", luaDoc.Document.Lines[call.FunctionLineCall - 1].TrimStart(new char[] { ' ', '\t' }), call.FunctionLineCall);
                                    TreeListViewSubItem tlvsiLocation = new TreeListViewSubItem(2, location);
                                    tlvi.SubItems.Add(tlvsiLocation);
                                }
                            }
                            else
                            {
                                string location = string.Format("{0}   ({1})   Line {2}", call.FunctionName, call.FunctionSource, call.LineCalled);
                                TreeListViewSubItem tlvsiLocation = new TreeListViewSubItem(2, location);
                                tlvi.SubItems.Add(tlvsiLocation);
                            }
                        }

                        if (luaThread.ThreadID == ClientDebugManager.Instance.CurrentThreadID)
                        {
                            tlvi.ImageIndex         = 0;
                            tlvi.SelectedImageIndex = 0;
                        }
                        else
                        {
                            tlvi.ImageIndex         = -1;
                            tlvi.SelectedImageIndex = -1;
                        }

                        tlvwThreads.Items.Add(tlvi);
                    }
                }
            }
            finally
            {
                tlvwThreads.EndUpdate();
            }
        }