use of sharpen.xobotos.output.OutputType in project XobotOS by xamarin.
the class SharpenGenerator method getOutputType.
private OutputType getOutputType() {
for (int i = _outputProviderStack.size() - 1; i >= 0; i--) {
IOutputProvider provider = _outputProviderStack.get(i);
if (provider == null)
continue;
OutputType type = provider.getOutputType();
if (type != null)
return type;
}
return OutputType.NAKED_STUB;
}
use of sharpen.xobotos.output.OutputType 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.OutputType 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.OutputType 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.OutputType in project XobotOS by xamarin.
the class AbstractTemplate method visit.
protected <T extends ASTNode, U extends CSNode, V extends AbstractMemberTemplate<T, U>> boolean visit(TemplateVisitor visitor, List<V> list, T member) {
if (list == null)
return true;
for (final V template : list) {
Match match = template.matches(member);
if (match == Match.NO_MATCH)
continue;
else if (match == Match.NEGATIVE)
return false;
OutputType output = template.getOutputType();
if ((output != null) && (output.getModeForMember(member) == OutputMode.NOTHING))
return false;
visitor.accept(template);
return true;
}
return true;
}
Aggregations