Browse Source

Remove some bitrot

pull/1/head
Alex Corrado 14 years ago
parent
commit
aefe6e0e2a
  1. 64
      src/Mono.Cxxi/Abi/Impl/VirtualOnlyAbi.cs
  2. 29
      src/Mono.Cxxi/CppInstancePtr.cs
  3. 75
      src/Mono.Cxxi/CppObjectMarshaler.cs
  4. 2
      src/Mono.Cxxi/Makefile.am
  5. 2
      src/Mono.Cxxi/Mono.Cxxi.csproj

64
src/Mono.Cxxi/Abi/Impl/VirtualOnlyAbi.cs

@ -1,64 +0,0 @@ @@ -1,64 +0,0 @@
//
// Mono.Cxxi.Abi.VirtualOnlyAbi.cs: A generalized C++ ABI that only supports virtual methods
//
// Author:
// Alexander Corrado (alexander.corrado@gmail.com)
// Andreia Gaita (shana@spoiledcat.net)
//
// Copyright (C) 2010-2011 Alexander Corrado
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
namespace Mono.Cxxi.Abi {
public class VirtualOnlyAbi : CppAbi {
public VirtualOnlyAbi (MemberFilter vtableOverrideFilter)
{
this.vtable_override_filter = vtableOverrideFilter;
}
public VirtualOnlyAbi () { }
public override MethodType GetMethodType (CppTypeInfo typeInfo, MethodInfo imethod)
{
MethodType defaultType = base.GetMethodType (typeInfo, imethod);
if (defaultType == MethodType.NativeCtor || defaultType == MethodType.NativeDtor)
return MethodType.NoOp;
return defaultType;
}
protected override string GetMangledMethodName (CppTypeInfo typeInfo, MethodInfo methodInfo)
{
throw new NotSupportedException ("Name mangling is not supported by this class. All C++ interface methods must be declared virtual.");
}
public override CallingConvention? GetCallingConvention (MethodInfo methodInfo)
{
// Use platform default
return null;
}
}
}

29
src/Mono.Cxxi/CppInstancePtr.cs

@ -40,37 +40,8 @@ namespace Mono.Cxxi { @@ -40,37 +40,8 @@ namespace Mono.Cxxi {
private IntPtr ptr, native_vtptr;
private bool manage_memory;
private static Dictionary<Type,object> implCache = null;
private static Dictionary<IntPtr,int> managed_vtptr_to_gchandle_offset = null;
// TODO: the managed instance argument may only be NULL if all methods in TWrapper
// that correspond to the virtual methods in Iface are static.
public static CppInstancePtr ForManagedObject<Iface,TWrapper> (TWrapper managed)
where Iface : ICppClassOverridable<TWrapper>
{
object cachedImpl;
Iface impl;
if (implCache == null)
implCache = new Dictionary<Type,object> ();
if (!implCache.TryGetValue (typeof (Iface), out cachedImpl))
{
// FIXME: fix this? or not...
//VirtualOnlyAbi virtualABI = new VirtualOnlyAbi (VTable.BindToSignature);
//impl = virtualABI.ImplementClass<Iface> (typeof (TWrapper), new CppLibrary (string.Empty), string.Empty);
//implCache.Add (typeof (Iface), impl);
throw new NotImplementedException ();
}
else
impl = (Iface)cachedImpl;
CppInstancePtr instance = impl.Alloc (managed);
impl.TypeInfo.VTable.InitInstance (ref instance);
return instance;
}
// Alloc a new C++ instance
internal CppInstancePtr (CppTypeInfo typeInfo, object managedWrapper)
{

75
src/Mono.Cxxi/CppObjectMarshaler.cs

@ -1,75 +0,0 @@ @@ -1,75 +0,0 @@
// Author:
// Alexander Corrado (alexander.corrado@gmail.com)
// Andreia Gaita (shana@spoiledcat.net)
//
// Copyright (C) 2010-2011 Alexander Corrado
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Runtime.InteropServices;
namespace Mono.Cxxi {
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 (IntPtr)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;
}
}
}

2
src/Mono.Cxxi/Makefile.am

@ -48,7 +48,6 @@ FILES = \ @@ -48,7 +48,6 @@ FILES = \
Abi/Impl/ItaniumAbi.cs \
Abi/Impl/ItaniumTypeInfo.cs \
Abi/Impl/MsvcAbi.cs \
Abi/Impl/VirtualOnlyAbi.cs \
Abi/MethodType.cs \
Abi/VTable.cs \
AssemblyInfo.cs \
@ -57,7 +56,6 @@ FILES = \ @@ -57,7 +56,6 @@ FILES = \
CppInstancePtr.cs \
CppLibrary.cs \
CppModifiers.cs \
CppObjectMarshaler.cs \
CppType.cs \
CppTypeInfo.cs \
Interfaces.cs \

2
src/Mono.Cxxi/Mono.Cxxi.csproj

@ -67,9 +67,7 @@ @@ -67,9 +67,7 @@
<Compile Include="Abi\VTable.cs" />
<Compile Include="Abi\MethodType.cs" />
<Compile Include="Abi\Impl\ItaniumAbi.cs" />
<Compile Include="Abi\Impl\VirtualOnlyAbi.cs" />
<Compile Include="Abi\Impl\MsvcAbi.cs" />
<Compile Include="CppObjectMarshaler.cs" />
<Compile Include="CppType.cs" />
<Compile Include="CppTypeInfo.cs" />
<Compile Include="Util\IEnumerableTransform.cs" />

Loading…
Cancel
Save