Search in sources :

Example 1 with Signature

use of sharpen.xobotos.api.interop.Signature in project XobotOS by xamarin.

the class SharpenGenerator method mappedMethodInvocationArgument.

@Override
public CSExpression mappedMethodInvocationArgument(CSharpBuilder builder, MethodInvocation node, int index, Expression expr) {
    final IMethodBinding binding = node.resolveMethodBinding();
    final NativeMethodBuilder nativeBuilder = my(BindingManager.class).resolveNativeBinding(binding);
    final ITypeBinding[] actualTypes = binding.getParameterTypes();
    final CSExpression mappedExpr = builder.mapExpression(actualTypes[index], expr);
    if (nativeBuilder != null) {
        final Signature signature = nativeBuilder.getNativeMethod().getSignature();
        final ParameterInfo info = signature.getParameterInfo(index);
        if ((info == null) || (info.mode == Mode.REMOVE))
            return null;
        if ((info.marshal == null) || !(info.marshal instanceof MarshalAsClass.Entry))
            return mappedExpr;
        if (CSharpBuilder.isZeroLiteral(expr)) {
            MarshalAsClass.Entry marshal = (MarshalAsClass.Entry) info.marshal;
            if (marshal.getNativeHandle() != null)
                return new CSNullLiteralExpression();
            else
                return new CSReferenceExpression("System.IntPtr.Zero");
        }
    }
    return mappedExpr;
}
Also used : MarshalAsClass(sharpen.xobotos.api.interop.marshal.MarshalAsClass) ParameterInfo(sharpen.xobotos.api.interop.Signature.ParameterInfo) NativeMethodBuilder(sharpen.xobotos.api.interop.NativeMethodBuilder) Signature(sharpen.xobotos.api.interop.Signature)

Aggregations

NativeMethodBuilder (sharpen.xobotos.api.interop.NativeMethodBuilder)1 Signature (sharpen.xobotos.api.interop.Signature)1 ParameterInfo (sharpen.xobotos.api.interop.Signature.ParameterInfo)1 MarshalAsClass (sharpen.xobotos.api.interop.marshal.MarshalAsClass)1