コード例 #1
0
ファイル: HexView.cs プロジェクト: principal6/HexDiff
        static public int getBuiltInTypeByteCount(BuiltInDataType builtInType)
        {
            if (builtInType == BuiltInDataType.AnsiChar8 ||
                builtInType == BuiltInDataType.Int8 ||
                builtInType == BuiltInDataType.Uint8)
            {
                return(1);
            }
            else if (builtInType == BuiltInDataType.Int16 ||
                     builtInType == BuiltInDataType.Uint16)
            {
                return(2);
            }
            else if (builtInType == BuiltInDataType.Int32 ||
                     builtInType == BuiltInDataType.Uint32 ||
                     builtInType == BuiltInDataType.Float)
            {
                return(4);
            }
            else if (builtInType == BuiltInDataType.Int64 ||
                     builtInType == BuiltInDataType.Uint64 ||
                     builtInType == BuiltInDataType.Double)
            {
                return(8);
            }

            return(-1); // 가변 길이!!
        }
コード例 #2
0
ファイル: HexView.cs プロジェクト: principal6/HexDiff
        private void constructDocumentTree(XmlNode xmlNode, ref TreeNode currTreeNode)
        {
            if (xmlNode != null)
            {
                for (int i = 0; i < xmlNode.ChildNodes.Count; ++i)
                {
                    XmlNode childNode = xmlNode.ChildNodes[i];

                    if (childNode.Attributes.Count == 0)
                    {
                        MessageBox.Show("속성이 없는 노드입니다. xml 파일을 확인해 주세요", "Document 파싱 실패");
                        continue;
                    }

                    TreeNode newChildNode = currTreeNode.appendChild(new NodeData());
                    for (int j = 0; j < childNode.Attributes.Count; ++j)
                    {
                        XmlNode currAttr = childNode.Attributes[j];
                        if (currAttr.Name == "Name")
                        {
                            newChildNode.Data.Name = currAttr.Value;
                        }
                        else if (currAttr.Name == "Type")
                        {
                            BuiltInDataType builtInType = HexViewDataType.stringToBuiltInDataType(currAttr.Value);
                            if (builtInType == BuiltInDataType.Wrapper)
                            {
                                HexViewDataType found = findDataType(currAttr.Value);
                                newChildNode.Data.Type = found;
                            }
                            else
                            {
                                newChildNode.Data.Type = new HexViewDataType(builtInType);
                            }
                        }
                        else if (currAttr.Name == "Content")
                        {
                            newChildNode.Data.Tip = currAttr.Value;
                        }
                    }

                    constructDocumentTree(childNode, ref newChildNode);
                }
            }
        }
コード例 #3
0
ファイル: Method.cs プロジェクト: romkij/CsCodeGenerator
 public Method(AccessModifier accessModifier, KeyWord singleKeyWord, BuiltInDataType builtInDataType, string name) : base(builtInDataType, name)
 {
     this.AccessModifier = accessModifier;
     this.KeyWords.Add(singleKeyWord);
 }
コード例 #4
0
ファイル: Method.cs プロジェクト: romkij/CsCodeGenerator
 public Method(BuiltInDataType builtInDataType, string name) : base(builtInDataType, name)
 {
 }
コード例 #5
0
 public Property(BuiltInDataType builtInDataType, string name) : base(builtInDataType, name)
 {
 }
コード例 #6
0
ファイル: BaseElement.cs プロジェクト: romkij/CsCodeGenerator
 public BaseElement(BuiltInDataType builtInDataType, string name)
 {
     this.BuiltInDataType = builtInDataType;
     this.Name            = name;
 }
コード例 #7
0
ファイル: HexView.cs プロジェクト: principal6/HexDiff
 public HexViewDataType(BuiltInDataType builtInDataType)
 {
     Name      = builtInDataType.ToString();
     ByteCount = HexViewDataType.getBuiltInTypeByteCount(builtInDataType);
 }
コード例 #8
0
ファイル: HexView.cs プロジェクト: principal6/HexDiff
        private bool constructDataTypeInternal(ref HexViewDataType currDataType, XmlNode xmlNode)
        {
            XmlNode attrName = xmlNode.Attributes.GetNamedItem("Name");

            if (attrName != null)
            {
                currDataType.Alias = attrName.Value;
            }

            XmlNode attrType = xmlNode.Attributes.GetNamedItem("Type");

            if (attrType != null)
            {
                BuiltInDataType builtInType = HexViewDataType.stringToBuiltInDataType(attrType.Value);
                if (builtInType == BuiltInDataType.Wrapper)
                {
                    HexViewDataType found = findDataType(attrType.Value);
                    if (found == null)
                    {
                        MessageBox.Show("해당 데이터 타입이 선언되지 않았습니다. 선언 순서를 지켰습니까?", "사용자 정의 자료형 파싱 실패");
                        return(false);
                    }
                    else
                    {
                        currDataType.Name      = found.Name;
                        currDataType.Children  = found.Children;
                        currDataType.ByteCount = found.ByteCount;
                    }
                }
                else
                {
                    currDataType.Name      = builtInType.ToString();
                    currDataType.ByteCount = HexViewDataType.getBuiltInTypeByteCount(builtInType);
                }
            }

            // 자식이 있는 경우 자식의 ByteCount 를 누적한 게 내 ByteCount 가 된다!
            if (currDataType.Children != null)
            {
                foreach (HexViewDataType childNode in currDataType.Children)
                {
                    currDataType.ByteCount += childNode.ByteCount;
                }
            }

            XmlNode attrContent = xmlNode.Attributes.GetNamedItem("Content");

            if (attrContent != null)
            {
                currDataType.Content = attrContent.Value;
            }

            XmlNode attrFormat = xmlNode.Attributes.GetNamedItem("Format");

            if (attrFormat != null)
            {
                currDataType.Format = attrFormat.Value;
            }

            return(true);
        }
コード例 #9
0
ファイル: HexView.cs プロジェクト: principal6/HexDiff
        public bool isBuiltInDataType()
        {
            BuiltInDataType result = stringToBuiltInDataType(Name);

            return(result != BuiltInDataType.Wrapper);
        }
コード例 #10
0
 public Parameter(BuiltInDataType builtInDataType, string name)
 {
     this.BuiltInDataType = builtInDataType;
     this.Name            = name;
 }
コード例 #11
0
ファイル: Field.cs プロジェクト: romkij/CsCodeGenerator
 public Field(BuiltInDataType builtInDataType, string name) : base(builtInDataType, name)
 {
 }