Browse Source

Restored the STD allocator in the OS X parser bindings.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/719/head
Dimitar Dobrev 9 years ago
parent
commit
c010a0d9a9
  1. 81
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std.cs
  2. 81
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs
  3. 2
      src/Generator/Passes/StripUnusedSystemTypesPass.cs
  4. 2
      src/Generator/Types/Std/Stdlib.cs

81
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std.cs

@ -139,6 +139,87 @@ namespace Std @@ -139,6 +139,87 @@ namespace Std
{
namespace __1
{
public unsafe partial class Allocator : IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 0)]
public unsafe partial struct __Internal
{
[SuppressUnmanagedCodeSecurity]
[DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZNSt3__19allocatorIcEC2Ev")]
internal static extern void ctor_0(global::System.IntPtr instance);
}
public global::System.IntPtr __Instance { get; protected set; }
protected int __PointerAdjustment;
public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Allocator> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Allocator>();
protected void*[] __OriginalVTables;
protected bool __ownsNativeInstance;
public static Allocator __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
{
return new Allocator(native.ToPointer(), skipVTables);
}
public static Allocator __CreateInstance(Allocator.__Internal native, bool skipVTables = false)
{
return new Allocator(native, skipVTables);
}
private static void* __CopyValue(Allocator.__Internal native)
{
var ret = Marshal.AllocHGlobal(0);
*(Allocator.__Internal*) ret = native;
return ret.ToPointer();
}
private Allocator(Allocator.__Internal native, bool skipVTables = false)
: this(__CopyValue(native), skipVTables)
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
protected Allocator(void* native, bool skipVTables = false)
{
if (native == null)
return;
__Instance = new global::System.IntPtr(native);
}
public Allocator()
{
__Instance = Marshal.AllocHGlobal(0);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
__Internal.ctor_0((__Instance + __PointerAdjustment));
}
public void Dispose()
{
Dispose(disposing: true);
}
public virtual void Dispose(bool disposing)
{
global::Std.__1.Allocator __dummy;
NativeToManagedMap.TryRemove(__Instance, out __dummy);
if (__ownsNativeInstance)
Marshal.FreeHGlobal(__Instance);
}
}
public unsafe partial class Rebind
{
[StructLayout(LayoutKind.Explicit, Size = 0)]
public partial struct __Internal
{
}
}
namespace CompressedPair
{
[StructLayout(LayoutKind.Explicit, Size = 12)]

81
src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs

@ -139,6 +139,87 @@ namespace Std @@ -139,6 +139,87 @@ namespace Std
{
namespace __1
{
public unsafe partial class Allocator : IDisposable
{
[StructLayout(LayoutKind.Explicit, Size = 0)]
public unsafe partial struct __Internal
{
[SuppressUnmanagedCodeSecurity]
[DllImport("Std-templates", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZNSt3__19allocatorIcEC2Ev")]
internal static extern void ctor_0(global::System.IntPtr instance);
}
public global::System.IntPtr __Instance { get; protected set; }
protected int __PointerAdjustment;
public static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Allocator> NativeToManagedMap = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, Allocator>();
protected void*[] __OriginalVTables;
protected bool __ownsNativeInstance;
public static Allocator __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
{
return new Allocator(native.ToPointer(), skipVTables);
}
public static Allocator __CreateInstance(Allocator.__Internal native, bool skipVTables = false)
{
return new Allocator(native, skipVTables);
}
private static void* __CopyValue(Allocator.__Internal native)
{
var ret = Marshal.AllocHGlobal(0);
*(Allocator.__Internal*) ret = native;
return ret.ToPointer();
}
private Allocator(Allocator.__Internal native, bool skipVTables = false)
: this(__CopyValue(native), skipVTables)
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
protected Allocator(void* native, bool skipVTables = false)
{
if (native == null)
return;
__Instance = new global::System.IntPtr(native);
}
public Allocator()
{
__Instance = Marshal.AllocHGlobal(0);
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
__Internal.ctor_0((__Instance + __PointerAdjustment));
}
public void Dispose()
{
Dispose(disposing: true);
}
public virtual void Dispose(bool disposing)
{
global::Std.__1.Allocator __dummy;
NativeToManagedMap.TryRemove(__Instance, out __dummy);
if (__ownsNativeInstance)
Marshal.FreeHGlobal(__Instance);
}
}
public unsafe partial class Rebind
{
[StructLayout(LayoutKind.Explicit, Size = 0)]
public partial struct __Internal
{
}
}
namespace CompressedPair
{
[StructLayout(LayoutKind.Explicit, Size = 24)]

2
src/Generator/Passes/StripUnusedSystemTypesPass.cs

@ -27,7 +27,7 @@ namespace CppSharp.Passes @@ -27,7 +27,7 @@ namespace CppSharp.Passes
{
// we need this one for marshalling std::string
foreach (var allocator in context.FindClass("allocator", false, true).Where(
a => a.Namespace.Name == "std"))
a => a.TranslationUnit.IsSystemHeader))
usedStdTypes.Add(allocator);
var result = base.VisitASTContext(context);

2
src/Generator/Types/Std/Stdlib.cs

@ -67,7 +67,7 @@ namespace CppSharp.Types.Std @@ -67,7 +67,7 @@ namespace CppSharp.Types.Std
ctx.Return.Write("*({0}*) ", basicString.Visit(typePrinter));
typePrinter.PopContext();
var allocator = ctx.Context.ASTContext.FindClass("allocator", false, true).First(
a => a.IsDependent);
a => a.IsDependent && a.TranslationUnit.IsSystemHeader);
if (type.IsPointer() || (type.IsReference() && ctx.Declaration is Field))
{
ctx.Return.Write("new {0}({1}, new {2}()).{3}",

Loading…
Cancel
Save