Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9682dc6

Browse files
committed
allocate space for GCHandle in instances of CLR Metatype (which are types themselves)
1 parent08ea6f3 commit9682dc6

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

‎src/runtime/typemanager.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ internal static IntPtr GetTypeHandle(ManagedType obj, Type type)
143143
/// </summary>
144144
internalstaticIntPtrCreateType(Typeimpl)
145145
{
146-
IntPtrtype=AllocateTypeObject(impl.Name);
146+
IntPtrtype=AllocateTypeObject(impl.Name,metatype:Runtime.PyTypeType);
147147
intob_size=ObjectOffset.Size(type);
148148

149149
// Set tp_basicsize to the size of our managed instance objects.
@@ -212,7 +212,7 @@ internal static IntPtr CreateType(ManagedType impl, Type clrType)
212212
base_=bc.pyHandle;
213213
}
214214

215-
IntPtrtype=AllocateTypeObject(name);
215+
IntPtrtype=AllocateTypeObject(name,Runtime.PyCLRMetaType);
216216

217217
Marshal.WriteIntPtr(type,TypeOffset.ob_type,Runtime.PyCLRMetaType);
218218
Runtime.XIncref(Runtime.PyCLRMetaType);
@@ -427,12 +427,15 @@ internal static IntPtr CreateMetaType(Type impl, out SlotsHolder slotsHolder)
427427
// the standard type slots, and has to subclass PyType_Type for
428428
// certain functions in the C runtime to work correctly with it.
429429

430-
IntPtrtype=AllocateTypeObject("CLR Metatype");
431-
IntPtrpy_type=Runtime.PyTypeType;
430+
IntPtrtype=AllocateTypeObject("CLR Metatype",metatype:Runtime.PyTypeType);
432431

432+
IntPtrpy_type=Runtime.PyTypeType;
433433
Marshal.WriteIntPtr(type,TypeOffset.tp_base,py_type);
434434
Runtime.XIncref(py_type);
435435

436+
intsize=TypeOffset.magic()+IntPtr.Size;
437+
Marshal.WriteIntPtr(type,TypeOffset.tp_basicsize,newIntPtr(size));
438+
436439
constintflags=TypeFlags.Default
437440
|TypeFlags.Managed
438441
|TypeFlags.HeapType
@@ -522,7 +525,7 @@ internal static IntPtr BasicSubType(string name, IntPtr base_, Type impl)
522525
// Utility to create a subtype of a std Python type, but with
523526
// a managed type able to override implementation
524527

525-
IntPtrtype=AllocateTypeObject(name);
528+
IntPtrtype=AllocateTypeObject(name,metatype:Runtime.PyTypeType);
526529
//Marshal.WriteIntPtr(type, TypeOffset.tp_basicsize, (IntPtr)obSize);
527530
//Marshal.WriteIntPtr(type, TypeOffset.tp_itemsize, IntPtr.Zero);
528531

@@ -564,9 +567,9 @@ internal static IntPtr BasicSubType(string name, IntPtr base_, Type impl)
564567
/// <summary>
565568
/// Utility method to allocate a type object &amp; do basic initialization.
566569
/// </summary>
567-
internalstaticIntPtrAllocateTypeObject(stringname)
570+
internalstaticIntPtrAllocateTypeObject(stringname,IntPtrmetatype)
568571
{
569-
IntPtrtype=Runtime.PyType_GenericAlloc(Runtime.PyTypeType,0);
572+
IntPtrtype=Runtime.PyType_GenericAlloc(metatype,0);
570573
// Clr type would not use __slots__,
571574
// and the PyMemberDef after PyHeapTypeObject will have other uses(e.g. type handle),
572575
// thus set the ob_size to 0 for avoiding slots iterations.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp