Ejemplo n.º 1
0
        public IEnumerable <Variable> GetVariablesByName(IEnumerable <string> names, EVariableNamespace scope = EVariableNamespace.MissionNamespace)
        {
            var command = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());

            command.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.GetVariable);
            var data = command.GetValue_Object()["data"];

            data.GetValue_Object()["name"]  = new asapJson.JsonNode(new List <asapJson.JsonNode>(names.Select(name => new asapJson.JsonNode(name))));
            data.GetValue_Object()["scope"] = new asapJson.JsonNode((int)scope);
            this.WriteMessage(command);

            //have to wait for response now. which will be command 3

            throw new NotImplementedException();
            //command should be the returned packet
            var variables = command.GetValue_Object()["data"];

            foreach (var variable in variables.GetValue_Array())
            {
                var name  = variable.GetValue_Object()["name"].GetValue_String();
                var type  = variable.GetValue_Object()["type"].GetValue_String();
                var value = "";
                if (type != "void")
                {
                    value = variable.GetValue_Object()["value"].GetValue_String();
                    var ns = (EVariableNamespace)variable.GetValue_Object()["ns"].GetValue_Number();//Namespace the variable comes from
                }
                yield return(new Variable()
                {
                    Name = name, Value = value, VariableType = Variable.ValueType.Parse(type)
                });
            }
        }
Ejemplo n.º 2
0
 public void UpdateBreakpoint(Breakpoint b)
 {
     {
         var command = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
         command.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.AddBreakpoint);
         command.GetValue_Object()["data"]    = b.Serialize();
         this.WriteMessage(command);
     }
 }
Ejemplo n.º 3
0
        //https://github.com/dedmen/ArmaDebugEngine/blob/master/BIDebugEngine/BIDebugEngine/breakPoint.cpp#L12 void BreakPoint::Serialize(JsonArchive& ar)

        /*
         *  {
         *      "action": {
         *          "code": "string",
         *          "basePath" : "string",
         *          "type": 0
         *      },
         *      "condition":  {
         *          "code": "string",
         *          "type": 0
         *      },
         *      "filename": "string",
         *      "line": 0
         *  }
         */
        public static asapJson.JsonNode Serialize(this ArmA.Studio.Debugger.Breakpoint b)
        {
            var data   = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
            var action = data.GetValue_Object()["action"] = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());

            action.GetValue_Object()["code"]     = new asapJson.JsonNode();
            action.GetValue_Object()["basePath"] = new asapJson.JsonNode();
            action.GetValue_Object()["type"]     = new asapJson.JsonNode(2); //https://github.com/dedmen/ArmaDebugEngine/blob/master/BIDebugEngine/BIDebugEngine/breakPoint.h#L82
            data.GetValue_Object()["condition"]  = new asapJson.JsonNode();
            data.GetValue_Object()["filename"]   = new asapJson.JsonNode(b.ArmAPath);
            data.GetValue_Object()["line"]       = new asapJson.JsonNode(b.Line);
            return(data);
        }
