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

Weakref support#1267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
amos402 wants to merge13 commits intopythonnet:masterfromamos402:weakref-support
Closed
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
d6c9716
Support weakref for CLR types
amos402Sep 24, 2020
5d57e5a
Merge branch 'master' into weakref-support
amos402Oct 22, 2020
f08813c
Apply unified mechanism for `GetManagedObjectType`
amos402Oct 22, 2020
b014ce1
Merge branch 'master' into weakref-support
filmorDec 10, 2020
e7f97a9
Merge branch 'master' into weakref-support
amos402Dec 21, 2020
b68f0a4
* Remove magic offset
amos402Dec 21, 2020
b4b1cff
Merge branch 'master' into weakref-support
amos402Dec 21, 2020
ff35e6d
Merge branch 'master' into weakref-support
amos402Feb 10, 2021
ea3d47a
Merge branch 'master' into weakref-support
amos402Feb 19, 2021
958a8eb
Fix Shutdown crash
amos402Feb 19, 2021
53ad8d9
Use PyTypeType.tp_basicsize as size of PyHeapTypeObject directly inst…
amos402Feb 19, 2021
647bc8a
Merge branch 'master' into weakref-support
amos402Feb 21, 2021
f474039
* Use C# 9.0 for Python.EmbeddingTest.csproj
amos402Feb 21, 2021
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
PrevPrevious commit
* Use C# 9.0 for Python.EmbeddingTest.csproj
* Remove dead code
  • Loading branch information
@amos402
amos402 committedFeb 21, 2021
commitf474039170b008e660235182e0e35acdf9232b4b
1 change: 1 addition & 0 deletionssrc/embed_tests/Python.EmbeddingTest.csproj
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
Expand Down
14 changes: 5 additions & 9 deletionssrc/embed_tests/TestClass.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,18 +31,14 @@ public void Dispose()
public void WeakRefForClrObject()
{
var obj = new MyClass();
using (var scope = Py.CreateScope())
{
scope.Set("clr_obj", obj);
scope.Exec(@"
using var scope = Py.CreateScope();
scope.Set("clr_obj", obj);
scope.Exec(@"
import weakref
ref = weakref.ref(clr_obj)
");
using (PyObject pyobj = scope.Get("clr_obj"))
{
ValidateAttachedGCHandle(obj, pyobj.Handle);
}
}
using PyObject pyobj = scope.Get("clr_obj");
ValidateAttachedGCHandle(obj, pyobj.Handle);
}

[Test]
Expand Down
12 changes: 1 addition & 11 deletionssrc/runtime/metatype.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,16 +155,6 @@ public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
flags |= TypeFlags.Subclass;
flags |= TypeFlags.HaveGC;
Util.WriteCLong(type, TypeOffset.tp_flags, flags);

//TypeManager.CopySlot(base_type, type, TypeOffset.tp_dealloc);

// Hmm - the standard subtype_traverse, clear look at ob_size to
// do things, so to allow gc to work correctly we need to move
// our hidden handle out of ob_size. Then, in theory we can
// comment this out and still not crash.
//TypeManager.CopySlot(base_type, type, TypeOffset.tp_traverse);
//TypeManager.CopySlot(base_type, type, TypeOffset.tp_clear);

// for now, move up hidden handle...
unsafe
{
Expand DownExpand Up@@ -361,7 +351,7 @@ public static IntPtr __subclasscheck__(IntPtr tp, IntPtr args)
[StructLayout(LayoutKind.Sequential)]
struct ClrMetaTypeEx
{
publicIntPtr ClrHandleOffset;
publicnint ClrHandleOffset;
public IntPtr ClrHandle;

public static unsafe ClrMetaTypeEx* FromType(IntPtr type)
Expand Down
2 changes: 1 addition & 1 deletionsrc/runtime/native/TypeOffset.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,7 +94,7 @@ internal static void Use(ITypeOffsets offsets)
int value = (int)sourceProperty.GetValue(offsets, null);
offsetProperty.SetValue(obj: null, value: value, index: null);
}
Size = (int)Marshal.ReadIntPtr(Runtime.PyTypeType, tp_basicsize); ;
Size = (int)Marshal.ReadIntPtr(Runtime.PyTypeType, tp_basicsize);
ValidateUnusedTypeOffsetProperties(offsetProperties);
ValidateRequiredOffsetsPresent(offsetProperties);
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp