mirror of https://github.com/mono/CppSharp.git
c-sharpdotnetmonobindingsbridgecclangcpluspluscppsharpglueinteropparserparsingpinvokeswigsyntax-treevisitorsxamarinxamarin-bindings
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
using System; |
|
using System.Runtime.InteropServices; |
|
|
|
namespace Mono.VisualC.Interop { |
|
public class CppObjectMarshaler : ICustomMarshaler { |
|
private static CppObjectMarshaler marshaler = null; |
|
private CppObjectMarshaler () { |
|
} |
|
|
|
public IntPtr MarshalManagedToNative (object managedObj) |
|
{ |
|
if (managedObj == null) |
|
return IntPtr.Zero; |
|
|
|
ICppObject cppObject = managedObj as ICppObject; |
|
if (cppObject == null) |
|
throw new ArgumentException ("Object to marshal must implement ICppObject"); |
|
|
|
return cppObject.Native; |
|
} |
|
|
|
public object MarshalNativeToManaged (IntPtr pNativeData) |
|
{ |
|
throw new NotImplementedException (); |
|
} |
|
|
|
public void CleanUpManagedData (object ManagedObj) |
|
{ |
|
} |
|
|
|
public void CleanUpNativeData (IntPtr pNativeData) |
|
{ |
|
} |
|
|
|
public int GetNativeDataSize () |
|
{ |
|
return -1; |
|
} |
|
|
|
public static ICustomMarshaler GetInstance(string cookie) |
|
{ |
|
if(marshaler == null) |
|
marshaler = new CppObjectMarshaler (); |
|
return marshaler; |
|
} |
|
|
|
} |
|
} |
|
|
|
|