Search in sources :

Example 1 with NamespaceTemplate

use of sharpen.xobotos.api.templates.NamespaceTemplate in project XobotOS by xamarin.

the class APIDefinition method compilationUnitDefinesBindings.

public boolean compilationUnitDefinesBindings(String unitName) {
    final ByRef<Boolean> result = new ByRef<Boolean>(false);
    TemplateVisitor visitor = new TemplateVisitor() {

        @Override
        public void accept(AbstractTemplate template) {
            if (template instanceof IBindingProvider) {
                IBindingProvider provider = (IBindingProvider) template;
                if (provider.getBinding() != null)
                    result.value = true;
            }
            if (template instanceof TypeTemplate) {
                TypeTemplate type = (TypeTemplate) template;
                if (type.getNativeType() != null)
                    result.value = true;
                else if (type.getNativeStruct() != null)
                    result.value = true;
            }
        }
    };
    for (final NamespaceTemplate def : getNamespaces()) {
        def.visit(visitor, unitName, VisitMode.All);
    }
    return result.value;
}
Also used : ByRef(sharpen.core.framework.ByRef) AbstractTemplate(sharpen.xobotos.api.templates.AbstractTemplate) IBindingProvider(sharpen.xobotos.api.bindings.IBindingProvider) TypeTemplate(sharpen.xobotos.api.templates.TypeTemplate) NamespaceTemplate(sharpen.xobotos.api.templates.NamespaceTemplate)

Example 2 with NamespaceTemplate

use of sharpen.xobotos.api.templates.NamespaceTemplate in project XobotOS by xamarin.

the class APIDefinition method findCompilationUnitTemplate.

public CompilationUnitTemplate findCompilationUnitTemplate(CompilationUnitPair pair) {
    final String fullName = getUnitName(pair.source);
    final ByRef<CompilationUnitTemplate> result = new ByRef<CompilationUnitTemplate>(null);
    TemplateVisitor visitor = new TemplateVisitor() {

        @Override
        public void accept(CompilationUnitTemplate template) {
            result.value = template;
        }
    };
    for (final NamespaceTemplate def : getNamespaces()) {
        if (def.visit(visitor, fullName, VisitMode.FirstMatch))
            break;
    }
    return result.value;
}
Also used : CompilationUnitTemplate(sharpen.xobotos.api.templates.CompilationUnitTemplate) ByRef(sharpen.core.framework.ByRef) NamespaceTemplate(sharpen.xobotos.api.templates.NamespaceTemplate)

Example 3 with NamespaceTemplate

use of sharpen.xobotos.api.templates.NamespaceTemplate in project XobotOS by xamarin.

the class APIDefinition method preprocess.

public CompilationUnitBuilder preprocess(CompilationUnitPair pair) {
    final String fullName = getUnitName(pair.source);
    final ByRef<IOutputProvider> defaultOutput = new ByRef<IOutputProvider>(null);
    final ByRef<CompilationUnitTemplate> unitTemplate = new ByRef<CompilationUnitTemplate>(CompilationUnitTemplate.DEFAULT);
    TemplateVisitor visitor = new TemplateVisitor() {

        @Override
        public void accept(NamespaceTemplate template) {
            if (defaultOutput.value != null)
                return;
            if (template.getOutputType() != null)
                defaultOutput.value = template;
        }

        @Override
        public void accept(CompilationUnitTemplate template) {
            unitTemplate.value = template;
        }
    };
    for (final NamespaceTemplate def : getNamespaces()) {
        if (def.visit(visitor, fullName, VisitMode.FirstMatch))
            break;
    }
    return my(BindingManager.class).preprocess(pair, unitTemplate.value, fullName, defaultOutput.value);
}
Also used : BindingManager(sharpen.xobotos.api.bindings.BindingManager) CompilationUnitTemplate(sharpen.xobotos.api.templates.CompilationUnitTemplate) ByRef(sharpen.core.framework.ByRef) IOutputProvider(sharpen.xobotos.output.IOutputProvider) NamespaceTemplate(sharpen.xobotos.api.templates.NamespaceTemplate)

Aggregations

ByRef (sharpen.core.framework.ByRef)3 NamespaceTemplate (sharpen.xobotos.api.templates.NamespaceTemplate)3 CompilationUnitTemplate (sharpen.xobotos.api.templates.CompilationUnitTemplate)2 BindingManager (sharpen.xobotos.api.bindings.BindingManager)1 IBindingProvider (sharpen.xobotos.api.bindings.IBindingProvider)1 AbstractTemplate (sharpen.xobotos.api.templates.AbstractTemplate)1 TypeTemplate (sharpen.xobotos.api.templates.TypeTemplate)1 IOutputProvider (sharpen.xobotos.output.IOutputProvider)1