- Notifications
You must be signed in to change notification settings - Fork768
Add soft shutdown#958
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
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
d1928dcf000e08f882400b7715ee41ac665c6dae9e4e19a4f657452e91f64b9b07b8447db724e2a88be42940973d108913cc9e7e51cb8e8c653a263b3e889b04d6dfb5150e6165e209ecad95da0dee5da00a0b3277da6df2039e69fe5050d593fb001ce83fcfba616abdc0f7249d98e8433d0f69b4864b1b466df49130c476ba5101ff21ac0b01378631bb43bf3d9f8da97502e8b316080d4fa09874cd18da561b9499c64431d6442b843945ade0698dabed7f4bb77a670bd743cb56f13c9a83c992c469924b217df84e298b5162197c8c2a39f47c8aa63f0b5b2f3d435cbe55f23cae6183f9d89d57a8208fad26bcfdcc766ab7191428af38e3c028b387e9ef85999ecb65af3498fc8ccc2219e8c8d66e4f0016539e20e3da7c15002b1adaa8840b2dec7a74e877b336d738bfff5edc35ac75ba65cb22e73865d41a75f519b6d140d9d55629b62a614f0420e4ab9f1c32bcb3a0077ea838ea0b606a656e09f82817ec9a6c802a43a0fdf9693a8c72db52bc01bfbf2c3883c4ce7e0d56d82034dc4ba50a71ecdce8b35f441ce8ee904c4bcb0f575bd3d1799aad2408b9fd2b6622b7bcac0af3504ba1df6e639ba1f7e5ab528075f48eb8cb8a308f0f21ae0bfe07aefe65387b05b20367419d137925a40641272b898c133e3d9b21a5c8dee53598cb7783e8dd56db3181e38a363b409a89f5c24b00d6c645fa89b4880a764412c02066a3cfc898da1fad7d44e86aa75c52343f89cc6b8e4d5fcfa4fa47957ff956e4c7b134c97e61a50b9d2c1178cbc83a17f3632034578d00e4cFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5,7 +5,6 @@ | ||
| using System.Runtime.InteropServices; | ||
| using System.Reflection; | ||
| using System.Text; | ||
| using System.Linq; | ||
| namespace Python.Runtime | ||
| @@ -70,15 +69,20 @@ public ModulePropertyAttribute() | ||
| } | ||
| } | ||
| internal static partial classTypeOffset | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Why can't this be in Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It could, but this change is getting big. I'd prefer doing it after this branch has been merged | ||
| { | ||
| public static int magic() => ManagedDataOffsets.Magic; | ||
| } | ||
| internal static class ManagedDataOffsets | ||
| { | ||
| public static int Magic { get; private set; } | ||
| public static readonly Dictionary<string, int> NameMapping = new Dictionary<string, int>(); | ||
| public static readonly int ob_data; | ||
| public static readonly int ob_dict; | ||
| static ManagedDataOffsets() | ||
| { | ||
| Type type = typeof(TypeOffset); | ||
| FieldInfo[] fields = type.GetFields(); | ||
| @@ -88,18 +92,30 @@ static TypeOffset() | ||
| int offset = i * size; | ||
| FieldInfo fi = fields[i]; | ||
| fi.SetValue(null, offset); | ||
| NameMapping[fi.Name] = offset; | ||
| } | ||
| // XXX: Use the members after PyHeapTypeObject as magic slot | ||
| Magic =TypeOffset.members; | ||
| } | ||
| public static int GetSlotOffset(string name) | ||
| { | ||
| return NameMapping[name]; | ||
| } | ||
| private static int BaseOffset(IntPtr type) | ||
| { | ||
| Debug.Assert(type != IntPtr.Zero); | ||
| int typeSize = Marshal.ReadInt32(type, TypeOffset.tp_basicsize); | ||
| Debug.Assert(typeSize > 0 && typeSize <= ExceptionOffset.Size()); | ||
| return typeSize; | ||
| } | ||
| public static int DataOffset(IntPtr type) | ||
| { | ||
| return BaseOffset(type) + ob_data; | ||
| } | ||
| public static int DictOffset(IntPtr type) | ||
| { | ||
| return BaseOffset(type) + ob_dict; | ||