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
7 changes: 7 additions & 0 deletions src/runtime/Python.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@
<ItemGroup Condition=" '$(PythonInteropFile)' != '' ">
<Compile Include="$(PythonInteropFile)" />
</ItemGroup>
<ItemGroup Condition=" '$(PythonInteropFile)' == '' ">
<Compile Include="interop26.cs" />
<Compile Include="interop27.cs" />
<Compile Include="interop32.cs" />
<Compile Include="interop34.cs" />
<Compile Include="interop35.cs" />
</ItemGroup>
<ItemGroup>
<None Include="buildclrmodule.bat" />
<None Include="clrmodule.il" />
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/interop26.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

#if (PYTHON26)
using System;
using System.Collections;
using System.Collections.Specialized;
Expand Down Expand Up @@ -150,3 +150,4 @@ public static int magic() {
public static int members = 0;
}
}
#endif
3 changes: 2 additions & 1 deletion src/runtime/interop27.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

#if (PYTHON27)
using System;
using System.Collections;
using System.Collections.Specialized;
Expand Down Expand Up @@ -150,3 +150,4 @@ public static int magic() {
public static int members = 0;
}
}
#endif
3 changes: 2 additions & 1 deletion src/runtime/interop32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

#if (PYTHON32)
using System;
using System.Collections;
using System.Collections.Specialized;
Expand Down Expand Up @@ -141,3 +141,4 @@ public static int magic() {
public static int members = 0;
}
}
#endif
3 changes: 2 additions & 1 deletion src/runtime/interop34.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

#if (PYTHON34)
using System;
using System.Collections;
using System.Collections.Specialized;
Expand Down Expand Up @@ -144,3 +144,4 @@ public static int magic() {
public static int members = 0;
}
}
#endif
3 changes: 2 additions & 1 deletion src/runtime/interop35.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

#if (PYTHON35)
using System;
using System.Collections;
using System.Collections.Specialized;
Expand Down Expand Up @@ -149,3 +149,4 @@ public static int magic() {
public static int members = 0;
}
}
#endif
17 changes: 15 additions & 2 deletions tools/geninterop/geninterop.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ def preprocess_python_headers():
def gen_interop_code(members):
"""Generate the TypeOffset C# class"""

defines = [
"PYTHON%d%s" % (sys.version_info[:2])
]

if hasattr(sys, "abiflags"):
if "d" in sys.abiflags:
defines.append("PYTHON_WITH_PYDEBUG")
if "m" in sys.abiflags:
defines.append("PYTHON_WITH_PYMALLOC")
if "u" in sys.abiflags:
defines.append("PYTHON_WITH_WIDE_UNICODE")

class_definition = """
// Auto-generated by %s.
// DOT NOT MODIFIY BY HAND.
Expand All @@ -209,7 +221,7 @@ def gen_interop_code(members):
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================

#if (%s)
using System;
using System.Collections;
using System.Collections.Specialized;
Expand All @@ -236,7 +248,7 @@ def gen_interop_code(members):
}

// Auto-generated from PyHeapTypeObject in Python.h
""" % os.path.basename(__file__)
""" % (os.path.basename(__file__), " && ".join(defines))

# All the members are sizeof(void*) so we don't need to do any
# extra work to determine the size based on the type.
Expand All @@ -249,6 +261,7 @@ def gen_interop_code(members):
public static int members = 0;
}
}
#endif
"""
return class_definition

Expand Down