| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,35 +31,19 @@ public MethodWrapper(Type type, string name) { | |||
| 31 | 31 | ||
| 32 | 32 | IntPtr fp = Interop.GetThunk(type.GetMethod(name)); | |
| 33 | 33 | ||
| 34 | - // XXX - here we create a Python string object, then take the | ||
| 35 | - // char * of the internal string to pass to our methoddef | ||
| 36 | - // structure. Its a hack, and the name is leaked! | ||
| 37 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35) | ||
| 38 | - IntPtr ps = Runtime.PyBytes_FromString(name); | ||
| 39 | - IntPtr sp = Runtime.PyBytes_AS_STRING(ps); | ||
| 40 | - #else | ||
| 41 | - IntPtr ps = Runtime.PyString_FromString(name); | ||
| 42 | - IntPtr sp = Runtime.PyString_AS_STRING(ps); | ||
| 43 | - #endif | ||
| 44 | - | ||
| 45 | 34 | // Allocate and initialize a PyMethodDef structure to represent | |
| 46 | 35 | // the managed method, then create a PyCFunction. | |
| 47 | 36 | ||
| 48 | 37 | mdef = Runtime.PyMem_Malloc(4 * IntPtr.Size); | |
| 49 | - Marshal.WriteIntPtr(mdef, sp); | ||
| 38 | + Marshal.WriteIntPtr(mdef, Marshal.StringToHGlobalAnsi(name)); | ||
| 50 | 39 | Marshal.WriteIntPtr(mdef, (1 * IntPtr.Size), fp); | |
| 51 | - Marshal.WriteIntPtr(mdef, (2 * IntPtr.Size), (IntPtr)0x0003); // METH_VARARGS | METH_KEYWORDS | ||
| 40 | + Marshal.WriteInt32(mdef, (2 * IntPtr.Size), 0x0003); // METH_VARARGS | METH_KEYWORDS | ||
| 52 | 41 | Marshal.WriteIntPtr(mdef, (3 * IntPtr.Size), IntPtr.Zero); | |
| 53 | 42 | ptr = Runtime.PyCFunction_NewEx(mdef, IntPtr.Zero, IntPtr.Zero); | |
| 54 | 43 | } | |
| 55 | 44 | ||
| 56 | 45 | public IntPtr Call(IntPtr args, IntPtr kw) { | |
| 57 | 46 | return Runtime.PyCFunction_Call(ptr, args, kw); | |
| 58 | 47 | } | |
| 59 | - | ||
| 60 | - | ||
| 61 | 48 | } | |
| 62 | - | ||
| 63 | - | ||
| 64 | - } | ||
| 65 | - | ||
| 49 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -306,9 +306,14 @@ internal static IntPtr CreateMetaType(Type impl) { | |||
| 306 | 306 | IntPtr mdef = Runtime.PyMem_Malloc(5 * IntPtr.Size); | |
| 307 | 307 | Marshal.WriteIntPtr(mdef, Marshal.StringToHGlobalAnsi("__instancecheck__")); | |
| 308 | 308 | Marshal.WriteIntPtr(mdef, (1 * IntPtr.Size), fp); | |
| 309 | - Marshal.WriteIntPtr(mdef, (2 * IntPtr.Size), (IntPtr)0x0001); // METH_VARARGS | ||
| 309 | + Marshal.WriteInt32(mdef, (2 * IntPtr.Size), 0x0001); | ||
| 310 | 310 | Marshal.WriteIntPtr(mdef, (3 * IntPtr.Size), IntPtr.Zero); | |
| 311 | + | ||
| 312 | + // Write empty sentinel struct | ||
| 311 | 313 | Marshal.WriteIntPtr(mdef, (4 * IntPtr.Size), IntPtr.Zero); | |
| 314 | + Marshal.WriteIntPtr(mdef, (5 * IntPtr.Size), IntPtr.Zero); | ||
| 315 | + Marshal.WriteIntPtr(mdef, (6 * IntPtr.Size), IntPtr.Zero); | ||
| 316 | + Marshal.WriteIntPtr(mdef, (7 * IntPtr.Size), IntPtr.Zero); | ||
| 312 | 317 | ||
| 313 | 318 | Marshal.WriteIntPtr(type, TypeOffset.tp_methods, mdef); | |
| 314 | 319 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments