Example #1
0
 public static string ComputeElementMd5(ClangSharp.Cursor Cursor)
 {
     using (var md5 = MD5.Create())
     {
         if (Cursor != null)
         {
             string Name       = Cursor.Spelling;
             string typeHash   = "";
             string file       = "";
             string Argument   = "";
             string ResultType = "";
             file     = Cursor.Location.File.ToString();
             typeHash = ComputeMd5(Cursor.Type);
             for (uint i = 0; i < Cursor.NumArguments; i++)
             {
                 Argument += ComputeMd5(Cursor.GetArgument(i).Type);
             }
             ResultType = ComputeMd5(Cursor.ResultType);
             byte[] CursorData = Encoding.ASCII.GetBytes(Name + typeHash + Argument + ResultType);
             var    hash       = md5.ComputeHash(CursorData);
             return(BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant());
         }
         else
         {
             return("");
         }
     }
 }
Example #2
0
        public static string GetFullyQualifiedName(ClangSharp.Cursor cursor)
        {
            string name;

            if (cursor.Type.TypeKind != ClangSharp.Type.Kind.Invalid)
            {
                return(GetFullyQualifiedName(cursor.Type));
            }
            else
            {
                name = cursor.Spelling;
                while (cursor.SemanticParent.Kind == ClangSharp.CursorKind.ClassDecl ||
                       cursor.SemanticParent.Kind == ClangSharp.CursorKind.StructDecl ||
                       cursor.SemanticParent.Kind == ClangSharp.CursorKind.ClassTemplate ||
                       cursor.SemanticParent.Kind == ClangSharp.CursorKind.Namespace)
                {
                    name   = cursor.SemanticParent.Spelling + "::" + name;
                    cursor = cursor.SemanticParent;
                }
            }
            return(name);
        }
Example #3
0
 public static string ComputeMd5(ClangSharp.Cursor Cursor)
 {
     using (var md5 = MD5.Create())
     {
         if (Cursor != null)
         {
             string Name = Cursor.Spelling;
             if (string.IsNullOrEmpty(Name) == true)
             {
                 Name = "";
             }
             string typeHash   = "";
             string file       = "";
             string Argument   = "";
             string ResultType = "";
             file = Cursor.Location.File.ToString().Replace('/', '\\');
             if (System.IO.File.Exists(file))
             {
                 file = System.IO.Path.GetFileName(file);
             }
             typeHash = ComputeMd5(Cursor.Type);
             for (uint i = 0; i < Cursor.NumArguments; i++)
             {
                 Argument += ComputeMd5(Cursor.GetArgument(i));
             }
             ResultType = ComputeMd5(Cursor.ResultType);
             byte[] CursorData = Encoding.ASCII.GetBytes(Name + typeHash + file + Argument + ResultType);
             var    hash       = md5.ComputeHash(CursorData);
             return(BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant());
         }
         else
         {
             return("");
         }
     }
 }