//////////////////////////////////////////////////////////////////////////
        internal bool ReadXml(XmlNode RootNode)
        {
            XmlNode Val = null;
            XmlNode Node = RootNode.FirstChild;
            while(Node!=null)
            {
                switch(Node.Name)
                {
                    case "BaseFilename":
                        Val = Node.FirstChild;
                        if (Val is XmlText) this.BaseFilename = Val.Value;
                        break;

                    case "NativeClass":
                        Val = Node.FirstChild;
                        if (Val is XmlText) this.NativeClass = Val.Value;
                        break;

                    case "Name":
                        Val = Node.FirstChild;
                        if(Val is XmlText) this.Name = Val.Value;
                        break;

                    case "Description":
                        Val = Node.FirstChild;
                        if (Val is XmlText) this.Desc = Val.Value;
                        break;

                    case "Method":
                        ScriptMethod Method = new ScriptMethod();
                        if (Method.ReadXml(Node)) Methods.Add(Method);
                        break;

                    case "Attribute":
                        ScriptAttribute Attr = new ScriptAttribute();
                        if (Attr.ReadXml(Node)) Attributes.Add(Attr);
                        break;

                    case "Event":
                        ScriptEvent Event = new ScriptEvent();
                        if (Event.ReadXml(Node)) Events.Add(Event);
                        break;
                }
                Node = Node.NextSibling;
            }

            return true;
        }
