Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/src/runtime/interopNative.cs

# General binaries and Build results
*.dll
*.exe
Expand Down
5 changes: 5 additions & 0 deletions pythonnet.15.sln
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "conda.recipe", "conda.recip
conda.recipe\README.md = conda.recipe\README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{BC426F42-8494-4AA5-82C9-5109ACD97BD1}"
ProjectSection(SolutionItems) = preProject
tools\geninterop\geninterop.py = tools\geninterop\geninterop.py
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/Python.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
<Compile Include="Codecs\DecoderGroup.cs" />
<Compile Include="Codecs\RawProxyEncoder.cs" />
<Compile Include="Codecs\TupleCodecs.cs" />
<Compile Include="native\ABI.cs" />
<Compile Include="native\GeneratedTypeOffsets.cs" />
<Compile Include="native\ITypeOffsets.cs" />
<Compile Include="native\TypeOffset.cs" />
<Compile Include="converterextensions.cs" />
<Compile Include="finalizer.cs" />
<Compile Include="intern.cs" />
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/debughelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ internal static void DumpType(IntPtr type)
//DebugUtil.Print(" mro: ", op);


FieldInfo[] slots = typeof(TypeOffset).GetFields();
var slots = TypeOffset.GetOffsets();
int size = IntPtr.Size;

for (var i = 0; i < slots.Length; i++)
foreach (var entry in slots)
{
int offset = i * size;
name = slots[i].Name;
int offset = entry.Value;
name = entry.Key;
op = Marshal.ReadIntPtr(type, offset);
Console.WriteLine(" {0}: {1}", name, op);
}
Expand Down
23 changes: 2 additions & 21 deletions src/runtime/interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,12 @@ public ModulePropertyAttribute()

internal static partial class TypeOffset
{
static TypeOffset()
{
Type type = typeof(TypeOffset);
FieldInfo[] fields = type.GetFields();
int size = IntPtr.Size;
for (int i = 0; i < fields.Length; i++)
{
int offset = i * size;
FieldInfo fi = fields[i];
fi.SetValue(null, offset);
}
}

public static int magic() => ManagedDataOffsets.Magic;
}

internal static class ManagedDataOffsets
{
public static int Magic { get; private set; }
public static int Magic { get; internal set; }
public static readonly Dictionary<string, int> NameMapping = new Dictionary<string, int>();

static class DataOffsets
Expand All @@ -108,13 +95,7 @@ static DataOffsets()

static ManagedDataOffsets()
{
Type type = typeof(TypeOffset);
foreach (FieldInfo fi in type.GetFields())
{
NameMapping[fi.Name] = (int)fi.GetValue(null);
}
// XXX: Use the members after PyHeapTypeObject as magic slot
Magic = TypeOffset.members;
NameMapping = TypeOffset.GetOffsets();

FieldInfo[] fields = typeof(DataOffsets).GetFields(BindingFlags.Static | BindingFlags.Public);
size = fields.Length * IntPtr.Size;
Expand Down
Loading