Ejemplo n.º 4
0
        //https://github.com/dedmen/ArmaDebugEngine/blob/master/BIDebugEngine/BIDebugEngine/breakPoint.cpp#L12 void BreakPoint::Serialize(JsonArchive& ar)

        /*
         *  {
         *      "action": {
         *          "code": "string",
         *          "basePath" : "string",
         *          "type": 0
         *      },
         *      "condition": "string",
         *      "filename": "string",
         *      "line": 0
         *  }
         */
        public static asapJson.JsonNode Serialize(this ArmA.Studio.Data.BreakpointInfo b)
        {
            var data   = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
            var action = data.GetValue_Object()["action"] = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());

            action.GetValue_Object()["code"]     = new asapJson.JsonNode();
            action.GetValue_Object()["basePath"] = new asapJson.JsonNode();
            action.GetValue_Object()["type"]     = new asapJson.JsonNode(2); //https://github.com/dedmen/ArmaDebugEngine/blob/master/BIDebugEngine/BIDebugEngine/breakPoint.h#L82
            data.GetValue_Object()["condition"]  = string.IsNullOrWhiteSpace(b.SqfCondition) ? new asapJson.JsonNode() : new asapJson.JsonNode(b.SqfCondition);
            data.GetValue_Object()["filename"]   = new asapJson.JsonNode(b.FileRef.ArmAPath.Replace('/', '\\').Replace(@"\\", @"\"));
            data.GetValue_Object()["line"]       = new asapJson.JsonNode(b.Line);
            return(data);
        }
Ejemplo n.º 5
0
        public bool Perform(EOperation op)
        {
            switch (op)
            {
            case EOperation.Continue:
            {
                var node = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
                node.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.ContinueExecution);
                node.GetValue_Object()["data"]    = new asapJson.JsonNode((int)EStepType.Continue);
                this.WriteMessage(node);
                return(true);
            }

            case EOperation.StepInto:
            {
                var node = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
                node.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.ContinueExecution);
                node.GetValue_Object()["data"]    = new asapJson.JsonNode((int)EStepType.StepInto);
                this.WriteMessage(node);
                return(true);
            }

            case EOperation.StepOver:
            {
                var node = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
                node.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.ContinueExecution);
                node.GetValue_Object()["data"]    = new asapJson.JsonNode((int)EStepType.StepOver);
                this.WriteMessage(node);
                return(true);
            }

            case EOperation.StepOut:
            {
                var node = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
                node.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.ContinueExecution);
                node.GetValue_Object()["data"]    = new asapJson.JsonNode((int)EStepType.StepOut);
                this.WriteMessage(node);
                return(true);
            }

            default:
                this.LastError = "Not Implemented";
                return(false);
            }
        }
Ejemplo n.º 6
0
        private void Thread_ReadPipeMessage()
        {
            try
            {
                var buffer = new byte[2048];
                while (this.Pipe.IsConnected)
                {
                    var builder = new StringBuilder();
                    do
                    {
                        var ammount = this.Pipe.Read(buffer, 0, buffer.Length);
                        for (int i = 0; i < ammount; i++)
                        {
                            builder.Append((char)buffer[i]);
                        }
                    } while (!this.Pipe.IsMessageComplete);
                    if (builder.Length > 0)
                    {
                        var node = new asapJson.JsonNode(builder.ToString(), true);
                        Logger.Log(NLog.LogLevel.Info, string.Format("RECV {0}", node.ToString()));
                        if (node.GetValue_Object().ContainsKey("exception"))
                        {
                            this.OnError?.Invoke(this, new OnErrorEventArgs()
                            {
                                Message = node.GetValue_Object()["exception"].GetValue_String()
                            });
                        }
                        else
                        {
                            switch ((int)node.GetValue_Object()["command"].GetValue_Number())
                            {
                            case (int)ERecvCommands.Halt:
                            {
                                var callstack      = this.LastCallstack = node.GetValue_Object()["callstack"];
                                var instruction    = node.GetValue_Object()["instruction"];
                                var fileOffsetNode = instruction.GetValue_Object()["fileOffset"];
                                var line           = (int)fileOffsetNode.GetValue_Array()[0].GetValue_Number();
                                var col            = (int)fileOffsetNode.GetValue_Array()[2].GetValue_Number();
                                this.OnHalt?.Invoke(this, new OnHaltEventArgs()
                                    {
                                        DocumentPath = instruction.GetValue_Object()["filename"].GetValue_String(), Col = col, Line = line
                                    });
                            }
                            break;

                            case (int)ERecvCommands.ContinueExecution:
                            {
                                this.OnContinue?.Invoke(this, new OnContinueEventArgs()
                                    {
                                    });
                            }
                            break;


                            default:
                                this.Messages.Add(node);
                                break;
                            }
                        }
                    }
                    Thread.Sleep(10);
                }
            }
            catch (ObjectDisposedException) { }
        }