Search in sources :

Example 6 with OutputType

use of sharpen.xobotos.output.OutputType 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();
    }
}
Also used : OutputMode(sharpen.xobotos.output.OutputMode) OutputType(sharpen.xobotos.output.OutputType)

Example 7 with OutputType

use of sharpen.xobotos.output.OutputType in project XobotOS by xamarin.

the class SharpenGenerator method processPropertyDeclaration.

@Override
public CSProperty processPropertyDeclaration(CSharpBuilder csharpBuilder, CSTypeDeclaration parent, MethodDeclaration node, String name, CSProperty property, IPropertyBuilderDelegate delegate) {
    final ITypeBuilder type = _typeStack.peek();
    final PropertyTemplate template = type.getTypeTemplate().findPropertyTemplate(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;
        PropertyBuilder builder = new PropertyBuilder(template, output, node);
        type.registerMember(node, builder);
        boolean existing = property != null;
        property = builder.build(csharpBuilder, delegate);
        if (!existing)
            parent.addMember(property);
        return property;
    } finally {
        _outputProviderStack.pop();
    }
}
Also used : OutputMode(sharpen.xobotos.output.OutputMode) OutputType(sharpen.xobotos.output.OutputType)

Example 8 with OutputType

use of sharpen.xobotos.output.OutputType in project XobotOS by xamarin.

the class SharpenGenerator method processAnonymousClass.

@Override
public CSAnonymousClass processAnonymousClass(CSharpBuilder csharpBuilder, CSTypeContainer parent, AnonymousClassDeclaration node, IAnonymousClassBuilderDelegate delegate) {
    final TypeTemplate typeTemplate = _typeStack.peek().getTypeTemplate();
    final AnonymousClassTemplate template = typeTemplate.findAnonymousClassTemplate(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;
        AnonymousClassBuilder builder = new AnonymousClassBuilder(template, output, node);
        _typeStack.push(builder);
        CSAnonymousClass type = builder.build(csharpBuilder, delegate);
        if (type != null)
            parent.addType(type.type());
        _typeStack.pop();
        return type;
    } finally {
        _outputProviderStack.pop();
    }
}
Also used : OutputMode(sharpen.xobotos.output.OutputMode) OutputType(sharpen.xobotos.output.OutputType)

Example 9 with OutputType

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;
}
Also used : Match(sharpen.xobotos.config.LocationFilter.Match) OutputType(sharpen.xobotos.output.OutputType)

Aggregations

OutputType (sharpen.xobotos.output.OutputType)9 OutputMode (sharpen.xobotos.output.OutputMode)7 MethodBinding (sharpen.xobotos.api.bindings.MethodBinding)1 NativeMethodBuilder (sharpen.xobotos.api.interop.NativeMethodBuilder)1 Match (sharpen.xobotos.config.LocationFilter.Match)1 IOutputProvider (sharpen.xobotos.output.IOutputProvider)1