Пример #2
0
        //////////////////////////////////////////////////////////////////////////
        internal bool ReadXml(XmlNode RootNode)
        {
            XmlNode Val  = null;
            XmlNode Node = RootNode.FirstChild;

            while (Node != null)
            {
                switch (Node.Name)
                {
                case "BaseFilename":
                    Val = Node.FirstChild;
                    if (Val is XmlText)
                    {
                        this.BaseFilename = Val.Value;
                    }
                    break;

                case "NativeClass":
                    Val = Node.FirstChild;
                    if (Val is XmlText)
                    {
                        this.NativeClass = Val.Value;
                    }
                    break;

                case "Name":
                    Val = Node.FirstChild;
                    if (Val is XmlText)
                    {
                        this.Name = Val.Value;
                    }
                    break;

                case "Description":
                    Val = Node.FirstChild;
                    if (Val is XmlText)
                    {
                        this.Desc = Val.Value;
                    }
                    break;

                case "Method":
                    ScriptMethod Method = new ScriptMethod();
                    if (Method.ReadXml(Node))
                    {
                        Methods.Add(Method);
                    }
                    break;

                case "Attribute":
                    ScriptAttribute Attr = new ScriptAttribute();
                    if (Attr.ReadXml(Node))
                    {
                        Attributes.Add(Attr);
                    }
                    break;

                case "Event":
                    ScriptEvent Event = new ScriptEvent();
                    if (Event.ReadXml(Node))
                    {
                        Events.Add(Event);
                    }
                    break;
                }
                Node = Node.NextSibling;
            }

            return(true);
        }
        //////////////////////////////////////////////////////////////////////////
        private ScriptObject ParseFile(string Filename)
        {
            ScriptObject Obj = new ScriptObject();
            Obj.BaseFilename = Path.GetFileNameWithoutExtension(Filename);

            List<string> Lines = new List<string>();
            ReadLines(Filename, ref Lines);

            ScriptItem CurrentItem = null;
            string CurrentGroup = "";
            bool InExample = false;
            string CurrentExample = "";

            foreach (string line in Lines)
            {
                string Token = GetToken(line);
                string Data = GetData(line);

                switch (Token)
                {
                    case "*tit":
                    case "*title":
                        if (Obj.Name != "") Obj.Name += "\n";
                        Obj.Name += Data;
                        break;

                    case "*cls":
                    case "*class":
                        Obj.NativeClass = Data;
                        break;

                    case "*des":
                    case "*desc":
                    case "*description":
                        if (CurrentItem != null)
                        {
                            if (CurrentItem.Desc != "") CurrentItem.Desc += "\n";
                            CurrentItem.Desc += Data;
                        }
                        else if(Obj!=null)
                        {
                            if (Obj.Desc != "") Obj.Desc += "\n";
                            Obj.Desc += Data;
                        }
                        break;

                    case "*grp":
                    case "*group":
                        CurrentGroup = Data;
                        break;

                    case "*met":
                    case "*method":
                    case "*con":
                        CurrentItem = new ScriptMethod();
                        Obj.Methods.Add((ScriptMethod)CurrentItem);

                        ((ScriptMethod)CurrentItem).Headers.Add(Data);
                        CurrentItem.Group = CurrentGroup;

                        if (Token.StartsWith("*c")) ((ScriptMethod)CurrentItem).Constructor = true;
                        break;

                    case "*mt2":
                    case "*met2":
                    case "*method2":
                    case "*con2":
                        if (CurrentItem != null && CurrentItem is ScriptMethod)
                        {
                            ((ScriptMethod)CurrentItem).Headers.Add(Data);
                        }
                        break;

                    case "*par":
                    case "*param":
                    case "*parameter":
                    case "*opt":
                    case "*optpar":
                        if (CurrentItem != null && CurrentItem is ScriptMethod)
                        {
                            string ParamName = GetToken(Data);
                            string ParamData = GetData(Data);

                            if (ParamName != "")
                            {
                                ScriptParameter Param = new ScriptParameter();
                                Param.Name = ParamName;
                                Param.Desc = ParamData;

                                if (Token.StartsWith("*o")) Param.Optional = true;

                                ((ScriptMethod)CurrentItem).Parameters.Add(Param);
                                //((ScriptMethod)CurrentItem).Parameters.Sort();

                            }
                        }
                        break;

                    case "*ret":
                    case "*return":
                        if (CurrentItem != null && CurrentItem is ScriptMethod)
                        {
                            ScriptMethod Mtd = (ScriptMethod)CurrentItem;
                            if (Mtd.Return != "") Mtd.Return += "\n";
                            Mtd.Return += Data;
                        }
                        break;

                    case "*rem":
                    case "*remark":
                        if (CurrentItem != null && CurrentItem is ScriptMethod)
                        {
                            ScriptMethod Mtd = (ScriptMethod)CurrentItem;
                            if (Mtd.Remark != "") Mtd.Remark += "\n";
                            Mtd.Remark += Data;
                        }
                        break;

                    case "*ex_start":
                        InExample = true;
                        CurrentExample = "";
                        break;

                    case "*ex_end":
                        InExample = false;
                        if (CurrentExample != "" && CurrentItem != null && CurrentItem is ScriptMethod)
                        {
                            ((ScriptMethod)CurrentItem).Examples.Add(CurrentExample);
                        }
                        CurrentExample = "";
                        break;

                    case "*atr":
                    case "*attr":
                    case "*attribute":
                    case "*gatr":
                    case "*gattr":
                    case "*gattribute":
                        CurrentItem = new ScriptAttribute();
                        Obj.Attributes.Add((ScriptAttribute)CurrentItem);

                        CurrentItem.Name = Data;
                        CurrentItem.Group = CurrentGroup;

                        if (Token.StartsWith("*g")) CurrentItem.IsGlobal = true;
                        break;

                    case "*ro":
                        if (CurrentItem != null && CurrentItem is ScriptAttribute)
                        {
                            ((ScriptAttribute)CurrentItem).ReadOnly = true;
                        }
                        break;

                    case "*glo":
                    case "*glob":
                    case "*global":
                        CurrentItem = new ScriptMethod();
                        Obj.Methods.Add((ScriptMethod)CurrentItem);

                        ((ScriptMethod)CurrentItem).Headers.Add(Data);
                        ((ScriptMethod)CurrentItem).IsGlobal = true;
                        CurrentItem.Group = CurrentGroup;
                        break;

                    case "*gl2":
                    case "*glo2":
                    case "*glob2":
                    case "*global2":
                        if (CurrentItem != null && CurrentItem is ScriptMethod)
                        {
                            ((ScriptMethod)CurrentItem).Headers.Add(Data);
                        }
                        break;

                    case "*evn":
                    case "*evt":
                    case "*event":
                        CurrentItem = new ScriptEvent();
                        Obj.Events.Add((ScriptEvent)CurrentItem);

                        CurrentItem.Name = Data;
                        CurrentItem.Group = CurrentGroup;
                        break;

                    default:
                        if (InExample && line != "")
                        {
                            if (CurrentExample != "") CurrentExample += "\n";
                            CurrentExample += line;
                        }
                        break;
                }

            }
            return Obj;
        }
