use of sharpen.xobotos.output.OutputMode in project XobotOS by xamarin.
the class SharpenGenerator method processMethodDeclaration.
@Override
public CSMethodBase processMethodDeclaration(CSharpBuilder csharpBuilder, CSTypeDeclaration parent, MethodDeclaration node, IMethodBuilderDelegate delegate) {
final ITypeBuilder type = _typeStack.peek();
final AbstractMethodTemplate<?> template = type.findMethodTemplate(node);
if (template == null)
return null;
try {
_outputProviderStack.push(template);
final OutputType output = getOutputType();
final OutputMode mode = output.getModeForMember(node);
if (mode == OutputMode.NOTHING)
return null;
MethodBinding binding = template.getBinding();
if ((binding != null) && (binding.getNativeHandle() != null))
return null;
AbstractMethodBuilder<?, ?> builder;
if (node.isConstructor())
builder = new ConstructorBuilder((ConstructorTemplate) template, output, node);
else if (template instanceof DestructorTemplate)
builder = new DestructorBuilder((DestructorTemplate) template, output, node);
else
builder = new MethodBuilder(type, (MethodTemplate) template, output, node, _builder.getNativeBuilder());
type.registerMember(node, builder);
_currentMethod = builder;
CSMethodBase method = builder.build(csharpBuilder, delegate);
_currentMethod = null;
if (method != null) {
delegate.fixup(parent, method);
parent.addMember(method);
if (method instanceof CSMethod)
registerMethod(node.resolveBinding(), (CSMethod) method);
}
return method;
} finally {
_outputProviderStack.pop();
}
}
use of sharpen.xobotos.output.OutputMode in project XobotOS by xamarin.
the class SharpenGenerator method processEnumDeclaration.
@Override
public CSEnum processEnumDeclaration(CSharpBuilder csharpBuilder, CSTypeContainer parent, EnumDeclaration node, IEnumBuilderDelegate delegate) {
final EnumTemplate template = findEnumTemplate(node);
if (template == null)
return null;
try {
_outputProviderStack.push(template);
final OutputType output = getOutputType();
final OutputMode mode;
if (node.resolveBinding().isNested())
mode = output.getModeForMember(node);
else
mode = output.getMode();
if (mode == OutputMode.NOTHING)
return null;
EnumBuilder builder = new EnumBuilder(template, output, node);
CSEnum theEnum = builder.build(csharpBuilder, delegate);
if (theEnum != null)
parent.addType(theEnum);
return theEnum;
} finally {
_outputProviderStack.pop();
}
}
use of sharpen.xobotos.output.OutputMode in project XobotOS by xamarin.
the class SharpenGenerator method processFieldDeclaration.
@Override
public CSField processFieldDeclaration(CSharpBuilder csharpBuilder, CSTypeDeclaration parent, FieldDeclaration node, VariableDeclarationFragment fragment, IFieldBuilderDelegate delegate) {
final ITypeBuilder type = _typeStack.peek();
final FieldTemplate template = type.getTypeTemplate().findFieldTemplate(node);
if (template == null)
return null;
try {
_outputProviderStack.push(template);
final OutputType output = getOutputType();
final OutputMode mode = output.getModeForMember(node);
if (mode == OutputMode.NOTHING)
return null;
FieldBuilder builder = new FieldBuilder(template, output, node, fragment);
type.registerMember(node, builder);
CSField field = builder.build(csharpBuilder, delegate);
if (field != null)
parent.addMember(field);
return field;
} finally {
_outputProviderStack.pop();
}
}
use of sharpen.xobotos.output.OutputMode in project XobotOS by xamarin.
the class SharpenGenerator method processTypeDeclaration.
@Override
public CSTypeDeclaration processTypeDeclaration(CSharpBuilder csharpBuilder, CSTypeContainer parent, TypeDeclaration node, ITypeBuilderDelegate delegate) {
final TypeTemplate template = findTypeTemplate(node);
if (template == null)
return null;
final ITypeBinding typeBinding = node.resolveBinding();
final AbstractTypeBinding binding = my(BindingManager.class).resolveBinding(typeBinding);
if ((binding != null) && (binding.getMapping() != null))
return null;
try {
_outputProviderStack.push(template);
final OutputType output = getOutputType();
final OutputMode mode;
if (node.resolveBinding().isNested())
mode = output.getModeForMember(node);
else
mode = output.getMode();
CSTypeDeclaration type;
if (mode == OutputMode.NOTHING)
return null;
else if (mode == OutputMode.NAKED_STUB) {
type = delegate.create();
generateNakedStub(csharpBuilder, node, type);
parent.addType(type);
return type;
}
TypeBuilder builder = new TypeBuilder(template, output, node);
_typeStack.push(builder);
type = builder.build(csharpBuilder, delegate);
if (type != null) {
registerType(typeBinding, type);
parent.addType(type);
}
_typeStack.pop();
return type;
} finally {
_outputProviderStack.pop();
}
}
use of sharpen.xobotos.output.OutputMode in project XobotOS by xamarin.
the class SharpenGenerator method processExtractedEnumDeclaration.
@Override
public CSTypeDeclaration processExtractedEnumDeclaration(CSharpBuilder csharpBuilder, CSTypeContainer parent, EnumDeclaration node, ITypeBuilderDelegate delegate) {
final EnumTemplate template = findEnumTemplate(node);
if (template == null)
return null;
final ITypeBinding typeBinding = node.resolveBinding();
final AbstractTypeBinding binding = my(BindingManager.class).resolveBinding(typeBinding);
if ((binding != null) && (binding.getMapping() != null))
return null;
try {
_outputProviderStack.push(template);
final OutputType output = getOutputType();
final OutputMode mode;
if (node.resolveBinding().isNested())
mode = output.getModeForMember(node);
else
mode = output.getMode();
CSTypeDeclaration type;
if ((mode == OutputMode.NOTHING) || (mode == OutputMode.NAKED_STUB))
return null;
ExtractedEnumBuilder builder = new ExtractedEnumBuilder(template, output, node);
_typeStack.push(builder);
type = builder.build(csharpBuilder, delegate);
if (type != null)
parent.addType(type);
_typeStack.pop();
return type;
} finally {
_outputProviderStack.pop();
}
}
Aggregations