use of sharpen.xobotos.api.interop.NativeHandle 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;
}
use of sharpen.xobotos.api.interop.NativeHandle in project XobotOS by xamarin.
the class SharpenGenerator method mappedMethodInvocation.
@Override
public CSExpression mappedMethodInvocation(CSharpBuilder builder, MethodInvocation node) {
final IMethodBinding binding = node.resolveMethodBinding();
final ITypeBinding declaringType = binding.getDeclaringClass();
final AbstractTypeBinding typeBinding = my(BindingManager.class).resolveBinding(declaringType);
final MethodBinding methodBinding = my(BindingManager.class).resolveBinding(binding);
if (typeBinding instanceof EnumBinding) {
EnumBinding enumBinding = (EnumBinding) typeBinding;
String ctorMethod = enumBinding.getConstructorMethod();
if ((ctorMethod != null) && node.getName().toString().equals(ctorMethod)) {
return builder.mapExpression(declaringType, (Expression) node.arguments().get(0));
}
}
if (methodBinding != null) {
NativeHandle nh = methodBinding.getNativeHandle();
if (nh != null) {
CSExpression expr = builder.mapExpression(declaringType, node.getExpression());
String member = nh.getProperty() != null ? nh.getProperty() : nh.getField();
return new CSMemberReferenceExpression(expr, member);
}
}
if (_currentMethod != null)
_currentMethod.checkInvocationTarget(binding);
return null;
}
Aggregations