diff --git a/ChangeLog b/ChangeLog index 1315cb27a..3440369fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2007-07-03 Mike Kestner +2007-07-12 Mike Kestner + + * generator/StructBase.cs : use typeof to pass type to PtrToStruct + to avoid an instantiation and method call. Duh. + +2007-07-10 Mike Kestner * generator/ImportSignature.cs : use Parameter.NativeSignature prop and refactor out some GError handling. diff --git a/generator/StructBase.cs b/generator/StructBase.cs index 57fc410a9..56b772d1f 100644 --- a/generator/StructBase.cs +++ b/generator/StructBase.cs @@ -190,12 +190,9 @@ namespace GtkSharp.Generation { sw.WriteLine(); if (!DisableNew) { sw.WriteLine ("\t\tpublic static " + QualifiedName + " New(IntPtr raw) {"); - sw.WriteLine ("\t\t\tif (raw == IntPtr.Zero) {"); + sw.WriteLine ("\t\t\tif (raw == IntPtr.Zero)"); sw.WriteLine ("\t\t\t\treturn {0}.Zero;", QualifiedName); - sw.WriteLine ("\t\t\t}"); - sw.WriteLine ("\t\t\t{0} self = new {0}();", QualifiedName); - sw.WriteLine ("\t\t\tself = ({0}) Marshal.PtrToStructure (raw, self.GetType ());", QualifiedName); - sw.WriteLine ("\t\t\treturn self;"); + sw.WriteLine ("\t\t\treturn ({0}) Marshal.PtrToStructure (raw, typeof ({0}));", QualifiedName); sw.WriteLine ("\t\t}"); sw.WriteLine (); }