Пример #4
0
        //////////////////////////////////////////////////////////////////////////
        private ScriptObject ParseFile(string Filename)
        {
            ScriptObject Obj = new ScriptObject();

            Obj.BaseFilename = Path.GetFileNameWithoutExtension(Filename);

            List <string> Lines = new List <string>();

            ReadLines(Filename, ref Lines);

            ScriptItem CurrentItem    = null;
            string     CurrentGroup   = "";
            bool       InExample      = false;
            string     CurrentExample = "";

            foreach (string line in Lines)
            {
                string Token = GetToken(line);
                string Data  = GetData(line);

                switch (Token)
                {
                case "*tit":
                case "*title":
                    if (Obj.Name != "")
                    {
                        Obj.Name += "\n";
                    }
                    Obj.Name += Data;
                    break;

                case "*cls":
                case "*class":
                    Obj.NativeClass = Data;
                    break;

                case "*des":
                case "*desc":
                case "*description":
                    if (CurrentItem != null)
                    {
                        if (CurrentItem.Desc != "")
                        {
                            CurrentItem.Desc += "\n";
                        }
                        CurrentItem.Desc += Data;
                    }
                    else if (Obj != null)
                    {
                        if (Obj.Desc != "")
                        {
                            Obj.Desc += "\n";
                        }
                        Obj.Desc += Data;
                    }
                    break;

                case "*grp":
                case "*group":
                    CurrentGroup = Data;
                    break;

                case "*met":
                case "*method":
                case "*con":
                    CurrentItem = new ScriptMethod();
                    Obj.Methods.Add((ScriptMethod)CurrentItem);

                    ((ScriptMethod)CurrentItem).Headers.Add(Data);
                    CurrentItem.Group = CurrentGroup;

                    if (Token.StartsWith("*c"))
                    {
                        ((ScriptMethod)CurrentItem).Constructor = true;
                    }
                    break;

                case "*mt2":
                case "*met2":
                case "*method2":
                case "*con2":
                    if (CurrentItem != null && CurrentItem is ScriptMethod)
                    {
                        ((ScriptMethod)CurrentItem).Headers.Add(Data);
                    }
                    break;

                case "*par":
                case "*param":
                case "*parameter":
                case "*opt":
                case "*optpar":
                    if (CurrentItem != null && CurrentItem is ScriptMethod)
                    {
                        string ParamName = GetToken(Data);
                        string ParamData = GetData(Data);

                        if (ParamName != "")
                        {
                            ScriptParameter Param = new ScriptParameter();
                            Param.Name = ParamName;
                            Param.Desc = ParamData;

                            if (Token.StartsWith("*o"))
                            {
                                Param.Optional = true;
                            }

                            ((ScriptMethod)CurrentItem).Parameters.Add(Param);
                            //((ScriptMethod)CurrentItem).Parameters.Sort();
                        }
                    }
                    break;

                case "*ret":
                case "*return":
                    if (CurrentItem != null && CurrentItem is ScriptMethod)
                    {
                        ScriptMethod Mtd = (ScriptMethod)CurrentItem;
                        if (Mtd.Return != "")
                        {
                            Mtd.Return += "\n";
                        }
                        Mtd.Return += Data;
                    }
                    break;

                case "*rem":
                case "*remark":
                    if (CurrentItem != null && CurrentItem is ScriptMethod)
                    {
                        ScriptMethod Mtd = (ScriptMethod)CurrentItem;
                        if (Mtd.Remark != "")
                        {
                            Mtd.Remark += "\n";
                        }
                        Mtd.Remark += Data;
                    }
                    break;

                case "*ex_start":
                    InExample      = true;
                    CurrentExample = "";
                    break;

                case "*ex_end":
                    InExample = false;
                    if (CurrentExample != "" && CurrentItem != null && CurrentItem is ScriptMethod)
                    {
                        ((ScriptMethod)CurrentItem).Examples.Add(CurrentExample);
                    }
                    CurrentExample = "";
                    break;

                case "*atr":
                case "*attr":
                case "*attribute":
                case "*gatr":
                case "*gattr":
                case "*gattribute":
                    CurrentItem = new ScriptAttribute();
                    Obj.Attributes.Add((ScriptAttribute)CurrentItem);

                    CurrentItem.Name  = Data;
                    CurrentItem.Group = CurrentGroup;

                    if (Token.StartsWith("*g"))
                    {
                        CurrentItem.IsGlobal = true;
                    }
                    break;

                case "*ro":
                    if (CurrentItem != null && CurrentItem is ScriptAttribute)
                    {
                        ((ScriptAttribute)CurrentItem).ReadOnly = true;
                    }
                    break;

                case "*glo":
                case "*glob":
                case "*global":
                    CurrentItem = new ScriptMethod();
                    Obj.Methods.Add((ScriptMethod)CurrentItem);

                    ((ScriptMethod)CurrentItem).Headers.Add(Data);
                    ((ScriptMethod)CurrentItem).IsGlobal = true;
                    CurrentItem.Group = CurrentGroup;
                    break;

                case "*gl2":
                case "*glo2":
                case "*glob2":
                case "*global2":
                    if (CurrentItem != null && CurrentItem is ScriptMethod)
                    {
                        ((ScriptMethod)CurrentItem).Headers.Add(Data);
                    }
                    break;

                case "*evn":
                case "*evt":
                case "*event":
                    CurrentItem = new ScriptEvent();
                    Obj.Events.Add((ScriptEvent)CurrentItem);

                    CurrentItem.Name  = Data;
                    CurrentItem.Group = CurrentGroup;
                    break;

                default:
                    if (InExample && line != "")
                    {
                        if (CurrentExample != "")
                        {
                            CurrentExample += "\n";
                        }
                        CurrentExample += line;
                    }
                    break;
                }
            }
            return(Obj);
        }