|
|
|
@ -22,7 +22,6 @@ namespace Mono.VisualC.Interop.ABI { |
|
|
|
//FIXME: Exception handling, operator overloading etc.
|
|
|
|
//FIXME: Exception handling, operator overloading etc.
|
|
|
|
//FIXME: Allow interface to override default calling convention
|
|
|
|
//FIXME: Allow interface to override default calling convention
|
|
|
|
public abstract partial class CppAbi { |
|
|
|
public abstract partial class CppAbi { |
|
|
|
|
|
|
|
|
|
|
|
protected ModuleBuilder impl_module; |
|
|
|
protected ModuleBuilder impl_module; |
|
|
|
protected TypeBuilder impl_type; |
|
|
|
protected TypeBuilder impl_type; |
|
|
|
|
|
|
|
|
|
|
|
@ -90,7 +89,6 @@ namespace Mono.VisualC.Interop.ABI { |
|
|
|
var methods = GetMethods (); |
|
|
|
var methods = GetMethods (); |
|
|
|
CppTypeInfo typeInfo = MakeTypeInfo (methods.Where (m => IsVirtual (m))); |
|
|
|
CppTypeInfo typeInfo = MakeTypeInfo (methods.Where (m => IsVirtual (m))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Implement all methods
|
|
|
|
// Implement all methods
|
|
|
|
int vtableIndex = 0; |
|
|
|
int vtableIndex = 0; |
|
|
|
foreach (var method in methods) |
|
|
|
foreach (var method in methods) |
|
|
|
@ -102,7 +100,6 @@ namespace Mono.VisualC.Interop.ABI { |
|
|
|
|
|
|
|
|
|
|
|
ctor_il.Emit (OpCodes.Ret); |
|
|
|
ctor_il.Emit (OpCodes.Ret); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (Iface)Activator.CreateInstance (impl_type.CreateType (), typeInfo); |
|
|
|
return (Iface)Activator.CreateInstance (impl_type.CreateType (), typeInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -225,15 +222,12 @@ namespace Mono.VisualC.Interop.ABI { |
|
|
|
case MethodType.NativeCtor: |
|
|
|
case MethodType.NativeCtor: |
|
|
|
EmitConstruct (il, nativeMethod, parameterTypes, nativePtr); |
|
|
|
EmitConstruct (il, nativeMethod, parameterTypes, nativePtr); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case MethodType.NativeDtor: |
|
|
|
case MethodType.NativeDtor: |
|
|
|
EmitDestruct (il, nativeMethod, parameterTypes, cppInstancePtr, nativePtr); |
|
|
|
EmitDestruct (il, nativeMethod, parameterTypes, cppInstancePtr, nativePtr); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
EmitCallNative (il, nativeMethod, isStatic, parameterTypes, nativePtr); |
|
|
|
EmitCallNative (il, nativeMethod, isStatic, parameterTypes, nativePtr); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
il.Emit (OpCodes.Ret); |
|
|
|
il.Emit (OpCodes.Ret); |
|
|
|
@ -253,7 +247,6 @@ namespace Mono.VisualC.Interop.ABI { |
|
|
|
|
|
|
|
|
|
|
|
// C++ interface properties are either to return the CppTypeInfo or to access C++ fields
|
|
|
|
// C++ interface properties are either to return the CppTypeInfo or to access C++ fields
|
|
|
|
if (retType.IsGenericType && retType.GetGenericTypeDefinition ().Equals (typeof (CppField<>))) { |
|
|
|
if (retType.IsGenericType && retType.GetGenericTypeDefinition ().Equals (typeof (CppField<>))) { |
|
|
|
|
|
|
|
|
|
|
|
// define a new field for the property
|
|
|
|
// define a new field for the property
|
|
|
|
// fieldData = impl_type.DefineField ("__" + propName + "_Data", retType, FieldAttributes.InitOnly | FieldAttributes.Private);
|
|
|
|
// fieldData = impl_type.DefineField ("__" + propName + "_Data", retType, FieldAttributes.InitOnly | FieldAttributes.Private);
|
|
|
|
|
|
|
|
|
|
|
|
@ -366,7 +359,6 @@ namespace Mono.VisualC.Interop.ABI { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected virtual MethodBuilder GetMethodBuilder (MethodInfo interfaceMethod) |
|
|
|
protected virtual MethodBuilder GetMethodBuilder (MethodInfo interfaceMethod) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
Type [] parameterTypes = ReflectionHelper.GetMethodParameterTypes (interfaceMethod); |
|
|
|
Type [] parameterTypes = ReflectionHelper.GetMethodParameterTypes (interfaceMethod); |
|
|
|
MethodBuilder methodBuilder = impl_type.DefineMethod (interfaceMethod.Name, MethodAttributes.Public | MethodAttributes.Virtual, |
|
|
|
MethodBuilder methodBuilder = impl_type.DefineMethod (interfaceMethod.Name, MethodAttributes.Public | MethodAttributes.Virtual, |
|
|
|
interfaceMethod.ReturnType, parameterTypes); |
|
|
|
interfaceMethod.ReturnType, parameterTypes); |
|
|
|
@ -643,9 +635,6 @@ namespace Mono.VisualC.Interop.ABI { |
|
|
|
il.MarkLabel (validRef); |
|
|
|
il.MarkLabel (validRef); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|