コード例 #1
0
        private static string CppTypeConvert_vector(TypeTreeNode varNode, List <TypeTreeNode> varTreeNodes, out List <TypeTreeNode> varFieldTypeNodes)
        {
            var tempIdx = varNode.m_Index;
            //check
            {
                Debug.Assert(varTreeNodes[tempIdx + 1].m_Name == "Array");
                Debug.Assert(varTreeNodes[tempIdx + 2].m_Name == "size");
                Debug.Assert(varTreeNodes[tempIdx + 3].m_Name == "data");
            }
            var tempFieldDes = varTreeNodes[tempIdx + 3].GetNodeCsharpTypeDes(varTreeNodes, out varFieldTypeNodes);

            return(string.Format("List<{0}>", tempFieldDes));
        }
コード例 #2
0
        public static List <TypeTree2Class> Convert(TypeTreeNode varFieldCls, List <TypeTreeNode> varTreeNodes)
        {
            PPtr.IsPPtr(varFieldCls.m_Type, out var tempClsName);
            if (string.IsNullOrEmpty(tempClsName))
            {
                tempClsName = varFieldCls.m_Type;
            }

            var tempTreeClses = new List <TypeTree2Class>();

            var tempAlignFields = new HashSet <string>();
            var tempFieldNames  = new Dictionary <string, string>();

            for (int iT = varFieldCls.m_Index + 1; iT < varTreeNodes.Count; ++iT)
            {
                var tempNode = varTreeNodes[iT];
                if (tempNode.m_Level <= varFieldCls.m_Level)
                {
                    break;
                }
                if (tempNode.m_Level != varFieldCls.m_Level + 1)
                {
                    continue;
                }

                var tempFieldName = CorrectFieldName(tempNode.m_Name);

                if ((tempNode.m_MetaFlag & (int)TypeTreeNode.TransferMetaFlags.kAlignBytesFlag) != 0)
                {
                    tempAlignFields.Add(tempFieldName);
                }

                tempFieldNames.Add(tempFieldName, tempNode.GetNodeCsharpTypeDes(varTreeNodes, out var tempFieldTypes));
                foreach (var item in tempFieldTypes)
                {
                    if (!item.IsVauleType())
                    {
                        tempTreeClses.AddRange(TypeTree2Class.Convert(item, varTreeNodes));
                    }
                }
            }

            tempTreeClses.Add(new TypeTree2Class(tempClsName, tempFieldNames, tempAlignFields));
            return(tempTreeClses);
        }
コード例 #3
0
        /// <summary>
        /// 解析Field的变量Type结构
        /// </summary>
        /// <param name="varNode"></param>
        /// <param name="varTreeNodes"></param>
        /// <param name="varFieldTypeNodes"></param>
        /// <returns></returns>
        public static string GetNodeCsharpTypeDes(this TypeTreeNode varNode, List <TypeTreeNode> varTreeNodes, out List <TypeTreeNode> varFieldTypeNodes)
        {
            if (_CppType2CSharp.TryGetValue(varNode.m_Type, out var tempTypeVal))
            {
                varFieldTypeNodes = new List <TypeTreeNode>()
                {
                    varNode
                };
                return(tempTypeVal);
            }

            if (_CppTypeConvert.TryGetValue(varNode.m_Type, out var tempConverter))
            {
                return(tempConverter(varNode, varTreeNodes, out varFieldTypeNodes));
            }
            //Debug.LogWarningFormat("GetNodeCsharpTypeDes not support [{0}]", varNode.m_Type);
            varFieldTypeNodes = new List <TypeTreeNode>()
            {
                varNode
            };
            return(varNode.m_Type);
        }
コード例 #4
0
        public TypeTree Parse(EndianBinaryReader varStream, SerializedFileFormatVersion varFormat)
        {
            var tempNodeCount        = varStream.ReadInt32();
            var tempStringBufferSize = varStream.ReadInt32();

            Nodes = new List <TypeTreeNode>(tempNodeCount);
            for (int i = 0; i < tempNodeCount; ++i)
            {
                var tempNode = new TypeTreeNode().Parse(varStream, varFormat);
                Nodes.Add(tempNode);
            }

            m_StringBuffer = varStream.ReadBytes(tempStringBufferSize);
            using (var stringBufferReader = new BinaryReader(new MemoryStream(m_StringBuffer)))
            {
                for (int i = 0; i < tempNodeCount; ++i)
                {
                    var m_Node = Nodes[i];
                    m_Node.m_Type = ReadCommonString(stringBufferReader, m_Node.m_TypeStrOffset);
                    m_Node.m_Name = ReadCommonString(stringBufferReader, m_Node.m_NameStrOffset);
                }
            }
            return(this);
        }
コード例 #5
0
 public static bool IsVauleType(this TypeTreeNode varNode) => _CppType2CSharp.ContainsKey(varNode.m_Type);