private PyCFunction_NewEx ( IntPtr ml, IntPtr self, IntPtr mod ) : IntPtr | ||
ml | IntPtr | |
self | IntPtr | |
mod | IntPtr | |
return | IntPtr |
public MethodWrapper(Type type, string name) { // Turn the managed method into a function pointer IntPtr fp = Interop.GetThunk(type.GetMethod(name)); // XXX - here we create a Python string object, then take the // char * of the internal string to pass to our methoddef // structure. Its a hack, and the name is leaked! #if (PYTHON32 || PYTHON33 || PYTHON34) IntPtr ps = Runtime.PyBytes_FromString(name); IntPtr sp = Runtime.PyBytes_AS_STRING(ps); #else IntPtr ps = Runtime.PyString_FromString(name); IntPtr sp = Runtime.PyString_AS_STRING(ps); #endif // Allocate and initialize a PyMethodDef structure to represent // the managed method, then create a PyCFunction. mdef = Runtime.PyMem_Malloc(4 * IntPtr.Size); Marshal.WriteIntPtr(mdef, sp); Marshal.WriteIntPtr(mdef, (1 * IntPtr.Size), fp); Marshal.WriteIntPtr(mdef, (2 * IntPtr.Size), (IntPtr)0x0003); // METH_VARARGS | METH_KEYWORDS Marshal.WriteIntPtr(mdef, (3 * IntPtr.Size), IntPtr.Zero); ptr = Runtime.PyCFunction_NewEx(mdef, IntPtr.Zero, IntPtr.Zero); }
public MethodWrapper(Type type, string name, string funcType = null) { // Turn the managed method into a function pointer IntPtr fp = Interop.GetThunk(type.GetMethod(name), funcType); // Allocate and initialize a PyMethodDef structure to represent // the managed method, then create a PyCFunction. mdef = Runtime.PyMem_Malloc(4 * IntPtr.Size); TypeManager.WriteMethodDef(mdef, name, fp, 0x0003); ptr = Runtime.PyCFunction_NewEx(mdef, IntPtr.Zero, IntPtr.Zero); }