Search in sources :

Example 1 with VariableBinding

use of sharpen.xobotos.api.bindings.VariableBinding in project XobotOS by xamarin.

the class SharpenGenerator method mappedVariableType.

@Override
public CSTypeReferenceExpression mappedVariableType(IVariableBinding binding) {
    if (binding == null)
        return null;
    VariableBinding variable = my(BindingManager.class).resolveBinding(binding);
    if (variable == null)
        return null;
    NativeHandle nh = variable.getNativeHandle();
    if (nh != null)
        return nh.getManagedType();
    if (variable.isPointer())
        return new CSTypeReference("System.IntPtr");
    if (variable.modifyType() != null)
        return variable.modifyType().getExpression();
    return null;
}
Also used : NativeHandle(sharpen.xobotos.api.interop.NativeHandle) VariableBinding(sharpen.xobotos.api.bindings.VariableBinding)

Example 2 with VariableBinding

use of sharpen.xobotos.api.bindings.VariableBinding in project XobotOS by xamarin.

the class SharpenGenerator method mappedNullPointer.

@Override
public CSExpression mappedNullPointer(Expression expr) {
    VariableBinding variable = lookupVariableBinding(expr);
    if (variable != null) {
        if (variable.getNativeHandle() != null)
            return new CSNullLiteralExpression();
        if (variable.isPointer())
            return new CSReferenceExpression("System.IntPtr.Zero");
        return null;
    }
    if (expr instanceof MethodInvocation) {
        IMethodBinding method = ((MethodInvocation) expr).resolveMethodBinding();
        MethodBinding binding = my(BindingManager.class).resolveBinding(method);
        if (binding == null)
            return null;
        if (binding.getNativeHandle() != null)
            return new CSNullLiteralExpression();
    }
    return null;
}
Also used : MethodBinding(sharpen.xobotos.api.bindings.MethodBinding) VariableBinding(sharpen.xobotos.api.bindings.VariableBinding)

Aggregations

VariableBinding (sharpen.xobotos.api.bindings.VariableBinding)2 MethodBinding (sharpen.xobotos.api.bindings.MethodBinding)1 NativeHandle (sharpen.xobotos.api.interop.NativeHandle)1