Browse Source

Started MetaData wrapper

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@193 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 21 years ago
parent
commit
d36c857e14
  1. 11
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  2. 26
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/MetaData/FieldProps.cs
  3. 144
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/MetaData/MetaData.cs
  4. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/MetaData/TypeDefProps.cs
  5. 12
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/MetaData/TypeRefProps.cs

11
src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.41115</ProductVersion>
<ProductVersion>8.0.50215</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}</ProjectGuid>
<OutputType>Library</OutputType>
@ -52,6 +52,10 @@ @@ -52,6 +52,10 @@
<Compile Include="Src\Debugger\Internal\ManagedCallbackProxy.cs" />
<Compile Include="Src\Debugger\Internal\MTA2STA.cs" />
<Compile Include="Src\Debugger\Internal\NativeMethods.cs" />
<Compile Include="Src\Debugger\MetaData\FieldProps.cs" />
<Compile Include="Src\Debugger\MetaData\MetaData.cs" />
<Compile Include="Src\Debugger\MetaData\TypeDefProps.cs" />
<Compile Include="Src\Debugger\MetaData\TypeRefProps.cs" />
<Compile Include="Src\Debugger\NDebugger.cs" />
<Compile Include="Src\Interop enums\ClassFieldAttribute.cs" />
<Compile Include="Src\Interop enums\CorCallingConvention.cs" />
@ -95,9 +99,6 @@ @@ -95,9 +99,6 @@
</ItemGroup>
<ItemGroup>
<Content Include="README.TXT" />
<Folder Include="Src\RemotingSinks" />
<Folder Include="Src\RemotingSinks\InvokeOnSTASink" />
<Folder Include="Src\RemotingSinks\PrivateEventHandlersSink" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>
</Project>

26
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/MetaData/FieldProps.cs

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DebuggerLibrary
{
struct FieldProps
{
public uint Token;
public string Name;
public uint ClassToken;
public uint Flags;
public bool IsStatic {
get {
return (Flags & (uint)ClassFieldAttribute.fdStatic) != 0;
}
}
public bool IsLiteral {
get {
return (Flags & (uint)ClassFieldAttribute.fdLiteral) != 0;
}
}
}
}

144
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/MetaData/MetaData.cs

@ -0,0 +1,144 @@ @@ -0,0 +1,144 @@
using System;
using System.Collections.Generic;
using System.Text;
using DebuggerInterop.MetaData;
using System.Runtime.InteropServices;
namespace DebuggerLibrary
{
class MetaData
{
IMetaDataImport metaData;
public MetaData(IMetaDataImport metaData)
{
this.metaData = metaData;
}
public TypeDefProps GetTypeDefProps(uint typeToken)
{
TypeDefProps typeDefProps;
typeDefProps.Token = typeToken;
uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero;
// Get length of string
metaData.GetTypeDefProps(typeDefProps.Token,
pString,
pStringLenght,
out pStringLenght,
out typeDefProps.Flags,
out typeDefProps.SuperClassToken);
// Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
// Get properties
metaData.GetTypeDefProps(typeDefProps.Token,
pString,
pStringLenght,
out pStringLenght,
out typeDefProps.Flags,
out typeDefProps.SuperClassToken);
typeDefProps.Name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString);
return typeDefProps;
}
public TypeRefProps GetTypeRefProps(uint typeToken)
{
TypeRefProps typeRefProps;
typeRefProps.Token = typeToken;
uint unused;
uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero;
metaData.GetTypeRefProps(typeRefProps.Token,
out unused,
pString,
pStringLenght,
out pStringLenght); // real string lenght
// Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
metaData.GetTypeRefProps(typeRefProps.Token,
out unused,
pString,
pStringLenght,
out pStringLenght); // real string lenght
typeRefProps.Name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString);
return typeRefProps;
}
public FieldProps GetFieldProps(uint fieldToken)
{
FieldProps fieldProps;
fieldProps.Token = fieldToken;
uint unused;
IntPtr unusedPtr = IntPtr.Zero;
uint pStringLenght = 0; // Terminating character included in pStringLenght
IntPtr pString = IntPtr.Zero;
metaData.GetFieldProps(fieldProps.Token,
out fieldProps.ClassToken,
pString,
pStringLenght,
out pStringLenght, // real string lenght
out fieldProps.Flags,
IntPtr.Zero,
out unused,
out unused,
out unusedPtr,
out unused);
// Allocate string buffer
pString = Marshal.AllocHGlobal((int)pStringLenght * 2);
metaData.GetFieldProps(fieldProps.Token,
out fieldProps.ClassToken,
pString,
pStringLenght,
out pStringLenght, // real string lenght
out fieldProps.Flags,
IntPtr.Zero,
out unused,
out unused,
out unusedPtr,
out unused);
fieldProps.Name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString);
return fieldProps;
}
public IList<FieldProps> EnumFields(uint classToken)
{
List<FieldProps> fields = new List<FieldProps>();
IntPtr enumerator = IntPtr.Zero;
while (true) {
uint fieldToken;
uint fieldCount;
metaData.EnumFields(ref enumerator, classToken, out fieldToken, 1, out fieldCount);
if (fieldCount == 0) {
metaData.CloseEnum(enumerator);
break;
}
fields.Add(GetFieldProps(fieldToken));
}
return fields;
}
}
}

14
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/MetaData/TypeDefProps.cs

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DebuggerLibrary
{
struct TypeDefProps
{
public uint Token;
public string Name;
public uint Flags;
public uint SuperClassToken;
}
}

12
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/MetaData/TypeRefProps.cs

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DebuggerLibrary
{
struct TypeRefProps
{
public uint Token;
public string Name;
}
}
Loading…
Cancel
Save