Browse Source

Removed a hack made redundant by the improved support for inlines.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/343/head
Dimitar Dobrev 11 years ago
parent
commit
f67af3f59b
  1. 26
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  2. 7
      src/Generator/Types/TypeMap.cs

26
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -1956,27 +1956,11 @@ namespace CppSharp.Generators.CSharp
if (copyCtorMethod == null) if (copyCtorMethod == null)
throw new NotSupportedException("Expected a valid copy constructor"); throw new NotSupportedException("Expected a valid copy constructor");
// Call the copy constructor. // Allocate memory for a new native object and call the ctor.
TypeMap typeMap; WriteLine("var ret = Marshal.AllocHGlobal({0});", @class.Layout.Size);
if (!copyCtorMethod.IsGenerated && Driver.TypeDatabase.FindTypeMap(@class, out typeMap)) WriteLine("{0}.Internal.{1}(ret, new global::System.IntPtr(&native));",
{ QualifiedIdentifier(@class), GetFunctionNativeIdentifier(copyCtorMethod));
var context = new CSharpMarshalContext(Driver) WriteLine("return ret;");
{
ArgName = "native",
ReturnVarName = "ret",
ReturnType = new QualifiedType(new TagType(@class))
};
typeMap.CSharpMarshalCopyCtorToManaged(context);
WriteLine(context.SupportBefore);
}
else
{
// Allocate memory for a new native object and call the ctor.
WriteLine("var ret = Marshal.AllocHGlobal({0});", @class.Layout.Size);
WriteLine("{0}.Internal.{1}(ret, new global::System.IntPtr(&native));",
QualifiedIdentifier(@class), GetFunctionNativeIdentifier(copyCtorMethod));
WriteLine("return ret;");
}
} }
else else
{ {

7
src/Generator/Types/TypeMap.cs

@ -44,7 +44,7 @@ namespace CppSharp.Types
} }
/// <summary> /// <summary>
/// Determines if the type map performs marshalling or only replaces copy ctors. /// Determines if the type map performs marshalling or only injects custom code.
/// </summary> /// </summary>
public virtual bool DoesMarshalling { get { return true; } } public virtual bool DoesMarshalling { get { return true; } }
@ -65,11 +65,6 @@ namespace CppSharp.Types
throw new NotImplementedException(); throw new NotImplementedException();
} }
public virtual void CSharpMarshalCopyCtorToManaged(MarshalContext ctx)
{
}
/// <summary> /// <summary>
/// Used to construct a new instance of the mapped type. /// Used to construct a new instance of the mapped type.
/// </summary> /// </summary>

Loading…
Cancel
Save