[Zope-CVS] CVS: PythonNet/src/runtime - ImportHook.cs:1.8 MethodWrapper.cs:1.6

Brian Lloyd cvs-admin at zope.org
Mon Nov 17 21:53:32 EST 2003


Update of /cvs-repository/PythonNet/src/runtime
In directory cvs.zope.org:/tmp/cvs-serv14768/src/runtime

Modified Files:
	ImportHook.cs MethodWrapper.cs 
Log Message:
fix dumb FreeHGlobal issue


=== PythonNet/src/runtime/ImportHook.cs 1.7 => 1.8 ===
--- PythonNet/src/runtime/ImportHook.cs:1.7	Thu Nov  6 23:05:05 2003
+++ PythonNet/src/runtime/ImportHook.cs	Mon Nov 17 21:53:32 2003
@@ -22,7 +22,7 @@
 
 	static IntPtr py_import;
 	static ModuleObject root;
-	static StaticMethodWrapper hook;
+	static MethodWrapper hook;
 
 	//===================================================================
 	// Initialization performed on startup of the Python runtime.
@@ -40,7 +40,7 @@
 	    py_import = Runtime.PyObject_GetAttrString(mod, "__import__");
 
 
-  	    hook = new StaticMethodWrapper(typeof(ImportHook),"__import__");
+  	    hook = new MethodWrapper(typeof(ImportHook), "__import__");
 
   	    Runtime.PyObject_SetAttrString(mod, "__import__", hook.pyHandle);
 


=== PythonNet/src/runtime/MethodWrapper.cs 1.5 => 1.6 ===
--- PythonNet/src/runtime/MethodWrapper.cs:1.5	Wed Oct 22 22:53:10 2003
+++ PythonNet/src/runtime/MethodWrapper.cs	Mon Nov 17 21:53:32 2003
@@ -16,13 +16,13 @@
 namespace Python.Runtime {
 
     /// <summary>
-    /// A StaticMethodWrapper wraps a static method of a managed type,
+    /// A MethodWrapper wraps a static method of a managed type,
     /// making it callable by Python as a PyCFunction object. This is
     /// currently used mainly to implement special cases like the CLR
     /// import hook.
     /// </summary>
 
-    internal class StaticMethodWrapper {
+    internal class MethodWrapper {
 
 	public Delegate mDelegate;
 	public IntPtr methodDef;
@@ -30,11 +30,11 @@
 
 	private static ArrayList keepAlive;
 
-	static StaticMethodWrapper() {
+	static MethodWrapper() {
 	    keepAlive = new ArrayList();
 	}
 
-	public StaticMethodWrapper(Type obType, string name) {
+	public MethodWrapper(Type obType, string name) {
 
 	    // Allocate and initialize a PyMethodDef structure to represent 
 	    // the managed method, then create a PyCFunction. 
@@ -46,7 +46,7 @@
 				 obType.GetMethod(name)
 				 );
 	    Thunk cb = new Thunk(mDelegate);
-	    IntPtr pThunk = Runtime.PyMem_Malloc(1 * IntPtr.Size);
+	    IntPtr pThunk = Marshal.AllocHGlobal(1 * IntPtr.Size);
 	    Marshal.StructureToPtr(cb, pThunk, false);
 	    IntPtr fp = Marshal.ReadIntPtr(pThunk, 0);
 	    Marshal.FreeHGlobal(pThunk);




More information about the Zope-CVS mailing list